File: vtkHyperTreeGridContour.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (288 lines) | stat: -rw-r--r-- 8,199 bytes parent folder | download | duplicates (5)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkHyperTreeGridContour
 * @brief   Extract cells from a hyper tree grid
 * where selected scalar value is within given range.
 *
 *
 * This filter extracts cells from a hyper tree grid that satisfy the
 * following contour: a cell is considered to be within range if its
 * value for the active scalar is within a specified range (inclusive).
 * The output remains a hyper tree grid.
 *
 * @sa
 * vtkHyperTreeGrid vtkHyperTreeGridAlgorithm vtkContourFilter
 *
 * @par Thanks:
 * This class was written by Guenole Harel and Jacques-Bernard Lekien 2014
 * This class was revised by Philippe Pebay, 2016
 * This class was modified by Jacques-Bernard Lekien, 2018
 * This work was supported by Commissariat a l'Energie Atomique
 * CEA, DAM, DIF, F-91297 Arpajon, France.
 */

#ifndef vtkHyperTreeGridContour_h
#define vtkHyperTreeGridContour_h

#include "vtkCellArray.h"              // For vtkCellArray
#include "vtkContourValues.h"          // Needed for inline methods
#include "vtkFiltersHyperTreeModule.h" // For export macro
#include "vtkHyperTreeGridAlgorithm.h"
#include "vtkNew.h"       // For vtkNew
#include "vtkPointData.h" // For vtkPointData

#include <vector> // For STL

VTK_ABI_NAMESPACE_BEGIN
class vtkBitArray;
class vtkCellData;
class vtkContourHelper;
class vtkDataArray;
class vtkHyperTreeGrid;
class vtkIdList;
class vtkIncrementalPointLocator;
class vtkLine;
class vtkPixel;
class vtkUnsignedCharArray;
class vtkVoxel;
class vtkHyperTreeGridNonOrientedCursor;
class vtkHyperTreeGridNonOrientedMooreSuperCursor;

