LCOV - code coverage report
Current view: top level - core - MeshOpSet.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 28 38 73.7 %
Date: 2020-07-01 15:24:36 Functions: 6 7 85.7 %
Branches: 37 92 40.2 %

           Branch data     Line data    Source code
       1                 :            : #include "MeshOpSet.hpp"
       2                 :            : #include "meshkit/MeshOpProxy.hpp"
       3                 :            : #include "meshkit/Error.hpp"
       4                 :            : #include <string>
       5                 :            : 
       6                 :            : namespace MeshKit {
       7                 :            : 
       8 [ +  - ][ +  + ]:        195 : MeshOpSet::MeshOpSet() {}
           [ #  #  #  # ]
       9                 :            : 
      10                 :       1203 : MeshOpSet& MeshOpSet::instance()
      11                 :            : {
      12 [ +  + ][ +  - ]:       1203 :   static MeshOpSet singleton;
         [ +  - ][ #  # ]
      13                 :       1203 :   return singleton;
      14                 :            : }
      15                 :            : 
      16                 :       1054 : void MeshOpSet::register_mesh_op( MeshOpProxy* proxy )
      17                 :            : {
      18                 :            :     // Check if a MeshOp with the same name is already registered
      19 [ +  - ][ +  - ]:       1054 :   iterator other = mesh_op_no_throw( proxy->name() );
      20 [ +  - ][ -  + ]:       1054 :   if (other != allMeshOps.end()) {
      21 [ #  # ][ #  # ]:          0 :     if (*other == proxy)
      22                 :       1054 :       return;
      23                 :            :     else
      24 [ #  # ][ #  # ]:          0 :       throw Error(MK_MULTIPLE_FOUND,"Conflicting MeshOp name: \"%s\"", proxy->name());
      25                 :            :   }
      26                 :            :   
      27                 :            :     // Try to detect unterminated output entity lists
      28         [ +  - ]:       1054 :   const moab::EntityType* types = proxy->output_types();
      29         [ +  + ]:       3511 :   for (int i = 0; types[i] != moab::MBMAXTYPE; ++i) 
      30         [ -  + ]:       2457 :     if (i >= moab::MBMAXTYPE)
      31 [ #  # ][ #  # ]:          0 :       throw Error(MK_BAD_INPUT,"Unterminated output type list for MeshOp: \"%s\"", proxy->name());
      32                 :            :   
      33                 :            :     // Add to list of all MeshOps
      34         [ +  - ]:       1054 :   allMeshOps.push_back(proxy);
      35                 :            :   
      36                 :            :     // Add to list for each dimension that it can mesh
      37         [ +  + ]:       5270 :   for (int i = 0; i < 4; ++i)
      38 [ +  - ][ +  + ]:       4216 :     if (proxy->can_mesh(static_cast<iBase_EntityType>(i)))
      39         [ +  - ]:        625 :       dimMeshOps[i].push_back(proxy);
      40                 :            : }
      41                 :            : 
      42                 :       1163 : MeshOpSet::iterator MeshOpSet::mesh_op_no_throw( const char* op_name ) const
      43                 :            : {
      44         [ +  - ]:       1163 :   std::string search(op_name);
      45 [ +  - ][ +  - ]:      15804 :   for (iterator i = allMeshOps.begin(); i != allMeshOps.end(); ++i) 
                 [ +  + ]
      46 [ +  - ][ +  - ]:      14750 :     if (search == (*i)->name())
         [ +  - ][ +  + ]
      47                 :        109 :       return i;
      48                 :       1163 :   return allMeshOps.end();
      49                 :            : }
      50                 :            : 
      51                 :        109 : MeshOpProxy* MeshOpSet::mesh_op( const char* op_name ) const
      52                 :            : {
      53         [ +  - ]:        109 :   iterator i = mesh_op_no_throw( op_name );
      54 [ +  - ][ -  + ]:        109 :   if (i == allMeshOps.end())
      55         [ #  # ]:          0 :     throw Error(MK_NOT_FOUND,"Invalid MeshOp name: \"%s\"", op_name);
      56         [ +  - ]:        109 :   return *i;
      57                 :            : }
      58                 :            : 
      59                 :          0 : unsigned MeshOpSet::index( const char* op_name ) const
      60                 :            : {
      61         [ #  # ]:          0 :   iterator i = mesh_op_no_throw( op_name );
      62 [ #  # ][ #  # ]:          0 :   if (i == allMeshOps.end())
      63         [ #  # ]:          0 :     throw Error(MK_NOT_FOUND,"Invalid MeshOp name: \"%s\"", op_name);
      64         [ #  # ]:          0 :   return i - allMeshOps.begin();
      65                 :            : }
      66                 :            : 
      67                 :         27 : MeshOpProxy* MeshOpSet::mesh_op( unsigned index ) const
      68                 :            : {
      69         [ -  + ]:         27 :   if (index >= allMeshOps.size())
      70         [ #  # ]:          0 :     new Error(MK_NOT_FOUND,"Invalid MeshOp index: %u", index);
      71                 :            :     
      72                 :         27 :   return allMeshOps[index];
      73                 :            : }
      74                 :            : 
      75                 :            : } // namespace MeshKit

Generated by: LCOV version 1.11