Salome HOME
Update copyrights
[modules/shaper.git] / src / SketchPlugin / Test / Test2018.py
1 # Copyright (C) 2014-2019  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 email : webmaster.salome@opencascade.com
18 #
19
20 """
21     Test2018.py
22     Test case for issue #2018 "After split auxiliary circle edit of axiliary state of arc is wrong"
23 """
24
25 from ModelAPI import *
26 from ModelAPI import ModelAPI_Feature
27 from ModelAPI import FeatureList
28 from ModelGeomAlgo import ModelGeomAlgo_Point2D
29 from SketchAPI import SketchAPI_Arc
30 from salome.shaper import model
31
32 def getArcs(theSketch):
33     anArcs = []
34     for aSubObj in theSketch.features().list():
35         aFeature = ModelAPI_Feature.feature(aSubObj)
36         if aFeature is not None and aFeature.getKind() == "SketchArc":
37             anArcs.append(aFeature)
38     return anArcs
39
40
41 model.begin()
42 partSet = model.moduleDocument()
43 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
44 SketchCircle_1 = Sketch_1.addCircle(-316.2976090885591, -103.0319555403832, 230.3644881376851)
45 SketchCircle_1.setAuxiliary(True)
46 SketchLine_1 = Sketch_1.addLine(-489.6131019153831, 48.7229038254136, -457.9545454545454, 334.0909090909091)
47 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1])
48 SketchLine_2 = Sketch_1.addLine(-457.9545454545454, 334.0909090909091, -251.2069112222553, 117.9454153513332)
49 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
50 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_1.results()[1])
51
52 # prepare point on circle
53 SketchLine_intersecting = Sketch_1.addLine(-316.2976090885591, -103.0319555403832, -457.9545454545454, 334.0909090909091)
54 Intersection_Point = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchCircle_1.feature(), FeatureList([SketchLine_intersecting.feature()]))
55 removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
56 GeomPoint = Intersection_Point[0]
57
58 #perform split
59 Sketch_1.addSplit(SketchCircle_1, Sketch_1.to2D(GeomPoint))
60 model.do()
61
62 anArcs = getArcs(Sketch_1)
63 # check auxiliary flags
64 for arc in anArcs:
65     aCurrentArc = SketchAPI_Arc(arc)
66     assert(aCurrentArc.auxiliary().value())
67     aCurrentArc.setAuxiliary(False)
68     model.do()
69     assert(aCurrentArc.auxiliary().value() == False)
70
71 model.end()
72
73 assert(model.checkPythonDump())