omdl  v1.0
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 and/or Modules

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, 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.
 

Usage Details

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 polyhedra data set, include the specific table of interest rather than polyhedra_all.scad, as shown in the following example. For a list of those available, see the polyhedra database section.

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])
rotate([90, 0, 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.
function ph_db_get_id(n, tr=ph_db_dtr)
Get data table identifier name (or names).
module ph_db_polyhedron(id, size, align, tr=ph_db_dtr, tc=ph_db_dtc)
Construct a named polyhedron.
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

Function and/or Module Documentation

◆ 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
+ Here is the caller graph for this function:

◆ 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().

+ Here is the caller graph for this function:

◆ ph_db_polyhedron()

module ph_db_polyhedron ( id  ,
size  ,
align  ,
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).
tr<table> The polyhedra data table rows.
tc<map> The polyhedra data table columns.

The polyhedron is constructed at the origin and can be repositioned using align. Each axis is aligned independently, with 0 indicating the center, +1 the positive bounds, and -1 the negative bounds. Fractional alignments and alignment values with magnitudes greater than 1 are also supported.

align value description
0 align at bounding box center
-1 align axis at lower shape bounds
+1 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, h1, 10];
h2 = 5; s2 = 2;
h3 = 3; s3 = [15, h3, 15];
translate([0, 0, h1])
{
rotate([90,0,0])
ph_db_polyhedron( id=ph_db_get_id(65), size=s1, align=[0,-1,0] );
rotate(-360/4/$fn)
cylinder(r=s2, h=h2);
translate([0, 0, h2]) mirror([0,0,1]) rotate([90,0,0])
ph_db_polyhedron( id=ph_db_get_id(41), size=s3, align=[0,-1,0] );
}
// 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 554 of file polyhedron_db.scad.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: