1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 OPEN CASCADE
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.opencascade.org or email : webmaster@opencascade.org
23 // File : SMDSControl_BoundaryFaces.cxx
24 // Author : Jean-Michel BOULCOURT
28 #include "SMDSControl_BoundaryFaces.ixx"
29 #include "SMDSControl.hxx"
31 #include "SMDS_MeshVolumesIterator.hxx"
32 #include "SMDS_MeshElement.hxx"
33 #include "SMDS_MeshFace.hxx"
34 #include "SMDS_MeshTriangle.hxx"
35 #include "SMDS_MeshQuadrangle.hxx"
36 #include "SMDS_MapIteratorOfExtendedMap.hxx"
38 //=======================================================================
39 //function : SMDSControl_BoundaryFaces
41 //=======================================================================
43 SMDSControl_BoundaryFaces::SMDSControl_BoundaryFaces(const Handle(SMDS_Mesh)& M)
44 :SMDSControl_MeshBoundary(M)
48 //=======================================================================
51 //=======================================================================
53 void SMDSControl_BoundaryFaces::Compute()
55 myBoundaryMesh = myMesh->AddSubMesh();
56 SMDS_MeshVolumesIterator itvol(myMesh);
58 Standard_Integer idnode[4]; // max number of nodes for a face
59 Standard_Integer nbnode;
61 for (;itvol.More();itvol.Next()) {
62 Handle(SMDS_MeshElement) ME = itvol.Value();
65 Standard_Integer nbfaces = ME->NbFaces();
67 for (Standard_Integer iface=1; iface<=nbfaces; ++iface) {
69 ME->GetFaceDefinedByNodes(iface,idnode,nbnode);
72 Handle(SMDS_MeshElement) face = new SMDS_MeshTriangle(0,idnode[0],idnode[1],idnode[2]);
73 if (!myBoundaryFaces.Add(face))
74 myBoundaryFaces.Remove(face);
80 Handle(SMDS_MeshElement) face = new SMDS_MeshQuadrangle(0,idnode[0],idnode[1],idnode[2],idnode[3]);
81 if (!myBoundaryFaces.Add(face))
82 myBoundaryFaces.Remove(face);
89 SMDS_MapIteratorOfExtendedMap itbound(myBoundaryFaces);
91 for (;itbound.More();itbound.Next()) {
92 const Handle(SMDS_MeshElement)& face = itbound.Key();
93 if (face->NbNodes() == 3)
94 myBoundaryMesh->AddFace(face->GetConnection(1),face->GetConnection(2),face->GetConnection(3));
96 myBoundaryMesh->AddFace(face->GetConnection(1),face->GetConnection(2),face->GetConnection(3),
97 face->GetConnection(4));