diff --git a/packages/base/src/3dview/mainview.tsx b/packages/base/src/3dview/mainview.tsx index 3588f6e2..013a810d 100644 --- a/packages/base/src/3dview/mainview.tsx +++ b/packages/base/src/3dview/mainview.tsx @@ -583,6 +583,7 @@ export class MainView extends React.Component { this._meshGroup = new THREE.Group(); + console.log(payload); Object.entries(payload).forEach(([objName, data]) => { const selected = selectedNames.includes(objName); const output = buildShape({ @@ -737,6 +738,7 @@ export class MainView extends React.Component { this.setState(old => ({ ...old, loading: false })); } } + private async _requestRender( sender: MainViewModel, renderData: { @@ -790,6 +792,7 @@ export class MainView extends React.Component { }); } } + private _updatePointers(refLength): void { this._pointerGeometry = new THREE.SphereGeometry(refLength / 10, 32, 32); diff --git a/packages/occ-worker/src/occparser.ts b/packages/occ-worker/src/occparser.ts index 8e571ed7..0b1a3422 100644 --- a/packages/occ-worker/src/occparser.ts +++ b/packages/occ-worker/src/occparser.ts @@ -51,6 +51,7 @@ export class OccParser { jcObject, faceList, edgeList: [...edgeList, ...wireList], + isSolid: this._isSolid(occShape), meta: metadata }; }); @@ -58,6 +59,48 @@ export class OccParser { return threejsData; } + private _isSolid(shape: OCC.TopoDS_Shape) { + console.log('try checking is solid'); + if ( + shape.ShapeType() == this._occ.TopAbs_ShapeEnum.TopAbs_SOLID || + shape.ShapeType() == this._occ.TopAbs_ShapeEnum.TopAbs_SHELL + ) { + console.log('1'); + try { + const classifier = new this._occ.BRepClass3d_SolidClassifier(); + console.log('2'); + classifier.Load(shape); + + console.log('3'); + // Define a point (doesn't need to be specific, as we only care if it's closed) + const point = new this._occ.gp_Pnt(); + console.log('4'); + classifier.Perform(point, 0); + + console.log('5'); + // Check if the point is inside, on the boundary, or outside the solid + if ( + classifier.State() == this._occ.TopAbs_State.TopAbs_IN || + classifier.State() == this._occ.TopAbs_State.TopAbs_ON + ) { + console.log('6'); + return true; // The solid is closed + } + } catch (e) { + if (typeof e === 'number') { + const exceptionData = this._occ.OCJS.getStandard_FailureData(e); + console.log( + `That didn't work because: ${exceptionData.GetMessageString()}` + ); + } else { + console.log('Unkown error'); + } + } + } + console.log('61'); + return false; + } + private _shouldComputeEdge(obj: IJCadObject): boolean { if (obj.shape === 'Part::Any' && obj.parameters?.Type === 'STL') { return false; diff --git a/packages/opencascade/build.yml b/packages/opencascade/build.yml index 12675082..a3aa86b5 100644 --- a/packages/opencascade/build.yml +++ b/packages/opencascade/build.yml @@ -21,6 +21,8 @@ mainBuild: - symbol: BRepBuilderAPI_MakeVertex - symbol: BRepBuilderAPI_MakeWire - symbol: BRepBuilderAPI_ModifyShape + - symbol: BRepClass3d_SClassifier + - symbol: BRepClass3d_SolidClassifier - symbol: BRepFilletAPI_LocalOperation - symbol: BRepFilletAPI_MakeChamfer - symbol: BRepFilletAPI_MakeFillet @@ -69,12 +71,14 @@ mainBuild: - symbol: Message_ProgressRange - symbol: NCollection_BaseList - symbol: NCollection_BaseMap + - symbol: OCJS - symbol: Poly_Array1OfTriangle - symbol: Poly_Connect - symbol: Poly_PolygonOnTriangulation - symbol: Poly_Triangle - symbol: Poly_Triangulation - symbol: RWStl + - symbol: Standard_Failure - symbol: Standard_Transient - symbol: StdPrs_ToolTriangulatedShape - symbol: STEPControl_Reader @@ -83,6 +87,7 @@ mainBuild: - symbol: TColStd_Array1OfInteger - symbol: TopAbs_Orientation - symbol: TopAbs_ShapeEnum + - symbol: TopAbs_State - symbol: TopExp - symbol: TopExp_Explorer - symbol: TopLoc_Location @@ -103,9 +108,7 @@ mainBuild: - symbol: XSControl_Reader emccFlags: - "-flto" - - "-fexceptions" - "-O3" - - "-sDISABLE_EXCEPTION_CATCHING=1" - "-sEXPORT_ES6=1" - "-sUSE_ES6_IMPORT_META=0" - "-sEXPORTED_RUNTIME_METHODS=['FS']" @@ -115,3 +118,10 @@ mainBuild: - "-sLLD_REPORT_UNDEFINED" - "--no-entry" - "-sENVIRONMENT='web'" +additionalCppCode: | + class OCJS { + public: + static Standard_Failure* getStandard_FailureData(intptr_t exceptionPtr) { + return reinterpret_cast(exceptionPtr); + } + }; diff --git a/packages/schema/src/interfaces.ts b/packages/schema/src/interfaces.ts index e7a417c3..5de253eb 100644 --- a/packages/schema/src/interfaces.ts +++ b/packages/schema/src/interfaces.ts @@ -209,6 +209,7 @@ export interface IParsedShape { jcObject: IJCadObject; faceList: Array; edgeList: Array; + isSolid: boolean; meta?: IDict; guiData?: IDict; }