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 SketchCircleId = 'SketchCircle'
14 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
16 aSession = ModelAPI_Session.get()
18 partSet = model.moduleDocument()
19 Part = model.addPart(partSet)
20 Part_doc = Part.document()
22 # Test1:begin split on circle with coincident point and intersection line : smaller part
23 Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
24 SketchCircle = Sketch.addCircle(50, 50, 20)
25 SketchLine_1 = Sketch.addLine(70, 50, 80, 80)
26 SketchLine_2 = Sketch.addLine(80, 80, 50, 70)
28 SketchConstraintCoincidence_1_1 = Sketch.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
29 SketchConstraintCoincidence_1_2 = Sketch.setCoincident(SketchLine_1.startPoint(), SketchCircle.results()[1])
30 SketchConstraintCoincidence_1_3 = Sketch.setCoincident(SketchLine_2.endPoint(), SketchCircle.results()[1])
33 Sketch_features = featureToCompositeFeature(Sketch.feature())
34 assert (Sketch_features.numberOfSubs() == 6)
35 #intersection points on circle to prepare a trim selection point
36 SketchLine_intersecting = Sketch.addLine(10, 60, 90, 60)
37 Circle_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchCircle.feature(), FeatureList([SketchLine_intersecting.feature()]))
38 assert(len(Circle_Points) == 2)
39 ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
40 Sketch_features = featureToCompositeFeature(Sketch.feature())
41 assert (Sketch_features.numberOfSubs() == 6)
43 assert (len(Circle_Points) == 2)
44 if Circle_Points[0].x() < Circle_Points[1].x():
45 GeomPoint = Circle_Points[0]
47 GeomPoint = Circle_Points[1]
49 #check number of features before trim
50 Sketch_feature = featureToCompositeFeature(Sketch.feature())
52 for index in range(Sketch_feature.numberOfSubs()):
53 idList_before.append(Sketch_feature.subFeature(index).getKind())
55 assert(idList_before.count(SketchCircleId) == 1)
56 assert(idList_before.count(SketchArcId) == 0)
57 assert(idList_before.count(SketchLineId) == 2)
58 assert(idList_before.count(SketchConstraintCoincidenceId) == 3)
61 SketchTrim = Sketch.addTrim(SketchCircle, Sketch.to2D(GeomPoint))
65 #check number of features after trim
66 SketchFeatures = featureToCompositeFeature(Sketch.feature())
68 for SubIndex in range(SketchFeatures.numberOfSubs()):
69 SubFeature = SketchFeatures.subFeature(SubIndex)
70 idList_after.append(SubFeature.getKind())
71 if SubFeature.getKind() == SketchArcId:
72 SketchArc = SubFeature
74 assert(idList_after.count(SketchCircleId) == 0)
75 assert(idList_after.count(SketchArcId) == 1)
76 assert(idList_after.count(SketchLineId) == 2)
77 assert(idList_after.count(SketchConstraintCoincidenceId) == 3)
80 #check arc position intersections of created arc to an additional line
81 SketchLine_intersecting_1 = Sketch.addLine(0, 0, 50, 50)
82 SketchLine_intersecting_2 = Sketch.addLine(50, 50, 100, 100)
84 Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_1.feature()]))
85 Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_2.feature()]))
87 assert(len(Intersection_Points_1) == 0)
88 assert(len(Intersection_Points_2) == 1)
91 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
92 Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchPoint.feature()]))
93 assert(len(Intersection_Points_3) == 0)
97 #assert(model.checkPythonDump())