VTK
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 
40  static vtkPoints2D *New(int dataType);
41 
42  static vtkPoints2D *New();
43 
44  vtkTypeMacro(vtkPoints2D, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
50  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
51 
55  virtual void Initialize();
56 
65  virtual void SetData(vtkDataArray *);
66  vtkDataArray *GetData() { return this->Data; }
67 
72  virtual int GetDataType();
73 
77  virtual void SetDataType(int dataType);
78  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
79  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
80  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
81  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
82  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
83  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
84  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
85  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
86  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
87  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
88  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
89 
94  void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
95 
99  virtual void Squeeze() { this->Data->Squeeze(); }
100 
104  virtual void Reset();
105 
107 
112  virtual void DeepCopy(vtkPoints2D *ad);
113  virtual void ShallowCopy(vtkPoints2D *ad);
115 
124  unsigned long GetActualMemorySize();
125 
129  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
130 
137  double *GetPoint(vtkIdType id) VTK_SIZEHINT(2) { return this->Data->GetTuple(id);}
138 
142  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x); }
143 
149  void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x); }
150  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])
158  { this->Data->InsertTuple(id,x); }
159  void InsertPoint(vtkIdType id, const double x[2])
160  { this->Data->InsertTuple(id,x); }
161  void InsertPoint(vtkIdType id, double x, double y);
162 
166  vtkIdType InsertNextPoint(const float x[2])
167  { return this->Data->InsertNextTuple(x); }
168  vtkIdType InsertNextPoint(const double x[2])
169  { return this->Data->InsertNextTuple(x); }
170  vtkIdType InsertNextPoint(double x, double y);
171 
175  void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
176 
182  void SetNumberOfPoints(vtkIdType numPoints);
183 
188  vtkTypeBool Resize(vtkIdType numPoints);
189 
193  void GetPoints(vtkIdList *ptId, vtkPoints2D *fp);
194 
198  virtual void ComputeBounds();
199 
203  double *GetBounds() VTK_SIZEHINT(4);
204 
208  void GetBounds(double bounds[4]);
209 
210 protected:
211  vtkPoints2D(int dataType = VTK_FLOAT);
212  ~vtkPoints2D() override;
213 
214  double Bounds[4];
215  vtkTimeStamp ComputeTime; // Time at which bounds computed
216  vtkDataArray *Data; // Array which represents data
217 
218 private:
219  vtkPoints2D(const vtkPoints2D&) = delete;
220  void operator=(const vtkPoints2D&) = delete;
221 };
222 
223 inline void vtkPoints2D::Reset()
224 {
225  this->Data->Reset();
226  this->Modified();
227 }
228 
230 {
231  this->Data->SetNumberOfComponents(2);
232  this->Data->SetNumberOfTuples(numPoints);
233  this->Modified();
234 }
235 
237 {
238  this->Data->SetNumberOfComponents(2);
239  this->Modified();
240  return this->Data->Resize(numPoints);
241 }
242 
243 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
244 {
245  double p[2] = { x, y };
246  this->Data->SetTuple(id, p);
247 }
248 
249 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
250 {
251  double p[2] = { x, y };
252  this->Data->InsertTuple(id, p);
253 }
254 
255 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
256 {
257  double p[2] = { x, y };
258  return this->Data->InsertNextTuple(p);
259 }
260 
261 #endif
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:88
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:159
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:236
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void Reset()
Make object look empty but do not delete memory.
Definition: vtkPoints2D.h:223
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:80
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:94
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:157
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkDataArray * GetData()
Definition: vtkPoints2D.h:66
int vtkIdType
Definition: vtkType.h:347
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:142
int vtkTypeBool
Definition: vtkABI.h:69
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:82
#define VTK_DOUBLE
Definition: vtkType.h:59
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:229
#define VTK_FLOAT
Definition: vtkType.h:58
vtkTimeStamp ComputeTime
Definition: vtkPoints2D.h:215
a simple class to control print indentation
Definition: vtkIndent.h:39
represent and manipulate 2D points
Definition: vtkPoints2D.h:36
list of point or cell ids
Definition: vtkIdList.h:36
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:149
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTK_SHORT
Definition: vtkType.h:52
#define VTK_CHAR
Definition: vtkType.h:49
#define VTK_LONG
Definition: vtkType.h:56
virtual void Modified()
Update the modification time for this object.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:84
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:99
#define VTK_SIZEHINT(...)
vtkDataArray * Data
Definition: vtkPoints2D.h:216
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:150
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:137
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:166
void SetDataTypeToInt()
Definition: vtkPoints2D.h:83
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:175
#define VTK_BIT
Definition: vtkType.h:48
void SetDataTypeToBit()
Definition: vtkPoints2D.h:78
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:57
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints2D.h:129
void SetDataTypeToChar()
Definition: vtkPoints2D.h:79
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:87
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:86
void SetDataTypeToShort()
Definition: vtkPoints2D.h:81
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:168
void SetDataTypeToLong()
Definition: vtkPoints2D.h:85
#define VTK_INT
Definition: vtkType.h:54