PR: examples adaptation

This commit is contained in:
prascle 2013-03-14 11:03:51 +00:00
parent 1d6c201310
commit bc14d0c0f2
10 changed files with 356 additions and 314 deletions

View File

@ -23,9 +23,15 @@
# =======================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometry
# ========
@ -57,68 +63,66 @@ g_trim = 1000
# Solids and rotation to prevent repair
# -------------------------------------
s_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
s_boite = geompy.MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete)
s_pi4 = 3.141592653/4
s_hauteur = 2*g_hauteur
s_centre = MakeVertex(g_x, g_y-g_hauteur, g_z)
s_dir = MakeVectorDXDYDZ(0, 1, 0)
s_centre = geompy.MakeVertex(g_x, g_y-g_hauteur, g_z)
s_dir = geompy.MakeVectorDXDYDZ(0, 1, 0)
s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur)
s_cyl1 = MakeRotation(s_cyl0, s_dir, s_pi4)
s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur)
s_cyl1 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4)
s_blo1 = MakeCut(s_boite, s_cyl1)
s_blo1 = geompy.MakeCut(s_boite, s_cyl1)
s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur)
s_cyl2 = MakeRotation(s_cyl0, s_dir, s_pi4)
s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur)
s_cyl2 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4)
s_blo2 = MakeCut(s_cyl1, s_cyl2)
s_blo2 = geompy.MakeCut(s_cyl1, s_cyl2)
s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur)
s_cyl3 = MakeRotation(s_cyl0, s_dir, s_pi4)
s_cyl0 = geompy.MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur)
s_cyl3 = geompy.MakeRotation(s_cyl0, s_dir, s_pi4)
s_blo3 = MakeCut(s_cyl2, s_cyl3)
s_blo3 = geompy.MakeCut(s_cyl2, s_cyl3)
s_arete = g_rayon1/2
s_blo4 = MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete, g_x+s_arete, g_y+g_hauteur, g_z+s_arete)
s_blo4 = geompy.MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete, g_x+s_arete, g_y+g_hauteur, g_z+s_arete)
s_blo5 = MakeCut(s_cyl3, s_blo4)
s_blo5 = geompy.MakeCut(s_cyl3, s_blo4)
# Partition
# ---------
p_tools = []
p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim))
p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim))
p_tools.append(geompy.MakePlane(s_centre, geompy.MakeVectorDXDYDZ( 1, 0, 1), g_trim))
p_tools.append(geompy.MakePlane(s_centre, geompy.MakeVectorDXDYDZ(-1, 0, 1), g_trim))
p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"])
p_partie = geompy.MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], geompy.ShapeType["SOLID"])
# Compound and glue
# -----------------
c_blocs = SubShapeAll(p_partie, ShapeType["SOLID"])
c_blocs = geompy.SubShapeAll(p_partie, geompy.ShapeType["SOLID"])
c_blocs.append(s_blo4)
c_cpd = MakeCompound(c_blocs)
c_cpd = geompy.MakeCompound(c_blocs)
c_element = MakeGlueFaces(c_cpd, 1e-4)
c_element = geompy.MakeGlueFaces(c_cpd, 1e-4)
# Grid
# ----
piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
piece = geompy.MakeMultiTranslation2D(c_element, geompy.MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, geompy.MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid)
# Add in study
# ------------
piece_id = addToStudy(piece, "ex12_grid17partition")
piece_id = geompy.addToStudy(piece, "ex12_grid17partition")
# Meshing
# =======
smesh.SetCurrentStudy(salome.myStudy)
# Create a hexahedral mesh
# ------------------------

View File

