smesh/test/ex30_groupsOp.py

94 lines
3.1 KiB
Python
Raw Normal View History

2012-08-09 16:03:55 +06:00
# -*- coding: iso-8859-1 -*-
2022-05-05 18:51:12 +05:00
# Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
2012-08-09 16:03:55 +06:00
#
# 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
2014-02-20 18:25:37 +06:00
# version 2.1 of the License, or (at your option) any later version.
2012-08-09 16:03:55 +06:00
#
# 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
#
import salome
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
2017-06-13 15:01:10 +05:00
geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
2017-06-13 15:01:10 +05:00
smesh = smeshBuilder.New()
import math
2012-08-09 16:03:55 +06:00
global Face_1
Face_1 = geompy.MakeFaceHW(100, 100, 1)
geompy.addToStudy( Face_1, "Face_1" )
2017-06-13 15:01:10 +05:00
smesh.UpdateStudy()
from salome.StdMeshers import StdMeshersBuilder
2012-08-09 16:03:55 +06:00
pattern = smesh.GetPattern()
Mesh_1 = smesh.Mesh(Face_1)
Regular_1D = Mesh_1.Segment()
Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
Nb_Segments_1.SetDistrType( 0 )
Quadrangle_2D = Mesh_1.Quadrangle()
isDone = Mesh_1.Compute()
2023-02-21 18:59:44 +05:00
if not isDone:
raise Exception("Error when computing Mesh")
2012-08-09 16:03:55 +06:00
# groups creation
aListOfElems = [ 52, 53, 54, 55, 56, 57,
62, 63, 64, 65, 66, 67,
72, 73, 74, 75, 76, 77,
82, 83, 84, 85, 86, 87 ]
aRedGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Red" )
2012-08-09 16:03:55 +06:00
aRedGroup.Add( aListOfElems );
aRedGroup.SetColor( SALOMEDS.Color( 1, 0, 0 ) )
aListOfElems = [ 55, 56, 57, 58, 59,
65, 66, 67, 68, 69,
75, 76, 77, 78, 79,
85, 86, 87, 88, 89,
95, 96, 97, 98, 99,
105, 106, 107, 108, 109,
115, 116, 117, 118, 119,
125, 126, 127, 128, 129 ]
aGreenGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Green" )
2012-08-09 16:03:55 +06:00
aGreenGroup.Add( aListOfElems );
aGreenGroup.SetColor( SALOMEDS.Color( 0, 1, 0 ) )
aListOfElems = [ 63, 64, 65, 66, 67, 68,
73, 74, 75, 76, 77, 78,
83, 84, 85, 86, 87, 88,
93, 94, 95, 96, 97, 98,
103, 104, 105, 106, 107, 108,
113, 114, 115, 116, 117, 118 ]
aBlueGroup = Mesh_1.GetMesh().CreateGroup( SMESH.FACE, "Blue" )
2012-08-09 16:03:55 +06:00
aBlueGroup.Add( aListOfElems );
aBlueGroup.SetColor( SALOMEDS.Color( 0, 0, 1 ) )
# UnionListOfGroups()
aUnGrp = Mesh_1.UnionListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "UnionGrp" )
# IntersectListOfGroups()
aIntGrp=Mesh_1.IntersectListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "IntGrp" )
# CutListOfGroups()
aCutGrp=Mesh_1.CutListOfGroups([aRedGroup],[aGreenGroup,aBlueGroup],"CutGrp")
2017-06-13 15:01:10 +05:00
salome.sg.updateObjBrowser()
2012-08-09 16:03:55 +06:00