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 =========================================================================*/
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 
37  static vtkPoints2D *New(int dataType);
38 
39  static vtkPoints2D *New();
40 
41  vtkTypeMacro(vtkPoints2D, vtkObject);
42  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
43 
47  virtual int Allocate(const vtkIdType sz, const vtkIdType ext = 1000);
48 
52  virtual void Initialize();
53 
62  virtual void SetData(vtkDataArray *);
63  vtkDataArray *GetData() { return this->Data; }
64 
69  virtual int GetDataType();
70 
74  virtual void SetDataType(int dataType);
75  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
76  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
77  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
78  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
79  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
80  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
81  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
82  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
83  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
84  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
85  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
86 
91  void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
92 
96  virtual void Squeeze() { this->Data->Squeeze(); }
97 
101  virtual void Reset();
102 
104 
109  virtual void DeepCopy(vtkPoints2D *ad);
110  virtual void ShallowCopy(vtkPoints2D *ad);
112 
121  unsigned long GetActualMemorySize();
122 
126  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
127 
134  double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);}
135 
139  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x); }
140 
146  void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x); }
147  void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x); }
148  void SetPoint(vtkIdType id, double x, double y);
149 
154  void InsertPoint(vtkIdType id, const float x[2])
155  { this->Data->InsertTuple(id,x); }
156  void InsertPoint(vtkIdType id, const double x[2])
157  { this->Data->InsertTuple(id,x); }
158  void InsertPoint(vtkIdType id, double x, double y);
159 
163  vtkIdType InsertNextPoint(const float x[2])
164  { return this->Data->InsertNextTuple(x); }
165  vtkIdType InsertNextPoint(const double x[2])
166  { return this->Data->InsertNextTuple(x); }
167  vtkIdType InsertNextPoint(double x, double y);
168 
172  void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
173 
179  void SetNumberOfPoints(vtkIdType numPoints);
180 
185  int Resize(vtkIdType numPoints);
186 
190  void GetPoints(vtkIdList *ptId, vtkPoints2D *fp);
191 
195  virtual void ComputeBounds();
196 
200  double *GetBounds();
201 
205  void GetBounds(double bounds[4]);
206 
207 protected:
208  vtkPoints2D(int dataType = VTK_FLOAT);
209  ~vtkPoints2D() VTK_OVERRIDE;
210 
211  double Bounds[4];
212  vtkTimeStamp ComputeTime; // Time at which bounds computed
213  vtkDataArray *Data; // Array which represents data
214 
215 private:
216  vtkPoints2D(const vtkPoints2D&) VTK_DELETE_FUNCTION;
217  void operator=(const vtkPoints2D&) VTK_DELETE_FUNCTION;
218 };
219 
220 inline void vtkPoints2D::Reset()
221 {
222  this->Data->Reset();
223  this->Modified();
224 }
225 
227 {
228  this->Data->SetNumberOfComponents(2);
229  this->Data->SetNumberOfTuples(numPoints);
230  this->Modified();
231 }
232 
233 inline int vtkPoints2D::Resize(vtkIdType numPoints)
234 {
235  this->Data->SetNumberOfComponents(2);
236  this->Modified();
237  return this->Data->Resize(numPoints);
238 }
239 
240 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
241 {
242  double p[2] = { x, y };
243  this->Data->SetTuple(id, p);
244 }
245 
246 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
247 {
248  double p[2] = { x, y };
249  this->Data->InsertTuple(id, p);
250 }
251 
252 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
253 {
254  double p[2] = { x, y };
255  return this->Data->InsertNextTuple(p);
256 }
257 
258 #endif
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:85
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:156
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
abstract base class for most VTK objects
Definition: vtkObject.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:77
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:91
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:154
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkDataArray * GetData()
Definition: vtkPoints2D.h:63
int vtkIdType
Definition: vtkType.h:345
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:139
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:79
#define VTK_DOUBLE
Definition: vtkType.h:59
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:226
#define VTK_FLOAT
Definition: vtkType.h:58
a simple class to control print indentation
Definition: vtkIndent.h:33
represent and manipulate 2D points
Definition: vtkPoints2D.h:33
list of point or cell ids
Definition: vtkIdList.h:30
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:146
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
#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:81
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:96
void Reset()
Reset to an empty state, without freeing any memory.
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:147
int Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:233
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:134
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:163
void SetDataTypeToInt()
Definition: vtkPoints2D.h:80
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:172
#define VTK_BIT
Definition: vtkType.h:48
void SetDataTypeToBit()
Definition: vtkPoints2D.h:75
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:57
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints2D.h:126
void SetDataTypeToChar()
Definition: vtkPoints2D.h:76
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:84
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:83
void SetDataTypeToShort()
Definition: vtkPoints2D.h:78
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:165
void SetDataTypeToLong()
Definition: vtkPoints2D.h:82
#define VTK_INT
Definition: vtkType.h:54