Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchPlugin / Test / TestFilletInteracting.py
1 """
2     TestFilletInteracting.py
3     Unit test of SketchPlugin_Fillet feature.
4     In scope of interaction with another constraints applied to filleted features.
5 """
6
7 from GeomAPI import *
8 from GeomDataAPI import *
9 from ModelAPI import *
10 import math
11 import unittest
12 from salome.shaper import model
13
14 __updated__ = "2017-03-06"
15
16 def isArcLineSmooth(theArc, theLine, theTolerance):
17   aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
18   aDistance = distancePointLine(aCenter, theLine)
19   aRadius = arcRadius(theArc)
20   return math.fabs(aRadius - aDistance) < theTolerance
21
22 def isArcArcSmooth(theArc1, theArc2, theTolerance):
23   aCenter1 = geomDataAPI_Point2D(theArc1.attribute("ArcCenter"))
24   aCenter2 = geomDataAPI_Point2D(theArc2.attribute("ArcCenter"))
25   aDistance = distancePointPoint(aCenter1, aCenter2)
26   aRadius1 = arcRadius(theArc1)
27   aRadius2 = arcRadius(theArc2)
28   aRadSum = aRadius1 + aRadius2
29   aRadDiff = math.fabs(aRadius1 - aRadius2)
30   return math.fabs(aDistance - aRadSum) < theTolerance or math.fabs(aDistance - aRadDiff) < theTolerance
31
32 def arcRadius(theArc):
33   aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
34   aStart = geomDataAPI_Point2D(theArc.attribute("ArcStartPoint"))
35   return distancePointPoint(aCenter, aStart)
36
37 def distancePointPoint(thePoint1, thePoint2):
38   return math.hypot(thePoint1.x() - thePoint2.x(), thePoint1.y() - thePoint2.y())
39
40 def distancePointLine(thePoint, theLine):
41   aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint"))
42   aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint"))
43   aLength = distancePointPoint(aLineStart, aLineEnd)
44   aDir1x, aDir1y = aLineEnd.x() - aLineStart.x(), aLineEnd.y() - aLineStart.y()
45   aDir2x, aDir2y = thePoint.x() - aLineStart.x(), thePoint.y() - aLineStart.y()
46   aCross = aDir1x * aDir2y - aDir1y * aDir2x
47   return math.fabs(aCross) / aLength
48
49
50
51 class TestFilletInteracting(unittest.TestCase):
52   def setUp(self):
53     model.begin()
54     self.myDocument = model.moduleDocument()
55     self.mySketch = model.addSketch(self.myDocument, model.defaultPlane("XOY"))
56     self.myTolerance = 1.e-6
57     self.myDOF = 0
58
59   def tearDown(self):
60     model.end()
61     self.assertTrue(model.checkPythonDump())
62     model.reset()
63
64
65   def checkDOF(self):
66     self.assertEqual(model.dof(self.mySketch), self.myDOF)
67
68   def collectFeatures(self):
69     self.myFeatures = {}
70     for aSubObj in self.mySketch.features().list():
71       aFeature = ModelAPI.ModelAPI_Feature.feature(aSubObj)
72       if aFeature is not None:
73         if self.myFeatures.get(aFeature.getKind()) == None:
74           self.myFeatures[aFeature.getKind()] = 1
75         else:
76           self.myFeatures[aFeature.getKind()] += 1
77
78   def checkNbFeatures(self, theFeatureKind, theFeatureCount):
79     if theFeatureCount == 0:
80       self.assertIsNone(self.myFeatures.get(theFeatureKind))
81     else:
82       self.assertIsNotNone(self.myFeatures.get(theFeatureKind), "No features of kind {0} but expected {1}".format(theFeatureKind, theFeatureCount))
83       self.assertEqual(self.myFeatures[theFeatureKind], theFeatureCount, "Observed number of {0} is {1} but expected {2}".format(theFeatureKind, self.myFeatures[theFeatureKind], theFeatureCount))
84
85   def checkFillet(self):
86     aPtPtCoincidences = self.getCoincidences()
87     for coinc in aPtPtCoincidences:
88       aConnectedFeatures = self.connectedFeatures(coinc)
89       self.assertEqual(len(aConnectedFeatures), 2)
90       if aConnectedFeatures[0].getKind() == "SketchArc":
91         if aConnectedFeatures[1].getKind() == "SketchArc":
92           self.assertTrue(isArcArcSmooth(aConnectedFeatures[0], aConnectedFeatures[1], self.myTolerance))
93         elif aConnectedFeatures[1].getKind() == "SketchLine":
94           self.assertTrue(isArcLineSmooth(aConnectedFeatures[0], aConnectedFeatures[1], self.myTolerance))
95       elif aConnectedFeatures[0].getKind() == "SketchLine" and aConnectedFeatures[1].getKind() == "SketchArc":
96         self.assertTrue(isArcLineSmooth(aConnectedFeatures[1], aConnectedFeatures[0], self.myTolerance))
97
98   def getCoincidences(self):
99     aCoincidences = []
100     for aSubObj in self.mySketch.features().list():
101       aSubFeature = ModelAPI.ModelAPI_Feature.feature(aSubObj)
102       if aSubFeature is not None and aSubFeature.getKind() == "SketchConstraintCoincidence":
103         anEntityA = aSubFeature.refattr("ConstraintEntityA")
104         anEntityB = aSubFeature.refattr("ConstraintEntityB")
105         if not anEntityA.isObject() and not anEntityB.isObject():
106           aCoincidences.append(aSubFeature)
107     return aCoincidences
108
109   def connectedFeatures(self, theCoincidence):
110     anEntityA = theCoincidence.refattr("ConstraintEntityA")
111     anEntityB = theCoincidence.refattr("ConstraintEntityB")
112     aFeatureA = ModelAPI.ModelAPI_Feature.feature(anEntityA.attr().owner())
113     aFeatureB = ModelAPI.ModelAPI_Feature.feature(anEntityB.attr().owner())
114     return [aFeatureA, aFeatureB]
115
116
117   def test_fillet_two_lines(self):
118     """ Test 1. Fillet on two connected lines
119     """
120     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
121     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
122     self.myDOF += 8
123     self.checkDOF()
124     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
125     self.myDOF -= 2
126     model.do()
127     self.checkDOF()
128     self.mySketch.setFillet(aSketchLineA.startPoint())
129     self.myDOF += 1
130     model.do()
131     self.checkFillet()
132     self.checkDOF()
133
134     self.collectFeatures()
135     self.checkNbFeatures("SketchLine", 2)
136     self.checkNbFeatures("SketchArc", 1)
137     self.checkNbFeatures("SketchConstraintCoincidence", 2)
138     self.checkNbFeatures("SketchConstraintTangent", 2)
139     self.checkNbFeatures("SketchFillet", 0)
140
141     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
142     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
143     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
144
145   def test_wrong_fillet_two_lines(self):
146     """ Test 2. Check the fillet is wrong on two connected lines when selecting incorrect point
147     """
148     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
149     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
150     self.myDOF += 8
151     self.checkDOF()
152     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
153     self.myDOF -= 2
154     model.do()
155     self.checkDOF()
156     aFillet = self.mySketch.setFillet(aSketchLineA.endPoint())
157     model.do()
158     self.checkDOF()
159
160     self.collectFeatures()
161     self.checkNbFeatures("SketchLine", 2)
162     self.checkNbFeatures("SketchArc", 0) # no arcs should be created
163     self.checkNbFeatures("SketchConstraintCoincidence", 1) # number of coincidences should not change
164     self.checkNbFeatures("SketchConstraintTangent", 0) # no tangencies should not be created
165     self.checkNbFeatures("SketchFillet", 1) # fillet feature should still exist. it should be wrong
166
167     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
168     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [2])
169     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [4])
170
171     # remove fillet for correct python dump
172     self.myDocument.removeFeature(aFillet.feature())
173
174   def test_fillet_arc_line(self):
175     """ Test 3. Fillet on connected arc and line
176     """
177     aSketchLine = self.mySketch.addLine(10., 10., 20., 10.)
178     aSketchArc = self.mySketch.addArc(20., 10., 20., 20., 10., 10., False)
179     self.myDOF += 9
180     self.checkDOF()
181     self.mySketch.setCoincident(aSketchLine.startPoint(), aSketchArc.endPoint())
182     self.myDOF -= 2
183     model.do()
184     self.checkDOF()
185     self.mySketch.setFillet(aSketchLine.startPoint())
186     self.myDOF += 1
187     model.do()
188     self.checkFillet()
189     self.checkDOF()
190
191     self.collectFeatures()
192     self.checkNbFeatures("SketchLine", 1)
193     self.checkNbFeatures("SketchArc", 2)
194     self.checkNbFeatures("SketchConstraintCoincidence", 2)
195     self.checkNbFeatures("SketchConstraintTangent", 2)
196     self.checkNbFeatures("SketchFillet", 0)
197
198     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
199     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
200     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
201
202   def test_fillet_two_arcs(self):
203     """ Test 4. Fillet on two connected arcs
204     """
205     aSketchArc1 = self.mySketch.addArc(20., 0., 20., 20., 10., 17.32050807568877293, False)
206     aSketchArc2 = self.mySketch.addArc(20., 34.64101615137754586, 20., 14.64101615137754586, 10., 17.32050807568877293, True)
207     self.myDOF += 10
208     self.checkDOF()
209     self.mySketch.setCoincident(aSketchArc1.endPoint(), aSketchArc2.endPoint())
210     self.myDOF -= 2
211     model.do()
212     self.checkDOF()
213     self.mySketch.setFillet(aSketchArc1.endPoint())
214     self.myDOF += 1
215     model.do()
216     self.checkFillet()
217     self.checkDOF()
218
219     self.collectFeatures()
220     self.checkNbFeatures("SketchLine", 0)
221     self.checkNbFeatures("SketchArc", 3)
222     self.checkNbFeatures("SketchConstraintCoincidence", 2)
223     self.checkNbFeatures("SketchConstraintTangent", 2)
224     self.checkNbFeatures("SketchFillet", 0)
225
226     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
227     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
228     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
229
230   def test_fillet_with_horizontal_vertical(self):
231     """ Test 5. Fillet on two connected lines in case of Horizontal or Vertical constraints applied
232     """
233     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
234     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
235     self.myDOF += 8
236     self.checkDOF()
237     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
238     self.myDOF -= 2
239     model.do()
240     self.checkDOF()
241     self.mySketch.setHorizontal(aSketchLineA.result())
242     self.mySketch.setVertical(aSketchLineB.result())
243     self.myDOF -= 2
244     model.do()
245     self.checkDOF()
246     self.mySketch.setFillet(aSketchLineA.startPoint())
247     self.myDOF += 1
248     model.do()
249     self.checkFillet()
250     self.checkDOF()
251
252     self.collectFeatures()
253     self.checkNbFeatures("SketchLine", 2)
254     self.checkNbFeatures("SketchArc", 1)
255     self.checkNbFeatures("SketchConstraintCoincidence", 2)
256     self.checkNbFeatures("SketchConstraintTangent", 2)
257     self.checkNbFeatures("SketchConstraintHorizontal", 1)
258     self.checkNbFeatures("SketchConstraintVertical", 1)
259     self.checkNbFeatures("SketchFillet", 0)
260
261     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
262     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
263     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
264
265   def test_fillet_with_orthogonal(self):
266     """ Test 6. Fillet on two connected lines in case of Perpendicular constraint applied
267     """
268     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
269     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
270     self.myDOF += 8
271     self.checkDOF()
272     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
273     self.myDOF -= 2
274     model.do()
275     self.checkDOF()
276     self.mySketch.setPerpendicular(aSketchLineA.result(), aSketchLineB.result())
277     self.myDOF -= 1
278     model.do()
279     self.checkDOF()
280     self.mySketch.setFillet(aSketchLineA.startPoint())
281     self.myDOF += 1
282     model.do()
283     self.checkFillet()
284     self.checkDOF()
285
286     self.collectFeatures()
287     self.checkNbFeatures("SketchLine", 2)
288     self.checkNbFeatures("SketchArc", 1)
289     self.checkNbFeatures("SketchConstraintCoincidence", 2)
290     self.checkNbFeatures("SketchConstraintTangent", 2)
291     self.checkNbFeatures("SketchConstraintPerpendicular", 1)
292     self.checkNbFeatures("SketchFillet", 0)
293
294     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
295     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
296     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
297
298   def test_fillet_with_parallel(self):
299     """ Test 7. Fillet on two connected lines in case of Parallel constraint applied
300     """
301     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
302     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
303     self.myDOF += 8
304     self.checkDOF()
305     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
306     self.myDOF -= 2
307     model.do()
308     self.checkDOF()
309     # third line to apply parallel constraint
310     aSketchLineC = self.mySketch.addLine(10., 0., 20., 5.)
311     self.myDOF += 4
312     self.mySketch.setParallel(aSketchLineB.result(), aSketchLineC.result())
313     self.myDOF -= 1
314     model.do()
315     self.checkDOF()
316     self.mySketch.setFillet(aSketchLineA.startPoint())
317     self.myDOF += 1
318     model.do()
319     self.checkFillet()
320     self.checkDOF()
321
322     self.collectFeatures()
323     self.checkNbFeatures("SketchLine", 3)
324     self.checkNbFeatures("SketchArc", 1)
325     self.checkNbFeatures("SketchConstraintCoincidence", 2)
326     self.checkNbFeatures("SketchConstraintTangent", 2)
327     self.checkNbFeatures("SketchConstraintParallel", 1)
328     self.checkNbFeatures("SketchFillet", 0)
329
330     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
331     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4])
332     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8])
333
334   def test_fillet_with_equal_lines(self):
335     """ Test 8. Fillet on two connected lines in case of Equal constraint applied
336     """
337     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
338     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
339     self.myDOF += 8
340     self.checkDOF()
341     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
342     self.myDOF -= 2
343     model.do()
344     self.checkDOF()
345     self.mySketch.setEqual(aSketchLineA.result(), aSketchLineB.result())
346     self.myDOF -= 1
347     model.do()
348     self.checkDOF()
349     self.mySketch.setFillet(aSketchLineA.startPoint())
350     self.myDOF += 2 # Equal has been removed
351     model.do()
352     self.checkFillet()
353     self.checkDOF()
354
355     self.collectFeatures()
356     self.checkNbFeatures("SketchLine", 2)
357     self.checkNbFeatures("SketchArc", 1)
358     self.checkNbFeatures("SketchConstraintCoincidence", 2)
359     self.checkNbFeatures("SketchConstraintTangent", 2)
360     self.checkNbFeatures("SketchConstraintEqual", 0) # Equal constraint expected to be removed
361     self.checkNbFeatures("SketchFillet", 0)
362
363     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
364     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
365     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
366
367   def test_fillet_with_equal_arcs(self):
368     """ Test 9. Fillet on two connected arcs in case of Equal constraint applied
369     """
370     aSketchArc1 = self.mySketch.addArc(20., 0., 20., 20., 10., 17.32050807568877293, False)
371     aSketchArc2 = self.mySketch.addArc(20., 34.64101615137754586, 20., 14.64101615137754586, 10., 17.32050807568877293, True)
372     self.myDOF += 10
373     self.checkDOF()
374     self.mySketch.setCoincident(aSketchArc1.endPoint(), aSketchArc2.endPoint())
375     self.myDOF -= 2
376     model.do()
377     self.checkDOF()
378     self.mySketch.setEqual(aSketchArc1.results()[1], aSketchArc2.results()[1])
379     self.myDOF -= 1
380     model.do()
381     self.checkDOF()
382     self.mySketch.setFillet(aSketchArc1.endPoint())
383     self.myDOF += 2 # Equal has been removed
384     model.do()
385     self.checkFillet()
386     self.checkDOF()
387
388     self.collectFeatures()
389     self.checkNbFeatures("SketchLine", 0)
390     self.checkNbFeatures("SketchArc", 3)
391     self.checkNbFeatures("SketchConstraintCoincidence", 2)
392     self.checkNbFeatures("SketchConstraintTangent", 2)
393     self.checkNbFeatures("SketchConstraintEqual", 0) # Equal constraint expected to be removed
394     self.checkNbFeatures("SketchFillet", 0)
395
396     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
397     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
398     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
399
400   def test_fillet_with_length(self):
401     """ Test 10. Fillet on two connected lines in case of Length constraint applied
402     """
403     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
404     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
405     self.myDOF += 8
406     self.checkDOF()
407     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
408     self.myDOF -= 2
409     model.do()
410     self.checkDOF()
411     self.mySketch.setLength(aSketchLineA.result(), 15.)
412     self.myDOF -= 1
413     model.do()
414     self.checkDOF()
415     self.mySketch.setFillet(aSketchLineA.startPoint())
416     self.myDOF += 2
417     model.do()
418     self.checkFillet()
419     self.checkDOF()
420
421     self.collectFeatures()
422     self.checkNbFeatures("SketchLine", 2)
423     self.checkNbFeatures("SketchArc", 1)
424     self.checkNbFeatures("SketchConstraintCoincidence", 2)
425     self.checkNbFeatures("SketchConstraintTangent", 2)
426     self.checkNbFeatures("SketchConstraintLength", 0) # Length constraint expected to be removed
427     self.checkNbFeatures("SketchFillet", 0)
428
429     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
430     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
431     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
432
433   def test_fillet_with_radius(self):
434     """ Test 11. Fillet on connected arc and line in case of Radius constraint is applied to arc
435     """
436     aSketchLine = self.mySketch.addLine(10., 10., 20., 10.)
437     aSketchArc = self.mySketch.addArc(0., 10., 0., 20., 10., 10., True)
438     self.myDOF += 9
439     self.checkDOF()
440     self.mySketch.setCoincident(aSketchLine.startPoint(), aSketchArc.endPoint())
441     self.myDOF -= 2
442     model.do()
443     self.checkDOF()
444     self.mySketch.setRadius(aSketchArc.results()[1], 12.)
445     self.myDOF -= 1
446     model.do()
447     self.checkDOF()
448     self.mySketch.setFillet(aSketchLine.startPoint())
449     self.myDOF += 1
450     model.do()
451     self.checkFillet()
452     self.checkDOF()
453
454     self.collectFeatures()
455     self.checkNbFeatures("SketchLine", 1)
456     self.checkNbFeatures("SketchArc", 2)
457     self.checkNbFeatures("SketchConstraintCoincidence", 2)
458     self.checkNbFeatures("SketchConstraintTangent", 2)
459     self.checkNbFeatures("SketchConstraintRadius", 1)
460     self.checkNbFeatures("SketchFillet", 0)
461
462     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
463     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
464     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
465
466   def test_fillet_with_distance(self):
467     """ Test 12. Fillet on two connected lines in case of Distance constraint applied
468     """
469     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
470     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
471     self.myDOF += 8
472     self.checkDOF()
473     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
474     self.myDOF -= 2
475     model.do()
476     self.checkDOF()
477     # third line to apply Distance constraints
478     aSketchLineC = self.mySketch.addLine(10., 0., 20., 5.)
479     self.myDOF += 4
480     self.mySketch.setDistance(aSketchLineB.startPoint(), aSketchLineC.result(), 10.)
481     self.mySketch.setDistance(aSketchLineB.endPoint(), aSketchLineC.result(), 5.)
482     self.myDOF -= 2
483     model.do()
484     self.checkDOF()
485     self.mySketch.setFillet(aSketchLineA.startPoint())
486     self.myDOF += 2 # Distance has been removed
487     model.do()
488     self.checkFillet()
489     self.checkDOF()
490
491     self.collectFeatures()
492     self.checkNbFeatures("SketchLine", 3)
493     self.checkNbFeatures("SketchArc", 1)
494     self.checkNbFeatures("SketchConstraintCoincidence", 2)
495     self.checkNbFeatures("SketchConstraintTangent", 2)
496     self.checkNbFeatures("SketchConstraintDistance", 1) # only one Distance should be left
497     self.checkNbFeatures("SketchFillet", 0)
498
499     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
500     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [4])
501     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [8])
502
503   def test_fillet_with_fixed_point(self):
504     """ Test 13. Fillet on two connected lines in case of Fixed constraint applied to the fillet point
505     """
506     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
507     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
508     self.myDOF += 8
509     self.checkDOF()
510     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
511     self.myDOF -= 2
512     model.do()
513     self.checkDOF()
514     self.mySketch.setFixed(aSketchLineA.startPoint())
515     self.myDOF -= 2
516     model.do()
517     self.checkDOF()
518     self.mySketch.setFillet(aSketchLineA.startPoint())
519     self.myDOF += 3 # Fixed constraint has been removed
520     model.do()
521     self.checkFillet()
522     self.checkDOF()
523
524     self.collectFeatures()
525     self.checkNbFeatures("SketchLine", 2)
526     self.checkNbFeatures("SketchArc", 1)
527     self.checkNbFeatures("SketchConstraintCoincidence", 2)
528     self.checkNbFeatures("SketchConstraintTangent", 2)
529     self.checkNbFeatures("SketchConstraintFixed", 0) # Fixed constraint expected to be removed
530     self.checkNbFeatures("SketchFillet", 0)
531
532     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
533     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
534     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
535
536   def test_fillet_with_fixed_line(self):
537     """ Test 14. Fillet on two connected lines in case of Fixed constraint applied to one of lines
538     """
539     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
540     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
541     self.myDOF += 8
542     self.checkDOF()
543     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
544     self.myDOF -= 2
545     model.do()
546     self.checkDOF()
547     self.mySketch.setFixed(aSketchLineA.result())
548     self.myDOF -= 4
549     model.do()
550     self.checkDOF()
551     self.mySketch.setFillet(aSketchLineA.startPoint())
552     self.myDOF += 1
553     model.do()
554     self.checkFillet()
555     self.checkDOF()
556
557     self.collectFeatures()
558     self.checkNbFeatures("SketchLine", 2)
559     self.checkNbFeatures("SketchArc", 1)
560     self.checkNbFeatures("SketchConstraintCoincidence", 2)
561     self.checkNbFeatures("SketchConstraintTangent", 2)
562     self.checkNbFeatures("SketchConstraintLength", 0) # Fixed constraint expected to be kept
563     self.checkNbFeatures("SketchFillet", 0)
564
565     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
566     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
567     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
568
569   def test_fillet_with_angle(self):
570     """ Test 15. Fillet on two connected lines in case of Perpendicular constraint applied
571     """
572     aSketchLineA = self.mySketch.addLine(10., 10., 20., 10.)
573     aSketchLineB = self.mySketch.addLine(10., 10., 10., 20.)
574     self.myDOF += 8
575     self.checkDOF()
576     self.mySketch.setCoincident(aSketchLineA.startPoint(), aSketchLineB.startPoint())
577     self.myDOF -= 2
578     model.do()
579     self.checkDOF()
580     self.mySketch.setAngle(aSketchLineA.result(), aSketchLineB.result(), 60.)
581     self.myDOF -= 1
582     model.do()
583     self.checkDOF()
584     self.mySketch.setFillet(aSketchLineA.startPoint())
585     self.myDOF += 1
586     model.do()
587     self.checkFillet()
588     self.checkDOF()
589
590     self.collectFeatures()
591     self.checkNbFeatures("SketchLine", 2)
592     self.checkNbFeatures("SketchArc", 1)
593     self.checkNbFeatures("SketchConstraintCoincidence", 2)
594     self.checkNbFeatures("SketchConstraintTangent", 2)
595     self.checkNbFeatures("SketchConstraintAngle", 1)
596     self.checkNbFeatures("SketchFillet", 0)
597
598     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [0])
599     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [3])
600     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [6])
601
602
603 if __name__ == '__main__':
604   unittest.main()