Salome HOME
4215c0d8c78e3ec074e232dc1209e13d1a62c08e
[modules/smesh.git] / src / SMDS / SMDSControl_BoundaryEdges.cxx
1 using namespace std;
2 // File:        SMDSControl_BoundaryEdges.cxx
3 // Created:     Wed Feb 20 19:28:42 2002
4 // Author:      Jean-Michel BOULCOURT
5 //              <jmb@localhost.localdomain>
6
7
8 #include "SMDSControl_BoundaryEdges.ixx"
9 #include "SMDSControl.hxx"
10
11 #include "SMDS_MeshFacesIterator.hxx"
12 #include "SMDS_MeshElement.hxx"
13 #include "SMDS_MeshEdge.hxx"
14 #include "SMDS_MapIteratorOfExtendedMap.hxx"
15
16 //=======================================================================
17 //function : SMDSControl_BoundaryEdges
18 //purpose  : 
19 //=======================================================================
20
21 SMDSControl_BoundaryEdges::SMDSControl_BoundaryEdges(const Handle(SMDS_Mesh)& M)
22   :SMDSControl_MeshBoundary(M)
23 {
24 }
25
26 //=======================================================================
27 //function : Compute
28 //purpose  : 
29 //=======================================================================
30
31 void SMDSControl_BoundaryEdges::Compute()
32 {
33   Standard_Integer idnode1;
34   Standard_Integer idnode2;
35   Standard_Integer nbedg;
36
37   myBoundaryMesh = myMesh->AddSubMesh();
38   SMDS_MeshFacesIterator itface(myMesh);
39
40   for (;itface.More();itface.Next()) {
41     Handle(SMDS_MeshElement) ME = itface.Value();
42
43     nbedg = ME->NbEdges();
44
45     for (Standard_Integer iedge=1; iedge<=nbedg; ++iedge) {
46       ME->GetEdgeDefinedByNodes(iedge,idnode1,idnode2);
47       Handle(SMDS_MeshElement) edge = new SMDS_MeshEdge(0,idnode1,idnode2);
48       if (!myBoundaryEdges.Add(edge))
49         myBoundaryEdges.Remove(edge);
50     }
51   }
52   
53   SMDS_MapIteratorOfExtendedMap itbound(myBoundaryEdges);
54
55   for (;itbound.More();itbound.Next()) {
56     const Handle(SMDS_MeshElement)& edge = itbound.Key();
57     myBoundaryMesh->AddEdge(edge->GetConnection(1),edge->GetConnection(2));
58   }
59 }