File size: 4,738 Bytes
985c397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkCleanUnstructuredGrid
 * @brief   merge duplicate points
 *
 *
 * vtkCleanUnstructuredGrid is a filter that takes unstructured grid data as
 * input and generates unstructured grid data as output. vtkCleanUnstructuredGrid can
 * merge duplicate points (with coincident coordinates) using the vtkMergePoints object
 * to merge points.
 *
 * @sa
 * vtkCleanPolyData
 */


#ifndef vtkCleanUnstructuredGrid_h
# define vtkCleanUnstructuredGrid_h

# include "vtkFiltersGeneralModule.h"  // For export macro
# include "vtkSmartPointer.h"
# include "vtkUnstructuredGridAlgorithm.h"

/*VTK_ABI_NAMESPACE_BEGIN*/

class vtkIncrementalPointLocator;
class vtkDataSet;

class /*VTKFILTERSGENERAL_EXPORT*/ vtkCleanUnstructuredGrid: public vtkUnstructuredGridAlgorithm
{
public:
    static vtkCleanUnstructuredGrid* New();
    vtkTypeMacro(vtkCleanUnstructuredGrid, vtkUnstructuredGridAlgorithm);
    void PrintSelf(ostream& os, vtkIndent indent) override;

    ///@{
    /**
     * By default ToleranceIsAbsolute is false and Tolerance is
     * a fraction of Bounding box diagonal, if true, AbsoluteTolerance is
     * used when adding points to locator (merging)
     */
    vtkSetMacro(ToleranceIsAbsolute, bool);
    vtkBooleanMacro(ToleranceIsAbsolute, bool);
    vtkGetMacro(ToleranceIsAbsolute, bool);
    ///@}

    ///@{
    /**
     * Specify tolerance in terms of fraction of bounding box length.
     * Default is 0.0.
     */
    vtkSetClampMacro(Tolerance, double, 0.0, 1.0);
    vtkGetMacro(Tolerance, double);
    ///@}

    ///@{
    /**
     * Specify tolerance in absolute terms. Default is 1.0.
     */
    vtkSetClampMacro(AbsoluteTolerance, double, 0.0, VTK_DOUBLE_MAX);
    vtkGetMacro(AbsoluteTolerance, double);
    ///@}

    ///@{
    /**
     * Set/Get a spatial locator for speeding the search process. By
     * default an instance of vtkMergePoints is used.
     */
    virtual void SetLocator(vtkIncrementalPointLocator* locator);
    virtual vtkIncrementalPointLocator* GetLocator();
    ///@}

    /**
     * Create default locator. Used to create one when none is specified.
     */
    void CreateDefaultLocator(vtkDataSet* input = nullptr);

    /**
     * Release locator
     */
    void ReleaseLocator()
    {
        this->SetLocator(nullptr);
    }

    ///@{
    /**
     * Set/get the desired precision for the output types. See the documentation
     * for the vtkAlgorithm::DesiredOutputPrecision enum for an explanation of
     * the available precision settings.
     */
    vtkSetMacro(OutputPointsPrecision, int);
    vtkGetMacro(OutputPointsPrecision, int);
    ///@}

    ///@{
    /**
     * Set/Get whether to remove points that do not
     * have any cells associated with it.
     * Default is false
     */
    vtkSetMacro(RemovePointsWithoutCells, bool);
    vtkGetMacro(RemovePointsWithoutCells, bool);
    vtkBooleanMacro(RemovePointsWithoutCells, bool);
    ///@}

    ///@{
    /**
     * Set/Get the strategy used to weigh point data on merging points
     *
     * Possibilities:
     * - FIRST_POINT (int(0), default): the point with the lowest index imposes its data on to the
     * merged point
     * - AVERAGING (int(1)): a number average is performed on all the duplicate points
     * - SPATIAL_DENSITY (int(2)): an average by attached cell volume (i.e. for every cell the point
     * is connected to sum cell_volume/number_cell_points) is performed on the point data
     */
    vtkGetMacro(PointDataWeighingStrategy, int);
    vtkSetClampMacro(PointDataWeighingStrategy, int, FIRST_POINT, NUMBER_OF_WEIGHING_TYPES - 1);
    ///@}

    enum DataWeighingType
    {
        FIRST_POINT = 0,
        AVERAGING,
        SPATIAL_DENSITY,
        NUMBER_OF_WEIGHING_TYPES
    };

protected:
    vtkCleanUnstructuredGrid();
    ~vtkCleanUnstructuredGrid() override;

    bool ToleranceIsAbsolute = false;
    double Tolerance = 0.0;
    double AbsoluteTolerance = 1.0;
    bool RemovePointsWithoutCells = false;
    vtkSmartPointer<vtkIncrementalPointLocator> Locator;
    int OutputPointsPrecision = vtkAlgorithm::DEFAULT_PRECISION;
    int PointDataWeighingStrategy = FIRST_POINT;

    int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
    int FillInputPortInformation(int port, vtkInformation* info) override;

private:
    vtkCleanUnstructuredGrid(const vtkCleanUnstructuredGrid&) = delete;
    void operator=(const vtkCleanUnstructuredGrid&) = delete;
};
/*VTK_ABI_NAMESPACE_END*/
#endif
// VTK-HeaderTest-Exclude: vtkCleanUnstructuredGrid.h