]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2650: Crash when create pipe
authordbv <dbv@opencascade.com>
Fri, 28 Sep 2018 15:24:04 +0000 (18:24 +0300)
committerdbv <dbv@opencascade.com>
Fri, 28 Sep 2018 15:24:36 +0000 (18:24 +0300)
Added one more fix.

src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/Test/Test2650.py
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp

index 411a6470ba67a5ef1daa2270d86c70a7e8482df9..8d785e658827d2d621b0d78407242db548749450 100644 (file)
@@ -141,12 +141,6 @@ bool FeaturesPlugin_ValidatorPipeLocations::isValid(const AttributePtr& theAttri
         return false;
       }
     }
-    ResultConstructionPtr aResultConstruction =
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
-    if (aResultConstruction.get()) {
-      theError = "Error: Result construction not allowed for selection.";
-      return false;
-    }
     std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
     if (!aShape.get() && aContext.get()) {
       GeomShapePtr aContextShape = aContext->shape();
index e321411616aeb70b2c028af309e6885e0bcf4046..8d7c256e6eb0d3e2e1a0defbefa5284211dafa3c 100644 (file)
@@ -24,27 +24,31 @@ model.begin()
 partSet = model.moduleDocument()
 Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
-Import_1 = model.addImport(Part_1_doc, "D:/rq_1.brep")
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_1.addLine(10.96877310597264, 4.388320842434023, 10.96877310597264, 75.63259202833271)
 model.do()
-Import_1.setName("rq_1")
-Import_1.result().setName("rq_1_1")
-Import_2 = model.addImport(Part_1_doc, "D:/rq2_1.brep")
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_2 = Sketch_2.addLine(20.69511709668412, -6.720507935503198, 19.39808085030927, 19.46570269579372)
+SketchLine_3 = Sketch_2.addLine(19.39808085030927, 19.46570269579372, 61.20243103906213, 28.02128023393725)
+SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchLine_4 = Sketch_2.addLine(61.20243103906213, 28.02128023393725, 64.54729867171925, -32.684941224703)
+SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchLine_5 = Sketch_2.addLine(64.54729867171925, -32.684941224703, 20.69511709668412, -6.720507935503198)
+SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_5.endPoint())
 model.do()
-Import_2.setName("rq2_1")
-Import_2.result().setName("rq2_1_1")
-Import_3 = model.addImport(Part_1_doc, "D:/spine.brep")
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e"))
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
+SketchLine_6 = Sketch_3.addLine(18.78449167586506, 11.40320166178118, 18.60732592394469, -15.47067574876233)
+SketchLine_7 = Sketch_3.addLine(18.60732592394469, -15.47067574876233, 57.06415928764967, -9.455161348995592)
+SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchLine_8 = Sketch_3.addLine(57.06415928764967, -9.455161348995592, 56.5687276408287, 11.2362868340608)
+SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
+SketchLine_9 = Sketch_3.addLine(56.5687276408287, 11.2362868340608, 18.78449167586506, 11.40320166178118)
+SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
+SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_6.startPoint(), SketchLine_9.endPoint())
 model.do()
-Import_3.setName("spine")
-Import_3.result().setName("spine_1")
-Import_4 = model.addImport(Part_1_doc, "D:/v1.brep")
-model.do()
-Import_4.setName("v1")
-Import_4.result().setName("v1_1")
-Import_5 = model.addImport(Part_1_doc, "D:/v2.brep")
-model.do()
-Import_5.setName("v2")
-Import_5.result().setName("v2_1")
-Pipe_1 = model.addPipe(Part_1_doc, [model.selection("WIRE", "rq_1_1"), model.selection("WIRE", "rq2_1_1")], model.selection("WIRE", "spine_1"), [model.selection("VERTEX", "spine_1/Shape2"), model.selection("VERTEX", "spine_1/Shape3")])
+Pipe_1 = model.addPipe(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r"), model.selection("FACE", "Sketch_3/Face-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")])
 model.do()
 model.end()
 
@@ -52,9 +56,9 @@ from GeomAPI import  GeomAPI_Shape
 
 model.testNbResults(Pipe_1, 1)
 model.testNbSubResults(Pipe_1, [0])
-model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [0])
-model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [4])
-model.testNbSubShapes(Pipe_1, GeomAPI_Shape.EDGE, [16])
-model.testNbSubShapes(Pipe_1, GeomAPI_Shape.VERTEX, [32])
+model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Pipe_1, GeomAPI_Shape.EDGE, [24])
+model.testNbSubShapes(Pipe_1, GeomAPI_Shape.VERTEX, [48])
 
 assert(model.checkPythonDump())
