Salome HOME
Renaming Fill in Split : Read old HDF
[modules/shaper.git] / src / FeaturesPlugin / Test / Test2738.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 # -*- coding: utf-8 -*-
21
22 from salome.shaper import model
23 from GeomAlgoAPI import *
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, "d", "8")
30 model.addParameter(Part_1_doc, "nb", "3")
31 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
32 SketchCircle_1 = Sketch_1.addCircle(-34.12026714434272, 28.71281409244911, 1.619211673722419)
33 SketchCircle_2 = Sketch_1.addCircle(-34.12026714434272, 28.71281409244911, 3.180589706721861)
34 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchCircle_2.center())
35 model.do()
36 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE_2", (-35.73947881806514, 28.71281409244911, 0))], model.selection(), 2, -1)
37 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", (-37.30085685106458, 28.71281409244911, 0))], model.selection(), 5, 0)
38 Partition_1 = model.addPartition(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1"), model.selection("COMPOUND", "all-in-Extrusion_2")])
39 Group_1 = model.addGroup(Part_1_doc, [model.selection("SOLID", (-34.12026714434272, 28.71281409244911, 1.5))])
40 Group_1.setName("Group_dechets")
41 Group_1.result().setName("Group_dechets")
42 Group_2 = model.addGroup(Part_1_doc, [model.selection("SOLID", (-34.12026714434272, 28.71281409244911, 2.35984679315518))])
43 Group_2.setName("Group_colis")
44 Group_2.result().setName("Group_colis")
45 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPSOLID", (-34.12026714434272, 28.71281409244911, 2.5))], model.selection("EDGE", "PartSet/OX"), "d", "nb", model.selection("EDGE", "PartSet/OY"), "d", "nb")
46 model.do()
47 # move groups to the end
48 Part_1_doc.moveFeature(Group_1.feature(), LinearCopy_1.feature())
49 Part_1_doc.moveFeature(Group_2.feature(), Group_1.feature())
50 model.end()
51
52 from ModelAPI import *
53 aFactory = ModelAPI_Session.get().validators()
54
55 # number of solids should be multiplyed by linear copy
56 selectionList = Group_1.feature().selectionList("group_list")
57 assert(selectionList.size() == 9)
58 assert(aFactory.validate(Group_1.feature()))
59 # checkthat solids in the first group are small, like the origin
60 for i in range(9):
61   delta = GeomAlgoAPI_ShapeTools_volume(selectionList.value(i).value()) - 8.236773528312948
62   assert(fabs(delta) < 1.e-5)
63
64 # same-plane faces should be merged
65 selectionList = Group_2.feature().selectionList("group_list")
66 assert(selectionList.size() == 9)
67 assert(aFactory.validate(Group_2.feature()))
68
69 # checkthat solids in the secong group are big, like the origin
70 for i in range(9):
71   delta = GeomAlgoAPI_ShapeTools_volume(selectionList.value(i).value()) - 150.66735294710597
72   assert(fabs(delta) < 1.e-5)
73
74 assert(model.checkPythonDump())