1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## Lesser General Public License for more details.
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 from salome.shaper import model
23 from ModelAPI import *
24 from GeomDataAPI import *
25 from ModelGeomAlgo import ModelGeomAlgo_Point2D
26 from salome.shaper import geom
31 SketchLineId = 'SketchLine'
32 SketchArcId = 'SketchArc'
33 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
34 SketchConstraintEqualId = 'SketchConstraintEqual'
36 aSession = ModelAPI_Session.get()
38 partSet = model.moduleDocument()
39 Part = model.addPart(partSet)
40 Part_doc = Part.document()
42 # Test1:begin split on arc with coincident point and intersection line : smaller part
43 Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
44 SketchArc = Sketch.addArc(50, 50, 30, 50, 50, 70, False)
45 SketchLine = Sketch.addLine(32, 20, 82, 70)
46 SketchLine_intersecting = Sketch.addLine(10, 40, 90, 40)
47 Sketch_features = featureToCompositeFeature(Sketch.feature())
48 assert (Sketch_features.numberOfSubs() == 3)
50 Arc_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc.feature(), FeatureList([SketchLine_intersecting.feature()]))
51 assert(len(Arc_Points) == 2)
53 ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
55 Sketch_features = featureToCompositeFeature(Sketch.feature())
56 assert (Sketch_features.numberOfSubs() == 2)
58 assert (len(Arc_Points) == 2)
59 if Arc_Points[0].x() < Arc_Points[1].x():
60 GeomPoint = Arc_Points[1]
62 GeomPoint = Arc_Points[0]
64 #check number of features before trim
65 Sketch_feature = featureToCompositeFeature(Sketch.feature())
67 for index in range(Sketch_feature.numberOfSubs()):
68 idList_before.append(Sketch_feature.subFeature(index).getKind())
70 assert(idList_before.count(SketchArcId) == 1)
71 assert(idList_before.count(SketchLineId) == 1)
72 assert(idList_before.count(SketchConstraintCoincidenceId) == 0)
75 SketchTrim = Sketch.addTrim(SketchArc, Sketch.to2D(GeomPoint))
79 #check number of features after trim
80 SketchFeatures = featureToCompositeFeature(Sketch.feature())
82 anArcList = FeatureList()
83 for SubIndex in range(SketchFeatures.numberOfSubs()):
84 SubFeature = SketchFeatures.subFeature(SubIndex)
85 idList_after.append(SubFeature.getKind())
86 if SubFeature.getKind() == SketchArcId:
87 SketchArc = SubFeature
88 anArcList.append(SubFeature)
90 assert(len(anArcList) == 2)
91 assert(idList_after.count(SketchArcId) == 2)
92 assert(idList_after.count(SketchLineId) == 1)
93 assert(idList_after.count(SketchConstraintCoincidenceId) == 3)
94 assert(idList_after.count(SketchConstraintEqualId) == 1)
97 #check arc position intersections of created arc to an additional line
98 SketchLine_intersecting_1 = Sketch.addLine(50, 50, 25, 25)
99 SketchLine_intersecting_2 = Sketch.addLine(50, 50, 75, 25)
100 SketchLine_intersecting_3 = Sketch.addLine(50, 50, 75, 75)
101 SketchLine_intersecting_4 = Sketch.addLine(50, 50, 25, 75)
103 Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_1.feature(), anArcList)
104 Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_2.feature(), anArcList)
105 Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_3.feature(), anArcList)
106 Intersection_Points_4 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_4.feature(), anArcList)
108 assert(len(Intersection_Points_1) == 1)
109 assert(len(Intersection_Points_2) == 0)
110 assert(len(Intersection_Points_3) == 1)
111 assert(len(Intersection_Points_4) == 0)
114 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
115 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
116 Intersection_Points_5 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchPoint.feature(), anArcList)
117 assert(len(Intersection_Points_5) == 0)
121 assert(model.checkPythonDump())