]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1366: Added test cases for "Union" and "Remove Sub-Shapes" features.
authordbv <dbv@opencascade.com>
Tue, 21 Jun 2016 12:16:25 +0000 (15:16 +0300)
committerdbv <dbv@opencascade.com>
Tue, 21 Jun 2016 12:17:14 +0000 (15:17 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/TestRemoveSubShapes.py [new file with mode: 0644]
src/FeaturesPlugin/remove_subshapes_widget.xml

index 2ffaf860df01f9d6772b9ff0612d091a2daf8ba1..70f4fc63272e8da6c7f138fbd5ebec809f8b7a1e 100644 (file)
@@ -126,4 +126,6 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestSerialBoolean.py
                TestGroup.py
                TestIntersection.py
-               TestPipe.py)
+               TestPipe.py
+               TestUnion.py
+               TestRemoveSubShapes.py)
diff --git a/src/FeaturesPlugin/Test/TestRemoveSubShapes.py b/src/FeaturesPlugin/Test/TestRemoveSubShapes.py
new file mode 100644 (file)
index 0000000..6685760
--- /dev/null
@@ -0,0 +1,74 @@
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part for extrusion
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch to extrude
+#=========================================================================
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+
+# Create circles
+aSketchCircle = aSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(-25, 0)
+aCircleRadius.setValue(50)
+aSketchCircle = aSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(25, 0)
+aCircleRadius.setValue(50)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+
+#=========================================================================
+# Make extrusion on sketch
+#=========================================================================
+# Create extrusion
+aSession.startOperation()
+anExtrusionFeature = aPart.addFeature("Extrusion")
+anExtrusionFeature.selectionList("base").append(aSketchResult, None)
+anExtrusionFeature.string("CreationMethod").setValue("BySizes")
+anExtrusionFeature.real("to_size").setValue(50)
+anExtrusionFeature.real("from_size").setValue(0)
+anExtrusionFeature.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFeature.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFeature.execute()
+aSession.finishOperation()
+anExtrusionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(anExtrusionFeature.firstResult()))
+
+#=========================================================================
+# Remove sub-shapes
+#=========================================================================
+aSession.startOperation()
+aRemoveSubShapesFeature = aPart.addFeature("Remove_SubShapes")
+aRemoveSubShapesFeature.selection("base_shape").setValue(anExtrusionResult, None)
+aRemoveSubShapesFeature.selectionList("subshapes").removeLast();
+aSession.finishOperation()
+assert (len(aRemoveSubShapesFeature.results()) > 0)
+anUnionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(aRemoveSubShapesFeature.firstResult()))
+assert (anUnionResult.numberOfSubs() == 2)
index 9300b9a2f511124a5fe2b30997a76467b8627822..93d3ac973e3705f7d95dd6722183e0d6ac7e0c46 100644 (file)
@@ -11,7 +11,7 @@
     <validator id="GeomValidators_BodyShapes"/>
   </shape_selector>
   <multi_selector id="subshapes"
-                  label="Sub-Shapes:"
+                  label="Sub-Shapes to keep:"
                   tooltip="Select shapes to keep."
                   type_choice="vertices edges wires faces shells solids compsolids compounds"
                   clear_in_neutral_point="false">