VTK  9.4.20251007
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
16
17#ifndef vtkPoints_h
18#define vtkPoints_h
19
20#include "vtkCommonCoreModule.h" // For export macro
21#include "vtkObject.h"
22#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
23
24#include "vtkDataArray.h" // Needed for inline methods
25
26VTK_ABI_NAMESPACE_BEGIN
27class vtkIdList;
28
29class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
30{
31public:
32 static vtkPoints* New(int dataType);
33
34 static vtkPoints* New();
35
36 vtkTypeMacro(vtkPoints, vtkObject);
37 void PrintSelf(ostream& os, vtkIndent indent) override;
38
42 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
43
47 virtual void Initialize();
48
57 virtual void SetData(vtkDataArray*);
58 vtkDataArray* GetData() { return this->Data; }
59
64 virtual int GetDataType() const;
65
70 virtual void SetDataType(int dataType);
82
87 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
88
92 virtual void Squeeze() { this->Data->Squeeze(); }
93
97 virtual void Reset();
98
100
105 virtual void DeepCopy(vtkPoints* ad);
106 virtual void ShallowCopy(vtkPoints* ad);
108
117 unsigned long GetActualMemorySize();
118
122 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
123
131 {
132 return this->Data->GetTuple(id);
133 }
134
139 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
140 VTK_SIZEHINT(3)
141 {
142 this->Data->GetTuple(id, x);
143 }
144
151 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
152 {
153 this->Data->SetTuple(id, x);
154 }
155 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
156 {
157 this->Data->SetTuple(id, x);
158 }
159 void SetPoint(vtkIdType id, double x, double y, double z)
160 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
161
163
167 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
168 {
169 this->Data->InsertTuple(id, x);
170 }
171 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
172 {
173 this->Data->InsertTuple(id, x);
174 }
175 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
177
184 {
185 this->Data->InsertTuples(dstIds, srcIds, source->Data);
186 }
187
194 {
195 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
196 }
197
201 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
202 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
203 vtkIdType InsertNextPoint(double x, double y, double z);
204
210 void SetNumberOfPoints(vtkIdType numPoints);
211
217 vtkTypeBool Resize(vtkIdType numPoints);
218
222 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
223
227 virtual void ComputeBounds();
228
233
237 void GetBounds(double bounds[6]);
238
243
249 void Modified() override;
250
251protected:
252 vtkPoints(int dataType = VTK_FLOAT);
253 ~vtkPoints() override;
254
255 double Bounds[6];
256 vtkTimeStamp ComputeTime; // Time at which bounds computed
257 vtkDataArray* Data; // Array which represents data
258
259private:
260 vtkPoints(const vtkPoints&) = delete;
261 void operator=(const vtkPoints&) = delete;
262};
263
264inline void vtkPoints::Reset()
265{
266 this->Data->Reset();
267 this->Modified();
268}
269
271{
272 this->Data->SetNumberOfComponents(3);
273 this->Data->SetNumberOfTuples(numPoints);
274 this->Modified();
275}
276
278{
279 this->Data->SetNumberOfComponents(3);
280 this->Modified();
281 return this->Data->Resize(numPoints);
282}
283
284inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
285{
286 double p[3] = { x, y, z };
287 this->Data->SetTuple(id, p);
288}
289
290inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
291{
292 double p[3] = { x, y, z };
293 this->Data->InsertTuple(id, p);
294}
295
296inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
297{
298 double p[3] = { x, y, z };
299 return this->Data->InsertNextTuple(p);
300}
301
302VTK_ABI_NAMESPACE_END
303#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:24
a simple class to control print indentation
Definition vtkIndent.h:29
virtual void Modified()
Update the modification time for this object.
void SetPoint(vtkIdType id, const double x[3])
Definition vtkPoints.h:155
vtkPoints(int dataType=VTK_FLOAT)
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:75
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:151
void SetDataTypeToChar()
Definition vtkPoints.h:72
vtkMTimeType GetMTime() override
The modified time of the points.
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:171
void Modified() override
Update the modification time for this object and its Data.
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition vtkPoints.h:76
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
virtual void Reset()
Make object look empty but do not delete memory.
Definition vtkPoints.h:264
void SetDataTypeToLong()
Definition vtkPoints.h:78
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:183
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:92
vtkTimeStamp ComputeTime
Definition vtkPoints.h:256
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:79
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:73
static vtkPoints * New(int dataType)
vtkDataArray * Data
Definition vtkPoints.h:257
vtkDataArray * GetData()
Definition vtkPoints.h:58
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:130
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:77
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:87
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition vtkPoints.h:139
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:74
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:122
void SetDataTypeToDouble()
Definition vtkPoints.h:81
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:270
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:277
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:167
void SetDataTypeToBit()
Definition vtkPoints.h:71
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
double Bounds[6]
Definition vtkPoints.h:255
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:201
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:193
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:80
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:202
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 vtkDataArray
#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)
#define VTK_MARSHALAUTO