Salome HOME
Fix bug on test of rotation.
[modules/shaper.git] / src / FeaturesPlugin / Test / TestMultiBoolean.py
index 953ffc4ee0c3e4d15bb0b8f8d7afaa0c135412d0..aa36d86280812bc8b1492249212b0355ba9e5bee 100644 (file)
@@ -50,13 +50,11 @@ aSketchFeatures = []
 for i in xrange(0, N):
     for j in xrange(0, N):
         # Create circle
-        aSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+        aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
         origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
         origin.setValue(0, 0, 0)
         dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
         dirx.setValue(1, 0, 0)
-        diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-        diry.setValue(0, 1, 0)
         norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
         norm.setValue(0, 0, 1)
         aSketchCircle = aSketchFeature.addFeature("SketchCircle")
@@ -82,19 +80,21 @@ for i in xrange(0, N * N):
     aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
     origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt()
     dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir()
-    dirY = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirY")).dir()
     norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir()
     aSketchFaces = ShapeList()
     GeomAlgoAPI_SketchBuilder.createFaces(
-        origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+        origin, dirX, norm, aSketchEdges, aSketchFaces)
 
     anExtrusionFt = aPart.addFeature("Extrusion")
     assert (anExtrusionFt.getKind() == "Extrusion")
 
     anExtrusionFt.selectionList("base").append(
         aSketchResult, aSketchFaces[0])
-    anExtrusionFt.real("size").setValue(10)
-    anExtrusionFt.boolean("reverse").setValue(False)
+    anExtrusionFt.string("CreationMethod").setValue("BySizes")
+    anExtrusionFt.real("from_size").setValue(0)
+    anExtrusionFt.real("to_size").setValue(10)
+    anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+    anExtrusionFt.real("from_offset").setValue(0) #TODO: remove        
     # v1.0.2 from master
     # anExtrusionFt.selection("extrusion_face").setValue(
     #    aSketchResult, aSketchFaces[0])
@@ -108,13 +108,11 @@ aSession.finishOperation()
 # Make rectangle sketch: base for the box, size 100x100
 #=========================================================================
 aSession.startOperation()
-aQuadrangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+aQuadrangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
 origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
 dirx = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
 norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSketchLineA = aQuadrangleSketchFeature.addFeature("SketchLine")
@@ -148,17 +146,19 @@ aSketchResult = aQuadrangleSketchFeature.firstResult()
 aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
 origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin")).pnt()
 dirX = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX")).dir()
-dirY = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirY")).dir()
 norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm")).dir()
 aSketchFaces = ShapeList()
 GeomAlgoAPI_SketchBuilder.createFaces(
-    origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+    origin, dirX, norm, aSketchEdges, aSketchFaces)
 # Create extrusion on them
 aBox = aPart.addFeature("Extrusion")
 aBox.selectionList("base").append(
     aSketchResult, aSketchFaces[0])
-aBox.real("size").setValue(10)
-aBox.boolean("reverse").setValue(False)
+aBox.string("CreationMethod").setValue("BySizes")
+aBox.real("from_size").setValue(0)
+aBox.real("to_size").setValue(10)
+aBox.real("to_offset").setValue(0) #TODO: remove
+aBox.real("from_offset").setValue(0) #TODO: remove
 # v 1.0.2 from master
 # aBox.selection("extrusion_face").setValue(
 #     aSketchResult, aSketchFaces[0])
@@ -170,20 +170,28 @@ aSession.finishOperation()
 
 #=========================================================================
 # Create a boolean cut of cylinders from the box:
-# result of Boolean is the first argument of the next Boolean
 #=========================================================================
-aCurrentResult = aBox.firstResult()
+aCurrentResult = modelAPI_ResultBody(aBox.firstResult())
 aSession.startOperation()
+
+aBooleanFt = aPart.addFeature("Boolean")
+aBooleanFt.selectionList("main_objects").append(aCurrentResult, aCurrentResult.shape())
 for i in xrange(0, N * N):
-    aBooleanFt = aPart.addFeature("Boolean")
-    aBooleanFt.reference("main_object").setValue(modelAPI_ResultBody(aCurrentResult))
-    aBooleanFt.reference("tool_object").setValue(modelAPI_ResultBody(anExtrusions[i].firstResult()))
-    kBooleanTypeCut = 0
-    aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut)
-    aBooleanFt.execute()
-    aCurrentResult = aBooleanFt.firstResult()
+    anExtrusionResult = modelAPI_ResultBody(anExtrusions[i].firstResult())
+    aBooleanFt.selectionList("tool_objects").append(anExtrusionResult, anExtrusionResult.shape())
+kBooleanTypeCut = 0
+aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut)
+aBooleanFt.execute()
+aFactory = ModelAPI_Session.get().validators()
+assert (aFactory.validate(aBooleanFt))
+assert (len(aBooleanFt.results()) > 0)
+aCurrentResult = modelAPI_ResultBody(aBooleanFt.firstResult())
+assert (aCurrentResult is not None)
 aSession.finishOperation()
 
 #=========================================================================
 # End of test
 #=========================================================================
+
+from salome.shaper import model
+assert(model.checkPythonDump())