1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // SMESH SMDS : implementaion of Salome mesh data structure
26 #pragma warning(disable:4786)
29 #include "SMDS_FaceOfEdges.hxx"
30 #include "SMDS_IteratorOfElements.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include "utilities.h"
36 //=======================================================================
39 //=======================================================================
41 int SMDS_FaceOfEdges::NbEdges() const
46 int SMDS_FaceOfEdges::NbFaces() const
50 //=======================================================================
53 //=======================================================================
55 void SMDS_FaceOfEdges::Print(ostream & OS) const
57 OS << "face <" << GetID() << " > : ";
59 for (i = 0; i < NbEdges() - 1; i++) OS << myEdges[i] << ",";
60 OS << myEdges[i] << ") " << endl;
63 SMDSAbs_ElementType SMDS_FaceOfEdges::GetType() const
68 //=======================================================================
69 //function : elementsIterator
71 //=======================================================================
73 class SMDS_FaceOfEdges_MyIterator:public SMDS_ElemIterator
75 const SMDS_MeshEdge* const *mySet;
79 SMDS_FaceOfEdges_MyIterator(const SMDS_MeshEdge* const *s, int l):
80 mySet(s),myLength(l),index(0) {}
84 return index<myLength;
87 const SMDS_MeshElement* next()
90 return mySet[index-1];
94 SMDS_ElemIteratorPtr SMDS_FaceOfEdges::elementsIterator
95 (SMDSAbs_ElementType type) const
100 return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
102 return SMDS_ElemIteratorPtr(new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges));
104 return SMDS_ElemIteratorPtr
105 (new SMDS_IteratorOfElements
106 (this,type, SMDS_ElemIteratorPtr
107 (new SMDS_FaceOfEdges_MyIterator(myEdges,myNbEdges))));
111 SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
112 const SMDS_MeshEdge* edge2,
113 const SMDS_MeshEdge* edge3)
115 //MESSAGE("****************************************************** SMDS_FaceOfEdges");
123 SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
124 const SMDS_MeshEdge* edge2,
125 const SMDS_MeshEdge* edge3,
126 const SMDS_MeshEdge* edge4)
128 //MESSAGE("****************************************************** SMDS_FaceOfEdges");
136 /*bool operator<(const SMDS_FaceOfEdges& f1, const SMDS_FaceOfEdges& f2)
138 set<SMDS_MeshNode> set1,set2;
139 SMDS_ElemIteratorPtr it;
140 const SMDS_MeshNode * n;
142 it=f1.nodesIterator();
146 n=static_cast<const SMDS_MeshNode *>(it->next());
151 it=f2.nodesIterator();
155 n=static_cast<const SMDS_MeshNode *>(it->next());
165 int SMDS_FaceOfEdges::NbNodes() const
167 return myEdges[0]->NbNodes() + myEdges[1]->NbNodes() + myEdges[2]->NbNodes() +
168 ( myNbEdges == 4 ? myEdges[3]->NbNodes() : 0 ) - myNbEdges;
172 * \brief Return node by its index
173 * \param ind - node index
174 * \retval const SMDS_MeshNode* - the node
176 const SMDS_MeshNode* SMDS_FaceOfEdges::GetNode(const int ind) const
179 for ( int i = 0; i < myNbEdges; ++i ) {
180 if ( index >= myEdges[ i ]->NbNodes() )
181 index -= myEdges[ i ]->NbNodes();
183 return myEdges[ i ]->GetNode( index );
188 SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const
190 return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
193 SMDSAbs_GeometryType SMDS_FaceOfEdges::GetGeomType() const
195 return myNbEdges == 3 ? SMDSGeom_TRIANGLE : SMDSGeom_QUADRANGLE;