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