1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2024 CEA, EDF
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Géométrie et maillage de base nécessaire au cas-test :
30 from salome.smesh import smeshBuilder
31 from salome.StdMeshers import StdMeshersBuilder
36 from blocFissure import gmu
37 from blocFissure.gmu.geomsmesh import geompy
38 from blocFissure.gmu.geomsmesh import geomPublish
39 from blocFissure.gmu.geomsmesh import geomPublishInFather
41 from blocFissure.gmu.triedreBase import triedreBase
42 from blocFissure.gmu.putName import putName
43 from blocFissure.gmu import initLog
49 O, OX, OY, OZ = triedreBase()
51 Circle_1 = geompy.MakeCircle(O, OX, 500.)
52 Extrusion_1 = geompy.MakePrismVecH2Ways(Circle_1, OX, 500)
53 Vertex_1 = geompy.MakeVertex(500., 0., 0.)
54 Circle_3 = geompy.MakeCircle(Vertex_1, OZ, 300)
55 Extrusion_2 = geompy.MakePrismVecH(Circle_3, OZ, 1000)
56 Partition_1 = geompy.MakePartition([Extrusion_1], [Extrusion_2], [], [], geompy.ShapeType["FACE"], 0, [], 0)
57 [Face_1,Face_2] = geompy.SubShapes(Partition_1, [18, 13])
59 FaceFissExt = geompy.MakeFuse(Face_2, Face_1)
60 geompy.addToStudy( FaceFissExt, 'FaceFissExt' )
61 geompy.ExportBREP(FaceFissExt, os.path.join(gmu.pathBloc, "materielCasTests", "faceGauche2Fiss.brep"))
63 Vertex_2 = geompy.MakeVertex(0, -500, 0)
64 Vertex_3 = geompy.MakeVertex(400, 500, 800)
65 objetSain = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2)
66 geompy.addToStudy( objetSain, 'objetSain' )
68 Rotation_1 = geompy.MakeRotation(Extrusion_1, OX, math.pi)
69 Partition_2 = geompy.MakePartition([Rotation_1], [Extrusion_2], [], [], geompy.ShapeType["FACE"], 0, [], 0)
70 geompy.addToStudy( Partition_2, 'Partition_2' )
71 [FaceFissExtSimple] = geompy.SubShapes(Partition_2, [13])
72 geompy.addToStudyInFather( Partition_2, FaceFissExtSimple, 'FaceFissExtSimple' )
73 Plane_1 = geompy.MakePlaneLCS(None, 2000., 3)
75 FaceFissExtCoupe = geompy.MakePartition([FaceFissExtSimple], [Plane_1], [], [], geompy.ShapeType["FACE"], 0, [], 0)
76 geompy.addToStudy( FaceFissExtCoupe, 'FaceFissExtCoupe' )
78 geompy.ExportBREP(FaceFissExtCoupe, os.path.join(gmu.pathBloc, "materielCasTests", "faceGauche2FissCoupe.brep"))
80 geomPublish(initLog.debug, Circle_1, 'Circle_1' )
81 geomPublish(initLog.debug, Extrusion_1, 'Extrusion_1' )
82 geomPublish(initLog.debug, Vertex_1, 'Vertex_1' )
83 geomPublish(initLog.debug, Circle_3, 'Circle_3' )
84 geomPublish(initLog.debug, Extrusion_2, 'Extrusion_2' )
85 geomPublish(initLog.debug, Partition_1, 'Partition_1' )
86 geomPublishInFather(initLog.debug, Partition_1, Face_1, 'Face_1' )
87 geomPublishInFather(initLog.debug, Partition_1, Face_2, 'Face_2' )
88 geomPublish(initLog.debug, Vertex_2, 'Vertex_2' )
89 geomPublish(initLog.debug, Vertex_3, 'Vertex_3' )
90 geomPublish(initLog.debug, Rotation_1, 'Rotation_1' )
91 geomPublish(initLog.debug, Plane_1, 'Plane_1' )
96 smesh = smeshBuilder.New()
97 Mesh_1 = smesh.Mesh(objetSain)
98 putName(Mesh_1.GetMesh(), 'Mesh_1')
100 Regular_1D = Mesh_1.Segment()
101 Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[ ])
102 Nb_Segments_1.SetDistrType( 0 )
103 Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
104 Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
107 #smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
108 #smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
109 #smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
110 putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='fissuregauche2')
112 is_done = Mesh_1.Compute()
113 text = "Mesh_1.Compute"
115 logging.info(text+" OK")
117 text = "Erreur au calcul du maillage.\n" + text
119 raise Exception(text)
121 Mesh_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "boiteSaine.med"))
123 if salome.sg.hasDesktop():
124 salome.sg.updateObjBrowser()