stack3js 0.0.0-stage → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMMAND.md +145 -0
- package/LICENSE +21 -0
- package/README.md +304 -2
- package/THIRD-PARTY-LICENSES.md +100 -0
- package/bin/stack3.mjs +5437 -0
- package/blender/import_stack.py +89 -0
- package/examples/future-tank.stack3.json +1 -0
- package/examples/traffic-cone-4view.png +0 -0
- package/meshing/blocks.py +82 -0
- package/meshing/branches.py +62 -0
- package/meshing/dexel.py +67 -0
- package/meshing/field_data.py +19 -0
- package/meshing/finish_blender.py +203 -0
- package/meshing/finishing.py +155 -0
- package/meshing/geometry.py +71 -0
- package/meshing/guided.py +150 -0
- package/meshing/implicit.py +178 -0
- package/meshing/intersection.py +33 -0
- package/meshing/material.py +115 -0
- package/meshing/mesh.py +103 -0
- package/meshing/network.py +136 -0
- package/meshing/regularization.py +213 -0
- package/meshing/sections.py +165 -0
- package/meshing/signed_distance.py +93 -0
- package/package.json +32 -4
- package/references/hard-surface/README.md +40 -0
- package/references/hard-surface/atlas/concrete-barrier-4view.png +0 -0
- package/references/hard-surface/atlas/preview.pipeline.yaml +14 -0
- package/references/hard-surface/case-studies/benchmark/README.md +22 -0
- package/references/hard-surface/case-studies/benchmark/lod-bevel.pipeline.yaml +258 -0
- package/references/hard-surface/finishing/exports.yaml +10 -0
- package/references/hard-surface/finishing/finish-lod.pipeline.yaml +33 -0
- package/references/hard-surface/finishing/inputs/stack/stack.json +1 -0
- package/references/hard-surface/finishing/inputs/stack/stack.png +0 -0
- package/references/hard-surface/finishing/regularize.pipeline.yaml +46 -0
- package/references/hard-surface/measured-depth/sdf/compare.pipeline.yaml +12 -0
- package/references/hard-surface/measured-depth/sdf/inputs/field.npy +0 -0
- package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.json +1 -0
- package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.png +0 -0
- package/references/hard-surface/measured-depth/sdf/inputs/truth.json +1 -0
- package/references/hard-surface/measured-depth/sdf/sdf.guide.json +3 -0
- package/references/hard-surface/measured-depth/triple-dexel/compare.pipeline.yaml +12 -0
- package/references/hard-surface/measured-depth/triple-dexel/dexel.guide.json +3 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/fixture.json +22 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.json +22 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.png +0 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/triple-dexel.npz +0 -0
- package/references/hard-surface/schema/pipeline-fragment.schema.json +5 -0
- package/references/hard-surface/schema/pipeline.schema.json +181 -0
- package/schema/pipeline-fragment.schema.json +5 -0
- package/schema/pipeline.schema.json +181 -0
- package/verification/assembly.py +96 -0
- package/verification/landmarks.py +53 -0
- package/verification/panels.py +137 -0
- package/verification/projections.py +135 -0
- package/verification/verify.py +108 -0
- package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
- package/viewer/dist/assets/GLTFExporter-xdVCArY-.js +1 -0
- package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
- package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
- package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
- package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
- package/viewer/dist/assets/compare-Du4RoRQO.js +6 -0
- package/viewer/dist/assets/compare.worker-CgJq-znx.js +21 -0
- package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
- package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
- package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
- package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
- package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
- package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
- package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
- package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
- package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
- package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
- package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
- package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
- package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
- package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
- package/viewer/dist/assets/presets-jXE0t1fU.js +1 -0
- package/viewer/dist/assets/preview-cache-BKV0EZl9.js +1 -0
- package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
- package/viewer/dist/assets/project-DtHHhfo-.js +17 -0
- package/viewer/dist/assets/reconstruct.worker-ONc9GyFO.js +21 -0
- package/viewer/dist/assets/script-engine-Bs3azDYZ.js +6 -0
- package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
- package/viewer/dist/assets/style-D6eZHs3D.js +4004 -0
- package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
- package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
- package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
- package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
- package/viewer/dist/assets/viewer-DIjS0No7.js +2 -0
- package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
- package/viewer/dist/compare.html +47 -0
- package/viewer/dist/examples/traffic-cone-4view.png +0 -0
- package/viewer/dist/index.html +148 -0
- package/viewer/dist/playground/index.html +3342 -0
- package/viewer/dist/project.html +83 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "stack3 pipeline v1",
|
|
4
|
+
"$ref": "#/$defs/manifest",
|
|
5
|
+
"required": ["version"],
|
|
6
|
+
"$defs": {
|
|
7
|
+
"manifest": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"version": { "const": 1 },
|
|
12
|
+
"includes": { "type": "array", "items": { "$ref": "#/$defs/text" } },
|
|
13
|
+
"values": { "type": "object", "description": "Defaults used by quoted .Values references." },
|
|
14
|
+
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"text": { "type": "string", "pattern": "\\S" },
|
|
18
|
+
"template": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"pattern": "\\{\\{\\s*\\.Values\\.[\\w-]+(?:\\.[\\w-]+)*\\s*\\}\\}"
|
|
21
|
+
},
|
|
22
|
+
"scalarReference": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^\\s*\\{\\{\\s*\\.Values\\.[\\w-]+(?:\\.[\\w-]+)*\\s*\\}\\}\\s*$"
|
|
25
|
+
},
|
|
26
|
+
"id": { "anyOf": [{ "type": "string", "pattern": "^[A-Za-z0-9_-]+$" }, { "$ref": "#/$defs/template" }] },
|
|
27
|
+
"bool": { "anyOf": [{ "type": "boolean" }, { "$ref": "#/$defs/scalarReference" }] },
|
|
28
|
+
"number": { "anyOf": [{ "type": "number" }, { "$ref": "#/$defs/scalarReference" }] },
|
|
29
|
+
"positive": { "anyOf": [{ "type": "number", "exclusiveMinimum": 0 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
30
|
+
"xyz": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "$ref": "#/$defs/number" } },
|
|
31
|
+
"bounds": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "$ref": "#/$defs/xyz" } },
|
|
32
|
+
"triangleBudget": { "anyOf": [{ "type": "integer", "minimum": 4, "maximum": 9007199254740991 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
33
|
+
"lodBevel": {
|
|
34
|
+
"type": "object", "additionalProperties": false, "required": ["preTriangleBudget", "rims"],
|
|
35
|
+
"description": "Run QEM before beveling selected circular rims. The export must fit finish.triangleBudget.",
|
|
36
|
+
"properties": {
|
|
37
|
+
"preTriangleBudget": { "$ref": "#/$defs/triangleBudget" },
|
|
38
|
+
"rims": { "type": "array", "minItems": 1, "items": {
|
|
39
|
+
"type": "object", "additionalProperties": false,
|
|
40
|
+
"required": ["id", "axis", "center", "radius", "radialTolerance", "axialTolerance"],
|
|
41
|
+
"properties": {
|
|
42
|
+
"id": { "$ref": "#/$defs/text" },
|
|
43
|
+
"axis": { "enum": ["x", "y", "z"] },
|
|
44
|
+
"center": { "$ref": "#/$defs/xyz" },
|
|
45
|
+
"radius": { "$ref": "#/$defs/positive" },
|
|
46
|
+
"radialTolerance": { "$ref": "#/$defs/positive" },
|
|
47
|
+
"axialTolerance": { "$ref": "#/$defs/positive" }
|
|
48
|
+
}
|
|
49
|
+
} }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"regularization": {
|
|
53
|
+
"type": "object", "additionalProperties": false, "required": ["tolerance", "features"],
|
|
54
|
+
"properties": {
|
|
55
|
+
"tolerance": { "$ref": "#/$defs/positive", "description": "Surface selection and fitting tolerance in stack scene units." },
|
|
56
|
+
"features": {
|
|
57
|
+
"type": "array", "minItems": 1,
|
|
58
|
+
"items": {
|
|
59
|
+
"type": "object", "additionalProperties": false, "required": ["id", "type"],
|
|
60
|
+
"properties": {
|
|
61
|
+
"id": { "$ref": "#/$defs/text" },
|
|
62
|
+
"type": { "enum": ["plane", "circle", "cylinder", "polygon"] },
|
|
63
|
+
"normal": { "$ref": "#/$defs/xyz" },
|
|
64
|
+
"bounds": { "$ref": "#/$defs/bounds" },
|
|
65
|
+
"center": { "$ref": "#/$defs/xyz" },
|
|
66
|
+
"axis": { "$ref": "#/$defs/xyz" },
|
|
67
|
+
"radius": { "$ref": "#/$defs/positive" },
|
|
68
|
+
"corners": { "type": "array", "minItems": 3, "items": { "$ref": "#/$defs/xyz" } }
|
|
69
|
+
},
|
|
70
|
+
"allOf": [
|
|
71
|
+
{ "if": { "properties": { "type": { "const": "plane" } } }, "then": { "required": ["normal", "bounds"], "propertyNames": { "enum": ["id", "type", "normal", "bounds"] } } },
|
|
72
|
+
{ "if": { "properties": { "type": { "const": "circle" } } }, "then": { "required": ["center", "axis", "radius"], "propertyNames": { "enum": ["id", "type", "center", "axis", "radius"] } } },
|
|
73
|
+
{ "if": { "properties": { "type": { "const": "cylinder" } } }, "then": { "required": ["center", "axis", "radius", "bounds"], "propertyNames": { "enum": ["id", "type", "center", "axis", "radius", "bounds"] } } },
|
|
74
|
+
{ "if": { "properties": { "type": { "const": "polygon" } } }, "then": { "required": ["corners"], "propertyNames": { "enum": ["id", "type", "corners"] } } }
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"relations": {
|
|
79
|
+
"type": "array", "items": {
|
|
80
|
+
"type": "object", "additionalProperties": false, "required": ["type", "features"],
|
|
81
|
+
"properties": {
|
|
82
|
+
"type": { "enum": ["parallel", "perpendicular", "coplanar"] },
|
|
83
|
+
"features": { "type": "array", "minItems": 2, "maxItems": 2, "uniqueItems": true, "items": { "$ref": "#/$defs/text" } }
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"description": "Optional soft relations between two fitted plane features."
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"method": {
|
|
91
|
+
"enum": [
|
|
92
|
+
"marching-cubes", "surface-nets", "voxel", "section-loft", "heightfield", "smooth-loft", "revolve",
|
|
93
|
+
"extended-mc", "hermite-dc", "mc33", "branch-loft", "path-sweep", "section-network", "greedy", "monotone",
|
|
94
|
+
"signed-distance-dc"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"finish": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"additionalProperties": false,
|
|
100
|
+
"properties": {
|
|
101
|
+
"fitTolerance": { "$ref": "#/$defs/positive", "description": "Maximum planar fitting residual in scene units." },
|
|
102
|
+
"primitives": { "$ref": "#/$defs/bool", "description": "Fit supported sphere and cylinder regions." },
|
|
103
|
+
"regularization": { "$ref": "#/$defs/regularization" },
|
|
104
|
+
"bevelWidth": { "$ref": "#/$defs/positive", "description": "Bevel offset in scene units." },
|
|
105
|
+
"bevelSegments": { "anyOf": [{ "type": "integer", "minimum": 1, "maximum": 16 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
106
|
+
"dissolveAngle": { "anyOf": [{ "type": "number", "exclusiveMinimum": 0, "maximum": 45 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
107
|
+
"triangleBudget": { "$ref": "#/$defs/triangleBudget" },
|
|
108
|
+
"lodBevel": { "$ref": "#/$defs/lodBevel" },
|
|
109
|
+
"aoRadius": { "$ref": "#/$defs/positive", "description": "Vertex ambient occlusion ray distance in scene units." }
|
|
110
|
+
},
|
|
111
|
+
"dependentRequired": { "bevelSegments": ["bevelWidth"], "lodBevel": ["bevelWidth", "triangleBudget"] },
|
|
112
|
+
"if": { "required": ["primitives"], "properties": { "primitives": { "const": true } } },
|
|
113
|
+
"then": { "required": ["fitTolerance"] }
|
|
114
|
+
},
|
|
115
|
+
"node": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"required": ["id", "type"],
|
|
118
|
+
"additionalProperties": false,
|
|
119
|
+
"properties": {
|
|
120
|
+
"id": { "$ref": "#/$defs/id" },
|
|
121
|
+
"type": { "anyOf": [{ "enum": ["load-stack", "reconstruct-stack", "extract-mesh", "write-glb"] }, { "$ref": "#/$defs/template" }] },
|
|
122
|
+
"input": { "$ref": "#/$defs/id", "description": "ID of the input node." },
|
|
123
|
+
"path": { "$ref": "#/$defs/text" },
|
|
124
|
+
"layout": { "$ref": "#/$defs/text", "examples": ["top,left,front,rear", "top,left,front,rear,right,bottom"] },
|
|
125
|
+
"layers": { "anyOf": [{ "type": "integer", "minimum": 8, "maximum": 9007199254740991 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
126
|
+
"resolution": { "anyOf": [{ "type": "integer", "minimum": 16, "maximum": 9007199254740991 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
127
|
+
"height": { "$ref": "#/$defs/positive" },
|
|
128
|
+
"pivot": { "anyOf": [{ "enum": ["ground", "center"] }, { "$ref": "#/$defs/template" }] },
|
|
129
|
+
"profile": { "anyOf": [{ "enum": ["silhouette", "round", "round-base"] }, { "$ref": "#/$defs/template" }] },
|
|
130
|
+
"threshold": { "anyOf": [{ "type": "integer", "minimum": 0, "maximum": 255 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
131
|
+
"method": { "anyOf": [{ "$ref": "#/$defs/method" }, { "$ref": "#/$defs/template" }] },
|
|
132
|
+
"guide": { "$ref": "#/$defs/text" },
|
|
133
|
+
"finish": { "$ref": "#/$defs/finish" },
|
|
134
|
+
"cache": { "$ref": "#/$defs/bool" },
|
|
135
|
+
"lit": { "$ref": "#/$defs/bool" },
|
|
136
|
+
"instances": {
|
|
137
|
+
"type": "array", "minItems": 1,
|
|
138
|
+
"description": "Translation for each GPU instance in glTF XYZ coordinates.",
|
|
139
|
+
"items": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "$ref": "#/$defs/number" } }
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"allOf": [
|
|
143
|
+
{
|
|
144
|
+
"if": { "properties": { "type": { "const": "load-stack" } } },
|
|
145
|
+
"then": { "required": ["path"], "propertyNames": { "enum": ["id", "type", "path"] } }
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"if": { "properties": { "type": { "const": "reconstruct-stack" } } },
|
|
149
|
+
"then": {
|
|
150
|
+
"required": ["path"],
|
|
151
|
+
"propertyNames": { "enum": ["id", "type", "path", "layout", "layers", "resolution", "height", "pivot", "profile", "threshold"] },
|
|
152
|
+
"anyOf": [
|
|
153
|
+
{ "properties": { "path": { "pattern": "\\.[jJ][sS][oO][nN]$" } }, "not": { "required": ["layout"] } },
|
|
154
|
+
{ "properties": { "path": { "pattern": "\\.[pP][nN][gG]$" } }, "required": ["layout"] },
|
|
155
|
+
{ "properties": { "path": { "$ref": "#/$defs/template" } } }
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"if": { "properties": { "type": { "const": "extract-mesh" } } },
|
|
161
|
+
"then": {
|
|
162
|
+
"required": ["input", "method"],
|
|
163
|
+
"propertyNames": { "enum": ["id", "type", "input", "method", "guide", "finish", "cache"] },
|
|
164
|
+
"if": { "properties": { "method": { "enum": ["marching-cubes", "voxel", "surface-nets"] } } },
|
|
165
|
+
"then": {
|
|
166
|
+
"properties": { "guide": false, "finish": { "maxProperties": 0 } }
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"if": { "properties": { "type": { "const": "write-glb" } } },
|
|
172
|
+
"then": {
|
|
173
|
+
"required": ["input", "path"],
|
|
174
|
+
"propertyNames": { "enum": ["id", "type", "input", "path", "lit", "instances"] },
|
|
175
|
+
"properties": { "path": { "anyOf": [{ "pattern": "\\.[gG][lL][bB]$" }, { "$ref": "#/$defs/template" }] } }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "stack3 pipeline v1",
|
|
4
|
+
"$ref": "#/$defs/manifest",
|
|
5
|
+
"required": ["version"],
|
|
6
|
+
"$defs": {
|
|
7
|
+
"manifest": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"version": { "const": 1 },
|
|
12
|
+
"includes": { "type": "array", "items": { "$ref": "#/$defs/text" } },
|
|
13
|
+
"values": { "type": "object", "description": "Defaults used by quoted .Values references." },
|
|
14
|
+
"nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"text": { "type": "string", "pattern": "\\S" },
|
|
18
|
+
"template": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"pattern": "\\{\\{\\s*\\.Values\\.[\\w-]+(?:\\.[\\w-]+)*\\s*\\}\\}"
|
|
21
|
+
},
|
|
22
|
+
"scalarReference": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^\\s*\\{\\{\\s*\\.Values\\.[\\w-]+(?:\\.[\\w-]+)*\\s*\\}\\}\\s*$"
|
|
25
|
+
},
|
|
26
|
+
"id": { "anyOf": [{ "type": "string", "pattern": "^[A-Za-z0-9_-]+$" }, { "$ref": "#/$defs/template" }] },
|
|
27
|
+
"bool": { "anyOf": [{ "type": "boolean" }, { "$ref": "#/$defs/scalarReference" }] },
|
|
28
|
+
"number": { "anyOf": [{ "type": "number" }, { "$ref": "#/$defs/scalarReference" }] },
|
|
29
|
+
"positive": { "anyOf": [{ "type": "number", "exclusiveMinimum": 0 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
30
|
+
"xyz": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "$ref": "#/$defs/number" } },
|
|
31
|
+
"bounds": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "$ref": "#/$defs/xyz" } },
|
|
32
|
+
"triangleBudget": { "anyOf": [{ "type": "integer", "minimum": 4, "maximum": 9007199254740991 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
33
|
+
"lodBevel": {
|
|
34
|
+
"type": "object", "additionalProperties": false, "required": ["preTriangleBudget", "rims"],
|
|
35
|
+
"description": "Run QEM before beveling selected circular rims. The export must fit finish.triangleBudget.",
|
|
36
|
+
"properties": {
|
|
37
|
+
"preTriangleBudget": { "$ref": "#/$defs/triangleBudget" },
|
|
38
|
+
"rims": { "type": "array", "minItems": 1, "items": {
|
|
39
|
+
"type": "object", "additionalProperties": false,
|
|
40
|
+
"required": ["id", "axis", "center", "radius", "radialTolerance", "axialTolerance"],
|
|
41
|
+
"properties": {
|
|
42
|
+
"id": { "$ref": "#/$defs/text" },
|
|
43
|
+
"axis": { "enum": ["x", "y", "z"] },
|
|
44
|
+
"center": { "$ref": "#/$defs/xyz" },
|
|
45
|
+
"radius": { "$ref": "#/$defs/positive" },
|
|
46
|
+
"radialTolerance": { "$ref": "#/$defs/positive" },
|
|
47
|
+
"axialTolerance": { "$ref": "#/$defs/positive" }
|
|
48
|
+
}
|
|
49
|
+
} }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"regularization": {
|
|
53
|
+
"type": "object", "additionalProperties": false, "required": ["tolerance", "features"],
|
|
54
|
+
"properties": {
|
|
55
|
+
"tolerance": { "$ref": "#/$defs/positive", "description": "Surface selection and fitting tolerance in stack scene units." },
|
|
56
|
+
"features": {
|
|
57
|
+
"type": "array", "minItems": 1,
|
|
58
|
+
"items": {
|
|
59
|
+
"type": "object", "additionalProperties": false, "required": ["id", "type"],
|
|
60
|
+
"properties": {
|
|
61
|
+
"id": { "$ref": "#/$defs/text" },
|
|
62
|
+
"type": { "enum": ["plane", "circle", "cylinder", "polygon"] },
|
|
63
|
+
"normal": { "$ref": "#/$defs/xyz" },
|
|
64
|
+
"bounds": { "$ref": "#/$defs/bounds" },
|
|
65
|
+
"center": { "$ref": "#/$defs/xyz" },
|
|
66
|
+
"axis": { "$ref": "#/$defs/xyz" },
|
|
67
|
+
"radius": { "$ref": "#/$defs/positive" },
|
|
68
|
+
"corners": { "type": "array", "minItems": 3, "items": { "$ref": "#/$defs/xyz" } }
|
|
69
|
+
},
|
|
70
|
+
"allOf": [
|
|
71
|
+
{ "if": { "properties": { "type": { "const": "plane" } } }, "then": { "required": ["normal", "bounds"], "propertyNames": { "enum": ["id", "type", "normal", "bounds"] } } },
|
|
72
|
+
{ "if": { "properties": { "type": { "const": "circle" } } }, "then": { "required": ["center", "axis", "radius"], "propertyNames": { "enum": ["id", "type", "center", "axis", "radius"] } } },
|
|
73
|
+
{ "if": { "properties": { "type": { "const": "cylinder" } } }, "then": { "required": ["center", "axis", "radius", "bounds"], "propertyNames": { "enum": ["id", "type", "center", "axis", "radius", "bounds"] } } },
|
|
74
|
+
{ "if": { "properties": { "type": { "const": "polygon" } } }, "then": { "required": ["corners"], "propertyNames": { "enum": ["id", "type", "corners"] } } }
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"relations": {
|
|
79
|
+
"type": "array", "items": {
|
|
80
|
+
"type": "object", "additionalProperties": false, "required": ["type", "features"],
|
|
81
|
+
"properties": {
|
|
82
|
+
"type": { "enum": ["parallel", "perpendicular", "coplanar"] },
|
|
83
|
+
"features": { "type": "array", "minItems": 2, "maxItems": 2, "uniqueItems": true, "items": { "$ref": "#/$defs/text" } }
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"description": "Optional soft relations between two fitted plane features."
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"method": {
|
|
91
|
+
"enum": [
|
|
92
|
+
"marching-cubes", "surface-nets", "voxel", "section-loft", "heightfield", "smooth-loft", "revolve",
|
|
93
|
+
"extended-mc", "hermite-dc", "mc33", "branch-loft", "path-sweep", "section-network", "greedy", "monotone",
|
|
94
|
+
"signed-distance-dc"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"finish": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"additionalProperties": false,
|
|
100
|
+
"properties": {
|
|
101
|
+
"fitTolerance": { "$ref": "#/$defs/positive", "description": "Maximum planar fitting residual in scene units." },
|
|
102
|
+
"primitives": { "$ref": "#/$defs/bool", "description": "Fit supported sphere and cylinder regions." },
|
|
103
|
+
"regularization": { "$ref": "#/$defs/regularization" },
|
|
104
|
+
"bevelWidth": { "$ref": "#/$defs/positive", "description": "Bevel offset in scene units." },
|
|
105
|
+
"bevelSegments": { "anyOf": [{ "type": "integer", "minimum": 1, "maximum": 16 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
106
|
+
"dissolveAngle": { "anyOf": [{ "type": "number", "exclusiveMinimum": 0, "maximum": 45 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
107
|
+
"triangleBudget": { "$ref": "#/$defs/triangleBudget" },
|
|
108
|
+
"lodBevel": { "$ref": "#/$defs/lodBevel" },
|
|
109
|
+
"aoRadius": { "$ref": "#/$defs/positive", "description": "Vertex ambient occlusion ray distance in scene units." }
|
|
110
|
+
},
|
|
111
|
+
"dependentRequired": { "bevelSegments": ["bevelWidth"], "lodBevel": ["bevelWidth", "triangleBudget"] },
|
|
112
|
+
"if": { "required": ["primitives"], "properties": { "primitives": { "const": true } } },
|
|
113
|
+
"then": { "required": ["fitTolerance"] }
|
|
114
|
+
},
|
|
115
|
+
"node": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"required": ["id", "type"],
|
|
118
|
+
"additionalProperties": false,
|
|
119
|
+
"properties": {
|
|
120
|
+
"id": { "$ref": "#/$defs/id" },
|
|
121
|
+
"type": { "anyOf": [{ "enum": ["load-stack", "reconstruct-stack", "extract-mesh", "write-glb"] }, { "$ref": "#/$defs/template" }] },
|
|
122
|
+
"input": { "$ref": "#/$defs/id", "description": "ID of the input node." },
|
|
123
|
+
"path": { "$ref": "#/$defs/text" },
|
|
124
|
+
"layout": { "$ref": "#/$defs/text", "examples": ["top,left,front,rear", "top,left,front,rear,right,bottom"] },
|
|
125
|
+
"layers": { "anyOf": [{ "type": "integer", "minimum": 8, "maximum": 9007199254740991 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
126
|
+
"resolution": { "anyOf": [{ "type": "integer", "minimum": 16, "maximum": 9007199254740991 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
127
|
+
"height": { "$ref": "#/$defs/positive" },
|
|
128
|
+
"pivot": { "anyOf": [{ "enum": ["ground", "center"] }, { "$ref": "#/$defs/template" }] },
|
|
129
|
+
"profile": { "anyOf": [{ "enum": ["silhouette", "round", "round-base"] }, { "$ref": "#/$defs/template" }] },
|
|
130
|
+
"threshold": { "anyOf": [{ "type": "integer", "minimum": 0, "maximum": 255 }, { "$ref": "#/$defs/scalarReference" }] },
|
|
131
|
+
"method": { "anyOf": [{ "$ref": "#/$defs/method" }, { "$ref": "#/$defs/template" }] },
|
|
132
|
+
"guide": { "$ref": "#/$defs/text" },
|
|
133
|
+
"finish": { "$ref": "#/$defs/finish" },
|
|
134
|
+
"cache": { "$ref": "#/$defs/bool" },
|
|
135
|
+
"lit": { "$ref": "#/$defs/bool" },
|
|
136
|
+
"instances": {
|
|
137
|
+
"type": "array", "minItems": 1,
|
|
138
|
+
"description": "Translation for each GPU instance in glTF XYZ coordinates.",
|
|
139
|
+
"items": { "type": "array", "minItems": 3, "maxItems": 3, "items": { "$ref": "#/$defs/number" } }
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"allOf": [
|
|
143
|
+
{
|
|
144
|
+
"if": { "properties": { "type": { "const": "load-stack" } } },
|
|
145
|
+
"then": { "required": ["path"], "propertyNames": { "enum": ["id", "type", "path"] } }
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"if": { "properties": { "type": { "const": "reconstruct-stack" } } },
|
|
149
|
+
"then": {
|
|
150
|
+
"required": ["path"],
|
|
151
|
+
"propertyNames": { "enum": ["id", "type", "path", "layout", "layers", "resolution", "height", "pivot", "profile", "threshold"] },
|
|
152
|
+
"anyOf": [
|
|
153
|
+
{ "properties": { "path": { "pattern": "\\.[jJ][sS][oO][nN]$" } }, "not": { "required": ["layout"] } },
|
|
154
|
+
{ "properties": { "path": { "pattern": "\\.[pP][nN][gG]$" } }, "required": ["layout"] },
|
|
155
|
+
{ "properties": { "path": { "$ref": "#/$defs/template" } } }
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"if": { "properties": { "type": { "const": "extract-mesh" } } },
|
|
161
|
+
"then": {
|
|
162
|
+
"required": ["input", "method"],
|
|
163
|
+
"propertyNames": { "enum": ["id", "type", "input", "method", "guide", "finish", "cache"] },
|
|
164
|
+
"if": { "properties": { "method": { "enum": ["marching-cubes", "voxel", "surface-nets"] } } },
|
|
165
|
+
"then": {
|
|
166
|
+
"properties": { "guide": false, "finish": { "maxProperties": 0 } }
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"if": { "properties": { "type": { "const": "write-glb" } } },
|
|
172
|
+
"then": {
|
|
173
|
+
"required": ["input", "path"],
|
|
174
|
+
"propertyNames": { "enum": ["id", "type", "input", "path", "lit", "instances"] },
|
|
175
|
+
"properties": { "path": { "anyOf": [{ "pattern": "\\.[gG][lL][bB]$" }, { "$ref": "#/$defs/template" }] } }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import cv2
|
|
4
|
+
import numpy as np
|
|
5
|
+
from PIL import Image, ImageDraw
|
|
6
|
+
from panels import CYAN, GOLD, RED, GREEN, canvas, dot, sheet, unregistered
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def assemble(base, local, spec, tolerance):
|
|
10
|
+
missing = unregistered(local)
|
|
11
|
+
if missing:
|
|
12
|
+
return dict(status="registration-needed", reason="Missing part registration", views=missing), None
|
|
13
|
+
|
|
14
|
+
def read_pair(view, pair):
|
|
15
|
+
p = local[view].annotation(pair["part"], view+".part")
|
|
16
|
+
q = base[view].annotation(pair["whole"], view+".whole")
|
|
17
|
+
return local[view].world(p), base[view].world(q)
|
|
18
|
+
|
|
19
|
+
fits = spec.get("mounts", {})
|
|
20
|
+
top = [read_pair("top", m) for m in fits.get("top", [])]
|
|
21
|
+
front = [read_pair("front", m) for m in fits.get("front", [])]
|
|
22
|
+
if len(top) < 2 or not front:
|
|
23
|
+
return dict(status="registration-needed", reason="Need two TOP mounts and a FRONT height mount"), None
|
|
24
|
+
p = np.array([[v["x"],v["y"]] for v,_ in top])
|
|
25
|
+
q = np.array([[v["x"],v["y"]] for _,v in top])
|
|
26
|
+
centered = p-p.mean(axis=0)
|
|
27
|
+
denom = (centered**2).sum()
|
|
28
|
+
if denom == 0:
|
|
29
|
+
return dict(status="registration-needed", reason="TOP mounts must be distinct"), None
|
|
30
|
+
scale = float((centered*(q-q.mean(axis=0))).sum()/denom)
|
|
31
|
+
if scale <= 0:
|
|
32
|
+
return dict(status="registration-needed", reason="TOP mounts disagree on part orientation"), None
|
|
33
|
+
tx, ty = q.mean(axis=0)-scale*p.mean(axis=0)
|
|
34
|
+
tz = sum(b["z"]-scale*a["z"] for a,b in front)/len(front)
|
|
35
|
+
shift = dict(x=float(tx), y=float(ty), z=tz)
|
|
36
|
+
def transform(view, xy):
|
|
37
|
+
world = local[view].world(xy)
|
|
38
|
+
return base[view].pixel({a: v*scale+shift[a] for a,v in world.items()})
|
|
39
|
+
images = canvas(base)
|
|
40
|
+
edges = {}
|
|
41
|
+
for v,panel in local.items():
|
|
42
|
+
lines = []
|
|
43
|
+
for contour in panel.contours:
|
|
44
|
+
coords = [transform(v, xy) for xy in contour]
|
|
45
|
+
lines.append(np.rint(coords).astype(np.int32))
|
|
46
|
+
pixels = np.array(images[v])
|
|
47
|
+
cv2.polylines(pixels, lines, True, CYAN, 1)
|
|
48
|
+
images[v].paste(Image.fromarray(pixels))
|
|
49
|
+
edges[v] = lines
|
|
50
|
+
residuals = []
|
|
51
|
+
for v in ("top", "front"):
|
|
52
|
+
for m in fits[v]:
|
|
53
|
+
pred = transform(v,m["part"])
|
|
54
|
+
residuals.append(dict(view=v, errorPx=math.dist(pred,m["whole"]), predicted=pred, whole=m["whole"]))
|
|
55
|
+
dot(ImageDraw.Draw(images[v]), m["whole"], GREEN)
|
|
56
|
+
checks = []
|
|
57
|
+
for c in spec.get("checks", []):
|
|
58
|
+
v = c["view"]
|
|
59
|
+
whole = base[v]
|
|
60
|
+
d = ImageDraw.Draw(images[v])
|
|
61
|
+
if c.get("visible", True) is False:
|
|
62
|
+
if "whole" in c:
|
|
63
|
+
dot(d, whole.annotation(c["whole"], c["id"]), GOLD, 6)
|
|
64
|
+
if "edge" in c:
|
|
65
|
+
pts = [tuple(whole.annotation(pt, c["id"])) for pt in c["edge"]]
|
|
66
|
+
if len(pts) >= 2:
|
|
67
|
+
d.line(pts, fill=GOLD, width=2)
|
|
68
|
+
checks.append(dict(id=c["id"], view=v, status="occluded"))
|
|
69
|
+
continue
|
|
70
|
+
if "edge" in c:
|
|
71
|
+
# Sample only the independently marked visible segment of the whole part.
|
|
72
|
+
pts = np.array([whole.annotation(pt, c["id"]) for pt in c["edge"]])
|
|
73
|
+
if len(pts) < 2:
|
|
74
|
+
raise ValueError("a visible edge needs at least two points")
|
|
75
|
+
pixels = np.ones(whole.mask.shape, np.uint8)
|
|
76
|
+
cv2.polylines(pixels, edges[v], True, 0, 1)
|
|
77
|
+
target = np.zeros_like(pixels)
|
|
78
|
+
cv2.polylines(target, [np.rint(pts).astype(np.int32)], False, 1, 1)
|
|
79
|
+
err = float(cv2.distanceTransform(pixels, cv2.DIST_L2, cv2.DIST_MASK_PRECISE)[target.astype(bool)].max()) if not pixels.all() else None
|
|
80
|
+
row = dict(maxEdgeErrorPx=err, edge=c["edge"])
|
|
81
|
+
bad = err is None or err > tolerance
|
|
82
|
+
d.line([tuple(pt) for pt in pts], fill=RED if bad else GREEN, width=2)
|
|
83
|
+
else:
|
|
84
|
+
a = local[v].annotation(c["part"], c["id"])
|
|
85
|
+
b = whole.annotation(c["whole"], c["id"])
|
|
86
|
+
if any(a == m["part"] or b == m["whole"] for m in fits.get(v, [])):
|
|
87
|
+
raise ValueError(f"{c['id']}: held-out check reuses a fit anchor in {v}")
|
|
88
|
+
pred = transform(v, a)
|
|
89
|
+
err = math.dist(pred,b)
|
|
90
|
+
row = dict(predicted=pred, observed=b, errorPx=err)
|
|
91
|
+
d.line([tuple(pred), tuple(b)], fill=RED, width=2)
|
|
92
|
+
dot(d, pred, CYAN, 5)
|
|
93
|
+
dot(d, b, GOLD)
|
|
94
|
+
checks.append(dict(id=c["id"], view=v, status="measured" if err is not None else "outside-panel", **row))
|
|
95
|
+
return dict(status="measured", transform=dict(scale=scale, offset=shift), fit=residuals, heldOut=checks), sheet(images,"Fixed part placement",
|
|
96
|
+
"Cyan: projected part Green: mount / matched edge Gold: observed or occluded Red: residual")
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from itertools import combinations
|
|
2
|
+
import math
|
|
3
|
+
|
|
4
|
+
from PIL import ImageDraw
|
|
5
|
+
from panels import CYAN, GOLD, RED, canvas, dot, sheet
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def landmarks(panels, items, tolerance):
|
|
9
|
+
images = canvas(panels)
|
|
10
|
+
rows = []
|
|
11
|
+
seen = set()
|
|
12
|
+
for item in items:
|
|
13
|
+
name = item["id"]
|
|
14
|
+
if not isinstance(name, str) or not name or name in seen:
|
|
15
|
+
raise ValueError("each landmark requires a unique id")
|
|
16
|
+
seen.add(name)
|
|
17
|
+
refs, hidden, missing = {}, [], []
|
|
18
|
+
for v, xy in item["points"].items():
|
|
19
|
+
if v not in panels:
|
|
20
|
+
raise ValueError(f"{name}: unknown view {v}")
|
|
21
|
+
if xy is None:
|
|
22
|
+
hidden.append(v)
|
|
23
|
+
elif panels[v].origin is None or panels[v].scale is None:
|
|
24
|
+
missing.append(v)
|
|
25
|
+
else:
|
|
26
|
+
refs[v] = panels[v].annotation(xy, name)
|
|
27
|
+
dot(ImageDraw.Draw(images[v]), refs[v], CYAN)
|
|
28
|
+
pairs, predictions = [], []
|
|
29
|
+
for a, b in combinations((v for v in panels if v in refs), 2):
|
|
30
|
+
aw, bw = panels[a].world(refs[a]), panels[b].world(refs[b])
|
|
31
|
+
shared = sorted(aw.keys() & bw.keys())
|
|
32
|
+
errors = {axis: abs(aw[axis]-bw[axis])*panels[b].scale for axis in shared}
|
|
33
|
+
pairs.append(dict(inputs=[a,b], measuredIn=b, sharedErrorPx=errors))
|
|
34
|
+
if max(errors.values()) > tolerance:
|
|
35
|
+
continue
|
|
36
|
+
world = {**aw, **bw}
|
|
37
|
+
for axis in shared:
|
|
38
|
+
world[axis] = (aw[axis]+bw[axis])/2
|
|
39
|
+
for test, observed in refs.items():
|
|
40
|
+
if test in (a,b) or not set(panels[test].axes) <= world.keys():
|
|
41
|
+
continue
|
|
42
|
+
predicted = panels[test].pixel(world)
|
|
43
|
+
error = math.dist(observed, predicted)
|
|
44
|
+
drawing = ImageDraw.Draw(images[test])
|
|
45
|
+
drawing.line([tuple(predicted), tuple(observed)], fill=RED, width=2)
|
|
46
|
+
dot(drawing, predicted, GOLD, 6)
|
|
47
|
+
predictions.append(dict(inputs=[a,b], heldOut=test, predicted=predicted, observed=observed, errorPx=error))
|
|
48
|
+
status = "measured" if pairs else "registration-needed" if missing else "skipped"
|
|
49
|
+
rows.append(dict(id=name, status=status, hidden=hidden, unregistered=missing, sharedAxes=pairs, predictions=predictions,
|
|
50
|
+
predictionNote=None if predictions else "No independent visible target with a compatible pair"))
|
|
51
|
+
status = "measured" if any(r["status"] == "measured" for r in rows) else "registration-needed" if any(r["unregistered"] for r in rows) else "skipped"
|
|
52
|
+
return dict(status=status, landmarks=rows), sheet(images, "Held-out landmark reprojection",
|
|
53
|
+
"Cyan: observed Gold: predicted from two other views Red: residual")
|