omdl  v0.6.1
OpenSCAD Mechanical Design Library
Tables

Table data type operations. More...

+ Collaboration diagram for Tables:

Files

file  datatypes_table.scad
 Table data type operations.
 

Functions

function get_table_ri (r, ri)
 Get the table row index that matches a table row identifier. More...
 
function get_table_r (r, ri)
 Get the table row that matches a table row identifier. More...
 
function get_table_ci (c, ci)
 Get the table column index that matches a table column identifier. More...
 
function get_table_c (c, ci)
 Get the table column that matches a table column identifier. More...
 
function get_table_v (r, c, ri, ci)
 Get the table cell value for a specified row and column identifier. More...
 
function get_table_crl (r, c, ci)
 Form a list of a select column across all table rows. More...
 
function get_table_ridl (r)
 Form a list of all table row identifiers. More...
 
function get_table_cidl (c)
 Form a list of all table column identifiers. More...
 
function table_exists (r, c, ri, ci)
 Test the existence of a table row and column identifier. More...
 
function get_table_size (r, c)
 Get the size of a table. More...
 
function get_table_copy (r, c, rl, cl)
 Create a new matrix from select rows and columns of a table. More...
 
function get_table_sum (r, c, rl, cl)
 Sum select rows and columns of a table. More...
 
module table_check (r, c, verbose=false)
 Perform some basic validation/checks on a table. More...
 
module table_dump (r, c, rl, cl, number=true)
 Dump a table to the console. More...
 

Detailed Description

Table data type operations.

Example

Result

ECHO: "[ INFO ] table_check(); begin table check"
ECHO: "[ INFO ] table_check(); row identifier found at column zero."
ECHO: "[ INFO ] table_check(); checking row column counts."
ECHO: "[ INFO ] table_check(); checking for repeat column identifiers."
ECHO: "[ INFO ] table_check(); checking for repeat row identifiers."
ECHO: "[ INFO ] table_check(); table size: 4 rows by 8 columns."
ECHO: "[ INFO ] table_check(); end table check"
ECHO: ""
ECHO: "row: 0"
ECHO: "[m3r08r] [id] (row identifier) = [m3r08r]"
ECHO: "[m3r08r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r08r] [td] (thread diameter) = [3]"
ECHO: "[m3r08r] [tl] (thread length) = [8]"
ECHO: "[m3r08r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r08r] [hl] (head length) = [3]"
ECHO: "[m3r08r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r08r] [nl] (hex nut length) = [25.4]"
ECHO: ""
ECHO: "row: 1"
ECHO: "[m3r14r] [id] (row identifier) = [m3r14r]"
ECHO: "[m3r14r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r14r] [td] (thread diameter) = [3]"
ECHO: "[m3r14r] [tl] (thread length) = [14]"
ECHO: "[m3r14r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r14r] [hl] (head length) = [3]"
ECHO: "[m3r14r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r14r] [nl] (hex nut length) = [31.75]"
ECHO: ""
ECHO: "row: 2"
ECHO: "[m3r16r] [id] (row identifier) = [m3r16r]"
ECHO: "[m3r16r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r16r] [td] (thread diameter) = [3]"
ECHO: "[m3r16r] [tl] (thread length) = [16]"
ECHO: "[m3r16r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r16r] [hl] (head length) = [3]"
ECHO: "[m3r16r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r16r] [nl] (hex nut length) = [38.1]"
ECHO: ""
ECHO: "row: 3"
ECHO: "[m3r20r] [id] (row identifier) = [m3r20r]"
ECHO: "[m3r20r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r20r] [td] (thread diameter) = [3]"
ECHO: "[m3r20r] [tl] (thread length) = [20]"
ECHO: "[m3r20r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r20r] [hl] (head length) = [3]"
ECHO: "[m3r20r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r20r] [nl] (hex nut length) = [44.45]"
ECHO: ""
ECHO: "table size: 4 rows by 8 columns."
ECHO: "metric 'nl' available"
ECHO: table_ids = ["m3r08r", "m3r14r", "m3r16r", "m3r20r"]
ECHO: table_cols_tl = [8, 14, 16, 20]
ECHO: m3r16r_tl = 16
ECHO: tnew = [[8, 25.4], [14, 31.75], [16, 38.1], [20, 44.45]]
ECHO: tsum = [58, 139.7]

