brep-io-kernel 1.0.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.
- package/LICENSE.md +32 -0
- package/README.md +144 -0
- package/dist-kernel/brep-kernel.js +74699 -0
- package/dist-kernel/help/CONTRIBUTING.html +248 -0
- package/dist-kernel/help/LICENSE.html +248 -0
- package/dist-kernel/help/MODELING.png +0 -0
- package/dist-kernel/help/PMI.png +0 -0
- package/dist-kernel/help/SKETCH.png +0 -0
- package/dist-kernel/help/assembly-constraints__Coincident_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Angle_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Distance_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Fixed_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Parallel_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Touch_Align_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints__angle-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__coincident-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__distance-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__fixed-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__parallel-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__solver.html +248 -0
- package/dist-kernel/help/assembly-constraints__touch-align-constraint.html +248 -0
- package/dist-kernel/help/brep-api.html +263 -0
- package/dist-kernel/help/brep-kernel.html +258 -0
- package/dist-kernel/help/brep-model.html +248 -0
- package/dist-kernel/help/cylindrical-face-radius-embedding.html +290 -0
- package/dist-kernel/help/dialog-screenshots.html +248 -0
- package/dist-kernel/help/extruded-sketch-radius-embedding.html +336 -0
- package/dist-kernel/help/features__Assembly_Component_dialog.png +0 -0
- package/dist-kernel/help/features__Boolean_dialog.png +0 -0
- package/dist-kernel/help/features__Chamfer_dialog.png +0 -0
- package/dist-kernel/help/features__Datium_dialog.png +0 -0
- package/dist-kernel/help/features__Extrude_dialog.png +0 -0
- package/dist-kernel/help/features__Fillet_dialog.png +0 -0
- package/dist-kernel/help/features__Helix_dialog.png +0 -0
- package/dist-kernel/help/features__Hole_dialog.png +0 -0
- package/dist-kernel/help/features__Image_Heightmap_Solid_dialog.png +0 -0
- package/dist-kernel/help/features__Image_to_Face_dialog.png +0 -0
- package/dist-kernel/help/features__Import_3D_Model_dialog.png +0 -0
- package/dist-kernel/help/features__Loft_dialog.png +0 -0
- package/dist-kernel/help/features__Mirror_dialog.png +0 -0
- package/dist-kernel/help/features__Offset_Shell_dialog.png +0 -0
- package/dist-kernel/help/features__Overlap_Cleanup_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_Linear_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_Radial_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_dialog.png +0 -0
- package/dist-kernel/help/features__Plane_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cone_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cube_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cylinder_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Pyramid_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Sphere_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Torus_dialog.png +0 -0
- package/dist-kernel/help/features__Remesh_dialog.png +0 -0
- package/dist-kernel/help/features__Revolve_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Contour_Flange_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Cutout_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Flange_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Tab_dialog.png +0 -0
- package/dist-kernel/help/features__Sketch_dialog.png +0 -0
- package/dist-kernel/help/features__Spline_dialog.png +0 -0
- package/dist-kernel/help/features__Sweep_dialog.png +0 -0
- package/dist-kernel/help/features__Transform_dialog.png +0 -0
- package/dist-kernel/help/features__Tube_dialog.png +0 -0
- package/dist-kernel/help/features__assembly-component.html +248 -0
- package/dist-kernel/help/features__boolean.html +248 -0
- package/dist-kernel/help/features__chamfer.html +248 -0
- package/dist-kernel/help/features__datium.html +248 -0
- package/dist-kernel/help/features__datum.html +248 -0
- package/dist-kernel/help/features__extrude.html +248 -0
- package/dist-kernel/help/features__fillet.html +248 -0
- package/dist-kernel/help/features__helix.html +248 -0
- package/dist-kernel/help/features__hole.html +248 -0
- package/dist-kernel/help/features__image-heightmap-solid.html +248 -0
- package/dist-kernel/help/features__image-to-face-2D_dialog.png +0 -0
- package/dist-kernel/help/features__image-to-face-3D_dialog.png +0 -0
- package/dist-kernel/help/features__image-to-face.html +248 -0
- package/dist-kernel/help/features__import-3d-model.html +248 -0
- package/dist-kernel/help/features__index.html +248 -0
- package/dist-kernel/help/features__loft.html +248 -0
- package/dist-kernel/help/features__mirror.html +248 -0
- package/dist-kernel/help/features__offset-shell.html +248 -0
- package/dist-kernel/help/features__pattern-linear.html +248 -0
- package/dist-kernel/help/features__pattern-radial.html +248 -0
- package/dist-kernel/help/features__pattern.html +248 -0
- package/dist-kernel/help/features__plane.html +248 -0
- package/dist-kernel/help/features__primitive-cone.html +248 -0
- package/dist-kernel/help/features__primitive-cube.html +248 -0
- package/dist-kernel/help/features__primitive-cylinder.html +248 -0
- package/dist-kernel/help/features__primitive-pyramid.html +248 -0
- package/dist-kernel/help/features__primitive-sphere.html +248 -0
- package/dist-kernel/help/features__primitive-torus.html +248 -0
- package/dist-kernel/help/features__remesh.html +248 -0
- package/dist-kernel/help/features__revolve.html +248 -0
- package/dist-kernel/help/features__sheet-metal-contour-flange.html +248 -0
- package/dist-kernel/help/features__sheet-metal-flange.html +248 -0
- package/dist-kernel/help/features__sheet-metal-tab.html +248 -0
- package/dist-kernel/help/features__sketch.html +248 -0
- package/dist-kernel/help/features__spline.html +248 -0
- package/dist-kernel/help/features__sweep.html +248 -0
- package/dist-kernel/help/features__transform.html +248 -0
- package/dist-kernel/help/features__tube.html +248 -0
- package/dist-kernel/help/file-formats.html +248 -0
- package/dist-kernel/help/getting-started.html +248 -0
- package/dist-kernel/help/highlights.html +248 -0
- package/dist-kernel/help/history-systems.html +248 -0
- package/dist-kernel/help/how-it-works.html +248 -0
- package/dist-kernel/help/index.html +862 -0
- package/dist-kernel/help/input-params-schema.html +363 -0
- package/dist-kernel/help/inspector-improvements.html +248 -0
- package/dist-kernel/help/inspector.html +248 -0
- package/dist-kernel/help/modes__modeling.html +248 -0
- package/dist-kernel/help/modes__pmi.html +248 -0
- package/dist-kernel/help/modes__sketch.html +248 -0
- package/dist-kernel/help/plugins.html +248 -0
- package/dist-kernel/help/pmi-annotations__Angle_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Explode_Body_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Hole_Callout_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Leader_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Linear_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Note_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Radial_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__angle-dimension.html +248 -0
- package/dist-kernel/help/pmi-annotations__explode-body.html +248 -0
- package/dist-kernel/help/pmi-annotations__hole-callout.html +248 -0
- package/dist-kernel/help/pmi-annotations__index.html +248 -0
- package/dist-kernel/help/pmi-annotations__leader.html +248 -0
- package/dist-kernel/help/pmi-annotations__linear-dimension.html +248 -0
- package/dist-kernel/help/pmi-annotations__note.html +248 -0
- package/dist-kernel/help/pmi-annotations__radial-dimension.html +248 -0
- package/dist-kernel/help/search-index.json +464 -0
- package/dist-kernel/help/simplified-radial-dimensions.html +298 -0
- package/dist-kernel/help/solid-methods.html +359 -0
- package/dist-kernel/help/table-of-contents.html +330 -0
- package/dist-kernel/help/ui-overview.html +248 -0
- package/dist-kernel/help/whats-new.html +248 -0
- package/package.json +54 -0
- package/src/BREP/AssemblyComponent.js +42 -0
- package/src/BREP/BREP.js +43 -0
- package/src/BREP/BetterSolid.js +805 -0
- package/src/BREP/Edge.js +103 -0
- package/src/BREP/Extrude.js +403 -0
- package/src/BREP/Face.js +187 -0
- package/src/BREP/MeshRepairer.js +634 -0
- package/src/BREP/OffsetShellSolid.js +614 -0
- package/src/BREP/PointCloudWrap.js +302 -0
- package/src/BREP/Revolve.js +345 -0
- package/src/BREP/SolidMethods/authoring.js +112 -0
- package/src/BREP/SolidMethods/booleanOps.js +230 -0
- package/src/BREP/SolidMethods/chamfer.js +122 -0
- package/src/BREP/SolidMethods/edgeResolution.js +25 -0
- package/src/BREP/SolidMethods/fillet.js +792 -0
- package/src/BREP/SolidMethods/index.js +72 -0
- package/src/BREP/SolidMethods/io.js +105 -0
- package/src/BREP/SolidMethods/lifecycle.js +103 -0
- package/src/BREP/SolidMethods/manifoldOps.js +375 -0
- package/src/BREP/SolidMethods/meshCleanup.js +2512 -0
- package/src/BREP/SolidMethods/meshQueries.js +264 -0
- package/src/BREP/SolidMethods/metadata.js +106 -0
- package/src/BREP/SolidMethods/metrics.js +51 -0
- package/src/BREP/SolidMethods/transforms.js +361 -0
- package/src/BREP/SolidMethods/visualize.js +508 -0
- package/src/BREP/SolidShared.js +26 -0
- package/src/BREP/Sweep.js +1596 -0
- package/src/BREP/Tube.js +857 -0
- package/src/BREP/Vertex.js +43 -0
- package/src/BREP/applyBooleanOperation.js +704 -0
- package/src/BREP/boundsUtils.js +48 -0
- package/src/BREP/chamfer.js +551 -0
- package/src/BREP/edgePolylineUtils.js +85 -0
- package/src/BREP/fillets/common.js +388 -0
- package/src/BREP/fillets/fillet.js +1422 -0
- package/src/BREP/fillets/filletGeometry.js +15 -0
- package/src/BREP/fillets/inset.js +389 -0
- package/src/BREP/fillets/offsetHelper.js +143 -0
- package/src/BREP/fillets/outset.js +88 -0
- package/src/BREP/helix.js +193 -0
- package/src/BREP/meshToBrep.js +234 -0
- package/src/BREP/primitives.js +279 -0
- package/src/BREP/setupManifold.js +71 -0
- package/src/BREP/threadGeometry.js +1120 -0
- package/src/BREP/triangleUtils.js +8 -0
- package/src/BREP/triangulate.js +608 -0
- package/src/FeatureRegistry.js +183 -0
- package/src/PartHistory.js +1132 -0
- package/src/UI/AccordionWidget.js +292 -0
- package/src/UI/CADmaterials.js +850 -0
- package/src/UI/EnvMonacoEditor.js +522 -0
- package/src/UI/FloatingWindow.js +396 -0
- package/src/UI/HistoryWidget.js +457 -0
- package/src/UI/MainToolbar.js +131 -0
- package/src/UI/ModelLibraryView.js +194 -0
- package/src/UI/OrthoCameraIdle.js +206 -0
- package/src/UI/PluginsWidget.js +280 -0
- package/src/UI/SceneListing.js +606 -0
- package/src/UI/SelectionFilter.js +629 -0
- package/src/UI/ViewCube.js +389 -0
- package/src/UI/assembly/AssemblyConstraintCollectionWidget.js +329 -0
- package/src/UI/assembly/AssemblyConstraintControlsWidget.js +282 -0
- package/src/UI/assembly/AssemblyConstraintsWidget.css +292 -0
- package/src/UI/assembly/AssemblyConstraintsWidget.js +1373 -0
- package/src/UI/assembly/constraintFaceUtils.js +115 -0
- package/src/UI/assembly/constraintHighlightUtils.js +70 -0
- package/src/UI/assembly/constraintLabelUtils.js +31 -0
- package/src/UI/assembly/constraintPointUtils.js +64 -0
- package/src/UI/assembly/constraintSelectionUtils.js +185 -0
- package/src/UI/assembly/constraintStatusUtils.js +142 -0
- package/src/UI/componentSelectorModal.js +240 -0
- package/src/UI/controls/CombinedTransformControls.js +386 -0
- package/src/UI/dialogs.js +351 -0
- package/src/UI/expressionsManager.js +100 -0
- package/src/UI/featureDialogWidgets/booleanField.js +25 -0
- package/src/UI/featureDialogWidgets/booleanOperationField.js +97 -0
- package/src/UI/featureDialogWidgets/buttonField.js +45 -0
- package/src/UI/featureDialogWidgets/componentSelectorField.js +102 -0
- package/src/UI/featureDialogWidgets/defaultField.js +23 -0
- package/src/UI/featureDialogWidgets/fileField.js +66 -0
- package/src/UI/featureDialogWidgets/index.js +34 -0
- package/src/UI/featureDialogWidgets/numberField.js +165 -0
- package/src/UI/featureDialogWidgets/optionsField.js +33 -0
- package/src/UI/featureDialogWidgets/referenceSelectionField.js +208 -0
- package/src/UI/featureDialogWidgets/stringField.js +24 -0
- package/src/UI/featureDialogWidgets/textareaField.js +28 -0
- package/src/UI/featureDialogWidgets/threadDesignationField.js +160 -0
- package/src/UI/featureDialogWidgets/transformField.js +252 -0
- package/src/UI/featureDialogWidgets/utils.js +43 -0
- package/src/UI/featureDialogWidgets/vec3Field.js +133 -0
- package/src/UI/featureDialogs.js +1414 -0
- package/src/UI/fileManagerWidget.js +615 -0
- package/src/UI/history/HistoryCollectionWidget.js +1294 -0
- package/src/UI/history/historyCollectionWidget.css.js +257 -0
- package/src/UI/history/historyDisplayInfo.js +133 -0
- package/src/UI/mobile.js +28 -0
- package/src/UI/objectDump.js +442 -0
- package/src/UI/pmi/AnnotationCollectionWidget.js +120 -0
- package/src/UI/pmi/AnnotationHistory.js +353 -0
- package/src/UI/pmi/AnnotationRegistry.js +90 -0
- package/src/UI/pmi/BaseAnnotation.js +269 -0
- package/src/UI/pmi/LabelOverlay.css +102 -0
- package/src/UI/pmi/LabelOverlay.js +191 -0
- package/src/UI/pmi/PMIMode.js +1550 -0
- package/src/UI/pmi/PMIViewsWidget.js +1098 -0
- package/src/UI/pmi/annUtils.js +729 -0
- package/src/UI/pmi/dimensions/AngleDimensionAnnotation.js +647 -0
- package/src/UI/pmi/dimensions/ExplodeBodyAnnotation.js +507 -0
- package/src/UI/pmi/dimensions/HoleCalloutAnnotation.js +462 -0
- package/src/UI/pmi/dimensions/LeaderAnnotation.js +403 -0
- package/src/UI/pmi/dimensions/LinearDimensionAnnotation.js +532 -0
- package/src/UI/pmi/dimensions/NoteAnnotation.js +110 -0
- package/src/UI/pmi/dimensions/RadialDimensionAnnotation.js +659 -0
- package/src/UI/pmi/pmiStyle.js +44 -0
- package/src/UI/sketcher/SketchMode3D.js +4095 -0
- package/src/UI/sketcher/dimensions.js +674 -0
- package/src/UI/sketcher/glyphs.js +236 -0
- package/src/UI/sketcher/highlights.js +60 -0
- package/src/UI/toolbarButtons/aboutButton.js +5 -0
- package/src/UI/toolbarButtons/exportButton.js +609 -0
- package/src/UI/toolbarButtons/flatPatternButton.js +307 -0
- package/src/UI/toolbarButtons/importButton.js +160 -0
- package/src/UI/toolbarButtons/inspectorToggleButton.js +12 -0
- package/src/UI/toolbarButtons/metadataButton.js +1063 -0
- package/src/UI/toolbarButtons/orientToFaceButton.js +114 -0
- package/src/UI/toolbarButtons/registerDefaultButtons.js +46 -0
- package/src/UI/toolbarButtons/saveButton.js +99 -0
- package/src/UI/toolbarButtons/scriptRunnerButton.js +302 -0
- package/src/UI/toolbarButtons/testsButton.js +26 -0
- package/src/UI/toolbarButtons/undoRedoButtons.js +25 -0
- package/src/UI/toolbarButtons/wireframeToggleButton.js +5 -0
- package/src/UI/toolbarButtons/zoomToFitButton.js +5 -0
- package/src/UI/triangleDebuggerWindow.js +945 -0
- package/src/UI/viewer.js +4228 -0
- package/src/assemblyConstraints/AssemblyConstraintHistory.js +1576 -0
- package/src/assemblyConstraints/AssemblyConstraintRegistry.js +120 -0
- package/src/assemblyConstraints/BaseAssemblyConstraint.js +66 -0
- package/src/assemblyConstraints/constraintExpressionUtils.js +35 -0
- package/src/assemblyConstraints/constraintUtils/parallelAlignment.js +676 -0
- package/src/assemblyConstraints/constraints/AngleConstraint.js +485 -0
- package/src/assemblyConstraints/constraints/CoincidentConstraint.js +194 -0
- package/src/assemblyConstraints/constraints/DistanceConstraint.js +616 -0
- package/src/assemblyConstraints/constraints/FixedConstraint.js +78 -0
- package/src/assemblyConstraints/constraints/ParallelConstraint.js +252 -0
- package/src/assemblyConstraints/constraints/TouchAlignConstraint.js +961 -0
- package/src/core/entities/HistoryCollectionBase.js +72 -0
- package/src/core/entities/ListEntityBase.js +109 -0
- package/src/core/entities/schemaProcesser.js +121 -0
- package/src/exporters/sheetMetalFlatPattern.js +659 -0
- package/src/exporters/sheetMetalUnfold.js +862 -0
- package/src/exporters/step.js +1135 -0
- package/src/exporters/threeMF.js +575 -0
- package/src/features/assemblyComponent/AssemblyComponentFeature.js +780 -0
- package/src/features/boolean/BooleanFeature.js +94 -0
- package/src/features/chamfer/ChamferFeature.js +116 -0
- package/src/features/datium/DatiumFeature.js +80 -0
- package/src/features/edgeFeatureUtils.js +41 -0
- package/src/features/extrude/ExtrudeFeature.js +143 -0
- package/src/features/fillet/FilletFeature.js +197 -0
- package/src/features/helix/HelixFeature.js +405 -0
- package/src/features/hole/HoleFeature.js +1050 -0
- package/src/features/hole/screwClearance.js +86 -0
- package/src/features/hole/threadDesignationCatalog.js +149 -0
- package/src/features/imageHeightSolid/ImageHeightmapSolidFeature.js +463 -0
- package/src/features/imageToFace/ImageToFaceFeature.js +727 -0
- package/src/features/imageToFace/imageEditor.js +1270 -0
- package/src/features/imageToFace/traceUtils.js +971 -0
- package/src/features/import3dModel/Import3dModelFeature.js +151 -0
- package/src/features/loft/LoftFeature.js +605 -0
- package/src/features/mirror/MirrorFeature.js +151 -0
- package/src/features/offsetFace/OffsetFaceFeature.js +370 -0
- package/src/features/offsetShell/OffsetShellFeature.js +89 -0
- package/src/features/overlapCleanup/OverlapCleanupFeature.js +85 -0
- package/src/features/pattern/PatternFeature.js +275 -0
- package/src/features/patternLinear/PatternLinearFeature.js +120 -0
- package/src/features/patternRadial/PatternRadialFeature.js +186 -0
- package/src/features/plane/PlaneFeature.js +154 -0
- package/src/features/primitiveCone/primitiveConeFeature.js +99 -0
- package/src/features/primitiveCube/primitiveCubeFeature.js +70 -0
- package/src/features/primitiveCylinder/primitiveCylinderFeature.js +91 -0
- package/src/features/primitivePyramid/primitivePyramidFeature.js +72 -0
- package/src/features/primitiveSphere/primitiveSphereFeature.js +62 -0
- package/src/features/primitiveTorus/primitiveTorusFeature.js +109 -0
- package/src/features/remesh/RemeshFeature.js +97 -0
- package/src/features/revolve/RevolveFeature.js +111 -0
- package/src/features/selectionUtils.js +118 -0
- package/src/features/sheetMetal/SheetMetalContourFlangeFeature.js +1656 -0
- package/src/features/sheetMetal/SheetMetalCutoutFeature.js +1056 -0
- package/src/features/sheetMetal/SheetMetalFlangeFeature.js +1568 -0
- package/src/features/sheetMetal/SheetMetalHemFeature.js +43 -0
- package/src/features/sheetMetal/SheetMetalObject.js +141 -0
- package/src/features/sheetMetal/SheetMetalTabFeature.js +176 -0
- package/src/features/sheetMetal/UNFOLD_NEUTRAL_REQUIREMENTS.md +153 -0
- package/src/features/sheetMetal/contour-flange-rebuild-spec.md +261 -0
- package/src/features/sheetMetal/profileUtils.js +25 -0
- package/src/features/sheetMetal/sheetMetalCleanup.js +9 -0
- package/src/features/sheetMetal/sheetMetalFaceTypes.js +146 -0
- package/src/features/sheetMetal/sheetMetalMetadata.js +165 -0
- package/src/features/sheetMetal/sheetMetalPipeline.js +169 -0
- package/src/features/sheetMetal/sheetMetalProfileUtils.js +216 -0
- package/src/features/sheetMetal/sheetMetalTabUtils.js +29 -0
- package/src/features/sheetMetal/sheetMetalTree.js +210 -0
- package/src/features/sketch/SketchFeature.js +955 -0
- package/src/features/sketch/sketchSolver2D/ConstraintEngine.js +800 -0
- package/src/features/sketch/sketchSolver2D/constraintDefinitions.js +704 -0
- package/src/features/sketch/sketchSolver2D/mathHelpersMod.js +307 -0
- package/src/features/spline/SplineEditorSession.js +988 -0
- package/src/features/spline/SplineFeature.js +1388 -0
- package/src/features/spline/splineUtils.js +218 -0
- package/src/features/sweep/SweepFeature.js +110 -0
- package/src/features/transform/TransformFeature.js +152 -0
- package/src/features/tube/TubeFeature.js +635 -0
- package/src/fs.proxy.js +625 -0
- package/src/idbStorage.js +254 -0
- package/src/index.js +12 -0
- package/src/main.js +15 -0
- package/src/metadataManager.js +64 -0
- package/src/path.proxy.js +277 -0
- package/src/plugins/ghLoader.worker.js +151 -0
- package/src/plugins/pluginManager.js +286 -0
- package/src/pmi/PMIViewsManager.js +134 -0
- package/src/services/componentLibrary.js +198 -0
- package/src/tests/ConsoleCapture.js +189 -0
- package/src/tests/S7-diagnostics-2025-12-23T18-37-23-570Z.json +630 -0
- package/src/tests/browserTests.js +597 -0
- package/src/tests/debugBoolean.js +225 -0
- package/src/tests/partFiles/badBoolean.json +957 -0
- package/src/tests/partFiles/extrudeTest.json +88 -0
- package/src/tests/partFiles/filletFail.json +58 -0
- package/src/tests/partFiles/import_TEst.part.part.json +646 -0
- package/src/tests/partFiles/sheetMetalHem.BREP.json +734 -0
- package/src/tests/test_boolean_subtract.js +27 -0
- package/src/tests/test_chamfer.js +17 -0
- package/src/tests/test_extrudeFace.js +24 -0
- package/src/tests/test_fillet.js +17 -0
- package/src/tests/test_fillet_nonClosed.js +45 -0
- package/src/tests/test_filletsMoreDifficult.js +46 -0
- package/src/tests/test_history_features_basic.js +149 -0
- package/src/tests/test_hole.js +282 -0
- package/src/tests/test_mirror.js +16 -0
- package/src/tests/test_offsetShellGrouping.js +85 -0
- package/src/tests/test_plane.js +4 -0
- package/src/tests/test_primitiveCone.js +11 -0
- package/src/tests/test_primitiveCube.js +7 -0
- package/src/tests/test_primitiveCylinder.js +8 -0
- package/src/tests/test_primitivePyramid.js +9 -0
- package/src/tests/test_primitiveSphere.js +17 -0
- package/src/tests/test_primitiveTorus.js +21 -0
- package/src/tests/test_pushFace.js +126 -0
- package/src/tests/test_sheetMetalContourFlange.js +125 -0
- package/src/tests/test_sheetMetal_features.js +80 -0
- package/src/tests/test_sketch_openLoop.js +45 -0
- package/src/tests/test_solidMetrics.js +58 -0
- package/src/tests/test_stlLoader.js +1889 -0
- package/src/tests/test_sweepFace.js +55 -0
- package/src/tests/test_tube.js +45 -0
- package/src/tests/test_tube_closedLoop.js +67 -0
- package/src/tests/tests.js +493 -0
- package/src/tools/assemblyConstraintDialogCapturePage.js +56 -0
- package/src/tools/dialogCapturePageFactory.js +227 -0
- package/src/tools/featureDialogCapturePage.js +47 -0
- package/src/tools/pmiAnnotationDialogCapturePage.js +60 -0
- package/src/utils/axisHelpers.js +99 -0
- package/src/utils/deepClone.js +69 -0
- package/src/utils/geometryTolerance.js +37 -0
- package/src/utils/normalizeTypeString.js +8 -0
- package/src/utils/xformMath.js +51 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import JSZip from 'jszip';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { FloatingWindow } from '../FloatingWindow.js';
|
|
4
|
+
import { buildSheetMetalFlatPatternSolids, buildSheetMetalFlatPatternSvgs } from '../../exporters/sheetMetalFlatPattern.js';
|
|
5
|
+
import { buildDebugLineSegments } from '../../exporters/sheetMetalUnfold.js';
|
|
6
|
+
|
|
7
|
+
const PANEL_KEY = '__flatPatternPanel';
|
|
8
|
+
|
|
9
|
+
function _collectSolids(viewer) {
|
|
10
|
+
const scene = viewer?.partHistory?.scene || viewer?.scene;
|
|
11
|
+
if (!scene) return [];
|
|
12
|
+
const solids = [];
|
|
13
|
+
scene.traverse((o) => {
|
|
14
|
+
if (!o || !o.visible) return;
|
|
15
|
+
if (o.type === 'SOLID' && typeof o.getMesh === 'function') solids.push(o);
|
|
16
|
+
});
|
|
17
|
+
const selected = solids.filter((o) => o.selected === true);
|
|
18
|
+
return selected.length ? selected : solids;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _safeName(raw, fallback = 'flat') {
|
|
22
|
+
const s = String(raw || '').trim();
|
|
23
|
+
return (s.length ? s : fallback).replace(/[^a-zA-Z0-9._-]+/g, '_').slice(0, 80);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function _download(filename, data, mime = 'application/octet-stream') {
|
|
27
|
+
const blob = new Blob([data], { type: mime });
|
|
28
|
+
const url = URL.createObjectURL(blob);
|
|
29
|
+
const a = document.createElement('a');
|
|
30
|
+
a.href = url;
|
|
31
|
+
a.download = filename;
|
|
32
|
+
document.body.appendChild(a);
|
|
33
|
+
a.click();
|
|
34
|
+
setTimeout(() => { document.body.removeChild(a); URL.revokeObjectURL(url); }, 0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _ensureStyles() {
|
|
38
|
+
if (document.getElementById('flat-pattern-styles')) return;
|
|
39
|
+
const style = document.createElement('style');
|
|
40
|
+
style.id = 'flat-pattern-styles';
|
|
41
|
+
style.textContent = `
|
|
42
|
+
.flat-pattern-content { display:flex; flex-direction:column; gap:10px; padding:10px; width:100%; height:100%; min-height:0; box-sizing:border-box; color:#e5e7eb; }
|
|
43
|
+
.flat-pattern-row { display:flex; align-items:center; gap:8px; }
|
|
44
|
+
.flat-pattern-label { min-width:70px; font-size:12px; color:#9aa0aa; }
|
|
45
|
+
.flat-pattern-select { flex:1 1 auto; padding:6px 8px; border-radius:8px; background:#0b0e14; color:#e5e7eb; border:1px solid #374151; outline:none; font-size:12px; }
|
|
46
|
+
.flat-pattern-select:focus { border-color:#3b82f6; box-shadow:0 0 0 3px rgba(59,130,246,.15); }
|
|
47
|
+
.flat-pattern-btn { background: rgba(255,255,255,.03); color: #f9fafb; border: 1px solid #374151; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12px; line-height: 1; }
|
|
48
|
+
.flat-pattern-btn:hover { border-color: #3b82f6; background: rgba(59,130,246,.12); }
|
|
49
|
+
.flat-pattern-btn:active { transform: translateY(1px); }
|
|
50
|
+
.flat-pattern-check { display:flex; align-items:center; gap:6px; font-size:12px; color:#cbd5f5; }
|
|
51
|
+
.flat-pattern-detail { flex:1 1 auto; min-height:0; font-size:12px; color:#cfd6e4; background:rgba(8,10,14,.55); border:1px solid #1f2937; border-radius:8px; padding:8px; overflow:auto; white-space:pre-wrap; line-height:1.35; }
|
|
52
|
+
.flat-pattern-empty { font-size:12px; color:#9aa0aa; }
|
|
53
|
+
`;
|
|
54
|
+
document.head.appendChild(style);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class FlatPatternPanel {
|
|
58
|
+
constructor(viewer) {
|
|
59
|
+
this.viewer = viewer;
|
|
60
|
+
this.window = null;
|
|
61
|
+
this.root = null;
|
|
62
|
+
this.content = null;
|
|
63
|
+
this.previewGroup = null;
|
|
64
|
+
this.solids = [];
|
|
65
|
+
this.activeEntry = null;
|
|
66
|
+
this.ui = {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toggle() {
|
|
70
|
+
if (this.root && this.root.style.display !== 'none') this.close();
|
|
71
|
+
else this.open();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
open() {
|
|
75
|
+
this._ensureWindow();
|
|
76
|
+
if (!this.root) return;
|
|
77
|
+
this.root.style.display = 'flex';
|
|
78
|
+
this._refreshSolids();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
close() {
|
|
82
|
+
this._clearPreview();
|
|
83
|
+
if (this.root) {
|
|
84
|
+
try { this.root.style.display = 'none'; } catch { }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_ensureWindow() {
|
|
89
|
+
if (this.window && this.root) return;
|
|
90
|
+
_ensureStyles();
|
|
91
|
+
const fw = new FloatingWindow({
|
|
92
|
+
title: 'Flat Pattern',
|
|
93
|
+
width: 420,
|
|
94
|
+
height: 360,
|
|
95
|
+
right: 14,
|
|
96
|
+
top: 80,
|
|
97
|
+
shaded: false,
|
|
98
|
+
onClose: () => this.close(),
|
|
99
|
+
});
|
|
100
|
+
const content = document.createElement('div');
|
|
101
|
+
content.className = 'flat-pattern-content';
|
|
102
|
+
fw.content.appendChild(content);
|
|
103
|
+
|
|
104
|
+
const rowSolid = document.createElement('div');
|
|
105
|
+
rowSolid.className = 'flat-pattern-row';
|
|
106
|
+
const labSolid = document.createElement('div');
|
|
107
|
+
labSolid.className = 'flat-pattern-label';
|
|
108
|
+
labSolid.textContent = 'Solid';
|
|
109
|
+
const selSolid = document.createElement('select');
|
|
110
|
+
selSolid.className = 'flat-pattern-select';
|
|
111
|
+
rowSolid.appendChild(labSolid);
|
|
112
|
+
rowSolid.appendChild(selSolid);
|
|
113
|
+
|
|
114
|
+
const rowActions = document.createElement('div');
|
|
115
|
+
rowActions.className = 'flat-pattern-row';
|
|
116
|
+
const btnGenerate = document.createElement('button');
|
|
117
|
+
btnGenerate.className = 'flat-pattern-btn';
|
|
118
|
+
btnGenerate.textContent = 'Generate';
|
|
119
|
+
const btnExport = document.createElement('button');
|
|
120
|
+
btnExport.className = 'flat-pattern-btn';
|
|
121
|
+
btnExport.textContent = 'Export SVG';
|
|
122
|
+
const btnExportAll = document.createElement('button');
|
|
123
|
+
btnExportAll.className = 'flat-pattern-btn';
|
|
124
|
+
btnExportAll.textContent = 'Export All';
|
|
125
|
+
rowActions.appendChild(btnGenerate);
|
|
126
|
+
rowActions.appendChild(btnExport);
|
|
127
|
+
rowActions.appendChild(btnExportAll);
|
|
128
|
+
|
|
129
|
+
const rowPreview = document.createElement('div');
|
|
130
|
+
rowPreview.className = 'flat-pattern-row';
|
|
131
|
+
const previewLabel = document.createElement('label');
|
|
132
|
+
previewLabel.className = 'flat-pattern-check';
|
|
133
|
+
const previewCheck = document.createElement('input');
|
|
134
|
+
previewCheck.type = 'checkbox';
|
|
135
|
+
previewLabel.appendChild(previewCheck);
|
|
136
|
+
previewLabel.appendChild(document.createTextNode('Show preview lines'));
|
|
137
|
+
rowPreview.appendChild(previewLabel);
|
|
138
|
+
|
|
139
|
+
const detail = document.createElement('div');
|
|
140
|
+
detail.className = 'flat-pattern-detail';
|
|
141
|
+
detail.textContent = 'Select a solid and click Generate.';
|
|
142
|
+
|
|
143
|
+
content.appendChild(rowSolid);
|
|
144
|
+
content.appendChild(rowActions);
|
|
145
|
+
content.appendChild(rowPreview);
|
|
146
|
+
content.appendChild(detail);
|
|
147
|
+
|
|
148
|
+
btnGenerate.addEventListener('click', () => this._generate());
|
|
149
|
+
btnExport.addEventListener('click', () => this._exportSingle());
|
|
150
|
+
btnExportAll.addEventListener('click', () => this._exportAll());
|
|
151
|
+
previewCheck.addEventListener('change', () => this._refreshPreview());
|
|
152
|
+
selSolid.addEventListener('change', () => {
|
|
153
|
+
this.activeEntry = null;
|
|
154
|
+
detail.textContent = 'Select a solid and click Generate.';
|
|
155
|
+
this._clearPreview();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
this.window = fw;
|
|
159
|
+
this.root = fw.root;
|
|
160
|
+
this.content = content;
|
|
161
|
+
this.ui = { selSolid, detail, previewCheck };
|
|
162
|
+
if (this.viewer) this.viewer[PANEL_KEY] = this;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_refreshSolids() {
|
|
166
|
+
const solids = _collectSolids(this.viewer);
|
|
167
|
+
this.solids = solids;
|
|
168
|
+
const select = this.ui.selSolid;
|
|
169
|
+
if (!select) return;
|
|
170
|
+
select.innerHTML = '';
|
|
171
|
+
solids.forEach((solid, idx) => {
|
|
172
|
+
const opt = document.createElement('option');
|
|
173
|
+
opt.value = String(idx);
|
|
174
|
+
opt.textContent = solid?.name || `SOLID_${idx + 1}`;
|
|
175
|
+
select.appendChild(opt);
|
|
176
|
+
});
|
|
177
|
+
if (!solids.length) {
|
|
178
|
+
const opt = document.createElement('option');
|
|
179
|
+
opt.value = '-1';
|
|
180
|
+
opt.textContent = 'No solids found';
|
|
181
|
+
select.appendChild(opt);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_getSelectedSolid() {
|
|
186
|
+
const idx = Number(this.ui.selSolid?.value ?? -1);
|
|
187
|
+
if (!Number.isFinite(idx) || idx < 0 || idx >= this.solids.length) return null;
|
|
188
|
+
return this.solids[idx] || null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_generate() {
|
|
192
|
+
const solid = this._getSelectedSolid();
|
|
193
|
+
if (!solid) {
|
|
194
|
+
this._setDetail('No solid selected.');
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const entries = buildSheetMetalFlatPatternSolids([solid], {});
|
|
199
|
+
const entry = Array.isArray(entries) && entries.length ? entries[0] : null;
|
|
200
|
+
if (!entry || !entry.flatPattern) {
|
|
201
|
+
this._setDetail('No flat pattern generated. Check that the solid has faceId + bend metadata.');
|
|
202
|
+
this.activeEntry = null;
|
|
203
|
+
this._clearPreview();
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this.activeEntry = entry;
|
|
208
|
+
const fp = entry.flatPattern;
|
|
209
|
+
const outlineCount = Array.isArray(fp.outlines) ? fp.outlines.length : 0;
|
|
210
|
+
const holeCount = Array.isArray(fp.holes) ? fp.holes.length : 0;
|
|
211
|
+
const bendCount = Array.isArray(fp.bendLines) ? fp.bendLines.length : 0;
|
|
212
|
+
const line1 = `Flat pattern ready for ${entry.name}.`;
|
|
213
|
+
const line2 = `Outlines: ${outlineCount}, Holes: ${holeCount}, Bends: ${bendCount}.`;
|
|
214
|
+
const warnings = Array.isArray(entry.warnings) && entry.warnings.length
|
|
215
|
+
? `Warnings:\n- ${entry.warnings.join('\n- ')}`
|
|
216
|
+
: null;
|
|
217
|
+
this._setDetail([line1, line2, warnings].filter(Boolean).join('\n'));
|
|
218
|
+
this._refreshPreview();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
_exportSingle() {
|
|
222
|
+
if (!this.activeEntry || !this.activeEntry.svg) {
|
|
223
|
+
this._setDetail('Generate a flat pattern before exporting.');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const safe = _safeName(this.activeEntry.name || 'flat');
|
|
227
|
+
_download(`${safe}_flat.svg`, this.activeEntry.svg, 'image/svg+xml');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async _exportAll() {
|
|
231
|
+
const solids = this.solids.length ? this.solids : _collectSolids(this.viewer);
|
|
232
|
+
if (!solids.length) {
|
|
233
|
+
this._setDetail('No solids available to export.');
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const entries = buildSheetMetalFlatPatternSvgs(solids, {});
|
|
237
|
+
if (!entries.length) {
|
|
238
|
+
this._setDetail('No flat pattern SVGs available.');
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const zip = new JSZip();
|
|
242
|
+
for (const entry of entries) {
|
|
243
|
+
const safe = _safeName(entry.name || 'flat');
|
|
244
|
+
zip.file(`${safe}_flat.svg`, entry.svg);
|
|
245
|
+
}
|
|
246
|
+
const blob = await zip.generateAsync({ type: 'uint8array', compression: 'DEFLATE', compressionOptions: { level: 6 } });
|
|
247
|
+
const base = _safeName(this.viewer?.fileManagerWidget?.currentName || 'flatpattern');
|
|
248
|
+
_download(`${base}_flatpattern.zip`, blob, 'application/zip');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
_refreshPreview() {
|
|
252
|
+
if (!this.ui.previewCheck?.checked || !this.activeEntry?.flatPattern) {
|
|
253
|
+
this._clearPreview();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
this._clearPreview();
|
|
257
|
+
const solid = this._getSelectedSolid();
|
|
258
|
+
if (!solid || !this.viewer?.scene) return;
|
|
259
|
+
|
|
260
|
+
const { cut, bends } = buildDebugLineSegments(this.activeEntry.flatPattern);
|
|
261
|
+
const group = new THREE.Group();
|
|
262
|
+
group.add(cut);
|
|
263
|
+
group.add(bends);
|
|
264
|
+
group.userData = { tool: 'flat-pattern-preview' };
|
|
265
|
+
|
|
266
|
+
const solidBox = new THREE.Box3().setFromObject(solid);
|
|
267
|
+
const flatBox = new THREE.Box3().setFromObject(group);
|
|
268
|
+
if (!solidBox.isEmpty() && !flatBox.isEmpty()) {
|
|
269
|
+
const size = solidBox.getSize(new THREE.Vector3());
|
|
270
|
+
const margin = Math.max(size.length() * 0.2, 1);
|
|
271
|
+
const offsetX = solidBox.max.x - flatBox.min.x + margin;
|
|
272
|
+
const offsetY = solidBox.min.y - flatBox.min.y;
|
|
273
|
+
group.position.set(offsetX, offsetY, solidBox.min.z);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
this.viewer.scene.add(group);
|
|
277
|
+
this.previewGroup = group;
|
|
278
|
+
try { this.viewer.render && this.viewer.render(); } catch { }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
_clearPreview() {
|
|
282
|
+
const group = this.previewGroup;
|
|
283
|
+
if (group && this.viewer?.scene) {
|
|
284
|
+
try { this.viewer.scene.remove(group); } catch { }
|
|
285
|
+
try {
|
|
286
|
+
group.traverse((child) => {
|
|
287
|
+
child.geometry?.dispose?.();
|
|
288
|
+
child.material?.dispose?.();
|
|
289
|
+
});
|
|
290
|
+
} catch { }
|
|
291
|
+
}
|
|
292
|
+
this.previewGroup = null;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
_setDetail(text) {
|
|
296
|
+
if (this.ui.detail) this.ui.detail.textContent = text || '';
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function createFlatPatternButton(viewer) {
|
|
301
|
+
const onClick = () => {
|
|
302
|
+
let panel = viewer?.[PANEL_KEY];
|
|
303
|
+
if (!panel) panel = new FlatPatternPanel(viewer);
|
|
304
|
+
panel.toggle();
|
|
305
|
+
};
|
|
306
|
+
return { label: '📐', title: 'Flat Pattern', onClick };
|
|
307
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import JSZip from 'jszip';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export function createImportButton(viewer) {
|
|
5
|
+
async function onClick() {
|
|
6
|
+
try {
|
|
7
|
+
const input = document.createElement('input');
|
|
8
|
+
input.type = 'file';
|
|
9
|
+
input.accept = '.3mf,model/3mf,application/vnd.ms-package.3dmanufacturing-3dmodel+xml,.json,application/json';
|
|
10
|
+
input.style.display = 'none';
|
|
11
|
+
input.addEventListener('change', async () => {
|
|
12
|
+
try {
|
|
13
|
+
const file = input.files && input.files[0];
|
|
14
|
+
try { if (input.parentNode) input.parentNode.removeChild(input); } catch {}
|
|
15
|
+
if (!file) return;
|
|
16
|
+
|
|
17
|
+
const buf = await file.arrayBuffer();
|
|
18
|
+
const u8 = new Uint8Array(buf);
|
|
19
|
+
const isZip = u8.length >= 2 && u8[0] === 0x50 && u8[1] === 0x4b; // 'PK'
|
|
20
|
+
const isJSON = String(file.name || '').toLowerCase().endsWith('.json');
|
|
21
|
+
|
|
22
|
+
if (!isZip && isJSON) {
|
|
23
|
+
// JSON path (backward compatible)
|
|
24
|
+
const text = await new Response(buf).text();
|
|
25
|
+
let payload = text;
|
|
26
|
+
try {
|
|
27
|
+
const obj = JSON.parse(text);
|
|
28
|
+
if (obj && typeof obj === 'object') {
|
|
29
|
+
// Normalize sketch arrays if present
|
|
30
|
+
const ensureArray = (v) => (Array.isArray(v) ? v : (v == null ? [] : [v]));
|
|
31
|
+
const normalizeSketch = (sk) => {
|
|
32
|
+
if (!sk || typeof sk !== 'object') return sk;
|
|
33
|
+
sk.points = ensureArray(sk.points);
|
|
34
|
+
sk.geometries = ensureArray(sk.geometries);
|
|
35
|
+
sk.constraints = ensureArray(sk.constraints);
|
|
36
|
+
if (Array.isArray(sk.geometries)) {
|
|
37
|
+
for (const g of sk.geometries) {
|
|
38
|
+
if (!g) continue;
|
|
39
|
+
g.points = Array.isArray(g?.points) ? g.points : (g?.points != null ? [g.points] : []);
|
|
40
|
+
if (Array.isArray(g.points)) g.points = g.points.map((x) => Number(x));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(sk.constraints)) {
|
|
44
|
+
for (const c of sk.constraints) {
|
|
45
|
+
if (!c) continue;
|
|
46
|
+
c.points = Array.isArray(c?.points) ? c.points : (c?.points != null ? [c.points] : []);
|
|
47
|
+
if (Array.isArray(c.points)) c.points = c.points.map((x) => Number(x));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return sk;
|
|
51
|
+
};
|
|
52
|
+
if (Array.isArray(obj.features)) {
|
|
53
|
+
for (const f of obj.features) {
|
|
54
|
+
if (f?.persistentData?.sketch) f.persistentData.sketch = normalizeSketch(f.persistentData.sketch);
|
|
55
|
+
}
|
|
56
|
+
} else if (obj.data && Array.isArray(obj.data.features)) {
|
|
57
|
+
for (const f of obj.data.features) {
|
|
58
|
+
if (f?.persistentData?.sketch) f.persistentData.sketch = normalizeSketch(f.persistentData.sketch);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Re-stringify payload
|
|
62
|
+
if (Array.isArray(obj.features)) payload = JSON.stringify(obj);
|
|
63
|
+
else if (obj.data) payload = (typeof obj.data === 'string') ? obj.data : JSON.stringify(obj.data);
|
|
64
|
+
}
|
|
65
|
+
} catch {}
|
|
66
|
+
await viewer?.partHistory?.reset?.();
|
|
67
|
+
await viewer?.partHistory?.fromJSON?.(payload);
|
|
68
|
+
// Sync Expressions UI with imported code
|
|
69
|
+
try { if (viewer?.expressionsManager?.textArea) viewer.expressionsManager.textArea.value = viewer.partHistory.expressions || ''; } catch {}
|
|
70
|
+
await viewer?.partHistory?.runHistory?.();
|
|
71
|
+
try { viewer?.zoomToFit?.(1.1); } catch {}
|
|
72
|
+
try { _updateCurrentNameFromFile(viewer, file); } catch {}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (isZip) {
|
|
77
|
+
// 3MF path → check for embedded feature history first
|
|
78
|
+
const zip = await JSZip.loadAsync(buf);
|
|
79
|
+
// Build lower-case path map
|
|
80
|
+
const files = {};
|
|
81
|
+
Object.keys(zip.files || {}).forEach(p => files[p.toLowerCase()] = p);
|
|
82
|
+
let fhKey = files['metadata/featurehistory.json'];
|
|
83
|
+
if (!fhKey) {
|
|
84
|
+
// search any *featurehistory.json
|
|
85
|
+
for (const k of Object.keys(files)) { if (k.endsWith('featurehistory.json')) { fhKey = files[k]; break; } }
|
|
86
|
+
}
|
|
87
|
+
if (fhKey) {
|
|
88
|
+
const jsonData = await zip.file(fhKey).async('string');
|
|
89
|
+
let root = null;
|
|
90
|
+
try { root = JSON.parse(jsonData); } catch {}
|
|
91
|
+
// Ensure expressions is a string if present
|
|
92
|
+
if (root && root.expressions != null && typeof root.expressions !== 'string') {
|
|
93
|
+
try { root.expressions = String(root.expressions); } catch { root.expressions = String(root.expressions); }
|
|
94
|
+
}
|
|
95
|
+
if (root) {
|
|
96
|
+
await viewer?.partHistory?.reset?.();
|
|
97
|
+
await viewer?.partHistory?.fromJSON?.(JSON.stringify(root));
|
|
98
|
+
// Sync Expressions UI with imported code
|
|
99
|
+
try { if (viewer?.expressionsManager?.textArea) viewer.expressionsManager.textArea.value = viewer.partHistory.expressions || ''; } catch {}
|
|
100
|
+
|
|
101
|
+
// Refresh PMI views UI if it exists
|
|
102
|
+
try {
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
try {
|
|
105
|
+
if (viewer?.pmiViewsWidget) {
|
|
106
|
+
viewer.pmiViewsWidget.refreshFromHistory?.();
|
|
107
|
+
viewer.pmiViewsWidget._renderList?.();
|
|
108
|
+
}
|
|
109
|
+
} catch { }
|
|
110
|
+
}, 100);
|
|
111
|
+
} catch { }
|
|
112
|
+
|
|
113
|
+
await viewer?.partHistory?.runHistory?.();
|
|
114
|
+
try { viewer?.zoomToFit?.(1.1); } catch {}
|
|
115
|
+
try { _updateCurrentNameFromFile(viewer, file); } catch {}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// No feature history → create a new Import 3D Model feature with the raw 3MF
|
|
121
|
+
await viewer?.partHistory?.reset?.();
|
|
122
|
+
const feat = await viewer?.partHistory?.newFeature?.('IMPORT3D');
|
|
123
|
+
if (feat) {
|
|
124
|
+
feat.inputParams.fileToImport = buf; // Import3dModelFeature can auto-detect 3MF zip
|
|
125
|
+
feat.inputParams.deflectionAngle = 15;
|
|
126
|
+
feat.inputParams.centerMesh = true;
|
|
127
|
+
}
|
|
128
|
+
await viewer?.partHistory?.runHistory?.();
|
|
129
|
+
try { viewer?.zoomToFit?.(1.1); } catch {}
|
|
130
|
+
try { _updateCurrentNameFromFile(viewer, file); } catch {}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
alert('Unsupported file format. Please select a 3MF or JSON file.');
|
|
135
|
+
} catch (e) {
|
|
136
|
+
alert('Import failed. See console for details.');
|
|
137
|
+
console.error(e);
|
|
138
|
+
}
|
|
139
|
+
}, { once: true });
|
|
140
|
+
document.body.appendChild(input);
|
|
141
|
+
input.click();
|
|
142
|
+
} catch (e) {
|
|
143
|
+
alert('Unable to open file dialog.');
|
|
144
|
+
console.error(e);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return { label: '📥', title: 'Import… (3MF/JSON)', onClick };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function _updateCurrentNameFromFile(viewer, file) {
|
|
152
|
+
const fm = viewer?.fileManagerWidget;
|
|
153
|
+
if (!fm) return;
|
|
154
|
+
const name = String(file?.name || '').replace(/\.[^.]+$/, '');
|
|
155
|
+
if (!name) return;
|
|
156
|
+
fm.currentName = name;
|
|
157
|
+
if (fm.nameInput) fm.nameInput.value = name;
|
|
158
|
+
fm.refreshList && fm.refreshList();
|
|
159
|
+
fm._saveLastName && fm._saveLastName(name);
|
|
160
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function createInspectorToggleButton(viewer) {
|
|
2
|
+
const onClick = () => {
|
|
3
|
+
try {
|
|
4
|
+
viewer && viewer.toggleInspectorPanel && viewer.toggleInspectorPanel();
|
|
5
|
+
} catch {}
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
label: '🕵️',
|
|
9
|
+
title: 'Toggle Inspector panel',
|
|
10
|
+
onClick
|
|
11
|
+
};
|
|
12
|
+
}
|