TestScale2.py
Test1816.py
Test1876.py
+ Test2225.py
Test2631.py
Test2636.py
Test2650.py
break;
}
- storeResult(aBaseShape, aPipeAlgo, aResultIndex++);
+ storeResult(aBaseShape, aPathShape, aPipeAlgo, aResultIndex++);
}
} else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) {
std::shared_ptr<GeomAlgoAPI_Pipe> aPipeAlgo(new GeomAlgoAPI_Pipe(aBaseShapesList,
return;
}
- storeResult(aBaseShapesList, aPipeAlgo, aResultIndex++);
+ storeResult(aBaseShapesList, aPathShape, aPipeAlgo, aResultIndex++);
} else {
setError("Error: Wrong creation method.");
return;
//==================================================================================================
void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Shape> thePathShape,
const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex)
{
aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE);
}
+ if (thePathShape.get())
+ aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE);
// Store from shapes.
storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->fromShapes(), "From_");
//==================================================================================================
void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes,
+ const std::shared_ptr<GeomAPI_Shape> thePathShape,
const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex)
{
aResultBody->loadGeneratedShapes(thePipeAlgo, aBaseShape, aShapeTypeToExplode);
}
+ if (thePathShape.get())
+ aResultBody->loadGeneratedShapes(thePipeAlgo, thePathShape, GeomAPI_Shape::EDGE);
+
// Store from shapes.
storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_");
private:
void storeResult(const std::shared_ptr<GeomAPI_Shape> theBaseShape,
+ const std::shared_ptr<GeomAPI_Shape> thePathShape,
const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex = 0);
void storeResult(const ListOfShape& theBaseShapes,
+ const std::shared_ptr<GeomAPI_Shape> thePathShape,
const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
const int theResultIndex = 0);
--- /dev/null
+# 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
+# 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
+#
+
+# -*- coding: utf-8 -*-
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(-55.80357142857143, 252.2321428571429, -250, 252.2321428571429)
+SketchLine_2 = Sketch_1.addLine(-250, 252.2321428571429, -250, 4.464285714285698)
+SketchLine_3 = Sketch_1.addLine(-250, 4.464285714285698, -55.80357142857143, 4.464285714285698)
+SketchLine_4 = Sketch_1.addLine(-55.80357142857143, 4.464285714285698, -55.80357142857143, 252.2321428571429)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+model.do()
+Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_1")]
+Face_1 = model.addFace(Part_1_doc, Face_1_objects)
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_5 = Sketch_2.addLine(-247.7678571428571, 71.42857142857137, -160.7142857142857, 167.4107142857142)
+SketchLine_6 = Sketch_2.addLine(-160.7142857142857, 167.4107142857142, -276.7857142857143, 267.8571428571428)
+SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchLine_7 = Sketch_2.addLine(-276.7857142857143, 267.8571428571428, -154.0178571428571, 350.4464285714285)
+SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchLine_8 = Sketch_2.addLine(-154.0178571428571, 350.4464285714285, -294.6428571428572, 428.5714285714284)
+SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+model.do()
+Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_6"), model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/SketchLine_8")]
+Wire_1 = model.addWire(Part_1_doc, Wire_1_objects)
+Pipe_1 = model.addPipe(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("WIRE", "Wire_1_1"))
+model.do()
+model.testHaveNamingSubshapes(Pipe_1, model, Part_1_doc)
+model.end()
+
+assert(model.checkPythonDump())
#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);
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.
TopoDS_Shape aBiNormalShape = theBiNormal->impl<TopoDS_Shape>();
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;
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());
+ }
+}
/// Face -> Solid
class GeomAlgoAPI_Pipe : public GeomAlgoAPI_MakeSweep
{
+ GeomAPI_DataMapOfShapeShape myMovedPath; ///< map from initial path edges to the moved
public:
/// \brief Creates extrusion for the given shape along a path.
/// \param[in] theBaseShape base shape(vertex, edge, wire of face).
void build(const ListOfShape& theBaseShapes,
const ListOfShape& theLocations,
const GeomShapePtr thePathShape);
+ /// keeps the information about the moved path shapes into myMovedPath field
+ void addMovedPath(GeomShapePtr thePath, GeomShapePtr theMoved);
};
#endif