VTK  9.1.0
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
31class vtkIdList;
32
33class VTKCOMMONCORE_EXPORT vtkPoints2D : public vtkObject
34{
35public:
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() const { 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
186
190 virtual void ComputeBounds();
191
196
200 void GetBounds(double bounds[4]);
201
202protected:
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
210private:
211 vtkPoints2D(const vtkPoints2D&) = delete;
212 void operator=(const vtkPoints2D&) = delete;
213};
214
215inline 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
235inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
236{
237 double p[2] = { x, y };
238 this->Data->SetTuple(id, p);
239}
240
241inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
242{
243 double p[2] = { x, y };
244 this->Data->InsertTuple(id, p);
245}
246
247inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
248{
249 double p[2] = { x, y };
250 return this->Data->InsertNextTuple(p);
251}
252
253#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
list of point or cell ids
Definition: vtkIdList.h:140
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:82
virtual void Modified()
Update the modification time for this object.
represent and manipulate 2D points
Definition: vtkPoints2D.h:34
virtual void ShallowCopy(vtkPoints2D *ad)
Different ways to copy data.
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.
static vtkPoints2D * New()
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:82
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax) bounds of points.
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:76
void SetDataTypeToShort()
Definition: vtkPoints2D.h:77
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
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:221
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints2D.h:90
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:84
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:83
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:161
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints2D.h:125
void RemovePoint(vtkIdType id)
Remove point described by its id.
Definition: vtkPoints2D.h:167
vtkDataArray * GetData()
Definition: vtkPoints2D.h:62
void GetPoint(vtkIdType id, double x[2])
Copy point components into user provided array v[2] for specified id.
Definition: vtkPoints2D.h:138
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[2] for a specific id.
Definition: vtkPoints2D.h:133
void SetDataTypeToInt()
Definition: vtkPoints2D.h:79
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void SetDataTypeToBit()
Definition: vtkPoints2D.h:74
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:154
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints2D.h:228
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:80
virtual int GetDataType() const
Return the underlying data type.
void InsertPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:153
void SetDataTypeToLong()
Definition: vtkPoints2D.h:81
virtual void DeepCopy(vtkPoints2D *ad)
Different ways to copy data.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints2D.h:95
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:146
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:78
void SetPoint(vtkIdType id, const float x[2])
Insert point into object.
Definition: vtkPoints2D.h:145
virtual void Initialize()
Return object to instantiated state.
vtkIdType InsertNextPoint(const float x[2])
Insert point into next available slot.
Definition: vtkPoints2D.h:160
void SetDataTypeToChar()
Definition: vtkPoints2D.h:75
record modification and/or execution time
Definition: vtkTimeStamp.h:52
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SHORT
Definition: vtkType.h:48
int vtkIdType
Definition: vtkType.h:332
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
#define VTK_DOUBLE
Definition: vtkType.h:55
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
#define VTK_INT
Definition: vtkType.h:50
#define VTK_FLOAT
Definition: vtkType.h:54
#define VTK_CHAR
Definition: vtkType.h:45
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:53
#define VTK_BIT
Definition: vtkType.h:44
#define VTK_LONG
Definition: vtkType.h:52
#define VTK_SIZEHINT(...)