Salome HOME
Cosmetics. Move XML files to the separate folder inside a corresponding project in VS.
[modules/shaper.git] / src / SketchPlugin / Test / TestProjection.py
index 45cc13a665b52734d8d0a85f9a3576977217fb12..537dcd0dad45966ffab773f97ee27f58f5e0eeb6 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
+#
+
 """
     TestProjection.py
     Unit test of SketchPlugin_Projection class
@@ -6,6 +25,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -41,19 +62,20 @@ aLineStart.setValue(10., 10.)
 aLineEnd.setValue(40., 30.)
 
 aCircle = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("CircleCenter"))
-aCircleRadius = aCircle.real("CircleRadius")
+aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
+aCircleRadius = aCircle.real("circle_radius")
 aCircleCenter.setValue(-25., -25)
 aCircleRadius.setValue(25.)
 
 anArc = aSketchFeature.addFeature("SketchArc")
-anArcCenter = geomDataAPI_Point2D(anArc.attribute("ArcCenter"))
-anArcStart = geomDataAPI_Point2D(anArc.attribute("ArcStartPoint"))
-anArcEnd = geomDataAPI_Point2D(anArc.attribute("ArcEndPoint"))
+anArcCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+anArcStart = geomDataAPI_Point2D(anArc.attribute("start_point"))
+anArcEnd = geomDataAPI_Point2D(anArc.attribute("end_point"))
 anArcCenter.setValue(10., 10.)
 anArcStart.setValue(50., 0.)
 anArcEnd.setValue(0., 50.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
 # Create another sketch
 #=========================================================================
@@ -71,17 +93,21 @@ aSession.finishOperation()
 #=========================================================================
 aSession.startOperation()
 aLineProjector = aSketchFeature.addFeature("SketchProjection")
-aLineProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchLine_1")
+aLineProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/SketchLine_1")
+aLineProjector.boolean("IncludeToResult").setValue(False)
 aLineProjector.execute()
 
 aCircleProjector = aSketchFeature.addFeature("SketchProjection")
-aCircleProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchCircle_1_2")
+aCircleProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/SketchCircle_1_2")
+aCircleProjector.boolean("IncludeToResult").setValue(False)
 aCircleProjector.execute()
 
 anArcProjector = aSketchFeature.addFeature("SketchProjection")
-anArcProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchArc_1_2")
+anArcProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/SketchArc_1_2")
+anArcProjector.boolean("IncludeToResult").setValue(False)
 anArcProjector.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 0)
 #=========================================================================
 # Check projection coordinates
 #=========================================================================
@@ -96,16 +122,16 @@ assert(math.fabs(aProjLineEnd.y() - aLineEnd.y()) < 1.e-10)
 
 aProjCircle = ModelAPI_Feature.feature(aCircleProjector.refattr("ProjectedFeature").object())
 assert(aProjCircle)
-aProjCircleCenter = geomDataAPI_Point2D(aProjCircle.attribute("CircleCenter"))
-aProjCircleRadius = aProjCircle.real("CircleRadius")
+aProjCircleCenter = geomDataAPI_Point2D(aProjCircle.attribute("circle_center"))
+aProjCircleRadius = aProjCircle.real("circle_radius")
 assert(math.fabs(aProjCircleCenter.x() - aCircleCenter.x()) < 1.e-10)
 assert(math.fabs(aProjCircleCenter.y() - aCircleCenter.y()) < 1.e-10)
 assert(math.fabs(aProjCircleRadius.value() - aCircleRadius.value()) < 1.e-10)
 
 aProjArc = ModelAPI_Feature.feature(anArcProjector.refattr("ProjectedFeature").object())
-aProjArcCenter = geomDataAPI_Point2D(aProjArc.attribute("ArcCenter"))
-aProjArcStart = geomDataAPI_Point2D(aProjArc.attribute("ArcStartPoint"))
-aProjArcEnd = geomDataAPI_Point2D(aProjArc.attribute("ArcEndPoint"))
+aProjArcCenter = geomDataAPI_Point2D(aProjArc.attribute("center_point"))
+aProjArcStart = geomDataAPI_Point2D(aProjArc.attribute("start_point"))
+aProjArcEnd = geomDataAPI_Point2D(aProjArc.attribute("end_point"))
 assert(math.fabs(aProjArcCenter.x() - anArcCenter.x()) < 1.e-10)
 assert(math.fabs(aProjArcCenter.y() - anArcCenter.y()) < 1.e-10)
 assert(math.fabs(aProjArcStart.x() - anArcStart.x()) < 1.e-10)
@@ -122,9 +148,9 @@ assert(math.fabs(aProjLineStart.x() - aLineStart.x()) < 1.e-10)
 assert(math.fabs(aProjLineStart.y() - aLineStart.y()) < 1.e-10)
 assert(math.fabs(aProjLineEnd.x() - aLineEnd.x()) < 1.e-10)
 assert(math.fabs(aProjLineEnd.y() - aLineEnd.y()) < 1.e-10)
+assert (model.dof(aSketchFeature) == 0)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())