index 84a09ea1029e1ad2410ac0bbf9411c5a1fc16d55..2578c836c64956f8525f79ab06c64af2622342f6 100644 (file)
@@ -209,11 +209,6 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
     return;
   }
 
-  bool aHasLocations = false;
-  if(!theLocations.empty()) {
-    aHasLocations = true;
-  }
-
   // Getting path.
   TopoDS_Shape aBaseShape;
   TopAbs_ShapeEnum aBaseShapeType;
@@ -229,6 +224,37 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
   gp_Trsf aTrsf = getPathToBaseTranslation(aBaseShape, aPathWire);
   aPathWire.Move(aTrsf);
 
+  // Get locations after moving path shape.
+  std::list<TopoDS_Vertex> aLocations;
+  for (ListOfShape::const_iterator aLocIt = theLocations.cbegin();
+       aLocIt != theLocations.cend();
+       ++aLocIt)
+  {
+    GeomShapePtr aLocation = *aLocIt;
+    if (!aLocation.get() || aLocation->shapeType() != GeomAPI_Shape::VERTEX) {
+      return;
+    }
+
+    TopoDS_Vertex aLocationVertex = aLocation->impl<TopoDS_Vertex>();
+    TopoDS_Vertex aMovedVertex;
+    for (TopExp_Explorer anExp(aPathWire, TopAbs_VERTEX); anExp.More(); anExp.Next()) {
+      if (anExp.Current().IsPartner(aLocationVertex)) {
+        aMovedVertex = TopoDS::Vertex(anExp.Current());
+        aLocations.push_back(aMovedVertex);
+        break;
+      }
+    }
+    if (aMovedVertex.IsNull()) {
+      return;
+    }
+  }
+
+  if (theLocations.size() != aLocations.size()) {
+    return;
+  }
+
+  bool aHasLocations = !aLocations.empty();
+
   // Making pipe.
   Standard_Boolean isDone = Standard_False;
   bool anIsSolidNeeded = false;
@@ -239,7 +265,7 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
       return;
     }
     ListOfShape::const_iterator aBaseIt = theBaseShapes.cbegin();
-    ListOfShape::const_iterator aLocIt = theLocations.cbegin();
+    std::list<TopoDS_Vertex>::const_iterator aLocationsIt = aLocations.cbegin();
     while(aBaseIt != theBaseShapes.cend()) {
       GeomShapePtr aBase = *aBaseIt;
       if(!getBase(aBaseShape, aBaseShapeType, aBase)) {
@@ -252,15 +278,8 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes,
       }
 
       if(aHasLocations) {
-        GeomShapePtr aLocation = *aLocIt;
-        if(!aLocation.get() || aLocation->shapeType() != GeomAPI_Shape::VERTEX) {
-          delete aPipeBuilder;
-          return;
-        }
-        TopoDS_Vertex aLocationVertex = aLocation->impl<TopoDS_Vertex>();
-        aLocationVertex.Move(aTrsf);
-        ++aLocIt;
-        aPipeBuilder->Add(aBaseShape, aLocationVertex);
+        aPipeBuilder->Add(aBaseShape, *aLocationsIt);
+        ++aLocationsIt;
       } else {
         aPipeBuilder->Add(aBaseShape);
       }