moab
GeomTopoTool.hpp
Go to the documentation of this file.
00001 
00018 #ifndef MOAB_GEOM_TOPO_TOOL_HPP
00019 #define MOAB_GEOM_TOPO_TOOL_HPP
00020 
00021 #include "moab/Forward.hpp"
00022 #include "moab/Range.hpp"
00023 #include "moab/OrientedBoxTreeTool.hpp"
00024 
00025 #include <map>
00026 
00027 namespace moab {
00028 
00034 class GeomTopoTool
00035 {
00036 public:
00037   GeomTopoTool(Interface *impl, bool find_geoments = false, EntityHandle modelRootSet = 0);
00038   ~GeomTopoTool() {}
00039   
00041   ErrorCode restore_topology();
00042 
00047    ErrorCode set_sense( EntityHandle entity,
00048                         EntityHandle wrt_entity,
00049                         int sense);
00050 
00053    ErrorCode get_sense( EntityHandle entity,
00054                         EntityHandle wrt_entity,
00055                         int & sense );
00056 
00057   ErrorCode get_senses (EntityHandle entity,
00058     std::vector<EntityHandle> &wrt_entities,
00059     std::vector<int> &senses);
00060 
00061   ErrorCode set_senses (EntityHandle entity,
00062                           std::vector<EntityHandle> &wrt_entities,
00063                           std::vector<int> &senses);
00064 
00076   ErrorCode other_entity(EntityHandle bounded, EntityHandle not_this, EntityHandle across,
00077                          EntityHandle &other);
00078 
00081   int dimension(EntityHandle this_set);
00082   
00083   // used mostly for debugging purposes
00084   int global_id(EntityHandle this_set);
00085   
00086   ErrorCode find_geomsets(Range *ranges = NULL);
00087 
00088   ErrorCode construct_obb_trees(bool make_one_vol = false);
00089 
00090   ErrorCode get_root(EntityHandle vol_or_surf, EntityHandle &root);
00091 
00092   EntityHandle get_one_vol_root();
00093 
00094   OrientedBoxTreeTool *obb_tree() {return &obbTree;}
00095 
00096   // this could make the obb tree out of date
00097   ErrorCode add_geo_set(EntityHandle set, int dimension, int global_id  = 0);
00098 
00099   // will assume no geo sets are defined for this surface
00100   // will output a mesh_set that contains everything (all sets of interest), for proper output
00101   ErrorCode geometrize_surface_set(EntityHandle surface, EntityHandle & output);
00102 
00103   // this would be a deep copy, into a new geom topo tool
00104   // sets will be duplicated, but entities not
00105   // modelSet will be a new one;
00106   // will take as input a pointer to a std::vector of gents (surfaces and volumes, usually),
00107   // which will serve to filter the gents from modelSet (only dependents will be part of the new gtt)
00108   // if the pointer is null, all gsets in the original modelSet are duplicated
00109 
00110   ErrorCode duplicate_model(GeomTopoTool *& duplicate, std::vector<EntityHandle> * pvGEnts = NULL);
00111 
00112   EntityHandle get_root_model_set() { return modelSet; }
00113 
00114   bool check_model();
00115   // should be used instead of keeping multiple ranges, for example in FBEngine
00116   const Range * geoRanges() { return geomRanges ; }
00117 private:
00118   Interface *mdbImpl;
00119   Tag sense2Tag;
00120   Tag senseNEntsTag, senseNSensesTag;
00121   Tag geomTag;
00122   Tag gidTag;
00123   // the model set encompasses a full topological model
00124   EntityHandle modelSet;
00125   Range geomRanges[5];// add one more dimension, for set of gentities; by default, they will
00126                       // have geom_dimension 4
00127   int maxGlobalId[5]; // one max global id for each dimension
00128   bool updated;
00129 
00130   OrientedBoxTreeTool obbTree;
00131   EntityHandle setOffset;
00132   std::vector<EntityHandle> rootSets;
00133 
00134   bool contiguous;
00135   std::map<EntityHandle, EntityHandle>  mapRootSets;
00136   EntityHandle oneVolRootSet;
00137 
00139   ErrorCode construct_vertex_ranges(const Range &geom_sets,
00140                       const Tag verts_tag);
00141   
00143   ErrorCode separate_by_dimension(const Range &geom_sets);
00144 
00145   // verify sense face tag
00146   ErrorCode check_face_sense_tag(bool create);
00147 
00148   // verify sense edge tags
00149   ErrorCode check_edge_sense_tags(bool create);
00150 
00151 };
00152 
00153 // get the root of the obbtree for a given entity
00154 inline ErrorCode GeomTopoTool::get_root(EntityHandle vol_or_surf, EntityHandle &root) 
00155 {
00156    if(contiguous)
00157    {
00158      unsigned int index = vol_or_surf - setOffset;
00159      root = (index < rootSets.size() ? rootSets[index] : 0);
00160    }
00161    else
00162       root = mapRootSets[vol_or_surf];
00163    return (root ? MB_SUCCESS : MB_INDEX_OUT_OF_RANGE);
00164 }
00165 
00166 inline EntityHandle GeomTopoTool::get_one_vol_root()
00167 {
00168   return oneVolRootSet;
00169 }
00170 
00171 }
00172  // namespace moab 
00173 
00174 #endif
00175 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines