SALOME - SMESH
|
00001 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 // SMESH SMDS : implementaion of Salome mesh data structure 00023 // File : SMDS_MeshElement.hxx 00024 // Module : SMESH 00025 // 00026 #ifndef _SMDS_MeshElement_HeaderFile 00027 #define _SMDS_MeshElement_HeaderFile 00028 00029 #include "SMESH_SMDS.hxx" 00030 00031 #include "SMDSAbs_ElementType.hxx" 00032 #include "SMDS_MeshObject.hxx" 00033 #include "SMDS_ElemIterator.hxx" 00034 #include "SMDS_MeshElementIDFactory.hxx" 00035 00036 #include <vector> 00037 #include <iostream> 00038 00039 class SMDS_MeshNode; 00040 class SMDS_MeshEdge; 00041 class SMDS_MeshFace; 00042 00043 // ============================================================ 00047 // ============================================================ 00048 00049 class SMDS_EXPORT SMDS_MeshElement:public SMDS_MeshObject 00050 { 00051 public: 00052 00053 SMDS_ElemIteratorPtr nodesIterator() const; 00054 SMDS_ElemIteratorPtr edgesIterator() const; 00055 SMDS_ElemIteratorPtr facesIterator() const; 00056 virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; 00057 00058 virtual int NbNodes() const; 00059 virtual int NbEdges() const; 00060 virtual int NbFaces() const; 00061 int GetID() const; 00062 00064 virtual SMDSAbs_ElementType GetType() const = 0; 00065 virtual bool IsPoly() const { return false; }; 00066 virtual bool IsQuadratic() const; 00068 virtual SMDSAbs_EntityType GetEntityType() const = 0; 00069 00070 virtual bool IsMediumNode(const SMDS_MeshNode* node) const; 00071 00072 friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *); 00073 friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem); 00074 00075 // =========================== 00076 // Access to nodes by index 00077 // =========================== 00083 virtual const SMDS_MeshNode* GetNode(const int ind) const; 00084 00092 const SMDS_MeshNode* GetNodeWrap(const int ind) const { return GetNode( WrappedIndex( ind )); } 00093 00099 virtual bool IsValidIndex(const int ind) const; 00100 00106 int WrappedIndex(const int ind) const { 00107 if ( ind < 0 ) return NbNodes() + ind % NbNodes(); 00108 if ( ind >= NbNodes() ) return ind % NbNodes(); 00109 return ind; 00110 } 00111 00117 int GetNodeIndex( const SMDS_MeshNode* node ) const; 00118 00119 protected: 00120 SMDS_MeshElement(int ID=-1); 00121 virtual void Print(std::ostream & OS) const; 00122 00123 private: 00124 int myID; 00125 }; 00126 00127 // ============================================================ 00131 // ============================================================ 00132 00133 struct TIDCompare { 00134 bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const 00135 { return e1->GetID() < e2->GetID(); } 00136 }; 00137 00138 #endif