]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update Arc unit test
authorazv <azv@opencascade.com>
Thu, 6 Apr 2017 11:27:08 +0000 (14:27 +0300)
committerazv <azv@opencascade.com>
Thu, 6 Apr 2017 11:27:08 +0000 (14:27 +0300)
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py
src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py
src/SketchPlugin/Test/TestCreateCircleByThreePoints.py

index d9aa0c5dadc288890e78120859c019649ed80c3c..9316f34233b939c61ec30b3e3d314d91429299aa 100644 (file)
@@ -127,9 +127,9 @@ INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
 
 ADD_UNIT_TESTS(TestSketchPointLine.py
                TestCreateArcByCenterStartEnd.py
-               TestCreateArcByThreePoints.py
-               TestCreateArcByTangentEdge.py
-               TestCreateArcChangeType.py
+               TestCreateArcByThreePoints.py
+               TestCreateArcByTangentEdge.py
+               TestCreateArcChangeType.py
                TestCreateCircleByCenterAndPassed.py
                TestCreateCircleByThreePoints.py
                TestCreateCircleChangeType.py
index 5cbe2fafb90255cf4ac446b32f669312d3037e9f..4f01b367fdd608328bf0fff5b9700fd84301f995 100644 (file)
@@ -15,6 +15,7 @@
 #=========================================================================
 from GeomDataAPI import *
 from ModelAPI import *
+from SketchAPI import SketchAPI_Sketch
 import math
 from salome.shaper import model
 
@@ -61,6 +62,7 @@ dirx.setValue(1, 0, 0)
 norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
+aSketch = SketchAPI_Sketch(aSketchFeature)
 
 #=========================================================================
 # Test 1. Create an arc by center, start and end points
@@ -118,6 +120,137 @@ aSession.finishOperation()
 assert (math.fabs(anArcAngle.value() - aPrevAngle) < TOLERANCE)
 verifyLastArc(aSketchFeature, [], [], [])
 
+#=========================================================================
+# Test 2. Create an arc as a macro-feature by center, start and end points
+#=========================================================================
+aSession.startOperation()
+anArc = aSketchFeature.addFeature("SketchMacroArc")
+assert (anArc.getKind() == "SketchMacroArc")
+anArcCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+assert (not anArcCenter.isInitialized())
+anArcStart = geomDataAPI_Point2D(anArc.attribute("start_point_1"))
+assert (not anArcStart.isInitialized())
+anArcEnd = geomDataAPI_Point2D(anArc.attribute("end_point_1"))
+assert (not anArcEnd.isInitialized())
+anArcType = anArc.string("arc_type")
+assert (not anArcType.isInitialized())
+anArcType.setValue("by_center_and_points")
+anArcCenter.setValue(aCenter[0], aCenter[1])
+anArcStart.setValue(aStart[0], aStart[1])
+anArcEnd.setValue(aEnd[0], aEnd[1])
+aSession.finishOperation()
+assert (aSketchFeature.numberOfSubs() == 2)
+verifyLastArc(aSketchFeature, [], [], [])
+
+#=========================================================================
+# Test 3. Create an arc by center and two points coincident to other points
+#=========================================================================
+# get previous arc
+aPrevArc = model.lastSubFeature(aSketchFeature, "SketchArc")
+aPrevArcStart = geomDataAPI_Point2D(aPrevArc.attribute("start_point"))
+aPrevArcEnd = geomDataAPI_Point2D(aPrevArc.attribute("end_point"))
+# create additional point
+aPointCoordinates = [0., 0.]
+aSession.startOperation()
+aPoint = aSketchFeature.addFeature("SketchPoint")
+aPointCoord = geomDataAPI_Point2D(aPoint.attribute("PointCoordinates"))
+aPointCoord.setValue(aPointCoordinates[0], aPointCoordinates[1])
+aPoint.selection("External").selectSubShape("VERTEX", "Origin")
+aSession.finishOperation()
+# create additional line
+aLineStart = [20., -5.]
+aLineEnd = [20., 20]
+aSession.startOperation()
+aLine = aSketchFeature.addFeature("SketchLine")
+aLineStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+aLineStartPoint.setValue(aLineStart[0], aLineStart[1])
+aLineEndPoint.setValue(aLineEnd[0], aLineEnd[1])
+aSession.finishOperation()
+# create new arc
+aSession.startOperation()
+anArc = aSketchFeature.addFeature("SketchMacroArc")
+aCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+aCenterRef = anArc.refattr("center_point_ref")
+assert (not aCenterRef.isInitialized())
+aStart = geomDataAPI_Point2D(anArc.attribute("start_point_1"))
+aStartRef = anArc.refattr("start_point_ref")
+assert (not aStartRef.isInitialized())
+aEnd = geomDataAPI_Point2D(anArc.attribute("end_point_1"))
+aEndRef = anArc.refattr("end_point_ref")
+assert (not aEndRef.isInitialized())
+anArcType = anArc.string("arc_type")
+assert (not anArcType.isInitialized())
+# initialize attributes
+anArcType.setValue("by_center_and_points")
+aCenterRef.setAttr(aPrevArcStart)
+aCenter.setValue(aPrevArcStart.pnt())
+aStartRef.setObject(aPoint.lastResult())
+aStart.setValue(aPointCoord.pnt())
+aEndRef.setAttr(aPrevArcEnd)
+aEnd.setValue(aPrevArcEnd.pnt())
+aSession.finishOperation()
+# check the MacroArc is not valid (selection of end point is not possible)
+aLastFeature = aSketchFeature.subFeature(aSketchFeature.numberOfSubs() - 1)
+assert aLastFeature.getKind() == "SketchMacroArc", "ERROR: SketchMacroArc has NOT expected to be valid"
+# change end point reference to a line
+aSession.startOperation()
+aEndRef.setObject(aLine.lastResult())
+aEnd.setValue(aLineStart[0], aLineStart[1])
+aSession.finishOperation()
+assert (aSketchFeature.numberOfSubs() == 8), "Number of subs {}".format(aSketchFeature.numberOfSubs())
+verifyPointCoordinates(aPointCoord, aPointCoordinates[0], aPointCoordinates[1])
+verifyLastArc(aSketchFeature, [aPrevArcStart.x(), aPrevArcStart.y()], aPointCoordinates, [])
+model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 3)
+
+#=========================================================================
+# Test 4. Create an arc by center and points coincident to other features
+#=========================================================================
+# get previous arc
+aPrevArc = model.lastSubFeature(aSketchFeature, "SketchArc")
+aPrevArcCenter = geomDataAPI_Point2D(aPrevArc.attribute("center_point"))
+aPrevArcStart = geomDataAPI_Point2D(aPrevArc.attribute("start_point"))
+aPrevArcEnd = geomDataAPI_Point2D(aPrevArc.attribute("end_point"))
+aPrevArcCenterXY = [aPrevArcCenter.x(), aPrevArcCenter.y()]
+aPrevArcStartXY = [aPrevArcStart.x(), aPrevArcStart.y()]
+aPrevArcEndXY = [aPrevArcEnd.x(), aPrevArcEnd.y()]
+# create new arc
+aSession.startOperation()
+anArc = aSketchFeature.addFeature("SketchMacroArc")
+aCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+aCenterRef = anArc.refattr("center_point_ref")
+aStart = geomDataAPI_Point2D(anArc.attribute("start_point_1"))
+aStartRef = anArc.refattr("start_point_ref")
+aEnd = geomDataAPI_Point2D(anArc.attribute("end_point_1"))
+aEndRef = anArc.refattr("end_point_ref")
+anArcType = anArc.string("arc_type")
+# initialize attributes
+anArcType.setValue("by_center_and_points")
+aCenterRef.setObject(aLine.lastResult())
+aCenter.setValue(aLineStartPoint.pnt())
+aStartRef.setObject(aPrevArc.lastResult())
+aStart.setValue(aPrevArcStart.pnt())
+aEndRef.setObject(aLine.lastResult())
+aEnd.setValue(aLineEndPoint.pnt())
+aSession.finishOperation()
+assert (aSketchFeature.numberOfSubs() == 12), "Number of subs {}".format(aSketchFeature.numberOfSubs())
+# check connected features do not change their positions
+verifyPointCoordinates(aPrevArcCenter, aPrevArcCenterXY[0], aPrevArcCenterXY[1])
+verifyPointCoordinates(aPrevArcStart, aPrevArcStartXY[0], aPrevArcStartXY[1])
+verifyPointCoordinates(aPrevArcEnd, aPrevArcEndXY[0], aPrevArcEndXY[1])
+verifyPointCoordinates(aLineStartPoint, aLineStart[0], aLineStart[1])
+verifyPointCoordinates(aLineEndPoint, aLineEnd[0], aLineEnd[1])
+# verify newly created arc
+anArc = model.lastSubFeature(aSketchFeature, "SketchArc")
+aCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+aStart = geomDataAPI_Point2D(anArc.attribute("start_point"))
+aEnd = geomDataAPI_Point2D(anArc.attribute("end_point"))
+verifyPointOnLine(aCenter, aLine)
+verifyPointOnLine(aEnd, aLine)
+verifyPointOnCircle(aStart, aPrevArc)
+model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 6)
+model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0)
+
 #=========================================================================
 # End of test
 #=========================================================================
