Salome HOME
Cosmetics. Move XML files to the separate folder inside a corresponding project in VS.
[modules/shaper.git] / src / SketchPlugin / Test / TestTrimLine02.py
index c10ce7c5fae92806131a75fa4d310bba7056edaa..5dc144cc7365abb1901ec5bd94a2f9672507c617 100644 (file)
@@ -1,3 +1,22 @@
+# Copyright (C) 2014-2020  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
+#
+
 from salome.shaper import model
 
 from ModelAPI import *
@@ -34,13 +53,13 @@ SketchConstraintCoincidence_1_3 = Sketch.setCoincident(SketchLine_3.endPoint(),
 GeomPoint = geom.Pnt2d(40, 50)
 
 #check number of features before trim
-#Sketch_feature = featureToCompositeFeature(Sketch.feature())
-#idList_before = []
-#for index in range(Sketch_feature.numberOfSubs()):
-#  idList_before.append(Sketch_feature.subFeature(index).getKind())
+Sketch_feature = featureToCompositeFeature(Sketch.feature())
+idList_before = []
+for index in range(Sketch_feature.numberOfSubs()):
+  idList_before.append(Sketch_feature.subFeature(index).getKind())
 
-#assert(idList_before.count(SketchLineId) == 3)
-#assert(idList_before.count(SketchConstraintCoincidenceId) == 2)
+assert(idList_before.count(SketchLineId) == 5)
+assert(idList_before.count(SketchConstraintCoincidenceId) == 3)
 
 #perform trim
 SketchTrim = Sketch.addTrim(SketchLine_intersecting, GeomPoint)
@@ -48,26 +67,41 @@ SketchTrim.execute()
 model.do()
 
 #check number of features after trim
-#SketchFeatures = featureToCompositeFeature(Sketch.feature())
-#idList_after = []
-#for SubIndex in range(SketchFeatures.numberOfSubs()):
-#    SubFeature = SketchFeatures.subFeature(SubIndex)
-#    idList_after.append(SubFeature.getKind())
-
-#assert(idList_after.count(SketchLineId) == 3)
-#assert(idList_after.count(SketchConstraintCoincidenceId) == 2)
+SketchFeatures = featureToCompositeFeature(Sketch.feature())
+idList_after = []
+
+LinesList = FeatureList()
+for SubIndex in range(SketchFeatures.numberOfSubs()):
+    SubFeature = SketchFeatures.subFeature(SubIndex)
+    idList_after.append(SubFeature.getKind())
+    if SubFeature.getKind() == SketchLineId:
+      LinesList.append(SubFeature)
+
+assert(idList_after.count(SketchLineId) == 6)
+assert(idList_after.count(SketchConstraintCoincidenceId) == 5)
+
+
+#check lines intersection to the source line
+SketchLine_intersecting_1 = Sketch.addLine(15, 55, 15, 40)
+SketchLine_intersecting_2 = Sketch.addLine(40, 55, 40, 40)
+SketchLine_intersecting_3 = Sketch.addLine(70, 55, 70, 40)
+SketchLine_intersecting_4 = Sketch.addLine(100, 55, 100, 40)
+SketchLine_intersecting_5 = Sketch.addLine(125, 55, 125, 40)
+
+Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_1.feature(), LinesList)
+Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_2.feature(), LinesList)
+Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_3.feature(), LinesList)
+Intersection_Points_4 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_4.feature(), LinesList)
+Intersection_Points_5 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_5.feature(), LinesList)
+
+assert(len(Intersection_Points_1) == 1)
+assert(len(Intersection_Points_2) == 0)
+assert(len(Intersection_Points_3) == 1)
+assert(len(Intersection_Points_4) == 1)
+assert(len(Intersection_Points_5) == 1)
 
 #check if line points are the same
-#assert(SketchLine_1.startPoint().x() == 200)
-#assert(SketchLine_1.startPoint().y() == 20)
-#assert(SketchLine_1.endPoint().x() == 20)
-#assert(SketchLine_1.endPoint().y() == 70)
-
-#assert(SketchLine_3.startPoint().x() == -10)
-#assert(SketchLine_3.startPoint().y() == 190)
-#assert(SketchLine_3.endPoint().x() == 90)
-#assert(SketchLine_3.endPoint().y() == 50)
 
 model.end()
 
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())