Salome HOME
Add some comments
[modules/smesh.git] / src / SMDS / SMDS_FaceOfEdges.cxx
1 //  SMESH SMDS : implementaion of Salome mesh data structure
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21
22 #include "SMDS_FaceOfEdges.hxx"
23 #include "SMDS_IteratorOfElements.hxx"
24 #include "SMDS_MeshNode.hxx"
25
26 //=======================================================================
27 //function : NbEdges
28 //purpose  : 
29 //=======================================================================
30
31 int SMDS_FaceOfEdges::NbEdges() const
32 {
33         return myEdges.size();
34 }
35
36 int SMDS_FaceOfEdges::NbFaces() const
37 {
38         return 1;
39 }
40 //=======================================================================
41 //function : Print
42 //purpose  : 
43 //=======================================================================
44
45 void SMDS_FaceOfEdges::Print(ostream & OS) const
46 {
47         OS << "face <" << GetID() << " > : ";
48         int i;
49         for (i = 0; i < NbEdges() - 1; i++) OS << myEdges[i] << ",";
50         OS << myEdges[i] << ") " << endl;
51 }
52
53 SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
54 {
55         return SMDSAbs_Face;
56 }
57
58 SMDS_Iterator<const SMDS_MeshElement *> * SMDS_FaceOfEdges::
59         elementsIterator(SMDSAbs_ElementType type) const
60 {
61         class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
62         {
63                 const vector<const SMDS_MeshEdge*>& mySet;
64                 int index;
65           public:
66                 MyIterator(const vector<const SMDS_MeshEdge*>& s):mySet(s),index(0)
67                 {}
68
69                 bool more()
70                 {
71                         return index<mySet.size();
72                 }
73
74                 const SMDS_MeshElement* next()
75                 {
76                         index++;
77                         return mySet[index-1];
78                 }       
79         };
80
81         switch(type)
82         {
83         case SMDSAbs_Face:return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
84         case SMDSAbs_Edge:return new MyIterator(myEdges);
85         default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myEdges));
86         }
87 }
88
89 SMDS_FaceOfEdges::SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
90         SMDS_MeshEdge* edge3)
91 {
92         myEdges.resize(3);
93         myEdges[0]=edge1;
94         myEdges[1]=edge2;
95         myEdges[2]=edge3;
96 }
97
98 SMDS_FaceOfEdges::SMDS_FaceOfEdges(SMDS_MeshEdge* edge1, SMDS_MeshEdge* edge2,
99         SMDS_MeshEdge* edge3, SMDS_MeshEdge* edge4)
100 {
101         myEdges.resize(4);
102         myEdges[0]=edge1;
103         myEdges[1]=edge2;
104         myEdges[2]=edge3;
105         myEdges[3]=edge4;       
106 }
107
108 /*bool operator<(const SMDS_FaceOfEdges& f1, const SMDS_FaceOfEdges& f2)
109 {
110         set<SMDS_MeshNode> set1,set2;
111         SMDS_Iterator<const SMDS_MeshElement*> * it;
112         const SMDS_MeshNode * n;
113
114         it=f1.nodesIterator();
115
116         while(it->more())
117         {
118                 n=static_cast<const SMDS_MeshNode *>(it->next());
119                 set1.insert(*n);
120         }
121
122         delete it;
123         it=f2.nodesIterator();
124         
125         while(it->more())
126         {       
127                 n=static_cast<const SMDS_MeshNode *>(it->next());
128                 set2.insert(*n);
129         }
130
131         delete it;
132         return set1<set2;       
133
134 }*/
135