Add model to type system
This commit is contained in:
@@ -2,8 +2,8 @@ include <cube.scad>;
|
||||
include <cylinder.scad>;
|
||||
include <draw.scad>;
|
||||
include <math.scad>;
|
||||
include <model.scad>;
|
||||
include <obj_util.scad>;
|
||||
include <sphere.scad>;
|
||||
include <struct.scad>;
|
||||
include <translate.scad>;
|
||||
include <types.scad>;
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
/// model:
|
||||
/// kKeyPoints "points" fPoints(): [ [x, y, z], ... ]
|
||||
/// kKeyFaces "faces" fFaces(): [ [ pointIdx, ... ], ... ]
|
||||
/// fKeyType "type" fType(): fTypeModel "model"
|
||||
/// fKeyPoints "points" fPoints(): [ [x, y, z], ... ]
|
||||
/// fKeyFaces "faces" fFaces(): [ [ pointIdx, ... ], ... ]
|
||||
|
||||
fTypeModel = "model";
|
||||
|
||||
function fIsModel(x) = (
|
||||
fType(x) == fTypeModel
|
||||
);
|
||||
|
||||
fKeyPoints = "points";
|
||||
fKeyFaces = "faces";
|
||||
|
||||
function fModel(points, faces) = (
|
||||
[
|
||||
[fKeyType, fTypeModel],
|
||||
[fKeyPoints, points],
|
||||
[fKeyFaces, faces],
|
||||
]
|
||||
@@ -1,3 +1,5 @@
|
||||
fKeyType = "type";
|
||||
|
||||
fTypeUndef = "undef";
|
||||
fTypeInt = "int";
|
||||
fTypeFloat = "float";
|
||||
@@ -12,6 +14,7 @@ function fType(x) = (
|
||||
: abs(x) + 1 > abs(x) ? fTypeFloat
|
||||
: str(x) == x ? fTypeString
|
||||
: str(x) == "false" || str(x) == "true" ? fTypeBoolean
|
||||
: fMapLookup(fKeyType, x) ? fMapLookup(fKeyType, x)
|
||||
: (x[0] == x[0]) && len(x) != undef ? fTypeVector
|
||||
: fTypeUnknown
|
||||
);
|
||||
@@ -40,6 +43,7 @@ function fIsVector(x) = (
|
||||
fType(x) == fTypeVector
|
||||
);
|
||||
|
||||
// Helpers
|
||||
function fMapLookup(key, model) = (
|
||||
[for (pair = model)
|
||||
let (iter_key = pair[0],
|
||||
|
||||
Reference in New Issue
Block a user