Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / Test / TestFilletInteracting.py
1 # Copyright (C) 2014-2023  CEA, EDF
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 email : webmaster.salome@opencascade.com
18 #
19
20 """
21     TestFilletInteracting.py
22     Unit test of SketchPlugin_Fillet feature.
23     In scope of interaction with another constraints applied to filleted features.
24 """
25
26 from GeomAPI import *
27 from GeomDataAPI import *
28 from ModelAPI import *
29 from SketchAPI 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     # sketch is invalid, so, no results at all
176     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.FACE, [])
177     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.EDGE, [])
178     model.testNbSubShapes(self.mySketch, GeomAPI_Shape.VERTEX, [])
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     test_program = unittest.main(exit=False)
636     assert test_program.result.wasSuccessful(), "Test failed"