VTK  9.3.20240726
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
118 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
119
126 double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
127
131 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
132
138 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
139 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
140 void SetPoint(vtkIdType id, double x, double y);
141
146 void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
147 void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
148 void InsertPoint(vtkIdType id, double x, double y);
149
153 vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
154 vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
155 vtkIdType InsertNextPoint(double x, double y);
156
160 void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
161
167 void SetNumberOfPoints(vtkIdType numPoints);
168
173 vtkTypeBool Resize(vtkIdType numPoints);
174
179
183 virtual void ComputeBounds();
184
189
193 void GetBounds(double bounds[4]);
194
195protected:
196 vtkPoints2D(int dataType = VTK_FLOAT);
197 ~vtkPoints2D() override;
198
199 double Bounds[4];
200 vtkTimeStamp ComputeTime; // Time at which bounds computed
201 vtkDataArray* Data; // Array which represents data
202
203private:
204 vtkPoints2D(const vtkPoints2D&) = delete;
205 void operator=(const vtkPoints2D&) = delete;
206};
207
208inline void vtkPoints2D::Reset()
209{
210 this->Data->Reset();
211 this->Modified();
212}
213
215{
216 this->Data->SetNumberOfComponents(2);
217 this->Data->SetNumberOfTuples(numPoints);
218 this->Modified();
219}
220
222{
223 this->Data->SetNumberOfComponents(2);
224 this->Modified();
225 return this->Data->Resize(numPoints);
226}
227
228inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
229{
230 double p[2] = { x, y };
231 this->Data->SetTuple(id, p);
232}
233
234inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
235{
236 double p[2] = { x, y };
237 this->Data->InsertTuple(id, p);
238}
239
240inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
241{
242 double p[2] = { x, y };
243 return this->Data->InsertNextTuple(p);
244}
245
246VTK_ABI_NAMESPACE_END
247#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: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])
vtkIdType GetNumberOfPoints() const
Return number of points in array.
void RemovePoint(vtkIdType id)
Remove point described by its id.
vtkDataArray * GetData()
Definition vtkPoints2D.h:55
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
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
void SetPoint(vtkIdType id, const double x[2])
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: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
#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_MARSHALAUTO