From: dbv Date: Tue, 21 Jun 2016 12:16:25 +0000 (+0300) Subject: Issue #1366: Added test cases for "Union" and "Remove Sub-Shapes" features. X-Git-Tag: V_2.4.0~84 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=51d557cd9aba1ec53569bb55c6b9a956e48182e1;p=modules%2Fshaper.git Issue #1366: Added test cases for "Union" and "Remove Sub-Shapes" features. --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 2ffaf860d..70f4fc632 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -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 index 000000000..6685760da --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRemoveSubShapes.py @@ -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) diff --git a/src/FeaturesPlugin/remove_subshapes_widget.xml b/src/FeaturesPlugin/remove_subshapes_widget.xml index 9300b9a2f..93d3ac973 100644 --- a/src/FeaturesPlugin/remove_subshapes_widget.xml +++ b/src/FeaturesPlugin/remove_subshapes_widget.xml @@ -11,7 +11,7 @@