Function Documentation

function get_table_c ( ,
ci   
)

Get the table column that matches a table column identifier.

Parameters
c<matrix-2xC> The table column matrix (2 x C-columns).
ci<string> The column identifier.
Returns
<list-2> The table column where the column identifier exists. If the identifier does not exists, returns undef.
function get_table_ci ( ,
ci   
)

Get the table column index that matches a table column identifier.

Parameters
c<matrix-2xC> The table column matrix (2 x C-columns).
ci<string> The column identifier.
Returns
<integer> The column index where the identifier exists. If the identifier does not exists, returns empty_lst.
function get_table_cidl ( )

Form a list of all table column identifiers.

Parameters
c<matrix-2xC> The table column matrix (2 x C-columns).
Returns
<list> The list of all column identifiers.
Note
This functions assumes the first element of each table column to be the column identifier.
function get_table_copy ( ,
,
rl  ,
cl   
)

Create a new matrix from select rows and columns of a table.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
rl<string-list> A list of selected row identifiers.
cl<string-list> A list of selected column identifiers.
Returns
<matrix> A matrix of the selected rows and columns.
function get_table_crl ( ,
,
ci   
)

Form a list of a select column across all table rows.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
ci<string> The column identifier.
Returns
<list> The list of a select column across all rows. If the identifier does not exists, returns undef.
function get_table_r ( ,
ri   
)

Get the table row that matches a table row identifier.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
ri<string> The row identifier.
Returns
<list-C> The table row where the row identifier exists. If the identifier does not exists, returns undef.
function get_table_ri ( ,
ri   
)

Get the table row index that matches a table row identifier.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
ri<string> The row identifier.
Returns
<integer> The row index where the identifier exists. If the identifier does not exists, returns empty_lst.

+ Here is the caller graph for this function:

function get_table_ridl ( )

Form a list of all table row identifiers.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
Returns
<list> The list of all row identifiers.
Note
This functions assumes the first element of each table row to be the row identifier, as enforced by the table_check(). As an alternative, the function get_table_crl(), of the form get_table_crl(r, c, "id"), may be used without this assumption.
function get_table_size ( ,
 
)

Get the size of a table.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
Returns
<decimal> The table size.

The size is reported as: (1) The number of rows when only the r parameter is specified. (2) The number of columns when only the c parameter is specified. (3) The (r * columns) when both parameters are specified.

+ Here is the caller graph for this function:

function get_table_sum ( ,
,
rl  ,
cl   
)

Sum select rows and columns of a table.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
rl<string-list> A list of selected row identifiers.
cl<string-list> A list of selected column identifiers.
Returns
<list> A list with the sum of each selected rows and columns.
function get_table_v ( ,
,
ri  ,
ci   
)

Get the table cell value for a specified row and column identifier.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
ri<string> The row identifier.
ci<string> The column identifier.
Returns
<value> The value of the matrix cell [ri, ci]. If either identifier does not exists, returns undef.

+ Here is the caller graph for this function:

module table_check ( ,
,
verbose  = false 
)

Perform some basic validation/checks on a table.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
verbose<boolean> Be verbose during check.

Check that: (1) the first table column identifier is 'id'. (2) Make sure that each row has the same number of columns as defined in the columns vector. (3) Make sure that there are no repeating column identifiers. (4) Make sure that there are no repeating row identifiers.

Definition at line 297 of file datatypes_table.scad.

+ Here is the call graph for this function:

module table_dump ( ,
,
rl  ,
cl  ,
number  = true 
)

Dump a table to the console.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
rl<string-list> A list of selected row identifiers.
cl<string-list> A list of selected column identifiers.
number<boolean> Number the table rows.

Output each table row to the console. To output only select rows and columns, assign the desired identifiers to rl and cl. For example to output only the column identifiers 'c1' and 'c2', assign cl = ["c1", "c2"].

Definition at line 377 of file datatypes_table.scad.

+ Here is the call graph for this function:

function table_exists ( ,
,
ri  ,
ci   
)

Test the existence of a table row and column identifier.

Parameters
r<matrix-CxR> The table data matrix (C-columns x R-rows).
c<matrix-2xC> The table column matrix (2 x C-columns).
ri<string> The row identifier.
ci<string> The column identifier.
Returns
true if the row and column identifier exists, and false otherwise.