1use serde::{Deserialize, Serialize};
2use wasm_bindgen::prelude::*;
3
4pub mod panic_hook;
9
10#[path = "geometry/tolerance.rs"]
11mod tolerance;
12pub use tolerance::{
13 curve_model_scale, model_scale, report_scale_migration, solid_model_scale, solid_scale,
14 offset_construction_band, vertex_tolerance_from_edges, KernelTolerances,
15 MeasuredTolerance, OFFSET_CONSTRUCTION_FLOOR, OFFSET_CONSTRUCTION_REL,
16 VERTEX_MATCH_FLOOR, VOLUME_DRIFT_ABS, VOLUME_DRIFT_REL,
17};
18#[path = "geometry/entity_tolerance.rs"]
23mod entity_tolerance;
24pub use entity_tolerance::{EntityTolerances, EDGE_CAP_FRACTION, VERTEX_CAP_FRACTION};
25#[path = "props/diagnostics.rs"]
26mod diagnostics;
27pub use diagnostics::{
28 Backing, DiagnosticEvent, DiagnosticSeverity, KernelDiagnostics, KernelOutcome, KernelRefusal,
29 KernelStage, OrRefuse, RefusalClass, SoundnessDefect, UndecidedCause,
30};
31#[path = "geometry/polygon.rs"]
32mod polygon;
33#[path = "geometry/curve.rs"]
34mod curve;
35pub use curve::{
36 make_arc, make_circle, make_hyperbola, make_line, make_parabola, uniform_clamped_knots,
37 KnotVector, NurbsCurve, Vec4, KNOT_DEDUP_EPS, KNOT_IDENTITY_TOL,
38};
39#[path = "blending/blend/mod.rs"]
40mod blend;
41pub use blend::{
42 take_blend_notes,
43 blend_closed_edge, blend_edge_variable, blend_open_edge, blend_smooth_chain,
44 round_convex_corner,
45};
46#[path = "blending/fillet.rs"]
47mod fillet;
48pub use fillet::{
49 chamfer_edge, chamfer_edge_angle, chamfer_edge_asymmetric, chamfer_edges_angle,
50 chamfer_edges_asymmetric, fillet_edge, fillet_edges, fillet_edges_reported,
51 fillet_edges_variable, fillet_edges_variable_law, fillet_edges_variable_vertex_radii,
52 BlendSelection,
53};
54#[path = "blending/law.rs"]
55mod law;
56pub use law::{LawSegment, RadiusLaw};
57#[path = "geometry/fit.rs"]
58mod fit;
59pub use fit::{
60 fit_polyline, fit_polyline_at, fit_polyline_of_degree, interpolate_curve, interpolate_curve_closed,
61 interpolate_curve_local, interpolate_curve_thinned, interpolate_curve_with_end_tangents,
62 simplify_polyline, simplify_polyline_indices, solve_banded, solve_dense, PolylineFit,
63 PolylineFitExit, PolylineFitLedger, PolylineFitReport, PolylineFitScope, MAX_FIT_STATIONS,
64};
65#[path = "geometry/image_curve.rs"]
66mod image_curve;
67pub use image_curve::{affine_image_curve, image_curve, image_curve_pair, ImageCurve, ImageCurveTier};
68#[path = "geometry/surface.rs"]
69mod surface;
70pub use surface::{
71 carrier_preview_patch, make_cone_surface, make_cylinder_surface, make_extrusion, make_plane,
72 make_revolution, make_sphere_surface, make_sphere_surface_framed, make_torus_surface,
73 ExtendRefusal, NurbsSurface, SurfaceSide, WeightSite, MAXIMUM_FOLD_ANGLE,
74 MAXIMUM_GROWTH_RATIO,
75};
76#[path = "geometry/coons.rs"]
77mod coons;
78pub use coons::{
79 coons_bilinear, coons_bilinear_reported, coons_with_ribbons, CompatWork, CoonsRefusal,
80 CoonsReport, RibbonReport,
81};
82#[path = "geometry/gordon.rs"]
83mod gordon;
84pub use gordon::{gordon_surface, gordon_surface_reported, GordonRefusal, GordonReport};
85#[path = "geometry/analytic_surface.rs"]
86mod analytic_surface;
87pub use analytic_surface::{
88 circle_angle_to_parameter, intersect_analytic_pair, plane_ruled_section_arc,
89 revolution_structure, AnalyticSurface, RevolutionFrame, RevolutionStructure,
90};
91pub(crate) use analytic_surface::{
92 intersect_analytic_pair_with, ruled_gate, ruled_gate_census, RuledGate,
93};
94#[path = "geometry/sphere_chart.rs"]
95mod sphere_chart;
96pub use sphere_chart::{
97 canonicalize_points, chart_grid_divisions, chart_grid_parameters, corner_index,
98 cube_edge_corner, cube_edge_divisions, cube_edge_index, cube_edge_parameters,
99 cube_edge_parts, Chart, ChartSegment, ChartSide, SphereAtlas,
100 SphericalRegion, CHART_COUNT, CUBE_CORNER_COUNT, CUBE_EDGE_COUNT,
101};
102#[path = "brep/solid_codec.rs"]
103mod solid_codec;
104pub use solid_codec::{decode_solid, encode_solid, SolidNames, SOLID_CODEC_VERSION};
105#[path = "brep/topology.rs"]
106mod topology;
107pub use topology::{
108 make_box_brep, make_cylinder_brep, make_pyramid_brep, BrepSolid, FaceRecord, IssueKind,
109 ValidationReport,
110};
111#[path = "brep/soundness.rs"]
112mod soundness;
113pub use soundness::{
114 face_self_intersections, loop_self_crossings, shell_vector_areas, solid_connectivity,
115 solid_euler, solid_self_intersections, ConnectivityReport, CrossingConfirmation, EulerReport,
116 FaceCrossing, FaceFold, FaceVectorArea,
117 LoopCrossing, LoopCrossingReport, SelfIntersectionOptions, SelfIntersectionReport,
118 ClosureReading, ShellConnectivity, ShellVectorArea, VectorAreaReport,
119};
120#[path = "brep/topology_arena.rs"]
121mod topology_arena;
122pub use topology_arena::{
123 ArenaCoedge, ArenaEdge, ArenaFace, ArenaLoop, ArenaShell, ArenaVertex, CoedgeId, EdgeId,
124 FaceId, LoopId, ShellId, TopologyArena, VertexId,
125};
126#[path = "brep/analytic_topology.rs"]
127mod analytic_topology;
128pub use analytic_topology::{
129 make_cone_brep, make_sphere_brep, make_sphere_brep_framed, make_torus_brep,
130};
131#[path = "construction/sweep_topology.rs"]
132mod sweep_topology;
133pub(crate) use sweep_topology::is_sweep_tight_bend;
134pub use sweep_topology::{
135 extrude_profile_brep, extrude_profile_brep_draft, fit_helix_curve, helix_sample_points,
136 profile_anchor, rib_from_profile, sweep_bend_profile, sweep_closure, BendStation,
137 JointContinuity, PathJoint, SweepClosure,
138 RibExtrusion, RibNames, SweepPath, MAX_JOINT_TANGENT_BREAK, SWEEP_TIGHT_BEND_REFUSAL,
139 SWEEP_TWIST_CLOSURE_REFUSAL,
140 build_swept_envelope, recognize_swept_envelope, swept_envelope_volume, SweptEnvelope,
141 SWEEP_ENVELOPE_REFUSAL, sweep_envelope_bodies,
142 sweep_profile_along_chain, sweep_profile_along_chain_with_stations, sweep_profile_along_path,
143 sweep_profile_along_path_anchored,
144 sweep_profile_helix,
145 sweep_profile_twisted, sweep_profile_twisted_anchored, ProfileAnchor, SectionPlacement,
146};
147#[path = "construction/revolve_topology.rs"]
148mod revolve_topology;
149pub use revolve_topology::{revolve_profile_brep, revolve_profile_brep_named};
150#[path = "construction/loft_topology.rs"]
151mod loft_topology;
152pub use loft_topology::{
153 loft_profile_brep, loft_profile_brep_closed, loft_profile_brep_guided,
154 loft_profile_brep_guided_frame, loft_profile_brep_tangent,
155};
156pub(crate) use loft_topology::loft_profile_brep_closed_shifted;
157#[path = "brep/transform_topology.rs"]
158mod transform_topology;
159pub use transform_topology::{mirror_brep, transform_brep, AffineTransform};
160#[path = "edit/split.rs"]
161mod split;
162pub use split::{
163 split_solid_by_face_surface, split_solid_by_plane, split_solid_by_surface, SplitSurface,
164};
165#[path = "props/mass_properties.rs"]
166mod mass_properties;
167pub use mass_properties::{
168 curve_arc_length, edge_arc_length, face_area, face_boundary_length, face_volume_contribution,
169 face_set_identity, mass_caller, parameter_space_area, solid_edge_length_total,
170 solid_mass_properties,
171 solid_mass_properties_full, solid_signed_volume, trim_polygons, DensityMassProperties,
172 FaceSetIdentity, FullMassProperties, MassCaller, MassProperties, MassPropertiesCache,
173};
174#[path = "meshing/tessellation.rs"]
175mod tessellation;
176pub use tessellation::{tessellate_brep, tessellate_face, TessellationOptions};
177#[path = "meshing/watertight_tessellation/mod.rs"]
178mod watertight_tessellation;
179pub use watertight_tessellation::{
180 sample_edge_polylines, sample_edges_encoded, tessellate_brep_watertight,
181 tessellate_brep_watertight_face_stride, tessellate_brep_watertight_face_stride_with_samples,
182};
183#[path = "feature_pipeline/mod.rs"]
188mod feature_pipeline;
189pub use feature_pipeline::execute_history_json;
190pub use feature_pipeline::{first_reference_name, reference_names};
191pub use feature_pipeline::face_transform_pivot;
195pub use feature_pipeline::{
198 clear_history_cache, execute_history, execute_history_observed, AddedSolid, Axis,
199 ComponentRecord, FeatureDescriptor, FeatureRefusal, FeatureResult, Frame, Fulfilment,
200 HistoryProgress, HistoryRequest, Rejected, RejectedKind,
201 HistoryResult, PortKind, PortRecord, ProfileLoop, ScenePoint, SketchProfile,
202};
203pub use feature_pipeline::wire_harness::{
207 bundle_diameter, Attachment as SplineAttachment, BundleStatus, PortSide, RouteResult,
208 RouteStatus,
209 WireHarnessBundle, WireHarnessConnection,
210 WireHarnessEndpoint, WireHarnessReport, WireHarnessState, BUNDLE_SOLID_PREFIX,
211 WIRE_HARNESS_FEATURE_ID, WIRE_HARNESS_FEATURE_TYPE,
212};
213pub use feature_pipeline::part_pins::{
218 declarations as declared_ports, declared_endpoints as declared_point_endpoints,
219 declared_points, endpoint_occurrence, follow_pin_edit, follow_point_edit, pin_labels,
220 pin_point_report, pins,
221 point_renames, port_group_for_unit, resolve_component_pin, resolve_part_pin,
222 unit_count as symbol_unit_count, unit_groups, DeclaredPin, DeclaredPoint, PinPoint,
223 PinPointChange, PinPointProblem, PinPointReport, PointRenames, DEFAULT_PORT_NAME,
224 DEFAULT_PORT_PURPOSE, PADS_BLOCK, SYMBOL_BLOCK,
225};
226pub use feature_pipeline::ports::{
231 address as port_address, document_is_boundary, seat_of as port_seat_of, seat_point,
232 seat_vector, seated_direction, split_address, unit_map, unseat_point, unseat_vector,
233 world_seat, PortDeclaration, PortPoint, PortPointRow, PortSeat, PortsReport, UnitProblem,
234 BOUNDARY_KEY, PORTS_BLOCK, PORTS_FEATURE_ID, PORTS_FEATURE_TYPE,
235};
236pub use feature_pipeline::pmi::{
240 clamp_text_size, format_dimension, format_number, pmi_schema_catalogue, pmi_type,
241 resolve_state as pmi_resolve_state, FcfFrame, PmiAnnotation, PmiAnnotationReport, PmiCamera,
242 PmiDisplay, PmiGeometry, PmiPlane, PmiProjection, PmiReport, PmiState, PmiStatus, PmiTypeDef, PmiView,
243 PmiViewReport, ToleranceBlock, ToleranceMode, PMI_TYPES,
244};
245pub use feature_pipeline::pmi::layout::{present as pmi_present, LayoutStyle as PmiLayoutStyle, Presentation as PmiPresentation};
246pub use feature_pipeline::pmi::annotations::fcf::{characteristic as pmi_characteristic, Characteristic as PmiCharacteristic, CHARACTERISTICS as PMI_CHARACTERISTICS};
247pub use feature_pipeline::assign_sketch_loop_ids;
251pub use feature_pipeline::{flat_pattern_dxf, flat_pattern_svg, is_sheet_metal_handle};
253pub use feature_pipeline::{native_import_payload, native_import_payload_with_appearance};
257pub use feature_pipeline::IsolatedSceneMetadata;
260pub use feature_pipeline::scene_metadata_colors_json;
263pub use feature_pipeline::{
266 add_part_to_library, add_part_to_library_impl, install_parts_library, missing_library_parts,
267 parts_library_json, parts_library_map, parts_library_revision, refresh_library_entry,
268 refresh_library_entry_impl, same_build, stable_json_hash, PartsLibraryEntry, PartsLibraryMap,
269};
270pub use feature_pipeline::assembly::{
273 assembly_add_constraint_json, assembly_apply_document_json,
274 assembly_apply_inferred_constraints_json, assembly_dof_json,
275 assembly_infer_constraints_json, assembly_inferable_types_json,
276 assembly_move_constraint_json, assembly_overlay_json, assembly_pose_updates_json,
277 assembly_remove_constraint_json, assembly_run_solve_json,
278 assembly_set_constraint_enabled_json, assembly_set_constraint_open_json,
279 assembly_state_json, assembly_statuses_json, assembly_update_constraint_json,
280 constraint_schema_catalogue,
281 assembly_add_constraint_impl, assembly_apply_document_impl, assembly_move_constraint_impl,
284 assembly_remove_constraint_impl, assembly_run_solve_impl,
285 assembly_set_constraint_enabled_impl, assembly_set_constraint_open_impl,
286 assembly_update_constraint_impl,
287};
288pub use feature_pipeline::{AssemblyState, ConstraintEntry};
289pub use feature_pipeline::assembly::transform_to_pose_params;
292pub use feature_pipeline::feature_schema_catalogue;
295pub use feature_pipeline::feature_hidden_params;
298pub use feature_pipeline::assembly::{constraint_type, ConstraintTypeDef, CONSTRAINT_TYPES};
301pub use feature_pipeline::{feature_context_applicable, SelectionProbe};
302pub use feature_pipeline::Env;
308
309pub fn eval_expression(
314 expressions: &str,
315 configurator_json: &serde_json::Value,
316 source: &str,
317) -> Result<f64, String> {
318 Env::build(expressions, configurator_json).and_then(|env| env.eval(source))
319}
320
321#[cfg(feature = "wasm-threads")]
328pub use wasm_bindgen_rayon::init_thread_pool;
329#[path = "geometry/projection.rs"]
330mod projection;
331pub use projection::{
332 project_point_to_curve, project_point_to_surface, project_point_to_surface_seeded,
333 CurveProjection, SurfaceProjection,
334};
335#[doc(hidden)]
336pub use projection::{
337 project_point_to_surface_basin_census, project_point_to_surface_general_lanes, BasinCensus,
338 GlobalStats,
339};
340#[path = "intersect/curve_surface_intersection.rs"]
341mod curve_surface_intersection;
342pub use curve_surface_intersection::{intersect_curve_surface, CurveSurfaceIntersection};
343#[path = "intersect/curve_curve_intersection.rs"]
344mod curve_curve_intersection;
345pub use curve_curve_intersection::{intersect_curves, CurveCurveIntersection};
346#[path = "intersect/surface_surface_intersection.rs"]
347mod surface_surface_intersection;
348pub use surface_surface_intersection::{
349 intersect_surfaces, intersect_surfaces_supplemental, SurfaceIntersectionCurve,
350 SurfaceIntersectionOptions,
351};
352pub(crate) use surface_surface_intersection::TRANSVERSE_SEED_CROSS;
353#[path = "brep/classification.rs"]
354mod classification;
355pub use classification::{
356 classify_point, containment_lane, horizon_cross_frame, parameter_point_in_face,
357 trim_sample_count, trim_station, ContainmentLane, PointClass, PointClassification,
358 PolygonClass, SolidClassifier, COVERING_RIM_STRIP_SWITCH, HORIZON_CONTAINMENT_SWITCH,
359 HORIZON_CROSS_FRAME_SWITCH, HORIZON_SINGLE_LOOP_SWITCH, NO_SPHERE_CHART_TRIM_SWITCH,
360 SEAM_BAND_MERGED_SWITCH,
361};
362#[doc(hidden)]
363pub use classification::parameter_point_in_face_scan;
364#[path = "geometry/spatial.rs"]
365mod spatial;
366pub use spatial::{Aabb, Bvh};
367#[path = "brep/pair_classification.rs"]
368mod pair_classification;
369pub use pair_classification::{
370 classify_surface_pair, classify_surface_pair_cached, SurfaceClassifyData,
371 SurfacePairClassification, SurfacePairRelation,
372};
373#[path = "intersect/arrangement.rs"]
374mod arrangement;
375pub use arrangement::{
376 arrange_segments, point_in_polygon, segment_intersection, ArrangementPiece, ArrangementRegion,
377 CycleUse, Segment2, Vec2,
378};
379#[path = "geometry/pcurve.rs"]
380mod pcurve;
381pub use pcurve::{
382 build_pcurve_on_surface, build_pcurve_on_surface_marched, build_pcurve_on_surface_range,
383 build_pcurve_on_surface_range_dense, build_pcurve_on_surface_stations, fit_pcurve_on_surface,
384 fit_pcurve_on_surface_marched, fit_pcurve_on_surface_range, fit_pcurve_on_surface_range_dense,
385 fit_pcurve_on_surface_stations, PcurveFit, PcurveFitExit, PcurveFitLedger, PcurveFitReport,
386 PcurveFitScope, PCURVE_OFF_BAR, PCURVE_REFINEMENT_TOLERANCE,
387};
388#[path = "csg/imprint.rs"]
389mod imprint;
390pub use imprint::{
391 build_imprints, EdgeSplitRecord, FaceImprints, FaceKey, FacePcurve, ImprintOptions,
392 ImprintPieceRecord, ImprintResultRecord, ImprintVertex,
393};
394#[path = "csg/edge_split.rs"]
395mod edge_split;
396pub use edge_split::{apply_edge_splits, apply_edge_splits_with_map};
397#[path = "csg/fragment.rs"]
398mod fragment;
399pub use fragment::{
400 fragment_face, fragment_solid, FaceFragmentRecord, FragmentCoedge, FragmentEdgeSource,
401 FragmentLoop,
402};
403#[path = "csg/boolean/mod.rs"]
404mod boolean;
405pub use boolean::{
406 boolean_operation, boolean_operation_nary, boolean_operation_with_diagnostics, boolean_split_operands,
407 BooleanOperation, BooleanOptions,
408};
409#[path = "csg/oracle.rs"]
410mod oracle;
411pub use oracle::{
412 boolean_residual_fusables, boolean_semantic_disagreement, boolean_semantic_disagreement_nary,
413 OracleReport, ResidualFusable, ResidualKind, SemanticDisagreement, DISAGREEMENT_THRESHOLD,
414};
415#[path = "healing/heal.rs"]
416mod heal;
417#[path = "healing/accept.rs"]
423mod accept;
424pub use accept::{
425 accept_sound, accept_sound_against, resolve_face_crossing, resolve_face_crossing_between,
426 take_crossing_repairs,
427 CrossingRepairRecord,
428};
429#[path = "offset/point.rs"]
434mod offset_point;
435pub use offset_point::{OffsetEvaluator, OffsetNormal, OffsetSample};
436#[path = "offset/analytic_pair.rs"]
443mod offset_analytic_pair;
444#[path = "offset/retrim.rs"]
451mod offset_retrim;
452#[path = "offset/reintersect.rs"]
460mod offset_reintersect;
461#[path = "offset/measure.rs"]
471mod offset_measure;
472pub use offset_measure::{
473 measure_edge_against_pcurve_image, measure_surface_fit_against_pointwise_offset,
474 span_midpoint_error, vertex_endpoint_gap,
475};
476#[path = "offset/offset.rs"]
477mod offset;
478pub use offset::{
479 offset_face_carrier, offset_face_carrier_measured, offset_face_carrier_sided, offset_surface,
480 offset_surface_measured, offset_surface_measured_sided, CarrierDeviation, CarrierExtension,
481 MeasuredOffsetSurface, OffsetFaceCarrier, OffsetSurfaceLane,
482};
483#[path = "offset/regularity.rs"]
489mod offset_regularity;
490#[path = "offset/fold_locus.rs"]
496mod offset_fold_locus;
497#[path = "offset/carve.rs"]
503mod offset_carve;
504#[path = "offset/thicken.rs"]
505mod thicken;
506pub use thicken::{thicken_face_sheet, thicken_trimmed_sheet};
507#[path = "healing/coalesce.rs"]
508mod coalesce;
509pub use coalesce::{concatenate_exact_curve_pieces, merge_curve_continuation_edges};
510#[path = "healing/face_merge.rs"]
511mod face_merge;
512#[allow(dead_code)]
515#[path = "healing/faceted_repair.rs"]
516mod faceted_repair;
517pub use face_merge::{merge_same_surface_faces, merge_same_surface_faces_excluding};
518pub use faceted_repair::{mesh_to_faceted_brep, repair_triangle_soup, MeshRepairReport};
519#[path = "offset/offset_shell.rs"]
520mod offset_shell;
521pub use offset_shell::{
522 offset_shell, offset_shell_with_diagnostics, OffsetFaceRole, OffsetShellFaceImageRecord,
523 OffsetShellResultRecord,
524};
525pub(crate) use offset_shell::{is_offset_shell_no_retained_face, is_offset_shell_open_curved_rim};
526#[path = "io/step_matrix.rs"]
527mod step_matrix;
528#[path = "io/step.rs"]
529mod step;
530pub use step::{
531 assembly_export_tree, audit_step_manifold, audit_step_pcurves, export_step,
532 export_step_assembly, export_step_assembly_report, export_step_report,
533 export_step_report_named, Mat4, StepAssemblyExport, StepColors, StepExportOccurrence,
534 StepExportProduct, StepExportReport, StepPmi, PART_ATTRIBUTES, PART_NUMBER,
535};
536#[path = "io/appearance.rs"]
540mod appearance;
541pub use appearance::{BodyAppearance, ImportedColor, COLOR_METADATA_KEY};
542#[path = "io/step_import/mod.rs"]
543mod step_import;
544pub use step_import::{
545 import_step, import_step_report, import_step_trim_readings, import_step_with_appearance,
546 occurrence_ref_parts, read_step_assembly, read_step_pmi, rewrite_occurrence_refs,
547 StepAssembly, StepBodyTrimReadings, StepEdgeReading, StepFaceReading, StepImportReport,
548 StepOccurrence, StepProduct, StepSuppliedTrim, StepTrimReadings, OCCURRENCE_REF_PREFIX,
549 STATED_PRECISION_INCONSISTENCY_RATIO,
550};
551#[doc(hidden)]
553pub fn io_step_text_for_tests(value: &str) -> String {
554 step::pmi::step_text(value)
555}
556#[doc(hidden)]
557pub fn io_step_decode_text_for_tests(value: &str) -> String {
558 step_import::decode_step_text_for_tests(value)
559}
560#[path = "io/iges/mod.rs"]
561mod iges;
562pub use iges::{export_iges, import_iges};
563#[path = "io/mesh_io.rs"]
564mod mesh_io;
565pub use mesh_io::{
566 read_binary_stl, read_obj, write_binary_stl, write_obj, ObjReadResult, StlReadResult,
567};
568#[path = "io/three_mf/mod.rs"]
574mod three_mf;
575pub use three_mf::{
576 read_3mf, ThreeMfError, ThreeMfInstance, ThreeMfMesh, ThreeMfReadResult, ThreeMfUnit,
577};
578#[path = "io/glb.rs"]
582mod glb;
583pub use glb::{write_glb, GlbReport, GlbSolid, GlbUpAxis, GLB_MAGIC};
584#[path = "io/snapshot.rs"]
588mod snapshot;
589pub use snapshot::{
590 restore_solids, snapshot_resident_solids, snapshot_solids, RestoredSnapshot, RestoredSolid,
591 SNAPSHOT_FORMAT_VERSION,
592};
593#[path = "solvers/linear_algebra.rs"]
594mod solver_linear_algebra;
595#[path = "solvers/sketch_solver.rs"]
596mod sketch_solver;
597pub use sketch_solver::{
598 is_sketch_origin_point_id, sketch_id_key, solve_sketch, solve_sketch_from_json,
599 SketchSolverSettings, SolveSketchRequest, SKETCH_ORIGIN_POINT_ID,
600};
601#[path = "solvers/assembly_solver.rs"]
602mod assembly_solver;
603pub use assembly_solver::{
604 solve_assembly, AssemblyBody, AssemblyMate, AssemblySolution, AssemblySolveOptions, BodyPose,
605 MateAlign, MateAxis, MateKind, MatePlane, MateResidualReport, SolveStrategy,
606};
607#[path = "solvers/assembly_resolve.rs"]
611mod assembly_resolve;
612pub use assembly_resolve::{
613 is_component_reference, resolve_component_point, resolve_edge_selection,
614 resolve_face_selection, resolve_named_selection, resolve_vertex_selection,
615 split_component_namespace, ResolveError, SelectionGeometry,
616};
617#[path = "edit/direct_edit.rs"]
618mod direct_edit;
619pub use direct_edit::{
620 delete_face_and_heal, delete_faces_and_heal, move_faces, offset_freeform_face,
621 offset_revolution_face, offset_ruled_face, offset_sphere_face, offset_torus_face,
622 recut_moved_planes, recut_moved_planes_rigid, resolve_face_by_point, rotate_faces,
623 route_reading, RouteReading,
624};
625pub use direct_edit::{face_refusal_slugs, face_transform_reason, FaceTransformReason};
626pub use direct_edit::{
627 refit_faces_as_one, refit_refusal_phrases, RefitCarrier, RefitReport, RefitSurfaceKind,
628};
629#[path = "healing/sew.rs"]
630mod sew;
631pub use sew::{sew_solid, split_pinched_vertices, SewReport};
632#[path = "meshing/mesh_weld.rs"]
633mod mesh_weld;
634#[path = "meshing/mesh_segment.rs"]
635mod mesh_segment;
636pub use mesh_segment::{
637 mesh_regions_to_brep, segment_mesh_faces, MeshRegion, MeshSegmentation, RegionCarrier,
638 SegmentOptions, UNASSIGNED_REGION,
639};
640
641#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize)]
642pub struct Vec3 {
643 pub x: f64,
644 pub y: f64,
645 pub z: f64,
646}
647
648impl Vec3 {
649 pub fn new(x: f64, y: f64, z: f64) -> Self {
650 Self { x, y, z }
651 }
652 pub fn sub(self, rhs: Self) -> Self {
653 Self::new(self.x - rhs.x, self.y - rhs.y, self.z - rhs.z)
654 }
655 pub fn add(self, rhs: Self) -> Self {
656 Self::new(self.x + rhs.x, self.y + rhs.y, self.z + rhs.z)
657 }
658 pub fn scale(self, factor: f64) -> Self {
659 Self::new(self.x * factor, self.y * factor, self.z * factor)
660 }
661 pub fn cross(self, rhs: Self) -> Self {
662 Self::new(
663 self.y * rhs.z - self.z * rhs.y,
664 self.z * rhs.x - self.x * rhs.z,
665 self.x * rhs.y - self.y * rhs.x,
666 )
667 }
668 pub fn dot(self, rhs: Self) -> f64 {
669 self.x * rhs.x + self.y * rhs.y + self.z * rhs.z
670 }
671 pub fn length(self) -> f64 {
672 self.dot(self).sqrt()
673 }
674 pub fn length_squared(self) -> f64 {
675 self.dot(self)
676 }
677 pub fn normalized(self) -> Result<Self, String> {
678 let length = self.length();
679 if length <= 1e-12 {
680 return Err("Vec3.normalized: zero-length vector".into());
681 }
682 Ok(self.scale(1.0 / length))
683 }
684 pub fn perpendicular(self) -> Result<Self, String> {
685 let x = self.x.abs();
686 let y = self.y.abs();
687 let z = self.z.abs();
688 let axis = if x <= y && x <= z {
689 Self::new(1.0, 0.0, 0.0)
690 } else if y <= z {
691 Self::new(0.0, 1.0, 0.0)
692 } else {
693 Self::new(0.0, 0.0, 1.0)
694 };
695 self.cross(axis).normalized()
696 }
697}
698
699#[derive(Clone, Debug, Default, Deserialize, Serialize)]
700pub struct Mesh {
701 pub positions: Vec<f64>,
702 pub normals: Vec<f64>,
703 pub indices: Vec<u32>,
704 pub face_ids: Vec<u32>,
705}
706
707impl Mesh {
708 fn push_vertex(&mut self, point: Vec3, normal: Vec3) -> u32 {
709 self.positions.extend([point.x, point.y, point.z]);
710 self.normals.extend([normal.x, normal.y, normal.z]);
711 (self.positions.len() / 3 - 1) as u32
712 }
713
714 fn quad(&mut self, points: [Vec3; 4], normal: Vec3, face_id: u32) {
715 let base = self.push_vertex(points[0], normal);
716 for point in points.iter().skip(1) {
717 self.push_vertex(*point, normal);
718 }
719 self.indices
720 .extend([base, base + 1, base + 2, base, base + 2, base + 3]);
721 self.face_ids.extend([face_id, face_id]);
722 }
723
724 pub fn signed_volume(&self) -> f64 {
725 self.indices
726 .chunks_exact(3)
727 .map(|tri| {
728 let point = |index: u32| {
729 let i = index as usize * 3;
730 Vec3::new(
731 self.positions[i],
732 self.positions[i + 1],
733 self.positions[i + 2],
734 )
735 };
736 point(tri[0]).dot(point(tri[1]).cross(point(tri[2]))) / 6.0
737 })
738 .sum()
739 }
740
741 pub fn validate(&self) -> Result<(), String> {
742 if self.positions.len() % 3 != 0 || self.normals.len() != self.positions.len() {
743 return Err("invalid vertex or normal buffer".into());
744 }
745 self.validate_geometry()
746 }
747
748 pub fn validate_geometry(&self) -> Result<(), String> {
753 if self.positions.len() % 3 != 0 {
754 return Err("invalid vertex buffer".into());
755 }
756 if self.indices.len() % 3 != 0 {
757 return Err("index buffer is not triangular".into());
758 }
759 let count = self.positions.len() / 3;
760 if self.indices.iter().any(|index| *index as usize >= count) {
761 return Err("index outside vertex buffer".into());
762 }
763 if !self.positions.iter().all(|value| value.is_finite()) {
764 return Err("non-finite vertex".into());
765 }
766 Ok(())
767 }
768}
769
770pub fn make_box(size_x: f64, size_y: f64, size_z: f64) -> Mesh {
771 let x = size_x.abs();
772 let y = size_y.abs();
773 let z = size_z.abs();
774 let p = [
775 Vec3::new(0.0, 0.0, 0.0),
776 Vec3::new(x, 0.0, 0.0),
777 Vec3::new(x, y, 0.0),
778 Vec3::new(0.0, y, 0.0),
779 Vec3::new(0.0, 0.0, z),
780 Vec3::new(x, 0.0, z),
781 Vec3::new(x, y, z),
782 Vec3::new(0.0, y, z),
783 ];
784 let mut mesh = Mesh::default();
785 mesh.quad([p[0], p[3], p[2], p[1]], Vec3::new(0.0, 0.0, -1.0), 0);
786 mesh.quad([p[4], p[5], p[6], p[7]], Vec3::new(0.0, 0.0, 1.0), 1);
787 mesh.quad([p[0], p[1], p[5], p[4]], Vec3::new(0.0, -1.0, 0.0), 2);
788 mesh.quad([p[3], p[7], p[6], p[2]], Vec3::new(0.0, 1.0, 0.0), 3);
789 mesh.quad([p[0], p[4], p[7], p[3]], Vec3::new(-1.0, 0.0, 0.0), 4);
790 mesh.quad([p[1], p[2], p[6], p[5]], Vec3::new(1.0, 0.0, 0.0), 5);
791 mesh
792}
793
794pub fn make_cylinder(radius: f64, height: f64, segments: usize) -> Mesh {
795 let radius = radius.abs();
796 let height = height.abs();
797 let segments = segments.max(3);
798 let mut mesh = Mesh::default();
799 for i in 0..segments {
800 let a = std::f64::consts::TAU * i as f64 / segments as f64;
801 let b = std::f64::consts::TAU * (i + 1) as f64 / segments as f64;
802 let (sa, ca) = a.sin_cos();
803 let (sb, cb) = b.sin_cos();
804 let pa = Vec3::new(radius * ca, 0.0, -radius * sa);
805 let pb = Vec3::new(radius * cb, 0.0, -radius * sb);
806 let ta = Vec3::new(pa.x, height, pa.z);
807 let tb = Vec3::new(pb.x, height, pb.z);
808 mesh.quad(
809 [pa, pb, tb, ta],
810 Vec3::new((ca + cb) * 0.5, 0.0, -(sa + sb) * 0.5),
811 0,
812 );
813 let bottom = mesh.push_vertex(Vec3::default(), Vec3::new(0.0, -1.0, 0.0));
814 let bi = mesh.push_vertex(pb, Vec3::new(0.0, -1.0, 0.0));
815 let bj = mesh.push_vertex(pa, Vec3::new(0.0, -1.0, 0.0));
816 mesh.indices.extend([bottom, bi, bj]);
817 mesh.face_ids.push(1);
818 let top = mesh.push_vertex(Vec3::new(0.0, height, 0.0), Vec3::new(0.0, 1.0, 0.0));
819 let ti = mesh.push_vertex(ta, Vec3::new(0.0, 1.0, 0.0));
820 let tj = mesh.push_vertex(tb, Vec3::new(0.0, 1.0, 0.0));
821 mesh.indices.extend([top, ti, tj]);
822 mesh.face_ids.push(2);
823 }
824 mesh
825}
826
827
828mod abi;
829pub use abi::*;
830