1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMDS : implementaion of Salome mesh data structure
25 #pragma warning(disable:4786)
28 #include "SMDS_FaceOfEdges.hxx"
29 #include "SMDS_IteratorOfElements.hxx"
30 #include "SMDS_MeshNode.hxx"
34 //=======================================================================
37 //=======================================================================
39 int SMDS_FaceOfEdges::NbEdges() const
44 int SMDS_FaceOfEdges::NbFaces() const
48 //=======================================================================
51 //=======================================================================
53 void SMDS_FaceOfEdges::Print(ostream & OS) const
55 OS << "face <" << GetID() << " > : ";
57 for (i = 0; i < NbEdges() - 1; i++) OS << myEdges[i] << ",";
58 OS << myEdges[i] << ") " << endl;
61 SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
66 //=======================================================================
67 //function : elementsIterator
69 //=======================================================================
71 class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
73 const SMDS_MeshEdge* const *mySet;
77 SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l):
78 mySet(s),myLength(l),index(0) {}
82 return index<myLength;
85 const SMDS_MeshElement* next()
88 return mySet[index-1];
92 SMDS_ElemIteratorPtr SMDS_FaceOfEdges::elementsIterator
93 (SMDSAbs_ElementType type) const
98 return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
100 return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges));
102 return SMDS_ElemIteratorPtr
103 (new SMDS_IteratorOfElements
104 (this,type, SMDS_ElemIteratorPtr
105 (new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges))));
109 SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
110 const SMDS_MeshEdge* edge2,
111 const SMDS_MeshEdge* edge3)
120 SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
121 const SMDS_MeshEdge* edge2,
122 const SMDS_MeshEdge* edge3,
123 const SMDS_MeshEdge* edge4)
132 /*bool operator<(const SMDS_FaceOfEdges& f1, const SMDS_FaceOfEdges& f2)
134 set<SMDS_MeshNode> set1,set2;
135 SMDS_ElemIteratorPtr it;
136 const SMDS_MeshNode * n;
138 it=f1.nodesIterator();
142 n=static_cast<const SMDS_MeshNode *>(it->next());
147 it=f2.nodesIterator();
151 n=static_cast<const SMDS_MeshNode *>(it->next());
161 int SMDS_FaceOfEdges::NbNodes() const
163 return myEdges[0]->NbNodes() + myEdges[1]->NbNodes() + myEdges[2]->NbNodes() +
164 ( myNbEdges == 4 ? myEdges[3]->NbNodes() : 0 ) - myNbEdges;
168 * \brief Return node by its index
169 * \param ind - node index
170 * \retval const SMDS_MeshNode* - the node
172 const SMDS_MeshNode* SMDS_FaceOfEdges::GetNode(const int ind) const
175 for ( int i = 0; i < myNbEdges; ++i ) {
176 if ( index >= myEdges[ i ]->NbNodes() )
177 index -= myEdges[ i ]->NbNodes();
179 return myEdges[ i ]->GetNode( index );
184 SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const
186 return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;