LCOV - code coverage report
Current view: top level - algs - MBGeomOp.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 28 33 84.8 %
Date: 2020-07-01 15:24:36 Functions: 6 7 85.7 %
Branches: 29 92 31.5 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * MBGeomOp.cpp
       3                 :            :  *
       4                 :            :  *  Created on: Sep 30, 2011
       5                 :            :  */
       6                 :            : 
       7                 :            : #include <iostream>
       8                 :            : 
       9                 :            : #include "meshkit/MBGeomOp.hpp"
      10                 :            : #include "meshkit/ModelEnt.hpp"
      11                 :            : 
      12                 :            : #include "moab/Core.hpp"
      13                 :            : #include "moab/GeomTopoTool.hpp"
      14                 :            : 
      15                 :            : namespace MeshKit {
      16                 :            : 
      17                 :            : //Entity Type initialization for geometrization; no mesh output
      18                 :            : moab::EntityType MBGeomOp_tps[] = { moab::MBMAXTYPE }; // no mesh, really
      19                 :         40 : const moab::EntityType* MBGeomOp::output_types()
      20                 :            : {
      21                 :         40 :   return MBGeomOp_tps;
      22                 :            : }
      23                 :            : 
      24                 :          1 : MBGeomOp::MBGeomOp(MKCore *mk_core, const MEntVector &me_vec) :
      25                 :          1 :   MeshScheme(mk_core, me_vec)
      26                 :            : {
      27                 :            :   // TODO Auto-generated constructor stub
      28                 :            : 
      29                 :          1 : }
      30                 :            : 
      31                 :          0 : MBGeomOp::~MBGeomOp()
      32                 :            : {
      33                 :            :   // TODO Auto-generated destructor stub
      34         [ #  # ]:          0 : }
      35                 :            : 
      36                 :            : //set up the geometrization of a model ent (face) for mesh-based geometry
      37                 :          1 : void MBGeomOp::setup_this()
      38                 :            : {
      39                 :            : 
      40                 :          1 : }
      41                 :            : 
      42                 :            : // construct the mesh: nothing to do, there is no mesh, really, only geometry
      43                 :            : // in the form of mesh-based geometry
      44                 :          1 : void MBGeomOp::execute_this()
      45                 :            : {
      46         [ -  + ]:          1 :   if (mentSelection.empty())
      47                 :          0 :       return;
      48         [ +  - ]:          1 :   ModelEnt * me = mentSelection.begin()->first;
      49                 :            :   // get the one and only model entity, which should be of dimension 2, and geometrize it
      50                 :            :   // this should be the model entity handle
      51         [ +  - ]:          1 :   moab::EntityHandle mset = me->mesh_handle();
      52         [ +  - ]:          1 :   iGeom::EntityHandle gent = me->geom_handle();
      53         [ -  + ]:          1 :   if (gent != 0) {
      54         [ #  # ]:          0 :     std::cout << "geometry exists on the model ent, do not geometrize\n";
      55                 :          0 :     return; // we do have something here, do not "geometrize"
      56                 :            :   }
      57 [ +  - ][ +  - ]:          1 :   moab::GeomTopoTool gtt(mk_core()->moab_instance());
                 [ +  - ]
      58                 :            :   moab::EntityHandle output;
      59         [ +  - ]:          1 :   moab::ErrorCode rval = gtt.geometrize_surface_set(mset, output);
      60 [ -  + ][ #  # ]:          1 :   MBERRCHK(rval, mk_core()->moab_instance());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      61                 :            :   // now, get all entity sets in here; the one with dimension 2, put it in mset, and
      62                 :            :   // form other model ents with other sets;
      63         [ +  - ]:          2 :   moab::Range geom_sets;
      64 [ +  - ][ +  - ]:          1 :   moab::Tag geomTag = mk_core()->moab_geom_dim_tag();
      65                 :            : 
      66 [ +  - ][ +  - ]:          1 :   rval = mk_core()->moab_instance()->get_entities_by_type_and_tag(output,
      67         [ +  - ]:          1 :       moab::MBENTITYSET, &geomTag, NULL, 1, geom_sets, moab::Interface::UNION);
      68 [ -  + ][ #  # ]:          1 :   MBERRCHK(rval, mk_core()->moab_instance());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      69                 :            : 
      70         [ +  - ]:          2 :   std::vector<int> dims;
      71 [ +  - ][ +  - ]:          1 :   dims.resize(geom_sets.size());
      72 [ +  - ][ +  - ]:          1 :   rval = mk_core()->moab_instance()->tag_get_data(geomTag, geom_sets, &dims[0]);
         [ +  - ][ +  - ]
      73 [ -  + ][ #  # ]:          1 :   MBERRCHK(rval, mk_core()->moab_instance());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      74                 :            : 
      75                 :            :   // find the one of dimension 2, it is the main one:
      76                 :            :   // the rest should be of dimension 1 or 0, and for each we should have a ModelEnt
      77                 :            :   // we should maybe repeat the process from populate mesh...
      78                 :            :   // maybe we should create new model ents for these new gents; they will be meshable with
      79                 :            :   //  camal, if the geo handles are from FBiGeom
      80                 :            :   // now, create additional model entities, with mesh based geometry
      81                 :            :   // the index of this geometry is returned
      82                 :            : 
      83                 :            :   // now, maybe we should not initialize new geometry
      84                 :            :   // entities at this point are just moab sets
      85                 :            : 
      86                 :            :   // at this moment, we have model entities with geom index indx,
      87                 :            :   //  for the mesh-based geometry
      88 [ +  - ][ +  - ]:          1 :   mentSelection[me].insert(output);
      89                 :            :   // the range (result) will have an rootModelSet appropriate for
      90                 :            :   // a new instantiation of GeomTopoTool
      91                 :          2 :   return;
      92                 :            : 
      93                 :            :   // get dimensions
      94                 :            : }
      95                 :            : 
      96 [ +  - ][ +  - ]:        156 : }

Generated by: LCOV version 1.11