@bldrs-ai/conway 0.18.886 → 0.18.902

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.
Files changed (33) hide show
  1. package/compiled/examples/browser-bundled.js +4 -4
  2. package/compiled/examples/validator-bundled.js +4 -4
  3. package/compiled/src/core/entity_description.d.ts +1 -1
  4. package/compiled/src/core/i_local_id_set.d.ts +27 -0
  5. package/compiled/src/core/i_local_id_set.d.ts.map +1 -0
  6. package/compiled/src/core/i_local_id_set.js +1 -0
  7. package/compiled/src/ifc/ifc_command_line_main.js +17 -3
  8. package/compiled/src/ifc/ifc_geometry_extraction.d.ts +15 -5
  9. package/compiled/src/ifc/ifc_geometry_extraction.d.ts.map +1 -1
  10. package/compiled/src/ifc/ifc_geometry_extraction.js +240 -228
  11. package/compiled/src/indexing/dynamic_single_index_set.d.ts +2 -1
  12. package/compiled/src/indexing/dynamic_single_index_set.d.ts.map +1 -1
  13. package/compiled/src/indexing/multi_index_set.d.ts +2 -2
  14. package/compiled/src/indexing/multi_index_set.d.ts.map +1 -1
  15. package/compiled/src/indexing/multi_index_set.js +3 -3
  16. package/compiled/src/indexing/multi_index_set_cursor_or.d.ts.map +1 -1
  17. package/compiled/src/indexing/search_operations.d.ts.map +1 -1
  18. package/compiled/src/indexing/single_index_set.d.ts +10 -3
  19. package/compiled/src/indexing/single_index_set.d.ts.map +1 -1
  20. package/compiled/src/indexing/single_index_set.js +19 -4
  21. package/compiled/src/indexing/single_index_set.test.js +12 -0
  22. package/compiled/src/loaders/conway_model_loader.d.ts +3 -1
  23. package/compiled/src/loaders/conway_model_loader.d.ts.map +1 -1
  24. package/compiled/src/loaders/conway_model_loader.js +4 -2
  25. package/compiled/src/rendering/threejs/scene_object.d.ts +19 -0
  26. package/compiled/src/rendering/threejs/scene_object.d.ts.map +1 -1
  27. package/compiled/src/rendering/threejs/scene_object.js +64 -10
  28. package/compiled/src/rendering/threejs/simple_viewer_scene.d.ts +34 -0
  29. package/compiled/src/rendering/threejs/simple_viewer_scene.d.ts.map +1 -1
  30. package/compiled/src/rendering/threejs/simple_viewer_scene.js +38 -6
  31. package/compiled/src/version/version.js +1 -1
  32. package/compiled/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +4 -2
