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