#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+"""Géométrie et maillage de base nécessaire au cas-test :
+. tube
+"""
-"""Cas-test de blocFissure sur un tube"""
-__revision__ = "V02.04"
+__revision__ = "V02.08"
+
+import os
import logging
-import sys
import salome
+from salome.shaper import model
+from salome.smesh import smeshBuilder
+from SketchAPI import *
+import SHAPERSTUDY
+import SMESH
-salome.salome_init()
-
-import os
from blocFissure import gmu
+from blocFissure.gmu.putName import putName
#=============== Options ====================
# 1. NOM_OBJET = nom de l'objet
F_THETA_1 = 3.
F_C_1 = 1.04
F_L_2 = 20.
+F_C_3 = 0.99
# 3. Maillage
# Nombre de segments du tube
NB_S_E = 4
NB_S_P = 30
#============================================
+salome.salome_init()
+
###
### SHAPER component
###
-from SketchAPI import *
-
-from salome.shaper import model
-
model.begin()
partSet = model.moduleDocument()
model.addParameter(Part_1_doc, "F_THETA_1", "{}".format(F_THETA_1))
model.addParameter(Part_1_doc, "F_R_1", "{}*{}".format(F_C_1,RAYON_INT))
model.addParameter(Part_1_doc, "F_L_2", "{}".format(F_L_2))
+model.addParameter(Part_1_doc, "F_D_3", "{}*{}".format(F_C_3,RAYON_INT))
### Create Sketch
Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
### Create Revolution
Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 180, 0)
Revolution_1.result().setName("Tube")
-Revolution_1.result().setTransparency(0.9399999999999999)
+Revolution_1.result().setTransparency(0.37)
### Create Sketch
Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
### Create SketchConstraintAngle
Sketch_2.setAngle(SketchLine_5.result(), SketchLine_6.result(), "F_THETA_1", type = "Direct")
-### Create SketchProjection
-SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
-SketchPoint_5 = SketchProjection_5.createdFeature()
-
### Create SketchEllipticArc
-SketchEllipticArc_1 = Sketch_2.addEllipticArc(-20, 8.956370781951521e-27, -10.21629725685072, 9.783702743149284, 10.10993798723031, 4.722461741243296, 9.440921421952831, 9.565935245237778, False)
-[SketchPoint_6, SketchPoint_7, SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchPoint_12, SketchLine_7, SketchLine_8] = SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+SketchEllipticArc_1 = Sketch_2.addEllipticArc(-20, 8.956370781951521e-27, -10.21629725685072, 9.783702743149284, 10.10993798723031, 4.722461741243296, 9.7416, 8.052073253504034, False)
+[SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchLine_7, SketchLine_8] = \
+ SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
Sketch_2.setCoincident(SketchEllipticArc_1.startPoint(), SketchLine_6.endPoint())
-Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_6).coordinates(), SketchLine_5.result())
+Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_5).coordinates(), SketchLine_5.result())
Sketch_2.setTangent(SketchEllipticArc_1.result(), SketchArc_1.results()[1])
### Create SketchProjection
-SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
-SketchPoint_13 = SketchProjection_6.createdFeature()
-Sketch_2.setHorizontalDistance(SketchAPI_Point(SketchPoint_6).coordinates(), SketchAPI_Point(SketchPoint_13).coordinates(), "F_L_2")
-
-### Create SketchLine
-SketchLine_9 = Sketch_2.addLine(-20, 8.956370781951521e-27, 9.440921421952831, 9.565935245237778)
-SketchLine_9.setAuxiliary(True)
-Sketch_2.setCoincident(SketchEllipticArc_1.center(), SketchLine_9.startPoint())
-Sketch_2.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_9.endPoint())
-
-### Create SketchConstraintAngle
-Sketch_2.setAngle(SketchLine_9.result(), SketchLine_5.result(), "6.*F_THETA_1", type = "Direct")
+SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_12 = SketchProjection_5.createdFeature()
+Sketch_2.setHorizontalDistance(SketchAPI_Point(SketchPoint_5).coordinates(), SketchAPI_Point(SketchPoint_12).coordinates(), "F_L_2")
### Create SketchConstraintAngle
Sketch_2.setAngle(SketchLine_5.result(), SketchLine_7.result(), 45, type = "Supplementary")
+### Create SketchProjection
+SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_13 = SketchProjection_6.createdFeature()
+Sketch_2.setHorizontalDistance(SketchEllipticArc_1.endPoint(), SketchAPI_Point(SketchPoint_13).coordinates(), "F_D_3")
+
### Create SketchConstraintMirror
SketchConstraintMirror_1 = Sketch_2.addMirror(SketchLine_5.result(), [SketchEllipticArc_1.result()])
[SketchEllipticArc_2] = SketchConstraintMirror_1.mirrored()
### Create SketchLine
-SketchLine_10 = Sketch_2.addLine(9.440921421952831, 9.565935245237778, 9.440921421952837, -9.565935245237783)
-Sketch_2.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_10.startPoint())
-Sketch_2.setCoincident(SketchAPI_EllipticArc(SketchEllipticArc_2).endPoint(), SketchLine_10.endPoint())
+SketchLine_9 = Sketch_2.addLine(9.7416, 8.052073253504034, 9.7416, -8.052073253504034)
+Sketch_2.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_9.startPoint())
+Sketch_2.setCoincident(SketchAPI_EllipticArc(SketchEllipticArc_2).endPoint(), SketchLine_9.endPoint())
model.do()
### Create Face
-Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_1_2r-SketchEllipticArc_1f-SketchLine_10f-SketchEllipticArc_2f")])
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_1_2r-SketchEllipticArc_1f-SketchLine_9f-SketchEllipticArc_2f")])
Face_1.result().setName("Fissure")
### Create Group
Group_3 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchEllipticArc_2")])
### Create Group
-Group_4 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchLine_10")])
+Group_4 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "Fissure/Modified_Edge&Sketch_2/SketchLine_9")])
### Create Group
Group_5 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Tube/Generated_Face&Sketch_1/SketchLine_1][Tube/From_Face]")])
Group_7.result().setName("Peripherie")
### Create Export
-ficxao = os.path.join(gmu.pathBloc, "materielCasTests", "{}Fiss.xao".format(NOM_OBJET))
-text = ".. Exportation de la géométrie de la fissure dans le fichier '{}'".format(ficxao)
+ficcao = os.path.join(gmu.pathBloc, "materielCasTests", "{}Fiss.xao".format(NOM_OBJET))
+text = ".. Exportation de la géométrie de la fissure dans le fichier '{}'".format(ficcao)
logging.info(text)
-_ = model.exportToXAO(Part_1_doc, ficxao, model.selection("FACE", "Fissure"), 'XAO')
+_ = model.exportToXAO(Part_1_doc, ficcao, model.selection("FACE", "Fissure"), 'XAO')
model.end()
###
model.publishToShaperStudy()
-import SHAPERSTUDY
+
l_aux = SHAPERSTUDY.shape(model.featureStringId(Revolution_1))
objet = l_aux[0]
l_groups = l_aux[1:]
### SMESH component
###
-import SMESH, SALOMEDS
-from salome.smesh import smeshBuilder
-
smesh = smeshBuilder.New()
-from salome.StdMeshers import StdMeshersBuilder
Maillage_tube = smesh.Mesh(objet)
-smesh.SetName(Maillage_tube, NOM_OBJET)
+putName(Maillage_tube.GetMesh(), NOM_OBJET)
for groupe in l_groups:
groupe_nom = groupe.GetName()
Number_of_Segments_2 = Regular_1D_2.NumberOfSegments(NB_S_H)
Propagation_of_1D_Hyp_1 = Regular_1D_2.Propagation()
+## set object names
+#smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
+#smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
+#smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
+putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='tube')
+putName(Number_of_Segments_1, 'Number_of_Segments_1', i_pref='tube')
+putName(Number_of_Segments_2, 'Number_of_Segments_2', i_pref='tube')
+putName(Propagation_of_1D_Hyp, 'Propagation', i_pref='tube')
+
is_done = Maillage_tube.Compute()
text = "Maillage_tube.Compute"
if is_done:
logging.info(text)
Maillage_tube.ExportMED(ficmed)
-## set object names
-smesh.SetName(Maillage_tube.GetMesh(), 'Maillage_tube')
-smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
-smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
-smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
-smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
-
if salome.sg.hasDesktop():
salome.sg.updateObjBrowser()