]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Test update
authordbv <dbv@opencascade.com>
Tue, 8 Sep 2015 08:06:37 +0000 (11:06 +0300)
committerdbv <dbv@opencascade.com>
Tue, 8 Sep 2015 08:06:50 +0000 (11:06 +0300)
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/Test/TestAxisCreation.py [new file with mode: 0644]
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/Test/TestPartition.py [new file with mode: 0644]
src/FeaturesPlugin/Test/TestRevolution.py
src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp

index 1c4aa2e688d804bc889f0034fc49d3a70575da33..8633f1f7bdf1d5adb3a8322a11e002e2ce006007 100644 (file)
@@ -47,5 +47,5 @@ INCLUDE_DIRECTORIES(
 )
 
 
-ADD_UNIT_TESTS(TestPointName.py
-              )
+ADD_UNIT_TESTS(TestAxisCreation.py
+               TestPointName.py)
diff --git a/src/ConstructionPlugin/Test/TestAxisCreation.py b/src/ConstructionPlugin/Test/TestAxisCreation.py
new file mode 100644 (file)
index 0000000..22040ad
--- /dev/null
@@ -0,0 +1,134 @@
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+import math
+from ModelAPI import *
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+assert (len(aPartFeature.results()) == 1)
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+#=========================================================================
+# Create a first point
+#=========================================================================
+aSession.startOperation()
+aPointFeature = aPart.addFeature("Point")
+aPointFeatureData = aPointFeature.data()
+assert(aPointFeatureData is not None)
+aPointFeatureData.real("x").setValue(0.)
+aPointFeatureData.real("y").setValue(0.)
+aPointFeatureData.real("z").setValue(0.)
+aPointFeature.execute()
+aSession.finishOperation()
+aPoint1Result = aPointFeature.firstResult();
+
+#=========================================================================
+# Create a second point
+#=========================================================================
+aSession.startOperation()
+aPointFeature = aPart.addFeature("Point")
+aPointFeatureData = aPointFeature.data()
+assert(aPointFeatureData is not None)
+aPointFeatureData.real("x").setValue(0.)
+aPointFeatureData.real("y").setValue(0.)
+aPointFeatureData.real("z").setValue(100.)
+aPointFeature.execute()
+aSession.finishOperation()
+aPoint2Result = aPointFeature.firstResult();
+
+#=========================================================================
+# Create axis by two points
+#=========================================================================
+aSession.startOperation()
+anAxisFeature = aPart.addFeature("Axis")
+anAxisFeatureData = anAxisFeature.data()
+assert(anAxisFeatureData is not None)
+anAxisFeatureData.string("CreationMethod").setValue("AxisByPointsCase")
+anAxisFeatureData.selection("FirstPoint").setValue(aPoint1Result, aPoint1Result.shape())
+anAxisFeatureData.selection("SecondPoint").setValue(aPoint2Result, aPoint2Result.shape())
+anAxisFeature.execute()
+aSession.finishOperation()
+
+assert (len(anAxisFeature.results()) > 0)
+anAxisResult = modelAPI_ResultConstruction(anAxisFeature.firstResult())
+assert (anAxisResult is not None)
+
+#=========================================================================
+# 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(50)
+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(100)
+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() == 100.0)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Create axis by cylinder
+#=========================================================================
+aSession.startOperation()
+anAxisFeature = aPart.addFeature("Axis")
+anAxisFeatureData = anAxisFeature.data()
+assert(anAxisFeatureData is not None)
+anAxisFeatureData.string("CreationMethod").setValue("AxisByCylindricalFaceCase")
+anAxisFeatureData.selection("CylindricalFace").selectSubShape("face", "Extrusion_1_1/LateralFace_1")
+anAxisFeature.execute()
+aSession.finishOperation()
+
+assert (len(anAxisFeature.results()) > 0)
+anAxisResult = modelAPI_ResultConstruction(anAxisFeature.firstResult())
+assert (anAxisResult is not None)
index 1fa7948da49c58c12a79e10e47df1c28cad9713b..c475ee87d0a974f5193602e05df148d154be4756 100644 (file)
@@ -85,6 +85,7 @@ ADD_UNIT_TESTS(TestExtrusion.py
                TestRevolution.py
                TestRevolutionCut.py
                TestRevolutionFuse.py
+               TestPartition.py
                TestMovement.py
                TestRotation.py
                TestBoolean.py
diff --git a/src/FeaturesPlugin/Test/TestPartition.py b/src/FeaturesPlugin/Test/TestPartition.py
new file mode 100644 (file)
index 0000000..84c70c4
--- /dev/null
@@ -0,0 +1,92 @@
+#=========================================================================
+# 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(50)
+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)
+
+# Check extrusion results
+assert (len(anExtrusionFt.results()) > 0)
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult())
+assert (anExtrusionResult is not None)
+
+#=========================================================================
+# Create a partition
+#=========================================================================
+aXOZPlane = modelAPI_Result(aDocument.objectByName("Construction", "XOZ"))
+aSession.startOperation()
+aPartitionFt = aPart.addFeature("Partition")
+assert (aPartitionFt.getKind() == "Partition")
+aPartitionFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape())
+aPartitionFt.selectionList("tool_objects").append(aXOZPlane, None)
+aPartitionFt.execute()
+aSession.finishOperation()
+
+assert (len(aPartitionFt.results()) > 0)
+aPartitionResult = modelAPI_ResultBody(aPartitionFt.firstResult())
+assert (aPartitionResult is not None)
index 7a6b0c40864753733d08665ce0f3329d53f49e30..1dd1ee277a11be158a18a06f663d8869a67c6917 100644 (file)
@@ -127,3 +127,56 @@ assert (len(aRevolFt.results()) > 0)
 aRevolResult = modelAPI_ResultBody(aRevolFt.firstResult())
 assert (aRevolResult is not None)
 
