1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2014-2023 CEA, EDF
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 to create Groups On Entities From GMFFile /tmp/tmp.mesh
29 theStudy = salome.myStudy
31 import salome_notebook
32 notebook = salome_notebook.NoteBook(theStudy)
33 #sys.path.insert( 0, r'/somewhere')
40 from salome.geom import geomBuilder
43 import SMESH, SALOMEDS
45 from salome.smesh import smeshBuilder
47 smesh = smeshBuilder.New(theStudy)
53 nameFile = r'/tmp/tmp.mesh'
56 #do not work (the_mesh, error) = smesh.CreateMeshesFromMED(nameFile)
57 (the_mesh, error) = smesh.CreateMeshesFromGMF(nameFile)
60 #print "the_mesh", the_mesh
63 blue = SALOMEDS.Color(0,0,1)
64 red = SALOMEDS.Color(1,0,0)
65 green = SALOMEDS.Color(0,1,0)
66 yellow = SALOMEDS.Color(1,1,0)
69 if "Entity_" in i: print(i)
71 entities = [("Tetra", SMESH.Entity_Tetra, blue),
72 ("Pyramid", SMESH.Entity_Pyramid, red),
73 ("Prism", SMESH.Entity_Penta, yellow),
74 ("Hexa", SMESH.Entity_Hexa, green)]
76 for name, entity, color in entities:
78 aCriterion = smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_EntityType,SMESH.FT_Undefined,entity)
79 aCriteria.append(aCriterion)
80 aFilter = smesh.GetFilterFromCriteria(aCriteria)
81 aFilter.SetMesh(the_mesh.GetMesh())
82 Group = the_mesh.GroupOnFilter( SMESH.VOLUME, name, aFilter )
83 Group.SetColor( color )
85 if salome.sg.hasDesktop():
86 salome.sg.updateObjBrowser(True)