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