Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / Test / Test17909.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 from SketchAPI import *
21 from GeomAlgoAPI import *
22 from GeomAPI import *
23 from salome.shaper import model
24
25 model.begin()
26 partSet = model.moduleDocument()
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 model.addParameter(Part_1_doc, "k", "30")
30 model.addParameter(Part_1_doc, "M", "10")
31 model.addParameter(Part_1_doc, "h", "20")
32 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
33 SketchLine_1 = Sketch_1.addLine(15, -8.660254037843767, 15, 8.660254037843762)
34 SketchLine_2 = Sketch_1.addLine(15, 8.660254037843762, 0, 0)
35 SketchLine_2.setAuxiliary(True)
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
37 SketchLine_3 = Sketch_1.addLine(0, 0, 15, -8.660254037843767)
38 SketchLine_3.setAuxiliary(True)
39 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
40 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
41 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result())
42 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result())
43 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
44 SketchPoint_1 = SketchProjection_1.createdFeature()
45 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.startPoint())
46 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
47 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.startPoint(), SketchLine_1.result(), "k/2", True)
48 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchLine_3.startPoint(), 360, 6, True)
49 [SketchLine_4, SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8] = SketchMultiRotation_1.rotated()
50 SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
51 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "M")
52 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_3.startPoint())
53 model.do()
54 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchCircle_1_2r")], model.selection(), "h", 0)
55 model.do()
56 # fillet with only one edge to  make correct result and put all edges to results sub-tree
57 Fillet_1_objects = [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7]")]
58 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
59 model.do()
60 # select all edges as a fillet arguments
61 aResult = Extrusion_1.results()[0].resultSubShapePair()[0]
62 aShape = aResult.shape()
63 aShapeExplorer = GeomAPI_ShapeExplorer(aShape, GeomAPI_Shape.EDGE)
64 aSelectionList = []
65 aLocations = {} # for unique locations support
66 while aShapeExplorer.more():
67   # select only vertical lines
68   anEdge = aShapeExplorer.current()
69   if not anEdge.edge().isLine() or anEdge.edge().line().direction().z() < 0.999:
70     aShapeExplorer.next()
71     continue
72   aLoc = anEdge.edge().line().location()
73   aLocStr = str(aLoc.x()) + " " + str(aLoc.y()) + " " + str(aLoc.z())
74   if aLocStr in aLocations:
75     aShapeExplorer.next()
76     continue
77   aLocations[aLocStr] = ""
78   aSelection = model.selection(aResult, aShapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result
79   aSelectionList.append(aSelection)
80   aShapeExplorer.next()
81 # Set the fillet arguments: all edges
82 Fillet_1.setBase(aSelectionList)
83
84 model.end()
85
86 # if in the fillet base edges names the fillet is used, the python dump should fail
87 assert(model.checkPythonDump())