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 GeomPoint = Circle_Points[1]
45 if Circle_Points[0].x() < Circle_Points[1].x():
46 GeomPoint = Circle_Points[1]
48 GeomPoint = Circle_Points[0]
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(SketchCircleId) == 1)
57 assert(idList_before.count(SketchArcId) == 0)
58 assert(idList_before.count(SketchLineId) == 2)
59 assert(idList_before.count(SketchConstraintCoincidenceId) == 3)
62 SketchTrim = Sketch.addTrim(SketchCircle, Sketch.to2D(GeomPoint))
66 #check number of features after trim
67 SketchFeatures = featureToCompositeFeature(Sketch.feature())
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
75 assert(idList_after.count(SketchCircleId) == 0)
76 assert(idList_after.count(SketchArcId) == 1)
77 assert(idList_after.count(SketchLineId) == 2)
78 assert(idList_after.count(SketchConstraintCoincidenceId) == 3)
81 #check arc position intersections of created arc to an additional line
82 SketchLine_intersecting_1 = Sketch.addLine(0, 0, 50, 50)
83 SketchLine_intersecting_2 = Sketch.addLine(50, 50, 100, 100)
85 Intersection_Points_1 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_1.feature()]))
86 Intersection_Points_2 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchLine_intersecting_2.feature()]))
88 assert(len(Intersection_Points_1) == 1)
89 assert(len(Intersection_Points_2) == 0)
92 SketchPoint = Sketch.addPoint(GeomPoint.x(), GeomPoint.y())
93 Intersection_Points_3 = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc, FeatureList([SketchPoint.feature()]))
94 assert(len(Intersection_Points_3) == 0)
98 #assert(model.checkPythonDump())