MeshKit  1.0
MBGeomOp.cpp
Go to the documentation of this file.
00001 /*
00002  * MBGeomOp.cpp
00003  *
00004  *  Created on: Sep 30, 2011
00005  */
00006 
00007 #include <iostream>
00008 
00009 #include "meshkit/MBGeomOp.hpp"
00010 #include "meshkit/ModelEnt.hpp"
00011 
00012 #include "moab/Core.hpp"
00013 #include "moab/GeomTopoTool.hpp"
00014 
00015 namespace MeshKit {
00016 
00017 //Entity Type initialization for geometrization; no mesh output
00018 moab::EntityType MBGeomOp_tps[] = { moab::MBMAXTYPE }; // no mesh, really
00019 const moab::EntityType* MBGeomOp::output_types()
00020 {
00021   return MBGeomOp_tps;
00022 }
00023 
00024 MBGeomOp::MBGeomOp(MKCore *mk_core, const MEntVector &me_vec) :
00025   MeshScheme(mk_core, me_vec)
00026 {
00027   // TODO Auto-generated constructor stub
00028 
00029 }
00030 
00031 MBGeomOp::~MBGeomOp()
00032 {
00033   // TODO Auto-generated destructor stub
00034 }
00035 
00036 //set up the geometrization of a model ent (face) for mesh-based geometry
00037 void MBGeomOp::setup_this()
00038 {
00039 
00040 }
00041 
00042 // construct the mesh: nothing to do, there is no mesh, really, only geometry
00043 // in the form of mesh-based geometry
00044 void MBGeomOp::execute_this()
00045 {
00046   if (mentSelection.empty())
00047       return;
00048   ModelEnt * me = mentSelection.begin()->first;
00049   // get the one and only model entity, which should be of dimension 2, and geometrize it
00050   // this should be the model entity handle
00051   moab::EntityHandle mset = me->mesh_handle();
00052   iGeom::EntityHandle gent = me->geom_handle();
00053   if (gent != 0) {
00054     std::cout << "geometry exists on the model ent, do not geometrize\n";
00055     return; // we do have something here, do not "geometrize"
00056   }
00057   moab::GeomTopoTool gtt(mk_core()->moab_instance());
00058   moab::EntityHandle output;
00059   moab::ErrorCode rval = gtt.geometrize_surface_set(mset, output);
00060   MBERRCHK(rval, mk_core()->moab_instance());
00061   // now, get all entity sets in here; the one with dimension 2, put it in mset, and
00062   // form other model ents with other sets;
00063   moab::Range geom_sets;
00064   moab::Tag geomTag = mk_core()->moab_geom_dim_tag();
00065 
00066   rval = mk_core()->moab_instance()->get_entities_by_type_and_tag(output,
00067       moab::MBENTITYSET, &geomTag, NULL, 1, geom_sets, moab::Interface::UNION);
00068   MBERRCHK(rval, mk_core()->moab_instance());
00069 
00070   std::vector<int> dims;
00071   dims.resize(geom_sets.size());
00072   rval = mk_core()->moab_instance()->tag_get_data(geomTag, geom_sets, &dims[0]);
00073   MBERRCHK(rval, mk_core()->moab_instance());
00074 
00075   // find the one of dimension 2, it is the main one:
00076   // the rest should be of dimension 1 or 0, and for each we should have a ModelEnt
00077   // we should maybe repeat the process from populate mesh...
00078   // maybe we should create new model ents for these new gents; they will be meshable with
00079   //  camal, if the geo handles are from FBiGeom
00080   // now, create additional model entities, with mesh based geometry
00081   // the index of this geometry is returned
00082 
00083   // now, maybe we should not initialize new geometry
00084   // entities at this point are just moab sets
00085 
00086   // at this moment, we have model entities with geom index indx,
00087   //  for the mesh-based geometry
00088   mentSelection[me].insert(output);
00089   // the range (result) will have an rootModelSet appropriate for
00090   // a new instantiation of GeomTopoTool
00091   return;
00092 
00093   // get dimensions
00094 }
00095 
00096 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines