Salome HOME
Update mail address
[modules/smesh.git] / src / SMDS / SMDS_VolumeOfFaces.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SMDS_VolumeOfFaces.cxx
25 //  Author : Jean-Michel BOULCOURT
26 //  Module : SMESH
27
28 #ifdef _MSC_VER
29 #pragma warning(disable:4786)
30 #endif
31
32 #include "SMDS_VolumeOfFaces.hxx"
33 #include "SMDS_IteratorOfElements.hxx"
34
35 using namespace std;
36
37 //=======================================================================
38 //function : Print
39 //purpose  : 
40 //=======================================================================
41
42 void SMDS_VolumeOfFaces::Print(ostream & OS) const
43 {
44         OS << "volume <" << GetID() << "> : ";
45         int i;
46         for (i = 0; i < NbFaces()-1; ++i) OS << myFaces[i] << ",";
47         OS << myFaces[i]<< ") " << endl;
48 }
49
50
51 int SMDS_VolumeOfFaces::NbFaces() const
52 {
53         return myNbFaces;
54 }
55
56 class SMDS_VolumeOfFaces_MyIterator:public SMDS_ElemIterator
57 {
58   const SMDS_MeshFace* const *mySet;
59   int myLength;
60   int index;
61  public:
62   SMDS_VolumeOfFaces_MyIterator(const SMDS_MeshFace* const *s, int l):
63     mySet(s),myLength(l),index(0) {}
64
65   bool more()
66   {
67     return index<myLength;
68   }
69
70   const SMDS_MeshElement* next()
71   {
72     index++;
73     return mySet[index-1];
74   }
75 };
76
77 SMDS_ElemIteratorPtr SMDS_VolumeOfFaces::
78         elementsIterator(SMDSAbs_ElementType type) const
79 {
80   switch(type)
81   {
82   case SMDSAbs_Volume:
83     return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
84   case SMDSAbs_Face:
85     return SMDS_ElemIteratorPtr(new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces));
86   default:
87     return SMDS_ElemIteratorPtr
88       (new SMDS_IteratorOfElements
89        (this,type,SMDS_ElemIteratorPtr
90         (new SMDS_VolumeOfFaces_MyIterator(myFaces,myNbFaces))));
91   }
92 }
93
94 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
95                                        const SMDS_MeshFace * face2,
96                                        const SMDS_MeshFace * face3,
97                                        const SMDS_MeshFace * face4)
98 {
99         myNbFaces = 4;
100         myFaces[0]=face1;
101         myFaces[1]=face2;
102         myFaces[2]=face3;
103         myFaces[3]=face4;
104         myFaces[4]=0;
105         myFaces[5]=0;
106 }
107
108 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
109                                        const SMDS_MeshFace * face2,
110                                        const SMDS_MeshFace * face3,
111                                        const SMDS_MeshFace * face4,
112                                        const SMDS_MeshFace * face5)
113 {
114         myNbFaces = 5;
115         myFaces[0]=face1;
116         myFaces[1]=face2;
117         myFaces[2]=face3;
118         myFaces[3]=face4;
119         myFaces[4]=face5;
120         myFaces[5]=0;
121 }
122
123 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(const SMDS_MeshFace * face1,
124                                        const SMDS_MeshFace * face2,
125                                        const SMDS_MeshFace * face3,
126                                        const SMDS_MeshFace * face4,
127                                        const SMDS_MeshFace * face5,
128                                        const SMDS_MeshFace * face6)
129 {
130         myNbFaces = 6;
131         myFaces[0]=face1;
132         myFaces[1]=face2;
133         myFaces[2]=face3;
134         myFaces[3]=face4;
135         myFaces[4]=face5;
136         myFaces[5]=face6;
137 }
138