VTK  9.0.20200809
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 =========================================================================*/
23 #ifndef vtkPoints2D_h
24 #define vtkPoints2D_h
25 
26 #include "vtkCommonCoreModule.h" // For export macro
27 #include "vtkObject.h"
28 
29 #include "vtkDataArray.h" // Needed for inline methods
30 
31 class vtkIdList;
32 
33 class VTKCOMMONCORE_EXPORT vtkPoints2D : public vtkObject
34 {
35 public:
36  static vtkPoints2D* New(int dataType);
37 
38  static vtkPoints2D* New();
39 
40  vtkTypeMacro(vtkPoints2D, vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
46  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
47 
51  virtual void Initialize();
52 
61  virtual void SetData(vtkDataArray*);
62  vtkDataArray* GetData() { return this->Data; }
63 
68  virtual int GetDataType() const;
69 
73  virtual void SetDataType(int dataType);
74  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
75  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
76  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
77  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
78  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
79  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
80  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
81  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
82  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
83  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
84  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
85 
90  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
91 
95  virtual void Squeeze() { this->Data->Squeeze(); }
96 
100  virtual void Reset();
101 
103 
108  virtual void DeepCopy(vtkPoints2D* ad);
109  virtual void ShallowCopy(vtkPoints2D* ad);
111 
120  unsigned long GetActualMemorySize();
121 
125  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
126 
133  double* GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id); }
134 
138  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id, x); }
139 
145  void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id, x); }
146  void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id, x); }
147  void SetPoint(vtkIdType id, double x, double y);
148 
153  void InsertPoint(vtkIdType id, const float x[2]) { this->Data->InsertTuple(id, x); }
154  void InsertPoint(vtkIdType id, const double x[2]) { this->Data->InsertTuple(id, x); }
155  void InsertPoint(vtkIdType id, double x, double y);
156 
160  vtkIdType InsertNextPoint(const float x[2]) { return this->Data->InsertNextTuple(x); }
161  vtkIdType InsertNextPoint(const double x[2]) { return this->Data->InsertNextTuple(x); }
162  vtkIdType InsertNextPoint(double x, double y);
163 
167  void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
168 
174  void SetNumberOfPoints(vtkIdType numPoints);
175 
180  vtkTypeBool Resize(vtkIdType numPoints);
181 
185  void GetPoints(vtkIdList* ptId, vtkPoints2D* fp);
186 
190  virtual void ComputeBounds();
191 
195  double* GetBounds() VTK_SIZEHINT(4);
196 
200  void GetBounds(double bounds[4]);
201 
202 protected:
203  vtkPoints2D(int dataType = VTK_FLOAT);
204  ~vtkPoints2D() override;
205 
206  double Bounds[4];
207  vtkTimeStamp ComputeTime; // Time at which bounds computed
208  vtkDataArray* Data; // Array which represents data
209 
210 private:
211  vtkPoints2D(const vtkPoints2D&) = delete;
212  void operator=(const vtkPoints2D&) = delete;
213 };
214 
215 inline void vtkPoints2D::Reset()
216 {
217  this->Data->Reset();
218  this->Modified();
219 }
220 
222 {
223  this->Data->SetNumberOfComponents(2);
224  this->Data->SetNumberOfTuples(numPoints);
225  this->Modified();
226 }
227 
229 {
230  this->Data->SetNumberOfComponents(2);
231  this->Modified();
232  return this->Data->Resize(numPoints);
233 }
234 
235 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
236 {
237  double p[2] = { x, y };
238  this->Data->SetTuple(id, p);
239 }
240 
241 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
242 {
243  double p[2] = { x, y };
244  this->Data->InsertTuple(id, p);
245 }
246 
247 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
248 {
249  double p[2] = { x, y };
250  return this->Data->InsertNextTuple(p);
251 }
252 
253 #endif
vtkPoints2D
represent and manipulate 2D points
Definition: vtkPoints2D.h:33
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkPoints2D::Resize
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:228
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
vtkPoints2D::InsertPoint
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:153
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkPoints2D::GetData
vtkDataArray * GetData()
Definition: vtkPoints2D.h:62
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPoints2D::SetDataTypeToUnsignedChar
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:76
vtkPoints2D::GetVoidPointer
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:90
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkPoints2D::SetDataTypeToUnsignedShort
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:78
vtkPoints2D::SetNumberOfPoints
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:221
vtkPoints2D::GetPoint
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:138
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkAbstractArray::Reset
void Reset()
Reset to an empty state, without freeing any memory.
Definition: vtkAbstractArray.h:304
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:54
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:55
vtkPoints2D::Squeeze
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:95
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
vtkPoints2D::SetPoint
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:145
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_LONG
#define VTK_LONG
Definition: vtkType.h:52
vtkPoints2D::GetPoint
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:133
vtkPoints2D::SetDataTypeToUnsignedInt
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:80
vtkObject.h
VTK_UNSIGNED_LONG
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:53
vtkPoints2D::InsertNextPoint
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:160
vtkPoints2D::SetPoint
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:146
vtkPoints2D::RemovePoint
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:167
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:48
vtkDataArray.h
vtkPoints2D::SetDataTypeToInt
void SetDataTypeToInt()
Definition: vtkPoints2D.h:79
vtkPoints2D::GetNumberOfPoints
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints2D.h:125
vtkPoints2D::SetDataTypeToFloat
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:83
vtkPoints2D::SetDataTypeToShort
void SetDataTypeToShort()
Definition: vtkPoints2D.h:77
vtkPoints2D::InsertNextPoint
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:161
vtkPoints2D::SetDataTypeToBit
void SetDataTypeToBit()
Definition: vtkPoints2D.h:74
VTK_BIT
#define VTK_BIT
Definition: vtkType.h:44
VTK_INT
#define VTK_INT
Definition: vtkType.h:50
vtkPoints2D::SetDataTypeToChar
void SetDataTypeToChar()
Definition: vtkPoints2D.h:75
vtkPoints2D::SetDataTypeToUnsignedLong
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:82
vtkPoints2D::SetDataTypeToLong
void SetDataTypeToLong()
Definition: vtkPoints2D.h:81
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints2D::SetDataTypeToDouble
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:84
vtkPoints2D::InsertPoint
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:154