@ -23,9 +23,15 @@
# ==================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometry
# ========
@ -50,11 +56,11 @@ cyl_thick = 30
def triangle(p1, p2, p3):
l = []
l.append(MakeEdge(p1, p2))
l.append(MakeEdge(p2, p3))
l.append(MakeEdge(p3, p1))
w = MakeWire(l)
return MakeFace(w, 1)
l.append(geompy.MakeEdge(p1, p2))
l.append(geompy.MakeEdge(p2, p3))
l.append(geompy.MakeEdge(p3, p1))
w = geompy.MakeWire(l)
return geompy.MakeFace(w, 1)
# The holed part
# ==============
@ -62,12 +68,12 @@ def triangle(p1, p2, p3):
# Vertex of the holed part
# ------------------------
hole_point_11 = MakeVertex(0 , 0 , 0)
hole_point_21 = MakeVertex(box_dx, 0 , 0)
hole_point_12 = MakeVertex(0 , box_dy, 0)
hole_point_22 = MakeVertex(box_dx, box_dy, 0)
hole_point_11 = geompy.MakeVertex(0 , 0 , 0)
hole_point_21 = geompy.MakeVertex(box_dx, 0 , 0)
hole_point_12 = geompy.MakeVertex(0 , box_dy, 0)
hole_point_22 = geompy.MakeVertex(box_dx, box_dy, 0)
hole_center = MakeVertex(cyl_x, cyl_y, 0)
hole_center = geompy.MakeVertex(cyl_x, cyl_y, 0)
# Faces of the holed part
# -----------------------
@ -80,33 +86,33 @@ hole_face_4 = triangle(hole_point_11, hole_point_12, hole_center)
# Solids of the holed part
# ------------------------
cyl_dir = MakeVectorDXDYDZ(0, 0, 1)
cyl_dir = geompy.MakeVectorDXDYDZ(0, 0, 1)
hole_solid_1 = MakePrismVecH(hole_face_1, cyl_dir, cyl_dz)
hole_solid_2 = MakePrismVecH(hole_face_2, cyl_dir, cyl_dz)
hole_solid_3 = MakePrismVecH(hole_face_3, cyl_dir, cyl_dz)
hole_solid_4 = MakePrismVecH(hole_face_4, cyl_dir, cyl_dz)
hole_solid_1 = geompy.MakePrismVecH(hole_face_1, cyl_dir, cyl_dz)
hole_solid_2 = geompy.MakePrismVecH(hole_face_2, cyl_dir, cyl_dz)
hole_solid_3 = geompy.MakePrismVecH(hole_face_3, cyl_dir, cyl_dz)
hole_solid_4 = geompy.MakePrismVecH(hole_face_4, cyl_dir, cyl_dz)
hole_internal = MakeCylinder(hole_center, cyl_dir, cyl_radius , cyl_dz)
hole_external = MakeCylinder(hole_center, cyl_dir, cyl_radius+cyl_thick, cyl_dz)
hole_median = MakeCut(hole_external, hole_internal)
hole_internal = geompy.MakeCylinder(hole_center, cyl_dir, cyl_radius , cyl_dz)
hole_external = geompy.MakeCylinder(hole_center, cyl_dir, cyl_radius+cyl_thick, cyl_dz)
hole_median = geompy.MakeCut(hole_external, hole_internal)
# Boolean operations
# ------------------
blocks = []
blocks.append( MakeCut(hole_solid_1, hole_external))
blocks.append(MakeCommon(hole_solid_1, hole_median ))
blocks.append( geompy.MakeCut(hole_solid_1, hole_external))
blocks.append(geompy.MakeCommon(hole_solid_1, hole_median ))
blocks.append( MakeCut(hole_solid_2, hole_external))
blocks.append(MakeCommon(hole_solid_2, hole_median ))
blocks.append( geompy.MakeCut(hole_solid_2, hole_external))
blocks.append(geompy.MakeCommon(hole_solid_2, hole_median ))
blocks.append( MakeCut(hole_solid_3, hole_external))
blocks.append(MakeCommon(hole_solid_3, hole_median ))
blocks.append( geompy.MakeCut(hole_solid_3, hole_external))
blocks.append(geompy.MakeCommon(hole_solid_3, hole_median ))
blocks.append( MakeCut(hole_solid_4, hole_external))
blocks.append(MakeCommon(hole_solid_4, hole_median ))
blocks.append( geompy.MakeCut(hole_solid_4, hole_external))
blocks.append(geompy.MakeCommon(hole_solid_4, hole_median ))
# The full part
# =============
@ -114,12 +120,12 @@ blocks.append(MakeCommon(hole_solid_4, hole_median ))
# Vertex of the full part
# -----------------------
full_point_11 = MakeVertex(0 , 0 , cyl_dz)
full_point_21 = MakeVertex(box_dx, 0 , cyl_dz)
full_point_12 = MakeVertex(0 , box_dy, cyl_dz)
full_point_22 = MakeVertex(box_dx, box_dy, cyl_dz)
full_point_11 = geompy.MakeVertex(0 , 0 , cyl_dz)
full_point_21 = geompy.MakeVertex(box_dx, 0 , cyl_dz)
full_point_12 = geompy.MakeVertex(0 , box_dy, cyl_dz)
full_point_22 = geompy.MakeVertex(box_dx, box_dy, cyl_dz)
full_center = MakeVertex(cyl_x, cyl_y, cyl_dz)
full_center = geompy.MakeVertex(cyl_x, cyl_y, cyl_dz)
# Faces of the full part
# ----------------------
@ -134,31 +140,31 @@ full_face_4 = triangle(full_point_11, full_point_12, full_center)
full_dz = box_dz - cyl_dz
full_solid_1 = MakePrismVecH(full_face_1, cyl_dir, full_dz)
full_solid_2 = MakePrismVecH(full_face_2, cyl_dir, full_dz)
full_solid_3 = MakePrismVecH(full_face_3, cyl_dir, full_dz)
full_solid_4 = MakePrismVecH(full_face_4, cyl_dir, full_dz)
full_solid_1 = geompy.MakePrismVecH(full_face_1, cyl_dir, full_dz)
full_solid_2 = geompy.MakePrismVecH(full_face_2, cyl_dir, full_dz)
full_solid_3 = geompy.MakePrismVecH(full_face_3, cyl_dir, full_dz)
full_solid_4 = geompy.MakePrismVecH(full_face_4, cyl_dir, full_dz)
full_internal = MakeCylinder(full_center, cyl_dir, cyl_radius , full_dz)
full_external = MakeCylinder(full_center, cyl_dir, cyl_radius+cyl_thick, full_dz)
full_median = MakeCut(full_external, full_internal)
full_internal = geompy.MakeCylinder(full_center, cyl_dir, cyl_radius , full_dz)
full_external = geompy.MakeCylinder(full_center, cyl_dir, cyl_radius+cyl_thick, full_dz)
full_median = geompy.MakeCut(full_external, full_internal)
# Boolean operations
# ------------------
full = []
full.append( MakeCut(full_solid_1, full_external))
full.append(MakeCommon(full_solid_1, full_median))
full.append( geompy.MakeCut(full_solid_1, full_external))
full.append(geompy.MakeCommon(full_solid_1, full_median))
full.append( MakeCut(full_solid_2, full_external))
full.append(MakeCommon(full_solid_2, full_median ))
full.append( geompy.MakeCut(full_solid_2, full_external))
full.append(geompy.MakeCommon(full_solid_2, full_median ))
full.append( MakeCut(full_solid_3, full_external))
full.append(MakeCommon(full_solid_3, full_median))
full.append( geompy.MakeCut(full_solid_3, full_external))
full.append(geompy.MakeCommon(full_solid_3, full_median))
full.append( MakeCut(full_solid_4, full_external))
full.append(MakeCommon(full_solid_4, full_median))
full.append( geompy.MakeCut(full_solid_4, full_external))
full.append(geompy.MakeCommon(full_solid_4, full_median))
# Filling the hole
# ----------------
@ -167,56 +173,54 @@ box_d = cyl_radius/3
x = cyl_x-box_d
y = x * cyl_y / cyl_x
box_point_11 = MakeVertex(x, y, cyl_dz)
box_point_11 = geompy.MakeVertex(x, y, cyl_dz)
x = cyl_x+box_d
y = (box_dx - x) * cyl_y / (box_dx - cyl_x)
box_point_12 = MakeVertex(x, y, cyl_dz)
box_point_12 = geompy.MakeVertex(x, y, cyl_dz)
x = cyl_x-box_d
y = box_dy - x * (box_dy - cyl_y) / cyl_x
box_point_21 = MakeVertex(x, y, cyl_dz)
box_point_21 = geompy.MakeVertex(x, y, cyl_dz)
x = cyl_x+box_d
y = box_dy - (box_dx - x) * (box_dy - cyl_y) / (box_dx - cyl_x)
box_point_22 = MakeVertex(x, y, cyl_dz)
box_point_22 = geompy.MakeVertex(x, y, cyl_dz)
box_face = MakeQuad4Vertices(box_point_11, box_point_12, box_point_21, box_point_22)
box_face = geompy.MakeQuad4Vertices(box_point_11, box_point_12, box_point_21, box_point_22)
box = MakePrismVecH(box_face, cyl_dir, full_dz)
box = geompy.MakePrismVecH(box_face, cyl_dir, full_dz)
full.append(box)
full.append(MakeCut(MakeCommon(full_solid_1, full_internal), box))
full.append(MakeCut(MakeCommon(full_solid_2, full_internal), box))
full.append(MakeCut(MakeCommon(full_solid_3, full_internal), box))
full.append(MakeCut(MakeCommon(full_solid_4, full_internal), box))
full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_1, full_internal), box))
full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_2, full_internal), box))
full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_3, full_internal), box))
full.append(geompy.MakeCut(geompy.MakeCommon(full_solid_4, full_internal), box))
# Cut the cylinder thikness
# -------------------------
full_plan = MakePlane(MakeVertex(0, 0, cyl_dz+cyl_thick), cyl_dir, 5000)
full_plan = geompy.MakePlane(geompy.MakeVertex(0, 0, cyl_dz+cyl_thick), cyl_dir, 5000)
full_parts = MakePartition(full, [full_plan], [], [], ShapeType["SOLID"])
full_parts = geompy.MakePartition(full, [full_plan], [], [], geompy.ShapeType["SOLID"])
# Geometry result
# ---------------
blocks.append(full_parts)
piece_cpd = MakeCompound(blocks)
piece_cpd = geompy.MakeCompound(blocks)
piece_ok = RemoveExtraEdges(piece_cpd, doUnionFaces=True)
piece_ok = geompy.RemoveExtraEdges(piece_cpd, doUnionFaces=True)
piece = MakeGlueFaces(piece_ok, 1.e-3)
piece = geompy.MakeGlueFaces(piece_ok, 1.e-3)
piece_id = addToStudy(piece, "ex13_hole1partial")
piece_id = geompy.addToStudy(piece, "ex13_hole1partial")
# Meshing
# =======
smesh.SetCurrentStudy(salome.myStudy)
# Create a mesh
# -------------
@ -233,7 +237,7 @@ hexa.Hexahedron()
# ----------------
def local(x, y, z, d):
edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
edge = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(x, y, z))
algo = hexa.Segment(edge)
algo.NumberOfSegments(d)
algo.Propagation()

