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