VTK  9.3.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 "vtkObject.h"
22 
23 #include "vtkDataArray.h" // Needed for inline methods
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkIdList;
27 
28 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
29 {
30 public:
31  static vtkPoints* New(int dataType);
32 
33  static vtkPoints* New();
34 
35  vtkTypeMacro(vtkPoints, vtkObject);
36  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
41  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
42 
46  virtual void Initialize();
47 
56  virtual void SetData(vtkDataArray*);
57  vtkDataArray* GetData() { return this->Data; }
58 
63  virtual int GetDataType() const;
64 
69  virtual void SetDataType(int dataType);
70  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
71  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
72  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
73  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
74  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
75  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
76  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
77  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
78  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
79  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
80  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
81 
86  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
87 
91  virtual void Squeeze() { this->Data->Squeeze(); }
92 
96  virtual void Reset();
97 
99 
104  virtual void DeepCopy(vtkPoints* ad);
105  virtual void ShallowCopy(vtkPoints* ad);
107 
116  unsigned long GetActualMemorySize();
117 
121  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
122 
129  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
130  {
131  return this->Data->GetTuple(id);
132  }
133 
138  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
139  VTK_SIZEHINT(3)
140  {
141  this->Data->GetTuple(id, x);
142  }
143 
150  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
151  {
152  this->Data->SetTuple(id, x);
153  }
154  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
155  {
156  this->Data->SetTuple(id, x);
157  }
158  void SetPoint(vtkIdType id, double x, double y, double z)
159  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
160 
162 
166  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
167  {
168  this->Data->InsertTuple(id, x);
169  }
170  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
171  {
172  this->Data->InsertTuple(id, x);
173  }
174  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
176 
183  {
184  this->Data->InsertTuples(dstIds, srcIds, source->Data);
185  }
186 
193  {
194  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
195  }
196 
200  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
201  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
202  vtkIdType InsertNextPoint(double x, double y, double z);
203 
209  void SetNumberOfPoints(vtkIdType numPoints);
210 
215  vtkTypeBool Resize(vtkIdType numPoints);
216 
220  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
221 
225  virtual void ComputeBounds();
226 
230  double* GetBounds() VTK_SIZEHINT(6);
231 
235  void GetBounds(double bounds[6]);
236 
240  vtkMTimeType GetMTime() override;
241 
247  void Modified() override;
248 
249 protected:
250  vtkPoints(int dataType = VTK_FLOAT);
251  ~vtkPoints() override;
252 
253  double Bounds[6];
254  vtkTimeStamp ComputeTime; // Time at which bounds computed
255  vtkDataArray* Data; // Array which represents data
256 
257 private:
258  vtkPoints(const vtkPoints&) = delete;
259  void operator=(const vtkPoints&) = delete;
260 };
261 
262 inline void vtkPoints::Reset()
263 {
264  this->Data->Reset();
265  this->Modified();
266 }
267 
269 {
270  this->Data->SetNumberOfComponents(3);
271  this->Data->SetNumberOfTuples(numPoints);
272  this->Modified();
273 }
274 
276 {
277  this->Data->SetNumberOfComponents(3);
278  this->Modified();
279  return this->Data->Resize(numPoints);
280 }
281 
282 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
283 {
284  double p[3] = { x, y, z };
285  this->Data->SetTuple(id, p);
286 }
287 
288 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
289 {
290  double p[3] = { x, y, z };
291  this->Data->InsertTuple(id, p);
292 }
293 
294 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
295 {
296  double p[3] = { x, y, z };
297  return this->Data->InsertNextTuple(p);
298 }
299 
300 VTK_ABI_NAMESPACE_END
301 #endif
void SetDataTypeToInt()
Definition: vtkPoints.h:75
void SetDataTypeToFloat()
Definition: vtkPoints.h:79
void GetBounds(T a, double bds[6])
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:72
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:138
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
abstract base class for most VTK objects
Definition: vtkObject.h:51
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:201
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:154
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
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:182
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
void SetDataTypeToLong()
Definition: vtkPoints.h:77
record modification and/or execution time
Definition: vtkTimeStamp.h:24
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:200
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:150
vtkDataArray * Data
Definition: vtkPoints.h:255
int vtkIdType
Definition: vtkType.h:315
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:76
void SetDataTypeToChar()
Definition: vtkPoints.h:71
int vtkTypeBool
Definition: vtkABI.h:64
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:275
#define VTK_DOUBLE
Definition: vtkType.h:43
#define VTK_FLOAT
Definition: vtkType.h:42
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:166
a simple class to control print indentation
Definition: vtkIndent.h:28
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:86
list of point or cell ids
Definition: vtkIdList.h:22
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_SHORT
Definition: vtkType.h:36
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:78
#define VTK_CHAR
Definition: vtkType.h:33
#define VTK_LONG
Definition: vtkType.h:40
virtual void Modified()
Update the modification time for this object.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:129
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:268
#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 *)
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:121
void SetDataTypeToBit()
Definition: vtkPoints.h:70
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
void SetDataTypeToShort()
Definition: vtkPoints.h:73
#define VTK_BIT
Definition: vtkType.h:32
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:74
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:41
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:192
vtkDataArray * GetData()
Definition: vtkPoints.h:57
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:91
void SetDataTypeToDouble()
Definition: vtkPoints.h:80
#define VTK_EXPECTS(x)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:170
#define VTK_INT
Definition: vtkType.h:38
represent and manipulate 3D points
Definition: vtkPoints.h:28