VTK  9.2.20220815
vtkPoints2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPoints2D.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef vtkPoints2D_h
27 #define vtkPoints2D_h
28 
29 #include "vtkCommonCoreModule.h" // For export macro
30 #include "vtkObject.h"
31 
32 #include "vtkDataArray.h" // Needed for inline methods
33 
34 class vtkIdList;
35 
36 class VTKCOMMONCORE_EXPORT vtkPoints2D : public vtkObject
37 {
38 public:
39  static vtkPoints2D* New(int dataType);
40 
41  static vtkPoints2D* New();
42 
43  vtkTypeMacro(vtkPoints2D, vtkObject);
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
49  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
50 
54  virtual void Initialize();
55 
64  virtual void SetData(vtkDataArray*);
65  vtkDataArray* GetData() { return this->Data; }
66 
71  virtual int GetDataType() const;
72 
76  virtual void SetDataType(int dataType);
77  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
78  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
79  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
80  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
81  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
82  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
83  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
84  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
85  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
86  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
87  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
88 
93  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
94 
98  virtual void Squeeze() { this->Data->Squeeze(); }
99 
103  virtual void Reset();
104 
106 
111  virtual void DeepCopy(vtkPoints2D* ad);
112  virtual void ShallowCopy(vtkPoints2D* ad);
114 
123  unsigned long GetActualMemorySize();
124 
128  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
129 
136  double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
137 
141  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
142 
148  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); }
150  void SetPoint(vtkIdType id, double x, double y);
151 
156  void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
157  void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
158  void InsertPoint(vtkIdType id, double x, double y);
159 
163  vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
164  vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
165  vtkIdType InsertNextPoint(double x, double y);
166 
170  void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
171 
177  void SetNumberOfPoints(vtkIdType numPoints);
178 
183  vtkTypeBool Resize(vtkIdType numPoints);
184 
188  void GetPoints(vtkIdList* ptId, vtkPoints2D* fp);
189 
193  virtual void ComputeBounds();
194 
198  double* GetBounds() VTK_SIZEHINT(4);
199 
203  void GetBounds(double bounds[4]);
204 
205 protected:
206  vtkPoints2D(int dataType = VTK_FLOAT);
207  ~vtkPoints2D() override;
208 
209  double Bounds[4];
210  vtkTimeStamp ComputeTime; // Time at which bounds computed
211  vtkDataArray* Data; // Array which represents data
212 
213 private:
214  vtkPoints2D(const vtkPoints2D&) = delete;
215  void operator=(const vtkPoints2D&) = delete;
216 };
217 
218 inline void vtkPoints2D::Reset()
219 {
220  this->Data->Reset();
221  this->Modified();
222 }
223 
225 {
226  this->Data->SetNumberOfComponents(2);
227  this->Data->SetNumberOfTuples(numPoints);
228  this->Modified();
229 }
230 
232 {
233  this->Data->SetNumberOfComponents(2);
234  this->Modified();
235  return this->Data->Resize(numPoints);
236 }
237 
238 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
239 {
240  double p[2] = { x, y };
241  this->Data->SetTuple(id, p);
242 }
243 
244 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
245 {
246  double p[2] = { x, y };
247  this->Data->InsertTuple(id, p);
248 }
249 
250 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
251 {
252  double p[2] = { x, y };
253  return this->Data->InsertNextTuple(p);
254 }
255 
256 #endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
list of point or cell ids
Definition: vtkIdList.h:143
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
virtual void Modified()
Update the modification time for this object.
represent and manipulate 2D points
Definition: vtkPoints2D.h:37
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:136
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:85
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:79
static vtkPoints2D * New()
void SetDataTypeToShort()
Definition: vtkPoints2D.h:80
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:65
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:224
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:87
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:86
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:164
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:93
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints2D.h:128
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:170
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:141
void SetDataTypeToInt()
Definition: vtkPoints2D.h:82
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition: vtkPoints2D.h:77
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:157
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:231
double * GetBounds()
Return the bounds of the points.
static vtkPoints2D * New(int dataType)
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:83
virtual int GetDataType() const
Return the underlying data type.
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:156
void SetDataTypeToLong()
Definition: vtkPoints2D.h:84
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:98
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:149
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:81
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:148
virtual void Initialize()
Return object to instantiated state.
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:163
void SetDataTypeToChar()
Definition: vtkPoints2D.h:78
record modification and/or execution time
Definition: vtkTimeStamp.h:55
void GetBounds(T a, double bds[6])
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SHORT
Definition: vtkType.h:47
int vtkIdType
Definition: vtkType.h:325
#define VTK_UNSIGNED_INT
Definition: vtkType.h:50
#define VTK_DOUBLE
Definition: vtkType.h:54
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:46
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:48
#define VTK_INT
Definition: vtkType.h:49
#define VTK_FLOAT
Definition: vtkType.h:53
#define VTK_CHAR
Definition: vtkType.h:44
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:52
#define VTK_BIT
Definition: vtkType.h:43
#define VTK_LONG
Definition: vtkType.h:51
#define VTK_SIZEHINT(...)