VTK  9.7.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
16
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
27VTK_ABI_NAMESPACE_BEGIN
28class vtkIdList;
29
30class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
31{
32public:
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);
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
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")
232
241 vtkTypeBool Reserve(vtkIdType numPoints);
242
246 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
247
251 virtual void ComputeBounds();
252
257
261 void GetBounds(double bounds[6]);
262
267
273 void Modified() override;
274
275protected:
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
283private:
284 vtkPoints(const vtkPoints&) = delete;
285 void operator=(const vtkPoints&) = delete;
286};
287
288inline 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
315inline 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
321inline 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
327inline 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
333VTK_ABI_NAMESPACE_END
334#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:26
a simple class to control print indentation
Definition vtkIndent.h:29
vtkPoints(int dataType=VTK_FLOAT)
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:77
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:161
void SetDataTypeToChar()
Definition vtkPoints.h:74
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:183
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:78
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
vtkTypeBool Reserve(vtkIdType numPoints)
Reserve the internal array to the requested number of points and preserve data.
Definition vtkPoints.h:304
virtual void Reset()
Make object look empty but do not delete memory.
Definition vtkPoints.h:288
void SetDataTypeToLong()
Definition vtkPoints.h:80
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
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:98
vtkTimeStamp ComputeTime
Definition vtkPoints.h:280
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:81
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:75
static vtkPoints * New(int dataType)
vtkDataArray * Data
Definition vtkPoints.h:281
vtkDataArray * GetData()
Definition vtkPoints.h:60
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:138
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:79
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:90
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:76
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:129
void SetDataTypeToDouble()
Definition vtkPoints.h:83
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:294
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:179
void SetDataTypeToBit()
Definition vtkPoints.h:73
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
double Bounds[6]
Definition vtkPoints.h:279
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:213
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:205
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:82
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:214
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
void Reset()
Initializes the field list to empty.
#define VTK_DEPRECATED_IN_9_7_0(reason)
virtual int GetNumberOfPoints()=0
Return the number of corner points that compose the cell.
#define VTK_SHORT
Definition vtkType.h:37
int vtkIdType
Definition vtkType.h:363
#define VTK_UNSIGNED_INT
Definition vtkType.h:40
#define VTK_DOUBLE
Definition vtkType.h:44
#define VTK_UNSIGNED_CHAR
Definition vtkType.h:36
#define VTK_UNSIGNED_SHORT
Definition vtkType.h:38
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_INT
Definition vtkType.h:39
#define VTK_FLOAT
Definition vtkType.h:43
#define VTK_CHAR
Definition vtkType.h:34
#define VTK_UNSIGNED_LONG
Definition vtkType.h:42
#define VTK_BIT
Definition vtkType.h:33
#define VTK_LONG
Definition vtkType.h:41
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)