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