@margoengine/brep 0.0.0-stage → 0.1.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.
- package/LICENSE +201 -0
- package/NOTICE +14 -0
- package/README.md +201 -3
- package/dist/geometry/curves.d.ts +31 -0
- package/dist/geometry/exact.d.ts +6 -0
- package/dist/geometry/nurbs.d.ts +35 -0
- package/dist/geometry/read.d.ts +22 -0
- package/dist/geometry/surfaces.d.ts +75 -0
- package/dist/geometry/vec.d.ts +33 -0
- package/dist/iges/file.d.ts +66 -0
- package/dist/iges/geometry.d.ts +148 -0
- package/dist/iges/shapes.d.ts +30 -0
- package/dist/iges/step.d.ts +19 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +16185 -0
- package/dist/jt/codec.d.ts +29 -0
- package/dist/jt/file.d.ts +70 -0
- package/dist/jt/lsg.d.ts +82 -0
- package/dist/jt/lzma.d.ts +22 -0
- package/dist/jt/mesh.d.ts +17 -0
- package/dist/jt/read.d.ts +68 -0
- package/dist/mesh/cdt.d.ts +41 -0
- package/dist/mesh/tessellate.d.ts +106 -0
- package/dist/mesh/validate.d.ts +45 -0
- package/dist/model/blend.d.ts +38 -0
- package/dist/model/boolean.d.ts +37 -0
- package/dist/model/build.d.ts +75 -0
- package/dist/model/check.d.ts +8 -0
- package/dist/model/distance.d.ts +28 -0
- package/dist/model/export.d.ts +17 -0
- package/dist/model/faces.d.ts +183 -0
- package/dist/model/geometry.d.ts +103 -0
- package/dist/model/import.d.ts +30 -0
- package/dist/model/index.d.ts +27 -0
- package/dist/model/intersect.d.ts +28 -0
- package/dist/model/loft.d.ts +12 -0
- package/dist/model/march.d.ts +20 -0
- package/dist/model/mass.d.ts +28 -0
- package/dist/model/offset-surface.d.ts +16 -0
- package/dist/model/offset.d.ts +39 -0
- package/dist/model/seams.d.ts +26 -0
- package/dist/model/setback.d.ts +12 -0
- package/dist/model/sew.d.ts +47 -0
- package/dist/model/sweep.d.ts +37 -0
- package/dist/model/topology.d.ts +116 -0
- package/dist/model/validate.d.ts +16 -0
- package/dist/sat/read.d.ts +16 -0
- package/dist/step/file.d.ts +82 -0
- package/dist/step/structure.d.ts +131 -0
- package/dist/step/write.d.ts +57 -0
- package/dist/xt/read.d.ts +22 -0
- package/dist/xt/schema.d.ts +18 -0
- package/dist/xt/step.d.ts +19 -0
- package/package.json +52 -6
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/NOTICE
ADDED
|
@@ -0,0 +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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,201 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
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.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type STEPFile } from '../step/file.js';
|
|
2
|
+
import { type SplineCurve } from './nurbs.js';
|
|
3
|
+
import { type XYZ } from './vec.js';
|
|
4
|
+
/** A 3D curve. */
|
|
5
|
+
export interface Curve {
|
|
6
|
+
/** Period of a closed curve (circle, ellipse, closed B-spline); 0 for an open one. */
|
|
7
|
+
readonly period: number;
|
|
8
|
+
/** Parameter range (infinite for a line; one period for a circle or ellipse). */
|
|
9
|
+
readonly domain: readonly [number, number];
|
|
10
|
+
/** Point and tangent at t: [x, y, z, dx, dy, dz]. */
|
|
11
|
+
at(t: number): number[];
|
|
12
|
+
/** The parameter of `p`, a point on (or very near) the curve; `hint` is a nearby parameter. */
|
|
13
|
+
parameter(p: readonly number[], hint?: number): number;
|
|
14
|
+
/** Parameters from a to b (either order, both included) whose chords stay within `deflection` and turn by at most `turn`. */
|
|
15
|
+
sample(a: number, b: number, deflection: number, turn: number): number[];
|
|
16
|
+
}
|
|
17
|
+
/** The largest angle step that keeps a circle of radius r within the chord deflection and turn. */
|
|
18
|
+
export declare const angleStep: (radius: number, deflection: number, turn: number) => number;
|
|
19
|
+
/** The curve of entity `id` (cached per file by the caller). Throws a TypeError for a curve the kernel lacks. */
|
|
20
|
+
export declare function curveOf(file: STEPFile, id: number): Curve;
|
|
21
|
+
/** Evaluators for curves the modeler makes from parameters (no STEP entity behind them). */
|
|
22
|
+
export declare const makeCurve: {
|
|
23
|
+
line: (origin: XYZ, direction: XYZ) => Curve;
|
|
24
|
+
/** A circle is an ellipse with equal semi-axes. */
|
|
25
|
+
ellipse: (f: {
|
|
26
|
+
origin: XYZ;
|
|
27
|
+
x: XYZ;
|
|
28
|
+
y: XYZ;
|
|
29
|
+
}, a: number, b: number) => Curve;
|
|
30
|
+
spline: (s: SplineCurve, closed: boolean) => Curve;
|
|
31
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orientation of d against the plane through a, b and c: positive when d lies on the side a, b, c turn clockwise as
|
|
3
|
+
* seen from (below the counter-clockwise side), negative on the other side, zero when the four points are coplanar.
|
|
4
|
+
* The sign is exact; the magnitude approximates six times the signed volume of the tetrahedron.
|
|
5
|
+
*/
|
|
6
|
+
export declare function orient3d(a: readonly number[], b: readonly number[], c: readonly number[], d: readonly number[]): number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The full knot vector from STEP's distinct knots and their multiplicities. */
|
|
2
|
+
export declare function knotVector(knots: readonly number[], multiplicities: readonly number[]): number[];
|
|
3
|
+
/**
|
|
4
|
+
* A2.1: the knot span index of `u` (n = last control point index, p = degree), always a span of non-zero length. At
|
|
5
|
+
* the domain's ends that is the first span past U[p] and the last before U[n + 1]: a knot vector whose end knot repeats
|
|
6
|
+
* more than p + 1 times (a writer listing the start value twice, multiplicities 4 and 3 on a cubic) has empty spans
|
|
7
|
+
* there, whose basis is 0 / 0, and the control points beyond the p + 1 at the end take no part in the curve.
|
|
8
|
+
*/
|
|
9
|
+
export declare function findSpan(n: number, p: number, u: number, U: readonly number[]): number;
|
|
10
|
+
/** A2.3 for orders 0 and 1: `out[0][j]` the basis functions N(span - p + j, p) at u, `out[1][j]` their derivatives. */
|
|
11
|
+
export declare function basisDerivatives(span: number, u: number, p: number, U: readonly number[]): [number[], number[]];
|
|
12
|
+
/** A B-spline curve: degree, homogeneous control points (4 per point), knot vector. */
|
|
13
|
+
export interface SplineCurve {
|
|
14
|
+
readonly degree: number;
|
|
15
|
+
readonly points: Float64Array;
|
|
16
|
+
readonly knots: readonly number[];
|
|
17
|
+
}
|
|
18
|
+
/** Point and first derivative of a (rational) B-spline curve at u: [x, y, z, dx, dy, dz]. */
|
|
19
|
+
export declare function curveAt(c: SplineCurve, u: number): number[];
|
|
20
|
+
/** A B-spline surface: degrees, homogeneous control net (row-major, u index outer: (i * nv + j) * 4), knots. */
|
|
21
|
+
export interface SplineSurface {
|
|
22
|
+
readonly uDegree: number;
|
|
23
|
+
readonly vDegree: number;
|
|
24
|
+
readonly nu: number;
|
|
25
|
+
readonly nv: number;
|
|
26
|
+
readonly points: Float64Array;
|
|
27
|
+
readonly uKnots: readonly number[];
|
|
28
|
+
readonly vKnots: readonly number[];
|
|
29
|
+
}
|
|
30
|
+
/** Point and first partial derivatives of a (rational) B-spline surface: [x, y, z, du(3), dv(3)]. */
|
|
31
|
+
export declare function surfaceAt(s: SplineSurface, u: number, v: number): number[];
|
|
32
|
+
/** Whether a knot vector is clamped (its first and last p + 1 knots repeat), so the spline starts and ends on control points. */
|
|
33
|
+
export declare function clamped(U: readonly number[], p: number): boolean;
|
|
34
|
+
/** Distinct knot values inside [U[p], U[n + 1]] (span boundaries), for sampling one span at a time. */
|
|
35
|
+
export declare function spanBreaks(U: readonly number[], p: number, n: number): number[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type STEPFile, type STEPValue } from '../step/file.js';
|
|
2
|
+
import { type XYZ } from './vec.js';
|
|
3
|
+
export declare const ref: (v: STEPValue | undefined) => number | undefined;
|
|
4
|
+
export declare const num: (v: STEPValue | undefined, fallback?: number) => number;
|
|
5
|
+
export declare const list: (v: STEPValue | undefined) => readonly STEPValue[];
|
|
6
|
+
/** An entity the kernel cannot evaluate yet: a TypeError naming it, so one bad face or edge can be skipped. */
|
|
7
|
+
export declare function unsupported(file: STEPFile, id: number, what: string): TypeError;
|
|
8
|
+
/** CARTESIAN_POINT coordinates (missing ones 0). */
|
|
9
|
+
export declare function point(file: STEPFile, id: number | undefined): XYZ;
|
|
10
|
+
/** DIRECTION as a unit vector. */
|
|
11
|
+
export declare function direction(file: STEPFile, id: number | undefined): XYZ;
|
|
12
|
+
/** VECTOR as direction times magnitude. */
|
|
13
|
+
export declare function vector(file: STEPFile, id: number | undefined): XYZ;
|
|
14
|
+
/** An orthonormal frame: origin and axes. */
|
|
15
|
+
export interface Frame {
|
|
16
|
+
readonly origin: XYZ;
|
|
17
|
+
readonly x: XYZ;
|
|
18
|
+
readonly y: XYZ;
|
|
19
|
+
readonly z: XYZ;
|
|
20
|
+
}
|
|
21
|
+
/** AXIS2_PLACEMENT_3D as a frame (ISO 10303-42 build_axes; a 2D placement lies in z = 0). */
|
|
22
|
+
export declare function frame(file: STEPFile, id: number | undefined): Frame;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type STEPFile } from '../step/file.js';
|
|
2
|
+
import { type Curve } from './curves.js';
|
|
3
|
+
import { type SplineSurface } from './nurbs.js';
|
|
4
|
+
import { type Frame } from './read.js';
|
|
5
|
+
import { type XYZ } from './vec.js';
|
|
6
|
+
/** A parametric surface S(u, v). */
|
|
7
|
+
export interface Surface {
|
|
8
|
+
/** Period in u and v (2 pi for angles, a closed B-spline's domain length), 0 when open. */
|
|
9
|
+
readonly uPeriod: number;
|
|
10
|
+
readonly vPeriod: number;
|
|
11
|
+
/** Parameter domain (infinite for planes, and in v for cylinders and cones). */
|
|
12
|
+
readonly uDomain: readonly [number, number];
|
|
13
|
+
readonly vDomain: readonly [number, number];
|
|
14
|
+
/** Point and first partial derivatives: [x, y, z, Su (3), Sv (3)]. */
|
|
15
|
+
at(u: number, v: number): number[];
|
|
16
|
+
/** Unit normal along Su x Sv, defined at poles and apexes too. */
|
|
17
|
+
normal(u: number, v: number): XYZ;
|
|
18
|
+
/** (u, v) of `p`, a point on or very near the surface; `hint` is a nearby (u, v). */
|
|
19
|
+
parameters(p: readonly number[], hint?: readonly number[]): [number, number];
|
|
20
|
+
/** Steps (du, dv) for interior points over the box [u0, u1, v0, v1]; Infinity where the surface is straight. */
|
|
21
|
+
steps(box: readonly number[], deflection: number, turn: number): [number, number];
|
|
22
|
+
/** v of the pole or apex on side +1 (high v) or -1 (low v), when the surface collapses to a point there. */
|
|
23
|
+
pole(side: 1 | -1): number | undefined;
|
|
24
|
+
/** u of a pole on side +1 (high u) or -1 (low u), where v has no meaning (a B-spline row collapsed at a u end). */
|
|
25
|
+
uPole?(side: 1 | -1): number | undefined;
|
|
26
|
+
/** Whether (u, v) is a pole or apex, where u has no meaning. */
|
|
27
|
+
singular(u: number, v: number): boolean;
|
|
28
|
+
/** A spline's knots in u and in v where its derivatives may jump, ascending, ends included (integrals split there). */
|
|
29
|
+
breaks?(): readonly [readonly number[], readonly number[]];
|
|
30
|
+
/**
|
|
31
|
+
* Whether an edge's straight (u, v) chord between two of its samples can stray from it further than the samples'
|
|
32
|
+
* own deflection: on a profile turned about an axis it does not lie in a plane with, a straight line (a cylinder's
|
|
33
|
+
* seam written that way) is a curve in (u, v).
|
|
34
|
+
*/
|
|
35
|
+
readonly skewed?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* How far the line of constant u turns about the surface's axis at v, from where it starts: on a profile turned
|
|
38
|
+
* about an axis it is not in a plane with, the point (u, v) lies at angle u + twist(v) about it. Meshing takes that
|
|
39
|
+
* turn out, so the domain is laid out as the surface is (a cylinder's side unrolled); otherwise its u lines run as
|
|
40
|
+
* helices that turn flat along a rim where the profile ends tangent to its circle, and triangles across them tilt
|
|
41
|
+
* off the surface. 0 everywhere unless `twisted`.
|
|
42
|
+
*/
|
|
43
|
+
twist?(v: number): number;
|
|
44
|
+
/** Whether `twist` is not 0 everywhere. */
|
|
45
|
+
twisted?(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* With `twist`: length along the surface's meridian section (the profile brought into one half plane of its axis)
|
|
48
|
+
* from the profile's start to v, and `meridianParameter` its inverse. Meshing lays v out by it, so the domain is
|
|
49
|
+
* spaced as the surface is where the profile's speed varies (down to zero where it ends tangent to its circle).
|
|
50
|
+
* Where the profile's range is not finite or it is closed, its section's speed at one point times v.
|
|
51
|
+
*/
|
|
52
|
+
meridian?(v: number): number;
|
|
53
|
+
meridianParameter?(length: number): number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether (u, v) is a place where a parameter of `s` has no meaning: Su or Sv vanishes there (`singular`) and the whole
|
|
57
|
+
* line of that parameter through it lies within `reach` of the point (a pole or apex, listed or not). Where a derivative
|
|
58
|
+
* vanishes at the point alone (a B-spline's corner whose two control points there meet, so Su is zero at it) the line
|
|
59
|
+
* still runs away from it, and the point has its own (u, v), as any corner does.
|
|
60
|
+
*/
|
|
61
|
+
export declare function onPole(s: Surface, u: number, v: number, reach: number): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The surface of entity `id`. `angleUnit` is radians per plane-angle unit of the body's context (a cone's half angle
|
|
64
|
+
* is written in it). Throws a TypeError for a surface the kernel lacks.
|
|
65
|
+
*/
|
|
66
|
+
export declare function surfaceOf(file: STEPFile, id: number, angleUnit: number, curves: (id: number) => Curve): Surface;
|
|
67
|
+
/** Evaluators for surfaces the modeler makes from parameters (no STEP entity behind them). */
|
|
68
|
+
export declare const makeSurface: {
|
|
69
|
+
plane: (f: Frame) => Surface;
|
|
70
|
+
/** A cylinder is a cone with zero half angle. */
|
|
71
|
+
cone: (f: Frame, radius: number, halfAngle: number) => Surface;
|
|
72
|
+
sphere: (f: Frame, radius: number) => Surface;
|
|
73
|
+
torus: (f: Frame, major: number, minor: number) => Surface;
|
|
74
|
+
spline: (s: SplineSurface, uClosed: boolean, vClosed: boolean) => Surface;
|
|
75
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type XYZ = [number, number, number];
|
|
2
|
+
export declare const add: (a: readonly number[], b: readonly number[]) => XYZ;
|
|
3
|
+
export declare const sub: (a: readonly number[], b: readonly number[]) => XYZ;
|
|
4
|
+
export declare const scale: (a: readonly number[], s: number) => XYZ;
|
|
5
|
+
export declare const dot: (a: readonly number[], b: readonly number[]) => number;
|
|
6
|
+
export declare const cross: (a: readonly number[], b: readonly number[]) => XYZ;
|
|
7
|
+
/**
|
|
8
|
+
* |(x, y, z)|: a square root of the sum of squares, several times faster than Math.hypot in V8 (these run millions of
|
|
9
|
+
* times an operation); Math.hypot where squaring would overflow or underflow (directions are dimensionless, so any
|
|
10
|
+
* finite size reaches here).
|
|
11
|
+
*/
|
|
12
|
+
export declare const norm: (x: number, y: number, z: number) => number;
|
|
13
|
+
export declare const length: (a: readonly number[]) => number;
|
|
14
|
+
export declare const distance: (a: readonly number[], b: readonly number[]) => number;
|
|
15
|
+
/** `a` scaled to unit length, or undefined when it has none. */
|
|
16
|
+
export declare const unit: (a: readonly number[]) => XYZ | undefined;
|
|
17
|
+
/** Angle between two vectors in radians (0 when either is zero). */
|
|
18
|
+
export declare const angle: (a: readonly number[], b: readonly number[]) => number;
|
|
19
|
+
/** `value` moved by whole periods to lie nearest `near`. */
|
|
20
|
+
export declare const nearest: (value: number, near: number, period: number) => number;
|
|
21
|
+
/**
|
|
22
|
+
* The size a model's relative tolerances scale with: how far it reaches from the origin (its farthest point, or sphere
|
|
23
|
+
* given as a centre and radius), but no more than the diagonal of its box, so the same wherever it sits. Its reach
|
|
24
|
+
* alone lets a tolerance grow past the model's features far out (1e-6 of the reach of a part 1 km out on each axis is
|
|
25
|
+
* 1.7 mm). No less than `rounding` (default `ROUNDING`) of its farthest coordinate, though: float64 rounds a coordinate
|
|
26
|
+
* to 1.1e-16 of itself, and points computed twice far out part by many of those.
|
|
27
|
+
*/
|
|
28
|
+
export declare function modelSize(points: Iterable<readonly number[]>, spheres?: Iterable<readonly [readonly number[], number]>, rounding?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* The least model size as a fraction of the farthest coordinate: 1e-9 of it (the Booleans' merge tolerance) is then
|
|
31
|
+
* about 9 float64 roundings of that coordinate, and 1e-6 of it (where two points meet) about 9000.
|
|
32
|
+
*/
|
|
33
|
+
export declare const ROUNDING = 0.000001;
|