MeshKit  1.0
MergeMesh.hpp
Go to the documentation of this file.
00001 #ifndef MESHKIT_MERGE_MESH_HPP
00002 #define MESHKIT_MERGE_MESH_HPP
00003 
00004 #include "MKException.hpp"
00005 
00006 #include "meshkit/Types.hpp"
00007 #include "meshkit/Error.hpp"
00008 #include "meshkit/MeshScheme.hpp"
00009 #include "meshkit/ModelEnt.hpp"
00010 
00011 #include <cassert>
00012 #include <string.h>
00013 #include <vector>
00014 #include <set>
00015 
00016 #include "iMesh.h"
00017 
00018 #ifdef HAVE_MOAB
00019 #include "MBiMesh.hpp"
00020 #include "MBInterface.hpp"
00021 #include "MBRange.hpp"
00022 #include "MBAdaptiveKDTree.hpp"
00023 #endif
00024 
00025 namespace MeshKit {
00026 
00027   class MKCore;
00028 
00029 
00047 class MergeMesh : public MeshScheme
00048 {
00049 public:
00050   /* \brief Constructor
00051    *
00052    * Create a new MergeMesh instance
00053    * \param impl the iMesh instance handle for the mesh
00054    */
00055 
00056 
00057   MergeMesh(MKCore *mkcore, const MEntVector &me_vec);
00058   
00059   /* \brief Destructor
00060    */
00061   virtual ~MergeMesh();
00062 
00063 
00065     static const char* name();
00066 
00071     static bool can_mesh(iBase_EntityType dim);
00072 
00079     static bool can_mesh(ModelEnt *me);
00080 
00084     static const moab::EntityType* output_types();
00085 
00089     virtual const moab::EntityType* mesh_types_arr() const;
00090 
00094     virtual bool add_modelent(ModelEnt *model_ent);
00095 
00097     virtual void setup_this();
00098 
00100     virtual void execute_this();
00101 
00102   /* \brief Return the imesh instance
00103    */
00104   iMesh* impl() const {return imeshImpl;}
00105 
00106 
00107 
00108     /* \brief Merge vertices in elements passed in
00109      */
00110   void merge_entities(iBase_EntityHandle *elems,
00111                       int elems_size,
00112                       const double merge_tol,
00113                       const int do_merge = true,
00114                       const int update_sets = false,
00115                       iBase_TagHandle merge_tag = 0);
00116   
00117     /* \brief Perform the actual merge between entities
00118      */
00119   void perform_merge(iBase_TagHandle merged_to);
00120   void set_merge_params(double mergeTol = 1e-4, int update_sets = 0,
00121                           int do_merge = 1, iBase_TagHandle mergeTag = NULL);
00122 private:
00123   
00124   iMesh *imeshImpl;
00125   double mergeTol, mergeTolSq;
00126   iBase_TagHandle mergeTag;
00127   int updateSets;
00128   int doMerge;
00129 
00130 #ifdef HAVE_MOAB
00131 
00132     //- given a kdtree, set tag on vertices in leaf nodes with vertices
00133     //- to which they should be merged
00134   MBErrorCode find_merged_to(MBAdaptiveKDTree & tree, MBEntityHandle &tree_root, MBTag merged_to);
00135 
00136   
00137   MBErrorCode merge_entities(MBRange &elems,
00138                              const int do_merge,
00139                              const int update_sets,
00140                              MBTag merge_tag);
00141   
00142     //- perform the actual merge
00143   MBErrorCode perform_merge(MBTag merged_to);
00144 
00145   MBInterface *mbImpl;
00146 
00147     //- the tag pointing to the entity to which an entity will be merged
00148   MBTag mbMergeTag;
00149 
00150     //- entities which will go away after the merge
00151   MBRange deadEnts;
00152 #endif
00153 };
00154 
00155   inline const char* MergeMesh::name()
00156   {
00157     return "MergeMesh";
00158   }
00159 
00160   inline bool MergeMesh::can_mesh(iBase_EntityType)
00161   {
00162     return false;
00163   }
00164 
00165   inline bool MergeMesh::can_mesh(ModelEnt *)
00166   {
00167     return true;
00168   }
00169 
00170   inline const moab::EntityType* MergeMesh::mesh_types_arr() const
00171   {
00172     return output_types();
00173   }
00174 
00175 } // namespace
00176 
00177 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines