X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_SWIG%2FSMESH_hexaedre.py;h=1284b20e5151e75f390325ab6bac2b4eaa2e5f4d;hp=4159ded6494812302579385cc24b897daea8c803;hb=a0f09b9f1b8f5eac0e1c9277f76d65eb643cac94;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6 diff --git a/src/SMESH_SWIG/SMESH_hexaedre.py b/src/SMESH_SWIG/SMESH_hexaedre.py index 4159ded64..1284b20e5 100755 --- a/src/SMESH_SWIG/SMESH_hexaedre.py +++ b/src/SMESH_SWIG/SMESH_hexaedre.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -7,7 +7,7 @@ # 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 @@ -20,40 +20,18 @@ # # 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 -import geompy -import smesh +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) -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") - -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.) @@ -73,85 +51,43 @@ vol1=geompy.MakeCut(sphereExt,sphereA) vol2=geompy.MakeCut(vol1,sphereB) vol3=geompy.MakeCut(vol2,cylindre) blob=geompy.MakeCut(vol3,sphereInt) +blob=geompy.RemoveExtraEdges(blob) 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" smesh.SetCurrentStudy(salome.myStudy) -# ---- init a Mesh with the geom shape -shape_mesh = blob -mesh=smesh.Mesh(shape_mesh, "MeshBlob") +# ---- define a mesh on the geom shape 'blob' +mesh=smesh.Mesh(blob, "MeshBlob") -# ---- add hypothesis and algorithms to mesh +# ---- assign global hypothesis and algorithms to mesh print "-------------------------- add hypothesis to mesh" algo1 = mesh.Segment() algo2 = mesh.Quadrangle() algo3 = mesh.Hexahedron() -numberOfSegmentsA = 4 - -algo = mesh.Segment(aretes[0]) -algo.NumberOfSegments(numberOfSegmentsA) -algo = mesh.Segment(aretes[2]) -algo.NumberOfSegments(numberOfSegmentsA) -algo = mesh.Segment(aretes[8]) -algo.NumberOfSegments(numberOfSegmentsA) -algo = mesh.Segment(aretes[10]) -algo.NumberOfSegments(numberOfSegmentsA) - - -numberOfSegmentsC = 15 - -algo = mesh.Segment(aretes[1]) -algo.NumberOfSegments(numberOfSegmentsC) -algo = mesh.Segment(aretes[3]) -algo.NumberOfSegments(numberOfSegmentsC) -algo = mesh.Segment(aretes[9]) -algo.NumberOfSegments(numberOfSegmentsC) -algo = mesh.Segment(aretes[11]) -algo.NumberOfSegments(numberOfSegmentsC) - - -numberOfSegmentsB = 10 -algo = mesh.Segment(aretes[4]) -algo.NumberOfSegments(numberOfSegmentsB) -algo = mesh.Segment(aretes[5]) -algo.NumberOfSegments(numberOfSegmentsB) -algo = mesh.Segment(aretes[6]) -algo.NumberOfSegments(numberOfSegmentsB) -algo = mesh.Segment(aretes[7]) -algo.NumberOfSegments(numberOfSegmentsB) - +# ---- 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=mesh.Compute() -print ret -if ret != 0: - #log=mesh.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 : ", mesh.NbNodes() print "Number of edges : ", mesh.NbEdges()