+#=========================================================================
+# Create a first plane
+#=========================================================================
+aXOYPlane = modelAPI_Result(aDocument.objectByName("Construction", "XOY"))
+aSession.startOperation()
+aPlaneFeature = aPart.addFeature("Plane")
+aPlaneFeatureData = aPlaneFeature.data()
+assert(aPlaneFeatureData is not None)
+aPlaneFeatureData.string("CreationMethod").setValue("PlaneByFaceAndDistance")
+aPlaneFeatureData.selection("planeFace").setValue(aXOYPlane, None)
+aPlaneFeatureData.real("distance").setValue(50)
+aPlaneFeature.execute()
+aSession.finishOperation()
+aPlane1Result = aPlaneFeature.firstResult();
+
+#=========================================================================
+# Create a second plane
+#=========================================================================
+aSession.startOperation()
+aPlaneFeature = aPart.addFeature("Plane")
+aPlaneFeatureData = aPlaneFeature.data()
+assert(aPlaneFeatureData is not None)
+aPlaneFeatureData.string("CreationMethod").setValue("PlaneByFaceAndDistance")
+aPlaneFeatureData.selection("planeFace").setValue(aXOYPlane, None)
+aPlaneFeatureData.real("distance").setValue(-50)
+aPlaneFeature.execute()
+aSession.finishOperation()
+aPlane2Result = aPlaneFeature.firstResult();
+
+#=========================================================================
+# Test revol between bounding planes
+#=========================================================================
+aSession.startOperation()
+aRevolFt = aPart.addFeature("Revolution")
+assert (aRevolFt.getKind() == "Revolution")
+# selection type FACE=4
+aRevolFt.selectionList("base").append(
+    aCircleSketchResult, aCircleSketchFaces[0])
+aRevolFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge)
+aRevolFt.string("CreationMethod").setValue("ByPlanesAndOffsets")
+aRevolFt.real("from_angle").setValue(0) #TODO: remove
+aRevolFt.real("to_angle").setValue(0) #TODO: remove
+aRevolFt.selection("to_object").setValue(aPlane1Result, None)
+aRevolFt.real("to_offset").setValue(0)
+aRevolFt.selection("from_object").setValue(aPlane2Result, None)
+aRevolFt.real("from_offset").setValue(0)
+aRevolFt.execute()
+aSession.finishOperation()
+
+# Check revol results
+assert (len(aRevolFt.results()) > 0)
+aRevolResult = modelAPI_ResultBody(aRevolFt.firstResult())
+assert (aRevolResult is not None)
\ No newline at end of file
index d47fbbd46fc0e58fdfe4494c1a97af760f1b33c9..544ff79b883cd76ae4eca544f12feb8c68811cc4 100644 (file)
@@ -332,7 +332,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBasi
     aResult = aToCutBuilder->Shape();
 
     // If after cut we got more than one solids then take closest to the center of mass of the base face.
-    //aResult = findClosest(aResult, aBasisCentre);
+    aResult = findClosest(aResult, aBasisCentre);
 
     // Setting naming.
     for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {
@@ -474,7 +474,7 @@ void GeomAlgoAPI_Revolution::build(const std::shared_ptr<GeomAPI_Shape>& theBasi
     }
 
     // If after cut we got more than one solids then take closest to the center of mass of the base face.
-    //aResult = findClosest(aResult, aBasisCentr);
+    aResult = findClosest(aResult, aBasisCentr);
 
     // Setting naming.
     for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {