Salome HOME
Issue #1916: Fatal error when create sketch on body Remove subshapes
[modules/shaper.git] / src / FeaturesPlugin / Test / TestRevolutionCut.py
index 8229b15b45eb0b9b581f72434cf5dbdd029176d1..6ec4eb3b584c37d659c5273b2745d5f96842e4df 100644 (file)
@@ -1,31 +1,3 @@
-"""
-      TestRevolutionCut.py
-      Unit test of FeaturesPlugin_RevolutionCut class
-      
-      class FeaturesPlugin_RevolutionCut : public FeaturesPlugin_RevolutionBoolean
-               static const std::string MY_REVOLUTION_ID("RevolutionCut");
-        static const std::string MY_SKETCH_OBJECT_ID("sketch");
-        static const std::string MY_AXIS_ID("axis_object");
-        static const std::string METHOD_ATTR("CreationMethod");
-        static const std::string MY_TO_ANGLE_ID("to_angle");
-        static const std::string MY_FROM_ANGLE_ID("from_angle");
-        static const std::string MY_TO_OBJECT_ID("to_object");
-        static const std::string MY_TO_OFFSET_ID("to_offset");
-        static const std::string MY_FROM_OBJECT_ID("from_object");
-        static const std::string MY_FROM_OFFSET_ID("from_offset");
-        static const std::string MY_BOOLEAN_OBJECTS_ID("boolean_objects");
-
-        data()->addAttribute(SKETCH_OBJECT_ID(), ModelAPI_AttributeReference::typeId());
-        data()->addAttribute(AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-               data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
-        data()->addAttribute(TO_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
-        data()->addAttribute(FROM_ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
-        data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-        data()->addAttribute(TO_OFFSET_ID(), ModelAPI_AttributeDouble::typeId());
-        data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-        data()->addAttribute(FROM_OFFSET_ID(), ModelAPI_AttributeSelection::typeId());
-        data()->addAttribute(BOOLEAN_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
-"""
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -142,21 +114,26 @@ dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
 norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
-aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace_1")
+aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
+aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
 anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
 aCircleRadius = aSketchCircle.real("CircleRadius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
+aSession.finishOperation()
+aSession.startOperation()
+aCircleSketchFeature.execute() # execute for sketch should be called here, because it is not set as current feature, so it is disabled.
+anRevolutionCutFt.selectionList("base").append(aCircleSketchFeature.firstResult(), None)
 anRevolutionCutFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge)
 anRevolutionCutFt.string("CreationMethod").setValue("ByAngles")
 anRevolutionCutFt.real("to_angle").setValue(50)
 anRevolutionCutFt.real("from_angle").setValue(50)
 anRevolutionCutFt.real("to_offset").setValue(0) #TODO: remove
 anRevolutionCutFt.real("from_offset").setValue(0) #TODO: remove
-anRevolutionCutFt.selectionList("boolean_objects").append(anExtrusionResult, anExtrusionResult.shape())
-anRevolutionCutFt.execute()
+anRevolutionCutFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape())
+aSession.finishOperation()
 aSession.finishOperation()
 
 #=========================================================================
@@ -167,3 +144,6 @@ assert (aFactory.validate(anRevolutionCutFt))
 assert (len(anRevolutionCutFt.results()) > 0)
 aCurrentResult = modelAPI_ResultBody(anRevolutionCutFt.firstResult())
 assert (aCurrentResult is not None)
+
+import model
+assert(model.checkPythonDump())