Salome HOME
updated copyright message
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMoveAndSplit4.py
1 # Copyright (C) 2014-2023  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 # Check the case when 2 faces in one solid selected in group with thranslation x5, moves to 5 translated groups
21 # This is an additional request in the issue #3059
22
23 from salome.shaper import model
24 from ModelAPI import *
25 from GeomAPI import *
26
27 model.begin()
28 partSet = model.moduleDocument()
29 Part_1 = model.addPart(partSet)
30 Part_1_doc = Part_1.document()
31 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
32 SketchCircle_1 = Sketch_1.addCircle(45.88138045990679, 57.99590690678009, 10.80094646219014)
33 SketchLine_1 = Sketch_1.addLine(40.23195449216883, 67.2015807394968, 46.4026355638949, 47.20754569686197)
34 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1])
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1])
36 model.do()
37 Sketch_1.changeFacesOrder([[SketchCircle_1.results()[1], SketchCircle_1.results()[1], SketchLine_1.result()],
38                            [SketchCircle_1.results()[1], SketchLine_1.result()]
39                           ])
40 model.do()
41 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_1_2r-SketchLine_1f")], model.selection(), 10, 0)
42 Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Extrusion_1_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1_2/To_Face")])
43 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OZ"), 5, keepSubResults = True)
44 model.do()
45 Part_1_doc.moveFeature(Group_1.feature(), AngularCopy_1.feature(), True)
46 model.end()
47
48 # must be created 5 groups of faces, 2 faces in each
49 assert(Part_1_doc.size("Groups") == 5)
50
51 for i in range(5):
52   resShape = modelAPI_Result(Part_1_doc.object("Groups", i)).shape()
53   assert(not resShape.isNull())
54   # the group result is a compund, check that this is a compound of two faces
55   aShapeExplorer = GeomAPI_ShapeExplorer(resShape, GeomAPI_Shape.FACE)
56   assert(aShapeExplorer.more())
57   assert(aShapeExplorer.current().isFace())
58   aShapeExplorer.next()
59   assert(aShapeExplorer.more())
60   assert(aShapeExplorer.current().isFace())
61   aShapeExplorer.next()
62   assert(not aShapeExplorer.more())
63
64 assert(model.checkPythonDump())