X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2FSMESH_hexaedre.py;h=8fd527f8ff02b496affe9db816a2b7922acbcc2e;hp=0a058a2a01cf356b5a9868bd83708f5902b8d850;hb=54182913fbb9df65a3f4cc96f55db3618835ecd8;hpb=c63ee099ad2b149bd70136839c973e8910137bc5 diff --git a/src/SMESH_SWIG/SMESH_hexaedre.py b/src/SMESH_SWIG/SMESH_hexaedre.py index 0a058a2a0..8fd527f8f 100755 --- a/src/SMESH_SWIG/SMESH_hexaedre.py +++ b/src/SMESH_SWIG/SMESH_hexaedre.py @@ -1,57 +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-2013 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. # -# 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. +# +# 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 # -#============================================================================== -# Info. -# Bug (from script, bug) : hexaedre_modified.py, PAL6194, PAL7153 -# Modified : 25/11/2004 -# Author : Kovaltchuk Alexey -# Project : PAL/SALOME -#============================================================================== - import salome -from salome import sg +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -import geompy - -import math +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) # ----------------------------------------------------------------------------- -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -myBuilder = salome.myStudy.NewBuilder() -gg = salome.ImportComponentGUI("GEOM") -from salome import sg - -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - -Boolop_common = 1 -Boolop_cut = 2 -Boolop_fuse = 3 -Boolop_section = 4 - p0 = geompy.MakeVertex(0., 0., 0.) px = geompy.MakeVertex(100., 0., 0.) py = geompy.MakeVertex(0., 100., 0.) @@ -74,93 +54,46 @@ blob=geompy.MakeCut(vol3,sphereInt) idblob = geompy.addToStudy(blob,"blob") -aretes = [] -aretes = geompy.SubShapeAllSorted(blob, ShapeTypeEdge) -eid=0 - -# ------------------------------- -# --- numerotation des aretes -##for edge in aretes: -## edname="arete%d"%eid -## idedge=geompy.addToStudy(edge,edname) -## eid=eid+1 +edgeGroups = geompy.Propagate( blob ) +assert len( edgeGroups ) == 3 salome.sg.updateObjBrowser(1) -# --- epaisseur 0 2 8 10 -# --- hauteur 1 3 9 11 -# --- largeur 4 5 6 7 - # ----------------------------------------------------------------------------- print "-------------------------- mesh" - -import SMESH -import StdMeshers -smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smesh.SetCurrentStudy(salome.myStudy) -# ---- create Hypothesis -print "-------------------------- create Hypothesis" -numberOfSegments = 4 -hypNbSegA=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") -hypNbSegA.SetNumberOfSegments(numberOfSegments) -numberOfSegments = 10 -hypNbSegB=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") -hypNbSegB.SetNumberOfSegments(numberOfSegments) -numberOfSegments = 15 -hypNbSegC=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") -hypNbSegC.SetNumberOfSegments(numberOfSegments) - -# ---- create Algorithms -print "-------------------------- create Algorithms" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") -quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so") -hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so") +# ---- define a mesh on the geom shape 'blob' +mesh=smesh.Mesh(blob, "MeshBlob") -# ---- init a Mesh with the geom shape -shape_mesh = blob -myMesh=smesh.CreateMesh(shape_mesh) - -# ---- add hypothesis and algorithms to mesh +# ---- assign global hypothesis and algorithms to mesh print "-------------------------- add hypothesis to mesh" -myMesh.AddHypothesis(shape_mesh,regular1D) -myMesh.AddHypothesis(shape_mesh,quad2D) -myMesh.AddHypothesis(shape_mesh,hexa3D) - -#myMesh.AddHypothesis(shape_mesh,hypNbSeg) - -myMesh.AddHypothesis(aretes[0],hypNbSegA) -myMesh.AddHypothesis(aretes[2],hypNbSegA) -myMesh.AddHypothesis(aretes[8],hypNbSegA) -myMesh.AddHypothesis(aretes[10],hypNbSegA) - -myMesh.AddHypothesis(aretes[1],hypNbSegC) -myMesh.AddHypothesis(aretes[3],hypNbSegC) -myMesh.AddHypothesis(aretes[9],hypNbSegC) -myMesh.AddHypothesis(aretes[11],hypNbSegC) - -myMesh.AddHypothesis(aretes[4],hypNbSegB) -myMesh.AddHypothesis(aretes[5],hypNbSegB) -myMesh.AddHypothesis(aretes[6],hypNbSegB) -myMesh.AddHypothesis(aretes[7],hypNbSegB) +algo1 = mesh.Segment() +algo2 = mesh.Quadrangle() +algo3 = mesh.Hexahedron() + +# ---- assign local hypothesis and algorithms to mesh +for edges in edgeGroups: # loop on groups of logically parallel edges + length = geompy.BasicProperties( edges )[0] + if length < 500: nbSeg = 4 + elif length < 2000: nbSeg = 10 + else: nbSeg = 15 + algo = mesh.Segment( edges ) + algo.NumberOfSegments( nbSeg ) + pass # ---- compute mesh - print "-------------------------- compute mesh" -ret=smesh.Compute(myMesh, shape_mesh) -print ret -if ret != 0: - #log=myMesh.GetLog(0) # no erase trace - #for linelog in log: - # print linelog +ok = mesh.Compute() +if ok: print "Information about the Mesh:" - print "Number of nodes : ", myMesh.NbNodes() - print "Number of edges : ", myMesh.NbEdges() - print "Number of faces : ", myMesh.NbFaces() - print "Number of quadrangles : ", myMesh.NbQuadrangles() - print "Number of volumes : ", myMesh.NbVolumes() - print "Number of hexahedrons : ", myMesh.NbHexas() + print "Number of nodes : ", mesh.NbNodes() + print "Number of edges : ", mesh.NbEdges() + print "Number of faces : ", mesh.NbFaces() + print "Number of quadrangles : ", mesh.NbQuadrangles() + print "Number of volumes : ", mesh.NbVolumes() + print "Number of hexahedrons : ", mesh.NbHexas() else: print "problem when Computing the mesh"