VTK: Common/Core/vtkPoints2D.h Source File

| VTK 9.3.1

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
20 #include "vtkDataArray.h" // Needed for inline methods
21
22 VTK_ABI_NAMESPACE_BEGIN
23 class vtkIdList;
24
25 class VTKCOMMONCORE_EXPORT vtkPoints2D : public vtkObject
26 {
27 public:
28 static vtkPoints2D* New(int dataType);
29
30 static vtkPoints2D* New();
31
32 vtkTypeMacro(vtkPoints2D, vtkObject);
33 void PrintSelf(ostream& os, vtkIndent indent) override;
34
38 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
39
43 virtual void Initialize();
44
53 virtual void SetData(vtkDataArray*);
54 vtkDataArray* GetData() { return this->Data; }
55
60 virtual int GetDataType() const;
61
65 virtual void SetDataType(int dataType);
66 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
67 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
68 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
69 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
70 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
71 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
72 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
73 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
74 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
75 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
76 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
77
82 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
83
87 virtual void Squeeze() { this->Data->Squeeze(); }
88
92 virtual void Reset();
93
95
100 virtual void DeepCopy(vtkPoints2D* ad);
101 virtual void ShallowCopy(vtkPoints2D* ad);
103
112 unsigned long GetActualMemorySize();
113
117 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
118
125 double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
126
130 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
131
137 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
138 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
139 void SetPoint(vtkIdType id, double x, double y);
140
145 void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
146 void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
147 void InsertPoint(vtkIdType id, double x, double y);
148
152 vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
153 vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
154 vtkIdType InsertNextPoint(double x, double y);
155
159 void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
160
166 void SetNumberOfPoints(vtkIdType numPoints);
167
172 vtkTypeBool Resize(vtkIdType numPoints);
173
177 void GetPoints(vtkIdList* ptId, vtkPoints2D* fp);
178
182 virtual void ComputeBounds();
183
187 double* GetBounds() VTK_SIZEHINT(4);
188
192 void GetBounds(double bounds[4]);
193
194 protected:
195 vtkPoints2D(int dataType = VTK_FLOAT);
196 ~vtkPoints2D() override;
197
198 double Bounds[4];
199 vtkTimeStamp ComputeTime; // Time at which bounds computed
200 vtkDataArray* Data; // Array which represents data
201
202 private:
203 vtkPoints2D(const vtkPoints2D&) = delete;
204 void operator=(const vtkPoints2D&) = delete;
205 };
206
207 inline void vtkPoints2D::Reset()
208 {
209 this->Data->Reset();
210 this->Modified();
211 }
212
213 inline void vtkPoints2D::SetNumberOfPoints(vtkIdType numPoints)
214 {
215 this->Data->SetNumberOfComponents(2);
216 this->Data->SetNumberOfTuples(numPoints);
217 this->Modified();
218 }
219
220 inline vtkTypeBool vtkPoints2D::Resize(vtkIdType numPoints)
221 {
222 this->Data->SetNumberOfComponents(2);
223 this->Modified();
224 return this->Data->Resize(numPoints);
225 }
226
227 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
228 {
229 double p[2] = { x, y };
230 this->Data->SetTuple(id, p);
231 }
232
233 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
234 {
235 double p[2] = { x, y };
236 this->Data->InsertTuple(id, p);
237 }
238
239 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
240 {
241 double p[2] = { x, y };
242 return this->Data->InsertNextTuple(p);
243 }
244
245 VTK_ABI_NAMESPACE_END
246 #endif
vtkAbstractArray::Reset
void Reset()
Reset to an empty state, without freeing any memory.
Definition: vtkAbstractArray.h:312
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:32
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPoints2D
represent and manipulate 2D points
Definition: vtkPoints2D.h:26
vtkPoints2D::ShallowCopy
virtual void ShallowCopy(vtkPoints2D *ad)
Different ways to copy data.
vtkPoints2D::GetPoints
void GetPoints(vtkIdList *ptId, vtkPoints2D *fp)
Given a list of pt ids, return an array of points.
vtkPoints2D::GetPoint
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:125
vtkPoints2D::SetDataTypeToUnsignedLong
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:74
vtkPoints2D::ComputeBounds
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
vtkPoints2D::SetDataTypeToUnsignedChar
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:68
vtkPoints2D::New
static vtkPoints2D * New()
vtkPoints2D::SetDataTypeToShort
void SetDataTypeToShort()
Definition: vtkPoints2D.h:69
vtkPoints2D::Allocate
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
vtkPoints2D::SetDataType
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
vtkPoints2D::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPoints2D::GetData
vtkDataArray * GetData()
Definition: vtkPoints2D.h:54
vtkPoints2D::SetNumberOfPoints
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:213
vtkPoints2D::SetDataTypeToDouble
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:76
vtkPoints2D::SetDataTypeToFloat
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:75
vtkPoints2D::InsertNextPoint
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:153
vtkPoints2D::GetVoidPointer
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:82
vtkPoints2D::GetNumberOfPoints
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints2D.h:117
vtkPoints2D::RemovePoint
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:159
vtkPoints2D::GetPoint
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:130
vtkPoints2D::SetDataTypeToInt
void SetDataTypeToInt()
Definition: vtkPoints2D.h:71
vtkPoints2D::SetData
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
vtkPoints2D::SetDataTypeToBit
void SetDataTypeToBit()
Definition: vtkPoints2D.h:66
vtkPoints2D::InsertPoint
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:146
vtkPoints2D::Resize
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:220
vtkPoints2D::GetBounds
double * GetBounds()
Return the bounds of the points.
vtkPoints2D::New
static vtkPoints2D * New(int dataType)
vtkPoints2D::SetDataTypeToUnsignedInt
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:72
vtkPoints2D::GetDataType
virtual int GetDataType() const
Return the underlying data type.
vtkPoints2D::InsertPoint
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:145
vtkPoints2D::SetDataTypeToLong
void SetDataTypeToLong()
Definition: vtkPoints2D.h:73
vtkPoints2D::DeepCopy
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
vtkPoints2D::Squeeze
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:87
vtkPoints2D::SetPoint
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:138
vtkPoints2D::GetActualMemorySize
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
vtkPoints2D::SetDataTypeToUnsignedShort
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:70
vtkPoints2D::SetPoint
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:137
vtkPoints2D::Initialize
virtual void Initialize()
Return object to instantiated state.
vtkPoints2D::InsertNextPoint
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:152
vtkPoints2D::SetDataTypeToChar
void SetDataTypeToChar()
Definition: vtkPoints2D.h:67
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:34
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:26
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkDataArray.h
vtkObject.h
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:36
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:43
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
VTK_INT
#define VTK_INT
Definition: vtkType.h:38
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:42
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:33
VTK_UNSIGNED_LONG
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:41
VTK_BIT
#define VTK_BIT
Definition: vtkType.h:32
VTK_LONG
#define VTK_LONG
Definition: vtkType.h:40
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:36