1 # -*- coding: utf-8 -*-
4 ### This file is generated automatically by SALOME v7.7.1 with dump python functionality
13 import salome_notebook
14 notebook = salome_notebook.NoteBook()
21 from salome.geom import geomBuilder
24 from . import utilityFunctions as uF
25 from .output import message
27 #ellipse.generate(data_demi_grand_axe, data_centre, data_normale,data_direction, data_demi_petit_axe, data_angle, rayon_entaille,extension, outFile)
29 #data_demi_grand_axe = 2.
30 #data_centre = [0., 0., 0.]
31 #data_normale = [1., 0., 0.]
32 #data_direction = [0., 1., 0.]
33 #data_demi_petit_axe = 1.
37 #outFile='/home/I60976/00_PROJETS/2015_INTEGRATION_ZCRACKS/zcracks_salome/test.med'
40 def generate(data_demi_grand_axe, data_centre, data_normale,
41 data_direction, data_demi_petit_axe, data_angle,
42 rayon_entaille, extension, outFile):
44 Vnormale, Vdirection, Vortho = uF.calcCoordVectors(data_normale, data_direction)
45 Vcentre = numpy.array(data_centre)
47 geompy = geomBuilder.New()
49 O = geompy.MakeVertex(0, 0, 0)
50 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
51 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
52 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
53 CENTRE = geompy.MakeVertex(Vcentre[0], Vcentre[1], Vcentre[2])
54 NORMALE = geompy.MakeVectorDXDYDZ(Vnormale[0], Vnormale[1], Vnormale[2])
55 DIRECTION = geompy.MakeVectorDXDYDZ(Vdirection[0], Vdirection[1], Vdirection[2])
56 DIRECTION_op = geompy.MakeVectorDXDYDZ(-Vdirection[0], -Vdirection[1], -Vdirection[2])
57 V3 = geompy.MakeVectorDXDYDZ(Vortho[0], Vortho[1], Vortho[2])
58 V3_op = geompy.MakeVectorDXDYDZ(-Vortho[0], -Vortho[1], -Vortho[2])
59 if data_demi_grand_axe >= data_demi_petit_axe:
60 ELLIPSE = geompy.MakeEllipse(CENTRE, NORMALE, data_demi_grand_axe, data_demi_petit_axe, DIRECTION)
62 ELLIPSE = geompy.MakeEllipse(CENTRE, NORMALE, data_demi_petit_axe, data_demi_grand_axe, V3)
64 if rayon_entaille<1.e-12:
65 FELLIPSE = geompy.MakeFaceWires([ELLIPSE], 1)
69 VP1=Vcentre+Vdirection*(data_demi_grand_axe-rayon_entaille)+Vnormale*rayon_entaille
70 VP2=Vcentre+Vdirection*(data_demi_grand_axe)
71 VP3=Vcentre+Vdirection*(data_demi_grand_axe-rayon_entaille)-Vnormale*rayon_entaille
72 PE1=geompy.MakeVertex(VP1[0], VP1[1], VP1[2])
73 PE2=geompy.MakeVertex(VP2[0], VP2[1], VP2[2])
74 PE3=geompy.MakeVertex(VP3[0], VP3[1], VP3[2])
75 ARC = geompy.MakeArc(PE1, PE2, PE3)
76 TUYAU = geompy.MakePipe(ARC, ELLIPSE)
77 subShapesList=geompy.GetFreeBoundary(TUYAU)[1]
78 entailleFace1 = geompy.MakeFaceWires([subShapesList[0]], 1)
79 entailleFace2 = geompy.MakeFaceWires([subShapesList[1]], 1)
80 FELLIPSE = geompy.MakeShell([TUYAU, entailleFace1, entailleFace2])
82 edgesIDs = geompy.SubShapeAllIDs(FELLIPSE, geompy.ShapeType["EDGE"])
83 edges = geompy.CreateGroup(FELLIPSE, geompy.ShapeType["EDGE"])
84 geompy.UnionIDs(edges, edgesIDs)
85 geompy.addToStudy( FELLIPSE, 'FELLIPSE' )
86 geompy.addToStudyInFather( FELLIPSE , edges, 'edges' )
88 hauteur=numpy.max([data_demi_grand_axe,data_demi_petit_axe])*1.1
92 extrusion=numpy.max([1.,rayon_entaille])*1.1
93 if ( (data_angle>(eps)) and (data_angle<(180.-eps)) ):
94 rayon2=hauteur*numpy.tan(data_angle*numpy.pi/180./2.)
96 B1=geompy.MakeTranslationVectorDistance(CENTRE,DIRECTION,hauteur)
97 B2=geompy.MakeTranslationVectorDistance(B1,V3,rayon2)
98 geompy.TranslateVectorDistance(B1,V3_op,rayon2, False)
99 LB01 = geompy.MakeLineTwoPnt(CENTRE, B1)
100 LB02 = geompy.MakeLineTwoPnt(CENTRE, B2)
101 LB12 = geompy.MakeLineTwoPnt(B1, B2)
102 plan_BOITE = geompy.MakeFaceWires([LB01, LB02, LB12], True)
104 BOITE = geompy.MakePrismVecH2Ways(plan_BOITE, NORMALE, extrusion)
106 FACE_FISSURE = geompy.MakeCommonList([FELLIPSE, BOITE])
108 elif ( (data_angle>=(180.-eps)) and (data_angle<=(180.+eps)) ):
109 VP1=Vcentre+Vortho*hauteur
110 VP2=Vcentre-Vortho*hauteur
111 VP3=Vcentre-Vortho*hauteur+Vdirection*hauteur
112 VP4=Vcentre+Vortho*hauteur+Vdirection*hauteur
114 Sommet_1 = geompy.MakeVertex(VP1[0], VP1[1], VP1[2])
115 Sommet_2 = geompy.MakeVertex(VP2[0], VP2[1], VP2[2])
116 Sommet_3 = geompy.MakeVertex(VP3[0], VP3[1], VP3[2])
117 Sommet_4 = geompy.MakeVertex(VP4[0], VP4[1], VP4[2])
119 Ligne_1 = geompy.MakeLineTwoPnt(Sommet_1, Sommet_2)
120 Ligne_2 = geompy.MakeLineTwoPnt(Sommet_2, Sommet_3)
121 Ligne_3 = geompy.MakeLineTwoPnt(Sommet_3, Sommet_4)
122 Ligne_4 = geompy.MakeLineTwoPnt(Sommet_4, Sommet_1)
124 Contour_1 = geompy.MakeWire([Ligne_1, Ligne_2, Ligne_3, Ligne_4], 1e-07)
125 Face_1 = geompy.MakeFaceWires([Contour_1], 1)
126 BOITE = geompy.MakePrismVecH2Ways(Face_1, NORMALE, extrusion)
127 FACE_FISSURE = geompy.MakeCommonList([FELLIPSE, BOITE])
129 elif ( (data_angle>(180.+eps)) and (data_angle<(360.-eps)) ):
130 rayon2=hauteur*numpy.tan((360.-data_angle)*numpy.pi/180./2.)
132 B1=geompy.MakeTranslationVectorDistance(CENTRE,DIRECTION_op,hauteur)
133 B2=geompy.MakeTranslationVectorDistance(B1,V3,rayon2)
134 geompy.TranslateVectorDistance(B1,V3_op,rayon2, False)
135 LB01 = geompy.MakeLineTwoPnt(CENTRE, B1)
136 LB02 = geompy.MakeLineTwoPnt(CENTRE, B2)
137 LB12 = geompy.MakeLineTwoPnt(B1, B2)
138 plan_BOITE = geompy.MakeFaceWires([LB01, LB02, LB12], True)
139 extrusion=numpy.max([1.,rayon_entaille])*1.1
140 BOITE = geompy.MakePrismVecH2Ways(plan_BOITE, NORMALE, extrusion)
142 FACE_FISSURE = geompy.MakeCutList(FELLIPSE, [BOITE])
144 elif ( (data_angle<=(eps)) or (data_angle>=(360.-eps)) ):
146 FACE_FISSURE = FELLIPSE
149 message('E','Angle non prevu')
152 #geompy.addToStudy( BOITE, 'BOITE' )
153 newEdgesIDs = geompy.SubShapeAllIDs(FACE_FISSURE, geompy.ShapeType["EDGE"])
154 newEdges = geompy.CreateGroup(FACE_FISSURE, geompy.ShapeType["EDGE"])
155 geompy.UnionIDs(newEdges, newEdgesIDs)
157 [oldEdges] = geompy.RestoreGivenSubShapes(FACE_FISSURE, [FELLIPSE, edges], GEOM.FSM_GetInPlace, True, False)
159 toExtrude = geompy.CutListOfGroups([newEdges], [oldEdges])
162 extrusion = geompy.MakePrismVecH(toExtrude, DIRECTION_op, extension)
164 FACE_FISSURE = geompy.MakeFuseList([FACE_FISSURE, extrusion], False, True)
166 FACE_FISSURE = geompy.MakeFuseList([FACE_FISSURE, extrusion], False, False)
168 #geompy.addToStudy( FACE_FISSURE, 'FACE_FISSURE' )
170 #geompy.addToStudy( FACE_FISSURE, 'FACE_FISSURE' )
172 import SMESH, SALOMEDS
173 from salome.smesh import smeshBuilder
174 smesh = smeshBuilder.New()
177 minAxes=numpy.min([data_demi_grand_axe,data_demi_petit_axe])
178 maxAxes=numpy.max([data_demi_grand_axe,data_demi_petit_axe])
181 if rayon_entaille>1.e-12:
182 R=numpy.min([R,rayon_entaille])
185 chordal, minSize = uF.calcElemSize(A, R)
188 Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim)
191 Maillage.ExportMED(outFile)
192 smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
194 print('ExportMED() failed. Invalid file name?')
197 ## Set names of Mesh objects
200 if salome.sg.hasDesktop():
201 salome.sg.updateObjBrowser()