From 22496e8ddca45c3f0307628bf2c6661c212d11fd Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 21 Mar 2005 08:38:22 +0000 Subject: [PATCH] New updated and tested smesh.py with some examples. Provided by FKL. --- src/SMESH_SWIG/Makefile.in | 35 +- src/SMESH_SWIG/SMESH_Sphere.py | 8 +- src/SMESH_SWIG/ex00_all.py | 25 + .../{cube2pyGibi.py => ex01_cube2build.py} | 42 +- ...ube2geometry.py => ex02_cube2primitive.py} | 45 +- ...be2partition.py => ex03_cube2partition.py} | 51 +- src/SMESH_SWIG/ex04_cube5tetraHexa.py | 87 ++++ .../{hole1pyGibi.py => ex05_hole1build.py} | 42 +- ...{hole1geometry.py => ex06_hole1boolean.py} | 74 ++- src/SMESH_SWIG/ex07_hole1partition.py | 79 +++ .../{hole2pyGibi.py => ex08_hole2build.py} | 61 ++- .../{grid4pyGibi.py => ex09_grid4build.py} | 51 +- ...rid4partition.py => ex10_grid4geometry.py} | 41 +- ...id3partition.py => ex11_grid3partition.py} | 68 +-- ...17partition.py => ex12_grid17partition.py} | 67 +-- src/SMESH_SWIG/ex13_hole1partial.py | 231 +++++++++ src/SMESH_SWIG/ex14_cyl1holed.py | 116 +++++ .../{cyl2geometry.py => ex15_cyl2geometry.py} | 58 ++- ...lementary.py => ex16_cyl2complementary.py} | 58 ++- src/SMESH_SWIG/ex17_dome1.py | 78 +++ src/SMESH_SWIG/ex18_dome2.py | 115 +++++ src/SMESH_SWIG/ex19_sphereINcube.py | 138 ++++++ src/SMESH_SWIG/hole1partition.py | 75 --- src/SMESH_SWIG/meshpy.py | 165 ------- src/SMESH_SWIG/smesh.py | 462 ++++++++++++++++++ 25 files changed, 1722 insertions(+), 550 deletions(-) create mode 100644 src/SMESH_SWIG/ex00_all.py rename src/SMESH_SWIG/{cube2pyGibi.py => ex01_cube2build.py} (95%) rename src/SMESH_SWIG/{cube2geometry.py => ex02_cube2primitive.py} (74%) rename src/SMESH_SWIG/{cube2partition.py => ex03_cube2partition.py} (60%) create mode 100644 src/SMESH_SWIG/ex04_cube5tetraHexa.py rename src/SMESH_SWIG/{hole1pyGibi.py => ex05_hole1build.py} (82%) rename src/SMESH_SWIG/{hole1geometry.py => ex06_hole1boolean.py} (56%) create mode 100644 src/SMESH_SWIG/ex07_hole1partition.py rename src/SMESH_SWIG/{hole2pyGibi.py => ex08_hole2build.py} (70%) rename src/SMESH_SWIG/{grid4pyGibi.py => ex09_grid4build.py} (79%) rename src/SMESH_SWIG/{grid4partition.py => ex10_grid4geometry.py} (69%) rename src/SMESH_SWIG/{grid3partition.py => ex11_grid3partition.py} (50%) rename src/SMESH_SWIG/{grid17partition.py => ex12_grid17partition.py} (63%) create mode 100644 src/SMESH_SWIG/ex13_hole1partial.py create mode 100644 src/SMESH_SWIG/ex14_cyl1holed.py rename src/SMESH_SWIG/{cyl2geometry.py => ex15_cyl2geometry.py} (84%) rename src/SMESH_SWIG/{cyl2complementary.py => ex16_cyl2complementary.py} (68%) create mode 100644 src/SMESH_SWIG/ex17_dome1.py create mode 100644 src/SMESH_SWIG/ex18_dome2.py create mode 100644 src/SMESH_SWIG/ex19_sphereINcube.py delete mode 100644 src/SMESH_SWIG/hole1partition.py delete mode 100644 src/SMESH_SWIG/meshpy.py create mode 100644 src/SMESH_SWIG/smesh.py diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in index fffd27d55..03edab751 100644 --- a/src/SMESH_SWIG/Makefile.in +++ b/src/SMESH_SWIG/Makefile.in @@ -39,22 +39,29 @@ LIB_SRC = SWIG_DEF = libSMESH_Swig.i EXPORT_PYSCRIPTS = libSMESH_Swig.py \ - meshpy.py \ + smesh.py \ batchmode_smesh.py \ batchmode_mefisto.py \ - cube2pyGibi.py \ - cube2geometry.py \ - cube2partition.py \ - grid4pyGibi.py \ - grid4partition.py \ - grid3partition.py \ - grid17partition.py \ - hole1geometry.py \ - hole1partition.py \ - hole1pyGibi.py \ - hole2pyGibi.py \ - cyl2geometry.py \ - cyl2complementary.py \ + ex00_all.py \ + ex01_cube2build.py \ + ex02_cube2primitive.py \ + ex03_cube2partition.py \ + ex04_cube5tetraHexa.py \ + ex05_hole1build.py \ + ex06_hole1boolean.py \ + ex07_hole1partition.py \ + ex08_hole2build.py \ + ex09_grid4build.py \ + ex10_grid4geometry.py \ + ex11_grid3partition.py \ + ex12_grid17partition.py \ + ex13_hole1partial.py \ + ex14_cyl1holed.py \ + ex15_cyl2geometry.py \ + ex16_cyl2complementary.py \ + ex17_dome1.py \ + ex18_dome2.py \ + ex19_sphereINcube.py \ SMESH_test.py\ SMESH_test0.py\ SMESH_test1.py \ diff --git a/src/SMESH_SWIG/SMESH_Sphere.py b/src/SMESH_SWIG/SMESH_Sphere.py index 9c6bc42a0..893e5441f 100644 --- a/src/SMESH_SWIG/SMESH_Sphere.py +++ b/src/SMESH_SWIG/SMESH_Sphere.py @@ -29,7 +29,7 @@ from geompy import * from math import * -from meshpy import * +import smesh # It is an example of creating a hexahedrical mesh on a sphere. # @@ -103,5 +103,9 @@ Id_Result = addToStudy(Result, "Result") #----------------------------------------------------------------------- #Meshing -my_hexa = MeshHexa(Result, NbSeg, "Sphere_Mesh") +my_hexa = smesh.Mesh(Result, "Sphere_Mesh") +algo = my_hexa.Segment() +algo.NumberOfSegments(NbSeg) +my_hexa.Quadrangle() +my_hexa.Hexahedron() my_hexa.Compute() diff --git a/src/SMESH_SWIG/ex00_all.py b/src/SMESH_SWIG/ex00_all.py new file mode 100644 index 000000000..aba2b4347 --- /dev/null +++ b/src/SMESH_SWIG/ex00_all.py @@ -0,0 +1,25 @@ +# CEA/LGLS 2005, Francis KLOSS (OCC) +# ================================== + +# Load all examples +# ----------------- + +import ex01_cube2build +import ex02_cube2primitive +#import ex03_cube2partition +import ex04_cube5tetraHexa +import ex05_hole1build +import ex06_hole1boolean +import ex07_hole1partition +import ex08_hole2build +import ex09_grid4build +import ex10_grid4geometry +import ex11_grid3partition +import ex12_grid17partition +import ex13_hole1partial +import ex14_cyl1holed +import ex15_cyl2geometry +import ex16_cyl2complementary +import ex17_dome1 +#import ex18_dome2 +import ex19_sphereINcube diff --git a/src/SMESH_SWIG/cube2pyGibi.py b/src/SMESH_SWIG/ex01_cube2build.py similarity index 95% rename from src/SMESH_SWIG/cube2pyGibi.py rename to src/SMESH_SWIG/ex01_cube2build.py index 9de2b23b8..02b5b1506 100644 --- a/src/SMESH_SWIG/cube2pyGibi.py +++ b/src/SMESH_SWIG/ex01_cube2build.py @@ -1,16 +1,14 @@ -# CEA/LGLS 2004, Francis KLOSS (OCC) -# ================================== - -# Import -# ------ +# CEA/LGLS 2004-2005, Francis KLOSS (OCC) +# ======================================= from geompy import * -from meshpy import * + +import smesh # Geometry # ======== -# A small cube centered and put on a great cube +# A small cube centered and put on a great cube build by points, edges, faces and solids # Points # ------ @@ -258,13 +256,12 @@ c_l.append(greatBlock13) c_l.append(greatBlock23) c_l.append(greatBlock33) -c_cpd = MakeCompound(c_l) -piece = MakeGlueFaces(c_cpd, 1.e-5) +piece = MakeCompound(c_l) # Add in study # ------------ -piece_id = addToStudy(piece, "Cubes2pyGibi") +piece_id = addToStudy(piece, "ex01_cube2build") # Meshing # ======= @@ -272,24 +269,25 @@ piece_id = addToStudy(piece, "Cubes2pyGibi") # Create hexahedrical mesh on piece # --------------------------------- -m_hexa=MeshHexa(piece, 4, "Cubes2pyGibiHexa") +hexa = smesh.Mesh(piece, "ex01_cube2build:hexa") -# Get edges -# --------- +algo = hexa.Segment() +algo.NumberOfSegments(4) -e_edges = SubShapeAllSorted(piece, ShapeType["EDGE"]) +hexa.Quadrangle() + +hexa.Hexahedron() # Create local hypothesis # ----------------------- -m_local=3 +algo = hexa.Segment(greatEdgeX111) + +algo.Arithmetic1D(1, 4) -m_i=10 -while m_i<18: - m_hexa.local(e_edges[m_i], m_local) - m_i=m_i+1 +algo.Propagation() -# Compute -# ------- +# Compute the mesh +# ---------------- -m_hexa.Compute() +hexa.Compute() diff --git a/src/SMESH_SWIG/cube2geometry.py b/src/SMESH_SWIG/ex02_cube2primitive.py similarity index 74% rename from src/SMESH_SWIG/cube2geometry.py rename to src/SMESH_SWIG/ex02_cube2primitive.py index 3d503dc13..747507211 100644 --- a/src/SMESH_SWIG/cube2geometry.py +++ b/src/SMESH_SWIG/ex02_cube2primitive.py @@ -1,19 +1,17 @@ -# CEA/LGLS 2004, Francis KLOSS (OCC) -# ================================== - -# Import -# ------ +# CEA/LGLS 2004-2005, Francis KLOSS (OCC) +# ======================================= from geompy import * -from meshpy import * + +import smesh # Geometry # ======== -# Piece -# ----- +# A small cube centered and put on a great cube build by primitive geometric functionalities -# A small cube centered and put on a great cube +# Values +# ------ ox = 0 oy = 0 @@ -29,14 +27,11 @@ blockPoint211 = MakeVertex(ox+arete, oy, oz) blockPoint112 = MakeVertex(ox , oy, oz+arete) blockPoint212 = MakeVertex(ox+arete, oy, oz+arete) -# Faces -# ----- +# Face and solid +# -------------- blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112) -# Solids -# ------ - blockSolid11 = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete) # Translations @@ -55,8 +50,8 @@ blockSolid33 = MakeTranslation(blockSolid23, arete, 0, 0) blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0) -# Compound -# -------- +# Compound and glue +# ----------------- c_l = [] c_l.append(blockSolid11) @@ -71,12 +66,13 @@ c_l.append(blockSolid33) c_l.append(blockSolid111) c_cpd = MakeCompound(c_l) + piece = MakeGlueFaces(c_cpd, 1.e-5) # Add in study # ------------ -piece_id = addToStudy(piece, "Cubes2geometry") +piece_id = addToStudy(piece, "ex02_cube2primitive") # Meshing # ======= @@ -84,9 +80,16 @@ piece_id = addToStudy(piece, "Cubes2geometry") # Create hexahedrical mesh on piece # --------------------------------- -m_hexa=MeshHexa(piece, 4, "Cubes2geometryHexa") +hexa = smesh.Mesh(piece, "ex02_cube2primitive:hexa") + +algo = hexa.Segment() +algo.LocalLength(1) + +hexa.Quadrangle() + +hexa.Hexahedron() -# Compute -# ------- +# Compute the mesh +# ---------------- -m_hexa.Compute() +hexa.Compute() diff --git a/src/SMESH_SWIG/cube2partition.py b/src/SMESH_SWIG/ex03_cube2partition.py similarity index 60% rename from src/SMESH_SWIG/cube2partition.py rename to src/SMESH_SWIG/ex03_cube2partition.py index 4d69f555e..cc566893c 100644 --- a/src/SMESH_SWIG/cube2partition.py +++ b/src/SMESH_SWIG/ex03_cube2partition.py @@ -1,19 +1,17 @@ -# CEA/LGLS 2004, Francis KLOSS (OCC) -# ================================== - -# Import -# ------ +# CEA/LGLS 2004-2005, Francis KLOSS (OCC) +# ======================================= from geompy import * -from meshpy import * - -# Piece -# ----- -# A small cube centered and put on a great cube +import smesh # Geometry -# -------- +# ======== + +# A small cube centered and put on a great cube build with partition + +# Values +# ------ g_ox = 0 g_oy = 0 @@ -46,28 +44,22 @@ s_haut = MakeBoxTwoPnt(v_3, v_4) p_dir1 = MakeVectorDXDYDZ(1, 0, 0) p_dir2 = MakeVectorDXDYDZ(0, 0, 1) +p_dir3 = MakeVectorDXDYDZ(0, 1, 0) p_tools = [] + p_tools.append(MakePlane(v_3, p_dir1, g_trim)) p_tools.append(MakePlane(v_4, p_dir1, g_trim)) p_tools.append(MakePlane(v_3, p_dir2, g_trim)) p_tools.append(MakePlane(v_4, p_dir2, g_trim)) +p_tools.append(MakePlane(v_3, p_dir3, g_trim)) -p_element = MakePartition([s_base], p_tools, [], [], ShapeType["SOLID"]) - -# Compound -# -------- - -c_element = SubShapeAll(p_element, ShapeType["SOLID"]) -c_element.append(s_haut) - -c_cpd = MakeCompound(c_element) -piece = MakeGlueFaces(c_cpd, 1.e-5) +piece = MakePartition([s_base, s_haut], p_tools, [], [], ShapeType["SOLID"]) # Study # ----- -piece_id = addToStudy(piece, "Cubes2partition") +piece_id = addToStudy(piece, "ex03_cube2partition") # Meshing # ======= @@ -75,9 +67,16 @@ piece_id = addToStudy(piece, "Cubes2partition") # Create hexahedrical mesh on piece # --------------------------------- -m_hexa=MeshHexa(piece, 4, "Cubes2partitionHexa") +hexa = smesh.Mesh(piece, "ex03_cube2partition:hexa") + +algo = hexa.Segment() +algo.NumberOfSegments(5) + +hexa.Quadrangle() + +hexa.Hexahedron() -# Compute -# ------- +# Compute the mesh +# ---------------- -m_hexa.Compute() +hexa.Compute() diff --git a/src/SMESH_SWIG/ex04_cube5tetraHexa.py b/src/SMESH_SWIG/ex04_cube5tetraHexa.py new file mode 100644 index 000000000..5bb4a1c89 --- /dev/null +++ b/src/SMESH_SWIG/ex04_cube5tetraHexa.py @@ -0,0 +1,87 @@ +# CEA/LGLS 2004-2005, Francis KLOSS (OCC) +# ======================================= + +from geompy import * + +import smesh + +# Geometry +# ======== + +# 5 box with a hexahedral mesh and with 2 box in tetrahedral mesh + +# Values +# ------ + +arete = 100 + +arete0 = 0 +arete1 = arete +arete2 = arete*2 +arete3 = arete*3 + +# Solids +# ------ + +box_tetra1 = MakeBox(arete0, arete0, 0, arete1, arete1, arete) + +box_ijk1 = MakeBox(arete1, arete0, 0, arete2, arete1, arete) + +box_hexa = MakeBox(arete1, arete1, 0, arete2, arete2, arete) + +box_ijk2 = MakeBox(arete2, arete1, 0, arete3, arete2, arete) + +box_tetra2 = MakeBox(arete2, arete2, 0, arete3 ,arete3, arete) + +# Piece +# ----- + +piece_cpd = MakeCompound([box_tetra1, box_ijk1, box_hexa, box_ijk2, box_tetra2]) + +piece = MakeGlueFaces(piece_cpd, 1e-4) + +piece_id = addToStudy(piece, "ex04_cube5tetraHexa") + +# Meshing +# ======= + +# Create a hexahedral mesh +# ------------------------ + +mixed = smesh.Mesh(piece, "ex04_cube5tetraHexa:mixed") + +algo = mixed.Segment() + +algo.StartEndLength(3, 25) + +mixed.Quadrangle() + +mixed.Hexahedron() + +# Tetrahedral local mesh +# ---------------------- + +def localMesh(b, hyp): + box = GetInPlace(piece, b) + faces = SubShapeAll(box, ShapeType["FACE"]) + + i = 0 + n = len(faces) + while i