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