LCOV - code coverage report
Current view: top level - src/mesquite/QualityImprover - PatchSetUser.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 13 14 92.9 %
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 2006 Lawrence Livermore National Laboratory.  Under
       5                 :            :     the terms of Contract B545069 with the University of Wisconsin --
       6                 :            :     Madison, Lawrence Livermore National Laboratory 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                 :            :     (2006) [email protected]
      24                 :            : 
      25                 :            :   ***************************************************************** */
      26                 :            : 
      27                 :            : #ifndef MSQ_PATCH_SET_USER_HPP
      28                 :            : #define MSQ_PATCH_SET_USER_HPP
      29                 :            : 
      30                 :            : #include "Mesquite.hpp"
      31                 :            : #include "VertexPatches.hpp"
      32                 :            : #include "GlobalPatch.hpp"
      33                 :            : 
      34                 :            : namespace MBMesquite
      35                 :            : {
      36                 :            : 
      37                 :            : /**\brief Utility class for handling variable patch types
      38                 :            :  *
      39                 :            :  * Common implementation for classes supporting variable patch types.
      40                 :            :  */
      41                 :            : class PatchSetUser
      42                 :            : {
      43                 :            :   public:
      44         [ +  - ]:        308 :     PatchSetUser( bool defaultGlobal ) : myVertexPatches( 1, true )
      45                 :            :     {
      46         [ +  - ]:        154 :         if( defaultGlobal )
      47                 :        154 :             activePatchSet = &myGlobalPatch;
      48                 :            :         else
      49                 :          0 :             activePatchSet = &myVertexPatches;
      50                 :        154 :     }
      51                 :            : 
      52                 :            :     PatchSetUser( PatchSet* my_patch_set ) : myVertexPatches( 1, true ), activePatchSet( my_patch_set ) {}
      53                 :            : 
      54                 :            :     virtual ~PatchSetUser();
      55                 :            : 
      56                 :            :     /**\brief Use a single patch representing the entire mesh */
      57                 :        112 :     void use_global_patch()
      58                 :            :     {
      59                 :        112 :         activePatchSet = &myGlobalPatch;
      60                 :        112 :     }
      61                 :            : 
      62                 :            :     /**\brief Using a single patch representing the entire mesh */
      63                 :            :     bool using_global_patch() const
      64                 :            :     {
      65                 :            :         return activePatchSet == &myGlobalPatch;
      66                 :            :     }
      67                 :            : 
      68                 :            :     /**\brief Construct a patch for each free vertex in the mesh
      69                 :            :      *\param num_layers Number of layers of adjacent elements to
      70                 :            :      *                  include in the patch.  If unsure, use 1.
      71                 :            :      */
      72                 :         30 :     void use_element_on_vertex_patch( unsigned num_layers = 1 )
      73                 :            :     {
      74                 :         30 :         activePatchSet = &myVertexPatches;
      75                 :         30 :         myVertexPatches.set_num_layers( num_layers );
      76                 :         30 :     }
      77                 :            : 
      78                 :            :     /**\brief True if a patch will be constructed for each free vertex */
      79                 :            :     bool using_element_on_vertex_patch() const
      80                 :            :     {
      81                 :            :         return activePatchSet == &myVertexPatches;
      82                 :            :     }
      83                 :            : 
      84                 :            :     /**\brief Get the number of layers of elements that will be included
      85                 :            :      *        in an element-on-vertex patch
      86                 :            :      */
      87                 :            :     unsigned num_element_on_vertex_layers() const
      88                 :            :     {
      89                 :            :         return myVertexPatches.get_num_layers();
      90                 :            :     }
      91                 :            : 
      92                 :        122 :     virtual PatchSet* get_patch_set()
      93                 :            :     {
      94                 :        122 :         return activePatchSet;
      95                 :            :     }
      96                 :            : 
      97                 :            :     void use_patch_set( PatchSet* patch_set )
      98                 :            :     {
      99                 :            :         activePatchSet = patch_set;
     100                 :            :     }
     101                 :            : 
     102                 :            :   private:
     103                 :            :     VertexPatches myVertexPatches;
     104                 :            :     GlobalPatch myGlobalPatch;
     105                 :            :     PatchSet* activePatchSet;
     106                 :            : };
     107                 :            : 
     108                 :            : }  // namespace MBMesquite
     109                 :            : 
     110                 :            : #endif

Generated by: LCOV version 1.11