VTK  9.3.1
vtkSphericalPointIterator.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
65 #ifndef vtkSphericalPointIterator_h
66 #define vtkSphericalPointIterator_h
67 
68 #include "vtkCommonDataModelModule.h" // For export macro
69 #include "vtkDataSet.h" // the dataset and its points to iterate over
70 #include "vtkDoubleArray.h" // For axes
71 #include "vtkObject.h"
72 #include "vtkSmartPointer.h" // auto destruct
73 
74 #include <memory> // for std::unique_ptr
75 
76 VTK_ABI_NAMESPACE_BEGIN
77 class vtkDoubleArray;
78 class vtkPolyData;
79 struct SpiralPointIterator;
80 
81 class VTKCOMMONDATAMODEL_EXPORT vtkSphericalPointIterator : public vtkObject
82 {
83 public:
85 
90  vtkAbstractTypeMacro(vtkSphericalPointIterator, vtkObject);
91  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
95 
98  vtkSetSmartPointerMacro(DataSet, vtkDataSet);
99  vtkGetSmartPointerMacro(DataSet, vtkDataSet);
101 
103 
116  vtkSetSmartPointerMacro(Axes, vtkDoubleArray);
117  vtkGetSmartPointerMacro(Axes, vtkDoubleArray);
119 
131  enum AxesType
132  {
133  XY_CW_AXES = 0, // axes clockwise around center in x-y plane (resolution required)
134  XY_CCW_AXES = 1, // axes counterclockwise around center (resolution required)
135  XY_SQUARE_AXES = 2, // axes +x,-x, +y,-y: axes through the four faces of a square
136  CUBE_AXES = 3, // axes +x,-x, +y,-y, +z,-z: axes through the six faces of a cube
137  OCTAHEDRON_AXES = 4, // axes through the eight faces of a regular octahedron
138  CUBE_OCTAHEDRON_AXES =
139  5, // axes through the eight faces of a regular octahedron and six faces of a cube
140  DODECAHEDRON_AXES = 6, // axes through the twelve faces of a dedecahdron
141  ICOSAHEDRON_AXES = 7, // axes through the twenty faces of a icosahedron
142  };
143 
150  void SetAxes(int axesType, int resolution = 6);
151 
160  enum SortType
161  {
162  SORT_NONE = 0,
163  SORT_ASCENDING = 1,
164  SORT_DESCENDING = 2
165  };
166 
168 
175  vtkSetClampMacro(Sorting, int, SORT_NONE, SORT_DESCENDING);
176  vtkGetMacro(Sorting, int);
177  void SetSortTypeToNone() { this->SetSorting(SORT_NONE); }
178  void SetSortTypeToAscending() { this->SetSorting(SORT_ASCENDING); }
179  void SetSortTypeToDescending() { this->SetSorting(SORT_DESCENDING); }
181 
182  // The following methods support point iteration. The data members referred
183  // to previously must be defined before these iteration methods can be
184  // successfully invoked.
185 
187 
195  bool Initialize(double center[3], vtkIdList* neighborhood);
196  bool Initialize(double center[3], vtkIdType numNei, vtkIdType* neighborhood);
197  bool Initialize(double center[3]); // all points of the specified dataset
199 
205  void GoToFirstPoint();
206 
210  bool IsDoneWithTraversal();
211 
216  void GoToNextPoint();
217 
222  void GetCurrentPoint(vtkIdType& ptId, double x[3]);
223 
227  vtkIdType GetCurrentPoint();
228 
233  vtkIdType GetPoint(int axis, int ptIdx);
234 
239  vtkIdType GetNumberOfAxes();
240 
244  void GetAxisPoints(int axis, vtkIdType& npts, const vtkIdType*& pts) VTK_SIZEHINT(pts, npts);
245 
254  void BuildRepresentation(vtkPolyData* pd);
255 
256 protected:
258  ~vtkSphericalPointIterator() override = default;
259 
260  // Information needed to define the spherical iterator.
261  vtkSmartPointer<vtkDataSet> DataSet; // The points to iterate over
262  vtkSmartPointer<vtkDoubleArray> Axes; // The axes defining the iteration pattern
263  int Sorting; // The direction of sorting, if sorting required
264 
265  // Iterator internals are represented using a PIMPL idiom
266  struct SphericalPointIterator;
267  std::unique_ptr<SphericalPointIterator> Iterator;
268 
269  // Changes to the VTK class must be propagated to the internal iterator
271 
272 private:
274  void operator=(const vtkSphericalPointIterator&) = delete;
275 };
276 
277 VTK_ABI_NAMESPACE_END
278 #endif // vtkSphericalPointIterator_h
vtkSmartPointer< vtkDataSet > DataSet
SortType
Points can be sorted along each axis.
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetSortTypeToAscending()
Specify whether points along each axis are radially sorted, and if so, whether in an ascending or des...
abstract class to specify dataset behavior
Definition: vtkDataSet.h:52
record modification and/or execution time
Definition: vtkTimeStamp.h:24
int vtkIdType
Definition: vtkType.h:315
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
dynamic, self-adjusting array of double
std::unique_ptr< SphericalPointIterator > Iterator
void SetSortTypeToNone()
Specify whether points along each axis are radially sorted, and if so, whether in an ascending or des...
void SetSortTypeToDescending()
Specify whether points along each axis are radially sorted, and if so, whether in an ascending or des...
a simple class to control print indentation
Definition: vtkIndent.h:28
list of point or cell ids
Definition: vtkIdList.h:22
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:28
#define VTK_SIZEHINT(...)
vtkSmartPointer< vtkDoubleArray > Axes
void GetPoint(int i, int j, int k, double pnt[3])
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
AxesType
While the axes can be arbitrarily specified, it is possible to select axes from a menu of predefined ...
Traverse a collection of points in spherical ordering.