okgeometry-api 1.6.0 → 1.10.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
  */
@@ -547,6 +649,15 @@ export function mesh_rotate(vertex_count: number, buffer: Float64Array, ax: numb
547
649
  */
548
650
  export function mesh_scale(vertex_count: number, buffer: Float64Array, sx: number, sy: number, sz: number): Float64Array;
549
651
 
652
+ /**
653
+ * Split a closed solid (mesh A) by a surface (mesh B) into BOTH capped solids.
654
+ * `outside` = the solid on the negative side of the surface, `inside` = the
655
+ * positive side; each is capped by the portion of the surface inside the
656
+ * solid, welded into a watertight result. Same packed layout as the other
657
+ * split exports.
658
+ */
659
+ export function mesh_solid_split_by_surface(vertex_count_a: number, buffer_a: Float64Array, vertex_count_b: number, buffer_b: Float64Array, operation: string): Float64Array;
660
+
550
661
  export function mesh_solid_split_plane(vertex_count: number, buffer: Float64Array, nx: number, ny: number, nz: number, d: number, operation: string): Float64Array;
551
662
 
552
663
  /**
@@ -602,12 +713,58 @@ export function nurbs_curve_curve_intersect(data_a: Float64Array, data_b: Float6
602
713
  */
603
714
  export function nurbs_curve_plane_intersect(data: Float64Array, nx: number, ny: number, nz: number, d: number): Float64Array;
604
715
 
716
+ /**
717
+ * Closest point on the surface to (x, y, z).
718
+ * Returns [u, v, px, py, pz] with u, v normalized to [0,1].
719
+ */
720
+ export function nurbs_surface_closest_point(data: Float64Array, x: number, y: number, z: number): Float64Array;
721
+
722
+ /**
723
+ * Surface curvature at normalized (u, v): [k1, k2, gaussian, mean, nx, ny, nz].
724
+ */
725
+ export function nurbs_surface_curvature(data: Float64Array, u: number, v: number): Float64Array;
726
+
727
+ /**
728
+ * Analytic surface derivatives at normalized (u, v) in [0,1]².
729
+ * Returns 18 floats: [S, Su, Sv, Suu, Suv, Svv] (xyz each), derivatives taken
730
+ * with respect to the NORMALIZED parameters (chain rule applied).
731
+ */
732
+ export function nurbs_surface_derivatives(data: Float64Array, u: number, v: number): Float64Array;
733
+
734
+ /**
735
+ * Exact degree elevation by `t` in one direction.
736
+ */
737
+ export function nurbs_surface_elevate_degree(data: Float64Array, u_dir: boolean, t: number): Float64Array;
738
+
605
739
  /**
606
740
  * Evaluate a NURBS surface at normalized parameters (u, v) in [0,1].
607
741
  * Returns [x, y, z]
608
742
  */
609
743
  export function nurbs_surface_evaluate(data: Float64Array, u: number, v: number): Float64Array;
610
744
 
745
+ /**
746
+ * Exact sub-patch extraction over normalized ranges.
747
+ */
748
+ export function nurbs_surface_extract_region(data: Float64Array, u0: number, u1: number, v0: number, v1: number): Float64Array;
749
+
750
+ /**
751
+ * Exact extruded (translational) surface from a profile curve.
752
+ */
753
+ export function nurbs_surface_extrude(curve_data: Float64Array, dx: number, dy: number, dz: number): Float64Array;
754
+
755
+ /**
756
+ * Exact knot insertion at normalized parameter t (repeated `times`).
757
+ * Returns the refined surface in standard surface format.
758
+ */
759
+ export function nurbs_surface_insert_knot(data: Float64Array, u_dir: boolean, t: number, times: number): Float64Array;
760
+
761
+ /**
762
+ * Exact rational iso-parametric curve. `u_dir = true` extracts the curve
763
+ * running along u at constant v = t; false extracts along v at constant u = t.
764
+ * t is normalized [0,1]. Returns curve data [degree, n, pts..., w..., knots...].
765
+ */
766
+ export function nurbs_surface_iso_curve(data: Float64Array, t: number, u_dir: boolean): Float64Array;
767
+
611
768
  /**
612
769
  * Evaluate a NURBS surface unit normal at normalized parameters (u, v) in [0,1].
613
770
  * Returns [x, y, z]
@@ -621,12 +778,51 @@ export function nurbs_surface_normal(data: Float64Array, u: number, v: number):
621
778
  */
622
779
  export function nurbs_surface_plane_intersect(surface_data: Float64Array, nx: number, ny: number, nz: number, d: number, tess: number): Float64Array;
623
780
 
781
+ /**
782
+ * Exact rational primitive surfaces.
783
+ * kind: "cylinder" [bx,by,bz, ax,ay,az, radius, height]
784
+ * "sphere" [cx,cy,cz, radius]
785
+ * "cone" [bx,by,bz, ax,ay,az, radius0, radius1, height]
786
+ * "torus" [cx,cy,cz, major, minor]
787
+ */
788
+ export function nurbs_surface_primitive(kind: string, params: Float64Array): Float64Array;
789
+
790
+ /**
791
+ * Exact surface of revolution from a profile curve (A8.1).
792
+ */
793
+ export function nurbs_surface_revolve(curve_data: Float64Array, ox: number, oy: number, oz: number, ax: number, ay: number, az: number, angle: number): Float64Array;
794
+
795
+ /**
796
+ * Exact ruled surface between two curves (auto degree/knot compatibility).
797
+ */
798
+ export function nurbs_surface_ruled(curve_a: Float64Array, curve_b: Float64Array): Float64Array;
799
+
800
+ /**
801
+ * Exact split at normalized parameter t. Returns [lenA, surfaceA..., lenB, surfaceB...].
802
+ */
803
+ export function nurbs_surface_split(data: Float64Array, u_dir: boolean, t: number): Float64Array;
804
+
624
805
  /**
625
806
  * Intersect two NURBS surfaces.
626
807
  * Returns polyline buffer.
627
808
  */
628
809
  export function nurbs_surface_surface_intersect(data_a: Float64Array, data_b: Float64Array, tess: number): Float64Array;
629
810
 
811
+ /**
812
+ * Curvature-adaptive tessellation against a chordal tolerance.
813
+ * Returns the standard mesh buffer [vertexCount, positions..., indices...].
814
+ */
815
+ export function nurbs_surface_tessellate_adaptive(data: Float64Array, tolerance: number, max_segments_per_span: number): Float64Array;
816
+
817
+ /**
818
+ * Display-ready render tessellation: twist-aware adaptive grid with ANALYTIC
819
+ * surface normals, plus feature edges only where the surface really has them
820
+ * (boundaries, kinked C0 knot lines, kinked closed seams).
821
+ * Output (f32, same packing as `mesh_build_render_buffers`):
822
+ * [vertexCount, positions..., normals..., edgeSegmentCount, edgeSegments...]
823
+ */
824
+ export function nurbs_surface_tessellate_render(data: Float64Array, tolerance: number, max_segments_per_span: number, crease_angle_deg: number): Float32Array;
825
+
630
826
  /**
631
827
  * Offset a polycurve made of line and arc segments.
632
828
  * Input format: [segment_count, type, ...data, ...]
@@ -752,6 +948,21 @@ export interface InitOutput {
752
948
  readonly memory: WebAssembly.Memory;
753
949
  readonly arc_length: (a: number, b: number, c: number) => number;
754
950
  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];
951
+ readonly brep_boolean_op: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
952
+ readonly brep_edges: (a: number, b: number, c: number) => [number, number];
953
+ readonly brep_extrude_curve: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
954
+ readonly brep_face_iso_curve: (a: number, b: number, c: number, d: number, e: number) => [number, number];
955
+ readonly brep_face_surface: (a: number, b: number, c: number) => [number, number];
956
+ readonly brep_face_tessellate: (a: number, b: number, c: number, d: number) => [number, number];
957
+ readonly brep_info: (a: number, b: number) => [number, number];
958
+ readonly brep_loft_curves: (a: number, b: number) => [number, number];
959
+ readonly brep_primitive: (a: number, b: number, c: number, d: number) => [number, number];
960
+ readonly brep_revolve_curve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
961
+ readonly brep_sheet_from_surface: (a: number, b: number) => [number, number];
962
+ readonly brep_tessellate: (a: number, b: number, c: number) => [number, number];
963
+ readonly brep_transform: (a: number, b: number, c: number, d: number) => [number, number];
964
+ readonly brep_validate: (a: number, b: number, c: number) => [number, number];
965
+ readonly brep_volume_area: (a: number, b: number, c: number) => [number, number];
755
966
  readonly build_nurbs_curve: (a: number, b: number, c: number, d: number) => [number, number];
756
967
  readonly chamfer_polycurve: (a: number, b: number, c: number) => [number, number];
757
968
  readonly circle_length: (a: number) => number;
@@ -806,6 +1017,7 @@ export interface InitOutput {
806
1017
  readonly mesh_build_coplanar_connected_face_groups: (a: number, b: number, c: number) => [number, number];
807
1018
  readonly mesh_build_render_buffers: (a: number, b: number, c: number, d: number) => [number, number];
808
1019
  readonly mesh_chamfer_all_edges: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1020
+ readonly mesh_clip_polyline: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
809
1021
  readonly mesh_compute_planar_curve_normal: (a: number, b: number, c: number) => [number, number];
810
1022
  readonly mesh_contains_point: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
811
1023
  readonly mesh_create_box: (a: number, b: number, c: number) => [number, number];
@@ -845,6 +1057,7 @@ export interface InitOutput {
845
1057
  readonly mesh_raycast_many: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
846
1058
  readonly mesh_rotate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
847
1059
  readonly mesh_scale: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1060
+ readonly mesh_solid_split_by_surface: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
848
1061
  readonly mesh_solid_split_plane: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
849
1062
  readonly mesh_surface_difference_all: (a: number, b: number, c: number, d: number) => [number, number];
850
1063
  readonly mesh_surface_split: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
@@ -854,10 +1067,24 @@ export interface InitOutput {
854
1067
  readonly mesh_translate: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
855
1068
  readonly nurbs_curve_curve_intersect: (a: number, b: number, c: number, d: number) => [number, number];
856
1069
  readonly nurbs_curve_plane_intersect: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1070
+ readonly nurbs_surface_closest_point: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1071
+ readonly nurbs_surface_curvature: (a: number, b: number, c: number, d: number) => [number, number];
1072
+ readonly nurbs_surface_derivatives: (a: number, b: number, c: number, d: number) => [number, number];
1073
+ readonly nurbs_surface_elevate_degree: (a: number, b: number, c: number, d: number) => [number, number];
857
1074
  readonly nurbs_surface_evaluate: (a: number, b: number, c: number, d: number) => [number, number];
1075
+ readonly nurbs_surface_extract_region: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1076
+ readonly nurbs_surface_extrude: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1077
+ readonly nurbs_surface_insert_knot: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1078
+ readonly nurbs_surface_iso_curve: (a: number, b: number, c: number, d: number) => [number, number];
858
1079
  readonly nurbs_surface_normal: (a: number, b: number, c: number, d: number) => [number, number];
859
1080
  readonly nurbs_surface_plane_intersect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1081
+ readonly nurbs_surface_primitive: (a: number, b: number, c: number, d: number) => [number, number];
1082
+ readonly nurbs_surface_revolve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
1083
+ readonly nurbs_surface_ruled: (a: number, b: number, c: number, d: number) => [number, number];
1084
+ readonly nurbs_surface_split: (a: number, b: number, c: number, d: number) => [number, number];
860
1085
  readonly nurbs_surface_surface_intersect: (a: number, b: number, c: number, d: number, e: number) => [number, number];
1086
+ readonly nurbs_surface_tessellate_adaptive: (a: number, b: number, c: number, d: number) => [number, number];
1087
+ readonly nurbs_surface_tessellate_render: (a: number, b: number, c: number, d: number, e: number) => [number, number];
861
1088
  readonly offset_polycurve: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
862
1089
  readonly offset_polycurve_all: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
863
1090
  readonly offset_polyline_curve: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];