VTK  9.3.20240328
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 
214 {
215  this->Data->SetNumberOfComponents(2);
216  this->Data->SetNumberOfTuples(numPoints);
217  this->Modified();
218 }
219 
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
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
list of point or cell ids
Definition: vtkIdList.h:132
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
virtual void Modified()
Update the modification time for this object.
represent and manipulate 2D points
Definition: vtkPoints2D.h:26
virtual void ShallowCopy(vtkPoints2D *ad)
Different ways to copy data.
void GetPoints(vtkIdList *ptId, vtkPoints2D *fp)
Given a list of pt ids, return an array of points.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:125
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:74
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:68
static vtkPoints2D * New()
void SetDataTypeToShort()
Definition: vtkPoints2D.h:69
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.
vtkDataArray * GetData()
Definition: vtkPoints2D.h:54
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:213
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:76
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:75
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:153
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:82
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints2D.h:117
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:159
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:130
void SetDataTypeToInt()
Definition: vtkPoints2D.h:71
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition: vtkPoints2D.h:66
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:146
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:220
double * GetBounds()
Return the bounds of the points.
static vtkPoints2D * New(int dataType)
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:72
virtual int GetDataType() const
Return the underlying data type.
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:145
void SetDataTypeToLong()
Definition: vtkPoints2D.h:73
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:87
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:138
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:70
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:137
virtual void Initialize()
Return object to instantiated state.
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:152
void SetDataTypeToChar()
Definition: vtkPoints2D.h:67
record modification and/or execution time
Definition: vtkTimeStamp.h:44
void GetBounds(T a, double bds[6])
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(...)