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