VTK  9.6.20260313
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 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
41
45 virtual void Initialize();
46
55 virtual void SetData(vtkDataArray*);
56 vtkDataArray* GetData() { return this->Data; }
57
62 virtual int GetDataType() const;
63
67 virtual void SetDataType(int dataType);
79
84 VTK_DEPRECATED_IN_9_7_0("Use vtkArrayDispatch")
85 void* GetVoidPointer(const int id)
86 {
87 return this->Data->GetVoidPointer(id); // NOLINT(bugprone-unsafe-functions)
88 }
89
93 virtual void Squeeze() { this->Data->Squeeze(); }
94
98 virtual void Reset();
99
101
106 virtual void DeepCopy(vtkPoints2D* ad);
107 virtual void ShallowCopy(vtkPoints2D* ad);
109
118 unsigned long GetActualMemorySize();
119
124 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
125
133 double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
134
139 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
140
147 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
149 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
151 void SetPoint(vtkIdType id, double x, double y);
152
157 void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
158 void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
159 void InsertPoint(vtkIdType id, double x, double y);
160
164 vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
165 vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
166 vtkIdType InsertNextPoint(double x, double y);
167
171 void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
172
179 void SetNumberOfPoints(vtkIdType numPoints);
180
186 vtkTypeBool Resize(vtkIdType numPoints);
187
192
196 virtual void ComputeBounds();
197
202
206 void GetBounds(double bounds[4]);
207
208protected:
209 vtkPoints2D(int dataType = VTK_FLOAT);
210 ~vtkPoints2D() override;
211
212 double Bounds[4];
213 vtkTimeStamp ComputeTime; // Time at which bounds computed
214 vtkDataArray* Data; // Array which represents data
215
216private:
217 vtkPoints2D(const vtkPoints2D&) = delete;
218 void operator=(const vtkPoints2D&) = delete;
219};
220
221inline void vtkPoints2D::Reset()
222{
223 this->Data->Reset();
224 this->Modified();
225}
226
228{
229 this->Data->SetNumberOfComponents(2);
230 this->Data->SetNumberOfTuples(numPoints);
231 this->Modified();
232}
233
235{
236 this->Data->SetNumberOfComponents(2);
237 this->Modified();
238 return this->Data->Resize(numPoints);
239}
240
241inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
242{
243 double p[2] = { x, y };
244 this->Data->SetTuple(id, p);
245}
246
247inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
248{
249 double p[2] = { x, y };
250 this->Data->InsertTuple(id, p);
251}
252
253inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
254{
255 double p[2] = { x, y };
256 return this->Data->InsertNextTuple(p);
257}
258
259VTK_ABI_NAMESPACE_END
260#endif
void Reset()
Reset to an empty state, without freeing any memory.
list of point or cell ids
Definition vtkIdList.h:133
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.
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:76
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition vtkPoints2D.h:70
void SetDataTypeToShort()
Definition vtkPoints2D.h:71
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:85
void SetDataTypeToDouble()
Definition vtkPoints2D.h:78
void SetDataTypeToFloat()
Definition vtkPoints2D.h:77
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:56
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
void SetDataTypeToInt()
Definition vtkPoints2D.h:73
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition vtkPoints2D.h:68
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:74
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:75
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition vtkPoints2D.h:93
vtkTimeStamp ComputeTime
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition vtkPoints2D.h:72
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:69
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)