1 // Copyright (C) 2007-2010 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
23 // SMESH SMDS : implementaion of Salome mesh data structure
26 #pragma warning(disable:4786)
29 #include "SMDS_SetIterator.hxx"
30 #include "SMDS_FaceOfNodes.hxx"
31 #include "SMDS_IteratorOfElements.hxx"
32 #include "SMDS_MeshNode.hxx"
33 #include "SMDS_Mesh.hxx"
35 #include "utilities.h"
39 //=======================================================================
42 //=======================================================================
44 int SMDS_FaceOfNodes::NbEdges() const
49 int SMDS_FaceOfNodes::NbFaces() const
54 int SMDS_FaceOfNodes::NbNodes() const
59 //=======================================================================
62 //=======================================================================
64 void SMDS_FaceOfNodes::Print(ostream & OS) const
66 OS << "face <" << GetID() << " > : ";
68 for (i = 0; i < NbNodes() - 1; i++) OS << myNodes[i] << ",";
69 OS << myNodes[i] << ") " << endl;
72 //=======================================================================
73 //function : elementsIterator
75 //=======================================================================
77 class SMDS_FaceOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
80 SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
81 SMDS_NodeArrayElemIterator( s, & s[ l ] ) {}
84 /// ===================================================================
86 * \brief Iterator on edges of face
88 /// ===================================================================
90 class _MyEdgeIterator : public SMDS_ElemIterator
92 vector< const SMDS_MeshElement* > myElems;
95 _MyEdgeIterator(const SMDS_FaceOfNodes* face):myIndex(0) {
96 myElems.reserve( face->NbNodes() );
97 for ( int i = 0; i < face->NbNodes(); ++i ) {
98 const SMDS_MeshElement* edge =
99 SMDS_Mesh::FindEdge( face->GetNode( i ), face->GetNodeWrap( i + 1 ));
101 myElems.push_back( edge );
104 /// Return true if and only if there are other object in this iterator
105 virtual bool more() { return myIndex < myElems.size(); }
107 /// Return the current object and step to the next one
108 virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
111 SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator
112 (SMDSAbs_ElementType type) const
117 return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
119 return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes));
121 return SMDS_ElemIteratorPtr(new _MyEdgeIterator( this ));
124 return SMDS_ElemIteratorPtr
125 (new SMDS_IteratorOfElements
126 (this,type,SMDS_ElemIteratorPtr
127 (new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes))));
129 return SMDS_ElemIteratorPtr();
132 SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
133 const SMDS_MeshNode* node2,
134 const SMDS_MeshNode* node3)
143 SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
144 const SMDS_MeshNode* node2,
145 const SMDS_MeshNode* node3,
146 const SMDS_MeshNode* node4)
154 bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
163 else if (nbNodes != 3)
170 * \brief Return node by its index
171 * \param ind - node index
172 * \retval const SMDS_MeshNode* - the node
174 const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const
176 return myNodes[ ind ];
179 SMDSAbs_EntityType SMDS_FaceOfNodes::GetEntityType() const
181 return myNbNodes == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;