00001 // Copyright (C) 2007-2011 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 00023 // SMESH SMDS : implementaion of Salome mesh data structure 00024 // 00025 #ifdef _MSC_VER 00026 #pragma warning(disable:4786) 00027 #endif 00028 00029 #include "SMDS_IteratorOfElements.hxx" 00030 00031 bool SMDS_IteratorOfElements::subMore() 00032 { 00033 if((t2Iterator.get()==NULL)||(!t2Iterator->more())) 00034 { 00035 if(t1Iterator->more()) 00036 { 00037 t2Iterator=t1Iterator->next()->elementsIterator(myType); 00038 return subMore(); 00039 } 00040 else return false; 00041 } 00042 else return true; 00043 } 00044 00045 const SMDS_MeshElement * SMDS_IteratorOfElements::subNext() 00046 { 00047 if((t2Iterator.get()==NULL)||(!t2Iterator->more())) 00048 if(t1Iterator->more()) 00049 t2Iterator=t1Iterator->next()->elementsIterator(myType); 00050 return t2Iterator->next(); 00051 } 00052 00057 SMDS_IteratorOfElements::SMDS_IteratorOfElements(const SMDS_MeshElement * element, 00058 SMDSAbs_ElementType type, 00059 const SMDS_ElemIteratorPtr& it) 00060 : t1Iterator(it), 00061 t2Iterator(SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL)), 00062 myType(type), myElement(element), 00063 myProxyElement(NULL) 00064 { 00065 while(subMore()) 00066 alreadyReturnedElements.insert(subNext()); 00067 itAlreadyReturned= alreadyReturnedElements.begin(); 00068 switch(myElement->GetType()) 00069 { 00070 case SMDSAbs_Node: 00071 case SMDSAbs_Edge: myReverseIteration=true; break; 00072 case SMDSAbs_Face: myReverseIteration=(type==SMDSAbs_Volume); break; 00073 default: myReverseIteration=false; 00074 } 00075 } 00076 00077 bool SMDS_IteratorOfElements::more() 00078 { 00079 if(myProxyElement==NULL) 00080 { 00081 while(itAlreadyReturned!=alreadyReturnedElements.end()) 00082 { 00083 myProxyElement=*itAlreadyReturned; 00084 itAlreadyReturned++; 00085 00086 if(myReverseIteration) 00087 { 00088 SMDS_ElemIteratorPtr it= 00089 myProxyElement->elementsIterator(myElement->GetType()); 00090 while(it->more()) 00091 { 00092 if(it->next()==myElement) return true; 00093 } 00094 } 00095 else return true; 00096 } 00097 myProxyElement=NULL; 00098 return false; 00099 } 00100 else return true; 00101 } 00102 00103 const SMDS_MeshElement * SMDS_IteratorOfElements::next() 00104 { 00105 more(); 00106 const SMDS_MeshElement *e=myProxyElement; 00107 myProxyElement=NULL; 00108 return e; 00109 }