class VTKFILTERSHYPERTREE_EXPORT vtkHyperTreeGridContour : public vtkHyperTreeGridAlgorithm
{
public:
  static vtkHyperTreeGridContour* New();
  vtkTypeMacro(vtkHyperTreeGridContour, vtkHyperTreeGridAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  ///@{
  /**
   * Set / get a spatial locator for merging points. By default,
   * an instance of vtkMergePoints is used.
   */
  void SetLocator(vtkIncrementalPointLocator*);
  vtkGetObjectMacro(Locator, vtkIncrementalPointLocator);
  ///@}

  /**
   * Create default locator. Used to create one when none is
   * specified. The locator is used to merge coincident points.
   */
  void CreateDefaultLocator();

  /**
   * Modified GetMTime Because we delegate to vtkContourValues.
   */
  vtkMTimeType GetMTime() override;

  ///@{
  /**
   * Methods (inlined) to set / get contour values.
   */
  void SetValue(int, double);
  double GetValue(int);
  double* GetValues();
  void GetValues(double*);
  void SetNumberOfContours(int);
  vtkIdType GetNumberOfContours();
  void GenerateValues(int, double[2]);
  void GenerateValues(int, double, double);
  ///@}

  enum CellStrategy3D
  {
    USE_VOXELS,
    USE_DECOMPOSED_POLYHEDRA
  };
  /**
   * Set the contour strategy to apply.
   * By default, strategy is USE_VOXELS.
   * This method is time-efficient but can lead to bad results in the 3D case, where generated dual
   * cells can be concave.
   * USE_DECOMPOSED_POLYHEDRA allow better results in such cases (3D HTGs only).
   * It takes advantage of the vtkPolyhedronUtilities::Decompose method to generate better contours.
   * The dowside is this method is much slower than USE_VOXELS.
   */
  vtkSetClampMacro(Strategy3D, int, USE_VOXELS, USE_DECOMPOSED_POLYHEDRA);

  ///@{
  /**
   * Set/Get whether or not the filter should use implicit arrays to store the
   * output contour values (stored as point data of the output contour).
   * Since these values are the same for each isosurface, some memory can be saved
   * by storing each value only once using an indexed array.
   *
   * @attention This option have no effect if there is more than 256 contour values.
   */
  vtkSetMacro(UseImplicitArrays, bool);
  vtkGetMacro(UseImplicitArrays, bool);
  vtkBooleanMacro(UseImplicitArrays, bool);
  ///@}

protected:
  vtkHyperTreeGridContour();
  ~vtkHyperTreeGridContour() override;

  /**
   * For this algorithm the output is a vtkPolyData instance
   */
  int FillOutputPortInformation(int, vtkInformation*) override;

  /**
   * Main routine to generate isocontours of hyper tree grid.
   */
  int ProcessTrees(vtkHyperTreeGrid*, vtkDataObject*) override;

  /**
   * Recursively decide whether a cell is intersected by a contour
   */
  bool RecursivelyPreProcessTree(vtkHyperTreeGridNonOrientedCursor*);

  /**
   * Recursively descend into the tree down to the leaves to construct the contour (verts, lines,
   * polys). dualPointData represents the point data of the dual mesh, i.e. HTG cell data used for
   * contouring.
   */
  void RecursivelyProcessTree(vtkHyperTreeGridNonOrientedMooreSuperCursor*, vtkCellArray* verts,
    vtkCellArray* lines, vtkCellArray* polys, vtkPointData* dualPointData);

  /**
   * Storage for contour values.
   */
  vtkContourValues* ContourValues;

  /**
   * Storage for pre-selected cells to be processed
   */
  vtkBitArray* SelectedCells;

  /**
   * Sign of isovalue if cell not treated
   */
  vtkBitArray** CellSigns;

  /**
   * Spatial locator to merge points.
   */
  vtkIncrementalPointLocator* Locator;

  ///@{
  /**
   * Pointers needed to perform isocontouring
   */
  vtkContourHelper* Helper;
  vtkDataArray* CellScalars;
  vtkLine* Line;
  vtkPixel* Pixel;
  vtkVoxel* Voxel;
  vtkIdList* Leaves;
  ///@}

  /**
   * Storage for signs relative to current contour value
   */
  std::vector<bool> Signs;

  /**
   * Keep track of current index in output polydata
   */
  vtkIdType CurrentId;

  /**
   * Keep track of selected input scalars
   */
  vtkDataArray* InScalars;

  vtkBitArray* InMask;
  vtkUnsignedCharArray* InGhostArray;

  // Strategy used to represent dual cells in 3D
  int Strategy3D = USE_VOXELS;

private:
  vtkHyperTreeGridContour(const vtkHyperTreeGridContour&) = delete;
  void operator=(const vtkHyperTreeGridContour&) = delete;

  // Use implicit arrays to store contour values
  bool UseImplicitArrays = false;

  struct vtkInternals;
  std::unique_ptr<vtkInternals> Internals;
};

/**
 * Set a particular contour value at contour number i. The index i ranges
 * between 0<=i<NumberOfContours.
 */
inline void vtkHyperTreeGridContour::SetValue(int i, double value)
{
  this->ContourValues->SetValue(i, value);
}

/**
 * Get the ith contour value.
 */
inline double vtkHyperTreeGridContour::GetValue(int i)
{
  return this->ContourValues->GetValue(i);
}

/**
 * Get a pointer to an array of contour values. There will be
 * GetNumberOfContours() values in the list.
 */
inline double* vtkHyperTreeGridContour::GetValues()
{
  return this->ContourValues->GetValues();
}

/**
 * Fill a supplied list with contour values. There will be
 * GetNumberOfContours() values in the list. Make sure you allocate
 * enough memory to hold the list.
 */
inline void vtkHyperTreeGridContour::GetValues(double* contourValues)
{
  this->ContourValues->GetValues(contourValues);
}

/**
 * Set the number of contours to place into the list. You only really
 * need to use this method to reduce list size. The method SetValue()
 * will automatically increase list size as needed.
 */
inline void vtkHyperTreeGridContour::SetNumberOfContours(int number)
{
  this->ContourValues->SetNumberOfContours(number);
}

/**
 * Get the number of contours in the list of contour values.
 */
inline vtkIdType vtkHyperTreeGridContour::GetNumberOfContours()
{
  return this->ContourValues->GetNumberOfContours();
}

/**
 * Generate numContours equally spaced contour values between specified
 * range. Contour values will include min/max range values.
 */
inline void vtkHyperTreeGridContour::GenerateValues(int numContours, double range[2])
{
  this->ContourValues->GenerateValues(numContours, range);
}

/**
 * Generate numContours equally spaced contour values between specified
 * range. Contour values will include min/max range values.
 */
inline void vtkHyperTreeGridContour::GenerateValues(
  int numContours, double rangeStart, double rangeEnd)
{
  this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);
}

VTK_ABI_NAMESPACE_END
#endif // vtkHyperTreeGridContour_h