]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Adjust unit tests
authorazv <azv@opencascade.com>
Thu, 14 Dec 2017 14:42:53 +0000 (17:42 +0300)
committerazv <azv@opencascade.com>
Thu, 14 Dec 2017 14:43:14 +0000 (17:43 +0300)
src/FeaturesPlugin/Test/TestFillSolidCompFace.py
src/FeaturesPlugin/Test/TestFillSolidCompShell.py
src/FeaturesPlugin/Test/TestFillSolidShell.py
src/Model/Model_BodyBuilder.cpp

index 302e5cca30591e667fb559110cf16e578a471c07..d38ece362f23f2d2c698c1c62019f2c552fb98d8 100644 (file)
@@ -28,9 +28,9 @@ partSet = model.moduleDocument()
 Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
 model.addParameter(Part_1_doc, "L", "10")
-model.addParameter(Part_1_doc, "Shift", "5")
+model.addParameter(Part_1_doc, "Shift", "12")
 Box_1 = model.addBox(Part_1_doc, "L", "L", "L")
-Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), "Shift", True)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), "L/2", True)
 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
 SketchPoint_1 = SketchProjection_1.createdFeature()
@@ -46,16 +46,16 @@ SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(),
 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint())
 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result())
 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "L+Shift/2")
-SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), -5)
+SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), "-Shift/3")
 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True)
 model.do()
-Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True)
+Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True)
 Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")])
 Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")])
 Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Boolean_1_1")])
 model.do()
 
-model.checkBooleansResult(Boolean_2, model, 1, [0], [1], [9], [46], [92])
+model.checkBooleansResult(Boolean_2, model, 1, [2], [2], [14], [60], [120])
 model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc)
 
 model.end()
index df0b4815dbadb1721d5c265a191c7b82e2e6805c..997708c53c3d7e3a463b06a9cd5b4d1b353ec43b 100644 (file)
@@ -28,9 +28,9 @@ partSet = model.moduleDocument()
 Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
 model.addParameter(Part_1_doc, "L", "10")
-model.addParameter(Part_1_doc, "Shift", "5")
+model.addParameter(Part_1_doc, "Shift", "12")
 Box_1 = model.addBox(Part_1_doc, "L", "L", "L")
-Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), "Shift", True)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), "L/2", True)
 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
 SketchPoint_1 = SketchProjection_1.createdFeature()
@@ -46,18 +46,18 @@ SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(),
 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint())
 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result())
 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "L+Shift/2")
-SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), -5)
+SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), "-Shift/3")
 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True)
 model.do()
-Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True)
+Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True)
 Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")])
 Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")])
 Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Boolean_1_1_2"), model.selection("FACE", "Boolean_1_1_1")])
 MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), 1, 3)
-Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "MultiTranslation_1_1")])
+Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "LinearCopy_1_1")])
 model.do()
 
-model.checkBooleansResult(Boolean_2, model, 1, [0], [1], [15], [90], [180])
+model.checkBooleansResult(Boolean_2, model, 1, [4], [4], [30], [132], [264])
 model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc)
 
 model.end()
index 33fe90bb4b2d518d118801c41e2aee06384c1b3f..2a06dab4212eb4084bfd9e390c626f214efffad8 100644 (file)
@@ -28,9 +28,9 @@ partSet = model.moduleDocument()
 Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
 model.addParameter(Part_1_doc, "L", "10")
-model.addParameter(Part_1_doc, "Shift", "5")
+model.addParameter(Part_1_doc, "Shift", "12")
 Box_1 = model.addBox(Part_1_doc, "L", "L", "L")
-Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), "Shift", True)
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), "L/2", True)
 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
 SketchPoint_1 = SketchProjection_1.createdFeature()
@@ -46,17 +46,17 @@ SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(),
 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint())
 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result())
 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "L+Shift/2")
-SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), -5)
+SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), "-Shift/3")
 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True)
 model.do()
-Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True)
+Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True)
 Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")])
 Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")])
 Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Boolean_1_1_2"), model.selection("FACE", "Boolean_1_1_1")])
 Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SHELL", "Shell_1_1")])
 model.do()
 
-model.checkBooleansResult(Boolean_2, model, 1, [0], [1], [9], [46], [92])
+model.checkBooleansResult(Boolean_2, model, 1, [2], [2], [14], [60], [120])
 model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc)
 
 model.end()
index 623ed23edd1b63dba50b24df9d64a17ecc13fcfa..fc25d4ecc08740deed5e7e4c650b194044a8c548 100755 (executable)
@@ -370,6 +370,27 @@ void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
   }
 }
 
+// Keep only the shapes with minimal shape type
+static void keepTopLevelShapes(ListOfShape& theShapes)
+{
+  GeomAPI_Shape::ShapeType aKeepShapeType = GeomAPI_Shape::SHAPE;
+  ListOfShape::iterator anIt = theShapes.begin();
+  while (anIt != theShapes.end()) {
+    GeomAPI_Shape::ShapeType aType = (*anIt)->shapeType();
+    if (aType < aKeepShapeType) {
+      // found a shape with lesser shape type => remove all previous shapes
+      aKeepShapeType = aType;
+      theShapes.erase(theShapes.begin(), anIt);
+      ++anIt;
+    } else if (aType > aKeepShapeType) {
+      // shapes with greater shape type should be removed from the list
+      ListOfShape::iterator aRemoveIt = anIt++;
+      theShapes.erase(aRemoveIt);
+    } else
+      ++anIt;
+  }
+}
+
 void Model_BodyBuilder::loadAndOrientModifiedShapes (
   GeomAlgoAPI_MakeShape* theMS,
   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
@@ -398,6 +419,7 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes (
     std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
     aRShape->setImpl((new TopoDS_Shape(aRoot)));
     theMS->modified(aRShape, aList);
+    keepTopLevelShapes(aList);
     // sort the list of images before naming
     GeomAlgoAPI_SortListOfShapes::sort(aList);
 
@@ -460,27 +482,6 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes (
   }
 }
 
-// Keep only the shapes with minimal shape type
-static void keepTopLevelShapes(ListOfShape& theShapes)
-{
-  GeomAPI_Shape::ShapeType aKeepShapeType = GeomAPI_Shape::SHAPE;
-  ListOfShape::iterator anIt = theShapes.begin();
-  while (anIt != theShapes.end()) {
-    GeomAPI_Shape::ShapeType aType = (*anIt)->shapeType();
-    if (aType < aKeepShapeType) {
-      // found a shape with lesser shape type => remove all previous shapes
-      aKeepShapeType = aType;
-      theShapes.erase(theShapes.begin(), anIt);
-      ++anIt;
-    } else if (aType > aKeepShapeType) {
-      // shapes with greater shape type should be removed from the list
-      ListOfShape::iterator aRemoveIt = anIt++;
-      theShapes.erase(aRemoveIt);
-    } else
-      ++anIt;
-  }
-}
-
 void Model_BodyBuilder::loadAndOrientGeneratedShapes (
   GeomAlgoAPI_MakeShape* theMS,
   std::shared_ptr<GeomAPI_Shape>  theShapeIn,