omdl  v0.9.5
OpenSCAD Mechanical Design Library
Polyhedrons db

Sizable polyhedra generated from shape database. More...

+ Collaboration diagram for Polyhedrons db:

Files

file  polyhedron_db.scad
 Sizable polyhedra generated from shape database.
 

Functions

function ph_db_get_size (tr=ph_db_dtr)
 Get the number of shape identifiers in data table. More...
 
function ph_db_get_id (n, tr=ph_db_dtr)
 Get data table identifier name (or names). More...
 
module ph_db_polyhedron (id, size, align, yz=true, tr=ph_db_dtr, tc=ph_db_dtc)
 Construct a named polyhedron. More...
 

Variables

 ph_db_dtc = dtc_polyhedra_polyhedra_all
 <map> The default polyhedra data table columns.
 
 ph_db_dtr = dtr_polyhedra_polyhedra_all
 <table> The default polyhedra data table rows.
 

Detailed Description

Sizable polyhedra generated from shape database.

Requires:
include <omdl-base.scad>;
include <database/geometry/polyhedra/polyhedra_all.scad>;
include <shapes/polyhedron_db.scad>;

To work with a smaller data table set, include the specific table of interest rather than polyhedra_all.scad, shown as required above. Here is an example that uses a limited set.

Cupolas example script

include <omdl-base.scad>;
include <database/geometry/polyhedra/cupolas.scad>;
include <shapes/polyhedron_db.scad>;
gx = ceil( sqrt( ph_db_get_size() ) );
gy = gx;
sx = 2.25;
sy = sx;
for ( i = [ 1 : ph_db_get_size() ] )
translate([sx * (i%gx), sy * (floor(i/gx)%gy), 0])
// end_include
dtc_polyhedra_cupolas
Definition: cupolas.scad:197
dtr_polyhedra_cupolas
Definition: cupolas.scad:212
function ph_db_get_size(tr=ph_db_dtr)
Get the number of shape identifiers in data table.
module ph_db_polyhedron(id, size, align, yz=true, tr=ph_db_dtr, tc=ph_db_dtc)
Construct a named polyhedron.
function ph_db_get_id(n, tr=ph_db_dtr)
Get data table identifier name (or names).
ph_db_dtc
<map> The default polyhedra data table columns.
ph_db_dtr
<table> The default polyhedra data table rows.

Cupolas example diagram
topbottomdiag
expand topexpand bottomexpand diag

For a list of all available polyhedra, see the polyhedra datbase.

Function Documentation

◆ ph_db_get_id()

function ph_db_get_id ( ,
tr  = ph_db_dtr 
)

Get data table identifier name (or names).

Parameters
n<integer> An index number.
tr<table> The polyhedra data table rows.
Returns
<string | string-list> The identifier name at index n or the list of all identifier names for n = 0.

Identifiers numbering start from 1 and end at ph_db_get_size().

◆ ph_db_get_size()

function ph_db_get_size ( tr  = ph_db_dtr)

Get the number of shape identifiers in data table.

Parameters
tr<table> The polyhedra data table rows.
Returns
<integer> The total number of identifiers

◆ ph_db_polyhedron()

module ph_db_polyhedron ( id  ,
size  ,
align  ,
yz  = true,
tr  = ph_db_dtr,
tc  = ph_db_dtc 
)

Construct a named polyhedron.

Parameters
id<string> The polyhedron identifier name.
size<decimal-list-3 | decimal> A list [x, y, z] of decimals or a single decimal for (x=y=z).
align<decimal-list-3 | decimal> A list [x, y, z] of decimals or a single decimal for (x=y=z).
yz<boolean> An internal dataset rotation control variable.
tr<table> The polyhedra data table rows.
tc<map> The polyhedra data table columns.

Each axis may be assigned an alignment value of 0, 1 or 2 as summarized in the following table.

align value description
0 do not align axis
1 align axis at lower shape bounds
2 align axis at upper shape bounds

Using this module, polyhedron can be incorporated into designs as shown in this simple example.

Design example script

include <omdl-base.scad>;
include <database/geometry/polyhedra/johnson.scad>;
include <shapes/polyhedron_db.scad>;
$fn = 5;
// shape sizes
h1 = 1; s1 = [10, 10, h1];
h2 = 5; s2 = 2;
h3 = 3; s3 = [15, 15, h3];
translate([0, 0, h1])
{
ph_db_polyhedron( id=ph_db_get_id(65), size=s1, align=[0,0,2] );
rotate(-360/4/$fn)
cylinder(r=s2, h=h2);
translate([0, 0, h2]) mirror([0,0,1])
ph_db_polyhedron( id=ph_db_get_id(41), size=s3, align=[0,0,2] );
}
// end_include
dtr_polyhedra_johnson
Definition: johnson.scad:212
dtc_polyhedra_johnson
Definition: johnson.scad:197

Design example diagram
frontdiag
expand frontexpand diag

Definition at line 553 of file polyhedron_db.scad.

+ Here is the call graph for this function: