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
34class vtkIdList;
35
36class VTKCOMMONCORE_EXPORT vtkPoints2D : public vtkObject
37{
38public:
39
40 static vtkPoints2D *New(int dataType);
41
42 static vtkPoints2D *New();
43
44 vtkTypeMacro(vtkPoints2D, vtkObject);
45 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
46
50 virtual int Allocate(const vtkIdType sz, const 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) { 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 int Resize(vtkIdType numPoints);
189
194
198 virtual void ComputeBounds();
199
203 double *GetBounds();
204
208 void GetBounds(double bounds[4]);
209
210protected:
211 vtkPoints2D(int dataType = VTK_FLOAT);
212 ~vtkPoints2D() VTK_OVERRIDE;
213
214 double Bounds[4];
215 vtkTimeStamp ComputeTime; // Time at which bounds computed
216 vtkDataArray *Data; // Array which represents data
217
218private:
219 vtkPoints2D(const vtkPoints2D&) VTK_DELETE_FUNCTION;
220 void operator=(const vtkPoints2D&) VTK_DELETE_FUNCTION;
221};
222
223inline 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
236inline int vtkPoints2D::Resize(vtkIdType numPoints)
237{
238 this->Data->SetNumberOfComponents(2);
239 this->Modified();
240 return this->Data->Resize(numPoints);
241}
242
243inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
244{
245 double p[2] = { x, y };
246 this->Data->SetTuple(id, p);
247}
248
249inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
250{
251 double p[2] = { x, y };
252 this->Data->InsertTuple(id, p);
253}
254
255inline 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 Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
virtual void Modified()
Update the modification time for this object.
represent and manipulate 2D points
Definition: vtkPoints2D.h:37
virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000)
Allocate initial memory size.
virtual void ShallowCopy(vtkPoints2D *ad)
double * GetBounds()
Return the bounds of the points.
void GetPoints(vtkIdList *ptId, vtkPoints2D *fp)
Given a list of pt ids, return an array of points.
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints2D.h:129
static vtkPoints2D * New()
~vtkPoints2D() override
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:86
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:80
void SetDataTypeToShort()
Definition: vtkPoints2D.h:81
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.
static vtkPoints2D * New(int dataType)
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints2D.h:229
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:94
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:88
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:87
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:168
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:175
vtkPoints2D(int dataType=VTK_FLOAT)
vtkDataArray * GetData()
Definition: vtkPoints2D.h:66
int Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:236
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:142
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:137
void SetDataTypeToInt()
Definition: vtkPoints2D.h:83
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition: vtkPoints2D.h:78
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:159
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:84
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:157
virtual int GetDataType()
Return the underlying data type.
void GetBounds(double bounds[4])
Return the bounds of the points.
void SetDataTypeToLong()
Definition: vtkPoints2D.h:85
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:99
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:150
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:82
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:149
virtual void Initialize()
Return object to instantiated state.
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:166
void SetDataTypeToChar()
Definition: vtkPoints2D.h:79
record modification and/or execution time
Definition: vtkTimeStamp.h:36
#define VTK_SHORT
Definition: vtkType.h:52
int vtkIdType
Definition: vtkType.h:287
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
#define VTK_DOUBLE
Definition: vtkType.h:59
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
#define VTK_INT
Definition: vtkType.h:54
#define VTK_FLOAT
Definition: vtkType.h:58
#define VTK_CHAR
Definition: vtkType.h:49
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:57
#define VTK_BIT
Definition: vtkType.h:48
#define VTK_LONG
Definition: vtkType.h:56