Back to index

salome-med  6.5.0
InterpKernelGeo2DAbstractEdge.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "InterpKernelGeo2DAbstractEdge.hxx"
00021 #include "InterpKernelGeo2DComposedEdge.hxx"
00022 #include "InterpKernelGeo2DElementaryEdge.hxx"
00023 
00024 using namespace INTERP_KERNEL;
00025 
00026 IteratorOnComposedEdge::IteratorOnComposedEdge():_list_handle(0)
00027 {
00028 }
00029 
00030 IteratorOnComposedEdge::IteratorOnComposedEdge(ComposedEdge *compEdges):_list_handle(compEdges->getListBehind()) 
00031 {
00032   first(); 
00033 }
00034 
00035 void IteratorOnComposedEdge::operator=(const IteratorOnComposedEdge& other)
00036 {
00037   _deep_it=other._deep_it;
00038   _list_handle=other._list_handle;
00039 }
00040 
00041 void IteratorOnComposedEdge::last()
00042 {
00043   _deep_it=_list_handle->end();
00044   _deep_it--;
00045 }
00046 
00047 void IteratorOnComposedEdge::nextLoop()
00048 {
00049   _deep_it++;
00050   if(_deep_it==_list_handle->end())
00051     first();
00052 }
00053 
00054 void IteratorOnComposedEdge::previousLoop()
00055 {
00056   if(_deep_it!=_list_handle->begin())
00057     _deep_it--;
00058   else
00059     last();
00060 }
00061 
00062 bool IteratorOnComposedEdge::goToNextInOn(bool direction, int& i, int nbMax)
00063 {
00064   TypeOfEdgeLocInPolygon loc=current()->getLoc();
00065   if(direction)
00066     {
00067       while(loc==FULL_OUT_1 && i<nbMax)
00068         {
00069           nextLoop(); i++;
00070           loc=current()->getLoc();
00071         }
00072       if(i==nbMax)
00073         return false;
00074       return true;
00075     }
00076   else
00077     {
00078       while(loc==FULL_OUT_1 && i<nbMax)
00079         {
00080           previousLoop(); i++;
00081           loc=current()->getLoc();
00082         }
00083       if(i==nbMax)
00084         return false;
00085       while(loc!=FULL_OUT_1 && i<nbMax)
00086         {
00087           previousLoop(); i++;
00088           loc=current()->getLoc();
00089         }
00090       nextLoop(); i--;
00091       return true;
00092     }
00093 }
00094 
00095 void IteratorOnComposedEdge::assignMySelfToAllElems(ComposedEdge *elems)
00096 {
00097   std::list<ElementaryEdge *> *myList=elems->getListBehind();
00098   for(std::list<ElementaryEdge *>::iterator iter=myList->begin();iter!=myList->end();iter++)
00099     (*iter)->getIterator()=(*this);
00100 }
00101 
00102 void IteratorOnComposedEdge::insertElemEdges(ComposedEdge *elems, bool changeMySelf)
00103 {
00104   std::list<ElementaryEdge *> *myListToInsert=elems->getListBehind();
00105   std::list<ElementaryEdge *>::iterator iter=myListToInsert->begin();
00106   *_deep_it=*iter;
00107   _deep_it++;
00108   iter++;
00109   int sizeOfMyList=myListToInsert->size();
00110   _list_handle->insert(_deep_it,iter,myListToInsert->end());
00111   if(!changeMySelf)
00112     {
00113       for(int i=0;i<sizeOfMyList;i++)
00114         _deep_it--;
00115     }
00116 }
00117