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=========================================================================*/
32#ifndef vtkPoints_h
33#define vtkPoints_h
34
35#include "vtkCommonCoreModule.h" // For export macro
36#include "vtkObject.h"
37
38#include "vtkDataArray.h" // Needed for inline methods
39
40class vtkIdList;
41
42class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
43{
44public:
45 static vtkPoints* New(int dataType);
46
47 static vtkPoints* New();
48
49 vtkTypeMacro(vtkPoints, vtkObject);
50 void PrintSelf(ostream& os, vtkIndent indent) override;
51
55 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
56
60 virtual void Initialize();
61
70 virtual void SetData(vtkDataArray*);
71 vtkDataArray* GetData() { return this->Data; }
72
77 virtual int GetDataType() const;
78
83 virtual void SetDataType(int dataType);
84 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
85 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
86 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
87 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
88 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
89 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
90 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
91 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
92 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
93 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
94 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
95
100 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
101
105 virtual void Squeeze() { this->Data->Squeeze(); }
106
110 virtual void Reset();
111
113
118 virtual void DeepCopy(vtkPoints* ad);
119 virtual void ShallowCopy(vtkPoints* ad);
121
130 unsigned long GetActualMemorySize();
131
135 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
136
143 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
144 {
145 return this->Data->GetTuple(id);
146 }
147
152 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
153 VTK_SIZEHINT(3)
154 {
155 this->Data->GetTuple(id, x);
156 }
157
164 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
165 {
166 this->Data->SetTuple(id, x);
167 }
168 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
169 {
170 this->Data->SetTuple(id, x);
171 }
172 void SetPoint(vtkIdType id, double x, double y, double z)
173 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
174
176
180 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
181 {
182 this->Data->InsertTuple(id, x);
183 }
184 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
185 {
186 this->Data->InsertTuple(id, x);
187 }
188 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
190
197 {
198 this->Data->InsertTuples(dstIds, srcIds, source->Data);
199 }
200
207 {
208 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
209 }
210
214 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
215 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
216 vtkIdType InsertNextPoint(double x, double y, double z);
217
223 void SetNumberOfPoints(vtkIdType numPoints);
224
229 vtkTypeBool Resize(vtkIdType numPoints);
230
234 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
235
239 virtual void ComputeBounds();
240
245
249 void GetBounds(double bounds[6]);
250
254 vtkMTimeType GetMTime() override;
255
261 void Modified() override;
262
263protected:
264 vtkPoints(int dataType = VTK_FLOAT);
265 ~vtkPoints() override;
266
267 double Bounds[6];
268 vtkTimeStamp ComputeTime; // Time at which bounds computed
269 vtkDataArray* Data; // Array which represents data
270
271private:
272 vtkPoints(const vtkPoints&) = delete;
273 void operator=(const vtkPoints&) = delete;
274};
275
276inline void vtkPoints::Reset()
277{
278 this->Data->Reset();
279 this->Modified();
280}
281
283{
284 this->Data->SetNumberOfComponents(3);
285 this->Data->SetNumberOfTuples(numPoints);
286 this->Modified();
287}
288
290{
291 this->Data->SetNumberOfComponents(3);
292 this->Modified();
293 return this->Data->Resize(numPoints);
294}
295
296inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
297{
298 double p[3] = { x, y, z };
299 this->Data->SetTuple(id, p);
300}
301
302inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
303{
304 double p[3] = { x, y, z };
305 this->Data->InsertTuple(id, p);
306}
307
308inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
309{
310 double p[3] = { x, y, z };
311 return this->Data->InsertNextTuple(p);
312}
313
314#endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:59
list of point or cell ids
Definition: vtkIdList.h:40
a simple class to control print indentation
Definition: vtkIndent.h:43
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:43
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:168
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:88
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:164
void SetDataTypeToChar()
Definition: vtkPoints.h:85
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:184
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:89
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition: vtkPoints.h:91
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:196
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:105
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:92
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:86
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition: vtkPoints.h:71
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:143
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:90
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:100
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:152
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:87
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:135
void SetDataTypeToDouble()
Definition: vtkPoints.h:94
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:282
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:289
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:180
void SetDataTypeToBit()
Definition: vtkPoints.h:84
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:214
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:206
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition: vtkPoints.h:93
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:215
record modification and/or execution time
Definition: vtkTimeStamp.h:42
void GetBounds(T a, double bds[6])
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)