1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 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
23 #pragma warning(disable:4786)
26 #include "SMDS_PolygonalFaceOfNodes.hxx"
28 #include "SMDS_IteratorOfElements.hxx"
29 #include "SMDS_SetIterator.hxx"
30 #include "utilities.h"
34 //=======================================================================
35 //function : Constructor
37 //=======================================================================
38 SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes
39 (std::vector<const SMDS_MeshNode *> nodes)
44 //=======================================================================
47 //=======================================================================
48 SMDSAbs_ElementType SMDS_PolygonalFaceOfNodes::GetType() const
51 //return SMDSAbs_PolygonalFace;
54 //=======================================================================
55 //function : ChangeNodes
57 //=======================================================================
58 bool SMDS_PolygonalFaceOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes)
68 //=======================================================================
69 //function : ChangeNodes
70 //purpose : to support the same interface, as SMDS_FaceOfNodes
71 //=======================================================================
72 bool SMDS_PolygonalFaceOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
78 myNodes.resize(nbNodes);
80 for (; i < nbNodes; i++) {
81 myNodes[i] = nodes[i];
87 //=======================================================================
90 //=======================================================================
91 int SMDS_PolygonalFaceOfNodes::NbNodes() const
93 return myNodes.size();
96 //=======================================================================
99 //=======================================================================
100 int SMDS_PolygonalFaceOfNodes::NbEdges() const
105 //=======================================================================
108 //=======================================================================
109 int SMDS_PolygonalFaceOfNodes::NbFaces() const
114 //=======================================================================
117 //=======================================================================
118 void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const
120 OS << "polygonal face <" << GetID() << " > : ";
121 int i, nbNodes = myNodes.size();
122 for (i = 0; i < nbNodes - 1; i++)
123 OS << myNodes[i] << ",";
124 OS << myNodes[i] << ") " << endl;
127 //=======================================================================
128 //function : elementsIterator
130 //=======================================================================
131 class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_NodeVectorElemIterator
134 SMDS_PolygonalFaceOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
135 SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
138 SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
139 (SMDSAbs_ElementType type) const
144 return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
146 return SMDS_ElemIteratorPtr(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes));
148 MESSAGE("Error : edge iterator for SMDS_PolygonalFaceOfNodes not implemented");
151 return SMDS_ElemIteratorPtr
152 (new SMDS_IteratorOfElements
153 (this,type,SMDS_ElemIteratorPtr
154 (new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes))));
156 return SMDS_ElemIteratorPtr();
160 * \brief Return node by its index
161 * \param ind - node index
162 * \retval const SMDS_MeshNode* - the node
164 * Index is wrapped if it is out of a valid range
166 const SMDS_MeshNode* SMDS_PolygonalFaceOfNodes::GetNode(const int ind) const
168 return myNodes[ WrappedIndex( ind )];