-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: GeomAlgoAPI_Sewing.cpp
-// Created: 25 April 2016
-// Author: Dmitry Bobylev
-
+// Copyright (C) 2014-2023 CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include "GeomAlgoAPI_Sewing.h"
//==================================================================================================
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;
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<TopoDS_Shape>();
aSewingBuilder->Add(aShape);
aSewingBuilder->Perform();
TopoDS_Shape aResult = aSewingBuilder->SewedShape();
- BRep_Builder aBuilder;
- 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) {
+ 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, aSubShape);
- aBuilder.Add(aResultCompound, aShell);
+ aBuilder.Add(aShell, aResult);
+ aResult = aShell;
}
}
- TopoDS_Iterator anIt(aResultCompound);
- if(anIt.More()) {
- aResult = aResultCompound;
- }
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aResult));
}
//==================================================================================================
+#include <GeomAPI_ShapeIterator.h>
+
void GeomAlgoAPI_Sewing::modified(const std::shared_ptr<GeomAPI_Shape> theShape,
ListOfShape& theHistory)
{
- static int anIndex = 0;
if(!theShape.get()) {
return;
}
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;
+ }
}