VTK  9.3.0
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
25VTK_ABI_NAMESPACE_BEGIN
26class vtkIdList;
27
28class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
29{
30public:
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
231
235 void GetBounds(double bounds[6]);
236
240 vtkMTimeType GetMTime() override;
241
247 void Modified() override;
248
249protected:
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
257private:
258 vtkPoints(const vtkPoints&) = delete;
259 void operator=(const vtkPoints&) = delete;
260};
261
262inline 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
282inline 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
288inline 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
294inline 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
300VTK_ABI_NAMESPACE_END
301#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:23
a simple class to control print indentation
Definition vtkIndent.h:29
abstract base class for most VTK objects
Definition vtkObject.h:49
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition vtkPoints.h:29
void SetPoint(vtkIdType id, const double x[3])
Definition vtkPoints.h:154
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:74
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:150
void SetDataTypeToChar()
Definition vtkPoints.h:71
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition vtkPoints.h:170
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition vtkPoints.h:75
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition vtkPoints.h:77
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
double * GetBounds()
Return the bounds of the points.
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition vtkPoints.h:91
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:78
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:72
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition vtkPoints.h:57
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition vtkPoints.h:129
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:76
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:86
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition vtkPoints.h:138
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:73
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:121
void SetDataTypeToDouble()
Definition vtkPoints.h:80
virtual void DeepCopy(vtkPoints *ad)
Different ways to copy data.
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition vtkPoints.h:268
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:275
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:166
void SetDataTypeToBit()
Definition vtkPoints.h:70
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
virtual void ShallowCopy(vtkPoints *ad)
Different ways to copy data.
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition vtkPoints.h:200
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Copy n consecutive points starting at srcStart from the source array to this array,...
Definition vtkPoints.h:192
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:79
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:201
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_SHORT
Definition vtkType.h:36
int vtkIdType
Definition vtkType.h:315
#define VTK_UNSIGNED_INT
Definition vtkType.h:39
#define VTK_DOUBLE
Definition vtkType.h:43
#define VTK_UNSIGNED_CHAR
Definition vtkType.h:35
#define VTK_UNSIGNED_SHORT
Definition vtkType.h:37
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_INT
Definition vtkType.h:38
#define VTK_FLOAT
Definition vtkType.h:42
#define VTK_CHAR
Definition vtkType.h:33
#define VTK_UNSIGNED_LONG
Definition vtkType.h:41
#define VTK_BIT
Definition vtkType.h:32
#define VTK_LONG
Definition vtkType.h:40
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)