1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2019 CEA/DEN, 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
26 import salome_notebook
29 from blocFissure import gmu
36 from salome.geom import geomBuilder
41 geompy = geomBuilder.New()
43 O = geompy.MakeVertex(0, 0, 0)
44 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
45 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
46 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
47 eprouvetteDroite = geompy.MakeBoxDXDYDZ(100, 200, 500)
48 [Compound_z, Compound_y, Compound_x] = geompy.Propagate(eprouvetteDroite)
50 Vertex_1 = geompy.MakeVertex(-10, -10, 200)
51 geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
52 Plane_1 = geompy.MakePlane(Vertex_1, OZ, 2000)
53 geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
54 Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F 0.000000 0.000000:TT 120.000000 0.000000:T 0.000000 100.000000:T -120.000000 0.000000:WW", Plane_1 )
55 sectionDroite = geompy.MakeFaceWires([Sketch_1], 1)
56 Box_1_vertex_7 = geompy.GetSubShape(eprouvetteDroite, [7])
57 Box_1_vertex_16 = geompy.GetSubShape(eprouvetteDroite, [16])
58 Line_1 = geompy.MakeLineTwoPnt(Box_1_vertex_7, Box_1_vertex_16)
59 geomObj_3 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
60 Plane_2 = geompy.MakePlane(Vertex_1, Line_1, 2000)
61 geomObj_4 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
62 Sketch_2 = geompy.MakeSketcherOnPlane("Sketcher:F 0.000000 0.000000:T 120.000000 0.000000:T 0.000000 100.000000:T -120.000000 20.000000:WW", Plane_2 )
63 SectionInclinee = geompy.MakeFaceWires([Sketch_2], 1)
64 geompy.ExportBREP(sectionDroite, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFissPb1.brep"))
65 geompy.ExportBREP(SectionInclinee, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss2.brep"))
66 Vertex_2 = geompy.MakeVertex(110, -10, 200)
67 Vertex_3 = geompy.MakeVertex(110, 80, 200)
68 Vertex_4 = geompy.MakeVertex(-10, 80, 200)
69 Line_2 = geompy.MakeLineTwoPnt(Vertex_1, Vertex_2)
70 Line_3 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3)
71 Line_4 = geompy.MakeLineTwoPnt(Vertex_3, Vertex_4)
72 Line_5 = geompy.MakeLineTwoPnt(Vertex_4, Vertex_1)
73 Face_1 = geompy.MakeFaceWires([Line_2, Line_3, Line_4, Line_5], 1)
74 Vertex_5 = geompy.MakeVertex(110, -10, 180)
75 Vertex_6 = geompy.MakeVertex(110, 70, 180)
76 Face_1_vertex_4 = geompy.GetSubShape(Face_1, [4])
77 Line_6 = geompy.MakeLineTwoPnt(Face_1_vertex_4, Vertex_5)
78 Line_7 = geompy.MakeLineTwoPnt(Vertex_5, Vertex_6)
79 Face_1_vertex_9 = geompy.GetSubShape(Face_1, [9])
80 Line_8 = geompy.MakeLineTwoPnt(Vertex_6, Face_1_vertex_9)
81 Face_2 = geompy.MakeFaceWires([Line_5, Line_6, Line_7, Line_8], 1)
82 geompy.ExportBREP(Face_1, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss_1.brep"))
83 geompy.ExportBREP(Face_2, os.path.join(gmu.pathBloc, "materielCasTests/EprouvetteDroiteFiss_2.brep"))
84 geompy.addToStudy( O, 'O' )
85 geompy.addToStudy( OX, 'OX' )
86 geompy.addToStudy( OY, 'OY' )
87 geompy.addToStudy( OZ, 'OZ' )
88 geompy.addToStudy( eprouvetteDroite, 'eprouvetteDroite' )
89 geompy.addToStudyInFather( eprouvetteDroite, Compound_z, 'Compound_z' )
90 geompy.addToStudyInFather( eprouvetteDroite, Compound_y, 'Compound_y' )
91 geompy.addToStudyInFather( eprouvetteDroite, Compound_x, 'Compound_x' )
92 geompy.addToStudy( Vertex_1, 'Vertex_1' )
93 geompy.addToStudy( Plane_1, 'Plane_1' )
94 geompy.addToStudy( Sketch_1, 'Sketch_1' )
95 geompy.addToStudy( sectionDroite, 'sectionDroite' )
96 geompy.addToStudyInFather( eprouvetteDroite, Box_1_vertex_7, 'Box_1:vertex_7' )
97 geompy.addToStudyInFather( eprouvetteDroite, Box_1_vertex_16, 'Box_1:vertex_16' )
98 geompy.addToStudy( Line_1, 'Line_1' )
99 geompy.addToStudy( Plane_2, 'Plane_2' )
100 geompy.addToStudy( Sketch_2, 'Sketch_2' )
101 geompy.addToStudy( SectionInclinee, 'SectionInclinee' )
102 geompy.addToStudy( Vertex_2, 'Vertex_2' )
103 geompy.addToStudy( Vertex_3, 'Vertex_3' )
104 geompy.addToStudy( Vertex_4, 'Vertex_4' )
105 geompy.addToStudy( Line_2, 'Line_2' )
106 geompy.addToStudy( Line_3, 'Line_3' )
107 geompy.addToStudy( Line_4, 'Line_4' )
108 geompy.addToStudy( Line_5, 'Line_5' )
109 geompy.addToStudy( Face_1, 'Face_1' )
110 geompy.addToStudy( Vertex_5, 'Vertex_5' )
111 geompy.addToStudy( Vertex_6, 'Vertex_6' )
112 geompy.addToStudyInFather( Face_1, Face_1_vertex_4, 'Face_1:vertex_4' )
113 geompy.addToStudy( Line_6, 'Line_6' )
114 geompy.addToStudy( Line_7, 'Line_7' )
115 geompy.addToStudyInFather( Face_1, Face_1_vertex_9, 'Face_1:vertex_9' )
116 geompy.addToStudy( Line_8, 'Line_8' )
117 geompy.addToStudy( Face_2, 'Face_2' )
123 import SMESH, SALOMEDS
124 from salome.smesh import smeshBuilder
126 smesh = smeshBuilder.New()
127 from salome.StdMeshers import StdMeshersBuilder
128 eprouvetteDroite_1 = smesh.Mesh(eprouvetteDroite)
129 Regular_1D = eprouvetteDroite_1.Segment()
130 Nb_Segments_1 = Regular_1D.NumberOfSegments(50,[],[ ])
131 Nb_Segments_1.SetDistrType( 0 )
132 Quadrangle_2D = eprouvetteDroite_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
133 Hexa_3D = eprouvetteDroite_1.Hexahedron(algo=smeshBuilder.Hexa)
134 Regular_1D_1 = eprouvetteDroite_1.Segment(geom=Compound_y)
135 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20,[],[ ])
136 Nb_Segments_2.SetDistrType( 0 )
137 Regular_1D_2 = eprouvetteDroite_1.Segment(geom=Compound_x)
138 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(10,[],[ ])
139 Nb_Segments_3.SetDistrType( 0 )
140 isDone = eprouvetteDroite_1.Compute()
141 smesh.SetName(eprouvetteDroite_1, 'eprouvetteDroite')
142 eprouvetteDroite_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/eprouvetteDroite.med"))
143 SubMesh_1 = Regular_1D_1.GetSubMesh()
144 SubMesh_2 = Regular_1D_2.GetSubMesh()
147 smesh.SetName(eprouvetteDroite_1.GetMesh(), 'eprouvetteDroite')
148 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
149 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
150 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
151 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
152 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
153 smesh.SetName(Nb_Segments_3, 'Nb. Segments_3')
154 smesh.SetName(SubMesh_1, 'SubMesh_1')
155 smesh.SetName(SubMesh_2, 'SubMesh_2')
157 if salome.sg.hasDesktop():
158 salome.sg.updateObjBrowser()