}
-void ModelAPI_CompositeFeature::exchangeIDs(
- std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
-{
- // by default nothing is in the implementation
-}
-
void ModelAPI_CompositeFeature::erase()
{
// erase all sub-features
/// structures of the owner (the remove from the document will be done outside just after)
virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
- /// Exchanges IDs of two given features: needed for more correct naming in some cases (issue 769)
- MODELAPI_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
- std::shared_ptr<ModelAPI_Feature> theFeature2);
-
/// in addition removes all subs
MODELAPI_EXPORT virtual void erase();
};
TestConstraintParallel.py
TestConstraintPerpendicular.py
TestConstraintRadius.py
+ TestConstraintRadiusFailure.py
TestConstraintTangent.py
TestConstraintVertical.py
TestCreateArcByCenterStartEnd.py
TestRemoveSketch.py
TestSignedDistancePointLine.py
TestSignedDistancePointPoint.py
+ TestSketchDrawer.py
TestSketchPointLine.py
TestSnowflake.py
TestSplit.py
+ TestSplitLine.py
+ TestSplitPreview.py
TestTrimArc01.py
TestTrimArc02.py
TestTrimArc03.py
TestTrimCircleAndArc01.py
TestTrimLine01.py
TestTrimLine02.py
- TestSketchDrawer.py
+ TestTrimLine03.py
+ TestTrimPreview.py
)
if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE})
return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
}
-
-void SketchPlugin_Sketch::exchangeIDs(
- std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
-{
- reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2);
-}
SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
- /// Exchanges IDs of two given features: needed for fillet feature better naming (issue 769)
- SKETCHPLUGIN_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
- std::shared_ptr<ModelAPI_Feature> theFeature2);
-
-
/// \brief Create a result for the point in the attribute if the attribute is initialized
/// \param theFeature a source feature
/// \param theSketch a sketch intance
return aBaseShape;
}
-std::shared_ptr<GeomDataAPI_Point2D> SketchPlugin_Split::getPointOfRefAttr(
- const AttributePtr& theAttribute)
-{
- AttributePoint2DPtr aPointAttribute;
-
- if (theAttribute->attributeType() == ModelAPI_AttributeRefAttr::typeId()) {
- AttributeRefAttrPtr aRefAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (aRefAttr.get() && aRefAttr->isInitialized()) {
- AttributePtr anAttribute = aRefAttr->attr();
- if (anAttribute.get() && anAttribute->attributeType() == GeomDataAPI_Point2D::typeId())
- aPointAttribute = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttribute);
- }
- }
- return aPointAttribute;
-}
-
void SketchPlugin_Split::getFeaturePoints(const FeaturePtr& theFeature,
AttributePoint2DPtr& theStartPointAttr,
AttributePoint2DPtr& theEndPointAttr)
return aResult;
}
+#ifdef _DEBUG
std::set<std::shared_ptr<ModelAPI_Attribute> > SketchPlugin_Split::getEdgeAttributes(
const std::shared_ptr<ModelAPI_Feature>& theFeature)
{
return anAttributes;
}
+#endif
std::shared_ptr<GeomDataAPI_Point2D> SketchPlugin_Split::getPointAttribute
(const bool isFirstAttribute)
std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr);
- /// Returns cast of attribute to geometrical point if the attribute is a ref attr attribute
- /// \param theAttribute an attribute
- /// \param geom point 2D or NULL
- std::shared_ptr<GeomDataAPI_Point2D> getPointOfRefAttr(const AttributePtr& theAttribute);
-
/// Obtains those constraints of the feature that should be modified. output maps contain
/// point of coincidence and attribute id to be modified after split
/// \param theFeaturesToDelete [out] constrains that will be deleted after split
if (aModifiedAttribute.get() && aSourceAttribute.get())
aModifiedAttribute->setValue(aSourceAttribute->value());
}
- else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
- AttributeRefAttrPtr aRefAttributeToFill = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theModifiedAttribute);
- AttributeRefAttrPtr aSourceRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theSourceAttribute);
- if (!aSourceRefAttr.get())
- aRefAttributeToFill->setAttr(theSourceAttribute);
- else {
- if (aSourceRefAttr->isObject())
- aRefAttributeToFill->setObject(aSourceRefAttr->object());
- else
- aRefAttributeToFill->setAttr(aSourceRefAttr->attr());
- }
- }
}
FeaturePtr SketchPlugin_Trim::createLineFeature(const FeaturePtr& theBaseFeature,
--- /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
+
+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(-30, 0, -10, 0)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchLine_1.result(), 20)
+model.do()
+
+assert(SketchConstraintRadius_1.feature().error() != "")
+
+model.end()
model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 6)
model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0)
+#=========================================================================
+# Test 5. Create another arc by center and points coincident to other features
+#=========================================================================
+# 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(aLine.lastResult())
+aStart.setValue(aLineEndPoint.pnt())
+aEndRef.setObject(aPrevArc.lastResult())
+aEnd.setValue(aPrevArcStart.pnt())
+aSession.finishOperation()
+assert (aSketchFeature.numberOfSubs() == 16), "Number of subs {}".format(aSketchFeature.numberOfSubs())
+# check connected features do not change their positions
+model.assertArc(aPrevArc, aPrevArcCenterXY, aPrevArcStartXY, aPrevArcEndXY)
+model.assertLine(aLine, aLineStart, aLineEnd)
+# 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(aStart, aLine)
+verifyPointOnCircle(aEnd, aPrevArc)
+model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 9)
+model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0)
+
+#=========================================================================
+# Test 6. Create one more 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")
+delta = [aPrevArcEndXY[0] - aPrevArcCenterXY[0], aPrevArcEndXY[1] - aPrevArcCenterXY[1]]
+aCenter.setValue(aPrevArcCenterXY[0] + 2 * delta[0], aPrevArcCenterXY[1] + 2 * delta[1])
+aStart.setValue(aPrevArcCenterXY[0] + 2 * delta[0] - 0.9 * delta[1], aPrevArcCenterXY[1] + 2 * delta[1] + 0.9 * delta[0])
+aEndRef.setObject(aPrevArc.lastResult())
+aEnd.setValue(aPrevArcCenterXY[0] + 1.1 * delta[0], aPrevArcCenterXY[1] + 1.1 * delta[1])
+aSession.finishOperation()
+assert (aSketchFeature.numberOfSubs() == 18), "Number of subs {}".format(aSketchFeature.numberOfSubs())
+# 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"))
+verifyPointOnCircle(aEnd, aPrevArc)
+model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 10)
+model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0)
+
+#=========================================================================
+# Test 7. Create one more arc by center and points coincident to other features
+#=========================================================================
+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")
+delta = [aPrevArcEndXY[0] - aPrevArcCenterXY[0], aPrevArcEndXY[1] - aPrevArcCenterXY[1]]
+aCenter.setValue(aPrevArcCenterXY[0] + 2 * delta[0], aPrevArcCenterXY[1] + 2 * delta[1])
+aStart.setValue(aPrevArcCenterXY[0] + 2 * delta[0] - delta[1], aPrevArcCenterXY[1] + 2 * delta[1] + delta[0])
+aEndRef.setObject(aPrevArc.lastResult())
+aEnd.setValue(aPrevArcCenterXY[0] + delta[0], aPrevArcCenterXY[1] + delta[1])
+aSession.finishOperation()
+assert (aSketchFeature.numberOfSubs() == 20), "Number of subs {}".format(aSketchFeature.numberOfSubs())
+# 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"))
+verifyPointOnCircle(aEnd, aPrevArc)
+model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 11)
+model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0)
+
#=========================================================================
# End of test
#=========================================================================
--- /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 SketchAPI import *
+
+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(-38.2842712474619, 18.28427124746191, -10, -10)
+SketchLine_2 = Sketch_1.addLine(-10, -10, -10, 20)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(-10, 20, -25, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40)
+SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()])
+[SketchLine_4, SketchLine_5] = SketchConstraintMirror_1.mirrored()
+model.do()
+
+model.testNbSubFeatures(Sketch_1, "SketchLine", 5)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 3)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 1)
+
+#perform split
+SketchSplit = Sketch_1.addSplit(SketchLine_1, geom.Pnt2d(-12, -8))
+SketchSplit.execute()
+model.do()
+
+model.testNbSubFeatures(Sketch_1, "SketchLine", 6)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 5)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 0)
+
+model.end()
+
+assert(model.checkPythonDump())
--- /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 ModelAPI import *
+from GeomDataAPI import *
+
+# base sketch
+model.begin()
+partSet = model.moduleDocument()
+Part = model.addPart(partSet)
+Part_doc = Part.document()
+Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch.addLine(0, 20, 100, 20)
+SketchLine_2 = Sketch.addLine(20, 0, 20, 40)
+SketchLine_3 = Sketch.addLine(80, 0, 80, 40)
+SketchCircle_1 = Sketch.addCircle(50, 50, 50)
+SketchPoint_1 = Sketch.addPoint(20, 20)
+SketchConstraintCoincidence_1 = Sketch.setCoincident(SketchPoint_1.coordinates(), SketchLine_2.result())
+SketchConstraintCoincidence_2 = Sketch.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result())
+SketchPoint_2 = Sketch.addPoint(80, 20)
+SketchConstraintCoincidence_3 = Sketch.setCoincident(SketchPoint_2.coordinates(), SketchLine_1.result())
+SketchConstraintCoincidence_4 = Sketch.setCoincident(SketchPoint_2.coordinates(), SketchLine_3.result())
+SketchPoint_3 = Sketch.addPoint(20, 10)
+SketchConstraintCoincidence_5 = Sketch.setCoincident(SketchPoint_3.coordinates(), SketchCircle_1.results()[1])
+SketchConstraintCoincidence_6 = Sketch.setCoincident(SketchPoint_3.coordinates(), SketchLine_2.result())
+SketchPoint_4 = Sketch.addPoint(80, 10)
+SketchConstraintCoincidence_7 = Sketch.setCoincident(SketchPoint_4.coordinates(), SketchCircle_1.results()[1])
+SketchConstraintCoincidence_8 = Sketch.setCoincident(SketchPoint_4.coordinates(), SketchLine_3.result())
+model.do()
+model.end()
+
+aSession = ModelAPI_Session.get()
+aSketchFeature = featureToCompositeFeature(Sketch.feature())
+
+# Create Split feature for a line
+aSession.startOperation()
+aSplit = aSketchFeature.addFeature("SketchSplit")
+aSelectedObj = aSplit.reference("SelectedObject")
+aSelectedObj.setValue(SketchLine_1.feature())
+aSelectedPoint = geomDataAPI_Point2D(aSplit.attribute("SelectedPoint"))
+aSelectedPoint.setValue(50, 20)
+aPreviewObj = aSplit.reference("PreviewObject")
+aPreviewObj.setValue(SketchLine_1.feature())
+aPreviewPoint = geomDataAPI_Point2D(aSplit.attribute("PreviewPoint"))
+aPreviewPoint.setValue(aSelectedPoint.pnt())
+aSession.finishOperation()
+
+model.testNbSubFeatures(Sketch, "SketchArc", 0)
+model.testNbSubFeatures(Sketch, "SketchCircle", 1)
+model.testNbSubFeatures(Sketch, "SketchLine", 5)
+model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 12)
+
+# Create Split feature for a circle to perform its substitution by an arc
+aSession.startOperation()
+aSplit = aSketchFeature.addFeature("SketchSplit")
+aSelectedObj = aSplit.reference("SelectedObject")
+aSelectedObj.setValue(SketchCircle_1.feature())
+aSelectedPoint = geomDataAPI_Point2D(aSplit.attribute("SelectedPoint"))
+aSelectedPoint.setValue(50, 0)
+aPreviewObj = aSplit.reference("PreviewObject")
+aPreviewObj.setValue(SketchCircle_1.feature())
+aPreviewPoint = geomDataAPI_Point2D(aSplit.attribute("PreviewPoint"))
+aPreviewPoint.setValue(aSelectedPoint.pnt())
+aSession.finishOperation()
+
+model.testNbSubFeatures(Sketch, "SketchArc", 2)
+model.testNbSubFeatures(Sketch, "SketchCircle", 0)
+model.testNbSubFeatures(Sketch, "SketchLine", 5)
+model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 16)
--- /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 SketchAPI import *
+
+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(-38.2842712474619, 18.28427124746191, -10, -10)
+SketchLine_2 = Sketch_1.addLine(-10, -10, -10, 20)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchLine_3 = Sketch_1.addLine(-10, 20, -25, 5)
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40)
+SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()])
+[SketchLine_4, SketchLine_5] = SketchConstraintMirror_1.mirrored()
+model.do()
+
+model.testNbSubFeatures(Sketch_1, "SketchLine", 5)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 3)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 1)
+
+#perform trim
+SketchTrim = Sketch_1.addTrim(SketchLine_1, geom.Pnt2d(-12, -8))
+SketchTrim.execute()
+model.do()
+
+model.testNbSubFeatures(Sketch_1, "SketchLine", 5)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 2)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1)
+model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 0)
+
+model.end()
+
+assert(model.checkPythonDump())
--- /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 ModelAPI import *
+from GeomDataAPI import *
+
+# base sketch
+model.begin()
+partSet = model.moduleDocument()
+Part = model.addPart(partSet)
+Part_doc = Part.document()
+Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch.addLine(0, 20, 100, 20)
+SketchLine_2 = Sketch.addLine(20, 0, 20, 40)
+SketchLine_3 = Sketch.addLine(80, 0, 80, 40)
+SketchCircle_1 = Sketch.addCircle(50, 50, 50)
+model.do()
+model.end()
+
+aSession = ModelAPI_Session.get()
+aSketchFeature = featureToCompositeFeature(Sketch.feature())
+
+# Create Trim feature for a line
+aSession.startOperation()
+aTrim = aSketchFeature.addFeature("SketchTrim")
+aSelectedObj = aTrim.reference("SelectedObject")
+aSelectedObj.setValue(SketchLine_1.feature())
+aSelectedPoint = geomDataAPI_Point2D(aTrim.attribute("SelectedPoint"))
+aSelectedPoint.setValue(50, 20)
+aPreviewObj = aTrim.reference("PreviewObject")
+aPreviewObj.setValue(SketchLine_1.feature())
+aPreviewPoint = geomDataAPI_Point2D(aTrim.attribute("PreviewPoint"))
+aPreviewPoint.setValue(aSelectedPoint.pnt())
+aSession.finishOperation()
+
+model.testNbSubFeatures(Sketch, "SketchArc", 0)
+model.testNbSubFeatures(Sketch, "SketchCircle", 1)
+model.testNbSubFeatures(Sketch, "SketchLine", 4)
+model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 2)
+
+# Create Trim feature for a circle to perform its substitution by an arc
+aSession.startOperation()
+aTrim = aSketchFeature.addFeature("SketchTrim")
+aSelectedObj = aTrim.reference("SelectedObject")
+aSelectedObj.setValue(SketchCircle_1.feature())
+aSelectedPoint = geomDataAPI_Point2D(aTrim.attribute("SelectedPoint"))
+aSelectedPoint.setValue(50, 0)
+aPreviewObj = aTrim.reference("PreviewObject")
+aPreviewObj.setValue(SketchCircle_1.feature())
+aPreviewPoint = geomDataAPI_Point2D(aTrim.attribute("PreviewPoint"))
+aPreviewPoint.setValue(aSelectedPoint.pnt())
+aSession.finishOperation()
+
+model.testNbSubFeatures(Sketch, "SketchArc", 1)
+model.testNbSubFeatures(Sketch, "SketchCircle", 0)
+model.testNbSubFeatures(Sketch, "SketchLine", 4)
+model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 4)