VTK  9.5.20250802
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
14#ifndef vtkPoints2D_h
15#define vtkPoints2D_h
16
17#include "vtkCommonCoreModule.h" // For export macro
18#include "vtkObject.h"
19#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
20
21#include "vtkDataArray.h" // Needed for inline methods
22
23VTK_ABI_NAMESPACE_BEGIN
24class vtkIdList;
25
26class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints2D : public vtkObject
27{
28public:
29 static vtkPoints2D* New(int dataType);
30
31 static vtkPoints2D* New();
32
33 vtkTypeMacro(vtkPoints2D, vtkObject);
34 void PrintSelf(ostream& os, vtkIndent indent) override;
35
39 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
40
44 virtual void Initialize();
45
54 virtual void SetData(vtkDataArray*);
55 vtkDataArray* GetData() { return this->Data; }
56
61 virtual int GetDataType() const;
62
66 virtual void SetDataType(int dataType);
67 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
68 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
69 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
70 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
71 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
72 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
73 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
74 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
75 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
76 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
77 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
78
83 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
84
88 virtual void Squeeze() { this->Data->Squeeze(); }
89
93 virtual void Reset();
94
96
101 virtual void DeepCopy(vtkPoints2D* ad);
102 virtual void ShallowCopy(vtkPoints2D* ad);
104
113 unsigned long GetActualMemorySize();
114
119 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
120
128 double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
129
134 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
135
142 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
144 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
146 void SetPoint(vtkIdType id, double x, double y);
147
152 void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
153 void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
154 void InsertPoint(vtkIdType id, double x, double y);
155
159 vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
160 vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
161 vtkIdType InsertNextPoint(double x, double y);
162
166 void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
167
174 void SetNumberOfPoints(vtkIdType numPoints);
175
181 vtkTypeBool Resize(vtkIdType numPoints);
182
187
191 virtual void ComputeBounds();
192
197
201 void GetBounds(double bounds[4]);
202
203protected:
204 vtkPoints2D(int dataType = VTK_FLOAT);
205 ~vtkPoints2D() override;
206
207 double Bounds[4];
208 vtkTimeStamp ComputeTime; // Time at which bounds computed
209 vtkDataArray* Data; // Array which represents data
210
211private:
212 vtkPoints2D(const vtkPoints2D&) = delete;
213 void operator=(const vtkPoints2D&) = delete;
214};
215
216inline void vtkPoints2D::Reset()
217{
218 this->Data->Reset();
219 this->Modified();
220}
221
223{
224 this->Data->SetNumberOfComponents(2);
225 this->Data->SetNumberOfTuples(numPoints);
226 this->Modified();
227}
228
230{
231 this->Data->SetNumberOfComponents(2);
232 this->Modified();
233 return this->Data->Resize(numPoints);
234}
235
236inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
237{
238 double p[2] = { x, y };
239 this->Data->SetTuple(id, p);
240}
241
242inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
243{
244 double p[2] = { x, y };
245 this->Data->InsertTuple(id, p);
246}
247
248inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
249{
250 double p[2] = { x, y };
251 return this->Data->InsertNextTuple(p);
252}
253
254VTK_ABI_NAMESPACE_END
255#endif
void GetPoint(int i, int j, int k, double pnt[3])
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:133
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
virtual void Modified()
Update the modification time for this object.
represent and manipulate 2D points
Definition vtkPoints2D.h:27
virtual void ShallowCopy(vtkPoints2D *ad)
Different ways to copy data.
double * GetBounds()
Return the bounds of the points.
void GetPoints(vtkIdList *ptId, vtkPoints2D *fp)
Given a list of pt ids, return an array of points.
static vtkPoints2D * New()
void SetDataTypeToUnsignedLong()
Definition vtkPoints2D.h:75
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition vtkPoints2D.h:69
void SetDataTypeToShort()
Definition vtkPoints2D.h:70
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:83
void SetDataTypeToDouble()
Definition vtkPoints2D.h:77
void SetDataTypeToFloat()
Definition vtkPoints2D.h:76
vtkIdType InsertNextPoint(const double x[2])
void RemovePoint(vtkIdType id)
Remove point described by its id.
vtkDataArray * GetData()
Definition vtkPoints2D.h:55
void SetDataTypeToInt()
Definition vtkPoints2D.h:72
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition vtkPoints2D.h:67
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:73
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:74
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition vtkPoints2D.h:88
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition vtkPoints2D.h:71
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:68
record modification and/or execution time
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SHORT
Definition vtkType.h:37
int vtkIdType
Definition vtkType.h:332
#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)