1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef MERGEMESH_HPP
#define MERGEMESH_HPP

#include "moab/Interface.hpp"
#include "moab/Range.hpp"
#include <set>

namespace moab
{

class AdaptiveKDTree;

class MergeMesh
{
  public:
    /* \brief Constructor
     */
    MergeMesh( Interface* mbImpl, bool printErrorIn = true );

    /* \brief Destructor
     */
    virtual ~MergeMesh();

    /* \brief Merge vertices in elements passed in
     */
    ErrorCode merge_entities( EntityHandle* elems,
                              int elems_size,
                              const double merge_tol,
                              const int do_merge    = true,
                              const int update_sets = false,
                              Tag merge_tag         = 0,
                              bool do_higher_dim    = true );

    ErrorCode merge_entities( Range& elems,
                              const double merge_tol,
                              const int do_merge    = true,
                              const int update_sets = false,
                              Tag merge_tag         = 0,
                              bool do_higher_dim    = true );

    // Identify higher dimension to be merged
    ErrorCode merge_higher_dimensions( Range& elems );

    // merge vertices according to an input tag
    ErrorCode merge_using_integer_tag( Range& verts, Tag user_tag, Tag merge_tag = 0 );

    //- perform the actual merge
    ErrorCode perform_merge( Tag merged_to );

    // new method, for overlapped meshes
    // meshset could be the whole mesh, represented by root set 0;
    ErrorCode merge_all( EntityHandle meshset, const double merge_tol );

  private:
    // iMesh_Instance imeshImpl;

    //- given a kdtree, set tag on vertices in leaf nodes with vertices
    //- to which they should be merged
    ErrorCode find_merged_to( EntityHandle& tree_root, AdaptiveKDTree& tree, Tag merged_to );

    Interface* mbImpl;

    //- the tag pointing to the entity to which an entity will be merged
    Tag mbMergeTag;

    double mergeTol, mergeTolSq;

    //- entities which will go away after the merge
    std::set< EntityHandle > deadEnts;

    // vertices that were merged with other vertices, and were left in the database
    std::set< EntityHandle > mergedToVertices;

    // Allow a warning to be suppressed when no merging is done
    bool printError;
};

}  // namespace moab

#endif