VTK  9.1.0
vtkPoints.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkPoints.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 vtkPoints_h
24#define vtkPoints_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 vtkPoints : public vtkObject
34{
35public:
36 static vtkPoints* New(int dataType);
37
38 static vtkPoints* New();
39
40 vtkTypeMacro(vtkPoints, 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
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(vtkPoints* ad);
110 virtual void ShallowCopy(vtkPoints* ad);
112
121 unsigned long GetActualMemorySize();
122
126 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
127
134 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
135 {
136 return this->Data->GetTuple(id);
137 }
138
143 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
144 VTK_SIZEHINT(3)
145 {
146 this->Data->GetTuple(id, x);
147 }
148
155 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
156 {
157 this->Data->SetTuple(id, x);
158 }
159 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
160 {
161 this->Data->SetTuple(id, x);
162 }
163 void SetPoint(vtkIdType id, double x, double y, double z)
164 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
165
167
171 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
172 {
173 this->Data->InsertTuple(id, x);
174 }
175 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
176 {
177 this->Data->InsertTuple(id, x);
178 }
179 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
181
188 {
189 this->Data->InsertTuples(dstIds, srcIds, source->Data);
190 }
191
198 {
199 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
200 }
201
205 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
206 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
207 vtkIdType InsertNextPoint(double x, double y, double z);
208
214 void SetNumberOfPoints(vtkIdType numPoints);
215
220 vtkTypeBool Resize(vtkIdType numPoints);
221
225 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
226
230 virtual void ComputeBounds();
231
236
240 void GetBounds(double bounds[6]);
241
245 vtkMTimeType GetMTime() override;
246
252 void Modified() override;
253
254protected:
255 vtkPoints(int dataType = VTK_FLOAT);
256 ~vtkPoints() override;
257
258 double Bounds[6];
259 vtkTimeStamp ComputeTime; // Time at which bounds computed
260 vtkDataArray* Data; // Array which represents data
261
262private:
263 vtkPoints(const vtkPoints&) = delete;
264 void operator=(const vtkPoints&) = delete;
265};
266
267inline void vtkPoints::Reset()
268{
269 this->Data->Reset();
270 this->Modified();
271}
272
274{
275 this->Data->SetNumberOfComponents(3);
276 this->Data->SetNumberOfTuples(numPoints);
277 this->Modified();
278}
279
281{
282 this->Data->SetNumberOfComponents(3);
283 this->Modified();
284 return this->Data->Resize(numPoints);
285}
286
287inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
288{
289 double p[3] = { x, y, z };
290 this->Data->SetTuple(id, p);
291}
292
293inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
294{
295 double p[3] = { x, y, z };
296 this->Data->InsertTuple(id, p);
297}
298
299inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
300{
301 double p[3] = { x, y, z };
302 return this->Data->InsertNextTuple(p);
303}
304
305#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:34
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:159
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:79
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:155
void SetDataTypeToChar()
Definition: vtkPoints.h:76
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:175
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:80
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition: vtkPoints.h:82
void InsertPoints(vtkIdList *dstIds, vtkIdList *srcIds, vtkPoints *source)
Copy the points indexed in srcIds from the source array to the tuple locations indexed by dstIds in t...
Definition: vtkPoints.h:187
double * GetBounds()
Return the bounds of the points.
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:96
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:83
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:77
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition: vtkPoints.h:62
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:134
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:81
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:91
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:143
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:78
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:126
void SetDataTypeToDouble()
Definition: vtkPoints.h:85
virtual void DeepCopy(vtkPoints *ad)
Different ways to copy data.
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:273
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:280
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:171
void SetDataTypeToBit()
Definition: vtkPoints.h:75
static vtkPoints * New()
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
virtual void ShallowCopy(vtkPoints *ad)
Different ways to copy data.
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:205
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Copy n consecutive points starting at srcStart from the source array to this array,...
Definition: vtkPoints.h:197
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition: vtkPoints.h:84
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:206
record modification and/or execution time
Definition: vtkTimeStamp.h:33
int vtkTypeBool
Definition: vtkABI.h:69
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#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
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#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(...)
#define VTK_EXPECTS(x)