VTK  9.2.6
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=========================================================================*/
29#ifndef vtkPoints_h
30#define vtkPoints_h
31
32#include "vtkCommonCoreModule.h" // For export macro
33#include "vtkObject.h"
34
35#include "vtkDataArray.h" // Needed for inline methods
36
37class vtkIdList;
38
39class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
40{
41public:
42 static vtkPoints* New(int dataType);
43
44 static vtkPoints* New();
45
46 vtkTypeMacro(vtkPoints, vtkObject);
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
53
57 virtual void Initialize();
58
67 virtual void SetData(vtkDataArray*);
68 vtkDataArray* GetData() { return this->Data; }
69
74 virtual int GetDataType() const;
75
80 virtual void SetDataType(int dataType);
81 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
82 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
83 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
84 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
85 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
86 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
87 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
88 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
89 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
90 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
91 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
92
97 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
98
102 virtual void Squeeze() { this->Data->Squeeze(); }
103
107 virtual void Reset();
108
110
115 virtual void DeepCopy(vtkPoints* ad);
116 virtual void ShallowCopy(vtkPoints* ad);
118
127 unsigned long GetActualMemorySize();
128
132 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
133
140 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
141 {
142 return this->Data->GetTuple(id);
143 }
144
149 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
150 VTK_SIZEHINT(3)
151 {
152 this->Data->GetTuple(id, x);
153 }
154
161 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
162 {
163 this->Data->SetTuple(id, x);
164 }
165 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
166 {
167 this->Data->SetTuple(id, x);
168 }
169 void SetPoint(vtkIdType id, double x, double y, double z)
170 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
171
173
177 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
178 {
179 this->Data->InsertTuple(id, x);
180 }
181 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
182 {
183 this->Data->InsertTuple(id, x);
184 }
185 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
187
194 {
195 this->Data->InsertTuples(dstIds, srcIds, source->Data);
196 }
197
204 {
205 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
206 }
207
211 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
212 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
213 vtkIdType InsertNextPoint(double x, double y, double z);
214
220 void SetNumberOfPoints(vtkIdType numPoints);
221
226 vtkTypeBool Resize(vtkIdType numPoints);
227
231 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
232
236 virtual void ComputeBounds();
237
242
246 void GetBounds(double bounds[6]);
247
251 vtkMTimeType GetMTime() override;
252
258 void Modified() override;
259
260protected:
261 vtkPoints(int dataType = VTK_FLOAT);
262 ~vtkPoints() override;
263
264 double Bounds[6];
265 vtkTimeStamp ComputeTime; // Time at which bounds computed
266 vtkDataArray* Data; // Array which represents data
267
268private:
269 vtkPoints(const vtkPoints&) = delete;
270 void operator=(const vtkPoints&) = delete;
271};
272
273inline void vtkPoints::Reset()
274{
275 this->Data->Reset();
276 this->Modified();
277}
278
280{
281 this->Data->SetNumberOfComponents(3);
282 this->Data->SetNumberOfTuples(numPoints);
283 this->Modified();
284}
285
287{
288 this->Data->SetNumberOfComponents(3);
289 this->Modified();
290 return this->Data->Resize(numPoints);
291}
292
293inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
294{
295 double p[3] = { x, y, z };
296 this->Data->SetTuple(id, p);
297}
298
299inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
300{
301 double p[3] = { x, y, z };
302 this->Data->InsertTuple(id, p);
303}
304
305inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
306{
307 double p[3] = { x, y, z };
308 return this->Data->InsertNextTuple(p);
309}
310
311#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:34
a simple class to control print indentation
Definition vtkIndent.h:40
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:40
void SetPoint(vtkIdType id, const double x[3])
Definition vtkPoints.h:165
void SetDataTypeToUnsignedShort()
Definition vtkPoints.h:85
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:161
void SetDataTypeToChar()
Definition vtkPoints.h:82
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:181
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition vtkPoints.h:86
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition vtkPoints.h:88
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:193
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:102
void SetDataTypeToUnsignedLong()
Definition vtkPoints.h:89
void SetDataTypeToUnsignedChar()
Definition vtkPoints.h:83
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition vtkPoints.h:68
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:140
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition vtkPoints.h:87
void * GetVoidPointer(const int id)
Return a void pointer.
Definition vtkPoints.h:97
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition vtkPoints.h:149
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition vtkPoints.h:84
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition vtkPoints.h:132
void SetDataTypeToDouble()
Definition vtkPoints.h:91
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:279
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition vtkPoints.h:286
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition vtkPoints.h:177
void SetDataTypeToBit()
Definition vtkPoints.h:81
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:211
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:203
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition vtkPoints.h:90
vtkIdType InsertNextPoint(const double x[3])
Definition vtkPoints.h:212
record modification and/or execution time
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)