From: dbv Date: Mon, 14 Sep 2015 08:39:58 +0000 (+0300) Subject: Tests for ExtrusionSketch and RevolutionSketch X-Git-Tag: V_1.4.0~76 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fe6e296e1bb1cc31210d510b569d70c70df02ac0;p=modules%2Fshaper.git Tests for ExtrusionSketch and RevolutionSketch --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 6e5948606..52239b22a 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -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 diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut.py b/src/FeaturesPlugin/Test/TestExtrusionCut.py index 033978132..9c17d56d0 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut.py @@ -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 diff --git a/src/FeaturesPlugin/Test/TestExtrusionFuse.py b/src/FeaturesPlugin/Test/TestExtrusionFuse.py index 1247a06bd..29e778c3c 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionFuse.py +++ b/src/FeaturesPlugin/Test/TestExtrusionFuse.py @@ -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 index 000000000..0b80dcdba --- /dev/null +++ b/src/FeaturesPlugin/Test/TestExtrusionSketch.py @@ -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) diff --git a/src/FeaturesPlugin/Test/TestRevolutionCut.py b/src/FeaturesPlugin/Test/TestRevolutionCut.py index 1b51b2e89..8229b15b4 100644 --- a/src/FeaturesPlugin/Test/TestRevolutionCut.py +++ b/src/FeaturesPlugin/Test/TestRevolutionCut.py @@ -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 diff --git a/src/FeaturesPlugin/Test/TestRevolutionFuse.py b/src/FeaturesPlugin/Test/TestRevolutionFuse.py index 9ece5c99d..d15735d2d 100644 --- a/src/FeaturesPlugin/Test/TestRevolutionFuse.py +++ b/src/FeaturesPlugin/Test/TestRevolutionFuse.py @@ -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 index 000000000..589015753 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRevolutionSketch.py @@ -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)