TestTrimArc05.py
TestTrimArc06.py
TestTrimArc07.py
+ TestTrimArc08.py
TestTrimCircle01.py
TestTrimCircle02.py
TestTrimCircle03.py
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
#=========================================================================
"""
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")
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()
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)
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)
--- /dev/null
+## 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())
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)
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)