-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// 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<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAlgoAPI_Pipe.h"
#include <GeomAPI_Dir.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <BRep_Tool.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
if(!getPath(aPathWire, thePathShape)) {
return;
}
+ GeomShapePtr anOldPath(new GeomAPI_Shape), aNewPath(new GeomAPI_Shape);
+ anOldPath->setImpl(new TopoDS_Shape(aPathWire));
aPathWire.Move(getPathToBaseTranslation(aBaseShape, aPathWire));
+ aNewPath->setImpl(new TopoDS_Shape(aPathWire));
+ if (!anOldPath->isSame(aNewPath))
+ addMovedPath(anOldPath, aNewPath);
// Making pipe.
BRepOffsetAPI_MakePipe* aPipeBuilder = new BRepOffsetAPI_MakePipe(aPathWire, aBaseShape);
const GeomShapePtr thePathShape,
const GeomShapePtr theBiNormal)
{
- // Getting base shape.
+ // Getting base shape and path.
TopoDS_Shape aBaseShape;
TopAbs_ShapeEnum aBaseShapeType;
- if(!getBase(aBaseShape, aBaseShapeType, theBaseShape)) {
- return;
- }
-
- // Getting path.
TopoDS_Wire aPathWire;
- if(!getPath(aPathWire, thePathShape)) {
+ if (!getBase(aBaseShape, aBaseShapeType, theBaseShape) ||
+ !getPath(aPathWire, thePathShape) ||
+ !theBiNormal.get()) {
return;
}
+ GeomShapePtr anOldPath(new GeomAPI_Shape), aNewPath(new GeomAPI_Shape);
+ anOldPath->setImpl(new TopoDS_Shape(aPathWire));
aPathWire.Move(getPathToBaseTranslation(theBaseShape->impl<TopoDS_Shape>(), aPathWire));
+ aNewPath->setImpl(new TopoDS_Shape(aPathWire));
+ if (!anOldPath->isSame(aNewPath))
+ addMovedPath(anOldPath, aNewPath);
// Getting Bi-Normal.
- if(!theBiNormal.get()) {
- return;
- }
TopoDS_Shape aBiNormalShape = theBiNormal->impl<TopoDS_Shape>();
if(aBiNormalShape.IsNull() || aBiNormalShape.ShapeType() != TopAbs_EDGE) {
return;
this->initialize(aPipeBuilder);
// Checking result.
- if(aBaseShapeType == TopAbs_FACE) {
- if(aPipeBuilder->MakeSolid() == Standard_False) {
- return;
- }
+ if(aBaseShapeType == TopAbs_FACE && !aPipeBuilder->MakeSolid()) {
+ return;
}
TopoDS_Shape aResult = aPipeBuilder->Shape();
if(aResult.IsNull()) {
return;
}
- // Getting path.
+ // Getting base shape and path.
TopoDS_Shape aBaseShape;
TopAbs_ShapeEnum aBaseShapeType;
- if (!getBase(aBaseShape, aBaseShapeType, theBaseShapes.front())) {
- return;
- }
-
TopoDS_Wire aPathWire;
- if(!getPath(aPathWire, thePathShape)) {
+ if (!getBase(aBaseShape, aBaseShapeType, theBaseShapes.front()) ||
+ !getPath(aPathWire, thePathShape)) {
return;
}
TopoDS_Shape aReallyBase = theBaseShapes.front()->impl<TopoDS_Shape>();
gp_Trsf aTrsf = getPathToBaseTranslation(aReallyBase, aPathWire);
+
+ GeomShapePtr anOldPath(new GeomAPI_Shape), aNewPath(new GeomAPI_Shape);
+ anOldPath->setImpl(new TopoDS_Shape(aPathWire));
aPathWire.Move(aTrsf);
+ aNewPath->setImpl(new TopoDS_Shape(aPathWire));
+ if (!anOldPath->isSame(aNewPath))
+ addMovedPath(anOldPath, aNewPath);
// Get locations after moving path shape.
std::list<TopoDS_Vertex> aLocations;
this->initialize(aPipeBuilder);
// Checking result.
- if(anIsSolidNeeded) {
- if(aPipeBuilder->MakeSolid() == Standard_False) {
- return;
- }
+ if(anIsSolidNeeded && !aPipeBuilder->MakeSolid()) {
+ return;
}
TopoDS_Shape aResult = aPipeBuilder->Shape();
void GeomAlgoAPI_Pipe::generated(const GeomShapePtr theShape,
ListOfShape& theHistory)
{
- GeomAlgoAPI_MakeShape::generated(theShape, theHistory);
+ if (myMovedPath.isBound(theShape))
+ GeomAlgoAPI_MakeShape::generated(myMovedPath.find(theShape), theHistory);
+ else
+ GeomAlgoAPI_MakeShape::generated(theShape, theHistory);
}
// Auxilary functions:
return aList;
}
+
+//==================================================================================================
+void GeomAlgoAPI_Pipe::addMovedPath(GeomShapePtr thePath, GeomShapePtr theMoved)
+{
+ myMovedPath.clear();
+ GeomAPI_ShapeExplorer anOldExp(thePath, GeomAPI_Shape::EDGE);
+ GeomAPI_ShapeExplorer aNewExp(theMoved, GeomAPI_Shape::EDGE);
+ for(; anOldExp.more(); anOldExp.next(), aNewExp.next()) {
+ myMovedPath.bind(anOldExp.current(), aNewExp.current());
+ }
+}