1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 EDF R&D
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
28 import salome_notebook
29 notebook = salome_notebook.notebook
32 from blocFissure import gmu
39 from salome.geom import geomBuilder
44 geompy = geomBuilder.New()
46 O = geompy.MakeVertex(0, 0, 0)
47 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
48 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
49 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
50 Vertex_1 = geompy.MakeVertex(-2000, 0, 0)
51 Cylinder_1 = geompy.MakeCylinder(Vertex_1, OY, 1900, 300)
52 Cylinder_2 = geompy.MakeCylinder(Vertex_1, OY, 2100, 300)
53 Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1)
54 Vertex_2 = geompy.MakeVertex(-500, -100, -300)
55 Vertex_3 = geompy.MakeVertex(500, 400, 300)
56 Box_1 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2)
57 Common_1 = geompy.MakeCommon(Box_1, Cut_1)
58 Vertex_4 = geompy.MakeVertex(-300, -1000, 0)
59 Cylinder_3 = geompy.MakeCylinder(Vertex_4, OX, 1100, 600)
60 EprouvetteCourbe = geompy.MakeCut(Common_1, Cylinder_3)
61 [Compound_y, Compound_z, Compound_x] = geompy.Propagate(EprouvetteCourbe)
62 geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
63 Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -110.000000 85.000000:T 220.000000 0.000000:T 0.000000 75.000000:T -220.000000 0.000000:WW", geomObj_1 )
64 SectionDroite = geompy.MakeFaceWires([Sketch_1], 1)
65 geompy.ExportBREP(SectionDroite, os.path.join(gmu.pathBloc, "materielCasTests", "EprouvetteCourbeFiss.brep"))
66 geompy.addToStudy( O, 'O' )
67 geompy.addToStudy( OX, 'OX' )
68 geompy.addToStudy( OY, 'OY' )
69 geompy.addToStudy( OZ, 'OZ' )
70 geompy.addToStudy( Vertex_1, 'Vertex_1' )
71 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
72 geompy.addToStudy( Cylinder_2, 'Cylinder_2' )
73 geompy.addToStudy( Cut_1, 'Cut_1' )
74 geompy.addToStudy( Vertex_2, 'Vertex_2' )
75 geompy.addToStudy( Vertex_3, 'Vertex_3' )
76 geompy.addToStudy( Box_1, 'Box_1' )
77 geompy.addToStudy( Common_1, 'Common_1' )
78 geompy.addToStudy( Cylinder_3, 'Cylinder_3' )
79 geompy.addToStudy( Vertex_4, 'Vertex_4' )
80 geompy.addToStudy( EprouvetteCourbe, 'EprouvetteCourbe' )
81 geompy.addToStudy( Sketch_1, 'Sketch_1' )
82 geompy.addToStudy( SectionDroite, 'SectionDroite' )
83 geompy.addToStudyInFather( EprouvetteCourbe, Compound_y, 'Compound_y' )
84 geompy.addToStudyInFather( EprouvetteCourbe, Compound_z, 'Compound_z' )
85 geompy.addToStudyInFather( EprouvetteCourbe, Compound_x, 'Compound_x' )
91 import SMESH, SALOMEDS
92 from salome.smesh import smeshBuilder
94 smesh = smeshBuilder.New()
95 from salome.StdMeshers import StdMeshersBuilder
96 EprouvetteCourbe_1 = smesh.Mesh(EprouvetteCourbe)
97 smesh.SetName(EprouvetteCourbe_1, 'EprouvetteCourbe')
98 Regular_1D = EprouvetteCourbe_1.Segment()
99 Nb_Segments_1 = Regular_1D.NumberOfSegments(50)
100 Nb_Segments_1.SetDistrType( 0 )
101 Quadrangle_2D = EprouvetteCourbe_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
102 Hexa_3D = EprouvetteCourbe_1.Hexahedron(algo=smeshBuilder.Hexa)
103 Regular_1D_1 = EprouvetteCourbe_1.Segment(geom=Compound_x)
104 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(15)
105 Nb_Segments_2.SetDistrType( 0 )
106 Regular_1D_2 = EprouvetteCourbe_1.Segment(geom=Compound_y)
107 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(25)
108 Nb_Segments_3.SetDistrType( 0 )
109 is_done = EprouvetteCourbe_1.Compute()
110 text = "EprouvetteCourbe_1.Compute"
112 logging.info(text+" OK")
114 text = "Erreur au calcul du maillage.\n" + text
116 raise Exception(text)
117 EprouvetteCourbe_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "EprouvetteCourbe.med"))
118 SubMesh_1 = Regular_1D_1.GetSubMesh()
119 SubMesh_2 = Regular_1D_2.GetSubMesh()
122 smesh.SetName(EprouvetteCourbe_1.GetMesh(), 'EprouvetteCourbe')
123 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
124 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
125 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
126 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
127 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
128 smesh.SetName(Nb_Segments_3, 'Nb. Segments_3')
129 smesh.SetName(SubMesh_1, 'SubMesh_1')
130 smesh.SetName(SubMesh_2, 'SubMesh_2')
132 if salome.sg.hasDesktop():
133 salome.sg.updateObjBrowser()