LCOV - code coverage report
Current view: top level - src/mesquite/Misc - VtkTypeInfo.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 13 23 56.5 %
Date: 2020-07-18 00:09:26 Functions: 3 3 100.0 %
Branches: 6 32 18.8 %

           Branch data     Line data    Source code
       1                 :            : /* *****************************************************************
       2                 :            :     MESQUITE -- The Mesh Quality Improvement Toolkit
       3                 :            : 
       4                 :            :     Copyright 2005 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                 :            :     [email protected]
      24                 :            : 
      25                 :            :   ***************************************************************** */
      26                 :            : 
      27                 :            : #include "VtkTypeInfo.hpp"
      28                 :            : #include "MsqError.hpp"
      29                 :            : #include <assert.h>
      30                 :            : 
      31                 :            : namespace MBMesquite
      32                 :            : {
      33                 :            : 
      34                 :            : const unsigned vtk_pixel_order[] = { 0, 1, 3, 2 };
      35                 :            : 
      36                 :            : const unsigned vtk_voxel_order[] = { 0, 1, 3, 2, 4, 5, 7, 6 };
      37                 :            : 
      38                 :            : const unsigned vtk_wedge_order[] = { 0,  2,  1,     // bottom corners
      39                 :            :                                      3,  5,  4,     // top corners
      40                 :            :                                      8,  7,  6,     // bottom edges
      41                 :            :                                      12, 14, 13,    // lateral edges
      42                 :            :                                      11, 10, 9,     // top edges
      43                 :            :                                      17, 16, 15 };  // quadrilateral faces
      44                 :            : 
      45                 :            : const unsigned vtk_hex_order[] = { 0,  1,  2,  3,                   // corners (same)
      46                 :            :                                    4,  5,  6,  7,  8,  9,  10, 11,  // mid-edge (top before lateral)
      47                 :            :                                    16, 17, 18, 19, 12, 13, 14, 15,
      48                 :            :                                    22, 21, 23, 20,  // mid-face (mixed up) & mid-region (same)
      49                 :            :                                    24, 25, 26 };
      50                 :            : 
      51                 :            : static const VtkTypeInfo typeInfoList[] = { { 0, 0, MIXED, 0, 0 },
      52                 :            :                                             { "vertex", 1, MIXED, 1, 0 },
      53                 :            :                                             { "polyvertex", 2, MIXED, 0, 0 },
      54                 :            :                                             { "line", 3, MIXED, 2, 0 },
      55                 :            :                                             { "polyline", 4, MIXED, 0, 0 },
      56                 :            :                                             { "triangle", 5, TRIANGLE, 3, 0 },
      57                 :            :                                             { "triangle strip", 6, MIXED, 0, 0 },
      58                 :            :                                             { "polygon", 7, POLYGON, 0, 0 },
      59                 :            :                                             { "pixel", 8, QUADRILATERAL, 4, vtk_pixel_order },
      60                 :            :                                             { "quadrilateral", 9, QUADRILATERAL, 4, 0 },
      61                 :            :                                             { "tetrahedron", 10, TETRAHEDRON, 4, 0 },
      62                 :            :                                             { "voxel", 11, HEXAHEDRON, 8, vtk_voxel_order },
      63                 :            :                                             { "hexahedron", 12, HEXAHEDRON, 8, 0 },
      64                 :            :                                             { "wedge", 13, PRISM, 6, vtk_wedge_order },
      65                 :            :                                             { "pyramid", 14, PYRAMID, 5, 0 },
      66                 :            :                                             { "pentagonal prism", 15, MIXED, 10, 0 },  // not supported
      67                 :            :                                             { "hexagonal prism", 16, MIXED, 12, 0 },   // not supported
      68                 :            :                                             { "invalid (17)", 17, MIXED, 0, 0 },
      69                 :            :                                             { "invalid (18)", 18, MIXED, 0, 0 },
      70                 :            :                                             { "invalid (19)", 19, MIXED, 0, 0 },
      71                 :            :                                             { "invalid (20)", 20, MIXED, 0, 0 },
      72                 :            :                                             { "quadratic edge", 21, MIXED, 3, 0 },
      73                 :            :                                             { "quadratic tri", 22, TRIANGLE, 6, 0 },
      74                 :            :                                             { "quadratic quad", 23, QUADRILATERAL, 8, 0 },
      75                 :            :                                             { "quadratic tet", 24, TETRAHEDRON, 10, 0 },
      76                 :            :                                             { "quadratic hex", 25, HEXAHEDRON, 20, vtk_hex_order },
      77                 :            :                                             { "quadratic wedge", 26, PRISM, 15, vtk_wedge_order },
      78                 :            :                                             { "quadratic pyramid", 27, PYRAMID, 13, 0 },
      79                 :            :                                             { "bi-quadratic quad", 28, QUADRILATERAL, 9, 0 },
      80                 :            :                                             { "tri-quadratic hex", 29, HEXAHEDRON, 27, vtk_hex_order },
      81                 :            :                                             { "quadratic-linear quad", 30, MIXED, 6, 0 },  // not supported
      82                 :            :                                             { "quadratic-linear wedge", 31, MIXED, 12,
      83                 :            :                                               vtk_wedge_order },                                       // not supported
      84                 :            :                                             { "bi-quadratic wedge", 32, MIXED, 18, vtk_wedge_order },  // not supported
      85                 :            :                                             { "bi-quadratic hex", 33, MIXED, 24, vtk_hex_order },      // not supported
      86                 :            :                                             { 0, 34, MIXED, 0, 0 } };
      87                 :            : 
      88                 :            : const unsigned typeInfoListLen = sizeof( typeInfoList ) / sizeof( typeInfoList[0] );
      89                 :            : 
      90                 :            : const unsigned reverseIndexList[][3] = { { 0, 0, 0 },     // 0
      91                 :            :                                          { 0, 0, 0 },     // 1
      92                 :            :                                          { 0, 0, 0 },     // 2
      93                 :            :                                          { 0, 0, 0 },     // 3
      94                 :            :                                          { 0, 0, 0 },     // 4
      95                 :            :                                          { 0, 0, 0 },     // 5
      96                 :            :                                          { 0, 0, 0 },     // 6
      97                 :            :                                          { 7, 0, 0 },     // POLYGON
      98                 :            :                                          { 5, 22, 0 },    // TRIANGLE
      99                 :            :                                          { 9, 23, 28 },   // QUADRILATERAL
     100                 :            :                                          { 0, 0, 0 },     // POLYHEDRON
     101                 :            :                                          { 10, 24, 0 },   // TETRAHEDRON
     102                 :            :                                          { 12, 25, 29 },  // HEXAHEDRON
     103                 :            :                                          { 13, 26, 0 },   // PRISM
     104                 :            :                                          { 14, 27, 0 },   // PYRAMID
     105                 :            :                                          { 0, 0, 0 },     // SEPTAHEDRON
     106                 :            :                                          { 0, 0, 0 } };
     107                 :            : 
     108                 :     116306 : const VtkTypeInfo* VtkTypeInfo::find_type( unsigned vtk_type, MsqError& err )
     109                 :            : {
     110         [ -  + ]:     116306 :     if( vtk_type >= typeInfoListLen )
     111                 :            :     {
     112         [ #  # ]:          0 :         MSQ_SETERR( err )( "Type out of bounds", MsqError::INVALID_ARG );
     113                 :          0 :         return 0;
     114                 :            :     }
     115                 :            : 
     116                 :     116306 :     return &typeInfoList[vtk_type];
     117                 :            : }
     118                 :            : 
     119                 :     103860 : const VtkTypeInfo* VtkTypeInfo::find_type( EntityTopology msq_type, unsigned num_nodes, MsqError& err )
     120                 :            : {
     121         [ +  + ]:     103860 :     if( typeInfoList[reverseIndexList[msq_type][0]].numNodes == num_nodes )
     122                 :     103852 :         return &typeInfoList[reverseIndexList[msq_type][0]];
     123         [ +  - ]:          8 :     else if( typeInfoList[reverseIndexList[msq_type][1]].numNodes == num_nodes )
     124                 :          8 :         return &typeInfoList[reverseIndexList[msq_type][1]];
     125         [ #  # ]:          0 :     else if( typeInfoList[reverseIndexList[msq_type][2]].numNodes == num_nodes )
     126                 :          0 :         return &typeInfoList[reverseIndexList[msq_type][2]];
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :     if( msq_type == POLYGON && num_nodes >= 3 && num_nodes <= 12 ) return &typeInfoList[reverseIndexList[msq_type][0]];
                 [ #  # ]
     129                 :            : 
     130                 :            :     MSQ_SETERR( err )
     131                 :            :     ( MsqError::UNSUPPORTED_ELEMENT, "VTK file does not support element type %d with %u nodes", (int)msq_type,
     132         [ #  # ]:          0 :       num_nodes );
     133                 :     103860 :     return 0;
     134                 :            : }
     135                 :            : 
     136                 :      51930 : void VtkTypeInfo::mesquiteToVtkOrder( std::vector< size_t >& conn_list ) const
     137                 :            : {
     138         [ -  + ]:      51930 :     assert( conn_list.size() == numNodes );
     139         [ -  + ]:      51930 :     if( vtkConnOrder )
     140                 :            :     {
     141         [ #  # ]:          0 :         std::vector< size_t > temp_list( numNodes );
     142         [ #  # ]:          0 :         std::swap( temp_list, conn_list );
     143         [ #  # ]:          0 :         for( size_t i = 0; i < numNodes; ++i )
     144 [ #  # ][ #  # ]:          0 :             conn_list[vtkConnOrder[i]] = temp_list[i];
     145                 :            :     }
     146                 :      51930 : }
     147                 :            : 
     148                 :            : }  // namespace MBMesquite

Generated by: LCOV version 1.11