VTK  9.0.20210919
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 
140 class vtkIdList;
141 
142 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
143 {
144 public:
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 
344  double* GetBounds() VTK_SIZEHINT(6);
345 
349  void GetBounds(double bounds[6]);
350 
354  vtkMTimeType GetMTime() override;
355 
361  void Modified() override;
362 
363 protected:
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 
371 private:
372  vtkPoints(const vtkPoints&) = delete;
373  void operator=(const vtkPoints&) = delete;
374 };
375 
376 inline 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 
396 inline 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 
402 inline 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 
408 inline 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
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkPoints::InsertNextPoint
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:314
vtkPoints::DeepCopy
virtual void DeepCopy(vtkPoints *ad)
Different ways to copy data.
vtkPoints::SetDataTypeToUnsignedShort
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:188
vtkPoints::SetDataTypeToShort
void SetDataTypeToShort()
Definition: vtkPoints.h:187
vtkPoints::SetNumberOfPoints
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:382
vtkPoints::Resize
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:389
VTK_EXPECTS
#define VTK_EXPECTS(x)
Definition: vtkWrappingHints.h:47
vtkPoints::Allocate
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
vtkPoints::Squeeze
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:205
vtkPoints::InsertPoint
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:280
vtkIdType
int vtkIdType
Definition: vtkType.h:332
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:52
vtkPoints::InsertNextPoint
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:315
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkPoints::GetVoidPointer
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:200
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkPoints::GetPoint
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:252
vtkPoints::InsertPoints
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
vtkPoints::SetDataTypeToUnsignedLong
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:192
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
vtkPoints::GetActualMemorySize
unsigned long GetActualMemorySize()
Return the memory in kibibytes (1024 bytes) consumed by this attribute data.
vtkAbstractArray::Reset
void Reset()
Reset to an empty state, without freeing any memory.
Definition: vtkAbstractArray.h:304
vtkPoints::SetDataTypeToChar
void SetDataTypeToChar()
Definition: vtkPoints.h:185
vtkPoints::GetPoint
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:243
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:45
vtkPoints::ComputeBounds
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkPoints::GetData
vtkDataArray * GetData()
Definition: vtkPoints.h:171
vtkPoints::SetDataTypeToInt
void SetDataTypeToInt()
Definition: vtkPoints.h:189
vtkPoints::New
static vtkPoints * New(int dataType)
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:54
vtkPoints::SetDataTypeToUnsignedInt
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:190
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:55
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
VTK_LONG
#define VTK_LONG
Definition: vtkType.h:52
vtkPoints::New
static vtkPoints * New()
vtkPoints::SetDataTypeToDouble
void SetDataTypeToDouble()
Definition: vtkPoints.h:194
vtkPoints::GetBounds
double * GetBounds()
Return the bounds of the points.
vtkObject.h
VTK_UNSIGNED_LONG
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:53
vtkPoints::SetPoint
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:268
vtkPoints::SetData
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:48
vtkDataArray.h
vtkPoints::GetPoints
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
vtkPoints::SetDataTypeToLong
void SetDataTypeToLong()
Definition: vtkPoints.h:191
vtkPoints::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPoints::SetDataTypeToFloat
void SetDataTypeToFloat()
Definition: vtkPoints.h:193
vtkPoints::ShallowCopy
virtual void ShallowCopy(vtkPoints *ad)
Different ways to copy data.
vtkPoints::InsertPoint
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:284
vtkPoints::Initialize
virtual void Initialize()
Return object to instantiated state.
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:998
VTK_BIT
#define VTK_BIT
Definition: vtkType.h:44
vtkPoints::SetDataType
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
vtkPoints::GetDataType
virtual int GetDataType() const
Return the underlying data type.
VTK_INT
#define VTK_INT
Definition: vtkType.h:50
vtkPoints::InsertPoints
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
vtkPoints::SetDataTypeToUnsignedChar
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:186
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints::GetNumberOfPoints
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:235
vtkPoints::SetPoint
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:264
vtkPoints::SetDataTypeToBit
void SetDataTypeToBit()
Definition: vtkPoints.h:184
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287