X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2Fex24_cylinder.py;h=f510c05fa95c7783ce8efa3d67daaacf5818ef35;hp=1fad8aa3bc42e199da34d7152cd62ea8b600e5bf;hb=1821a9c35f90be93d3d55b1e1db9114902eaf6f8;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESH_SWIG/ex24_cylinder.py b/src/SMESH_SWIG/ex24_cylinder.py index 1fad8aa3b..f510c05fa 100644 --- a/src/SMESH_SWIG/ex24_cylinder.py +++ b/src/SMESH_SWIG/ex24_cylinder.py @@ -1,10 +1,10 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2014 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. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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()