From: mpv Date: Wed, 6 Mar 2019 12:33:07 +0000 (+0300) Subject: Fix for the issue #2225 : Incorrect face naming when creating a pipe from a face... X-Git-Tag: V9_3_0a2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aca54238175d75c25fa9b12ade0e274765a1cabd;p=modules%2Fshaper.git Fix for the issue #2225 : Incorrect face naming when creating a pipe from a face. Usage of OCCT 7.3.0p3 fix. --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 907daf153..d1b4bfbea 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -441,6 +441,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestScale2.py Test1816.py Test1876.py + Test2225.py Test2631.py Test2636.py Test2650.py diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index cd6c8781f..c3a387887 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -238,7 +238,7 @@ void FeaturesPlugin_Pipe::execute() break; } - storeResult(aBaseShape, aPipeAlgo, aResultIndex++); + storeResult(aBaseShape, aPathShape, aPipeAlgo, aResultIndex++); } } else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) { std::shared_ptr aPipeAlgo(new GeomAlgoAPI_Pipe(aBaseShapesList, @@ -251,7 +251,7 @@ void FeaturesPlugin_Pipe::execute() return; } - storeResult(aBaseShapesList, aPipeAlgo, aResultIndex++); + storeResult(aBaseShapesList, aPathShape, aPipeAlgo, aResultIndex++); } else { setError("Error: Wrong creation method."); return; @@ -262,6 +262,7 @@ void FeaturesPlugin_Pipe::execute() //================================================================================================== void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBaseShape, + const std::shared_ptr thePathShape, const std::shared_ptr thePipeAlgo, const int theResultIndex) { @@ -312,6 +313,8 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa 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_"); @@ -324,6 +327,7 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa //================================================================================================== void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, + const std::shared_ptr thePathShape, const std::shared_ptr thePipeAlgo, const int theResultIndex) { @@ -365,6 +369,9 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, 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_"); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.h b/src/FeaturesPlugin/FeaturesPlugin_Pipe.h index 08ccb1e8e..078ae9f3c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.h @@ -120,10 +120,12 @@ public: private: void storeResult(const std::shared_ptr theBaseShape, + const std::shared_ptr thePathShape, const std::shared_ptr thePipeAlgo, const int theResultIndex = 0); void storeResult(const ListOfShape& theBaseShapes, + const std::shared_ptr thePathShape, const std::shared_ptr thePipeAlgo, const int theResultIndex = 0); diff --git a/src/FeaturesPlugin/Test/Test2225.py b/src/FeaturesPlugin/Test/Test2225.py new file mode 100644 index 000000000..aad529a11 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2225.py @@ -0,0 +1,60 @@ +# 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()) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp index b0a693ceb..067a249bd 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,12 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape, 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); @@ -140,7 +146,12 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape, return; } + GeomShapePtr anOldPath(new GeomAPI_Shape), aNewPath(new GeomAPI_Shape); + anOldPath->setImpl(new TopoDS_Shape(aPathWire)); aPathWire.Move(getPathToBaseTranslation(theBaseShape->impl(), aPathWire)); + aNewPath->setImpl(new TopoDS_Shape(aPathWire)); + if (!anOldPath->isSame(aNewPath)) + addMovedPath(anOldPath, aNewPath); // Getting Bi-Normal. TopoDS_Shape aBiNormalShape = theBiNormal->impl(); @@ -211,7 +222,13 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes, TopoDS_Shape aReallyBase = theBaseShapes.front()->impl(); 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 aLocations; @@ -329,7 +346,10 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes, 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: @@ -440,3 +460,14 @@ ListOfShape getListFromShape(const TopoDS_Shape& theShape) 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()); + } +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.h b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.h index bc97bef65..879927886 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.h @@ -36,6 +36,7 @@ /// 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). @@ -78,6 +79,8 @@ private: 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