View File

@ -23,9 +23,15 @@
# =======================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometrie
# =========
@ -52,19 +58,19 @@ g_trim = 15000
# Construire le cylindre
# ----------------------
c_point = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
c_dir = MakeVectorDXDYDZ(0, 0, 1)
c_point = geompy.MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
c_dir = geompy.MakeVectorDXDYDZ(0, 0, 1)
c_hauteur = 2*g_cyl_demiHauteur
c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
c_cylindre = geompy.MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
# Trouer le cylindre par un minuscule cylindre excentre
# -----------------------------------------------------
t_hauteur = g_cyl_demiHauteur
t_point = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
t_trou = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
t_point = geompy.MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
t_trou = geompy.MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
t_piece = MakeCut(c_cylindre, t_trou)
t_piece = geompy.MakeCut(c_cylindre, t_trou)
# Geometrie hexahedrique
# ======================
@ -73,10 +79,10 @@ t_piece = MakeCut(c_cylindre, t_trou)
# --------
h_outils = []
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
h_outils.append(geompy.MakePlane(t_point, geompy.MakeVectorDXDYDZ(1, 0, 0), g_trim))
h_outils.append(geompy.MakePlane(t_point, geompy.MakeVectorDXDYDZ(0, 1, 0), g_trim))
h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
h_piece = geompy.MakePartition([t_piece], h_outils, [], [], geompy.ShapeType["SOLID"])
# Decouper pour les conditions locales
# ------------------------------------
@ -87,21 +93,19 @@ l_n = 12
l_hauteur = c_hauteur/l_n
while l_i<l_n:
l_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
l_outils.append(geompy.MakePlane(geompy.MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur+l_i*l_hauteur), c_dir, g_trim))
l_i = l_i+1
piece = MakePartition([h_piece], l_outils, [], [], ShapeType["SOLID"])
piece = geompy.MakePartition([h_piece], l_outils, [], [], geompy.ShapeType["SOLID"])
# Ajouter la piece dans l'etude
# -----------------------------
piece_id = addToStudy(piece, "ex14_cyl1holed")
piece_id = geompy.addToStudy(piece, "ex14_cyl1holed")
# Maillage
# ========
smesh.SetCurrentStudy(salome.myStudy)
# Creer un maillage hexahedrique
# ------------------------------
@ -127,8 +131,8 @@ m_y = g_oy
m_z = g_oz-g_cyl_demiHauteur+m_h/2
while m_i<m_n:
m_p = MakeVertex(m_x, m_y, m_z + m_i*m_h)
m_e = GetEdgeNearPoint(piece, m_p)
m_p = geompy.MakeVertex(m_x, m_y, m_z + m_i*m_h)
m_e = geompy.GetEdgeNearPoint(piece, m_p)
m_a = hexa.Segment(m_e)
m_a.NumberOfSegments(m_d[m_i])
m_a.Propagation()

View File

