]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[Code coverage SketchPlugin]: Increase coverage of Arc, Split and Trim features
authorazv <azv@opencascade.com>
Fri, 30 Nov 2018 07:55:07 +0000 (10:55 +0300)
committerazv <azv@opencascade.com>
Fri, 30 Nov 2018 07:55:54 +0000 (10:55 +0300)
14 files changed:
src/ModelAPI/ModelAPI_CompositeFeature.cpp
src/ModelAPI/ModelAPI_CompositeFeature.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/SketchPlugin_Split.cpp
src/SketchPlugin/SketchPlugin_Split.h
src/SketchPlugin/SketchPlugin_Trim.cpp
src/SketchPlugin/Test/TestConstraintRadiusFailure.py [new file with mode: 0644]
src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py
src/SketchPlugin/Test/TestSplitLine.py [new file with mode: 0644]
src/SketchPlugin/Test/TestSplitPreview.py [new file with mode: 0644]
src/SketchPlugin/Test/TestTrimLine03.py [new file with mode: 0644]
src/SketchPlugin/Test/TestTrimPreview.py [new file with mode: 0644]

index 8fc0c819a87fc355761c57f14465e86881911740..b9227b04336c441a6ec097d900299ffb0f1a5344 100644 (file)
@@ -25,12 +25,6 @@ ModelAPI_CompositeFeature::~ModelAPI_CompositeFeature()
 
 }
 
-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
index 1011b350b9272fe6fb185582fa7af3e32a48de25..29276b544a55e523cce9393de6ac900218764134 100644 (file)
@@ -55,10 +55,6 @@ public:
   /// 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();
 };
index 8a17e7fed0b7c325e8922e8a77fa1da1278d03bd..fd6cd63815daf5de04467ed0c0a98a04891f6764 100644 (file)
@@ -208,6 +208,7 @@ ADD_UNIT_TESTS(
   TestConstraintParallel.py
   TestConstraintPerpendicular.py
   TestConstraintRadius.py
+  TestConstraintRadiusFailure.py
   TestConstraintTangent.py
   TestConstraintVertical.py
   TestCreateArcByCenterStartEnd.py
@@ -249,9 +250,12 @@ ADD_UNIT_TESTS(
   TestRemoveSketch.py
   TestSignedDistancePointLine.py
   TestSignedDistancePointPoint.py
+  TestSketchDrawer.py
   TestSketchPointLine.py
   TestSnowflake.py
   TestSplit.py
+  TestSplitLine.py
+  TestSplitPreview.py
   TestTrimArc01.py
   TestTrimArc02.py
   TestTrimArc03.py
@@ -267,7 +271,8 @@ ADD_UNIT_TESTS(
   TestTrimCircleAndArc01.py
   TestTrimLine01.py
   TestTrimLine02.py
-  TestSketchDrawer.py
+  TestTrimLine03.py
+  TestTrimPreview.py
 )
 
 if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE})
index 368f4452c23ef858864450e0cac50616fd3c1a2d..92fb4fcc53581ca4a3e94fe6911410509eee3060 100755 (executable)
@@ -370,9 +370,3 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the
 
   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);
-}
index 57dde7c5c8367abd5ab2bfc5c4863118b807287f..310001a81fcf2014302abe6450d1dd97fa050b6a 100644 (file)
@@ -206,11 +206,6 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu
 
   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
index d9e0cc2527b5b0814f4d5ab6cc42468d4ebade37..48162af135ee7a5569ed923dc6ce3b0b0772b051 100644 (file)
@@ -713,23 +713,6 @@ GeomShapePtr SketchPlugin_Split::getSubShape(const std::string& theObjectAttribu
   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)
@@ -1566,6 +1549,7 @@ std::shared_ptr<ModelAPI_Result> SketchPlugin_Split::getFeatureResult(
   return aResult;
 }
 
+#ifdef _DEBUG
 std::set<std::shared_ptr<ModelAPI_Attribute> > SketchPlugin_Split::getEdgeAttributes(
                                            const std::shared_ptr<ModelAPI_Feature>& theFeature)
 {
@@ -1585,6 +1569,7 @@ std::set<std::shared_ptr<ModelAPI_Attribute> > SketchPlugin_Split::getEdgeAttrib
 
   return anAttributes;
 }
+#endif
 
 std::shared_ptr<GeomDataAPI_Point2D> SketchPlugin_Split::getPointAttribute
                                                               (const bool isFirstAttribute)
index 363db36458a37f3051af9524741a864d2d490eec..a52428b797427d45c75dc060ba86bccba3fc823a 100644 (file)
@@ -149,11 +149,6 @@ private:
                         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
index 387f3a8b4e9edaf2ccfcffc9263c3f0b0066b81d..64b4a2252235edb6c7e3363154035e5ca1798a28 100644 (file)
@@ -1197,20 +1197,6 @@ void SketchPlugin_Trim::fillAttribute(const AttributePtr& theModifiedAttribute,
     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,
diff --git a/src/SketchPlugin/Test/TestConstraintRadiusFailure.py b/src/SketchPlugin/Test/TestConstraintRadiusFailure.py
new file mode 100644 (file)
index 0000000..c989fc9
--- /dev/null
@@ -0,0 +1,34 @@
+## 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()
index 0e44647749bcb621f235025a4c94a29aa0ccf221..92666b17849f2f0b38a5a43d9ef6d06fae8c7485 100644 (file)
@@ -272,6 +272,116 @@ verifyPointOnCircle(aStart, aPrevArc)
 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
 #=========================================================================
diff --git a/src/SketchPlugin/Test/TestSplitLine.py b/src/SketchPlugin/Test/TestSplitLine.py
new file mode 100644 (file)
index 0000000..bdabae1
--- /dev/null
@@ -0,0 +1,59 @@
+## 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())
diff --git a/src/SketchPlugin/Test/TestSplitPreview.py b/src/SketchPlugin/Test/TestSplitPreview.py
new file mode 100644 (file)
index 0000000..ac59f96
--- /dev/null
@@ -0,0 +1,88 @@
+## 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)
diff --git a/src/SketchPlugin/Test/TestTrimLine03.py b/src/SketchPlugin/Test/TestTrimLine03.py
new file mode 100644 (file)
index 0000000..acc9201
--- /dev/null
@@ -0,0 +1,59 @@
+## 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())
diff --git a/src/SketchPlugin/Test/TestTrimPreview.py b/src/SketchPlugin/Test/TestTrimPreview.py
new file mode 100644 (file)
index 0000000..8f5a641
--- /dev/null
@@ -0,0 +1,76 @@
+## 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)