index 35f55de79ea8ed822c220c1f2de6a493fbb5edde..a7b453b74ab4718c2822726fb2d86829f133aae6 100644 (file)
@@ -136,11 +136,11 @@ verifyLastCircle(aSketchFeature, -25., -25., aRadius)
 aPrevCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 aPrevCenter = geomDataAPI_Point2D(aPrevCircle.attribute("circle_center"))
 # create additional point
-aPointCoodinates = [0., 0.]
+aPointCoordinates = [0., 0.]
 aSession.startOperation()
 aPoint = aSketchFeature.addFeature("SketchPoint")
 aPointCoord = geomDataAPI_Point2D(aPoint.attribute("PointCoordinates"))
-aPointCoord.setValue(aPointCoodinates[0], aPointCoodinates[1])
+aPointCoord.setValue(aPointCoordinates[0], aPointCoordinates[1])
 aSession.finishOperation()
 # create new circle
 aSession.startOperation()
@@ -162,7 +162,7 @@ aPassed.setValue(aPrevCenter.pnt())
 aRadius = model.distancePointPoint(aPrevCenter, aPointCoord)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 6)
-verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
+verifyPointCoordinates(aPointCoord, aPointCoordinates[0], aPointCoordinates[1])
 verifyLastCircle(aSketchFeature, aPointCoord.x(), aPointCoord.y(), aRadius)
 model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 2)
 
