1 from salome.shaper import model
4 from GeomDataAPI import *
5 from ModelGeomAlgo import ModelGeomAlgo_Point2D
6 from salome.shaper import geom
11 SketchLineId = 'SketchLine'
12 SketchArcId = 'SketchArc'
13 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
14 SketchConstraintEqualId = 'SketchConstraintEqual'
16 aSession = ModelAPI_Session.get()
18 partSet = model.moduleDocument()
19 Part = model.addPart(partSet)
20 Part_doc = Part.document()
22 # Test1:begin split on arc with coincident point and intersection line : smaller part
23 Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
24 SketchArc = Sketch.addArc(50, 50, 30, 50, 50, 70, False)
25 SketchLine_1 = Sketch.addLine(50, 20, 100, 20)
26 SketchLine_2 = Sketch.addLine(100, 20, 70, 50)
27 SketchLine_intersecting = Sketch.addLine(10, 40, 90, 40)
29 SketchConstraintCoincidence_1_1 = Sketch.setCoincident(SketchLine_1.startPoint(), SketchArc.results()[1])
30 SketchConstraintCoincidence_1_3 = Sketch.setCoincident(SketchLine_2.endPoint(), SketchArc.results()[1])
31 SketchConstraintCoincidence_1_2 = Sketch.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 Sketch_features = featureToCompositeFeature(Sketch.feature())
34 assert (Sketch_features.numberOfSubs() == 7)
36 Arc_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc.feature(), FeatureList([SketchLine_intersecting.feature()]))
37 assert(len(Arc_Points) == 2)
39 ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
41 Sketch_features = featureToCompositeFeature(Sketch.feature())
42 assert (Sketch_features.numberOfSubs() == 6)
44 assert (len(Arc_Points) == 2)
45 if Arc_Points[0].x() < Arc_Points[1].x():
46 GeomPoint = Arc_Points[0]
48 GeomPoint = Arc_Points[1]
50 #check number of features before trim
51 Sketch_feature = featureToCompositeFeature(Sketch.feature())
53 for index in range(Sketch_feature.numberOfSubs()):
54 idList_before.append(Sketch_feature.subFeature(index).getKind())
56 assert(idList_before.count(SketchArcId) == 1)
57 assert(idList_before.count(SketchLineId) == 2)
58 assert(idList_before.count(SketchConstraintCoincidenceId) == 3)
61 SketchTrim = Sketch.addTrim(SketchArc, Sketch.to2D(GeomPoint))
65 #check number of features after trim
66 SketchFeatures = featureToCompositeFeature(Sketch.feature())
68 anArcList = FeatureList()
69 for SubIndex in range(SketchFeatures.numberOfSubs()):
70 SubFeature = SketchFeatures.subFeature(SubIndex)
71 idList_after.append(SubFeature.getKind())
72 if SubFeature.getKind() == SketchArcId:
73 SketchArc = SubFeature
74 anArcList.append(SubFeature)
76 assert(len(anArcList) == 1)
77 assert(idList_after.count(SketchArcId) == 1)
78 assert(idList_after.count(SketchLineId) == 2)
79 assert(idList_after.count(SketchConstraintCoincidenceId) == 3)
81 #check arc position intersections of created arc to an additional line
82 SketchLine_intersecting_1 = Sketch.addLine(50, 50, 25, 25)
83 SketchLine_intersecting_2 = Sketch.addLine(50, 50, 75, 25)
84 SketchLine_intersecting_3 = Sketch.addLine(50, 50, 75, 75)
85 SketchLine_intersecting_4 = Sketch.addLine(50, 50, 25, 75)
87 Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_1.feature(), anArcList)
88 Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_2.feature(), anArcList)
89 Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_3.feature(), anArcList)
90 Intersection_Points_4 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchLine_intersecting_4.feature(), anArcList)
92 assert(len(Intersection_Points_1) == 0)
93 assert(len(Intersection_Points_2) == 1)
94 assert(len(Intersection_Points_3) == 1)
95 assert(len(Intersection_Points_4) == 0)
98 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
99 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
100 Intersection_Points_5 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchPoint.feature(), anArcList)
101 assert(len(Intersection_Points_5) == 0)
105 #assert(model.checkPythonDump())