]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Tests for ExtrusionSketch and RevolutionSketch
authordbv <dbv@opencascade.com>
Mon, 14 Sep 2015 08:39:58 +0000 (11:39 +0300)
committerdbv <dbv@opencascade.com>
Mon, 14 Sep 2015 08:40:18 +0000 (11:40 +0300)
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/TestExtrusionCut.py
src/FeaturesPlugin/Test/TestExtrusionFuse.py
src/FeaturesPlugin/Test/TestExtrusionSketch.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRevolutionCut.py
src/FeaturesPlugin/Test/TestRevolutionFuse.py
src/FeaturesPlugin/Test/TestRevolutionSketch.py [new file with mode: 0644]

index 6e5948606107c3ecf19792e3dc7f68e67499f1b2..52239b22af0b6d706d5fea0235d6eb5b52c37f78 100644 (file)
@@ -88,9 +88,11 @@ INSTALL(TARGETS FeaturesPlugin DESTINATION plugins)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
 
 ADD_UNIT_TESTS(TestExtrusion.py
+               TestExtrusionSketch.py
                TestExtrusionCut.py
                TestExtrusionFuse.py
                TestRevolution.py
+               TestRevolutionSketch.py
                TestRevolutionCut.py
                TestRevolutionFuse.py
                TestPartition.py
index 0339781329a3e6df1e7b74773f9fd98b65c39866..9c17d56d0f605ab45c8456b411d4e2ff9fe9c691 100644 (file)
@@ -138,4 +138,3 @@ 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
index 1247a06bd981431d9acd2747133d8cd18d4078c1..29e778c3cc2f14522f7299dd7bbf58571e527842 100644 (file)
@@ -138,4 +138,3 @@ 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/TestExtrusionSketch.py b/src/FeaturesPlugin/Test/TestExtrusionSketch.py
new file mode 100644 (file)
index 0000000..0b80dcd
--- /dev/null
@@ -0,0 +1,122 @@
+#=========================================================================
+# 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()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Make extrusion sketch
+#=========================================================================
+aSession.startOperation()
+anExtrusionSketchFt = featureToCompositeFeature(aPart.addFeature("ExtrusionSketch"))
+assert (anExtrusionSketchFt.getKind() == "ExtrusionSketch")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anExtrusionSketchFt.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)
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anExtrusionSketchFt.string("CreationMethod").setValue("BySizes")
+anExtrusionSketchFt.real("to_size").setValue(10)
+anExtrusionSketchFt.real("from_size").setValue(10)
+anExtrusionSketchFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionSketchFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionSketchFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anExtrusionSketchFt))
+assert (len(anExtrusionSketchFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anExtrusionSketchFt.firstResult())
+assert (aCurrentResult is not None)
+
+#=========================================================================
+# Test extrusion between bounding planes
+#=========================================================================
+# Create from plane
+aSession.startOperation()
+aSketchPlaneFeature = aPart.addFeature("Plane")
+aSketchPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation")
+aSketchPlaneFeature.real("A").setValue(0.)
+aSketchPlaneFeature.real("B").setValue(0.)
+aSketchPlaneFeature.real("C").setValue(1.)
+aSketchPlaneFeature.real("D").setValue(30.)
+aSession.finishOperation()
+aFromResult = aSketchPlaneFeature.firstResult()
+aFromShape = modelAPI_ResultConstruction(aFromResult).shape()
+
+# Create to plane
+aSession.startOperation()
+aToPlaneFeature = aPart.addFeature("Plane")
+aToPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation")
+aToPlaneFeature.real("A").setValue(0.)
+aToPlaneFeature.real("B").setValue(0.)
+aToPlaneFeature.real("C").setValue(1.)
+aToPlaneFeature.real("D").setValue(-30.)
+aSession.finishOperation()
+aToResult = aToPlaneFeature.firstResult()
+aToShape = modelAPI_ResultConstruction(aToResult).shape()
+
+#=========================================================================
+# Make extrusion sketch
+#=========================================================================
+aSession.startOperation()
+anExtrusionSketchFt = featureToCompositeFeature(aPart.addFeature("ExtrusionSketch"))
+assert (anExtrusionSketchFt.getKind() == "ExtrusionSketch")
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anExtrusionSketchFt.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)
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anExtrusionSketchFt.string("CreationMethod").setValue("ByPlanesAndOffsets")
+anExtrusionSketchFt.real("to_size").setValue(0) #TODO: remove
+anExtrusionSketchFt.real("from_size").setValue(0) #TODO: remove
+anExtrusionSketchFt.selection("to_object").setValue(aToResult, aToShape)
+anExtrusionSketchFt.real("to_offset").setValue(0)
+anExtrusionSketchFt.selection("from_object").setValue(aFromResult, aFromShape)
+anExtrusionSketchFt.real("from_offset").setValue(0)
+anExtrusionSketchFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anExtrusionSketchFt))
+assert (len(anExtrusionSketchFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anExtrusionSketchFt.firstResult())
+assert (aCurrentResult is not None)
index 1b51b2e89df645ffa38712e2e967cd9251283649..8229b15b45eb0b9b581f72434cf5dbdd029176d1 100644 (file)
@@ -167,4 +167,3 @@ 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
index 9ece5c99db841b493987bb875358ebb01eb86317..d15735d2d9503eb98e13423c4a6f95a96bc377d6 100644 (file)
@@ -167,4 +167,3 @@ 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
diff --git a/src/FeaturesPlugin/Test/TestRevolutionSketch.py b/src/FeaturesPlugin/Test/TestRevolutionSketch.py
new file mode 100644 (file)
index 0000000..5890157
--- /dev/null
@@ -0,0 +1,149 @@
+#=========================================================================
+# 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()
+
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a sketch line to revol
+#=========================================================================
+aSession.startOperation()
+aLineSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aLineSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aLineSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aLineSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 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 sketch
+#=========================================================================
+aSession.startOperation()
+anRevolutionSketchFt = featureToCompositeFeature(aPart.addFeature("RevolutionSketch"))
+assert (anRevolutionSketchFt.getKind() == "RevolutionSketch")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anRevolutionSketchFt.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)
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anRevolutionSketchFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge)
+anRevolutionSketchFt.string("CreationMethod").setValue("ByAngles")
+anRevolutionSketchFt.real("to_angle").setValue(50)
+anRevolutionSketchFt.real("from_angle").setValue(50)
+anRevolutionSketchFt.real("to_offset").setValue(0) #TODO: remove
+anRevolutionSketchFt.real("from_offset").setValue(0) #TODO: remove
+anRevolutionSketchFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anRevolutionSketchFt))
+assert (len(anRevolutionSketchFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anRevolutionSketchFt.firstResult())
+assert (aCurrentResult is not None)
+
+#=========================================================================
+# Test revolution between bounding planes
+#=========================================================================
+# Create from plane
+aSession.startOperation()
+aSketchPlaneFeature = aPart.addFeature("Plane")
+aSketchPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation")
+aSketchPlaneFeature.real("A").setValue(0.)
+aSketchPlaneFeature.real("B").setValue(0.)
+aSketchPlaneFeature.real("C").setValue(1.)
+aSketchPlaneFeature.real("D").setValue(15.)
+aSession.finishOperation()
+aFromResult = aSketchPlaneFeature.firstResult()
+aFromShape = modelAPI_ResultConstruction(aFromResult).shape()
+
+# Create to plane
+aSession.startOperation()
+aToPlaneFeature = aPart.addFeature("Plane")
+aToPlaneFeature.string("CreationMethod").setValue("PlaneByGeneralEquation")
+aToPlaneFeature.real("A").setValue(0.)
+aToPlaneFeature.real("B").setValue(0.)
+aToPlaneFeature.real("C").setValue(1.)
+aToPlaneFeature.real("D").setValue(-15.)
+aSession.finishOperation()
+aToResult = aToPlaneFeature.firstResult()
+aToShape = modelAPI_ResultConstruction(aToResult).shape()
+
+#=========================================================================
+# Make revolution sketch
+#=========================================================================
+aSession.startOperation()
+anRevolutionSketchFt = featureToCompositeFeature(aPart.addFeature("RevolutionSketch"))
+assert (anRevolutionSketchFt.getKind() == "RevolutionSketch")
+# selection type FACE=4
+aSession.startOperation()
+aCircleSketchFeature = featureToCompositeFeature(anRevolutionSketchFt.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)
+aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
+aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(10)
+aSession.finishOperation()
+anRevolutionSketchFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge)
+anRevolutionSketchFt.string("CreationMethod").setValue("ByPlanesAndOffsets")
+anRevolutionSketchFt.real("to_angle").setValue(0) #TODO: remove
+anRevolutionSketchFt.real("from_angle").setValue(0) #TODO: remove
+anRevolutionSketchFt.selection("to_object").setValue(aToResult, aToShape)
+anRevolutionSketchFt.real("to_offset").setValue(0)
+anRevolutionSketchFt.selection("from_object").setValue(aFromResult, aFromShape)
+anRevolutionSketchFt.real("from_offset").setValue(0)
+anRevolutionSketchFt.execute()
+aSession.finishOperation()
+
+#=========================================================================
+# Test results
+#=========================================================================
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(anRevolutionSketchFt))
+assert (len(anRevolutionSketchFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(anRevolutionSketchFt.firstResult())
+assert (aCurrentResult is not None)