index 8998bb931eac0e5f4524e1b8f1742f7ab07b8e46..ddee805b2f7b77ab972ba6a43ab0ee3da32959ac 100644 (file)
@@ -132,13 +132,13 @@ aPrevCenter = geomDataAPI_Point2D(aPrevCircle.attribute("circle_center"))
 aPrevCenterXY = [aPrevCenter.x(), aPrevCenter.y()]
 aPrevCircleRadius = aPrevCircle.real("circle_radius").value()
 # create additional point and line
-aPointCoodinates = [5., 20.]
+aPointCoordinates = [5., 20.]
 aLineStart = [10., 0.]
 aLineEnd = [10., 50.]
 aSession.startOperation()
 aPoint = aSketchFeature.addFeature("SketchPoint")
 aPointCoord = geomDataAPI_Point2D(aPoint.attribute("PointCoordinates"))
-aPointCoord.setValue(aPointCoodinates[0], aPointCoodinates[1])
+aPointCoord.setValue(aPointCoordinates[0], aPointCoordinates[1])
 aLine = aSketchFeature.addFeature("SketchLine")
 aStartPnt = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
 aStartPnt.setValue(aLineStart[0], aLineStart[1])
@@ -167,7 +167,7 @@ aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 7)
 # check the points do not change their positions
 verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
-verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
+verifyPointCoordinates(aPointCoord, aPointCoordinates[0], aPointCoordinates[1])
 verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
 # check newly created circle passes through the points
 aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")