Salome HOME
PAL9522 - do not abort on hypothesis assignation failure
[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 #ifdef _MSC_VER
23 #pragma warning(disable:4786)
24 #endif
25
26 #include "SMDS_FaceOfEdges.hxx"
27 #include "SMDS_IteratorOfElements.hxx"
28 #include "SMDS_MeshNode.hxx"
29
30 using namespace std;
31
32 //=======================================================================
33 //function : NbEdges
34 //purpose  : 
35 //=======================================================================
36
37 int SMDS_FaceOfEdges::NbEdges() const
38 {
39         return myNbEdges;
40 }
41
42 int SMDS_FaceOfEdges::NbFaces() const
43 {
44         return 1;
45 }
46 //=======================================================================
47 //function : Print
48 //purpose  : 
49 //=======================================================================
50
51 void SMDS_FaceOfEdges::Print(ostream & OS) const
52 {
53         OS << "face <" << GetID() << " > : ";
54         int i;
55         for (i = 0; i < NbEdges() - 1; i++) OS << myEdges[i] << ",";
56         OS << myEdges[i] << ") " << endl;
57 }
58
59 SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
60 {
61         return SMDSAbs_Face;
62 }
63
64 //=======================================================================
65 //function : elementsIterator
66 //purpose  : 
67 //=======================================================================
68
69 class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
70 {
71   const SMDS_MeshEdge* const *mySet;
72   int myLength;
73   int index;
74  public:
75   SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l):
76     mySet(s),myLength(l),index(0) {}
77
78   bool more()
79   {
80     return index<myLength;
81   }
82
83   const SMDS_MeshElement* next()
84   {
85     index++;
86     return mySet[index-1];
87   }     
88 };
89
90 SMDS_ElemIteratorPtr SMDS_FaceOfEdges::elementsIterator
91                          (SMDSAbs_ElementType type) const
92 {
93   switch(type)
94   {
95   case SMDSAbs_Face:
96     return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
97   case SMDSAbs_Edge:
98     return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges));
99   default:
100     return SMDS_ElemIteratorPtr
101       (new SMDS_IteratorOfElements
102        (this,type, SMDS_ElemIteratorPtr
103         (new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges))));
104   }
105 }
106
107 SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
108                                    const SMDS_MeshEdge* edge2,
109                                    const SMDS_MeshEdge* edge3)
110 {
111         myNbEdges = 3;
112         myEdges[0]=edge1;
113         myEdges[1]=edge2;
114         myEdges[2]=edge3;
115         myEdges[3]=0;
116 }
117
118 SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
119                                    const SMDS_MeshEdge* edge2,
120                                    const SMDS_MeshEdge* edge3,
121                                    const SMDS_MeshEdge* edge4)
122 {
123         myNbEdges = 4;
124         myEdges[0]=edge1;
125         myEdges[1]=edge2;
126         myEdges[2]=edge3;
127         myEdges[3]=edge4;       
128 }
129
130 /*bool operator<(const SMDS_FaceOfEdges& f1, const SMDS_FaceOfEdges& f2)
131 {
132         set<SMDS_MeshNode> set1,set2;
133         SMDS_ElemIteratorPtr it;
134         const SMDS_MeshNode * n;
135
136         it=f1.nodesIterator();
137
138         while(it->more())
139         {
140                 n=static_cast<const SMDS_MeshNode *>(it->next());
141                 set1.insert(*n);
142         }
143
144         delete it;
145         it=f2.nodesIterator();
146         
147         while(it->more())
148         {       
149                 n=static_cast<const SMDS_MeshNode *>(it->next());
150                 set2.insert(*n);
151         }
152
153         delete it;
154         return set1<set2;       
155
156 }*/
157