VTK  9.2.6
vtkSphericalPointIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSphericalPointIterator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
77 #ifndef vtkSphericalPointIterator_h
78 #define vtkSphericalPointIterator_h
79 
80 #include "vtkCommonDataModelModule.h" // For export macro
81 #include "vtkDataSet.h" // the dataset and its points to iterate over
82 #include "vtkDoubleArray.h" // For axes
83 #include "vtkObject.h"
84 #include "vtkSmartPointer.h" // auto destruct
85 
86 #include <memory> // for std::unique_ptr
87 
88 class vtkDoubleArray;
89 class vtkPolyData;
90 struct SpiralPointIterator;
91 
92 class VTKCOMMONDATAMODEL_EXPORT vtkSphericalPointIterator : public vtkObject
93 {
94 public:
96 
100  static vtkSphericalPointIterator* New();
101  vtkAbstractTypeMacro(vtkSphericalPointIterator, vtkObject);
102  void PrintSelf(ostream& os, vtkIndent indent) override;
104 
106 
109  vtkSetSmartPointerMacro(DataSet, vtkDataSet);
110  vtkGetSmartPointerMacro(DataSet, vtkDataSet);
112 
114 
127  vtkSetSmartPointerMacro(Axes, vtkDoubleArray);
128  vtkGetSmartPointerMacro(Axes, vtkDoubleArray);
130 
142  enum AxesType
143  {
144  XY_CW_AXES = 0, // axes clockwise around center in x-y plane (resolution required)
145  XY_CCW_AXES = 1, // axes counterclockwise around center (resolution required)
146  XY_SQUARE_AXES = 2, // axes +x,-x, +y,-y: axes through the four faces of a square
147  CUBE_AXES = 3, // axes +x,-x, +y,-y, +z,-z: axes through the six faces of a cube
148  OCTAHEDRON_AXES = 4, // axes through the eight faces of a regular octahedron
149  CUBE_OCTAHEDRON_AXES =
150  5, // axes through the eight faces of a regular octahedron and six faces of a cube
151  DODECAHEDRON_AXES = 6, // axes through the twelve faces of a dedecahdron
152  ICOSAHEDRON_AXES = 7, // axes through the twenty faces of a icosahedron
153  };
154 
161  void SetAxes(int axesType, int resolution = 6);
162 
171  enum SortType
172  {
173  SORT_NONE = 0,
174  SORT_ASCENDING = 1,
175  SORT_DESCENDING = 2
176  };
177 
179 
186  vtkSetClampMacro(Sorting, int, SORT_NONE, SORT_DESCENDING);
187  vtkGetMacro(Sorting, int);
188  void SetSortTypeToNone() { this->SetSorting(SORT_NONE); }
189  void SetSortTypeToAscending() { this->SetSorting(SORT_ASCENDING); }
190  void SetSortTypeToDescending() { this->SetSorting(SORT_DESCENDING); }
192 
193  // The following methods support point iteration. The data members referred
194  // to previously must be defined before these iteration methods can be
195  // successfully invoked.
196 
198 
206  bool Initialize(double center[3], vtkIdList* neighborhood);
207  bool Initialize(double center[3], vtkIdType numNei, vtkIdType* neighborhood);
208  bool Initialize(double center[3]); // all points of the specified dataset
210 
216  void GoToFirstPoint();
217 
221  bool IsDoneWithTraversal();
222 
227  void GoToNextPoint();
228 
233  void GetCurrentPoint(vtkIdType& ptId, double x[3]);
234 
238  vtkIdType GetCurrentPoint();
239 
244  vtkIdType GetPoint(int axis, int ptIdx);
245 
250  vtkIdType GetNumberOfAxes();
251 
255  void GetAxisPoints(int axis, vtkIdType& npts, const vtkIdType*& pts) VTK_SIZEHINT(pts, npts);
256 
265  void BuildRepresentation(vtkPolyData* pd);
266 
267 protected:
269  ~vtkSphericalPointIterator() override = default;
270 
271  // Information needed to define the spherical iterator.
272  vtkSmartPointer<vtkDataSet> DataSet; // The points to iterate over
273  vtkSmartPointer<vtkDoubleArray> Axes; // The axes defining the iteration pattern
274  int Sorting; // The direction of sorting, if sorting required
275 
276  // Iterator internals are represented using a PIMPL idiom
277  struct SphericalPointIterator;
278  std::unique_ptr<SphericalPointIterator> Iterator;
279 
280  // Changes to the VTK class must be propagated to the internal iterator
282 
283 private:
285  void operator=(const vtkSphericalPointIterator&) = delete;
286 };
287 
288 #endif // vtkSphericalPointIterator_h
vtkSmartPointer< vtkDataSet > DataSet
SortType
Points can be sorted along each axis.
abstract base class for most VTK objects
Definition: vtkObject.h:62
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:62
record modification and/or execution time
Definition: vtkTimeStamp.h:35
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
void GetPoint(const int i, const int j, const int k, double pnt[3])
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:39
list of point or cell ids
Definition: vtkIdList.h:33
std::map< std::string, DataArray > DataSet
key: variable name, value: DataArray
Definition: VTXTypes.h:39
#define VTK_SIZEHINT(...)
vtkSmartPointer< vtkDoubleArray > Axes
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.