VTK  9.6.20260402
vtkPoints2D.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
13
14#ifndef vtkPoints2D_h
15#define vtkPoints2D_h
16
17#include "vtkCommonCoreModule.h" // For export macro
18#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
19#include "vtkObject.h"
20#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
21
22#include "vtkDataArray.h" // Needed for inline methods
23
24VTK_ABI_NAMESPACE_BEGIN
25class vtkIdList;
26
27class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints2D : public vtkObject
28{
29public:
30 static vtkPoints2D* New(int dataType);
31
32 static vtkPoints2D* New();
33
34 vtkTypeMacro(vtkPoints2D, vtkObject);
35 void PrintSelf(ostream& os, vtkIndent indent) override;
36
40 VTK_DEPRECATED_IN_9_7_0("Use Reserve() to allocate or Initialize() to deallocate.")
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
68 virtual void SetDataType(int dataType);
80
85 VTK_DEPRECATED_IN_9_7_0("Use vtkArrayDispatch")
86 void* GetVoidPointer(const int id)
87 {
88 return this->Data->GetVoidPointer(id); // NOLINT(bugprone-unsafe-functions)
89 }
90
94 virtual void Squeeze() { this->Data->Squeeze(); }
95
99 virtual void Reset();
100
102
107 virtual void DeepCopy(vtkPoints2D* ad);
108 virtual void ShallowCopy(vtkPoints2D* ad);
110
119 unsigned long GetActualMemorySize();
120
125 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
126
134 double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
135
140 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
141
148 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
150 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
152 void SetPoint(vtkIdType id, double x, double y);
153
158 void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
159 void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
160 void InsertPoint(vtkIdType id, double x, double y);
161
165 vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
166 vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
167 vtkIdType InsertNextPoint(double x, double y);
168
172 void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
173
180 void SetNumberOfPoints(vtkIdType numPoints);
181
187 VTK_DEPRECATED_IN_9_7_0("Use Reserve, Squeeze or Initialize")
189
198 vtkTypeBool Reserve(vtkIdType numPoints);
199
204
208 virtual void ComputeBounds();
209
214
218 void GetBounds(double bounds[4]);
219
220protected:
221 vtkPoints2D(int dataType = VTK_FLOAT);
222 ~vtkPoints2D() override;
223
224 double Bounds[4];
225 vtkTimeStamp ComputeTime; // Time at which bounds computed
226 vtkDataArray* Data; // Array which represents data
227
228private:
229 vtkPoints2D(const vtkPoints2D&) = delete;
230 void operator=(const vtkPoints2D&) = delete;
231};
232
233inline void vtkPoints2D::Reset()
234{
235 this->Data->Reset();
236 this->Modified();
237}
238
240{
241 this->Data->SetNumberOfComponents(2);
242 this->Data->SetNumberOfTuples(numPoints);
243 this->Modified();
244}
245
247{
248 if (numPoints != this->Data->GetNumberOfTuples())
249 {
250 this->Data->SetNumberOfComponents(3);
251 this->Modified();
252 return this->Data->ReserveTuples(numPoints);
253 }
254 return 1;
255}
256
257inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
258{
259 double p[2] = { x, y };
260 this->Data->SetTuple(id, p);
261}
262
263inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
264{
265 double p[2] = { x, y };
266 this->Data->InsertTuple(id, p);
267}
268
269inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
270{
271 double p[2] = { x, y };
272 return this->Data->InsertNextTuple(p);
273}
274
275VTK_ABI_NAMESPACE_END
276#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:135
a simple class to control print indentation
Definition vtkIndent.h:108
virtual void Modified()
Update the modification time for this object.
virtual void ShallowCopy(vtkPoints2D *ad)
Different ways to copy data.
double * GetBounds()
Return the bounds of the points.
vtkTypeBool Reserve(vtkIdType numPoints)
Resize the internal array to the requested number of points and preserve data.
void GetPoints(vtkIdList *ptId, vtkPoints2D *fp)
Given a list of pt ids, return an array of points.
virtual void Reset()
Make object look empty but do not delete memory.
static vtkPoints2D * New()
void SetDataTypeToUnsignedLong()
Definition vtkPoints2D.h:77
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition vtkPoints2D.h:71
void SetDataTypeToShort()
Definition vtkPoints2D.h:72
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkPoints2D * New(int dataType)
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints2D.h:86
void SetDataTypeToDouble()
Definition vtkPoints2D.h:79
void SetDataTypeToFloat()
Definition vtkPoints2D.h:78
vtkIdType InsertNextPoint(const double x[2])
vtkDataArray * Data
vtkIdType GetNumberOfPoints() const
Return number of points in array.
double Bounds[4]
void RemovePoint(vtkIdType id)
Remove point described by its id.
vtkPoints2D(int dataType=VTK_FLOAT)
vtkDataArray * GetData()
Definition vtkPoints2D.h:57
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
void SetDataTypeToInt()
Definition vtkPoints2D.h:74
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition vtkPoints2D.h:69
void InsertPoint(vtkIdType id, const double x[2])
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
void SetDataTypeToUnsignedInt()
Definition vtkPoints2D.h:75
virtual int GetDataType() const
Return the underlying data type.
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
void SetDataTypeToLong()
Definition vtkPoints2D.h:76
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition vtkPoints2D.h:94
vtkTimeStamp ComputeTime
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition vtkPoints2D.h:73
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
virtual void Initialize()
Return object to instantiated state.
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
void SetDataTypeToChar()
Definition vtkPoints2D.h:70
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
#define vtkDataArray
#define VTK_DEPRECATED_IN_9_7_0(reason)
#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
#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_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)