X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2Fex13_hole1partial.py;h=6cb4b1c2ddac575b226a3287c62d7148178b1ff0;hp=705509bee76e2cf3c61ccb822b1ea2fe06656251;hb=30ce546b0c5099ad1112929e2db94810e683e54b;hpb=57b43b4d010e2d0a1529d3c131bbb9d416e63258 diff --git a/src/SMESH_SWIG/ex13_hole1partial.py b/src/SMESH_SWIG/ex13_hole1partial.py index 705509bee..6cb4b1c2d 100644 --- a/src/SMESH_SWIG/ex13_hole1partial.py +++ b/src/SMESH_SWIG/ex13_hole1partial.py @@ -1,28 +1,37 @@ -# Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS # -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. # -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. # -# See http://www.salome-platform.org/ +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# CEA/LGLS 2005, Francis KLOSS (OCC) -# ================================== -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 # ======== @@ -47,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 # ============== @@ -59,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 # ----------------------- @@ -77,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 # ============= @@ -111,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 # ---------------------- @@ -131,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 # ---------------- @@ -164,50 +173,50 @@ 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) +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 # ======= @@ -228,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() @@ -248,3 +257,8 @@ local(cyl_x+d, cyl_y+d, box_dz, 10) # ---------------- hexa.Compute() + +# Update object browser +# --------------------- + +salome.sg.updateObjBrowser(True)