]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Tests update
authordbv <dbv@opencascade.com>
Fri, 3 Jul 2015 14:58:55 +0000 (17:58 +0300)
committerdbv <dbv@opencascade.com>
Fri, 3 Jul 2015 15:03:29 +0000 (18:03 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_ExtrusionCut.h
src/FeaturesPlugin/FeaturesPlugin_ExtrusionFuse.h
src/FeaturesPlugin/Test/TestExtrusionCut.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestExtrusionFuse.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRevolutionCut.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRevolutionFuse.py [new file with mode: 0644]

index a1e85685aadd133d6c05a96278fb689abce34245..952e741fccd31dd1ed22c042eb8d15a0d6d19c52 100644 (file)
@@ -73,10 +73,14 @@ INSTALL(TARGETS FeaturesPlugin DESTINATION plugins)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
 
 ADD_UNIT_TESTS(TestExtrusion.py
+               TestExtrusionCut.py
+               TestExtrusionFuse.py
                TestRevolution.py
+               TestRevolutionCut.py
+               TestRevolutionFuse.py
                TestMovement.py
                TestRotation.py
                TestBoolean.py
                TestMultiBoolean.py
-                          TestSerialBoolean.py
+               TestSerialBoolean.py
                TestGroup.py)
index 4879a0eb9e74ecf1ecec1b7c6e0be6777401adbf..fbff14c5ecbcb19fc10ad0d04bf13e8296ed12b5 100755 (executable)
@@ -18,8 +18,8 @@ class FeaturesPlugin_ExtrusionCut : public FeaturesPlugin_ExtrusionBoolean
   /// Feature kind.
   inline static const std::string& ID()
   {
-    static const std::string MY_REVOLUTION_ID("ExtrusionCut");
-    return MY_REVOLUTION_ID;
+    static const std::string MY_EXTRUSION_ID("ExtrusionCut");
+    return MY_EXTRUSION_ID;
   }
 
   /// \return the kind of a feature
index 9b8c36c1003fbf1c138ce3071ae659e608b08f61..558a02893cb9f4a62bd61b8f25b087edd7163740 100644 (file)
@@ -18,8 +18,8 @@ class FeaturesPlugin_ExtrusionFuse : public FeaturesPlugin_ExtrusionBoolean
   /// Feature kind.
   inline static const std::string& ID()
   {
-    static const std::string MY_REVOLUTION_ID("ExtrusionFuse");
-    return MY_REVOLUTION_ID;
+    static const std::string MY_EXTRUSION_ID("ExtrusionFuse");
+    return MY_EXTRUSION_ID;
   }
 
   /// \return the kind of a feature
diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut.py b/src/FeaturesPlugin/Test/TestExtrusionCut.py
new file mode 100644 (file)
index 0000000..0339781
--- /dev/null
@@ -0,0 +1,141 @@
+"""
+      TestExtrusionCut.py
+      Unit test of FeaturesPlugin_ExtrusionCut class
+      
+      class FeaturesPlugin_ExtrusionCut : public FeaturesPlugin_ExtrusionBoolean
+               static const std::string MY_EXTRUSION_ID("ExtrusionCut");
+        static const std::string MY_SKETCH_OBJECT_ID("sketch");
+        static const std::string METHOD_ATTR("CreationMethod");
+        static const std::string MY_TO_SIZE_ID("to_size");
+        static const std::string MY_FROM_SIZE_ID("from_size");
+        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(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
+        data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(FROM_SIZE_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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+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)
+# Another way is:
+# aPart = aSession.activeDocument()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+#=========================================================================
+# Create a sketch circle to extrude
+#=========================================================================
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+# Create circle
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(20)
+aSession.finishOperation()
+#=========================================================================
+# Make extrusion on circle
+#=========================================================================
+# Build shape from sketcher results
+aCircleSketchResult = aCircleSketchFeature.firstResult()
+aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape()
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir()
+aCircleSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(
+    origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces)
+assert (len(aCircleSketchFaces) > 0)
+assert (aCircleSketchFaces[0] is not None)
+# Create extrusion
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+# selection type FACE=4
+anExtrusionFt.selectionList("base").append(
+    aCircleSketchResult, aCircleSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(0)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Make extrusion cut
+#=========================================================================
+aSession.startOperation()
+anExtrusionCutFt = featureToCompositeFeature(aPart.addFeature("ExtrusionCut"))
+assert (anExtrusionCutFt.getKind() == "ExtrusionCut")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anExtrusionCutFt.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 50)
+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")
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anExtrusionCutFt.string("CreationMethod").setValue("BySizes")
+anExtrusionCutFt.real("to_size").setValue(10)
+anExtrusionCutFt.real("from_size").setValue(10)
+anExtrusionCutFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionCutFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionCutFt.selectionList("boolean_objects").append(anExtrusionResult, anExtrusionResult.shape())
+anExtrusionCutFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anExtrusionCutFt))
+assert (len(anExtrusionCutFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anExtrusionCutFt.firstResult())
+assert (aCurrentResult is not None)
+aSession.finishOperation()
\ No newline at end of file
diff --git a/src/FeaturesPlugin/Test/TestExtrusionFuse.py b/src/FeaturesPlugin/Test/TestExtrusionFuse.py
new file mode 100644 (file)
index 0000000..1247a06
--- /dev/null
@@ -0,0 +1,141 @@
+"""
+      TestExtrusionFuse.py
+      Unit test of FeaturesPlugin_ExtrusionFuse class
+      
+      class FeaturesPlugin_ExtrusionFuse : public FeaturesPlugin_ExtrusionBoolean
+               static const std::string MY_EXTRUSION_ID("ExtrusionFuse");
+        static const std::string MY_SKETCH_OBJECT_ID("sketch");
+        static const std::string METHOD_ATTR("CreationMethod");
+        static const std::string MY_TO_SIZE_ID("to_size");
+        static const std::string MY_FROM_SIZE_ID("from_size");
+        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(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
+        data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(FROM_SIZE_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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+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)
+# Another way is:
+# aPart = aSession.activeDocument()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+#=========================================================================
+# Create a sketch circle to extrude
+#=========================================================================
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+# Create circle
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(20)
+aSession.finishOperation()
+#=========================================================================
+# Make extrusion on circle
+#=========================================================================
+# Build shape from sketcher results
+aCircleSketchResult = aCircleSketchFeature.firstResult()
+aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape()
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir()
+aCircleSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(
+    origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces)
+assert (len(aCircleSketchFaces) > 0)
+assert (aCircleSketchFaces[0] is not None)
+# Create extrusion
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+# selection type FACE=4
+anExtrusionFt.selectionList("base").append(
+    aCircleSketchResult, aCircleSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(0)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Make extrusion cut
+#=========================================================================
+aSession.startOperation()
+anExtrusionFuseFt = featureToCompositeFeature(aPart.addFeature("ExtrusionFuse"))
+assert (anExtrusionFuseFt.getKind() == "ExtrusionFuse")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anExtrusionFuseFt.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 50)
+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")
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anExtrusionFuseFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFuseFt.real("to_size").setValue(10)
+anExtrusionFuseFt.real("from_size").setValue(10)
+anExtrusionFuseFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFuseFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFuseFt.selectionList("boolean_objects").append(anExtrusionResult, anExtrusionResult.shape())
+anExtrusionFuseFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anExtrusionFuseFt))
+assert (len(anExtrusionFuseFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anExtrusionFuseFt.firstResult())
+assert (aCurrentResult is not None)
+aSession.finishOperation()
\ No newline at end of file
diff --git a/src/FeaturesPlugin/Test/TestRevolutionCut.py b/src/FeaturesPlugin/Test/TestRevolutionCut.py
new file mode 100644 (file)
index 0000000..1b51b2e
--- /dev/null
@@ -0,0 +1,170 @@
+"""
+      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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+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)
+# Another way is:
+# aPart = aSession.activeDocument()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+#=========================================================================
+# Create a sketch circle to extrude
+#=========================================================================
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+# Create circle
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(20)
+aSession.finishOperation()
+#=========================================================================
+# Make extrusion on circle
+#=========================================================================
+# Build shape from sketcher results
+aCircleSketchResult = aCircleSketchFeature.firstResult()
+aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape()
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir()
+aCircleSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(
+    origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces)
+assert (len(aCircleSketchFaces) > 0)
+assert (aCircleSketchFaces[0] is not None)
+# Create extrusion
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+# selection type FACE=4
+anExtrusionFt.selectionList("base").append(
+    aCircleSketchResult, aCircleSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(0)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Create a sketch line to revol
+#=========================================================================
+aSession.startOperation()
+aLineSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aLineSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 50)
+dirx = geomDataAPI_Dir(aLineSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aLineSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace_1")
+
+aSketchLine = aLineSketchFeature.addFeature("SketchLine")
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
+aLineStartPoint.setValue(-20, -20)
+aLineEndPoint.setValue(20, -20)
+aSession.finishOperation()
+
+# Build shape from sketcher results
+aLineSketchResult = aLineSketchFeature.firstResult()
+aLineSketchShape = modelAPI_ResultConstruction(aLineSketchResult).shape()
+aShapeExplorer = GeomAPI_ShapeExplorer(aLineSketchShape, GeomAPI_Shape.EDGE)
+aLineEdge = aShapeExplorer.current()
+
+#=========================================================================
+# Make revolution cut
+#=========================================================================
+aSession.startOperation()
+anRevolutionCutFt = featureToCompositeFeature(aPart.addFeature("RevolutionCut"))
+assert (anRevolutionCutFt.getKind() == "RevolutionCut")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anRevolutionCutFt.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 50)
+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")
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+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()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anRevolutionCutFt))
+assert (len(anRevolutionCutFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anRevolutionCutFt.firstResult())
+assert (aCurrentResult is not None)
+aSession.finishOperation()
\ No newline at end of file
diff --git a/src/FeaturesPlugin/Test/TestRevolutionFuse.py b/src/FeaturesPlugin/Test/TestRevolutionFuse.py
new file mode 100644 (file)
index 0000000..9ece5c9
--- /dev/null
@@ -0,0 +1,170 @@
+"""
+      TestRevolutionFuse.py
+      Unit test of FeaturesPlugin_RevolutionFuse class
+      
+      class FeaturesPlugin_RevolutionFuse : public FeaturesPlugin_RevolutionBoolean
+               static const std::string MY_REVOLUTION_ID("RevolutionFuse");
+        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
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+
+__updated__ = "2014-12-16"
+
+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)
+# Another way is:
+# aPart = aSession.activeDocument()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+#=========================================================================
+# Create a sketch circle to extrude
+#=========================================================================
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+# Create circle
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(20)
+aSession.finishOperation()
+#=========================================================================
+# Make extrusion on circle
+#=========================================================================
+# Build shape from sketcher results
+aCircleSketchResult = aCircleSketchFeature.firstResult()
+aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape()
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir()
+aCircleSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(
+    origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces)
+assert (len(aCircleSketchFaces) > 0)
+assert (aCircleSketchFaces[0] is not None)
+# Create extrusion
+aSession.startOperation()
+anExtrusionFt = aPart.addFeature("Extrusion")
+assert (anExtrusionFt.getKind() == "Extrusion")
+# selection type FACE=4
+anExtrusionFt.selectionList("base").append(
+    aCircleSketchResult, aCircleSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(0)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+assert (anExtrusionFt.real("to_size").value() == 50.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Create a sketch line to revol
+#=========================================================================
+aSession.startOperation()
+aLineSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aLineSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 50)
+dirx = geomDataAPI_Dir(aLineSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aLineSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aLineSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace_1")
+
+aSketchLine = aLineSketchFeature.addFeature("SketchLine")
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
+aLineStartPoint.setValue(-20, -20)
+aLineEndPoint.setValue(20, -20)
+aSession.finishOperation()
+
+# Build shape from sketcher results
+aLineSketchResult = aLineSketchFeature.firstResult()
+aLineSketchShape = modelAPI_ResultConstruction(aLineSketchResult).shape()
+aShapeExplorer = GeomAPI_ShapeExplorer(aLineSketchShape, GeomAPI_Shape.EDGE)
+aLineEdge = aShapeExplorer.current()
+
+#=========================================================================
+# Make revolution fuse
+#=========================================================================
+aSession.startOperation()
+anRevolutionFuseFt = featureToCompositeFeature(aPart.addFeature("RevolutionFuse"))
+assert (anRevolutionFuseFt.getKind() == "RevolutionFuse")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anRevolutionFuseFt.addFeature("Sketch"))
+origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 50)
+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")
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anRevolutionFuseFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge)
+anRevolutionFuseFt.string("CreationMethod").setValue("ByAngles")
+anRevolutionFuseFt.real("to_angle").setValue(50)
+anRevolutionFuseFt.real("from_angle").setValue(50)
+anRevolutionFuseFt.real("to_offset").setValue(0) #TODO: remove
+anRevolutionFuseFt.real("from_offset").setValue(0) #TODO: remove
+anRevolutionFuseFt.selectionList("boolean_objects").append(anExtrusionResult, anExtrusionResult.shape())
+anRevolutionFuseFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anRevolutionFuseFt))
+assert (len(anRevolutionFuseFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anRevolutionFuseFt.firstResult())
+assert (aCurrentResult is not None)
+aSession.finishOperation()
\ No newline at end of file