Salome HOME
Cosmetics. Move XML files to the separate folder inside a corresponding project in VS.
[modules/shaper.git] / src / SketchPlugin / Test / TestConstraintMiddlePoint.py
index b9b0e70b7b802bd7223695aac0df100fc826100f..e5673eff5a4629ac4820879ac57497c3fff385e5 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
+#
+
 """
     TestConstraintCoincidence.py
     Unit test of SketchPlugin_ConstraintCoincidence class
@@ -19,6 +38,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -45,10 +66,8 @@ aDocument = aSession.moduleDocument()
 # add an origin
 aSession.startOperation()
 aFeature = aDocument.addFeature("Point")
-# aFeature.string("creation_method").setValue("by_xyz")
-aFeature.real("x").setValue(0.)
-aFeature.real("y").setValue(0.)
-aFeature.real("z").setValue(0.)
+geomDataAPI_Point(aFeature.attribute("point3d")).setValue(0., 0., 0.)
+aFeature.string("creation_method").setValue("by_xyz")
 anOriginName = aFeature.name()
 aSession.finishOperation()
 #=========================================================================
@@ -78,6 +97,7 @@ aEndPoint2 = geomDataAPI_Point2D(aLine2.attribute("EndPoint"))
 aStartPoint2.setValue(10., 100.)
 aEndPoint2.setValue(100., 25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Make end point of second line middle point on first line
 #=========================================================================
@@ -106,6 +126,7 @@ reflistA.setAttr(aEndPoint2)
 reflistB.setObject(aLine1.lastResult())
 aConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 6)
 
 #=========================================================================
 # Check values and move one constrainted object
@@ -116,6 +137,7 @@ aSession.startOperation()
 aStartPoint1.setValue(aStartPoint1.x() + deltaX, aStartPoint1.y() + deltaY)
 aSession.finishOperation()
 checkMiddlePoint(aEndPoint2, aLine1)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Remove constraint and move the line
 #=========================================================================
@@ -123,10 +145,12 @@ aCurX, aCurY = aEndPoint2.x(), aEndPoint2.y()
 aSession.startOperation()
 aDocument.removeFeature(aConstraint)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 aSession.startOperation()
 aEndPoint1.setValue(90., 0.)
 aSession.finishOperation()
 assert (aEndPoint2.x() == aCurX and aEndPoint2.y() == aCurY)
+assert (model.dof(aSketchFeature) == 8)
 
 #=========================================================================
 # Set external point as a middle point
@@ -138,10 +162,11 @@ assert (anOrigRes)
 anOrigShape = anOrigRes.shape()
 assert (anOrigShape)
 anOrigin = aSketchFeature.addFeature("SketchPoint")
-anOriginCoord = geomDataAPI_Point2D(anOrigin.attribute("PointCoordindates"))
+anOriginCoord = geomDataAPI_Point2D(anOrigin.attribute("PointCoordinates"))
 anOriginCoord.setValue(0., 0.)
 anOrigin.selection("External").setValue(anOrigRes, anOrigShape)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 # middle point constraint
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintMiddle")
@@ -151,6 +176,7 @@ reflistA.setObject(aLine2.lastResult())
 reflistB.setObject(anOrigin.lastResult())
 aSession.finishOperation()
 checkMiddlePoint(anOriginCoord, aLine2)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Check origin coordinates does not changed
 #=========================================================================
@@ -171,6 +197,7 @@ reflistB = aCoincidence.refattr("ConstraintEntityB")
 reflistA.setAttr(aEndPoint3)
 reflistB.setObject(aLine1.lastResult())
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Set Middle point
 #=========================================================================
@@ -183,6 +210,7 @@ reflistB.setObject(aLine1.lastResult())
 aSession.finishOperation()
 # check the point, and no error message
 assert aSketchFeature.string("SolverError").value() == ""
+assert (model.dof(aSketchFeature) == 8)
 checkMiddlePoint(aEndPoint3, aLine1)
 #=========================================================================
 # Remove coincidence and move one line
@@ -196,10 +224,10 @@ aStartPoint1.setValue(aStartPoint1.x() + deltaX, aStartPoint1.y() + deltaY)
 aEndPoint1.setValue(aEndPoint1.x() + deltaX, aEndPoint1.y() + deltaY)
 aSession.finishOperation()
 checkMiddlePoint(aEndPoint3, aLine1)
+assert (model.dof(aSketchFeature) == 8)
 
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())