@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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type XYZ } from '../geometry/vec.js';
|
|
2
|
+
import { type Profile } from './build.js';
|
|
3
|
+
import { Body, type History, type Name } from './topology.js';
|
|
4
|
+
/**
|
|
5
|
+
* One piece of a path: a line to `to`, or an arc to `to` about `center`, turning counter-clockwise about `axis` (by
|
|
6
|
+
* default the shorter way round; an arc of half a turn or a whole one needs its axis).
|
|
7
|
+
*/
|
|
8
|
+
export interface PathSegment {
|
|
9
|
+
readonly kind: 'line' | 'arc';
|
|
10
|
+
readonly to: XYZ;
|
|
11
|
+
readonly center?: XYZ;
|
|
12
|
+
readonly axis?: XYZ;
|
|
13
|
+
/** The name the faces swept along this piece take after the profile segment's name. */
|
|
14
|
+
readonly name?: Name;
|
|
15
|
+
}
|
|
16
|
+
/** A path from `start`, piece by piece, its tangent continuous where one piece meets the next. */
|
|
17
|
+
export interface Path {
|
|
18
|
+
readonly name: Name;
|
|
19
|
+
readonly start: XYZ;
|
|
20
|
+
readonly segments: readonly PathSegment[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Sweeps a closed planar profile of lines and arcs along a path of lines and arcs into a solid named `name`. The
|
|
24
|
+
* profile's plane must pass through the path's start, across the path's tangent there; it is carried along the path
|
|
25
|
+
* in its rotation-minimising frame (translated along lines, turned about the axis of arcs). The solid has a start and
|
|
26
|
+
* an end face (planes) and a side face per profile segment and path piece, named `<piece>/<segment>` (pieces default
|
|
27
|
+
* to p0, p1 and so on, segments to e0, e1 and so on). A path that ends where it starts, along its starting tangent,
|
|
28
|
+
* makes a ring with no end faces.
|
|
29
|
+
*
|
|
30
|
+
* Throws a RangeError for an open, degenerate or self-touching profile, a profile not across the path's start, a path
|
|
31
|
+
* with a corner or a degenerate piece, an arc curving tighter than the profile reaches towards its axis, a profile
|
|
32
|
+
* segment that would turn into an unsupported surface (an arc reaching the axis of a path arc), and pieces of the path
|
|
33
|
+
* close enough for the solid to cross itself (see the file header).
|
|
34
|
+
*/
|
|
35
|
+
export declare function sweep(name: Name, profile: Profile, path: Path, { history }?: {
|
|
36
|
+
history?: History;
|
|
37
|
+
}): Body;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { XYZ } from '../geometry/vec.js';
|
|
2
|
+
import type { CurveDef, SurfaceDef } from './geometry.js';
|
|
3
|
+
/** A persistent name, such as 'box1/face:+z' or 'extrude2/side:sketch1/e3'. */
|
|
4
|
+
export type Name = string;
|
|
5
|
+
/** A point where edges meet, with its persistent name and how far it may be from its edges' curves. */
|
|
6
|
+
export declare class Vertex {
|
|
7
|
+
name: Name;
|
|
8
|
+
point: XYZ;
|
|
9
|
+
/** Largest distance the vertex may be from the curves of its edges, in metres. */
|
|
10
|
+
tolerance: number;
|
|
11
|
+
constructor(name: Name, point: XYZ,
|
|
12
|
+
/** Largest distance the vertex may be from the curves of its edges, in metres. */
|
|
13
|
+
tolerance?: number);
|
|
14
|
+
}
|
|
15
|
+
/** A bounded piece of a curve between two vertices (one, for a closed edge), used once each way by two face loops in a solid. */
|
|
16
|
+
export declare class Edge {
|
|
17
|
+
name: Name;
|
|
18
|
+
curve: CurveDef;
|
|
19
|
+
start: Vertex;
|
|
20
|
+
end: Vertex;
|
|
21
|
+
/** Whether start to end runs in the curve's increasing parameter direction. */
|
|
22
|
+
sameSense: boolean;
|
|
23
|
+
/** Largest distance from the edge to the surfaces of its faces, in metres. */
|
|
24
|
+
tolerance: number;
|
|
25
|
+
/** The edge's uses by face loops: two, run in opposite directions, for an edge inside a solid. */
|
|
26
|
+
readonly coedges: Coedge[];
|
|
27
|
+
constructor(name: Name, curve: CurveDef, start: Vertex, end: Vertex,
|
|
28
|
+
/** Whether start to end runs in the curve's increasing parameter direction. */
|
|
29
|
+
sameSense?: boolean,
|
|
30
|
+
/** Largest distance from the edge to the surfaces of its faces, in metres. */
|
|
31
|
+
tolerance?: number);
|
|
32
|
+
/** A closed edge (a full circle) starts and ends at one vertex. */
|
|
33
|
+
get closed(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/** One use of an edge by a face loop, along the edge or against it. */
|
|
36
|
+
export declare class Coedge {
|
|
37
|
+
readonly edge: Edge;
|
|
38
|
+
/** Whether the loop runs along the edge (start to end). */
|
|
39
|
+
readonly forward: boolean;
|
|
40
|
+
loop: Loop;
|
|
41
|
+
constructor(edge: Edge,
|
|
42
|
+
/** Whether the loop runs along the edge (start to end). */
|
|
43
|
+
forward: boolean, loop: Loop);
|
|
44
|
+
get start(): Vertex;
|
|
45
|
+
get end(): Vertex;
|
|
46
|
+
}
|
|
47
|
+
/** A closed chain of coedges bounding a face; the face lies to their left seen from its normal. */
|
|
48
|
+
export declare class Loop {
|
|
49
|
+
face: Face;
|
|
50
|
+
readonly coedges: Coedge[];
|
|
51
|
+
constructor(face: Face);
|
|
52
|
+
/** Adds the use of `edge` (forward or reversed) at the end of the loop. */
|
|
53
|
+
use(edge: Edge, forward: boolean): Coedge;
|
|
54
|
+
}
|
|
55
|
+
/** A bounded piece of a surface, its normal along the surface's or against it, bounded by loops. */
|
|
56
|
+
export declare class Face {
|
|
57
|
+
name: Name;
|
|
58
|
+
surface: SurfaceDef;
|
|
59
|
+
/** Whether the face normal (out of a solid) is the surface's natural normal. */
|
|
60
|
+
sense: boolean;
|
|
61
|
+
shell?: Shell | undefined;
|
|
62
|
+
readonly loops: Loop[];
|
|
63
|
+
constructor(name: Name, surface: SurfaceDef,
|
|
64
|
+
/** Whether the face normal (out of a solid) is the surface's natural normal. */
|
|
65
|
+
sense: boolean, shell?: Shell | undefined);
|
|
66
|
+
/** A new loop on this face; the face lies to the left of its coedges, seen from the face normal. */
|
|
67
|
+
loop(): Loop;
|
|
68
|
+
}
|
|
69
|
+
/** A connected set of faces: a closed shell bounds a solid (or a cavity in one). */
|
|
70
|
+
export declare class Shell {
|
|
71
|
+
body?: Body | undefined;
|
|
72
|
+
readonly faces: Face[];
|
|
73
|
+
/** For a cavity's shell: the shell it lies inside. Its faces face into the cavity, out of the material. */
|
|
74
|
+
outer?: Shell;
|
|
75
|
+
constructor(body?: Body | undefined);
|
|
76
|
+
add(face: Face): Face;
|
|
77
|
+
}
|
|
78
|
+
/** A solid or a sheet: its shells, and the faces, edges and vertices they hold. */
|
|
79
|
+
export declare class Body {
|
|
80
|
+
name: Name;
|
|
81
|
+
/** 'solid': closed shells bounding material; 'sheet': open or closed surfaces with no inside. */
|
|
82
|
+
kind: 'solid' | 'sheet';
|
|
83
|
+
readonly shells: Shell[];
|
|
84
|
+
constructor(name: Name,
|
|
85
|
+
/** 'solid': closed shells bounding material; 'sheet': open or closed surfaces with no inside. */
|
|
86
|
+
kind: 'solid' | 'sheet');
|
|
87
|
+
shell(): Shell;
|
|
88
|
+
get faces(): Face[];
|
|
89
|
+
get edges(): Edge[];
|
|
90
|
+
get vertices(): Vertex[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* One operation's effect on names: what it made new (and from what), what continued under other names (a face split
|
|
94
|
+
* by a cut continues as its pieces), and what it removed.
|
|
95
|
+
*/
|
|
96
|
+
export interface HistoryEntry {
|
|
97
|
+
readonly operation: Name;
|
|
98
|
+
/** New entities and the entities they were made from (a side face from a sketch segment, an edge where two faces met). */
|
|
99
|
+
readonly generated: readonly (readonly [Name, readonly Name[]])[];
|
|
100
|
+
/** Entities that continue as others: [from, to], several for one `from` when it was split. */
|
|
101
|
+
readonly modified: readonly (readonly [Name, Name])[];
|
|
102
|
+
readonly deleted: readonly Name[];
|
|
103
|
+
}
|
|
104
|
+
/** The record of operations that lets a name stored before an edit find what became of it. */
|
|
105
|
+
export declare class History {
|
|
106
|
+
readonly entries: HistoryEntry[];
|
|
107
|
+
record(entry: HistoryEntry): void;
|
|
108
|
+
/**
|
|
109
|
+
* The current names of what `name` became: itself when nothing changed it, the names it continued as (a face split
|
|
110
|
+
* by a cut becomes two), or none when it was deleted.
|
|
111
|
+
*/
|
|
112
|
+
resolve(name: Name): Name[];
|
|
113
|
+
/** The current names of what was made from `name` (the side face swept from a sketch segment), followed to now. */
|
|
114
|
+
generatedFrom(name: Name): Name[];
|
|
115
|
+
private follow;
|
|
116
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Body, Edge, Name } from './topology.js';
|
|
2
|
+
/** One problem, with the persistent name of the entity it concerns. */
|
|
3
|
+
export interface ValidityProblem {
|
|
4
|
+
readonly name: Name;
|
|
5
|
+
readonly problem: string;
|
|
6
|
+
}
|
|
7
|
+
/** Curve parameters of points along an edge, start to end (a closed edge goes once round). */
|
|
8
|
+
export declare function edgeParameters(edge: Edge, count: number): number[];
|
|
9
|
+
/**
|
|
10
|
+
* Raises edge and vertex tolerances to the gaps a file's geometry has (a writer's spline fits leave edges a micrometre
|
|
11
|
+
* off their faces, more than the accuracy it declares), half again for margin, where the gap is at most `cap` metres:
|
|
12
|
+
* the tolerant edges a kernel keeps for an imported part. Larger gaps stay for validateBody to report.
|
|
13
|
+
*/
|
|
14
|
+
export declare function measureTolerances(body: Body, cap: number): void;
|
|
15
|
+
/** Problems with `body`, empty when it is valid. */
|
|
16
|
+
export declare function validateBody(body: Body): ValidityProblem[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** What {@link satToSTEP} produces. */
|
|
2
|
+
export interface SATConversion {
|
|
3
|
+
/** An AP214 STEP file with one product holding every body, in millimetres. */
|
|
4
|
+
readonly step: string;
|
|
5
|
+
/** The SAT save version (for example 700 for ACIS 7.0). */
|
|
6
|
+
readonly version: number;
|
|
7
|
+
/** Millimetres per SAT model unit (from the header; 1 when the file gives none). */
|
|
8
|
+
readonly unit: number;
|
|
9
|
+
/** What was left out and why: faces on geometry with no stored approximation, unknown surface types. */
|
|
10
|
+
readonly warnings: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Converts ACIS SAT text to an AP214 STEP file the kernel reads. Throws a TypeError for a file it cannot read; faces it
|
|
14
|
+
* cannot convert are left out and listed in `warnings`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function satToSTEP(input: string | ArrayBuffer | ArrayBufferView): SATConversion;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** A reference to another entity instance (`#12`). */
|
|
2
|
+
export declare class Ref {
|
|
3
|
+
readonly id: number;
|
|
4
|
+
constructor(id: number);
|
|
5
|
+
}
|
|
6
|
+
/** An enumeration value (`.T.`, `.MILLI.`); its name without the dots. */
|
|
7
|
+
export declare class Enum {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
constructor(name: string);
|
|
10
|
+
}
|
|
11
|
+
/** A typed parameter (`LENGTH_MEASURE(25.4)`). */
|
|
12
|
+
export declare class Typed {
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly value: STEPValue;
|
|
15
|
+
constructor(type: string, value: STEPValue);
|
|
16
|
+
}
|
|
17
|
+
/** `*`: an attribute whose value a supertype derives. */
|
|
18
|
+
export declare const DERIVED: unique symbol;
|
|
19
|
+
/** A parameter: number, string, `$` (null), reference, enumeration, typed value, list, or derived. */
|
|
20
|
+
export type STEPValue = number | string | null | Ref | Enum | Typed | typeof DERIVED | STEPValue[];
|
|
21
|
+
/** One entity instance. A complex instance (`#5=(A(..)B(..));`) has `type` 'COMPLEX' and its partial types in `parts`. */
|
|
22
|
+
export interface STEPEntity {
|
|
23
|
+
readonly id: number;
|
|
24
|
+
readonly type: string;
|
|
25
|
+
readonly args: readonly STEPValue[];
|
|
26
|
+
readonly parts?: ReadonlyMap<string, readonly STEPValue[]>;
|
|
27
|
+
}
|
|
28
|
+
/** The HEADER section's file description, name and schema. */
|
|
29
|
+
export interface STEPHeader {
|
|
30
|
+
readonly description: readonly string[];
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly timeStamp: string;
|
|
33
|
+
readonly author: readonly string[];
|
|
34
|
+
readonly organization: readonly string[];
|
|
35
|
+
readonly preprocessor: string;
|
|
36
|
+
readonly system: string;
|
|
37
|
+
/** FILE_SCHEMA names, for example 'AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF { 1 0 10303 442 1 1 4 }'. */
|
|
38
|
+
readonly schema: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A STEP file's entity table. `get(id)` parses an instance on first use and caches it; `ids(type)` lists the
|
|
42
|
+
* instances whose type (or, for a complex instance, one of whose partial types) is `type`.
|
|
43
|
+
*/
|
|
44
|
+
export declare class STEPFile {
|
|
45
|
+
private readonly text;
|
|
46
|
+
readonly header: STEPHeader;
|
|
47
|
+
private readonly slots;
|
|
48
|
+
private readonly starts;
|
|
49
|
+
private readonly ends;
|
|
50
|
+
private readonly types;
|
|
51
|
+
private readonly byType;
|
|
52
|
+
private readonly cache;
|
|
53
|
+
/** Ids asked for with `has` and found missing: references to instances the file never defines. */
|
|
54
|
+
readonly missing: Set<number>;
|
|
55
|
+
constructor(text: string);
|
|
56
|
+
private headerSection;
|
|
57
|
+
/** Indexes `#id=...;` instances from `i` to ENDSEC; returns the index after it. */
|
|
58
|
+
private dataSection;
|
|
59
|
+
private index;
|
|
60
|
+
/** Number of entity instances. */
|
|
61
|
+
get size(): number;
|
|
62
|
+
/** Whether `#id` exists. A missing one (an id of 0 or more) is noted in `missing`: something referred to it. */
|
|
63
|
+
has(id: number): boolean;
|
|
64
|
+
/** The instances whose parameters refer to `#id`, found in the text (for messages about one never defined). */
|
|
65
|
+
referrers(id: number, most?: number): number[];
|
|
66
|
+
/** `#id` and its type, as messages name an instance. */
|
|
67
|
+
describe(id: number): string;
|
|
68
|
+
/** Ids of the instances of `type` (upper case), including complex instances that have it as a partial type. */
|
|
69
|
+
ids(type: string): readonly number[];
|
|
70
|
+
/** Every type present and its instance count. */
|
|
71
|
+
census(): Map<string, number>;
|
|
72
|
+
/** Instance `#id`, parsed on first use. Throws when it does not exist. */
|
|
73
|
+
get(id: number): STEPEntity;
|
|
74
|
+
/** The parameters of `#id` as `type`: its own when it is that type, or that partial type's of a complex instance. */
|
|
75
|
+
args(id: number, type?: string): readonly STEPValue[];
|
|
76
|
+
/** Whether `#id` is `type`, or a complex instance with that partial type. */
|
|
77
|
+
is(id: number, type: string): boolean;
|
|
78
|
+
/** The type name to show for `#id`: its type, or a complex instance's partial types joined with '+'. */
|
|
79
|
+
typeName(id: number): string;
|
|
80
|
+
}
|
|
81
|
+
/** Decodes STEP bytes as ISO 8859-1 (the standard's character set; non-ASCII text uses the escapes above). */
|
|
82
|
+
export declare function stepText(input: string | ArrayBuffer | ArrayBufferView): string;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type STEPFile } from './file.js';
|
|
2
|
+
/** RGBA in 0..1: the colour as the file writes it (display values) and 1 - transparency. */
|
|
3
|
+
export type STEPColor = readonly [number, number, number, number];
|
|
4
|
+
/** A product definition: a part or an assembly. */
|
|
5
|
+
export interface STEPProduct {
|
|
6
|
+
/** The PRODUCT_DEFINITION's entity id. */
|
|
7
|
+
readonly id: number;
|
|
8
|
+
/** The product's name (its id when the name is empty). */
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** The product's id, usually its part number. */
|
|
11
|
+
readonly partNumber: string;
|
|
12
|
+
}
|
|
13
|
+
/** One B-rep body (solid or shell model) or tessellated body, wherever and however often it is placed. */
|
|
14
|
+
export interface STEPBody {
|
|
15
|
+
/** The body's entity id. */
|
|
16
|
+
readonly id: number;
|
|
17
|
+
/** 'solid' (MANIFOLD_SOLID_BREP, BREP_WITH_VOIDS), 'faceted', 'shell' (SHELL_BASED_SURFACE_MODEL), 'tessellated'. */
|
|
18
|
+
readonly kind: 'solid' | 'faceted' | 'shell' | 'tessellated';
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Face entity ids (empty for tessellated bodies). */
|
|
21
|
+
readonly faces: readonly number[];
|
|
22
|
+
/** Faces turned inside out by an oriented shell or face around them (a void's shell is reversed). */
|
|
23
|
+
readonly reversed?: readonly number[];
|
|
24
|
+
/** Number of distinct edges. */
|
|
25
|
+
readonly edges: number;
|
|
26
|
+
/** Metres per unit of the body's coordinates (0.001 for a body modelled in millimetres). */
|
|
27
|
+
readonly unit: number;
|
|
28
|
+
/** Radians per plane-angle unit of the body's context (a cone's half angle is written in it); NaN when unread. */
|
|
29
|
+
readonly angleUnit: number;
|
|
30
|
+
/** The body's style colour, when the file gives one. */
|
|
31
|
+
readonly color?: STEPColor;
|
|
32
|
+
/**
|
|
33
|
+
* Ids its shells, faces, loops and edges refer to that the file never defines (the instances referring to them are
|
|
34
|
+
* named in the model's `warnings`): what they held is missing from the body, so it is incomplete.
|
|
35
|
+
*/
|
|
36
|
+
readonly unresolved?: readonly number[];
|
|
37
|
+
}
|
|
38
|
+
/** One placed body: which body, which product it belongs to, and where. */
|
|
39
|
+
export interface STEPInstance {
|
|
40
|
+
/** Index into `bodies`. */
|
|
41
|
+
readonly body: number;
|
|
42
|
+
/** Index into `products` of the part the body belongs to (-1 for geometry outside any product). */
|
|
43
|
+
readonly product: number;
|
|
44
|
+
/**
|
|
45
|
+
* Column-major 4x4 from the body's coordinates in metres (multiply them by the body's `unit` first) to the model's
|
|
46
|
+
* world, in metres.
|
|
47
|
+
*/
|
|
48
|
+
readonly matrix: Float64Array;
|
|
49
|
+
/** Product indices from the root assembly down to `product`. */
|
|
50
|
+
readonly path: readonly number[];
|
|
51
|
+
/** Index into `occurrences` of the placed product the body belongs to (-1 for geometry outside any product). */
|
|
52
|
+
readonly occurrence: number;
|
|
53
|
+
}
|
|
54
|
+
/** One placed product: a root, or a component where an assembly places it (each use is its own occurrence). */
|
|
55
|
+
export interface STEPOccurrence {
|
|
56
|
+
/** Index into `products`. */
|
|
57
|
+
readonly product: number;
|
|
58
|
+
/** Index into `occurrences` of the assembly occurrence that places it (-1 for a root). */
|
|
59
|
+
readonly parent: number;
|
|
60
|
+
/** Column-major 4x4 from the product's coordinates in metres to the model's world, in metres. */
|
|
61
|
+
readonly matrix: Float64Array;
|
|
62
|
+
}
|
|
63
|
+
/** A point or direction in metres. */
|
|
64
|
+
export type STEPPoint = readonly [number, number, number];
|
|
65
|
+
/**
|
|
66
|
+
* What a file states about its own shape for readers to check against (the CAx-IF recommended practices for geometric
|
|
67
|
+
* and tessellated validation properties): the exporting system's volume, area, centre, bounding box or facet count of a
|
|
68
|
+
* product (its components included) or of particular bodies. Lengths are metres, in the coordinates of the product, or
|
|
69
|
+
* of the bodies' own representation when `bodies` is set. Properties stated separately for one shape are merged.
|
|
70
|
+
*/
|
|
71
|
+
export interface STEPValidationProperty {
|
|
72
|
+
/** The first PROPERTY_DEFINITION entity that states it. */
|
|
73
|
+
readonly id: number;
|
|
74
|
+
/** The described shape's name: the shape aspect's description, or the product's name. */
|
|
75
|
+
readonly label: string;
|
|
76
|
+
/** Index into `products` of the product the shape belongs to (-1 when the file does not say). */
|
|
77
|
+
readonly product: number;
|
|
78
|
+
/** Indices into `bodies` when particular bodies are described; undefined for the whole product. */
|
|
79
|
+
readonly bodies?: readonly number[];
|
|
80
|
+
/** A tessellated validation property: area, centre and facets of the triangles the file itself carries. */
|
|
81
|
+
readonly tessellated: boolean;
|
|
82
|
+
/** Of the independent surfaces (surface bodies beside the solids) rather than the solids. */
|
|
83
|
+
readonly independent?: boolean;
|
|
84
|
+
/** Volume in cubic metres. */
|
|
85
|
+
readonly volume?: number;
|
|
86
|
+
/** Surface area in square metres. */
|
|
87
|
+
readonly area?: number;
|
|
88
|
+
/** Centre of the volume, or of the surface when `surfaceCentroid` is true. */
|
|
89
|
+
readonly centroid?: STEPPoint;
|
|
90
|
+
/** Whether `centroid` is the centre of the surface (a tessellation, or a point the file names a surface centre). */
|
|
91
|
+
readonly surfaceCentroid?: boolean;
|
|
92
|
+
/** Bounding box `[min, max]`. */
|
|
93
|
+
readonly box?: readonly [STEPPoint, STEPPoint];
|
|
94
|
+
/** Number of facets as the file writes them, degenerate strip joins included. */
|
|
95
|
+
readonly facets?: number;
|
|
96
|
+
}
|
|
97
|
+
/** What `readStructure` finds. */
|
|
98
|
+
export interface STEPStructure {
|
|
99
|
+
readonly products: readonly STEPProduct[];
|
|
100
|
+
/** Indices of the products no assembly uses as a component. */
|
|
101
|
+
readonly roots: readonly number[];
|
|
102
|
+
readonly bodies: readonly STEPBody[];
|
|
103
|
+
readonly instances: readonly STEPInstance[];
|
|
104
|
+
/** Every placed product, an assembly before its components. */
|
|
105
|
+
readonly occurrences: readonly STEPOccurrence[];
|
|
106
|
+
/** The validation properties the file states (empty when it states none). */
|
|
107
|
+
readonly validation: readonly STEPValidationProperty[];
|
|
108
|
+
/** Face colours that differ from their body's, by face entity id. */
|
|
109
|
+
readonly faceColors: ReadonlyMap<number, STEPColor>;
|
|
110
|
+
/** Surface and edge-curve types of the bodies' faces, with counts (complex types joined with '+'). */
|
|
111
|
+
readonly census: {
|
|
112
|
+
readonly surfaces: Readonly<Record<string, number>>;
|
|
113
|
+
readonly curves: Readonly<Record<string, number>>;
|
|
114
|
+
};
|
|
115
|
+
/** What was skipped and why (for example an assembly link with no placement). */
|
|
116
|
+
readonly warnings: readonly string[];
|
|
117
|
+
}
|
|
118
|
+
/** Options of {@link readStructure}. */
|
|
119
|
+
export interface STEPStructureOptions {
|
|
120
|
+
/** Most placed bodies to list (default 1,000,000); a larger assembly throws a RangeError that names this option. */
|
|
121
|
+
readonly maxInstances?: number;
|
|
122
|
+
}
|
|
123
|
+
/** Product of two column-major affine matrices (math's multiplyMatrices). */
|
|
124
|
+
export declare const multiply: (a: Float64Array, b: Float64Array) => Float64Array;
|
|
125
|
+
/** Inverse of an affine matrix (general 3x3 part, so a scaled transformation operator inverts correctly). */
|
|
126
|
+
export declare function invert(m: Float64Array): Float64Array;
|
|
127
|
+
/**
|
|
128
|
+
* Reads a STEP file's products, assembly tree, bodies, units and colours. Geometry is not evaluated: bodies list their
|
|
129
|
+
* faces for the tessellator, and instances say where each body goes.
|
|
130
|
+
*/
|
|
131
|
+
export declare function readStructure(file: STEPFile, { maxInstances }?: STEPStructureOptions): STEPStructure;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** A B-spline with standard (clamped: end multiplicity degree + 1) knot vectors, control points already in place. */
|
|
2
|
+
export interface WriterSpline {
|
|
3
|
+
/** One degree for a curve, [u, v] for a surface. */
|
|
4
|
+
readonly degrees: readonly number[];
|
|
5
|
+
/** Control points per direction ([n] for a curve, [nu, nv] for a surface). */
|
|
6
|
+
readonly counts: readonly number[];
|
|
7
|
+
/** Distinct knots per direction. */
|
|
8
|
+
readonly knots: readonly (readonly number[])[];
|
|
9
|
+
/** Their multiplicities. */
|
|
10
|
+
readonly multiplicities: readonly (readonly number[])[];
|
|
11
|
+
/** Control points; for a surface, u varies fastest (index j * nu + i). */
|
|
12
|
+
readonly points: readonly (readonly number[])[];
|
|
13
|
+
/** Weights, when rational, in the order of `points`. */
|
|
14
|
+
readonly weights?: readonly number[];
|
|
15
|
+
}
|
|
16
|
+
export declare class StepWriter {
|
|
17
|
+
private readonly lines;
|
|
18
|
+
private next;
|
|
19
|
+
private readonly styled;
|
|
20
|
+
/** Lines of entities reserved and not yet filled, by id. */
|
|
21
|
+
private readonly reserved;
|
|
22
|
+
/** Adds an entity (its text without the id) and returns its id, such as '#123'. */
|
|
23
|
+
add(entity: string): string;
|
|
24
|
+
/** An id for an entity written later with {@link StepWriter.fill}; one never filled is left out of the file. */
|
|
25
|
+
reserve(): string;
|
|
26
|
+
fill(id: string, entity: string): void;
|
|
27
|
+
/** The entities so far as a STEP file, for evaluating converted geometry before the conversion finishes. */
|
|
28
|
+
draft(): string;
|
|
29
|
+
/** A STEP real: a decimal point always, before any exponent. */
|
|
30
|
+
real(v: number): string;
|
|
31
|
+
point(p: readonly number[]): string;
|
|
32
|
+
direction(d: readonly number[]): string;
|
|
33
|
+
/** AXIS2_PLACEMENT_3D at `origin`, z axis `z`, x towards `x` (made perpendicular; any perpendicular when parallel). */
|
|
34
|
+
axis(origin: readonly number[], z: readonly number[], x: readonly number[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* A B-spline curve (one degree) or surface (two degrees), rational when it has weights; written as the reserved id
|
|
37
|
+
* `into` when given.
|
|
38
|
+
*/
|
|
39
|
+
spline(s: WriterSpline, into?: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* A shape representation of `items` (with an origin placement) that mapped items can place: returns the map, for
|
|
42
|
+
* {@link StepWriter.place}.
|
|
43
|
+
*/
|
|
44
|
+
shape(items: readonly string[]): string;
|
|
45
|
+
/** A mapped item placing a {@link StepWriter.shape} at `origin` with axes `z` and `x`. */
|
|
46
|
+
place(map: string, origin: readonly number[], z: readonly number[], x: readonly number[]): string;
|
|
47
|
+
/** Gives `item` (a face or body) a surface colour, red, green and blue in 0..1. */
|
|
48
|
+
style(item: string, rgb: readonly number[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* The finished file: one product whose shape holds `items` (solids, shell models, mapped items), lengths in
|
|
51
|
+
* millimetres or metres.
|
|
52
|
+
*/
|
|
53
|
+
finish(items: readonly string[], { unit, source }: {
|
|
54
|
+
unit: 'mm' | 'm';
|
|
55
|
+
source: string;
|
|
56
|
+
}): string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** A field value: number (or null for Parasolid's null value), string (char, char array), vector, or array. */
|
|
2
|
+
export type XTValue = number | null | string | boolean | readonly number[] | readonly XTValue[];
|
|
3
|
+
/** One node of the file. */
|
|
4
|
+
export interface XTNode {
|
|
5
|
+
readonly type: number;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly index: number;
|
|
8
|
+
readonly fields: Readonly<Record<string, XTValue>>;
|
|
9
|
+
}
|
|
10
|
+
/** What {@link readXT} returns. */
|
|
11
|
+
export interface XTFile {
|
|
12
|
+
readonly modeller: string;
|
|
13
|
+
readonly schema: string;
|
|
14
|
+
readonly nodes: ReadonlyMap<number, XTNode>;
|
|
15
|
+
/** Index 1: the root (a body, an assembly, a list of parts or a partition's world). */
|
|
16
|
+
readonly root: XTNode | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads a Parasolid transmit file (text .x_t or neutral binary .x_b) into its nodes. Throws a TypeError for a file it
|
|
20
|
+
* cannot read, naming where.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readXT(input: string | ArrayBuffer | ArrayBufferView): XTFile;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A field: its type and count (0 a scalar, 1 the variable-length last field, n > 1 a fixed array). */
|
|
2
|
+
export interface XTField {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly type: string;
|
|
5
|
+
readonly count: number;
|
|
6
|
+
}
|
|
7
|
+
/** A node type's name and fields. */
|
|
8
|
+
export interface XTNodeType {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly fields: readonly XTField[];
|
|
11
|
+
}
|
|
12
|
+
/** The base schema's node types by number. */
|
|
13
|
+
export declare const BASE_SCHEMA: ReadonlyMap<number, XTNodeType>;
|
|
14
|
+
/**
|
|
15
|
+
* Layouts that changed after the base schema, for files that state a later schema without describing it (no base
|
|
16
|
+
* suffix in their schema name): learned from files that do describe their changes.
|
|
17
|
+
*/
|
|
18
|
+
export declare const LATER_SCHEMA: ReadonlyMap<number, XTNodeType>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** What {@link xtToSTEP} produces. */
|
|
2
|
+
export interface XTConversion {
|
|
3
|
+
/** An AP214 STEP file in metres: one product, bodies placed as the assembly places them. */
|
|
4
|
+
readonly step: string;
|
|
5
|
+
readonly modeller: string;
|
|
6
|
+
readonly schema: string;
|
|
7
|
+
/** What was left out and why (faces on surfaces the converter lacks, edges with no curve to follow). */
|
|
8
|
+
readonly warnings: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/** Options of {@link xtToSTEP}. */
|
|
11
|
+
export interface XTOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Which of the file's top-level parts (its bodies and assemblies, in the file's order, from 0) to convert; all of
|
|
14
|
+
* them when omitted.
|
|
15
|
+
*/
|
|
16
|
+
readonly parts?: readonly number[];
|
|
17
|
+
}
|
|
18
|
+
/** Converts a Parasolid transmit file (text or neutral binary) to STEP for the kernel. */
|
|
19
|
+
export declare function xtToSTEP(input: string | ArrayBuffer | ArrayBufferView, options?: XTOptions): XTConversion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@margoengine/brep",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
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
|
+
}
|