Salome HOME
updated copyright message
[modules/shaper.git] / src / CollectionPlugin / Test / TestGroupMoveAndSplit1.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 # Check the specification case of move to the end and split (#3059)
21
22 from salome.shaper import model
23 from ModelAPI import *
24 from GeomAPI import *
25
26 model.begin()
27 partSet = model.moduleDocument()
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30 Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 12, 0)
31 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
32 SketchCircle_1 = Sketch_1.addCircle(33.32502963835739, 19.24021483244179, 5)
33 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
34 SketchLine_1 = Sketch_1.addLine(0, 0, 33.32502963835739, 19.24021483244179)
35 SketchLine_1.setAuxiliary(True)
36 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
37 SketchPoint_1 = SketchProjection_1.createdFeature()
38 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
39 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.endPoint())
40 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
41 SketchLine_2 = SketchProjection_2.createdFeature()
42 SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_2.result(), SketchLine_1.result(), 30)
43 Extrusion_1.setNestedSketch(Sketch_1)
44 Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Extrusion_1_1/To_Face")])
45 AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OZ"), 12)
46 model.do()
47 Part_1_doc.moveFeature(Group_1.feature(), AngularCopy_1.feature(), True)
48 model.end()
49
50 # must be created 12 groups of faces, 12 results
51 assert(Part_1_doc.size("Groups") == 12)
52
53 for i in range(12):
54   resShape = modelAPI_Result(Part_1_doc.object("Groups", i)).shape()
55   assert(not resShape.isNull())
56   # the group result is a compund, check that this is a compound of one face
57   aShapeExplorer = GeomAPI_ShapeExplorer(resShape, GeomAPI_Shape.FACE)
58   assert(aShapeExplorer.more())
59   assert(aShapeExplorer.current().isFace())
60   aShapeExplorer.next()
61   assert(not aShapeExplorer.more())
62
63 assert(model.checkPythonDump())