VTK  9.7.1
vtkPoints.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
17 #ifndef vtkPoints_h
18 #define vtkPoints_h
19 
20 #include "vtkCommonCoreModule.h" // For export macro
21 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
22 #include "vtkObject.h"
23 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
24 
25 #include "vtkDataArray.h" // Needed for inline methods
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class vtkIdList;
29 
30 class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
31 {
32 public:
33  static vtkPoints* New(int dataType);
34 
35  static vtkPoints* New();
36 
37  vtkTypeMacro(vtkPoints, vtkObject);
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
43  VTK_DEPRECATED_IN_9_7_0("Use Reserve() to allocate or Initialize() to deallocate.")
44  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
45 
49  virtual void Initialize();
50 
59  virtual void SetData(vtkDataArray*);
60  vtkDataArray* GetData() { return this->Data; }
61 
66  virtual int GetDataType() const;
67 
72  virtual void SetDataType(int dataType);
73  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
74  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
75  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
76  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
77  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
78  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
79  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
80  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
81  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
82  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
83  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
84 
89  VTK_DEPRECATED_IN_9_7_0("Use vtkArrayDispatch")
90  void* GetVoidPointer(const int id)
91  {
92  return this->Data->GetVoidPointer(id); // NOLINT(bugprone-unsafe-functions)
93  }
94 
98  virtual void Squeeze() { this->Data->Squeeze(); }
99 
103  virtual void Reset();
104 
106 
111  virtual void DeepCopy(vtkPoints* ad);
112  virtual void ShallowCopy(vtkPoints* ad);
114 
123  unsigned long GetActualMemorySize();
124 
129  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
130 
138  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
139  {
140  return this->Data->GetTuple(id);
141  }
142 
148  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
149  VTK_SIZEHINT(3)
150  {
151  this->Data->GetTuple(id, x);
152  }
153 
161  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
162  {
163  this->Data->SetTuple(id, x);
164  }
166  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
167  {
168  this->Data->SetTuple(id, x);
169  }
171  void SetPoint(vtkIdType id, double x, double y, double z)
172  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
173 
175 
179  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
180  {
181  this->Data->InsertTuple(id, x);
182  }
183  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
184  {
185  this->Data->InsertTuple(id, x);
186  }
187  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
189 
196  {
197  this->Data->InsertTuples(dstIds, srcIds, source->Data);
198  }
199 
206  {
207  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
208  }
209 
213  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
214  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
215  vtkIdType InsertNextPoint(double x, double y, double z);
216 
223  void SetNumberOfPoints(vtkIdType numPoints);
224 
230  VTK_DEPRECATED_IN_9_7_0("Use Reserve, Squeeze or Initialize")
231  vtkTypeBool Resize(vtkIdType numPoints);
232 
241  vtkTypeBool Reserve(vtkIdType numPoints);
242 
246  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
247 
251  virtual void ComputeBounds();
252 
256  double* GetBounds() VTK_SIZEHINT(6);
257 
261  void GetBounds(double bounds[6]);
262 
266  vtkMTimeType GetMTime() override;
267 
273  void Modified() override;
274 
275 protected:
276  vtkPoints(int dataType = VTK_FLOAT);
277  ~vtkPoints() override;
278 
279  double Bounds[6];
280  vtkTimeStamp ComputeTime; // Time at which bounds computed
281  vtkDataArray* Data; // Array which represents data
282 
283 private:
284  vtkPoints(const vtkPoints&) = delete;
285  void operator=(const vtkPoints&) = delete;
286 };
287 
288 inline void vtkPoints::Reset()
289 {
290  this->Data->Reset();
291  this->Modified();
292 }
293 
295 {
296  if (numPoints != this->Data->GetNumberOfTuples())
297  {
298  this->Data->SetNumberOfComponents(3);
299  this->Data->SetNumberOfTuples(numPoints);
300  this->Modified();
301  }
302 }
303 
305 {
306  if (numPoints != this->Data->GetNumberOfTuples())
307  {
308  this->Data->SetNumberOfComponents(3);
309  this->Modified();
310  return this->Data->ReserveTuples(numPoints);
311  }
312  return 1;
313 }
314 
315 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
316 {
317  double p[3] = { x, y, z };
318  this->Data->SetTuple(id, p);
319 }
320 
321 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
322 {
323  double p[3] = { x, y, z };
324  this->Data->InsertTuple(id, p);
325 }
326 
327 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
328 {
329  double p[3] = { x, y, z };
330  return this->Data->InsertNextTuple(p);
331 }
332 
333 VTK_ABI_NAMESPACE_END
334 #endif
void SetDataTypeToInt()
Definition: vtkPoints.h:78
void SetDataTypeToFloat()
Definition: vtkPoints.h:82
void GetBounds(T a, double bds[6])
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:75
#define VTK_UNSIGNED_INT
Definition: vtkType.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:52
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:214
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool Reserve(vtkIdType numPoints)
Reserve the internal array to the requested number of points and preserve data.
Definition: vtkPoints.h:304
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
void InsertPoints(vtkIdList *dstIds, vtkIdList *srcIds, vtkPoints *source)
Copy the points indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
Definition: vtkPoints.h:195
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:38
void SetDataTypeToLong()
Definition: vtkPoints.h:80
record modification and/or execution time
Definition: vtkTimeStamp.h:24
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:213
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:161
vtkDataArray * Data
Definition: vtkPoints.h:281
int vtkIdType
Definition: vtkType.h:363
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:79
void SetDataTypeToChar()
Definition: vtkPoints.h:74
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DOUBLE
Definition: vtkType.h:44
#define VTK_FLOAT
Definition: vtkType.h:43
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:179
a simple class to control print indentation
Definition: vtkIndent.h:28
list of point or cell ids
Definition: vtkIdList.h:25
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_SHORT
Definition: vtkType.h:37
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:81
#define VTK_CHAR
Definition: vtkType.h:34
#define VTK_LONG
Definition: vtkType.h:41
virtual void Modified()
Update the modification time for this object.
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:294
#define VTK_SIZEHINT(...)
void Reset()
Reset to an empty state, without freeing any memory.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
#define VTK_MARSHALEXCLUDE(reason)
void SetDataTypeToBit()
Definition: vtkPoints.h:73
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:36
void GetPoint(int i, int j, int k, double pnt[3])
void SetDataTypeToShort()
Definition: vtkPoints.h:76
#define VTK_BIT
Definition: vtkType.h:33
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:77
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:42
#define VTK_MARSHALAUTO
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Copy n consecutive points starting at srcStart from the source array to this array, starting at the dstStart location.
Definition: vtkPoints.h:205
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:98
void SetDataTypeToDouble()
Definition: vtkPoints.h:83
#define VTK_EXPECTS(x)
#define VTK_DEPRECATED_IN_9_7_0(reason)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:183
#define VTK_INT
Definition: vtkType.h:39
represent and manipulate 3D points
Definition: vtkPoints.h:30