]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchPlugin/Test/TestCreateCircleChangeType.py
Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / Test / TestCreateCircleChangeType.py
index 92998894a1c3bd1c9bc40be92742c7cb58121492..803561bfc96db13ddb5b8370f7261d8efd164206 100644 (file)
@@ -1,3 +1,22 @@
+# Copyright (C) 2014-2023  CEA, EDF
+#
+# 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
+#
+
 """
     TestCreateCircleChangeType.py
 
@@ -23,9 +42,7 @@ __updated__ = "2017-03-22"
 
 def assertNotInitializedByCenterAndPassed(theMacroCircle):
     # check points
-    aCenterPoint = geomDataAPI_Point2D(theMacroCircle.attribute("center_point"))
     aPassedPoint = geomDataAPI_Point2D(theMacroCircle.attribute("passed_point"))
-    assert (not aCenterPoint.isInitialized())
     assert (not aPassedPoint.isInitialized())
     # check references
     aCenterPointRef = theMacroCircle.refattr("center_point_ref")
@@ -49,8 +66,12 @@ def assertNotInitializedByThreePoints(theMacroCircle):
     assert (not aSecondPointRef.isInitialized())
     assert (not aThirdPointRef.isInitialized())
 
-def distancePointPoint(thePoint1, thePoint2):
-    return thePoint1.pnt().distance(thePoint2.pnt())
+def verifyLastCircle(theSketch, theX, theY, theR):
+    """
+    subroutine to verify position of last circle in the sketch
+    """
+    aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
+    model.assertCircle(aLastCircle, [theX, theY], theR)
 
 
 #=========================================================================
@@ -159,8 +180,9 @@ aPassedPointRef.setAttr(aLineEnd)
 aPassedPoint.setValue(aLineEnd.pnt())
 aSession.finishOperation()
 
-aRadius = distancePointPoint(aLineStart, aLineEnd)
-assert (aSketchFeature.numberOfSubs() == 2)
+aRadius = model.distancePointPoint(aLineStart, aLineEnd)
+NB_FEATURES_EXPECTED = 4 # line, circle and two coincidences
+assert (aSketchFeature.numberOfSubs() == NB_FEATURES_EXPECTED), "Number of features in sketch {}, expected {}".format(aSketchFeature.numberOfSubs(), NB_FEATURES_EXPECTED)
 verifyLastCircle(aSketchFeature, aLineStart.x(), aLineStart.y(), aRadius)
 
 #=========================================================================