Salome HOME
bos #19068: Unable to quit Sketch because of conflicting constraint
[modules/shaper.git] / src / CollectionPlugin / Test / TestField.py
index 5bf10bdacc3a4cda80eb05ffe06b6e999839dd43..93bc30144e682b1933e97ecc491584fb1ea25a1d 100644 (file)
@@ -1,3 +1,22 @@
+# Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 """
       TestBoolean.py
       Unit test of FeaturesPlugin_Group class
@@ -53,21 +72,15 @@ aLineCEndPoint.setValue(-100., 0.)
 aSession.finishOperation()
 # Build sketch faces
 aSession.startOperation()
-aSketchResult = aTriangleSketchFeature.firstResult()
-aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
-origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
-dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
-norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
-aSketchFaces = ShapeList()
-GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces)
+aSketchResult = modelAPI_ResultConstruction(aTriangleSketchFeature.firstResult())
 # Create extrusion on them
 anExtrusionFt = aPart.addFeature("Extrusion")
-anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0])
+anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0))
 anExtrusionFt.string("CreationMethod").setValue("BySizes")
 anExtrusionFt.real("to_size").setValue(50)
 anExtrusionFt.real("from_size").setValue(50)
-anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
-anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("to_offset").setValue(0)
+anExtrusionFt.real("from_offset").setValue(0)
 anExtrusionFt.execute()
 aSession.finishOperation()
 anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
@@ -78,20 +91,18 @@ aSession.startOperation()
 aField = aSession.activeDocument().addFeature("Field")
 aSelectionListAttr = aField.selectionList("selected")
 aSelectionListAttr.setSelectionType("vertex")
-aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
-aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
-aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1")
+aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]")
+aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]")
+aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(2) # two components
 aComponentNames.setValue(0, "temperatue")
 aComponentNames.setValue(1, "porosity")
-aField.integer("type").setValue(2) # double
-aField.integer("steps_nb").setValue(1) # one step
 aStamps = aField.intArray("stamps")
-aStamps.setSize(1)
+aStamps.setSize(1) # one step
 aStamps.setValue(0, 10)
 aTables = aField.tables("values")
-aTables.setType(2)
+aTables.setType(2) # double
 aTables.setSize(1 + 3, 2, 1) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue(20, 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue(35, 1, 0, 0)
@@ -109,18 +120,16 @@ aSession.startOperation()
 aField = aSession.activeDocument().addFeature("Field")
 aSelectionListAttr = aField.selectionList("selected")
 aSelectionListAttr.setSelectionType("face")
-aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(1) # one component
 aComponentNames.setValue(0, "description")
-aField.integer("type").setValue(3) # string
-aField.integer("steps_nb").setValue(2) # two steps
 aStamps = aField.intArray("stamps")
-aStamps.setSize(2)
+aStamps.setSize(2) # two steps
 aStamps.setValue(0, 1)
 aStamps.setValue(1, 3)
 aTables = aField.tables("values")
-aTables.setType(3)
+aTables.setType(3) # string
 aTables.setSize(1 + 1, 1, 2) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue("-default-", 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue("-default-", 0, 0, 1)
@@ -137,17 +146,15 @@ aSession.startOperation()
 aField = aSession.activeDocument().addFeature("Field")
 aSelectionListAttr = aField.selectionList("selected")
 aSelectionListAttr.setSelectionType("face")
-aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(1) # one component
 aComponentNames.setValue(0, "description")
-aField.integer("type").setValue(1) # integer
-aField.integer("steps_nb").setValue(1) # one step
 aStamps = aField.intArray("stamps")
-aStamps.setSize(1)
+aStamps.setSize(1) # one step
 aStamps.setValue(0, 0)
 aTables = aField.tables("values")
-aTables.setType(1)
+aTables.setType(1) # integer
 aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue(0, 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue(2, 1, 0, 0)
@@ -163,17 +170,15 @@ aSession.startOperation()
 aField = aSession.activeDocument().addFeature("Field")
 aSelectionListAttr = aField.selectionList("selected")
 aSelectionListAttr.setSelectionType("face")
-aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")
 aComponentNames = aField.stringArray("components_names")
 aComponentNames.setSize(1) # one component
 aComponentNames.setValue(0, "description")
-aField.integer("type").setValue(0) # boolean
-aField.integer("steps_nb").setValue(1) # one step
 aStamps = aField.intArray("stamps")
-aStamps.setSize(1)
+aStamps.setSize(1) # one step
 aStamps.setValue(0, 0)
 aTables = aField.tables("values")
-aTables.setType(0)
+aTables.setType(0) # boolean
 aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables)
 aTables.setValue(True, 0, 0, 0) # value, index of selection, index of component, index of step
 aTables.setValue(False, 1, 0, 0)
@@ -182,5 +187,5 @@ aSession.finishOperation()
 aFieldResult = aField.firstResult()
 assert(aFieldResult)
 
-import model
+from salome.shaper import model
 assert(model.checkPythonDump())