diff --git a/src/SMESH_SWIG/ex12_grid17partition.py b/src/SMESH_SWIG/ex12_grid17partition.py index bf6593b99..76a49da65 100644 --- a/src/SMESH_SWIG/ex12_grid17partition.py +++ b/src/SMESH_SWIG/ex12_grid17partition.py @@ -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 # ------------------------ diff --git a/src/SMESH_SWIG/ex13_hole1partial.py b/src/SMESH_SWIG/ex13_hole1partial.py index a54fd6266..36847d4bd 100644 --- a/src/SMESH_SWIG/ex13_hole1partial.py +++ b/src/SMESH_SWIG/ex13_hole1partial.py @@ -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() diff --git a/src/SMESH_SWIG/ex14_cyl1holed.py b/src/SMESH_SWIG/ex14_cyl1holed.py index 0f058c098..281ad4ec0 100644 --- a/src/SMESH_SWIG/ex14_cyl1holed.py +++ b/src/SMESH_SWIG/ex14_cyl1holed.py @@ -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