X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Sewing.cpp;h=7c1768f8094c88f7ce625d457008b0405eb962bf;hb=4c86b629d1bf8daa737f90b64e934c7bd22f6525;hp=b30d1dd60dff6c9a82730b1f1f6534ecffac00d3;hpb=a94fc319f2aa64b43c9a73b5ff7063923648faec;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp index b30d1dd60..7c1768f80 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "GeomAlgoAPI_Sewing.h" @@ -30,10 +29,17 @@ //================================================================================================== GeomAlgoAPI_Sewing::GeomAlgoAPI_Sewing(const ListOfShape& theShapes) { + myBuildShell = true; build(theShapes); } -void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes) +GeomAlgoAPI_Sewing::GeomAlgoAPI_Sewing(const ListOfShape& theShapes, const bool theAllowNonManifold, const double theTolerance) +{ + myBuildShell = false; + build(theShapes, theAllowNonManifold, theTolerance); +} + +void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes, const bool theAllowNonManifold, const double theTolerance) { if(theShapes.empty()) { return; @@ -42,6 +48,14 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes) BRepBuilderAPI_Sewing* aSewingBuilder = new BRepBuilderAPI_Sewing(); this->setImpl(aSewingBuilder); + 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(); aSewingBuilder->Add(aShape); @@ -50,27 +64,30 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes) aSewingBuilder->Perform(); TopoDS_Shape aResult = aSewingBuilder->SewedShape(); - 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); + 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; } - 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()); @@ -80,10 +97,11 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes) } //================================================================================================== +#include + void GeomAlgoAPI_Sewing::modified(const std::shared_ptr theShape, ListOfShape& theHistory) { - static int anIndex = 0; if(!theShape.get()) { return; } @@ -101,4 +119,21 @@ void GeomAlgoAPI_Sewing::modified(const std::shared_ptr theShape, aGeomShape->setImpl(new TopoDS_Shape(anExp.Current())); theHistory.push_back(aGeomShape); } + + if (theShape->shapeType() < GeomAPI_Shape::FACE) { + ListOfShape aNewShapes; + // collect faces and parent shapes, if it is not done yet + if (!isNewShapesCollected(theShape, GeomAPI_Shape::FACE)) + collectNewShapes(theShape, GeomAPI_Shape::FACE); + + for (GeomAPI_ShapeIterator anIt(shape()); anIt.more(); anIt.next()) { + GeomShapePtr anOldShapesCompound = + oldShapesForNew(theShape, anIt.current(), GeomAPI_Shape::FACE); + if (!anOldShapesCompound->isNull()) + aNewShapes.push_back(anIt.current()); + } + + if (!aNewShapes.empty()) + theHistory = aNewShapes; + } }