MeshKit  1.0
ModelEnt.hpp
Go to the documentation of this file.
00001 #ifndef MESHKIT_MODELENT_HPP
00002 #define MESHKIT_MODELENT_HPP
00003 
00004 #include "meshkit/iGeom.hpp"
00005 #include "meshkit/Types.hpp"
00006 #include "moab/Interface.hpp"
00007 #include <cassert>
00008 #include <vector>
00009 #include <set>
00010 #include <map>
00011 
00012 namespace MeshKit {
00013 
00014 class ModelEnt;
00015 class MKCore;
00016 class IAVariable;
00017 
00030 class ModelEnt
00031 {
00032 public:
00033 
00046   ModelEnt(MKCore *mk,
00047            iGeom::EntityHandle geom_ent,
00048            int geom_index,
00049            moab::EntityHandle mesh_ent = 0,
00050            int mesh_index = -1,
00051            int irel_index = -1,
00052            int sizing_index = -1);
00053 
00062   ModelEnt(MKCore *mk,
00063            iGeom::EntitySetHandle geom_set,
00064            int geom_index,
00065            moab::EntityHandle mesh_ent = 0,
00066            int mesh_index = -1,
00067            int irel_index = -1,
00068            int sizing_index = -1,
00069            IAVariable *ia_var = NULL);
00070 
00073   virtual ~ModelEnt();
00074 
00086   void children(std::vector<MEntVector> &child_ents) const;
00087 
00093   void children(std::vector<MEntVector> &child_ents);
00094 
00100   void children(std::vector<std::vector<moab::EntityHandle> > &child_ents) const;
00101 
00107   void children(std::vector<std::vector<iGeom::EntityHandle> > &child_ents) const;
00108 
00115   void get_adjacencies(int dim, MEntVector &adjs) const;
00116 
00123   void get_adjacencies(int dim, std::vector<iGeom::EntityHandle> &adjs) const;
00124 
00131   void get_adjacencies(int dim, std::vector<moab::EntityHandle> &adjs) const;
00132 
00139   void get_adjacencies(int dim, moab::Range &adjs) const;
00140 
00149   ModelEnt *shared_entity(ModelEnt *ent2, int to_dim);
00150   
00158   void get_adjs_bool(MEntVector &from_ents,
00159                      int to_dim,
00160                      MEntVector &to_ents,
00161                      BooleanType op_type,
00162                      bool only_to_ents = true);
00169 
00170   int dimension() const;
00171   
00173   double measure() const;
00174   
00176   double measure_discrete() const;
00177   
00192   void evaluate(double x, double y, double z, 
00193                 double *close = NULL,
00194                 double *direction = NULL,
00195                 double *curvature1 = NULL,
00196                 double *curvature2 = NULL) const;
00197   
00212   void evaluate_discrete(double x, double y, double z, 
00213                          double *close = NULL,
00214                          double *direction = NULL,
00215                          double *curvature1 = NULL,
00216                          double *curvature2 = NULL) const;
00217   
00219   int id() const;
00220   
00238   void create_mesh_set(int ordered_flag = -1);
00239 
00248   void commit_mesh(moab::Range &mesh_ents,
00249                    MeshedState mstate);
00250   
00260   void commit_mesh(moab::EntityHandle *mesh_ents,
00261                    int num_ents,
00262                    MeshedState mstate);
00263 
00274   void get_mesh(int dim,
00275                 std::vector<moab::EntityHandle> &ments,
00276                 bool bdy_too = false);
00277 
00286   void boundary(int dim,
00287                 std::vector<moab::EntityHandle> &bdy,
00288                 std::vector<int> *senses = NULL,
00289                 std::vector<int> *group_sizes = NULL);
00290 
00297   void boundary(int dim,
00298                 MEntVector &elements,
00299                 std::vector<int> *senses,
00300                 std::vector<int> *group_sizes = NULL);
00301 
00310   void boundary(int dim, 
00311                 moab::Range &ents) const;
00312 
00327   void get_indexed_connect_coords(std::vector<moab::EntityHandle> &ents,
00328                                   std::vector<int> *senses,
00329                                   moab::Tag tagh,
00330                                   std::vector<int> &ents_as_ids,
00331                                   std::vector<double> &coords,
00332                                   moab::Range *verts_range = NULL,
00333                                   int start_index = 0);
00334   
00338   MeshedState get_meshed_state();
00339 
00343   void set_meshed_state(MeshedState mstate);
00344 
00355   int sizing_function_index() const;
00356 
00361   void sizing_function_index(int index, bool children_too = true);
00362 
00367   double mesh_interval_size() const;
00368 
00370   int mesh_intervals() const;
00371 
00375   void mesh_intervals(int ints);
00376 
00378   Firmness interval_firmness() const;
00379 
00383   void interval_firmness(Firmness firm);
00384 
00386   bool constrain_even() const;
00387   
00391   void constrain_even(bool flag);
00392 
00404   void add_meshop(MeshOp *meshop);
00405   
00410   void remove_meshop(MeshOp *meshop);
00411   
00416   void get_meshops(std::vector<MeshOp*> &meshops);
00417 
00422   bool is_meshops_list_empty()
00423   {
00424     return meshOps.empty();
00425   }
00426 
00434 
00435   MKCore *mk_core() const;
00436   
00438   iGeom::EntityHandle geom_handle() const;
00439 
00441   iGeom::EntityHandle geom_handle(moab::EntityHandle ment) const;
00442 
00446   iGeom * igeom_instance() const ;
00447 
00451   moab::Interface * moab_instance() const ;
00452 
00454   moab::EntityHandle mesh_handle() const;
00455 
00457   moab::EntityHandle mesh_handle(iGeom::EntityHandle gent) const;
00458 
00460   moab::EntityHandle mesh_handle(iGeom::EntitySetHandle gent) const;
00461 
00462   int iGeomIndex()
00463    {return igeomIndex;}
00464 
00465   int iRelPairIndex()
00466    {return irelIndex;}
00467 
00468   IAVariable *ia_var() {return iaVariable;}
00469   const IAVariable *ia_var() const {return iaVariable;}
00470   void ia_var(IAVariable *var) {iaVariable = var;}
00471 
00472 private:
00473 
00480   ModelEnt *next_winding(ModelEnt *this_edge, 
00481                             int this_sense, 
00482                             MEntVector &tmp_adjs);
00483   
00486   void init_parents_children();
00487 
00490   void init_group_contents();
00491   
00493   void set_downward_senses();
00494   
00496   MKCore *mkCore;
00497 
00499   int igeomIndex;
00500 
00502   int meshIndex;
00503 
00505   int irelIndex;
00506 
00508   iGeom::EntityHandle iGeomEnt;
00509   
00511   iGeom::EntitySetHandle iGeomSet;
00512   
00514   moab::EntityHandle moabEntSet;
00515   
00517   int sizingFunctionIndex;
00518   
00520   int meshIntervals;
00521   
00523   Firmness intervalFirmness;
00524 
00526   bool constrainEven;
00527   
00529   MeshedState meshedState;
00530 
00532   std::vector<MeshOp*> meshOps;
00533 
00535   IAVariable *iaVariable;
00536 };
00537 
00538 inline MKCore *ModelEnt::mk_core() const
00539 {
00540   return mkCore;
00541 }
00542 
00543 inline iGeom::EntityHandle ModelEnt::geom_handle() const
00544 {
00545   return iGeomEnt;
00546 }
00547 
00548 inline moab::EntityHandle ModelEnt::mesh_handle() const
00549 {
00550   return moabEntSet;
00551 }
00552 
00553 inline void ModelEnt::children(std::vector<std::vector<moab::EntityHandle> > &child_ents) const 
00554 {
00555   std::vector<MEntVector> tmp_vec;
00556   children(tmp_vec);
00557   std::vector<moab::EntityHandle> tmp_vec2;
00558   for (std::vector<MEntVector>::iterator vit1 = tmp_vec.begin(); vit1 != tmp_vec.end(); vit1++) {
00559     tmp_vec2.clear();
00560     for (MEntVector::iterator vit2 = (*vit1).begin(); vit2 != (*vit1).end(); vit2++)
00561       tmp_vec2.push_back((*vit2)->mesh_handle());
00562     child_ents.push_back(tmp_vec2);
00563   }
00564 }
00565 
00571 inline void ModelEnt::children(std::vector<std::vector<iGeom::EntityHandle> > &child_ents) const
00572 {
00573   std::vector<MEntVector> tmp_vec;
00574   children(tmp_vec);
00575   std::vector<iGeom::EntityHandle> tmp_vec2;
00576   for (std::vector<MEntVector>::iterator vit1 = tmp_vec.begin(); vit1 != tmp_vec.end(); vit1++) {
00577     tmp_vec2.clear();
00578     for (MEntVector::iterator vit2 = (*vit1).begin(); vit2 != (*vit1).end(); vit2++)
00579       tmp_vec2.push_back((*vit2)->geom_handle());
00580     child_ents.push_back(tmp_vec2);
00581   }
00582 }
00583 
00584 inline int ModelEnt::sizing_function_index() const 
00585 {
00586   return sizingFunctionIndex;
00587 }
00588 
00590 inline int ModelEnt::mesh_intervals() const 
00591 {
00592   return meshIntervals;
00593 }
00594 
00596 inline void ModelEnt::mesh_intervals(int ints)
00597 {
00598   meshIntervals = ints;
00599 }
00600 
00602 inline Firmness ModelEnt::interval_firmness() const 
00603 {
00604   return intervalFirmness;
00605 }
00606 
00608 inline void ModelEnt::interval_firmness(Firmness firm) 
00609 {
00610   intervalFirmness = firm;
00611 }
00612 
00613 inline bool ModelEnt::constrain_even() const 
00614 {
00615   return constrainEven;
00616 }
00617 
00618 inline void ModelEnt::constrain_even(bool flag) 
00619 {
00620   constrainEven = flag;
00621 }
00622 
00623 inline MeshedState ModelEnt::get_meshed_state() 
00624 {
00625   return meshedState;
00626 }
00627 
00628 inline void ModelEnt::set_meshed_state(MeshedState mstate) 
00629 {
00630   meshedState = mstate;
00631 }
00632 
00633 inline void ModelEnt::evaluate_discrete(double x, double y, double z, 
00634                                         double *close,
00635                                         double *direction,
00636                                         double *curvature1,
00637                                         double *curvature2) const
00638 {
00639   evaluate(x, y, z, close, direction, curvature1, curvature2);
00640 }
00641 
00645 inline void ModelEnt::add_meshop(MeshOp *meshop) 
00646 {
00647   assert(std::find(meshOps.begin(), meshOps.end(), meshop) == meshOps.end());
00648   meshOps.push_back(meshop);
00649 }
00650   
00651     /* \brief Remove a MeshOp that pointed to this ModelEnt
00652      * \param meshop MeshOp to remove
00653      */
00654 inline void ModelEnt::remove_meshop(MeshOp *meshop)
00655 {
00656   assert(std::find(meshOps.begin(), meshOps.end(), meshop) != meshOps.end());
00657   meshOps.erase(std::remove(meshOps.begin(), meshOps.end(), meshop), meshOps.end());
00658 }
00659   
00660     /* \brief Get MeshOps pointing to this ModelEnt
00661      * \param meshop MeshOps returned
00662      */
00663 inline void ModelEnt::get_meshops(std::vector<MeshOp*> &meshops) 
00664 {
00665   meshops.resize(meshOps.size());
00666   std::copy(meshOps.begin(), meshOps.end(), meshops.begin());
00667 }
00668 
00669 // TODO: unimplemented functions (these are just here because SWIG expects some
00670 // implementation!
00671 inline void ModelEnt::get_adjacencies(int dim, std::vector<iGeom::EntityHandle> &adjs) const {}
00672 inline void ModelEnt::get_adjacencies(int dim, std::vector<moab::EntityHandle> &adjs) const {}
00673 inline void ModelEnt::get_adjacencies(int dim, moab::Range &adjs) const {}
00674 inline void ModelEnt::children(std::vector<MEntVector> &child_ents) const {}
00675 inline void ModelEnt::children(std::vector<MEntVector> &child_ents) {}
00676 
00677 } // namespace meshkit
00678 
00679 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines