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 =========================================================================*/
25 #ifndef vtkPoints2D_h
26 #define vtkPoints2D_h
27 
28 #include "vtkCommonCoreModule.h" // For export macro
29 #include "vtkObject.h"
30 
31 #include "vtkDataArray.h" // Needed for inline methods
32 
33 class vtkIdList;
34 
36 {
37 public:
38 //BTX
39  static vtkPoints2D *New(int dataType);
40 //ETX
41  static vtkPoints2D *New();
42 
43  vtkTypeMacro(vtkPoints2D, vtkObject);
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
47  virtual int Allocate(const vtkIdType sz, const vtkIdType ext = 1000);
48 
50  virtual void Initialize();
51 
53 
59  virtual void SetData(vtkDataArray *);
60  vtkDataArray *GetData() { return this->Data; }
62 
65  virtual int GetDataType();
66 
68 
69  virtual void SetDataType(int dataType);
70  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
71  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
72  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
73  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
74  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
75  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
76  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
77  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
78  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
79  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
80  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
82 
85  void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
86 
88  virtual void Squeeze() { this->Data->Squeeze(); }
89 
91  virtual void Reset();
92 
94 
97  virtual void DeepCopy(vtkPoints2D *ad);
98  virtual void ShallowCopy(vtkPoints2D *ad);
100 
107  unsigned long GetActualMemorySize();
108 
110  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
111 
116  double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);}
117 
119  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x); }
120 
122 
125  void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x); }
126  void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x); }
127  void SetPoint(vtkIdType id, double x, double y);
129 
131 
133  void InsertPoint(vtkIdType id, const float x[2])
134  { this->Data->InsertTuple(id,x); }
135  void InsertPoint(vtkIdType id, const double x[2])
136  { this->Data->InsertTuple(id,x); }
137  void InsertPoint(vtkIdType id, double x, double y);
139 
141 
142  vtkIdType InsertNextPoint(const float x[2])
143  { return this->Data->InsertNextTuple(x); }
144  vtkIdType InsertNextPoint(const double x[2])
145  { return this->Data->InsertNextTuple(x); }
146  vtkIdType InsertNextPoint(double x, double y);
148 
150  void RemovePoint(vtkIdType id) { this->Data->RemoveTuple(id); }
151 
155  void SetNumberOfPoints(vtkIdType numPoints);
156 
159  int Resize(vtkIdType numPoints);
160 
162  void GetPoints(vtkIdList *ptId, vtkPoints2D *fp);
163 
165  virtual void ComputeBounds();
166 
168  double *GetBounds();
169 
171  void GetBounds(double bounds[4]);
172 
173 protected:
174  vtkPoints2D(int dataType = VTK_FLOAT);
175  ~vtkPoints2D();
176 
177  double Bounds[4];
178  vtkTimeStamp ComputeTime; // Time at which bounds computed
179  vtkDataArray *Data; // Array which represents data
180 
181 private:
182  vtkPoints2D(const vtkPoints2D&); // Not implemented.
183  void operator=(const vtkPoints2D&); // Not implemented.
184 };
185 
186 inline void vtkPoints2D::Reset()
187 {
188  this->Data->Reset();
189  this->Modified();
190 }
191 
193 {
194  this->Data->SetNumberOfComponents(2);
195  this->Data->SetNumberOfTuples(numPoints);
196  this->Modified();
197 }
198 
199 inline int vtkPoints2D::Resize(vtkIdType numPoints)
200 {
201  this->Data->SetNumberOfComponents(2);
202  this->Modified();
203  return this->Data->Resize(numPoints);
204 }
205 
206 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
207 {
208  double p[2] = { x, y };
209  this->Data->SetTuple(id, p);
210 }
211 
212 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
213 {
214  double p[2] = { x, y };
215  this->Data->InsertTuple(id, p);
216 }
217 
218 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
219 {
220  double p[2] = { x, y };
221  return this->Data->InsertNextTuple(p);
222 }
223 
224 #endif
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:80
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:135
#define VTK_UNSIGNED_INT
Definition: vtkType.h:32
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual void Reset()
Definition: vtkPoints2D.h:186
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:30
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:72
void * GetVoidPointer(const int id)
Definition: vtkPoints2D.h:85
#define VTKCOMMONCORE_EXPORT
void InsertPoint(vtkIdType id, const float x[2])
Definition: vtkPoints2D.h:133
record modification and/or execution time
Definition: vtkTimeStamp.h:34
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkDataArray * GetData()
Definition: vtkPoints2D.h:60
virtual void SetNumberOfTuples(vtkIdType number)=0
int vtkIdType
Definition: vtkType.h:275
void GetPoint(vtkIdType id, double x[2])
Definition: vtkPoints2D.h:119
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:74
#define VTK_DOUBLE
Definition: vtkType.h:36
void SetNumberOfPoints(vtkIdType numPoints)
Definition: vtkPoints2D.h:192
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
#define VTK_FLOAT
Definition: vtkType.h:35
vtkTimeStamp ComputeTime
Definition: vtkPoints2D.h:178
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
represent and manipulate 2D points
Definition: vtkPoints2D.h:35
list of point or cell ids
Definition: vtkIdList.h:35
virtual int Resize(vtkIdType numTuples)=0
void SetPoint(vtkIdType id, const float x[2])
Definition: vtkPoints2D.h:125
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTK_SHORT
Definition: vtkType.h:29
#define VTK_CHAR
Definition: vtkType.h:26
#define VTK_LONG
Definition: vtkType.h:33
virtual void Modified()
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:76
virtual void Squeeze()
Definition: vtkPoints2D.h:88
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
vtkDataArray * Data
Definition: vtkPoints2D.h:179
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:126
int Resize(vtkIdType numPoints)
Definition: vtkPoints2D.h:199
virtual void SetNumberOfComponents(int)
double * GetPoint(vtkIdType id)
Definition: vtkPoints2D.h:116
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:28
vtkIdType InsertNextPoint(const float x[2])
Definition: vtkPoints2D.h:142
void SetDataTypeToInt()
Definition: vtkPoints2D.h:75
void RemovePoint(vtkIdType id)
Definition: vtkPoints2D.h:150
#define VTK_BIT
Definition: vtkType.h:25
void SetDataTypeToBit()
Definition: vtkPoints2D.h:70
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:34
vtkIdType GetNumberOfPoints()
Definition: vtkPoints2D.h:110
void SetDataTypeToChar()
Definition: vtkPoints2D.h:71
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:79
static vtkObject * New()
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:78
void SetDataTypeToShort()
Definition: vtkPoints2D.h:73
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:144
void SetDataTypeToLong()
Definition: vtkPoints2D.h:77
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
#define VTK_INT
Definition: vtkType.h:31