Salome HOME
NRI : Change lGeometryClient by lGEOMClient.
[modules/smesh.git] / src / SMDS / SMDSControl_BoundaryFaces.cxx
1 using namespace std;
2 // File:        SMDSControl_BoundaryFaces.cxx
3 // Created:     Tue Mar 12 23:46:24 2002
4 // Author:      Jean-Michel BOULCOURT
5 //              <jmb@localhost.localdomain>
6
7
8 #include "SMDSControl_BoundaryFaces.ixx"
9 #include "SMDSControl.hxx"
10
11 #include "SMDS_MeshVolumesIterator.hxx"
12 #include "SMDS_MeshElement.hxx"
13 #include "SMDS_MeshFace.hxx"
14 #include "SMDS_MeshTriangle.hxx"
15 #include "SMDS_MeshQuadrangle.hxx"
16 #include "SMDS_MapIteratorOfExtendedMap.hxx"
17
18 //=======================================================================
19 //function : SMDSControl_BoundaryFaces
20 //purpose  : 
21 //=======================================================================
22
23 SMDSControl_BoundaryFaces::SMDSControl_BoundaryFaces(const Handle(SMDS_Mesh)& M)
24   :SMDSControl_MeshBoundary(M)
25 {
26 }
27
28 //=======================================================================
29 //function : Compute
30 //purpose  : 
31 //=======================================================================
32
33 void SMDSControl_BoundaryFaces::Compute()
34 {
35   myBoundaryMesh = myMesh->AddSubMesh();
36   SMDS_MeshVolumesIterator itvol(myMesh);
37   
38   Standard_Integer idnode[4]; // max number of nodes for a face
39   Standard_Integer nbnode;
40
41   for (;itvol.More();itvol.Next()) {
42     Handle(SMDS_MeshElement) ME = itvol.Value();
43
44
45     Standard_Integer nbfaces = ME->NbFaces();
46
47     for (Standard_Integer iface=1; iface<=nbfaces; ++iface) {
48
49       ME->GetFaceDefinedByNodes(iface,idnode,nbnode);
50       // Triangle
51       if (nbnode == 3) {
52         Handle(SMDS_MeshElement) face = new SMDS_MeshTriangle(0,idnode[0],idnode[1],idnode[2]);
53         if (!myBoundaryFaces.Add(face))
54           myBoundaryFaces.Remove(face);
55
56           
57       } else {
58         // Quadrangle
59           
60         Handle(SMDS_MeshElement) face = new SMDS_MeshQuadrangle(0,idnode[0],idnode[1],idnode[2],idnode[3]);
61         if (!myBoundaryFaces.Add(face))
62           myBoundaryFaces.Remove(face);
63           
64       }
65     } // end iface
66
67   } // end itvol
68
69   SMDS_MapIteratorOfExtendedMap itbound(myBoundaryFaces);
70
71   for (;itbound.More();itbound.Next()) {
72     const Handle(SMDS_MeshElement)& face = itbound.Key();
73     if (face->NbNodes() == 3)
74       myBoundaryMesh->AddFace(face->GetConnection(1),face->GetConnection(2),face->GetConnection(3));
75     else
76       myBoundaryMesh->AddFace(face->GetConnection(1),face->GetConnection(2),face->GetConnection(3),
77                               face->GetConnection(4));
78   }
79
80 }
81         
82