MeshKit
1.0
|
00001 #ifndef MESHKIT_MERGE_MESH_HPP 00002 #define MESHKIT_MERGE_MESH_HPP 00003 00004 #include "meshkit/Types.hpp" 00005 #include "meshkit/Error.hpp" 00006 #include "meshkit/MeshScheme.hpp" 00007 #include "meshkit/ModelEnt.hpp" 00008 00009 #include <cassert> 00010 #include <string.h> 00011 #include <vector> 00012 #include <set> 00013 00014 #include "iMesh.h" 00015 00016 #include "meshkit/iMesh.hpp" 00017 #include "moab/Interface.hpp" 00018 #include "moab/Range.hpp" 00019 #include "moab/AdaptiveKDTree.hpp" 00020 00021 namespace MeshKit { 00022 00023 class MKCore; 00024 00025 00043 class MergeMesh : public MeshScheme 00044 { 00045 public: 00046 /* \brief Constructor 00047 * 00048 * Create a new MergeMesh instance 00049 * \param impl the iMesh instance handle for the mesh 00050 */ 00051 00052 00053 MergeMesh(MKCore *mkcore, const MEntVector &me_vec); 00054 00055 /* \brief Destructor 00056 */ 00057 virtual ~MergeMesh(); 00058 00059 00061 static const char* name(); 00062 00067 static bool can_mesh(iBase_EntityType dim); 00068 00075 static bool can_mesh(ModelEnt *me); 00076 00080 static const moab::EntityType* output_types(); 00081 00085 virtual const moab::EntityType* mesh_types_arr() const; 00086 00090 virtual bool add_modelent(ModelEnt *model_ent); 00091 00093 virtual void setup_this(); 00094 00096 virtual void execute_this(); 00097 00098 /* \brief Return the imesh instance 00099 */ 00100 iMesh* impl() const {return imeshImpl;} 00101 00102 00103 00104 /* \brief Merge vertices in elements passed in 00105 */ 00106 void merge_entities(iBase_EntityHandle *elems, 00107 int elems_size, 00108 const double merge_tol, 00109 const int do_merge = true, 00110 const int update_sets = false, 00111 iBase_TagHandle merge_tag = 0); 00112 00113 /* \brief Perform the actual merge between entities 00114 */ 00115 void perform_merge(iBase_TagHandle merged_to); 00116 void set_merge_params(double mergeTol = 1e-4, int update_sets = 0, 00117 int do_merge = 1, iBase_TagHandle mergeTag = NULL); 00118 private: 00119 00120 iMesh *imeshImpl; 00121 double mergeTol, mergeTolSq; 00122 iBase_TagHandle mergeTag; 00123 int updateSets; 00124 int doMerge; 00125 00126 00127 //- given a kdtree, set tag on vertices in leaf nodes with vertices 00128 //- to which they should be merged 00129 moab::ErrorCode find_merged_to(moab::AdaptiveKDTree & tree, moab::EntityHandle &tree_root, moab::Tag merged_to); 00130 00131 00132 moab::ErrorCode merge_entities(moab::Range &elems, 00133 const int do_merge, 00134 const int update_sets, 00135 moab::Tag merge_tag); 00136 00137 //- perform the actual merge 00138 moab::ErrorCode perform_merge(moab::Tag merged_to); 00139 00140 moab::Interface *mbImpl; 00141 00142 //- the tag pointing to the entity to which an entity will be merged 00143 moab::Tag mbMergeTag; 00144 00145 //- entities which will go away after the merge 00146 moab::Range deadEnts; 00147 }; 00148 00149 inline const char* MergeMesh::name() 00150 { 00151 return "MergeMesh"; 00152 } 00153 00154 inline bool MergeMesh::can_mesh(iBase_EntityType) 00155 { 00156 return false; 00157 } 00158 00159 inline bool MergeMesh::can_mesh(ModelEnt *) 00160 { 00161 return true; 00162 } 00163 00164 inline const moab::EntityType* MergeMesh::mesh_types_arr() const 00165 { 00166 return output_types(); 00167 } 00168 00169 } // namespace 00170 00171 #endif