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