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=========================================================================*/
132#ifndef vtkPoints_h
133#define vtkPoints_h
134
135#include "vtkCommonCoreModule.h" // For export macro
136#include "vtkObject.h"
137
138#include "vtkDataArray.h" // Needed for inline methods
139
140class vtkIdList;
141
142class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
143{
144public:
145 static vtkPoints* New(int dataType);
146
147 static vtkPoints* New();
148
149 vtkTypeMacro(vtkPoints, vtkObject);
150 void PrintSelf(ostream& os, vtkIndent indent) override;
151
155 virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
156
160 virtual void Initialize();
161
170 virtual void SetData(vtkDataArray*);
171 vtkDataArray* GetData() { return this->Data; }
172
177 virtual int GetDataType() const;
178
183 virtual void SetDataType(int dataType);
184 void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
185 void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
186 void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
187 void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
188 void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
189 void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
190 void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
191 void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
192 void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
193 void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
194 void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
195
200 void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
201
205 virtual void Squeeze() { this->Data->Squeeze(); }
206
210 virtual void Reset();
211
213
218 virtual void DeepCopy(vtkPoints* ad);
219 virtual void ShallowCopy(vtkPoints* ad);
221
230 unsigned long GetActualMemorySize();
231
235 vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
236
243 double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
244 {
245 return this->Data->GetTuple(id);
246 }
247
252 void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
253 VTK_SIZEHINT(3)
254 {
255 this->Data->GetTuple(id, x);
256 }
257
264 void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
265 {
266 this->Data->SetTuple(id, x);
267 }
268 void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
269 {
270 this->Data->SetTuple(id, x);
271 }
272 void SetPoint(vtkIdType id, double x, double y, double z)
273 VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
274
276
280 void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
281 {
282 this->Data->InsertTuple(id, x);
283 }
284 void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
285 {
286 this->Data->InsertTuple(id, x);
287 }
288 void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
290
297 {
298 this->Data->InsertTuples(dstIds, srcIds, source->Data);
299 }
300
307 {
308 this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
309 }
310
314 vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
315 vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
316 vtkIdType InsertNextPoint(double x, double y, double z);
317
323 void SetNumberOfPoints(vtkIdType numPoints);
324
329 vtkTypeBool Resize(vtkIdType numPoints);
330
334 void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
335
339 virtual void ComputeBounds();
340
345
349 void GetBounds(double bounds[6]);
350
354 vtkMTimeType GetMTime() override;
355
361 void Modified() override;
362
363protected:
364 vtkPoints(int dataType = VTK_FLOAT);
365 ~vtkPoints() override;
366
367 double Bounds[6];
368 vtkTimeStamp ComputeTime; // Time at which bounds computed
369 vtkDataArray* Data; // Array which represents data
370
371private:
372 vtkPoints(const vtkPoints&) = delete;
373 void operator=(const vtkPoints&) = delete;
374};
375
376inline void vtkPoints::Reset()
377{
378 this->Data->Reset();
379 this->Modified();
380}
381
383{
384 this->Data->SetNumberOfComponents(3);
385 this->Data->SetNumberOfTuples(numPoints);
386 this->Modified();
387}
388
390{
391 this->Data->SetNumberOfComponents(3);
392 this->Modified();
393 return this->Data->Resize(numPoints);
394}
395
396inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
397{
398 double p[3] = { x, y, z };
399 this->Data->SetTuple(id, p);
400}
401
402inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
403{
404 double p[3] = { x, y, z };
405 this->Data->InsertTuple(id, p);
406}
407
408inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
409{
410 double p[3] = { x, y, z };
411 return this->Data->InsertNextTuple(p);
412}
413
414#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:73
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:143
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:268
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:188
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:264
void SetDataTypeToChar()
Definition: vtkPoints.h:185
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:284
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:189
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
void SetDataTypeToLong()
Definition: vtkPoints.h:191
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:296
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:205
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:192
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:186
static vtkPoints * New(int dataType)
vtkDataArray * GetData()
Definition: vtkPoints.h:171
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:243
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:190
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:200
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:252
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:187
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:235
void SetDataTypeToDouble()
Definition: vtkPoints.h:194
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:382
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:389
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:280
void SetDataTypeToBit()
Definition: vtkPoints.h:184
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:314
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:306
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
void SetDataTypeToFloat()
Definition: vtkPoints.h:193
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:315
record modification and/or execution time
Definition: vtkTimeStamp.h:52
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)