LCOV - code coverage report
Current view: top level - src/mesquite/Mesh - VertexPatches.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 25 39 64.1 %
Date: 2020-07-18 00:09:26 Functions: 5 5 100.0 %
Branches: 39 92 42.4 %

           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_VERTEX_PATCHES_CPP
      28                 :            : #define MSQ_VERTEX_PATCHES_CPP
      29                 :            : 
      30                 :            : /** \file VertexPatches.cpp
      31                 :            :  *  \brief
      32                 :            :  *  \author Jason Kraftcheck
      33                 :            :  */
      34                 :            : 
      35                 :            : #include "VertexPatches.hpp"
      36                 :            : #include "MsqError.hpp"
      37                 :            : #include "MeshInterface.hpp"
      38                 :            : #include "MsqVertex.hpp"
      39                 :            : 
      40                 :            : #include <algorithm>
      41                 :            : 
      42                 :            : namespace MBMesquite
      43                 :            : {
      44                 :            : 
      45         [ -  + ]:        554 : VertexPatches::~VertexPatches() {}
      46                 :            : 
      47                 :         51 : void VertexPatches::get_patch_handles( std::vector< PatchHandle >& patch_handles_out, MsqError& err )
      48                 :            : {
      49                 :            :     // get all vertex handles
      50 [ -  + ][ #  # ]:         51 :     get_mesh()->get_all_vertices( patch_handles_out, err );MSQ_ERRRTN( err );
                 [ -  + ]
      51         [ -  + ]:         51 :     if( patch_handles_out.empty() ) return;
      52                 :            : 
      53         [ +  + ]:         51 :     if( free_vertices_only() )
      54                 :            :     {
      55                 :            :         // get fixed flags for vertices
      56         [ +  - ]:         37 :         std::vector< unsigned char > flags( patch_handles_out.size() );
      57 [ +  - ][ +  - ]:         37 :         get_mesh()->vertices_get_byte( arrptr( patch_handles_out ), arrptr( flags ), patch_handles_out.size(), err );MSQ_ERRRTN( err );
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ #  # ][ #  # ]
                 [ -  + ]
      58                 :            : 
      59                 :            :         // remove fixed  and slaved vertices from list
      60                 :         37 :         size_t write = 0;
      61         [ +  + ]:      25335 :         for( size_t read = 0; read < patch_handles_out.size(); ++read )
      62 [ +  - ][ +  + ]:      25298 :             if( !( flags[read] & ( MsqVertex::MSQ_HARD_FIXED | MsqVertex::MSQ_DEPENDENT ) ) )
      63 [ +  - ][ +  - ]:      20360 :                 patch_handles_out[write++] = patch_handles_out[read];
      64 [ +  - ][ +  - ]:         51 :         patch_handles_out.resize( write );
      65                 :            :     }
      66                 :            : }
      67                 :            : 
      68                 :     928195 : void VertexPatches::get_patch( PatchHandle patch_handle, std::vector< Mesh::ElementHandle >& elem_handles_out,
      69                 :            :                                std::vector< Mesh::VertexHandle >& free_vertices_out, MsqError& err )
      70                 :            : {
      71                 :     928195 :     free_vertices_out.clear();
      72                 :     928195 :     elem_handles_out.clear();
      73                 :            : 
      74         [ +  + ]:     928195 :     if( free_vertices_only() )
      75                 :            :     {  // check if vertex is culled
      76                 :            :         unsigned char byte;
      77 [ +  - ][ +  - ]:     890499 :         get_mesh()->vertices_get_byte( &patch_handle, &byte, 1, err );
      78 [ +  - ][ -  + ]:     890499 :         if( MSQ_CHKERR( err ) || ( byte & MsqVertex::MSQ_CULLED ) ) return;
         [ #  # ][ #  # ]
         [ +  + ][ +  + ]
      79                 :            :     }
      80                 :            : 
      81                 :     867485 :     free_vertices_out.push_back( patch_handle );
      82         [ -  + ]:     867485 :     if( !numLayers )  // if no layers of elements, then done.
      83                 :          0 :         return;
      84                 :            : 
      85                 :            :     // get elements adjacent to free vertex
      86                 :     867485 :     get_mesh()->vertices_get_attached_elements( &patch_handle, 1, elem_handles_out, junk, err );
      87 [ -  + ][ #  # ]:     867485 :     if( MSQ_CHKERR( err ) ) return;
                 [ -  + ]
      88                 :            : 
      89                 :     867485 :     unsigned remaining = numLayers;
      90         [ -  + ]:     928195 :     while( --remaining )
      91                 :            :     {  // loop if more than one layer of elements
      92         [ #  # ]:          0 :         if( elem_handles_out.empty() ) break;
      93                 :            : 
      94                 :            :         // Get vertices adjacent to elements
      95                 :          0 :         free_vertices_out.clear();
      96                 :          0 :         get_mesh()->elements_get_attached_vertices( arrptr( elem_handles_out ), elem_handles_out.size(),
      97                 :          0 :                                                     free_vertices_out, junk, err );
      98 [ #  # ][ #  # ]:          0 :         if( MSQ_CHKERR( err ) ) break;
                 [ #  # ]
      99                 :            : 
     100                 :            :         // remove duplicates from vertex list
     101                 :          0 :         std::sort( free_vertices_out.begin(), free_vertices_out.end() );
     102                 :            :         free_vertices_out.erase( std::unique( free_vertices_out.begin(), free_vertices_out.end() ),
     103                 :          0 :                                  free_vertices_out.end() );
     104                 :            : 
     105                 :            :         // Get elements adjacent to vertices
     106                 :          0 :         elem_handles_out.clear();
     107                 :          0 :         get_mesh()->vertices_get_attached_elements( arrptr( free_vertices_out ), free_vertices_out.size(),
     108                 :          0 :                                                     elem_handles_out, junk, err );
     109 [ #  # ][ #  # ]:          0 :         if( MSQ_CHKERR( err ) ) break;
                 [ #  # ]
     110                 :            : 
     111                 :            :         // Remove duplicates from element list
     112                 :          0 :         std::sort( elem_handles_out.begin(), elem_handles_out.end() );
     113                 :            :         elem_handles_out.erase( std::unique( elem_handles_out.begin(), elem_handles_out.end() ),
     114                 :          0 :                                 elem_handles_out.end() );
     115                 :            :     }
     116                 :            : }
     117                 :            : 
     118 [ +  - ][ +  - ]:        120 : }  // namespace MBMesquite
     119                 :            : 
     120                 :            : #endif

Generated by: LCOV version 1.11