LCOV - code coverage report
Current view: top level - src/mesquite/Mesh - MsqFreeVertexIndexIterator.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 12 14 85.7 %
Date: 2020-07-18 00:09:26 Functions: 4 4 100.0 %
Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2004 Sandia Corporation and Argonne National
       5                 :            :     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
       6                 :            :     with Sandia Corporation, the U.S. Government retains certain
       7                 :            :     rights in this software.
       8                 :            : 
       9                 :            :     This library is free software; you can redistribute it and/or
      10                 :            :     modify it under the terms of the GNU Lesser General Public
      11                 :            :     License as published by the Free Software Foundation; either
      12                 :            :     version 2.1 of the License, or (at your option) any later version.
      13                 :            : 
      14                 :            :     This library is distributed in the hope that it will be useful,
      15                 :            :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :            :     Lesser General Public License for more details.
      18                 :            : 
      19                 :            :     You should have received a copy of the GNU Lesser General Public License
      20                 :            :     (lgpl.txt) along with this library; if not, write to the Free Software
      21                 :            :     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      22                 :            : 
      23                 :            :     [email protected], [email protected], [email protected],
      24                 :            :     [email protected], [email protected], [email protected]
      25                 :            : 
      26                 :            :   ***************************************************************** */
      27                 :            : /*!
      28                 :            :   \file   MsqFreeVertexIndexIterator.hpp
      29                 :            :   \brief    This file contains the MsqFreeVertexIndexIterator class
      30                 :            : 
      31                 :            :   \author Thomas Leurent
      32                 :            :   \date   2002-01-17
      33                 :            : */
      34                 :            : 
      35                 :            : #ifndef MsqFreeVertexIndexIterator_hpp
      36                 :            : #define MsqFreeVertexIndexIterator_hpp
      37                 :            : 
      38                 :            : #include <cstddef>
      39                 :            : #include <cstdlib>
      40                 :            : 
      41                 :            : #include "Mesquite.hpp"
      42                 :            : #include "MsqVertex.hpp"
      43                 :            : #include "PatchData.hpp"
      44                 :            : #include "MsqVertex.hpp"
      45                 :            : 
      46                 :            : namespace MBMesquite
      47                 :            : {
      48                 :            : class MsqError;
      49                 :            : 
      50                 :            : /*! \class MsqFreeVertexIndexIterator
      51                 :            :   \brief iterates over indexes of free vetices in a PatchData.
      52                 :            : 
      53                 :            :   A free vertex is defined as not having the MSQ_CULLED and MSQ_HARD_FIXED
      54                 :            :   flags activated.
      55                 :            : 
      56                 :            :   Use the iterator as follow:
      57                 :            :   MsqFreeVertexIndexIterator ind(&patch_data,err);
      58                 :            :   ind.reset();
      59                 :            :   while (ind.next()) {
      60                 :            :     cout << ind.value();
      61                 :            :   }  .*/
      62                 :            : class MsqFreeVertexIndexIterator
      63                 :            : {
      64                 :            :   public:
      65                 :       1322 :     MsqFreeVertexIndexIterator( const PatchData& p_pd, MsqError& )
      66                 :       1322 :         : iterOriginator( p_pd ), iterCurrentIndex( (size_t)-1 )
      67                 :            :     {
      68                 :       1322 :     }
      69                 :            :     //! Resets the iterator.
      70                 :            :     //! The next call to next() will set the iterator on the first free vertex.
      71                 :       1322 :     void reset()
      72                 :            :     {
      73                 :       1322 :         iterCurrentIndex = (size_t)-1;
      74                 :       1322 :     }
      75                 :            :     //! Increments the iterator. returns false if there is no more free vertex.
      76                 :            :     inline bool next();
      77                 :            :     //! Returns an index corresponding to a free vertex.
      78                 :       1322 :     std::size_t value()
      79                 :            :     {
      80                 :       1322 :         return iterCurrentIndex;
      81                 :            :     }
      82                 :            : 
      83                 :            :   private:
      84                 :            :     const PatchData& iterOriginator;
      85                 :            :     std::size_t iterCurrentIndex;
      86                 :            : };
      87                 :            : 
      88                 :            : /** \brief Advance iterator
      89                 :            :  *
      90                 :            :  * Advance iterator to next free vertex
      91                 :            :  *\return false if at end, true otherwise
      92                 :            :  */
      93                 :       1322 : inline bool MsqFreeVertexIndexIterator::next()
      94                 :            : {
      95                 :       1322 :     ++iterCurrentIndex;
      96         [ +  - ]:       1322 :     while( iterCurrentIndex < iterOriginator.num_free_vertices() )
      97                 :            :     {
      98         [ +  - ]:       1322 :         if( !iterOriginator.vertex_by_index( iterCurrentIndex ).is_flag_set( MsqVertex::MSQ_CULLED ) ) return true;
      99                 :          0 :         ++iterCurrentIndex;
     100                 :            :     }
     101                 :          0 :     return false;
     102                 :            : }
     103                 :            : 
     104                 :            : }  // namespace MBMesquite
     105                 :            : 
     106                 :            : #endif  //  MsqFreeVertexIndexIterator_hpp

Generated by: LCOV version 1.11