okgeometry-api 1.6.0 → 1.9.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.
@@ -12,6 +12,97 @@ export function arc_length(radius: number, start_angle: number, end_angle: numbe
12
12
  */
13
13
  export function arc_point_at(cx: number, cy: number, cz: number, nx: number, ny: number, nz: number, radius: number, start_angle: number, end_angle: number, t: number): Float64Array;
14
14
 
15
+ /**
16
+ * Parametric BREP boolean: exact surface–surface intersection curves with
17
+ * trimmed-surface output. Both operands must be closed solids.
18
+ * op: "union" | "intersect" | "subtract".
19
+ * Returns the result BREP as JSON, or {"error": "..."} on failure.
20
+ */
21
+ export function brep_boolean_op(a_json: string, b_json: string, op: string, tolerance: number): string;
22
+
23
+ /**
24
+ * All BREP edges as polylines: [num_polylines, n1, x,y,z..., n2, ...].
25
+ */
26
+ export function brep_edges(json: string, tolerance: number): Float64Array;
27
+
28
+ /**
29
+ * Extrude a profile curve into a BREP (closed profile → capped solid,
30
+ * open profile → sheet). Returns JSON.
31
+ */
32
+ export function brep_extrude_curve(curve_data: Float64Array, dx: number, dy: number, dz: number, height: number): string;
33
+
34
+ /**
35
+ * Iso-parametric curve of a NURBS face's backing surface (untrimmed).
36
+ * Returns curve data, or empty for planar faces.
37
+ */
38
+ export function brep_face_iso_curve(json: string, face_index: number, t: number, u_dir: boolean): Float64Array;
39
+
40
+ /**
41
+ * Geometric backing of a face.
42
+ * Returns [0, ox,oy,oz, ux,uy,uz, vx,vy,vz] for planes,
43
+ * or [1, surface_data...] for NURBS faces.
44
+ */
45
+ export function brep_face_surface(json: string, face_index: number): Float64Array;
46
+
47
+ /**
48
+ * Tessellate a single BREP face. Returns the standard mesh buffer.
49
+ */
50
+ export function brep_face_tessellate(json: string, face_index: number, tolerance: number): Float64Array;
51
+
52
+ /**
53
+ * BREP structure summary: [face_count, edge_count, vertex_count, is_closed].
54
+ */
55
+ export function brep_info(json: string): Float64Array;
56
+
57
+ /**
58
+ * Loft through profile curves into a BREP.
59
+ * Input: [num_curves, curve1_data..., curve2_data...]. Returns JSON.
60
+ */
61
+ export function brep_loft_curves(data: Float64Array): string;
62
+
63
+ /**
64
+ * BREP primitives.
65
+ * kind: "box" [minx,miny,minz, maxx,maxy,maxz]
66
+ * "cylinder" [bx,by,bz, ax,ay,az, radius, height]
67
+ * "sphere" [cx,cy,cz, radius]
68
+ * "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
69
+ * "torus" [cx,cy,cz, major, minor]
70
+ * Returns the BREP as JSON ("" on failure).
71
+ */
72
+ export function brep_primitive(kind: string, params: Float64Array): string;
73
+
74
+ /**
75
+ * Revolve a profile curve into a BREP. Returns JSON.
76
+ */
77
+ export function brep_revolve_curve(curve_data: Float64Array, ox: number, oy: number, oz: number, ax: number, ay: number, az: number, angle: number): string;
78
+
79
+ /**
80
+ * Untrimmed sheet BREP from a NURBS surface. Returns JSON.
81
+ */
82
+ export function brep_sheet_from_surface(surface_data: Float64Array): string;
83
+
84
+ /**
85
+ * Tessellate a BREP into the standard mesh buffer
86
+ * [vertexCount, positions..., indices...]. Crack-free across shared edges.
87
+ */
88
+ export function brep_tessellate(json: string, tolerance: number): Float64Array;
89
+
90
+ /**
91
+ * Apply a row-major 4x4 matrix to a BREP. Returns transformed JSON.
92
+ */
93
+ export function brep_transform(json: string, matrix: Float64Array): string;
94
+
95
+ /**
96
+ * Validate a BREP. Returns a JSON report:
97
+ * {"isClosed":bool,"boundaryEdgeCount":n,"maxCoherenceError":e,"issues":[...]}
98
+ */
99
+ export function brep_validate(json: string, tolerance: number): string;
100
+
101
+ /**
102
+ * Volume and surface area from tessellation: [volume, area].
103
+ */
104
+ export function brep_volume_area(json: string, tolerance: number): Float64Array;
105
+
15
106
  /**
16
107
  * Build a NURBS curve from raw control points with kernel-managed knots and weights.
17
108
  *
@@ -326,6 +417,17 @@ export function mesh_build_render_buffers(vertex_count: number, buffer: Float64A
326
417
  */
327
418
  export function mesh_chamfer_all_edges(mesh_type: string, params: Float64Array, offset: number): Float64Array;
328
419
 
420
+ /**
421
+ * Clip a polyline against a closed mesh volume (boolean intersection for curves).
422
+ *
423
+ * `points` is a flat [x,y,z, ...] vertex list; `closed` marks a closed loop
424
+ * (no duplicated seam point required, one is tolerated).
425
+ * Returns two concatenated polyline buffers — inside pieces first, then
426
+ * outside pieces — each encoded as [num_polylines, n1, x,y,z,..., ...].
427
+ * Returns an empty buffer on failure (open cutter, degenerate polyline).
428
+ */
429
+ export function mesh_clip_polyline(vertex_count: number, buffer: Float64Array, points: Float64Array, closed: boolean): Float64Array;
430
+
329
431
  /**
330
432
  * Compute planar curve normal from ordered points.
331
433
  */
@@ -602,12 +704,58 @@ export function nurbs_curve_curve_intersect(data_a: Float64Array, data_b: Float6
602
704
  */
603
705
  export function nurbs_curve_plane_intersect(data: Float64Array, nx: number, ny: number, nz: number, d: number): Float64Array;
604
706
 
707
+ /**
708
+ * Closest point on the surface to (x, y, z).
709
+ * Returns [u, v, px, py, pz] with u, v normalized to [0,1].
710
+ */
711
+ export function nurbs_surface_closest_point(data: Float64Array, x: number, y: number, z: number): Float64Array;
712
+
713
+ /**
714
+ * Surface curvature at normalized (u, v): [k1, k2, gaussian, mean, nx, ny, nz].
715
+ */
716
+ export function nurbs_surface_curvature(data: Float64Array, u: number, v: number): Float64Array;
717
+
718
+ /**
719
+ * Analytic surface derivatives at normalized (u, v) in [0,1]².
720
+ * Returns 18 floats: [S, Su, Sv, Suu, Suv, Svv] (xyz each), derivatives taken
721
+ * with respect to the NORMALIZED parameters (chain rule applied).
722
+ */
723
+ export function nurbs_surface_derivatives(data: Float64Array, u: number, v: number): Float64Array;
724
+
725
+ /**
726
+ * Exact degree elevation by `t` in one direction.
727
+ */
728
+ export function nurbs_surface_elevate_degree(data: Float64Array, u_dir: boolean, t: number): Float64Array;
729
+
605
730
  /**
606
731
  * Evaluate a NURBS surface at normalized parameters (u, v) in [0,1].
607
732
  * Returns [x, y, z]
608
733
  */
609
734
  export function nurbs_surface_evaluate(data: Float64Array, u: number, v: number): Float64Array;
610
735
 
736
+ /**
737
+ * Exact sub-patch extraction over normalized ranges.
738
+ */
739
+ export function nurbs_surface_extract_region(data: Float64Array, u0: number, u1: number, v0: number, v1: number): Float64Array;
740
+
741
+ /**
742
+ * Exact extruded (translational) surface from a profile curve.
743
+ */
744
+ export function nurbs_surface_extrude(curve_data: Float64Array, dx: number, dy: number, dz: number): Float64Array;
745
+
746
+ /**
747
+ * Exact knot insertion at normalized parameter t (repeated `times`).
748
+ * Returns the refined surface in standard surface format.
749
+ */
750
+ export function nurbs_surface_insert_knot(data: Float64Array, u_dir: boolean, t: number, times: number): Float64Array;
751
+
752
+ /**
753
+ * Exact rational iso-parametric curve. `u_dir = true` extracts the curve
754
+ * running along u at constant v = t; false extracts along v at constant u = t.
755
+ * t is normalized [0,1]. Returns curve data [degree, n, pts..., w..., knots...].
756
+ */
757
+ export function nurbs_surface_iso_curve(data: Float64Array, t: number, u_dir: boolean): Float64Array;
758
+
611
759
  /**
612
760
  * Evaluate a NURBS surface unit normal at normalized parameters (u, v) in [0,1].
613
761
  * Returns [x, y, z]
@@ -621,12 +769,51 @@ export function nurbs_surface_normal(data: Float64Array, u: number, v: number):
621
769
  */
622
770
  export function nurbs_surface_plane_intersect(surface_data: Float64Array, nx: number, ny: number, nz: number, d: number, tess: number): Float64Array;
623
771
 
772
+ /**
773
+ * Exact rational primitive surfaces.
774
+ * kind: "cylinder" [bx,by,bz, ax,ay,az, radius, height]
775
+ * "sphere" [cx,cy,cz, radius]
776
+ * "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
777
+ * "torus" [cx,cy,cz, major, minor]
778
+ */
779
+ export function nurbs_surface_primitive(kind: string, params: Float64Array): Float64Array;
780
+
781
+ /**
782
+ * Exact surface of revolution from a profile curve (A8.1).
783
+ */
784
+ export function nurbs_surface_revolve(curve_data: Float64Array, ox: number, oy: number, oz: number, ax: number, ay: number, az: number, angle: number): Float64Array;
785
+
786
+ /**
787
+ * Exact ruled surface between two curves (auto degree/knot compatibility).
788
+ */
789
+ export function nurbs_surface_ruled(curve_a: Float64Array, curve_b: Float64Array): Float64Array;
790
+
791
+ /**
792
+ * Exact split at normalized parameter t. Returns [lenA, surfaceA..., lenB, surfaceB...].
793
+ */
794
+ export function nurbs_surface_split(data: Float64Array, u_dir: boolean, t: number): Float64Array;
795
+
624
796
  /**
625
797
  * Intersect two NURBS surfaces.
626
798
  * Returns polyline buffer.
627
799
  */
628
800
  export function nurbs_surface_surface_intersect(data_a: Float64Array, data_b: Float64Array, tess: number): Float64Array;
629
801
 
802
+ /**
803
+ * Curvature-adaptive tessellation against a chordal tolerance.
804
+ * Returns the standard mesh buffer [vertexCount, positions..., indices...].
805
+ */
806
+ export function nurbs_surface_tessellate_adaptive(data: Float64Array, tolerance: number, max_segments_per_span: number): Float64Array;
807
+
808
+ /**
809
+ * Display-ready render tessellation: twist-aware adaptive grid with ANALYTIC
810
+ * surface normals, plus feature edges only where the surface really has them
811
+ * (boundaries, kinked C0 knot lines, kinked closed seams).
812
+ * Output (f32, same packing as `mesh_build_render_buffers`):
813
+ * [vertexCount, positions..., normals..., edgeSegmentCount, edgeSegments...]
814
+ */
815
+ export function nurbs_surface_tessellate_render(data: Float64Array, tolerance: number, max_segments_per_span: number, crease_angle_deg: number): Float32Array;
816
+
630
817
  /**
631
818
  * Offset a polycurve made of line and arc segments.
632
819
  * Input format: [segment_count, type, ...data, ...]
@@ -752,6 +939,21 @@ export interface InitOutput {
752
939
  readonly memory: WebAssembly.Memory;
753
940
  readonly arc_length: (a: number, b: number, c: number) => number;
754
941
  readonly arc_point_at: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
942
+ readonly brep_boolean_op: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
943
+ readonly brep_edges: (a: number, b: number, c: number) => [number, number];
944
+ readonly brep_extrude_curve: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
945
+ readonly brep_face_iso_curve: (a: number, b: number, c: number, d: number, e: number) => [number, number];
946
+ readonly brep_face_surface: (a: number, b: number, c: number) => [number, number];
947
+ readonly brep_face_tessellate: (a: number, b: number, c: number, d: number) => [number, number];
948
+ readonly brep_info: (a: number, b: number) => [number, number];
949
+ readonly brep_loft_curves: (a: number, b: number) => [number, number];
950
+ readonly brep_primitive: (a: number, b: number, c: number, d: number) => [number, number];
951
+ readonly brep_revolve_curve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
952
+ readonly brep_sheet_from_surface: (a: number, b: number) => [number, number];
953
+ readonly brep_tessellate: (a: number, b: number, c: number) => [number, number];
954
+ readonly brep_transform: (a: number, b: number, c: number, d: number) => [number, number];
955
+ readonly brep_validate: (a: number, b: number, c: number) => [number, number];
956
+ readonly brep_volume_area: (a: number, b: number, c: number) => [number, number];
755
957
  readonly build_nurbs_curve: (a: number, b: number, c: number, d: number) => [number, number];
756
958
  readonly chamfer_polycurve: (a: number, b: number, c: number) => [number, number];
757
959
  readonly circle_length: (a: number) => number;
@@ -806,6 +1008,7 @@ export interface InitOutput {
806
1008
  readonly mesh_build_coplanar_connected_face_groups: (a: number, b: number, c: number) => [number, number];
807
1009
  readonly mesh_build_render_buffers: (a: number, b: number, c: number, d: number) => [number, number];
808
1010
  readonly mesh_chamfer_all_edges: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1011
+ readonly mesh_clip_polyline: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
809
1012
  readonly mesh_compute_planar_curve_normal: (a: number, b: number, c: number) => [number, number];
810
1013
  readonly mesh_contains_point: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
811
1014
  readonly mesh_create_box: (a: number, b: number, c: number) => [number, number];
@@ -854,10 +1057,24 @@ export interface InitOutput {
854
1057
  readonly mesh_translate: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
855
1058
  readonly nurbs_curve_curve_intersect: (a: number, b: number, c: number, d: number) => [number, number];
856
1059
  readonly nurbs_curve_plane_intersect: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1060
+ readonly nurbs_surface_closest_point: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1061
+ readonly nurbs_surface_curvature: (a: number, b: number, c: number, d: number) => [number, number];
1062
+ readonly nurbs_surface_derivatives: (a: number, b: number, c: number, d: number) => [number, number];
1063
+ readonly nurbs_surface_elevate_degree: (a: number, b: number, c: number, d: number) => [number, number];
857
1064
  readonly nurbs_surface_evaluate: (a: number, b: number, c: number, d: number) => [number, number];
1065
+ readonly nurbs_surface_extract_region: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1066
+ readonly nurbs_surface_extrude: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1067
+ readonly nurbs_surface_insert_knot: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1068
+ readonly nurbs_surface_iso_curve: (a: number, b: number, c: number, d: number) => [number, number];
858
1069
  readonly nurbs_surface_normal: (a: number, b: number, c: number, d: number) => [number, number];
859
1070
  readonly nurbs_surface_plane_intersect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1071
+ readonly nurbs_surface_primitive: (a: number, b: number, c: number, d: number) => [number, number];
1072
+ readonly nurbs_surface_revolve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
1073
+ readonly nurbs_surface_ruled: (a: number, b: number, c: number, d: number) => [number, number];
1074
+ readonly nurbs_surface_split: (a: number, b: number, c: number, d: number) => [number, number];
860
1075
  readonly nurbs_surface_surface_intersect: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1076
+ readonly nurbs_surface_tessellate_adaptive: (a: number, b: number, c: number, d: number) => [number, number];
1077
+ readonly nurbs_surface_tessellate_render: (a: number, b: number, c: number, d: number, e: number) => [number, number];
861
1078
  readonly offset_polycurve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
862
1079
  readonly offset_polycurve_all: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
863
1080
  readonly offset_polyline_curve: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];