Salome HOME
Remove OCC_LIBS from LDFLAGS
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMDS_MeshVolume.cxx
25 //  Author : Jean-Michel BOULCOURT
26 //  Module : SMESH
27
28 #include "SMDS_VolumeOfFaces.hxx"
29 #include "SMDS_IteratorOfElements.hxx"
30 //=======================================================================
31 //function : Print
32 //purpose  : 
33 //=======================================================================
34
35 void SMDS_VolumeOfFaces::Print(ostream & OS) const
36 {
37         OS << "volume <" << GetID() << "> : ";
38         int i;
39         for (i = 0; i < myFaces.size()-1; ++i) OS << myFaces[i] << ",";
40         OS << myFaces[i]<< ") " << endl;
41 }
42
43
44 int SMDS_VolumeOfFaces::NbFaces() const
45 {
46         return myFaces.size();
47 }
48
49 SMDS_Iterator<const SMDS_MeshElement *> * SMDS_VolumeOfFaces::
50         elementsIterator(SMDSAbs_ElementType type) const
51 {
52         class MyIterator:public SMDS_Iterator<const SMDS_MeshElement*>
53         {
54                 const vector<SMDS_MeshFace*>& mySet;
55                 int index;
56           public:
57                 MyIterator(const vector<SMDS_MeshFace*>& s):mySet(s),index(0)
58                 {}
59
60                 bool more()
61                 {
62                         return index<mySet.size();
63                 }
64
65                 const SMDS_MeshElement* next()
66                 {
67                         index++;
68                         return mySet[index-1];
69                 }       
70         };
71
72         switch(type)
73         {
74         case SMDSAbs_Volume:return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
75         case SMDSAbs_Face:return new MyIterator(myFaces);
76         default:return new SMDS_IteratorOfElements(this,type,new MyIterator(myFaces));
77         }
78 }
79
80 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
81         SMDS_MeshFace * face3, SMDS_MeshFace * face4)
82 {
83         myFaces.resize(4);
84         myFaces[0]=face1;
85         myFaces[1]=face2;
86         myFaces[2]=face3;
87         myFaces[3]=face4;
88 }
89
90 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
91                 SMDS_MeshFace * face3, SMDS_MeshFace * face4,
92                 SMDS_MeshFace * face5)
93 {
94         myFaces.resize(5);
95         myFaces[0]=face1;
96         myFaces[1]=face2;
97         myFaces[2]=face3;
98         myFaces[3]=face4;
99         myFaces[4]=face5;
100 }
101
102 SMDS_VolumeOfFaces::SMDS_VolumeOfFaces(SMDS_MeshFace * face1, SMDS_MeshFace * face2,
103                 SMDS_MeshFace * face3, SMDS_MeshFace * face4,
104                 SMDS_MeshFace * face5,SMDS_MeshFace * face6)
105 {
106         myFaces.resize(6);
107         myFaces[0]=face1;
108         myFaces[1]=face2;
109         myFaces[2]=face3;
110         myFaces[3]=face4;
111         myFaces[4]=face5;
112         myFaces[5]=face6;
113 }
114