@ -23,9 +23,15 @@
# =======================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometrie
# =========
@ -53,20 +59,20 @@ g_trim = 1000
cpd = []
g_base = MakeVertex(cx, cy, cz)
g_dir = MakeVectorDXDYDZ(0, 0, 1)
g_base = geompy.MakeVertex(cx, cy, cz)
g_dir = geompy.MakeVectorDXDYDZ(0, 0, 1)
t_hauteur = p_rayon+10.0
g_cyl = MakeCylinder(g_base, g_dir, g_rayon, g_hauteur)
g_cyl = geompy.MakeCylinder(g_base, g_dir, g_rayon, g_hauteur)
g_coupe = MakeVectorDXDYDZ(1, 0, 0)
g_coupe = geompy.MakeVectorDXDYDZ(1, 0, 0)
g_tools = []
g_tools.append(MakePlane(MakeVertex(cx+t_hauteur, cy, cz), g_coupe, g_trim))
g_tools.append(MakePlane(MakeVertex(cx-t_hauteur, cy, cz), g_coupe, g_trim))
g_tools.append(geompy.MakePlane(geompy.MakeVertex(cx+t_hauteur, cy, cz), g_coupe, g_trim))
g_tools.append(geompy.MakePlane(geompy.MakeVertex(cx-t_hauteur, cy, cz), g_coupe, g_trim))
g_partie = MakePartition([g_cyl], g_tools, [], [], ShapeType["SOLID"])
g_bas, g_centre, g_haut = SubShapeAllSorted(g_partie, ShapeType["SOLID"])
g_partie = geompy.MakePartition([g_cyl], g_tools, [], [], geompy.ShapeType["SOLID"])
g_bas, g_centre, g_haut = geompy.SubShapeAllSorted(g_partie, geompy.ShapeType["SOLID"])
# Partie basse du gros cylindre
# -----------------------------
@ -74,28 +80,28 @@ g_bas, g_centre, g_haut = SubShapeAllSorted(g_partie, ShapeType["SOLID"])
b_hauteur = 10
b_base = 20
b_boite = MakeBox(cx-t_hauteur, cy-b_base, cz, cx-t_hauteur-b_hauteur, cy+b_base, cz+g_hauteur)
b_boite = geompy.MakeBox(cx-t_hauteur, cy-b_base, cz, cx-t_hauteur-b_hauteur, cy+b_base, cz+g_hauteur)
cpd.append(b_boite)
b_cyl = MakeCut(g_bas, b_boite)
b_cyl = geompy.MakeCut(g_bas, b_boite)
b_tools = []
b_tools.append(MakePlane(MakeVertex(cx-t_hauteur-b_hauteur, cy+b_base, cz), MakeVectorDXDYDZ( 1, 1, 0), g_trim))
b_tools.append(MakePlane(MakeVertex(cx-t_hauteur-b_hauteur, cy-b_base, cz), MakeVectorDXDYDZ(-1, 1, 0), g_trim))
b_tools.append(geompy.MakePlane(geompy.MakeVertex(cx-t_hauteur-b_hauteur, cy+b_base, cz), geompy.MakeVectorDXDYDZ( 1, 1, 0), g_trim))
b_tools.append(geompy.MakePlane(geompy.MakeVertex(cx-t_hauteur-b_hauteur, cy-b_base, cz), geompy.MakeVectorDXDYDZ(-1, 1, 0), g_trim))
b_partie = MakePartition([b_cyl], b_tools, [], [], ShapeType["SOLID"])
b_element = SubShapeAll(b_partie, ShapeType["SOLID"])
b_partie = geompy.MakePartition([b_cyl], b_tools, [], [], geompy.ShapeType["SOLID"])
b_element = geompy.SubShapeAll(b_partie, geompy.ShapeType["SOLID"])
cpd = cpd + b_element
# Partie haute du gros cylindre
# -----------------------------
h_plan = MakePlane(g_base, g_coupe, g_trim)
h_plan = geompy.MakePlane(g_base, g_coupe, g_trim)
cpd.append(MakeMirrorByPlane(b_boite, h_plan))
cpd.append(geompy.MakeMirrorByPlane(b_boite, h_plan))
for h in b_element:
h_symetrie = MakeMirrorByPlane(h, h_plan)
h_symetrie = geompy.MakeMirrorByPlane(h, h_plan)
cpd.append(h_symetrie)
# Petit cylindre
@ -108,79 +114,77 @@ px = cx-x_arete
py = cy-1.5*g_rayon
pz = cz+g_hauteur/2
p_base = MakeVertex(cx, py, pz)
p_dir = MakeVectorDXDYDZ(0, 1, 0)
p_cyl = MakeCylinder(p_base, p_dir, p_rayon, p_hauteur)
p_base = geompy.MakeVertex(cx, py, pz)
p_dir = geompy.MakeVectorDXDYDZ(0, 1, 0)
p_cyl = geompy.MakeCylinder(p_base, p_dir, p_rayon, p_hauteur)
p_boite = MakeBox(px, py, pz-z_arete, cx+x_arete, py+p_hauteur, pz+z_arete)
p_boite = geompy.MakeBox(px, py, pz-z_arete, cx+x_arete, py+p_hauteur, pz+z_arete)
# Partie interieure du petit cylindre
# -----------------------------------
i_cyl = MakeCommon(p_cyl, g_cyl)
i_tuyau = MakeCut(i_cyl, p_boite)
i_boite = MakeCommon(p_boite, g_cyl)
i_cyl = geompy.MakeCommon(p_cyl, g_cyl)
i_tuyau = geompy.MakeCut(i_cyl, p_boite)
i_boite = geompy.MakeCommon(p_boite, g_cyl)
# Partie exterieure du petit cylindre
# -----------------------------------
e_cyl0 = MakeCut(p_cyl, g_cyl)
e_cyl = SubShapeAllSorted(e_cyl0, ShapeType["SOLID"])
e_cyl0 = geompy.MakeCut(p_cyl, g_cyl)
e_cyl = geompy.SubShapeAllSorted(e_cyl0, geompy.ShapeType["SOLID"])
e_tuyau = MakeCut(e_cyl[1], p_boite)
e_tuyau = geompy.MakeCut(e_cyl[1], p_boite)
e_boite0 = MakeCut(p_boite, g_cyl)
e_boite = SubShapeAllSorted(e_boite0, ShapeType["SOLID"])
e_boite0 = geompy.MakeCut(p_boite, g_cyl)
e_boite = geompy.SubShapeAllSorted(e_boite0, geompy.ShapeType["SOLID"])
cpd.append(e_boite[1])
# Partie centrale du gros cylindre
# --------------------------------
c_cyl = MakeCut(g_centre, p_cyl)
c_cyl = geompy.MakeCut(g_centre, p_cyl)
# Partitionner
# ------------
p_tools = []
p_tools.append(MakePlane(MakeVertex(px, py, pz-z_arete), MakeVectorDXDYDZ(-z_arete, 0, x_arete), g_trim))
p_tools.append(MakePlane(MakeVertex(px, py, pz+z_arete), MakeVectorDXDYDZ( z_arete, 0, x_arete), g_trim))
p_tools.append(geompy.MakePlane(geompy.MakeVertex(px, py, pz-z_arete), geompy.MakeVectorDXDYDZ(-z_arete, 0, x_arete), g_trim))
p_tools.append(geompy.MakePlane(geompy.MakeVertex(px, py, pz+z_arete), geompy.MakeVectorDXDYDZ( z_arete, 0, x_arete), g_trim))
p_partie = MakePartition([e_tuyau], p_tools, [], [], ShapeType["SOLID"])
p_element = SubShapeAll(p_partie, ShapeType["SOLID"])
p_partie = geompy.MakePartition([e_tuyau], p_tools, [], [], geompy.ShapeType["SOLID"])
p_element = geompy.SubShapeAll(p_partie, geompy.ShapeType["SOLID"])
cpd = cpd + p_element
q_partie = MakePartition([i_tuyau, c_cyl], p_tools, [], [], ShapeType["SOLID"])
q_element = SubShapeAll(q_partie, ShapeType["SOLID"])
q_partie = geompy.MakePartition([i_tuyau, c_cyl], p_tools, [], [], geompy.ShapeType["SOLID"])
q_element = geompy.SubShapeAll(q_partie, geompy.ShapeType["SOLID"])
q_element = q_element + [i_boite]
q_tools = []
q_tools.append(MakePlane(MakeVertex(cx, cy-b_base, cz), MakeVectorDXDYDZ(0, 1, 0), g_trim))
q_tools.append(MakePlane(MakeVertex(cx, cy+b_base, cz), MakeVectorDXDYDZ(0, 1, 0), g_trim))
q_tools.append(geompy.MakePlane(geompy.MakeVertex(cx, cy-b_base, cz), geompy.MakeVectorDXDYDZ(0, 1, 0), g_trim))
q_tools.append(geompy.MakePlane(geompy.MakeVertex(cx, cy+b_base, cz), geompy.MakeVectorDXDYDZ(0, 1, 0), g_trim))
r_element = []
for e in q_element:
r_partie = MakePartition([e], q_tools, [], [], ShapeType["SOLID"])
r_element = r_element + SubShapeAll(r_partie, ShapeType["SOLID"])
r_partie = geompy.MakePartition([e], q_tools, [], [], geompy.ShapeType["SOLID"])
r_element = r_element + geompy.SubShapeAll(r_partie, geompy.ShapeType["SOLID"])
cpd = cpd + r_element
# Compound
# --------
piece = RemoveExtraEdges(MakeCompound(cpd), True)
piece = geompy.RemoveExtraEdges(geompy.MakeCompound(cpd), True)
# Ajouter la piece dans l'etude
# -----------------------------
piece_id = addToStudy(piece, "ex15_cyl2geometry")
piece_id = geompy.addToStudy(piece, "ex15_cyl2geometry")
# Meshing
# =======
smesh.SetCurrentStudy(salome.myStudy)
# Create a hexahedral mesh
# ------------------------

