From bba9c3762b215b5621f3922c40adf1159f624eb0 Mon Sep 17 00:00:00 2001 From: mbs Date: Fri, 2 Dec 2022 09:33:51 +0000 Subject: [PATCH] support legacy code when building a shell --- src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp | 38 +++++++++++++++++++++++--- src/GeomAlgoAPI/GeomAlgoAPI_Sewing.h | 3 ++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp index 18236bd52..cde818449 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp @@ -29,11 +29,13 @@ //================================================================================================== GeomAlgoAPI_Sewing::GeomAlgoAPI_Sewing(const ListOfShape& theShapes) { + myBuildShell = true; build(theShapes); } GeomAlgoAPI_Sewing::GeomAlgoAPI_Sewing(const ListOfShape& theShapes, const bool theAllowNonManifold, const double theTolerance) { + myBuildShell = false; build(theShapes, theAllowNonManifold, theTolerance); } @@ -46,10 +48,13 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes, const bool theAllow BRepBuilderAPI_Sewing* aSewingBuilder = new BRepBuilderAPI_Sewing(); this->setImpl(aSewingBuilder); - aSewingBuilder->SetTolerance(theTolerance); - aSewingBuilder->SetFaceMode(Standard_True); - aSewingBuilder->SetFloatingEdgesMode(Standard_False); - aSewingBuilder->SetNonManifoldMode(theAllowNonManifold); + if (!myBuildShell) + { + aSewingBuilder->SetTolerance(theTolerance); + aSewingBuilder->SetFaceMode(Standard_True); + aSewingBuilder->SetFloatingEdgesMode(Standard_False); + aSewingBuilder->SetNonManifoldMode(theAllowNonManifold); + } for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) { const TopoDS_Shape& aShape = (*anIt)->impl(); @@ -59,6 +64,31 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes, const bool theAllow aSewingBuilder->Perform(); TopoDS_Shape aResult = aSewingBuilder->SewedShape(); + if (myBuildShell) + { + BRep_Builder aBuilder; + if(aResult.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Compound aResultCompound; + aBuilder.MakeCompound(aResultCompound); + for(TopoDS_Iterator anIt(aResult); anIt.More(); anIt.Next()) { + const TopoDS_Shape aSubShape = anIt.Value(); + if(aSubShape.ShapeType() == TopAbs_SHELL) { + aBuilder.Add(aResultCompound, aSubShape); + } else if (aSubShape.ShapeType() == TopAbs_FACE) { + TopoDS_Shell aShell; + aBuilder.MakeShell(aShell); + aBuilder.Add(aShell, aSubShape); + aBuilder.Add(aResultCompound, aShell); + } + } + aResult = aResultCompound; + } else if(aResult.ShapeType() == TopAbs_FACE) { + TopoDS_Shell aShell; + aBuilder.MakeShell(aShell); + aBuilder.Add(aShell, aResult); + aResult = aShell; + } + } std::shared_ptr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aResult)); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.h b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.h index 811b6e449..416ac84f2 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.h @@ -44,6 +44,9 @@ public: GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, ListOfShape& theHistory); +protected: + bool myBuildShell; + private: /// Builds resulting shape. void build(const ListOfShape& theShapes, const bool theAllowNonManifold = false, const double theTolerance = 1.e-6); -- 2.39.2