]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #2225 : Incorrect face naming when creating a pipe from a face...
authormpv <mpv@opencascade.com>
Wed, 6 Mar 2019 12:33:07 +0000 (15:33 +0300)
committermpv <mpv@opencascade.com>
Wed, 6 Mar 2019 12:33:07 +0000 (15:33 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp
src/FeaturesPlugin/FeaturesPlugin_Pipe.h
src/FeaturesPlugin/Test/Test2225.py [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.h

index 907daf15375632cca10e7b0389796f4b6ccf8133..d1b4bfbeadba11bb08d17041aad1814fa9d2aaf7 100644 (file)
@@ -441,6 +441,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestScale2.py
                Test1816.py
                Test1876.py
+               Test2225.py
                Test2631.py
                Test2636.py
                Test2650.py
index cd6c8781fd3af762360ae3b84edea67165994f70..c3a38788782385f5fa00772b093daaa95fefc2fb 100644 (file)
@@ -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<GeomAlgoAPI_Pipe> 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<GeomAPI_Shape> theBaseShape,
+                                      const std::shared_ptr<GeomAPI_Shape> thePathShape,
                                       const std::shared_ptr<GeomAlgoAPI_Pipe> thePipeAlgo,
                                       const int theResultIndex)
 {
@@ -312,6 +313,8 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape> theBa
 
 //==================================================================================================
 void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes,
+                                      const std::shared_ptr<GeomAPI_Shape> thePathShape,
                                       const std::shared_ptr<GeomAlgoAPI_Pipe> 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_");
 
index 08ccb1e8e35de664975f8f86274ed88d210a69c6..078ae9f3c6570fd1d0378b13f2762b12f805977c 100644 (file)
@@ -120,10 +120,12 @@ public:
 
 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);
 
diff --git a/src/FeaturesPlugin/Test/Test2225.py b/src/FeaturesPlugin/Test/Test2225.py
new file mode 100644 (file)
index 0000000..aad529a
--- /dev/null
@@ -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())
index b0a693cebbea4a10e5e1bccfaeaa90be2a26594c..067a249bd592d27e11cf924b8923f6dcee1b48d2 100644 (file)
@@ -24,6 +24,7 @@
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Lin.h>
+#include <GeomAPI_ShapeExplorer.h>
 
 #include <BRep_Tool.hxx>
 #include <BRepExtrema_DistShapeShape.hxx>
@@ -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<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>();
@@ -211,7 +222,13 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
 
   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;
@@ -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());
+  }
+}
index bc97bef65d4a9af03925521b902ef20ed38b1ba3..879927886d2224b03eec92ce99e056ac0416868c 100644 (file)
@@ -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