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_SetIterator.hxx"
29 #include "SMDS_FaceOfNodes.hxx"
30 #include "SMDS_IteratorOfElements.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include "SMDS_Mesh.hxx"
34 #include "utilities.h"
38 //=======================================================================
41 //=======================================================================
43 int SMDS_FaceOfNodes::NbEdges() const
48 int SMDS_FaceOfNodes::NbFaces() const
53 int SMDS_FaceOfNodes::NbNodes() const
58 //=======================================================================
61 //=======================================================================
63 void SMDS_FaceOfNodes::Print(ostream & OS) const
65 OS << "face <" << GetID() << " > : ";
67 for (i = 0; i < NbNodes() - 1; i++) OS << myNodes[i] << ",";
68 OS << myNodes[i] << ") " << endl;
71 //=======================================================================
72 //function : elementsIterator
74 //=======================================================================
76 class SMDS_FaceOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
79 SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
80 SMDS_NodeArrayElemIterator( s, & s[ l ] ) {}
83 /// ===================================================================
85 * \brief Iterator on edges of face
87 /// ===================================================================
89 class _MyEdgeIterator : public SMDS_ElemIterator
91 vector< const SMDS_MeshElement* > myElems;
94 _MyEdgeIterator(const SMDS_FaceOfNodes* face):myIndex(0) {
95 myElems.reserve( face->NbNodes() );
96 for ( int i = 0; i < face->NbNodes(); ++i ) {
97 const SMDS_MeshElement* edge =
98 SMDS_Mesh::FindEdge( face->GetNode( i ), face->GetNodeWrap( i + 1 ));
100 myElems.push_back( edge );
103 /// Return true if and only if there are other object in this iterator
104 virtual bool more() { return myIndex < myElems.size(); }
106 /// Return the current object and step to the next one
107 virtual const SMDS_MeshElement* next() { return myElems[ myIndex++ ]; }
110 SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator
111 (SMDSAbs_ElementType type) const
116 return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
118 return SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes));
120 return SMDS_ElemIteratorPtr(new _MyEdgeIterator( this ));
123 return SMDS_ElemIteratorPtr
124 (new SMDS_IteratorOfElements
125 (this,type,SMDS_ElemIteratorPtr
126 (new SMDS_FaceOfNodes_MyIterator(myNodes,myNbNodes))));
128 return SMDS_ElemIteratorPtr();
131 SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
132 const SMDS_MeshNode* node2,
133 const SMDS_MeshNode* node3)
142 SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1,
143 const SMDS_MeshNode* node2,
144 const SMDS_MeshNode* node3,
145 const SMDS_MeshNode* node4)
153 bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
162 else if (nbNodes != 3)
169 * \brief Return node by its index
170 * \param ind - node index
171 * \retval const SMDS_MeshNode* - the node
173 const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const
175 return myNodes[ ind ];
178 SMDSAbs_EntityType SMDS_FaceOfNodes::GetEntityType() const
180 return myNbNodes == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;