View File

@ -23,9 +23,15 @@
# =======================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometry
# ========
@ -53,65 +59,63 @@ g_trim = 1000
# The parallelepipede
# -------------------
p_boite = MakeBox(gx-g_dx, gy-g_dy, gz-g_dz, gx+g_dx, gy+g_dy, gz+g_dz)
p_boite = geompy.MakeBox(gx-g_dx, gy-g_dy, gz-g_dz, gx+g_dx, gy+g_dy, gz+g_dz)
# The great cylinder
# ------------------
g_base = MakeVertex(gx-g_dx, gy, gz)
g_dir = MakeVectorDXDYDZ(1, 0, 0)
g_cyl = MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
g_base = geompy.MakeVertex(gx-g_dx, gy, gz)
g_dir = geompy.MakeVectorDXDYDZ(1, 0, 0)
g_cyl = geompy.MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
# The first hole
# --------------
b_boite = MakeCut(p_boite , g_cyl)
b_boite = geompy.MakeCut(p_boite , g_cyl)
# Partitioning
# ------------
p_base = MakeVertex(gx, gy, gz)
p_base = geompy.MakeVertex(gx, gy, gz)
p_tools = []
p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, 1 , 0 ), g_trim))
p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, g_dz, g_dy), g_trim))
p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, 1 , 0 ), g_trim))
p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, g_dz, g_dy), g_trim))
p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
p_tools.append(MakePlane(MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
p_tools.append(MakePlane(MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
p_piece = MakePartition([b_boite], p_tools, [], [], ShapeType["SOLID"])
p_piece = geompy.MakePartition([b_boite], p_tools, [], [], geompy.ShapeType["SOLID"])
# The small cylinder
# ------------------
c_cyl = MakeCylinder(p_base, MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
c_cyl = geompy.MakeCylinder(p_base, geompy.MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
# The second hole
# ---------------
d_element = SubShapeAllSorted(p_piece, ShapeType["SOLID"])
d_element = geompy.SubShapeAllSorted(p_piece, geompy.ShapeType["SOLID"])
d_element[ 8] = MakeCut(d_element[ 8], c_cyl)
d_element[10] = MakeCut(d_element[10], c_cyl)
d_element[ 8] = geompy.MakeCut(d_element[ 8], c_cyl)
d_element[10] = geompy.MakeCut(d_element[10], c_cyl)
# Compound
# --------
piece = RemoveExtraEdges(MakeCompound(d_element))
piece = MakeGlueFaces(piece, 1e-07)
piece = geompy.RemoveExtraEdges(geompy.MakeCompound(d_element))
piece = geompy.MakeGlueFaces(piece, 1e-07)
# Add piece in study
# ------------------
piece_id = addToStudy(piece, "ex16_cyl2complementary")
piece_id = geompy.addToStudy(piece, "ex16_cyl2complementary")
# Meshing
# =======
smesh.SetCurrentStudy(salome.myStudy)
# Create a hexahedral mesh
# ------------------------
@ -128,7 +132,7 @@ hexa.Hexahedron()
# -----------------------
def local(x, y, z, d):
edge = GetEdgeNearPoint(piece, MakeVertex(x, y, z))
edge = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(x, y, z))
algo = hexa.Segment(edge)
algo.NumberOfSegments(d)
algo.Propagation()

View File

@ -23,9 +23,15 @@
# =======================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometrie
# =========
@ -47,43 +53,41 @@ plan_trim = 2000
# Cylindre
# --------
cylindre_base = MakeVertex(0, 0, 0)
cylindre_dir = MakeVectorDXDYDZ(1, 0, 0)
cylindre = MakeCylinder(cylindre_base, cylindre_dir, cylindre_rayon, cylindre_hauteur)
cylindre_base = geompy.MakeVertex(0, 0, 0)
cylindre_dir = geompy.MakeVectorDXDYDZ(1, 0, 0)
cylindre = geompy.MakeCylinder(cylindre_base, cylindre_dir, cylindre_rayon, cylindre_hauteur)
# Dome
# ----
dome_sphere = MakeSpherePntR(cylindre_base, cylindre_rayon)
dome = MakeFuse(dome_sphere, cylindre)
dome_sphere = geompy.MakeSpherePntR(cylindre_base, cylindre_rayon)
dome = geompy.MakeFuse(dome_sphere, cylindre)
# Cheminee
# --------
cheminee_base = MakeVertex(-cylindre_hauteur/2, 0, trou_z)
cheminee_trou = MakeCylinder(cheminee_base, cylindre_dir, trou_rayon, 2*cylindre_hauteur)
cheminee = MakeCut(dome, cheminee_trou)
cheminee_base = geompy.MakeVertex(-cylindre_hauteur/2, 0, trou_z)
cheminee_trou = geompy.MakeCylinder(cheminee_base, cylindre_dir, trou_rayon, 2*cylindre_hauteur)
cheminee = geompy.MakeCut(dome, cheminee_trou)
# Decoupage et reparation
# -----------------------
blocs_plan1 = MakePlane(cheminee_base, MakeVectorDXDYDZ(0, 1, 0), plan_trim)
blocs_plan2 = MakePlane(cheminee_base, MakeVectorDXDYDZ(0, 0, 1), plan_trim)
blocs_plan1 = geompy.MakePlane(cheminee_base, geompy.MakeVectorDXDYDZ(0, 1, 0), plan_trim)
blocs_plan2 = geompy.MakePlane(cheminee_base, geompy.MakeVectorDXDYDZ(0, 0, 1), plan_trim)
blocs_part = MakePartition([cheminee], [blocs_plan1, blocs_plan2], [], [], ShapeType["SOLID"])
blocs_part = geompy.MakePartition([cheminee], [blocs_plan1, blocs_plan2], [], [], geompy.ShapeType["SOLID"])
piece = RemoveExtraEdges(blocs_part)
piece = geompy.RemoveExtraEdges(blocs_part)
# Etude
# -----
piece_id = addToStudy(piece, "ex17_dome1")
piece_id = geompy.addToStudy(piece, "ex17_dome1")
# Maillage
# ========
smesh.SetCurrentStudy(salome.myStudy)
# Maillage hexahedrique
# ---------------------

View File

@ -23,9 +23,15 @@
# =======================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import math
@ -57,70 +63,68 @@ g_trim = 15000
# Cylindre
# --------
c_point = MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
c_dir = MakeVectorDXDYDZ(0, 0, 1)
c_point = geompy.MakeVertex(g_ox, g_oy, g_oz-g_cyl_demiHauteur)
c_dir = geompy.MakeVectorDXDYDZ(0, 0, 1)
c_hauteur = 2*g_cyl_demiHauteur
c_cylindre = MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
c_cylindre = geompy.MakeCylinder(c_point, c_dir, g_cyl_rayon, c_hauteur)
# Sphere
# ------
s_hauteur = math.sqrt(g_sphere_rayon*g_sphere_rayon - g_cyl_rayon*g_cyl_rayon) - g_cyl_demiHauteur
s_sphere = MakeSphere(g_ox, g_oy, g_oz-s_hauteur, g_sphere_rayon)
s_sphere = geompy.MakeSphere(g_ox, g_oy, g_oz-s_hauteur, g_sphere_rayon)
# Calottes
# --------
c_outils = []
c_outils.append(MakePlane(MakeVertex(g_ox, g_oy, g_oz+g_cyl_demiHauteur), MakeVectorDXDYDZ(0, 0, 1), g_trim))
c_outils.append(geompy.MakePlane(geompy.MakeVertex(g_ox, g_oy, g_oz+g_cyl_demiHauteur), geompy.MakeVectorDXDYDZ(0, 0, 1), g_trim))
c_cpd = MakePartition([s_sphere], c_outils, [], [], ShapeType["SOLID"])
c_calotte_haut, c_reste = SubShapeAllSorted(c_cpd, ShapeType["SOLID"])
c_cpd = geompy.MakePartition([s_sphere], c_outils, [], [], geompy.ShapeType["SOLID"])
c_calotte_haut, c_reste = geompy.SubShapeAllSorted(c_cpd, geompy.ShapeType["SOLID"])
c_plan = MakePlane(MakeVertex(g_ox, g_oy, g_oz), MakeVectorDXDYDZ(0, 0, 1), g_trim)
c_calotte_bas = MakeMirrorByPlane(c_calotte_haut, c_plan)
c_plan = geompy.MakePlane(geompy.MakeVertex(g_ox, g_oy, g_oz), geompy.MakeVectorDXDYDZ(0, 0, 1), g_trim)
c_calotte_bas = geompy.MakeMirrorByPlane(c_calotte_haut, c_plan)
# Fusionner
# ---------
f_piece1 = MakeFuse(c_cylindre, c_calotte_haut)
f_piece = MakeFuse(f_piece1, c_calotte_bas)
f_piece1 = geompy.MakeFuse(c_cylindre, c_calotte_haut)
f_piece = geompy.MakeFuse(f_piece1, c_calotte_bas)
# Trouer
# ------
t_hauteur = g_sphere_rayon
t_point = MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
t_trou = MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
t_point = geompy.MakeVertex(g_ox-g_trou_centre, g_oy, g_oz-t_hauteur)
t_trou = geompy.MakeCylinder(t_point, c_dir, g_trou_rayon, 2*t_hauteur)
t_piece = MakeCut(f_piece, t_trou)
t_piece = geompy.MakeCut(f_piece, t_trou)
# Decouper
# --------
h_outils = []
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(1, 0, 0), g_trim))
h_outils.append(MakePlane(t_point, MakeVectorDXDYDZ(0, 1, 0), g_trim))
h_outils.append(geompy.MakePlane(t_point, geompy.MakeVectorDXDYDZ(1, 0, 0), g_trim))
h_outils.append(geompy.MakePlane(t_point, geompy.MakeVectorDXDYDZ(0, 1, 0), g_trim))
h_piece = MakePartition([t_piece], h_outils, [], [], ShapeType["SOLID"])
h_piece = geompy.MakePartition([t_piece], h_outils, [], [], geompy.ShapeType["SOLID"])
# Reparer
# -------
piece = RemoveExtraEdges(h_piece)
piece = geompy.RemoveExtraEdges(h_piece)
# Ajouter la piece dans l'etude
# -----------------------------
piece_id = addToStudy(piece, "ex18_dome2")
piece_id = geompy.addToStudy(piece, "ex18_dome2")
# Maillage
# ========
smesh.SetCurrentStudy(salome.myStudy)
# Maillage hexahedrique
# ---------------------

View File

@ -23,10 +23,15 @@
# ==================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import geompy
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometrie
# =========
@ -45,23 +50,23 @@ plan_trim = 1000
# Sphere
# ------
sphere_centre = MakeVertex(0, 0, 0)
sphere_centre = geompy.MakeVertex(0, 0, 0)
sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
sphere_pleine = geompy.MakeSpherePntR(sphere_centre, sphere_rayon)
# Cube interieur
# --------------
boite_cote = sphere_rayon / 2
boite = MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
boite = geompy.MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
blocs = [boite]
# Decoupage sphere
# ----------------
sphere_troue = MakeCut(sphere_pleine, boite)
sphere_troue = geompy.MakeCut(sphere_pleine, boite)
#sphere_outils = []
#sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim))
@ -69,74 +74,74 @@ sphere_troue = MakeCut(sphere_pleine, boite)
#sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim))
#sphere_outils.append(MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim))
f1 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim)
f2 = MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim)
f3 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim)
f4 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim)
f1 = geompy.MakePlane(sphere_centre, geompy.MakeVectorDXDYDZ( 1, 0, 1), plan_trim)
f2 = geompy.MakePlane(sphere_centre, geompy.MakeVectorDXDYDZ(-1, 1, 0), plan_trim)
f3 = geompy.MakePlane(sphere_centre, geompy.MakeVectorDXDYDZ( 1, 1, 0), plan_trim)
f4 = geompy.MakePlane(sphere_centre, geompy.MakeVectorDXDYDZ( 1, 0, -1), plan_trim)
#sphere_decoupee = MakePartition(solids, sphere_outils, [], [], ShapeType["SOLID"])
sphere_decoupee = MakePartition([sphere_troue], [f1], [], [], ShapeType["SOLID"])
sphere_decoupee = MakePartition([sphere_decoupee], [f2], [], [], ShapeType["SOLID"])
sphere_decoupee = MakePartition([sphere_decoupee], [f3], [], [], ShapeType["SOLID"])
sphere_decoupee = MakePartition([sphere_decoupee], [f4], [], [], ShapeType["SOLID"])
sphere_decoupee = geompy.MakePartition([sphere_troue], [f1], [], [], geompy.ShapeType["SOLID"])
sphere_decoupee = geompy.MakePartition([sphere_decoupee], [f2], [], [], geompy.ShapeType["SOLID"])
sphere_decoupee = geompy.MakePartition([sphere_decoupee], [f3], [], [], geompy.ShapeType["SOLID"])
sphere_decoupee = geompy.MakePartition([sphere_decoupee], [f4], [], [], geompy.ShapeType["SOLID"])
sphere_partie = geompy.MakeCompound([sphere_decoupee])
sphere_partie = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
sphere_bloc = RemoveExtraEdges(sphere_partie)
sphere_partie = geompy.GetBlockNearPoint(sphere_decoupee, geompy.MakeVertex(-sphere_rayon, 0, 0))
sphere_bloc = geompy.RemoveExtraEdges(sphere_partie)
blocs.append(sphere_bloc)
pi2 = 3.141592653/2
sphere_dir1 = MakeVectorDXDYDZ(0, 1, 0)
sphere_dir2 = MakeVectorDXDYDZ(0, 0, 1)
sphere_dir1 = geompy.MakeVectorDXDYDZ(0, 1, 0)
sphere_dir2 = geompy.MakeVectorDXDYDZ(0, 0, 1)
blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
blocs.append(geompy.MakeRotation(sphere_bloc, sphere_dir1, +pi2))
blocs.append(geompy.MakeRotation(sphere_bloc, sphere_dir1, -pi2))
blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
blocs.append(geompy.MakeRotation(sphere_bloc, sphere_dir2, +pi2))
blocs.append(geompy.MakeRotation(sphere_bloc, sphere_dir2, -pi2))
blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
blocs.append(geompy.MakeMirrorByPoint(sphere_bloc, sphere_centre))
# Cube exterieur
# --------------
cube_plein = MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
cube_trou = MakeCut(cube_plein, sphere_pleine)
cube_plein = geompy.MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
cube_trou = geompy.MakeCut(cube_plein, sphere_pleine)
#cube_decoupe = MakePartition([cube_trou], sphere_outils, [], [], ShapeType["SOLID"])
cube_decoupe = MakePartition([cube_trou], [f1], [], [], ShapeType["SOLID"])
cube_decoupe = MakePartition([cube_decoupe], [f2], [], [], ShapeType["SOLID"])
cube_decoupe = MakePartition([cube_decoupe], [f3], [], [], ShapeType["SOLID"])
cube_decoupe = MakePartition([cube_decoupe], [f4], [], [], ShapeType["SOLID"])
cube_decoupe = geompy.MakePartition([cube_trou], [f1], [], [], geompy.ShapeType["SOLID"])
cube_decoupe = geompy.MakePartition([cube_decoupe], [f2], [], [], geompy.ShapeType["SOLID"])
cube_decoupe = geompy.MakePartition([cube_decoupe], [f3], [], [], geompy.ShapeType["SOLID"])
cube_decoupe = geompy.MakePartition([cube_decoupe], [f4], [], [], geompy.ShapeType["SOLID"])
cube_decoupe = geompy.MakeCompound([cube_decoupe])
cube_partie = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
cube_bloc = RemoveExtraEdges(cube_partie)
cube_partie = geompy.GetBlockNearPoint(cube_decoupe, geompy.MakeVertex(-cube_cote, 0, 0))
cube_bloc = geompy.RemoveExtraEdges(cube_partie)
blocs.append(cube_bloc)
blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
blocs.append(geompy.MakeRotation(cube_bloc, sphere_dir1, +pi2))
blocs.append(geompy.MakeRotation(cube_bloc, sphere_dir1, -pi2))
blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
blocs.append(geompy.MakeRotation(cube_bloc, sphere_dir2, +pi2))
blocs.append(geompy.MakeRotation(cube_bloc, sphere_dir2, -pi2))
blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
blocs.append(geompy.MakeMirrorByPoint(cube_bloc, sphere_centre))
# Piece
# -----
piece_cpd = MakeCompound(blocs)
piece = MakeGlueFaces(piece_cpd, 1.e-3)
piece_cpd = geompy.MakeCompound(blocs)
piece = geompy.MakeGlueFaces(piece_cpd, 1.e-3)
piece_id = addToStudy(piece, "ex19_sphereINcube")
piece_id = geompy.addToStudy(piece, "ex19_sphereINcube")
# Groupe geometrique
# ==================
@ -144,24 +149,22 @@ piece_id = addToStudy(piece, "ex19_sphereINcube")
# Definition du groupe
# --------------------
groupe = CreateGroup(piece, ShapeType["SOLID"])
groupe = geompy.CreateGroup(piece, geompy.ShapeType["SOLID"])
groupe_nom = "ex19_sphereINcube_interieur"
addToStudy(groupe, groupe_nom)
geompy.addToStudy(groupe, groupe_nom)
groupe.SetName(groupe_nom)
# Contenu du groupe
# -----------------
groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
groupe_sphere = geompy.GetShapesOnSphere(piece, geompy.ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
UnionList(groupe, groupe_sphere)
geompy.UnionList(groupe, groupe_sphere)
# Meshing
# =======
smesh.SetCurrentStudy(salome.myStudy)
# Create a hexahedral mesh
# ------------------------

View File

@ -23,9 +23,15 @@
# ==================================
#
from geompy import *
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import smesh
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
# Geometry
# ========
@ -49,53 +55,51 @@ height = 100
# Build a box
# -----------
box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
box = geompy.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
# Build a cylinder
# ----------------
pt1 = MakeVertex(0, 0, cote/3)
di1 = MakeVectorDXDYDZ(0, 0, 1)
cyl = MakeCylinder(pt1, di1, section, size)
pt1 = geompy.MakeVertex(0, 0, cote/3)
di1 = geompy.MakeVectorDXDYDZ(0, 0, 1)
cyl = geompy.MakeCylinder(pt1, di1, section, size)
# Build a truncated cone
# ----------------------
pt2 = MakeVertex(0, 0, size)
cone = MakeCone(pt2, di1, radius_1, radius_2, height)
pt2 = geompy.MakeVertex(0, 0, size)
cone = geompy.MakeCone(pt2, di1, radius_1, radius_2, height)
# Fuse
# ----
box_cyl = MakeFuse(box, cyl)
piece = MakeFuse(box_cyl, cone)
box_cyl = geompy.MakeFuse(box, cyl)
piece = geompy.MakeFuse(box_cyl, cone)
# Add in study
# ------------
addToStudy(piece, name)
geompy.addToStudy(piece, name)
# Create a group of faces
# -----------------------
group = CreateGroup(piece, ShapeType["FACE"])
group = geompy.CreateGroup(piece, geompy.ShapeType["FACE"])
group_name = name + "_grp"
addToStudy(group, group_name)
geompy.addToStudy(group, group_name)
group.SetName(group_name)
# Add faces in the group
# ----------------------
faces = SubShapeAllIDs(piece, ShapeType["FACE"])
faces = geompy.SubShapeAllIDs(piece, geompy.ShapeType["FACE"])
UnionIDs(group, faces)
geompy.UnionIDs(group, faces)
# Create a mesh
# =============
smesh.SetCurrentStudy(salome.myStudy)
# Define a mesh on a geometry
# ---------------------------
@ -116,7 +120,7 @@ algo2d.LengthFromEdges()
# Define 3D hypothesis
# --------------------
algo3d = tetra.Tetrahedron(smesh.NETGEN)
algo3d = tetra.Tetrahedron(smeshBuilder.NETGEN)
algo3d.MaxElementVolume(100)
# Compute the mesh

View File

@ -22,9 +22,16 @@
#
import math
import geompy
import smesh
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
geo = geompy
# Parameters
@ -36,62 +43,62 @@ height = 200
# Build a cylinder
# ----------------
base = geo.MakeVertex(0, 0, 0)
direction = geo.MakeVectorDXDYDZ(0, 0, 1)
base = geompy.MakeVertex(0, 0, 0)
direction = geompy.MakeVectorDXDYDZ(0, 0, 1)
cylinder = geo.MakeCylinder(base, direction, radius, height)
cylinder = geompy.MakeCylinder(base, direction, radius, height)
geo.addToStudy(cylinder, "cylinder")
geompy.addToStudy(cylinder, "cylinder")
# Build blocks
# ------------
size = radius/2.0
box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
box_axis = geo.MakeLine(base, direction)
box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
box_rot = geompy.MakeBox(-size, -size, 0, +size, +size, height)
box_axis = geompy.MakeLine(base, direction)
box = geompy.MakeRotation(box_rot, box_axis, math.pi/4)
hole = geo.MakeCut(cylinder, box)
hole = geompy.MakeCut(cylinder, box)
plane_trim = 2000
plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
plane_a = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
plane_b = geompy.MakePlane(base, geompy.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
blocks_all = geo.MakeCompound(blocks_list)
blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
blocks_part = geompy.MakePartition([hole], [plane_a, plane_b], [], [], geompy.ShapeType["SOLID"])
blocks_list = [box] + geompy.SubShapeAll(blocks_part, geompy.ShapeType["SOLID"])
blocks_all = geompy.MakeCompound(blocks_list)
blocks = geompy.MakeGlueFaces(blocks_all, 0.0001)
geo.addToStudy(blocks, "cylinder:blocks")
geompy.addToStudy(blocks, "cylinder:blocks")
# Build geometric groups
# ----------------------
def group(name, shape, type, base=None, direction=None):
t = geo.ShapeType[type]
g = geo.CreateGroup(shape, t)
t = geompy.ShapeType[type]
g = geompy.CreateGroup(shape, t)
geo.addToStudy(g, name)
geompy.addToStudy(g, name)
g.SetName(name)
if base!=None:
l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
geo.UnionIDs(g, l)
l = geompy.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, GEOM.ST_ON)
geompy.UnionIDs(g, l)
return g
group_a = group("baseA", blocks, "FACE", base, direction)
base_b = geo.MakeVertex(0, 0, height)
base_b = geompy.MakeVertex(0, 0, height)
group_b = group("baseB", blocks, "FACE", base_b, direction)
group_1 = group("limit", blocks, "SOLID")
group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
geo.UnionIDs(group_1, group_1_all)
group_1_box = geo.GetBlockNearPoint(blocks, base)
geo.DifferenceList(group_1, [group_1_box])
group_1_all = geompy.SubShapeAllIDs(blocks, geompy.ShapeType["SOLID"])
geompy.UnionIDs(group_1, group_1_all)
group_1_box = geompy.GetBlockNearPoint(blocks, base)
geompy.DifferenceList(group_1, [group_1_box])
# Mesh the blocks with hexahedral
# -------------------------------
@ -99,8 +106,8 @@ geo.DifferenceList(group_1, [group_1_box])
smesh.SetCurrentStudy(salome.myStudy)
def discretize(x, y, z, n, s=blocks):
p = geo.MakeVertex(x, y, z)
e = geo.GetEdgeNearPoint(s, p)
p = geompy.MakeVertex(x, y, z)
e = geompy.GetEdgeNearPoint(s, p)
a = hexa.Segment(e)
a.NumberOfSegments(n)
a.Propagation()