]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage SketchPlugin]: Increase coverage for Distance, Trim and Split features
authorazv <azv@opencascade.com>
Tue, 4 Dec 2018 15:53:12 +0000 (18:53 +0300)
committerazv <azv@opencascade.com>
Tue, 4 Dec 2018 15:53:12 +0000 (18:53 +0300)
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestPresentation.py
src/SketchPlugin/Test/TestSplitPreview.py
src/SketchPlugin/Test/TestTrimArc08.py [new file with mode: 0644]
src/SketchPlugin/Test/TestTrimPreview.py

index ce0c7406a6330aea25035c13185391c3700e6d3e..4d399b188090ce51d567115fe91b4325d159a906 100644 (file)
@@ -264,6 +264,7 @@ ADD_UNIT_TESTS(
   TestTrimArc05.py
   TestTrimArc06.py
   TestTrimArc07.py
+  TestTrimArc08.py
   TestTrimCircle01.py
   TestTrimCircle02.py
   TestTrimCircle03.py
index 46ce2e4d1cba0c4bf6125b3f467242c37fda21dd..a36c178353a9361934a68e79014a50e6157ce53f 100644 (file)
@@ -171,6 +171,25 @@ assert (refattrB.isInitialized())
 assert (aDistance.isInitialized())
 assert math.fabs(aDistance.value() - aDist) < 1.e-4, "Distance values are different: {0} != {1}".format(aDistance.value(), aDist)
 assert (model.dof(aSketchFeature) == 5)
+
+#=========================================================================
+# Swap point and line in the distance
+#=========================================================================
+aSession.startOperation()
+refattrA.setAttr(aSketchPointCoords)
+refattrB.setObject(aLineResult)
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
+# set flyout point then abort operation, after that check the Distance is correct
+aSession.startOperation()
+aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
+aFlyoutPoint.setValue(100.0, 100.0)
+aSession.abortOperation()
+assert (refattrA.isInitialized())
+assert (refattrB.isInitialized())
+assert (aDistance.isInitialized())
+assert math.fabs(aDistance.value() - aDist) < 1.e-4, "Distance values are different: {0} != {1}".format(aDistance.value(), aDist)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Change distance value
 #=========================================================================
index 499d97ad2f4df9fff01d0acae36d7e0c320ad319..f4ebf9eb53d6a497ef39d5f9e0aa0816bc3294d9 100644 (file)
 
 """
     TestPresentation.py
-    Test AIS presentations for constraints
+    Test AIS presentations for constraints and macro-features
 """
 
 from salome.shaper import model
 from GeomAPI import *
 from ModelAPI import *
+from GeomDataAPI import *
 
 from ConfigAPI import *
 Config_PropManager().registerProp("Visualization", "dimension_value_size", "Dimension value size", Config_Prop.IntSpin, "16")
@@ -98,4 +99,32 @@ aFillet.refattr("fillet_point").setAttr(SketchLine_1.endPoint());
 assert(featureToPresentation(aFillet).getAISObject(None) is not None)
 aSession.finishOperation()
 
+# Test presentation for MacroCircle on low-level
+aSession.startOperation()
+aCircle = aSketchFeature.addFeature("SketchMacroCircle")
+aCirclePnt1 = geomDataAPI_Point2D(aCircle.attribute("first_point"))
+aCirclePnt2 = geomDataAPI_Point2D(aCircle.attribute("second_point"))
+aCirclePnt3 = geomDataAPI_Point2D(aCircle.attribute("third_point"))
+aCircleType = aCircle.string("circle_type")
+aCircleType.setValue("circle_type_by_three_points")
+aCirclePnt1.setValue(10, 0)
+aCirclePnt2.setValue(-10, 0)
+aCirclePnt3.setValue(0, 10)
+assert(featureToPresentation(aCircle).getAISObject(None) is not None)
+aSession.finishOperation()
+
+# Test presentation for MacroArc on low-level
+aSession.startOperation()
+anArc = aSketchFeature.addFeature("SketchMacroArc")
+anArcPnt1 = geomDataAPI_Point2D(anArc.attribute("start_point_2"))
+anArcPnt2 = geomDataAPI_Point2D(anArc.attribute("end_point_2"))
+anArcPnt3 = geomDataAPI_Point2D(anArc.attribute("passed_point"))
+anArcType = anArc.string("arc_type")
+anArcType.setValue("by_three_points")
+anArcPnt1.setValue(5, 0)
+anArcPnt2.setValue(-5, 0)
+anArcPnt3.setValue(0, 5)
+assert(featureToPresentation(anArc).getAISObject(None) is not None)
+aSession.finishOperation()
+
 model.end()
index ac59f961343baf4ae122c606101b2408ff081815..c4bb13798441639e4ecd4b0799a8e88a09beea4b 100644 (file)
@@ -62,6 +62,7 @@ aPreviewObj = aSplit.reference("PreviewObject")
 aPreviewObj.setValue(SketchLine_1.feature())
 aPreviewPoint = geomDataAPI_Point2D(aSplit.attribute("PreviewPoint"))
 aPreviewPoint.setValue(aSelectedPoint.pnt())
+assert(featureToPresentation(aSplit).getAISObject(None) is not None)
 aSession.finishOperation()
 
 model.testNbSubFeatures(Sketch, "SketchArc", 0)
@@ -80,6 +81,7 @@ aPreviewObj = aSplit.reference("PreviewObject")
 aPreviewObj.setValue(SketchCircle_1.feature())
 aPreviewPoint = geomDataAPI_Point2D(aSplit.attribute("PreviewPoint"))
 aPreviewPoint.setValue(aSelectedPoint.pnt())
+assert(featureToPresentation(aSplit).getAISObject(None) is not None)
 aSession.finishOperation()
 
 model.testNbSubFeatures(Sketch, "SketchArc", 2)
diff --git a/src/SketchPlugin/Test/TestTrimArc08.py b/src/SketchPlugin/Test/TestTrimArc08.py
new file mode 100644 (file)
index 0000000..fbf2584
--- /dev/null
@@ -0,0 +1,68 @@
+## Copyright (C) 2018-20xx  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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+from salome.shaper import geom
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(12, -8, -12, -8)
+SketchLine_2 = Sketch_1.addLine(-12, -8, -12, 20)
+SketchLine_3 = Sketch_1.addLine(-12, 20, 12, 20)
+SketchLine_4 = Sketch_1.addLine(12, 20, 12, -8)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchArc_1 = Sketch_1.addArc(0, -3, 20, -3, -20, -3, False)
+SketchLine_5 = Sketch_1.addLine(20, -3, 20, -30)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_5.startPoint())
+SketchLine_6 = Sketch_1.addLine(20, 17, 50, 17)
+SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_5.result(), SketchArc_1.results()[1])
+SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_6.result(), SketchArc_1.results()[1])
+model.do()
+
+model.testNbSubFeatures(Sketch_1, "SketchArc", 1)
+model.testNbSubFeatures(Sketch_1, "SketchLine", 6)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 5)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintTangent", 2)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintEqual", 0)
+
+# perform trim
+SketchTrim = Sketch_1.addTrim(SketchArc_1, geom.Pnt2d(0, 17))
+SketchTrim.execute()
+model.do()
+
+model.testNbSubFeatures(Sketch_1, "SketchArc", 2)
+model.testNbSubFeatures(Sketch_1, "SketchLine", 6)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 8)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintTangent", 2)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintEqual", 1)
+
+model.end()
+
+assert(model.checkPythonDump())
index 8f5a641a4e4cfaba2dd7a13a2b351a10f790083c..0f018cf18e6afb5aff562966af02d1d5ca9a9ff2 100644 (file)
@@ -50,6 +50,7 @@ aPreviewObj = aTrim.reference("PreviewObject")
 aPreviewObj.setValue(SketchLine_1.feature())
 aPreviewPoint = geomDataAPI_Point2D(aTrim.attribute("PreviewPoint"))
 aPreviewPoint.setValue(aSelectedPoint.pnt())
+assert(featureToPresentation(aTrim).getAISObject(None) is not None)
 aSession.finishOperation()
 
 model.testNbSubFeatures(Sketch, "SketchArc", 0)
@@ -68,6 +69,7 @@ aPreviewObj = aTrim.reference("PreviewObject")
 aPreviewObj.setValue(SketchCircle_1.feature())
 aPreviewPoint = geomDataAPI_Point2D(aTrim.attribute("PreviewPoint"))
 aPreviewPoint.setValue(aSelectedPoint.pnt())
+assert(featureToPresentation(aTrim).getAISObject(None) is not None)
 aSession.finishOperation()
 
 model.testNbSubFeatures(Sketch, "SketchArc", 1)