@margoengine/brep 0.1.0 → 1.0.0

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.
Files changed (4) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +14 -14
  3. package/README.md +201 -201
  4. package/package.json +52 -52
package/LICENSE CHANGED
@@ -1,201 +1,201 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2026 Scott Campbell
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Scott Campbell
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE CHANGED
@@ -1,14 +1,14 @@
1
- Margo Engine
2
- Copyright 2026 Scott Campbell
3
-
4
- This product includes Margo Engine (https://margoengine.com) by Scott Campbell.
5
-
6
- @margoengine/brep is licensed under the Apache License, Version 2.0 (LICENSE).
7
-
8
- JT reader (src/jt):
9
- This software reads the JT Data Format as described in the Siemens JT File Format Reference and ISO 14306.
10
- Copyright in the JT data structures and operators is owned by Siemens Product Lifecycle Management Software Inc.
11
- (Siemens Digital Industries Software) and they are used under the Siemens JT Data Format Reference Intellectual
12
- Property License Terms. US 8,019,788, US 2011/0199382 and corresponding foreign patents are licensed royalty-free
13
- under the Siemens JT Data Format Reference Patent Clarification Notice. JT and Parasolid are trademarks of Siemens;
14
- they are named here only to identify the format. This software is not endorsed by or affiliated with Siemens.
1
+ Margo Engine
2
+ Copyright 2026 Scott Campbell
3
+
4
+ This product includes Margo Engine (https://margoengine.com) by Scott Campbell.
5
+
6
+ @margoengine/brep is licensed under the Apache License, Version 2.0 (LICENSE).
7
+
8
+ JT reader (src/jt):
9
+ This software reads the JT Data Format as described in the Siemens JT File Format Reference and ISO 14306.
10
+ Copyright in the JT data structures and operators is owned by Siemens Product Lifecycle Management Software Inc.
11
+ (Siemens Digital Industries Software) and they are used under the Siemens JT Data Format Reference Intellectual
12
+ Property License Terms. US 8,019,788, US 2011/0199382 and corresponding foreign patents are licensed royalty-free
13
+ under the Siemens JT Data Format Reference Patent Clarification Notice. JT and Parasolid are trademarks of Siemens;
14
+ they are named here only to identify the format. This software is not endorsed by or affiliated with Siemens.
package/README.md CHANGED
@@ -1,201 +1,201 @@
1
- # @margoengine/brep
2
-
3
- Margo's own CAD kernel, written from the published standards (ISO 10303-21 for the file, ISO 10303-41/42/43 and the
4
- AP203, AP214 and AP242 schemas for the data) with no third-party CAD code. It is the only CAD kernel the
5
- engine uses (`@margoengine/cad-import` reads every B-rep format through it; `docs/brep-kernel.md` tells how it was built in
6
- stages): it reads a STEP file's structure (stage 1), evaluates its exact geometry (stage 2) and tessellates it, one discretization per edge shared by both faces (stage 3) and a constrained Delaunay triangulation per
7
- face (stage 4).
8
-
9
- ```ts
10
- import { parseSTEP } from 'margoengine/brep';
11
-
12
- const model = parseSTEP(await (await fetch('/assembly.step')).arrayBuffer());
13
- console.log(model.header.schema, model.products.map((p) => p.name));
14
- for (const instance of model.instances) {
15
- const body = model.bodies[instance.body];
16
- // instance.matrix: column-major, body coordinates in metres (times body.unit) to the model's world, in metres.
17
- console.log(model.products[instance.product]?.name, body.kind, body.faces.length, body.color);
18
- }
19
- ```
20
-
21
- To mesh the bodies:
22
-
23
- ```ts
24
- import { parseSTEP, tessellateSTEP } from 'margoengine/brep';
25
-
26
- const model = parseSTEP(await (await fetch('/assembly.step')).arrayBuffer());
27
- const meshes = tessellateSTEP(model, { relativeDeflection: 0.001, angle: 0.5 });
28
- for (const instance of model.instances) {
29
- const mesh = meshes[instance.body];
30
- // mesh.positions (body units; times mesh.unit for metres), mesh.normals, mesh.indices; mesh.faces[i] is a run of
31
- // indices with the face's own colour; mesh.failures lists faces the kernel could not mesh. instance.matrix places it.
32
- console.log(mesh.indices.length / 3, 'triangles', mesh.failures.length, 'failed faces', instance.matrix);
33
- }
34
- ```
35
-
36
- To check the meshes against what the file says about itself (many AP242 and AP203 files state their volume, area,
37
- centre, bounding box or facet count as CAx-IF validation properties):
38
-
39
- ```ts
40
- import { parseSTEP, tessellateSTEP, validateSTEP } from 'margoengine/brep';
41
-
42
- const model = parseSTEP(await (await fetch('/assembly.step')).arrayBuffer());
43
- for (const check of validateSTEP(model, tessellateSTEP(model)))
44
- if (!check.ok) console.warn(check.property.label, check.differences, check.note);
45
- ```
46
-
47
- ## Modelling (`model`)
48
-
49
- The kernel also builds and edits solids, as one namespace, `model`: bodies with persistent face names, primitives (`box`,
50
- `cylinder`, `cone`, `sphere`, `torus`), `extrude`, `revolve`, `sweep`, `loft`, `boolean`, `fillet`, `chamfer`,
51
- `offsetFaces`, `shell`, `draft`, `sew`, validity checks (`validateBody`, `checkBody`), exact `massProperties`, and
52
- `bodiesToSTEP`, `bodiesFromSTEP` and `meshBodies` to write, read and mesh what it makes. Lengths are in metres.
53
-
54
- ```ts
55
- import { model } from 'margoengine/brep';
56
-
57
- const mm = 0.001;
58
- // A 40 x 30 x 20 mm block, hollowed to 2 mm walls and open at its top face.
59
- const block = model.box('block', [40 * mm, 30 * mm, 20 * mm]);
60
- const cup = model.shell('cup', block, ['block/face:+z'], -2 * mm);
61
- console.log(model.checkBody(cup).length, 'problems', model.massProperties(cup).volume, 'm3');
62
- // A frustum: bottom radius, top radius, height.
63
- console.log(model.massProperties(model.cone('frustum', 10 * mm, 5 * mm, 20 * mm)).volume, 'm3');
64
- ```
65
-
66
- - **`cone(name, radius, topRadius, height)`:** a cone or frustum (a top radius of 0 is the apex). `revolve` also takes a
67
- profile that touches the axis (an apex, a pole, a disc); a profile that touches the axis at a point with no segment
68
- along it would pinch the solid and is refused.
69
- - **`sew(name, facesOrBodies, tolerance)`:** joins loose faces into a body within a tolerance and returns a report (joined,
70
- merged and split edges, dropped faces, open edges with their gap distances, flipped faces, problems); the body is a
71
- solid only when it is closed and passes `checkBody`. Closed shells nested in each other are sorted: an odd nesting
72
- count is a cavity of the innermost solid shell and is turned inward.
73
- - **`offsetFaces(name, body, faceNames, distance)`, `shell(name, body, openFaceNames, thickness)` and
74
- `draft(name, body, faceNames, neutral, pull, angle)`:** planes, cylinders, cones, spheres and tori are re-solved (new
75
- vertices by Gauss-Newton, circles about the old axis, an edge whose faces now meet in another curve traced between
76
- its new ends as a Boolean traces it, every new edge checked on both faces); a negative `shell`
77
- thickness cuts the walls inward, a positive one grows them outward, with no open faces it makes a closed cavity. A
78
- cylinder or cone whose axis lies along the pull becomes a cone when drafted. Offsets that change the topology
79
- (a face moved past a neighbour, walls thicker than the part) and faces on B-spline surfaces are refused with a
80
- `RangeError` that says why.
81
- - **`sweep(name, profile, path)`:** a closed planar profile along a tangent-continuous `Path` of lines and arcs (a
82
- rotation-minimising frame; a closed path makes a ring), with analytic faces only. Refused by name: a corner, an arc
83
- tighter than the profile's reach, pieces of the path closer than twice that reach, a profile that is not across the
84
- path's start tangent.
85
- - **`loft(name, sections)`:** a ruled loft through two or more closed planar sections with the same number of segments;
86
- faces are planes, cylinders, cones, or bilinear or rational ruled splines, joined with C0 continuity at inner
87
- sections. A twist between sections is refused.
88
-
89
- ## Other B-rep formats
90
-
91
- ACIS SAT, Parasolid XT (also inside JT files) and IGES are converted to STEP entities and then read and meshed by the
92
- same kernel:
93
-
94
- - **IGES** (`parseIGES`, `igesToSTEP`, `readIGES` for the raw entities, `isIGES` to detect a file): IGES 5.3 fixed
95
- ASCII files, written from the published specification (US PRO/IPO-100-1996). The Start, Global, Directory Entry,
96
- Parameter Data and Terminate sections; parameter and record delimiters from the Global section, Hollerith strings
97
- across lines, D exponents and defaulted fields; units flag and model space scale (the result is in millimetres);
98
- transformation matrices (124), chained. Manifold solid B-rep objects (186) with their shells, faces, loops, edge and
99
- vertex lists (514, 510, 508, 504, 502) become solids, voids included; trimmed (144) and bounded (143, 141) surfaces,
100
- bounded planes (108) and untrimmed surfaces become the faces of one surface model. Curves: circular and conic arcs
101
- (100, 104; parabolas and hyperbolas as exact rational quadratics), composite curves (102), linear paths (106),
102
- lines (110), parametric splines (112, exact), rational B-splines (126), offset curves (130, fitted), curves on
103
- surfaces (142: the model-space curve, else the parameter-space curve mapped through its surface and fitted).
104
- Surfaces: planes (108, 190), parametric spline surfaces (114, exact: each bicubic patch a Bezier patch of one
105
- B-spline, knots at the breakpoints; patches that part on a shared edge by more than the file's tolerance are refused),
106
- ruled surfaces (118: exact for matching rails, sampled otherwise), surfaces of revolution (120), tabulated cylinders (122), rational B-spline surfaces (128), offset
107
- surfaces (140), cylinders, cones, spheres and tori (192 to 198). Colour numbers and colour definitions (314) colour
108
- the faces. Not yet: the Compressed and Binary formats, subfigure and solid instances (308/408, 430), CSG
109
- solids (150 to 184), and wireframe-only files (nothing to mesh). Faces of trimmed-surface files keep their own edges (they
110
- are not sewn into solids).
111
-
112
- - **ACIS SAT** (`parseSAT`, `satToSTEP`): save versions before and after ACIS 7.0, written from Spatial's published SAT
113
- format chapter and class restore descriptions. Bodies, lumps, shells, faces, loops, coedges, edges, vertices; plane,
114
- cone, cylinder, sphere, torus and spline surfaces; straight, ellipse and interpolated curves (procedural splines from
115
- the B-spline approximation the file stores with them); body transforms, units and rgb_color attributes.
116
- - **Parasolid XT** (`parseXT`, `xtToSTEP`, `readXT` for the raw nodes): text (.x_t) and neutral binary (.x_b)
117
- transmit files, written from the published XT Format Reference. Node layouts come from the base schema, with each
118
- file's own schema edits applied (Parasolid V14 on); assemblies become mapped items (a part placed many times is meshed
119
- once); solid and sheet bodies; plane, cylinder, cone, sphere, torus, B-surface, offset, swept and spun surfaces; line,
120
- circle, ellipse, B-curve, trimmed and intersection curves (through their chart points); rolling-ball and cliff-edge
121
- blends (each ball centre moved onto both offset supports, or onto the surface and the cliff edge, the exact arc
122
- between the contacts as a rational quadratic); tolerant edges (the curve followed along a fin's trimmed SP-curve over
123
- its face surface); SDL/TYSA_COLOUR attributes. Lengths are metres. Foreign geometry is left out and listed in
124
- `warnings` for now.
125
- - **JT** (`parseJT`, `tessellateJT`): JT 9.5 and later (ISO 14306), written from the JT File Format Reference and
126
- the standard under Siemens' published licence terms (`THIRD-PARTY-NOTICES.md`, `docs/jt-licensing.md`). The file header and table
127
- of contents, zlib (JT 9) and LZMA (JT 10) segment compression, the scene graph (partitions, groups, instances,
128
- parts, LOD and switch nodes, transforms, materials, properties with names and units) and each part's exact B-rep
129
- from its XT B-rep segment (or the file's MultiXT segment), read by the Parasolid reader. Parts and placements come
130
- out in metres. JT 9 and JT 10 tessellated shapes (tri-strip sets) are decoded into triangle meshes with normals and
131
- face groups: Int32 compressed data packets (bit-length, arithmetic, chopper, move-to-front), the polygon mesh
132
- topology decoder, coordinates and Deering normals, each checked against the hashes the file stores; real files'
133
- departures from the published texts are in `docs/jt-reader.md`. Polylines and JT files that partition nodes refer
134
- to are listed in `warnings`.
135
-
136
- ## What stage 1 reads
137
-
138
- - **The file:** one pass indexes every entity instance of the DATA sections; parameters are parsed only when used, so
139
- a 10 MB file is not turned into millions of objects to read its structure. Text escapes (`''`, `\S\`, `\X\`, `\X2\`,
140
- `\X4\`) are decoded; bytes are read as ISO 8859-1, the standard's character set. `STEPFile` exposes the table:
141
- `get(id)`, `ids(type)` (complex instances listed under each partial type), `args(id, type)`, `census()`.
142
- - **Products:** every `PRODUCT_DEFINITION` with its product's name and id (part number).
143
- - **Assemblies:** `NEXT_ASSEMBLY_USAGE_OCCURRENCE` links placed by `CONTEXT_DEPENDENT_SHAPE_REPRESENTATION` through
144
- an `ITEM_DEFINED_TRANSFORMATION` (or a Cartesian transformation operator), whichever way round the exporter wrote
145
- the two representations, and `MAPPED_ITEM` copies. A component an assembly link already places is not placed again
146
- by a mapped copy of it.
147
- - **Bodies:** `MANIFOLD_SOLID_BREP`, `BREP_WITH_VOIDS`, `FACETED_BREP`, `SHELL_BASED_SURFACE_MODEL` and the AP242
148
- tessellated bodies (`TESSELLATED_SOLID`, `TESSELLATED_SHELL`, triangulated faces and surface sets, with triangle
149
- lists, strips and fans through `pnindex`, and the file's normals), with their faces and distinct edges, and a
150
- census of surface and edge-curve types.
151
- - **Units:** each body's length unit in metres (SI prefixes and conversion-based units such as inches); placements are
152
- converted to metres. A representation context with no length unit the reader can read (no
153
- `GLOBAL_UNIT_ASSIGNED_CONTEXT`, a misspelt one, an unknown unit) is refused with a TypeError naming it, never taken
154
- as metres; with no plane-angle unit it is warned of, and a cone's half angle in it is refused.
155
- - **References:** a reference to an instance the file never defines is named in `warnings` with what refers to it;
156
- a body that lost a shell, face, loop or edge to one lists it in `unresolved` and is not imported.
157
- - **Occurrences:** every placed product (a root, or a component where an assembly places it), with its parent and its
158
- frame in metres; each instance names its occurrence.
159
- - **Validation properties:** `PROPERTY_DEFINITION`s tagged geometric or tessellated validation property, of a
160
- product or of a shape aspect that names bodies (`GEOMETRIC_ITEM_SPECIFIC_USAGE`, or a shape representation of the
161
- aspect): volume, area, centre point, bounding box and number of facets, in metres, with the measure items' own
162
- derived units. Values for independent surfaces are kept apart; independent points and curves, and the zero values
163
- some exporters write as placeholders, are left out. `validateSTEP` measures the meshes in each property's frame;
164
- a product's values cover its components' solids, its area may count surface bodies too (exporters differ), and a
165
- tessellated property is checked against the tessellated bodies.
166
- - **Colours:** `STYLED_ITEM` and `OVER_RIDING_STYLED_ITEM` down to `COLOUR_RGB` or a pre-defined colour, with
167
- `SURFACE_STYLE_TRANSPARENT` as alpha; body colours, and face colours that differ.
168
-
169
- ## Geometry and tessellation (stages 2 to 4)
170
-
171
- - **Curves:** line, circle, ellipse, polyline, B-spline and rational B-spline (simple or complex instances), through
172
- surface, seam, intersection and trimmed curves. A clamped B-spline that ends where it starts is treated as closed
173
- even when the file does not mark it so.
174
- - **Surfaces:** plane, cylinder, cone, sphere, torus (and degenerate torus), surface of revolution, surface of linear
175
- extrusion, B-spline and rational B-spline, offset and rectangular trimmed surfaces. Each evaluates points and first
176
- derivatives (The NURBS Book's algorithms for splines) and inverts a point to its (u, v): closed form for the
177
- analytic surfaces, Gauss-Newton from the nearest of a grid of samples for splines.
178
- - **Edges:** each edge is discretized once, between its exact vertices, by chord deflection and angle; every face
179
- that uses it uses the same points, so the mesh has no cracks.
180
- - **Faces:** bounds are mapped into the surface's (u, v), unwrapped across seams; a pole or apex becomes a line of the
181
- domain; bounds that wrap round a surface are cut at a seam (a band) or closed at the pole (a cap); a face with no
182
- bounds covers its whole closed surface. The domain is triangulated with an exact-predicate constrained Delaunay
183
- triangulation (Shewchuk's robust predicates, Sloan's constraint recovery) over interior points spaced by curvature,
184
- then refined where an edge midpoint or a triangle centre strays from the surface by more than the deflection or
185
- neighbouring normals turn by more than the angle. Normals are the exact surface normals, flipped with the face.
186
- - **Options:** `relativeDeflection` (default 0.001 of each body's bounding-box diagonal) or `deflection` in metres,
187
- `angle` (default 0.5 radians), `interiorDeflection` and `interiorAngle` for face interiors, `minSize`, and
188
- `maxFaceVertices` (default 50,000).
189
-
190
- ## Errors and limits
191
-
192
- A malformed file throws a `TypeError` that names the line. `maxInstances` (default 1,000,000) bounds the placed bodies
193
- of an assembly; a larger one throws a `RangeError` that names the option. Links, placements and styles the reader
194
- cannot use are skipped with a message in `model.warnings` (at most 100). A face whose surface, curve or bounds the
195
- kernel cannot resolve is left out of its body's mesh and listed in `mesh.failures` with the reason; the rest of the body
196
- still meshes. Tessellation options out of range throw a `RangeError` that names the option.
197
-
198
- ## Licence
199
-
200
- Apache-2.0, like the rest of Margo Engine (`LICENSE`). The package's `NOTICE` adds the Siemens JT notice the JT reader
201
- must carry (`docs/jt-licensing.md`); every file of the reader in `src/jt` carries it in its header too.
1
+ # @margoengine/brep
2
+
3
+ Margo's own CAD kernel, written from the published standards (ISO 10303-21 for the file, ISO 10303-41/42/43 and the
4
+ AP203, AP214 and AP242 schemas for the data) with no third-party CAD code. It is the only CAD kernel the
5
+ engine uses (`@margoengine/cad` reads every B-rep format through it; `docs/brep-kernel.md` tells how it was built in
6
+ stages): it reads a STEP file's structure (stage 1), evaluates its exact geometry (stage 2) and tessellates it, one discretization per edge shared by both faces (stage 3) and a constrained Delaunay triangulation per
7
+ face (stage 4).
8
+
9
+ ```ts
10
+ import { parseSTEP } from 'margoengine/brep';
11
+
12
+ const model = parseSTEP(await (await fetch('/assembly.step')).arrayBuffer());
13
+ console.log(model.header.schema, model.products.map((p) => p.name));
14
+ for (const instance of model.instances) {
15
+ const body = model.bodies[instance.body];
16
+ // instance.matrix: column-major, body coordinates in metres (times body.unit) to the model's world, in metres.
17
+ console.log(model.products[instance.product]?.name, body.kind, body.faces.length, body.color);
18
+ }
19
+ ```
20
+
21
+ To mesh the bodies:
22
+
23
+ ```ts
24
+ import { parseSTEP, tessellateSTEP } from 'margoengine/brep';
25
+
26
+ const model = parseSTEP(await (await fetch('/assembly.step')).arrayBuffer());
27
+ const meshes = tessellateSTEP(model, { relativeDeflection: 0.001, angle: 0.5 });
28
+ for (const instance of model.instances) {
29
+ const mesh = meshes[instance.body];
30
+ // mesh.positions (body units; times mesh.unit for metres), mesh.normals, mesh.indices; mesh.faces[i] is a run of
31
+ // indices with the face's own colour; mesh.failures lists faces the kernel could not mesh. instance.matrix places it.
32
+ console.log(mesh.indices.length / 3, 'triangles', mesh.failures.length, 'failed faces', instance.matrix);
33
+ }
34
+ ```
35
+
36
+ To check the meshes against what the file says about itself (many AP242 and AP203 files state their volume, area,
37
+ centre, bounding box or facet count as CAx-IF validation properties):
38
+
39
+ ```ts
40
+ import { parseSTEP, tessellateSTEP, validateSTEP } from 'margoengine/brep';
41
+
42
+ const model = parseSTEP(await (await fetch('/assembly.step')).arrayBuffer());
43
+ for (const check of validateSTEP(model, tessellateSTEP(model)))
44
+ if (!check.ok) console.warn(check.property.label, check.differences, check.note);
45
+ ```
46
+
47
+ ## Modelling (`model`)
48
+
49
+ The kernel also builds and edits solids, as one namespace, `model`: bodies with persistent face names, primitives (`box`,
50
+ `cylinder`, `cone`, `sphere`, `torus`), `extrude`, `revolve`, `sweep`, `loft`, `boolean`, `fillet`, `chamfer`,
51
+ `offsetFaces`, `shell`, `draft`, `sew`, validity checks (`validateBody`, `checkBody`), exact `massProperties`, and
52
+ `bodiesToSTEP`, `bodiesFromSTEP` and `meshBodies` to write, read and mesh what it makes. Lengths are in metres.
53
+
54
+ ```ts
55
+ import { model } from 'margoengine/brep';
56
+
57
+ const mm = 0.001;
58
+ // A 40 x 30 x 20 mm block, hollowed to 2 mm walls and open at its top face.
59
+ const block = model.box('block', [40 * mm, 30 * mm, 20 * mm]);
60
+ const cup = model.shell('cup', block, ['block/face:+z'], -2 * mm);
61
+ console.log(model.checkBody(cup).length, 'problems', model.massProperties(cup).volume, 'm3');
62
+ // A frustum: bottom radius, top radius, height.
63
+ console.log(model.massProperties(model.cone('frustum', 10 * mm, 5 * mm, 20 * mm)).volume, 'm3');
64
+ ```
65
+
66
+ - **`cone(name, radius, topRadius, height)`:** a cone or frustum (a top radius of 0 is the apex). `revolve` also takes a
67
+ profile that touches the axis (an apex, a pole, a disc); a profile that touches the axis at a point with no segment
68
+ along it would pinch the solid and is refused.
69
+ - **`sew(name, facesOrBodies, tolerance)`:** joins loose faces into a body within a tolerance and returns a report (joined,
70
+ merged and split edges, dropped faces, open edges with their gap distances, flipped faces, problems); the body is a
71
+ solid only when it is closed and passes `checkBody`. Closed shells nested in each other are sorted: an odd nesting
72
+ count is a cavity of the innermost solid shell and is turned inward.
73
+ - **`offsetFaces(name, body, faceNames, distance)`, `shell(name, body, openFaceNames, thickness)` and
74
+ `draft(name, body, faceNames, neutral, pull, angle)`:** planes, cylinders, cones, spheres and tori are re-solved (new
75
+ vertices by Gauss-Newton, circles about the old axis, an edge whose faces now meet in another curve traced between
76
+ its new ends as a Boolean traces it, every new edge checked on both faces); a negative `shell`
77
+ thickness cuts the walls inward, a positive one grows them outward, with no open faces it makes a closed cavity. A
78
+ cylinder or cone whose axis lies along the pull becomes a cone when drafted. Offsets that change the topology
79
+ (a face moved past a neighbour, walls thicker than the part) and faces on B-spline surfaces are refused with a
80
+ `RangeError` that says why.
81
+ - **`sweep(name, profile, path)`:** a closed planar profile along a tangent-continuous `Path` of lines and arcs (a
82
+ rotation-minimising frame; a closed path makes a ring), with analytic faces only. Refused by name: a corner, an arc
83
+ tighter than the profile's reach, pieces of the path closer than twice that reach, a profile that is not across the
84
+ path's start tangent.
85
+ - **`loft(name, sections)`:** a ruled loft through two or more closed planar sections with the same number of segments;
86
+ faces are planes, cylinders, cones, or bilinear or rational ruled splines, joined with C0 continuity at inner
87
+ sections. A twist between sections is refused.
88
+
89
+ ## Other B-rep formats
90
+
91
+ ACIS SAT, Parasolid XT (also inside JT files) and IGES are converted to STEP entities and then read and meshed by the
92
+ same kernel:
93
+
94
+ - **IGES** (`parseIGES`, `igesToSTEP`, `readIGES` for the raw entities, `isIGES` to detect a file): IGES 5.3 fixed
95
+ ASCII files, written from the published specification (US PRO/IPO-100-1996). The Start, Global, Directory Entry,
96
+ Parameter Data and Terminate sections; parameter and record delimiters from the Global section, Hollerith strings
97
+ across lines, D exponents and defaulted fields; units flag and model space scale (the result is in millimetres);
98
+ transformation matrices (124), chained. Manifold solid B-rep objects (186) with their shells, faces, loops, edge and
99
+ vertex lists (514, 510, 508, 504, 502) become solids, voids included; trimmed (144) and bounded (143, 141) surfaces,
100
+ bounded planes (108) and untrimmed surfaces become the faces of one surface model. Curves: circular and conic arcs
101
+ (100, 104; parabolas and hyperbolas as exact rational quadratics), composite curves (102), linear paths (106),
102
+ lines (110), parametric splines (112, exact), rational B-splines (126), offset curves (130, fitted), curves on
103
+ surfaces (142: the model-space curve, else the parameter-space curve mapped through its surface and fitted).
104
+ Surfaces: planes (108, 190), parametric spline surfaces (114, exact: each bicubic patch a Bezier patch of one
105
+ B-spline, knots at the breakpoints; patches that part on a shared edge by more than the file's tolerance are refused),
106
+ ruled surfaces (118: exact for matching rails, sampled otherwise), surfaces of revolution (120), tabulated cylinders (122), rational B-spline surfaces (128), offset
107
+ surfaces (140), cylinders, cones, spheres and tori (192 to 198). Colour numbers and colour definitions (314) colour
108
+ the faces. Not yet: the Compressed and Binary formats, subfigure and solid instances (308/408, 430), CSG
109
+ solids (150 to 184), and wireframe-only files (nothing to mesh). Faces of trimmed-surface files keep their own edges (they
110
+ are not sewn into solids).
111
+
112
+ - **ACIS SAT** (`parseSAT`, `satToSTEP`): save versions before and after ACIS 7.0, written from Spatial's published SAT
113
+ format chapter and class restore descriptions. Bodies, lumps, shells, faces, loops, coedges, edges, vertices; plane,
114
+ cone, cylinder, sphere, torus and spline surfaces; straight, ellipse and interpolated curves (procedural splines from
115
+ the B-spline approximation the file stores with them); body transforms, units and rgb_color attributes.
116
+ - **Parasolid XT** (`parseXT`, `xtToSTEP`, `readXT` for the raw nodes): text (.x_t) and neutral binary (.x_b)
117
+ transmit files, written from the published XT Format Reference. Node layouts come from the base schema, with each
118
+ file's own schema edits applied (Parasolid V14 on); assemblies become mapped items (a part placed many times is meshed
119
+ once); solid and sheet bodies; plane, cylinder, cone, sphere, torus, B-surface, offset, swept and spun surfaces; line,
120
+ circle, ellipse, B-curve, trimmed and intersection curves (through their chart points); rolling-ball and cliff-edge
121
+ blends (each ball centre moved onto both offset supports, or onto the surface and the cliff edge, the exact arc
122
+ between the contacts as a rational quadratic); tolerant edges (the curve followed along a fin's trimmed SP-curve over
123
+ its face surface); SDL/TYSA_COLOUR attributes. Lengths are metres. Foreign geometry is left out and listed in
124
+ `warnings` for now.
125
+ - **JT** (`parseJT`, `tessellateJT`): JT 9.5 and later (ISO 14306), written from the JT File Format Reference and
126
+ the standard under Siemens' published licence terms (`THIRD-PARTY-NOTICES.md`, `docs/jt-licensing.md`). The file header and table
127
+ of contents, zlib (JT 9) and LZMA (JT 10) segment compression, the scene graph (partitions, groups, instances,
128
+ parts, LOD and switch nodes, transforms, materials, properties with names and units) and each part's exact B-rep
129
+ from its XT B-rep segment (or the file's MultiXT segment), read by the Parasolid reader. Parts and placements come
130
+ out in metres. JT 9 and JT 10 tessellated shapes (tri-strip sets) are decoded into triangle meshes with normals and
131
+ face groups: Int32 compressed data packets (bit-length, arithmetic, chopper, move-to-front), the polygon mesh
132
+ topology decoder, coordinates and Deering normals, each checked against the hashes the file stores; real files'
133
+ departures from the published texts are in `docs/jt-reader.md`. Polylines and JT files that partition nodes refer
134
+ to are listed in `warnings`.
135
+
136
+ ## What stage 1 reads
137
+
138
+ - **The file:** one pass indexes every entity instance of the DATA sections; parameters are parsed only when used, so
139
+ a 10 MB file is not turned into millions of objects to read its structure. Text escapes (`''`, `\S\`, `\X\`, `\X2\`,
140
+ `\X4\`) are decoded; bytes are read as ISO 8859-1, the standard's character set. `STEPFile` exposes the table:
141
+ `get(id)`, `ids(type)` (complex instances listed under each partial type), `args(id, type)`, `census()`.
142
+ - **Products:** every `PRODUCT_DEFINITION` with its product's name and id (part number).
143
+ - **Assemblies:** `NEXT_ASSEMBLY_USAGE_OCCURRENCE` links placed by `CONTEXT_DEPENDENT_SHAPE_REPRESENTATION` through
144
+ an `ITEM_DEFINED_TRANSFORMATION` (or a Cartesian transformation operator), whichever way round the exporter wrote
145
+ the two representations, and `MAPPED_ITEM` copies. A component an assembly link already places is not placed again
146
+ by a mapped copy of it.
147
+ - **Bodies:** `MANIFOLD_SOLID_BREP`, `BREP_WITH_VOIDS`, `FACETED_BREP`, `SHELL_BASED_SURFACE_MODEL` and the AP242
148
+ tessellated bodies (`TESSELLATED_SOLID`, `TESSELLATED_SHELL`, triangulated faces and surface sets, with triangle
149
+ lists, strips and fans through `pnindex`, and the file's normals), with their faces and distinct edges, and a
150
+ census of surface and edge-curve types.
151
+ - **Units:** each body's length unit in metres (SI prefixes and conversion-based units such as inches); placements are
152
+ converted to metres. A representation context with no length unit the reader can read (no
153
+ `GLOBAL_UNIT_ASSIGNED_CONTEXT`, a misspelt one, an unknown unit) is refused with a TypeError naming it, never taken
154
+ as metres; with no plane-angle unit it is warned of, and a cone's half angle in it is refused.
155
+ - **References:** a reference to an instance the file never defines is named in `warnings` with what refers to it;
156
+ a body that lost a shell, face, loop or edge to one lists it in `unresolved` and is not imported.
157
+ - **Occurrences:** every placed product (a root, or a component where an assembly places it), with its parent and its
158
+ frame in metres; each instance names its occurrence.
159
+ - **Validation properties:** `PROPERTY_DEFINITION`s tagged geometric or tessellated validation property, of a
160
+ product or of a shape aspect that names bodies (`GEOMETRIC_ITEM_SPECIFIC_USAGE`, or a shape representation of the
161
+ aspect): volume, area, centre point, bounding box and number of facets, in metres, with the measure items' own
162
+ derived units. Values for independent surfaces are kept apart; independent points and curves, and the zero values
163
+ some exporters write as placeholders, are left out. `validateSTEP` measures the meshes in each property's frame;
164
+ a product's values cover its components' solids, its area may count surface bodies too (exporters differ), and a
165
+ tessellated property is checked against the tessellated bodies.
166
+ - **Colours:** `STYLED_ITEM` and `OVER_RIDING_STYLED_ITEM` down to `COLOUR_RGB` or a pre-defined colour, with
167
+ `SURFACE_STYLE_TRANSPARENT` as alpha; body colours, and face colours that differ.
168
+
169
+ ## Geometry and tessellation (stages 2 to 4)
170
+
171
+ - **Curves:** line, circle, ellipse, polyline, B-spline and rational B-spline (simple or complex instances), through
172
+ surface, seam, intersection and trimmed curves. A clamped B-spline that ends where it starts is treated as closed
173
+ even when the file does not mark it so.
174
+ - **Surfaces:** plane, cylinder, cone, sphere, torus (and degenerate torus), surface of revolution, surface of linear
175
+ extrusion, B-spline and rational B-spline, offset and rectangular trimmed surfaces. Each evaluates points and first
176
+ derivatives (The NURBS Book's algorithms for splines) and inverts a point to its (u, v): closed form for the
177
+ analytic surfaces, Gauss-Newton from the nearest of a grid of samples for splines.
178
+ - **Edges:** each edge is discretized once, between its exact vertices, by chord deflection and angle; every face
179
+ that uses it uses the same points, so the mesh has no cracks.
180
+ - **Faces:** bounds are mapped into the surface's (u, v), unwrapped across seams; a pole or apex becomes a line of the
181
+ domain; bounds that wrap round a surface are cut at a seam (a band) or closed at the pole (a cap); a face with no
182
+ bounds covers its whole closed surface. The domain is triangulated with an exact-predicate constrained Delaunay
183
+ triangulation (Shewchuk's robust predicates, Sloan's constraint recovery) over interior points spaced by curvature,
184
+ then refined where an edge midpoint or a triangle centre strays from the surface by more than the deflection or
185
+ neighbouring normals turn by more than the angle. Normals are the exact surface normals, flipped with the face.
186
+ - **Options:** `relativeDeflection` (default 0.001 of each body's bounding-box diagonal) or `deflection` in metres,
187
+ `angle` (default 0.5 radians), `interiorDeflection` and `interiorAngle` for face interiors, `minSize`, and
188
+ `maxFaceVertices` (default 50,000).
189
+
190
+ ## Errors and limits
191
+
192
+ A malformed file throws a `TypeError` that names the line. `maxInstances` (default 1,000,000) bounds the placed bodies
193
+ of an assembly; a larger one throws a `RangeError` that names the option. Links, placements and styles the reader
194
+ cannot use are skipped with a message in `model.warnings` (at most 100). A face whose surface, curve or bounds the
195
+ kernel cannot resolve is left out of its body's mesh and listed in `mesh.failures` with the reason; the rest of the body
196
+ still meshes. Tessellation options out of range throw a `RangeError` that names the option.
197
+
198
+ ## Licence
199
+
200
+ Apache-2.0, like the rest of Margo Engine (`LICENSE`). The package's `NOTICE` adds the Siemens JT notice the JT reader
201
+ must carry (`docs/jt-licensing.md`); every file of the reader in `src/jt` carries it in its header too.
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
- {
2
- "name": "@margoengine/brep",
3
- "version": "0.1.0",
4
- "description": "Margo's own CAD kernel: STEP (ISO 10303-21), IGES 5.3, ACIS SAT, Parasolid XT and JT (ISO 14306) reading, product structure, units and colours, exact B-rep geometry (analytic surfaces and NURBS) and crack-free tessellation.",
5
- "keywords": [
6
- "margoengine",
7
- "webgpu",
8
- "3d",
9
- "cad",
10
- "b-rep",
11
- "step",
12
- "nurbs",
13
- "tessellation",
14
- "jt",
15
- "iges"
16
- ],
17
- "homepage": "https://margoengine.com",
18
- "bugs": {
19
- "url": "https://github.com/scottcampbelldata/margoengine/issues"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/scottcampbelldata/margoengine.git",
24
- "directory": "packages/brep"
25
- },
26
- "license": "Apache-2.0",
27
- "author": "Scott Campbell",
28
- "type": "module",
29
- "publishConfig": {
30
- "access": "public"
31
- },
32
- "scripts": {
33
- "build": "node ../../scripts/build-optional.js brep",
34
- "test": "npm run build && node --test tests/*.test.js",
35
- "prepack": "npm run build"
36
- },
37
- "sideEffects": false,
38
- "exports": {
39
- ".": {
40
- "types": "./dist/index.d.ts",
41
- "import": "./dist/index.js"
42
- }
43
- },
44
- "files": [
45
- "dist",
46
- "LICENSE",
47
- "NOTICE"
48
- ],
49
- "dependencies": {
50
- "@margoengine/math": "^0.1.0"
51
- }
52
- }
1
+ {
2
+ "name": "@margoengine/brep",
3
+ "version": "1.0.0",
4
+ "description": "Margo's own CAD kernel: STEP (ISO 10303-21), IGES 5.3, ACIS SAT, Parasolid XT and JT (ISO 14306) reading, product structure, units and colours, exact B-rep geometry (analytic surfaces and NURBS) and crack-free tessellation.",
5
+ "keywords": [
6
+ "margoengine",
7
+ "webgpu",
8
+ "3d",
9
+ "cad",
10
+ "b-rep",
11
+ "step",
12
+ "nurbs",
13
+ "tessellation",
14
+ "jt",
15
+ "iges"
16
+ ],
17
+ "homepage": "https://margoengine.com",
18
+ "bugs": {
19
+ "url": "https://github.com/scottcampbelldata/margoengine/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/scottcampbelldata/margoengine.git",
24
+ "directory": "packages/brep"
25
+ },
26
+ "license": "Apache-2.0",
27
+ "author": "Scott Campbell",
28
+ "type": "module",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "node ../../scripts/build-optional.js brep",
34
+ "test": "npm run build && node --test tests/*.test.js",
35
+ "prepack": "npm run build"
36
+ },
37
+ "sideEffects": false,
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.js"
42
+ }
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "LICENSE",
47
+ "NOTICE"
48
+ ],
49
+ "dependencies": {
50
+ "@margoengine/math": "^1.0.0"
51
+ }
52
+ }