@@ -110,19 +110,25 @@ export class IfcGeometryExtraction {
110
110
  /**
111
111
  * Construct a geometry extraction from an IFC step model and conway model
112
112
  *
113
- * @param conwayModel
114
- * @param model
115
- * @param lowMemoryMode
113
+ * @param conwayModel The ConwayGeometry instance to use for geometry operations.
114
+ * @param model The IfcStepModel instance representing the IFC model.
115
+ * @param limitCSGDepth Whether to limit the depth of CSG operations.
116
+ * @param csgDepthLimit The maximum depth for CSG operations when limit CSG depth is used,
117
+ * or the maximum level for CSG memoization if it is not.
118
+ * @param lowMemoryMode Whether to enable low memory mode for geometry extraction.
116
119
  */
117
- constructor(conwayModel, model, lowMemoryMode = false) {
120
+ constructor(conwayModel, model, limitCSGDepth = true, csgDepthLimit = 20, lowMemoryMode = false) {
118
121
  this.conwayModel = conwayModel;
119
122
  this.model = model;
123
+ this.limitCSGDepth = limitCSGDepth;
124
+ this.csgDepthLimit = csgDepthLimit;
120
125
  this.lowMemoryMode = lowMemoryMode;
121
126
  this.TWO_DIMENSIONS = 2;
122
127
  this.THREE_DIMENSIONS = 3;
123
128
  this.circleSegments = 12;
124
129
  this.pointBuffer = null;
125
130
  this.csgMemoization = true;
131
+ this.csgDepth = 0;
126
132
  this.freeVectorPolygonalFaces_ = [];
127
133
  this.csgMemoization = !this.lowMemoryMode;
128
134
  this.materials = model.materials;
@@ -700,6 +706,28 @@ export class IfcGeometryExtraction {
700
706
  this.model.geometry.delete(localID);
701
707
  }
702
708
  }
709
+ getOperandGeometry(from, isSecondOperand, isRelVoid = false) {
710
+ if (from instanceof IfcExtrudedAreaSolid ||
711
+ from instanceof IfcPolygonalFaceSet ||
712
+ from instanceof IfcBooleanClippingResult ||
713
+ from instanceof IfcBooleanResult ||
714
+ from instanceof IfcPolygonalBoundedHalfSpace ||
715
+ from instanceof IfcHalfSpaceSolid ||
716
+ from instanceof IfcFacetedBrep) {
717
+ this.extractBooleanOperand(from, isRelVoid, undefined, isSecondOperand);
718
+ }
719
+ let geometry;
720
+ if (isRelVoid) {
721
+ return this.model.voidGeometry.getByLocalID(from.localID);
722
+ }
723
+ return this.model.geometry.getByLocalID(from.localID);
724
+ }
725
+ getFirstBoolenOperandGeometry(from, isRelVoid = false) {
726
+ return this.getOperandGeometry(from.FirstOperand, false, isRelVoid);
727
+ }
728
+ getSecondBoolenOperandGeometry(from, isRelVoid = false) {
729
+ return this.getOperandGeometry(from.SecondOperand, true, isRelVoid);
730
+ }
703
731
  /**
704
732
  * Accepts IfcBooleanResult and IfcBooleanClippingResult
705
733
  *
@@ -713,139 +741,109 @@ export class IfcGeometryExtraction {
713
741
  return;
714
742
  }
715
743
  }
716
- this.csgOperations.add(from.localID, {
717
- type: CsgOperationType.DIFFERENCE,
718
- operand1ID: from.FirstOperand.localID,
719
- operand2ID: from.SecondOperand.localID,
720
- }, true);
721
- if (from.FirstOperand instanceof IfcExtrudedAreaSolid ||
722
- from.FirstOperand instanceof IfcPolygonalFaceSet ||
723
- from.FirstOperand instanceof IfcBooleanClippingResult ||
724
- from.FirstOperand instanceof IfcBooleanResult ||
725
- from.FirstOperand instanceof IfcPolygonalBoundedHalfSpace ||
726
- from.FirstOperand instanceof IfcHalfSpaceSolid ||
727
- from.FirstOperand instanceof IfcFacetedBrep) {
728
- this.extractBooleanOperand(from.FirstOperand, isRelVoid, from, isRelVoid);
729
- }
730
- if (from.SecondOperand instanceof IfcExtrudedAreaSolid ||
731
- from.SecondOperand instanceof IfcPolygonalFaceSet ||
732
- from.SecondOperand instanceof IfcBooleanClippingResult ||
733
- from.SecondOperand instanceof IfcBooleanResult ||
734
- from.SecondOperand instanceof IfcPolygonalBoundedHalfSpace ||
735
- from.SecondOperand instanceof IfcHalfSpaceSolid ||
736
- from.SecondOperand instanceof IfcFacetedBrep) {
737
- this.extractBooleanOperand(from.SecondOperand, isRelVoid, undefined, true);
738
- }
739
- // get geometry TODO(nickcastel50): eventually support flattening meshes
740
- let flatFirstMeshVector; // = this.nativeVectorGeometry()
741
- let firstMesh;
742
- const flatFirstMeshVectorFromParts = false;
743
- if (isRelVoid) {
744
- firstMesh = this.model.voidGeometry.getByLocalID(from.FirstOperand.localID);
745
- }
746
- else {
747
- firstMesh = this.model.geometry.getByLocalID(from.FirstOperand.localID);
748
- }
749
- if (firstMesh !== void 0 && firstMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
750
- /* const _testEntity = this.model.getElementByLocalID(firstMesh.localID)!
751
- const outputFilePath_ =
752
- `${_testEntity.expressID}_${EntityTypesIfc[_testEntity.type]}FIRST_MESH.obj`
753
-
754
- this.dumpGeometry(outputFilePath_, firstMesh.geometry) */
755
- // const geometryParts = firstMesh.geometry.getParts()
756
- // if (geometryParts.size() > 0) {
757
- // /* for (let geometryPartIndex = 0;
758
- // geometryPartIndex < geometryParts.size(); ++geometryPartIndex) {
759
- // flatFirstMeshVector.push_back(geometryParts.get(geometryPartIndex))
760
- // }*/
761
- // flatFirstMeshVector = geometryParts
762
- // flatFirstMeshVectorFromParts = true
763
- // } else {
764
- flatFirstMeshVector = this.nativeVectorGeometry();
765
- flatFirstMeshVector.push_back(firstMesh.geometry);
766
- // }
767
- }
768
- else {
769
- Logger.error(`Error extracting firstOperand geometry for expressID:
770
- ${from.FirstOperand.expressID} - type:
771
- ${EntityTypesIfc[from.FirstOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
772
- return;
773
- }
774
- let flatSecondMeshVector; // = this.nativeVectorGeometry()
775
- const flatSecondMeshVectorFromParts = false;
776
- let secondMesh;
777
- if (isRelVoid) {
778
- secondMesh = this.model.voidGeometry.getByLocalID(from.SecondOperand.localID);
779
- }
780
- else {
781
- secondMesh = this.model.geometry.getByLocalID(from.SecondOperand.localID);
782
- }
783
- if (secondMesh !== void 0 && secondMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
784
- flatSecondMeshVector = this.nativeVectorGeometry();
785
- flatSecondMeshVector.push_back(secondMesh.geometry);
786
- }
787
- else {
788
- Logger.error(`Error extracting secondOperand geometry for expressID:
789
- ${from.SecondOperand.localID} - type:
790
- ${EntityTypesIfc[from.SecondOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
791
- return;
792
- }
793
- const parameters = this.paramsGetBooleanResultPool.acquire();
794
- parameters.flatFirstMesh = flatFirstMeshVector;
795
- parameters.flatSecondMesh = flatSecondMeshVector;
796
- parameters.operatorType = from.Operator.valueOf();
797
- parameters.isSubtractOperand = isRelVoid;
798
- const booleanGeometryObject = this.conwayModel.getBooleanResult(parameters);
799
- // const outputFilePath =
800
- // `${from.expressID}_${EntityTypesIfc[from.type]}_post_subtract_test.obj`
801
- // this.dumpGeometry(outputFilePath, booleanGeometryObject)
802
- if (firstMesh.type === CanonicalMeshType.BUFFER_GEOMETRY &&
803
- secondMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
804
- const canonicalMesh = {
805
- type: CanonicalMeshType.BUFFER_GEOMETRY,
806
- geometry: booleanGeometryObject,
807
- localID: from.localID,
808
- model: this.model,
809
- temporary: false,
810
- };
811
- const styledItemLocalID_ = this.materials.styledItemMap.get(from.localID);
812
- if (styledItemLocalID_ !== undefined) {
813
- const styledItem_ = this.model.getElementByLocalID(styledItemLocalID_);
814
- this.extractStyledItem(styledItem_);
744
+ ++this.csgDepth;
745
+ try {
746
+ this.csgOperations.add(from.localID, {
747
+ type: CsgOperationType.DIFFERENCE,
748
+ operand1ID: from.FirstOperand.localID,
749
+ operand2ID: from.SecondOperand.localID,
750
+ }, true);
751
+ // get geometry TODO(nickcastel50): eventually support flattening meshes
752
+ let flatFirstMeshVector; // = this.nativeVectorGeometry()
753
+ const firstMesh = this.getFirstBoolenOperandGeometry(from, isRelVoid);
754
+ if (firstMesh !== void 0 && firstMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
755
+ /* const _testEntity = this.model.getElementByLocalID(firstMesh.localID)!
756
+ const outputFilePath_ =
757
+ `${_testEntity.expressID}_${EntityTypesIfc[_testEntity.type]}FIRST_MESH.obj`
758
+
759
+ this.dumpGeometry(outputFilePath_, firstMesh.geometry) */
760
+ // const geometryParts = firstMesh.geometry.getParts()
761
+ // if (geometryParts.size() > 0) {
762
+ // /* for (let geometryPartIndex = 0;
763
+ // geometryPartIndex < geometryParts.size(); ++geometryPartIndex) {
764
+ // flatFirstMeshVector.push_back(geometryParts.get(geometryPartIndex))
765
+ // }*/
766
+ // flatFirstMeshVector = geometryParts
767
+ // flatFirstMeshVectorFromParts = true
768
+ // } else {
769
+ flatFirstMeshVector = this.nativeVectorGeometry();
770
+ flatFirstMeshVector.push_back(firstMesh.geometry);
771
+ // }
815
772
  }
816
773
  else {
817
- // get material from first operand
818
- const firstOperandStyledItemLocalID_ = this.materials.styledItemMap.get(from.FirstOperand.localID);
819
- if (firstOperandStyledItemLocalID_ !== undefined) {
820
- const firstOperandStyledItem = this.model.getElementByLocalID(firstOperandStyledItemLocalID_);
821
- this.extractStyledItem(firstOperandStyledItem, from);
822
- }
774
+ Logger.error(`Error extracting firstOperand geometry for expressID:
775
+ ${from.FirstOperand.expressID} - type:
776
+ ${EntityTypesIfc[from.FirstOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
777
+ return;
823
778
  }
824
- // add mesh to the list of mesh objects
825
- if (!isRelVoid) {
826
- if (!this.csgMemoization &&
827
- RegressionCaptureState.memoization !== MemoizationCapture.FULL) {
828
- this.dropNonSceneGeometry(firstMesh.localID);
829
- this.dropNonSceneGeometry(secondMesh.localID);
830
- }
831
- this.model.geometry.add(canonicalMesh);
779
+ let flatSecondMeshVector; // = this.nativeVectorGeometry()
780
+ const secondMesh = this.getSecondBoolenOperandGeometry(from, isRelVoid);
781
+ if (secondMesh !== void 0 && secondMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
782
+ flatSecondMeshVector = this.nativeVectorGeometry();
783
+ flatSecondMeshVector.push_back(secondMesh.geometry);
832
784
  }
833
785
  else {
834
- if (!this.csgMemoization &&
835
- RegressionCaptureState.memoization !== MemoizationCapture.FULL) {
836
- this.model.voidGeometry.delete(firstMesh.localID);
837
- this.model.voidGeometry.delete(secondMesh.localID);
786
+ Logger.error(`Error extracting secondOperand geometry for expressID:
787
+ ${from.SecondOperand.localID} - type:
788
+ ${EntityTypesIfc[from.SecondOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
789
+ return;
790
+ }
791
+ const parameters = this.paramsGetBooleanResultPool.acquire();
792
+ parameters.flatFirstMesh = flatFirstMeshVector;
793
+ parameters.flatSecondMesh = flatSecondMeshVector;
794
+ parameters.operatorType = from.Operator.valueOf();
795
+ parameters.isSubtractOperand = isRelVoid;
796
+ const booleanGeometryObject = this.conwayModel.getBooleanResult(parameters);
797
+ // const outputFilePath =
798
+ // `${from.expressID}_${EntityTypesIfc[from.type]}_post_subtract_test.obj`
799
+ // this.dumpGeometry(outputFilePath, booleanGeometryObject)
800
+ if (firstMesh.type === CanonicalMeshType.BUFFER_GEOMETRY &&
801
+ secondMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
802
+ const canonicalMesh = {
803
+ type: CanonicalMeshType.BUFFER_GEOMETRY,
804
+ geometry: booleanGeometryObject,
805
+ localID: from.localID,
806
+ model: this.model,
807
+ temporary: false,
808
+ };
809
+ const styledItemLocalID_ = this.materials.styledItemMap.get(from.localID);
810
+ if (styledItemLocalID_ !== undefined) {
811
+ const styledItem_ = this.model.getElementByLocalID(styledItemLocalID_);
812
+ this.extractStyledItem(styledItem_);
813
+ }
814
+ else {
815
+ // get material from first operand
816
+ const firstOperandStyledItemLocalID_ = this.materials.styledItemMap.get(from.FirstOperand.localID);
817
+ if (firstOperandStyledItemLocalID_ !== undefined) {
818
+ const firstOperandStyledItem = this.model.getElementByLocalID(firstOperandStyledItemLocalID_);
819
+ this.extractStyledItem(firstOperandStyledItem, from);
820
+ }
821
+ }
822
+ // add mesh to the list of mesh objects
823
+ if (!isRelVoid) {
824
+ if ((!this.csgMemoization &&
825
+ RegressionCaptureState.memoization !== MemoizationCapture.FULL)) {
826
+ this.dropNonSceneGeometry(firstMesh.localID);
827
+ this.dropNonSceneGeometry(secondMesh.localID);
828
+ }
829
+ this.model.geometry.add(canonicalMesh);
830
+ }
831
+ else {
832
+ if (!this.csgMemoization &&
833
+ RegressionCaptureState.memoization !== MemoizationCapture.FULL) {
834
+ this.model.voidGeometry.delete(firstMesh.localID);
835
+ this.model.voidGeometry.delete(secondMesh.localID);
836
+ }
837
+ this.model.voidGeometry.add(canonicalMesh);
838
838
  }
839
- this.model.voidGeometry.add(canonicalMesh);
840
839
  }
841
- }
842
- if (!flatFirstMeshVectorFromParts) {
843
840
  flatFirstMeshVector.delete();
844
- }
845
- if (!flatSecondMeshVectorFromParts) {
846
841
  flatSecondMeshVector.delete();
842
+ this.paramsGetBooleanResultPool.release(parameters);
843
+ }
844
+ finally {
845
+ --this.csgDepth;
847
846
  }
848
- this.paramsGetBooleanResultPool.release(parameters);
849
847
  }
850
848
  /**
851
849
  * Extract a boolean operand from a boolean result.
@@ -887,113 +885,127 @@ export class IfcGeometryExtraction {
887
885
  this.extractIfcFacetedBrep(from, true, isRelVoid);
888
886
  }
889
887
  else if (from instanceof IfcBooleanResult) {
890
- if (from.FirstOperand instanceof IfcExtrudedAreaSolid ||
891
- from.FirstOperand instanceof IfcPolygonalFaceSet ||
892
- from.FirstOperand instanceof IfcBooleanClippingResult ||
893
- from.FirstOperand instanceof IfcBooleanResult ||
894
- from.FirstOperand instanceof IfcPolygonalBoundedHalfSpace ||
895
- from.FirstOperand instanceof IfcHalfSpaceSolid ||
896
- from.FirstOperand instanceof IfcFacetedBrep) {
897
- this.extractBooleanOperand(from.FirstOperand, isRelVoid, representationItem, isSecondOperand);
898
- }
899
- if (from.SecondOperand instanceof IfcExtrudedAreaSolid ||
900
- from.SecondOperand instanceof IfcPolygonalFaceSet ||
901
- from.SecondOperand instanceof IfcBooleanClippingResult ||
902
- from.SecondOperand instanceof IfcBooleanResult ||
903
- from.SecondOperand instanceof IfcPolygonalBoundedHalfSpace ||
904
- from.SecondOperand instanceof IfcHalfSpaceSolid ||
905
- from.SecondOperand instanceof IfcFacetedBrep) {
906
- this.extractBooleanOperand(from.SecondOperand, isRelVoid, void 0, true);
907
- }
908
- // get geometry TODO(nickcastel50): eventually support flattening meshes
909
- let flatFirstMeshVector; // = this.nativeVectorGeometry()
910
- const flatFirstMeshVectorFromParts = false;
911
- let firstMesh;
912
- if (isRelVoid) {
913
- firstMesh = this.model.voidGeometry.getByLocalID(from.FirstOperand.localID);
914
- }
915
- else {
916
- firstMesh = this.model.geometry.getByLocalID(from.FirstOperand.localID);
917
- }
918
- if (firstMesh !== void 0 && firstMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
919
- flatFirstMeshVector = this.nativeVectorGeometry();
920
- flatFirstMeshVector.push_back(firstMesh.geometry);
921
- }
922
- else {
923
- Logger.error(`(Operand) Error extracting firstOperand geometry for expressID:
924
- ${from.FirstOperand.expressID} - type:
925
- ${EntityTypesIfc[from.FirstOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
926
- return;
927
- }
928
- let flatSecondMeshVector; // = this.nativeVectorGeometry()
929
- const flatSecondMeshVectorFromParts = false;
930
- let secondMesh;
931
- if (isRelVoid) {
932
- secondMesh = this.model.voidGeometry.getByLocalID(from.SecondOperand.localID);
933
- }
934
- else {
935
- secondMesh = this.model.geometry.getByLocalID(from.SecondOperand.localID);
936
- }
937
- if (secondMesh !== void 0 && secondMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
938
- flatSecondMeshVector = this.nativeVectorGeometry();
939
- flatSecondMeshVector.push_back(secondMesh.geometry);
940
- }
941
- else {
942
- Logger.error(`(Operand) Error extracting secondOperand geometry for expressID:
943
- ${from.SecondOperand.expressID} - type:
944
- ${EntityTypesIfc[from.SecondOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
945
- return;
946
- }
947
- const parameters = this.paramsGetBooleanResultPool.acquire();
948
- parameters.flatFirstMesh = flatFirstMeshVector;
949
- parameters.flatSecondMesh = flatSecondMeshVector;
950
- parameters.operatorType = from.Operator.valueOf();
951
- parameters.isSubtractOperand = isSecondOperand;
952
- const booleanGeometryObject = this.conwayModel.getBooleanResult(parameters);
953
- const canonicalMesh = {
954
- type: CanonicalMeshType.BUFFER_GEOMETRY,
955
- geometry: booleanGeometryObject,
956
- localID: from.localID,
957
- model: this.model,
958
- temporary: true,
959
- };
960
- const styledItemLocalID_ = this.materials.styledItemMap.get(from.localID);
961
- if (styledItemLocalID_ !== undefined) {
962
- const styledItem_ = this.model.getElementByLocalID(styledItemLocalID_);
963
- this.extractStyledItem(styledItem_);
964
- }
965
- else {
966
- // get material from first operand
967
- const firstOperandStyledItemLocalID_ = this.materials.styledItemMap.get(from.FirstOperand.localID);
968
- if (firstOperandStyledItemLocalID_ !== undefined) {
969
- const firstOperandStyledItem = this.model.getElementByLocalID(firstOperandStyledItemLocalID_);
970
- this.extractStyledItem(firstOperandStyledItem, representationItem);
888
+ ++this.csgDepth;
889
+ try {
890
+ const maximumCsgMemoizationDepth = this.csgDepthLimit;
891
+ const firstMesh = this.getFirstBoolenOperandGeometry(from, isRelVoid);
892
+ if (this.limitCSGDepth && this.csgDepth >= maximumCsgMemoizationDepth) {
893
+ if (firstMesh === void 0) {
894
+ return;
895
+ }
896
+ const canonicalMesh = {
897
+ type: CanonicalMeshType.BUFFER_GEOMETRY,
898
+ geometry: firstMesh.geometry.clone(),
899
+ localID: from.localID,
900
+ model: this.model,
901
+ temporary: true,
902
+ };
903
+ if (!isRelVoid) {
904
+ if ((!this.csgMemoization &&
905
+ RegressionCaptureState.memoization !== MemoizationCapture.FULL) ||
906
+ this.csgDepth > maximumCsgMemoizationDepth) {
907
+ this.dropNonSceneGeometry(firstMesh.localID);
908
+ }
909
+ this.model.geometry.add(canonicalMesh);
910
+ }
911
+ else {
912
+ if ((!this.csgMemoization &&
913
+ RegressionCaptureState.memoization !== MemoizationCapture.FULL) ||
914
+ this.csgDepth > maximumCsgMemoizationDepth) {
915
+ this.model.voidGeometry.delete(firstMesh.localID);
916
+ }
917
+ this.model.voidGeometry.add(canonicalMesh);
918
+ }
919
+ const styledItemLocalID_ = this.materials.styledItemMap.get(from.localID);
920
+ if (styledItemLocalID_ !== undefined) {
921
+ const styledItem_ = this.model.getElementByLocalID(styledItemLocalID_);
922
+ this.extractStyledItem(styledItem_);
923
+ }
924
+ else {
925
+ // get material from first operand
926
+ const firstOperandStyledItemLocalID_ = this.materials.styledItemMap.get(from.FirstOperand.localID);
927
+ if (firstOperandStyledItemLocalID_ !== undefined) {
928
+ const firstOperandStyledItem = this.model.getElementByLocalID(firstOperandStyledItemLocalID_);
929
+ this.extractStyledItem(firstOperandStyledItem, representationItem);
930
+ }
931
+ }
932
+ return;
971
933
  }
972
- }
973
- // add mesh to the list of mesh objects
974
- if (!isRelVoid) {
975
- if (!this.csgMemoization &&
976
- RegressionCaptureState.memoization !== MemoizationCapture.FULL) {
977
- this.dropNonSceneGeometry(firstMesh.localID);
978
- this.dropNonSceneGeometry(secondMesh.localID);
934
+ let flatFirstMeshVector; // = this.nativeVectorGeometry()
935
+ if (firstMesh !== void 0 && firstMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
936
+ flatFirstMeshVector = this.nativeVectorGeometry();
937
+ flatFirstMeshVector.push_back(firstMesh.geometry);
979
938
  }
980
- this.model.geometry.add(canonicalMesh);
981
- }
982
- else {
983
- if (!this.csgMemoization &&
984
- RegressionCaptureState.memoization !== MemoizationCapture.FULL) {
985
- this.model.voidGeometry.delete(firstMesh.localID);
986
- this.model.voidGeometry.delete(secondMesh.localID);
939
+ else {
940
+ Logger.error(`(Operand) Error extracting firstOperand geometry for expressID:
941
+ ${from.FirstOperand.expressID} - type:
942
+ ${EntityTypesIfc[from.FirstOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
943
+ return;
944
+ }
945
+ let flatSecondMeshVector;
946
+ const secondMesh = this.getSecondBoolenOperandGeometry(from, isRelVoid);
947
+ if (secondMesh !== void 0 && secondMesh.type === CanonicalMeshType.BUFFER_GEOMETRY) {
948
+ flatSecondMeshVector = this.nativeVectorGeometry();
949
+ flatSecondMeshVector.push_back(secondMesh.geometry);
950
+ }
951
+ else {
952
+ Logger.error(`(Operand) Error extracting secondOperand geometry for expressID:
953
+ ${from.SecondOperand.expressID} - type:
954
+ ${EntityTypesIfc[from.SecondOperand.type]} - isRelVoid: ${isRelVoid ? "True" : "False"}`);
955
+ return;
956
+ }
957
+ const parameters = this.paramsGetBooleanResultPool.acquire();
958
+ parameters.flatFirstMesh = flatFirstMeshVector;
959
+ parameters.flatSecondMesh = flatSecondMeshVector;
960
+ parameters.operatorType = from.Operator.valueOf();
961
+ parameters.isSubtractOperand = isSecondOperand;
962
+ const booleanGeometryObject = this.conwayModel.getBooleanResult(parameters);
963
+ const canonicalMesh = {
964
+ type: CanonicalMeshType.BUFFER_GEOMETRY,
965
+ geometry: booleanGeometryObject,
966
+ localID: from.localID,
967
+ model: this.model,
968
+ temporary: true,
969
+ };
970
+ const styledItemLocalID_ = this.materials.styledItemMap.get(from.localID);
971
+ if (styledItemLocalID_ !== undefined) {
972
+ const styledItem_ = this.model.getElementByLocalID(styledItemLocalID_);
973
+ this.extractStyledItem(styledItem_);
974
+ }
975
+ else {
976
+ // get material from first operand
977
+ const firstOperandStyledItemLocalID_ = this.materials.styledItemMap.get(from.FirstOperand.localID);
978
+ if (firstOperandStyledItemLocalID_ !== undefined) {
979
+ const firstOperandStyledItem = this.model.getElementByLocalID(firstOperandStyledItemLocalID_);
980
+ this.extractStyledItem(firstOperandStyledItem, representationItem);
981
+ }
982
+ }
983
+ // add mesh to the list of mesh objects
984
+ if (!isRelVoid) {
985
+ if ((!this.csgMemoization &&
986
+ RegressionCaptureState.memoization !== MemoizationCapture.FULL) ||
987
+ this.csgDepth > maximumCsgMemoizationDepth) {
988
+ this.dropNonSceneGeometry(firstMesh.localID);
989
+ this.dropNonSceneGeometry(secondMesh.localID);
990
+ }
991
+ this.model.geometry.add(canonicalMesh);
992
+ }
993
+ else {
994
+ if ((!this.csgMemoization &&
995
+ RegressionCaptureState.memoization !== MemoizationCapture.FULL) ||
996
+ this.csgDepth > maximumCsgMemoizationDepth) {
997
+ this.model.voidGeometry.delete(firstMesh.localID);
998
+ this.model.voidGeometry.delete(secondMesh.localID);
999
+ }
1000
+ this.model.voidGeometry.add(canonicalMesh);
987
1001
  }
988
- this.model.voidGeometry.add(canonicalMesh);
989
- }
990
- if (!flatFirstMeshVectorFromParts) {
991
1002
  flatFirstMeshVector.delete();
992
- }
993
- if (!flatSecondMeshVectorFromParts) {
994
1003
  flatSecondMeshVector.delete();
1004
+ this.paramsGetBooleanResultPool.release(parameters);
1005
+ }
1006
+ finally {
1007
+ --this.csgDepth;
995
1008
  }
996
- this.paramsGetBooleanResultPool.release(parameters);
997
1009
  }
998
1010
  }
999
1011
  /* eslint-disable no-magic-numbers */ // No magic numbers disabled
@@ -1,6 +1,7 @@
1
1
  import { IIndexSetCursor } from "../core/i_index_set_cursor.js";
2
2
  import { DynamicSingleIndexSetCursor } from "./dynamic_single_index_set_cursor.js";
3
3
  import { SingleIndexSet } from "./single_index_set.js";
4
+ import { ILocalIDSetWithCursor } from "../core/i_local_id_set.js";
4
5
  /**
5
6
  * As deep as the stack of nodes for this can ever be.
6
7
  */
@@ -9,7 +10,7 @@ export declare const ELEMENT_SIZE = 2;
9
10
  /**
10
11
  * A single set of indices
11
12
  */
12
- export default class DynamicSingleIndexSet {
13
+ export default class DynamicSingleIndexSet implements ILocalIDSetWithCursor {
13
14
  private stack_;
14
15
  private populated_;
15
16
  private size_;
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic_single_index_set.d.ts","sourceRoot":"","sources":["../../../src/indexing/dynamic_single_index_set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAG/E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMnD;;GAEG;AACH,eAAO,MAAM,cAAc,KAAU,CAAA;AACrC,eAAO,MAAM,YAAY,IAAW,CAAA;AAIpC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAqB;IAExC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAY;IAEzB;;;;;;OAMG;gBACU,IAAI,CAAC,EAAE,cAAc,GAAG,eAAe;IAoCpD;;;;;OAKG;IACI,MAAM,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IA8HzC;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;OAKG;IACI,MAAM,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IA8BzC;;;;;OAKG;IACI,GAAG,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IA2BtC;;;;OAIG;IACI,MAAM,IAAI,2BAA2B;CAO7C"}
1
+ {"version":3,"file":"dynamic_single_index_set.d.ts","sourceRoot":"","sources":["../../../src/indexing/dynamic_single_index_set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAG/E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAM9D;;GAEG;AACH,eAAO,MAAM,cAAc,KAAU,CAAA;AACrC,eAAO,MAAM,YAAY,IAAW,CAAA;AAIpC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,qBAAqB;IAEzE,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAY;IAEzB;;;;;;OAMG;gBACU,IAAI,CAAC,EAAE,cAAc,GAAG,eAAe;IAoCpD;;;;;OAKG;IACI,MAAM,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IA8HzC;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;OAKG;IACI,MAAM,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IA8BzC;;;;;OAKG;IACI,GAAG,CAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IA2BtC;;;;OAIG;IACI,MAAM,IAAI,2BAA2B;CAO7C"}
@@ -27,10 +27,10 @@ export declare class MultiIndexSet<IndexType extends number> {
27
27
  * Does the set have a particular index for a particular type.
28
28
  *
29
29
  * @param indexType The index type to check for.
30
- * @param denseIndex The dense index in the set to check.
30
+ * @param localID The dense index in the set to check.
31
31
  * @return {boolean} True if it has the type.
32
32
  */
33
- has(indexType: IndexType, denseIndex: number): boolean;
33
+ has(indexType: IndexType, localID: number): boolean;
34
34
  /**
35
35
  * Get a cursor that lets you iterate over the union of the sets of multiple indices.
36
36
  *
@@ -1 +1 @@
1
- {"version":3,"file":"multi_index_set.d.ts","sourceRoot":"","sources":["../../../src/indexing/multi_index_set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAK5D;;GAEG;AACH,qBAAa,aAAa,CAAE,SAAS,SAAS,MAAM;IAchD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B;;;;;;;;;;OAUG;gBAEgB,eAAe,EAAE,WAAW,EAC5B,SAAS,EAAE,WAAW;IAGzC;;;;OAIG;IACK,KAAK,IAAK,gBAAgB,CAAE,SAAS,CAAE;IAgB/C;;;;;;OAMG;IACI,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAI,OAAO;IAc/D;;;;;OAKG;IACI,MAAM,CAAE,GAAG,UAAU,EAAE,SAAS,EAAE,GAAI,eAAe;CAsB7D"}
1
+ {"version":3,"file":"multi_index_set.d.ts","sourceRoot":"","sources":["../../../src/indexing/multi_index_set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAK5D;;GAEG;AACH,qBAAa,aAAa,CAAE,SAAS,SAAS,MAAM;IAchD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAb5B;;;;;;;;;;OAUG;gBAEgB,eAAe,EAAE,WAAW,EAC5B,SAAS,EAAE,WAAW;IAGzC;;;;OAIG;IACK,KAAK,IAAK,gBAAgB,CAAE,SAAS,CAAE;IAgB/C;;;;;;OAMG;IACI,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAI,OAAO;IAc5D;;;;;OAKG;IACI,MAAM,CAAE,GAAG,UAAU,EAAE,SAAS,EAAE,GAAI,eAAe;CAsB7D"}
@@ -37,17 +37,17 @@ export class MultiIndexSet {
37
37
  * Does the set have a particular index for a particular type.
38
38
  *
39
39
  * @param indexType The index type to check for.
40
- * @param denseIndex The dense index in the set to check.
40
+ * @param localID The dense index in the set to check.
41
41
  * @return {boolean} True if it has the type.
42
42
  */
43
- has(indexType, denseIndex) {
43
+ has(indexType, localID) {
44
44
  if (indexType >= this.prefixSumTable_.length - 1) {
45
45
  return false;
46
46
  }
47
47
  const prefixSum = this.prefixSumTable_;
48
48
  const indexOffset = prefixSum[indexType] * 2;
49
49
  const indexEnd = prefixSum[indexType + 1] * 2;
50
- return indexSetPointQuery32(denseIndex, this.elements_, indexOffset, indexEnd);
50
+ return indexSetPointQuery32(localID, this.elements_, indexOffset, indexEnd);
51
51
  }
52
52
  /**
53
53
  * Get a cursor that lets you iterate over the union of the sets of multiple indices.
@@ -1 +1 @@
1
- {"version":3,"file":"multi_index_set_cursor_or.d.ts","sourceRoot":"","sources":["../../../src/indexing/multi_index_set_cursor_or.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAO5D;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,IAAI,CAAY;IAExB;;OAEG;IACH,OAAO;IAIP;;;;;OAKG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;OAKG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED;;;;;OAKG;IACI,IAAI,IAAI,OAAO;IAqDtB;;;;;OAKG;WACW,QAAQ,CAAE,MAAM,EAAE,WAAW,GAAI,qBAAqB;IAepE;;;;;OAKG;IACI,QAAQ,CAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAI,IAAI;IAsBjD;;OAEG;IACI,IAAI,IAAI,IAAI;CAIpB"}
1
+ {"version":3,"file":"multi_index_set_cursor_or.d.ts","sourceRoot":"","sources":["../../../src/indexing/multi_index_set_cursor_or.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAQ5D;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,OAAO,CAAC,CAAa;IAC7B,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,IAAI,CAAY;IAExB;;OAEG;IACH,OAAO;IAIP;;;;;OAKG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;;OAKG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAGD;;;;;OAKG;IACI,IAAI,IAAI,OAAO;IAmDtB;;;;;OAKG;WACW,QAAQ,CAAE,MAAM,EAAE,WAAW,GAAI,qBAAqB;IAepE;;;;;OAKG;IACI,QAAQ,CAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAI,IAAI;IAsBjD;;OAEG;IACI,IAAI,IAAI,IAAI;CAIpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"search_operations.d.ts","sourceRoot":"","sources":["../../../src/indexing/search_operations.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,EAEnB,MAAM,GAAE,MAAU,EAClB,GAAG,CAAC,EAAE,MAAM,GAAI,MAAM,CAkBzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,MAAU,EAClB,GAAG,CAAC,EAAE,MAAM,GAAI,OAAO,CAQ1B"}
1
+ {"version":3,"file":"search_operations.d.ts","sourceRoot":"","sources":["../../../src/indexing/search_operations.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,MAAU,EAClB,GAAG,CAAC,EAAE,MAAM,GAAI,MAAM,CAkBzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,WAAW,EACnB,MAAM,GAAE,MAAU,EAClB,GAAG,CAAC,EAAE,MAAM,GAAI,OAAO,CAQ1B"}
@@ -1,9 +1,10 @@
1
1
  import { IIndexSetCursor } from "../core/i_index_set_cursor.js";
2
+ import { ILocalIDSetWithCursor } from "../core/i_local_id_set.js";
2
3
  import { ReadonlyUint32Array } from "../core/readonly_typed_array.js";
3
4
  /**
4
5
  * A single set of indices
5
6
  */
6
- export declare class SingleIndexSet {
7
+ export declare class SingleIndexSet implements ILocalIDSetWithCursor {
7
8
  private readonly start_;
8
9
  private readonly end_;
9
10
  private readonly elements_;
@@ -19,6 +20,12 @@ export declare class SingleIndexSet {
19
20
  * unioned-one-hot representation).
20
21
  */
21
22
  constructor(start_: number, end_: number, elements_: Uint32Array);
23
+ /**
24
+ * The size of the set.
25
+ *
26
+ * @return {number} The size of the set.
27
+ */
28
+ get size(): number;
22
29
  /**
23
30
  * Get the buffer elements from this (treat as immutable)
24
31
  *
@@ -28,10 +35,10 @@ export declare class SingleIndexSet {
28
35
  /**
29
36
  * Does the set have a particular index for a particular type.
30
37
  *
31
- * @param denseIndex The dense index in the set to check.
38
+ * @param localID The dense index in the set to check.
32
39
  * @return {boolean} True if it has the type.
33
40
  */
34
- has(denseIndex: number): boolean;
41
+ has(localID: number): boolean;
35
42
  /**
36
43
  * Get a cursor that lets you iterate over the items in this set.
37
44
  *