VTK  9.2.20230606
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 =========================================================================*/
138 #ifndef vtkPoints_h
139 #define vtkPoints_h
140 
141 #include "vtkCommonCoreModule.h" // For export macro
142 #include "vtkObject.h"
143 
144 #include "vtkDataArray.h" // Needed for inline methods
145 
146 VTK_ABI_NAMESPACE_BEGIN
147 class vtkIdList;
148 
149 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
150 {
151 public:
152  static vtkPoints* New(int dataType);
153 
154  static vtkPoints* New();
155 
156  vtkTypeMacro(vtkPoints, vtkObject);
157  void PrintSelf(ostream& os, vtkIndent indent) override;
158 
162  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
163 
167  virtual void Initialize();
168 
177  virtual void SetData(vtkDataArray*);
178  vtkDataArray* GetData() { return this->Data; }
179 
184  virtual int GetDataType() const;
185 
190  virtual void SetDataType(int dataType);
191  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
192  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
193  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
194  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
195  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
196  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
197  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
198  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
199  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
200  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
201  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
202 
207  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
208 
212  virtual void Squeeze() { this->Data->Squeeze(); }
213 
217  virtual void Reset();
218 
220 
225  virtual void DeepCopy(vtkPoints* ad);
226  virtual void ShallowCopy(vtkPoints* ad);
228 
237  unsigned long GetActualMemorySize();
238 
242  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
243 
250  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
251  {
252  return this->Data->GetTuple(id);
253  }
254 
259  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
260  VTK_SIZEHINT(3)
261  {
262  this->Data->GetTuple(id, x);
263  }
264 
271  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
272  {
273  this->Data->SetTuple(id, x);
274  }
275  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
276  {
277  this->Data->SetTuple(id, x);
278  }
279  void SetPoint(vtkIdType id, double x, double y, double z)
280  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
281 
283 
287  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
288  {
289  this->Data->InsertTuple(id, x);
290  }
291  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
292  {
293  this->Data->InsertTuple(id, x);
294  }
295  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
297 
304  {
305  this->Data->InsertTuples(dstIds, srcIds, source->Data);
306  }
307 
314  {
315  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
316  }
317 
321  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
322  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
323  vtkIdType InsertNextPoint(double x, double y, double z);
324 
330  void SetNumberOfPoints(vtkIdType numPoints);
331 
336  vtkTypeBool Resize(vtkIdType numPoints);
337 
341  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
342 
346  virtual void ComputeBounds();
347 
351  double* GetBounds() VTK_SIZEHINT(6);
352 
356  void GetBounds(double bounds[6]);
357 
361  vtkMTimeType GetMTime() override;
362 
368  void Modified() override;
369 
370 protected:
371  vtkPoints(int dataType = VTK_FLOAT);
372  ~vtkPoints() override;
373 
374  double Bounds[6];
375  vtkTimeStamp ComputeTime; // Time at which bounds computed
376  vtkDataArray* Data; // Array which represents data
377 
378 private:
379  vtkPoints(const vtkPoints&) = delete;
380  void operator=(const vtkPoints&) = delete;
381 };
382 
383 inline void vtkPoints::Reset()
384 {
385  this->Data->Reset();
386  this->Modified();
387 }
388 
390 {
391  this->Data->SetNumberOfComponents(3);
392  this->Data->SetNumberOfTuples(numPoints);
393  this->Modified();
394 }
395 
397 {
398  this->Data->SetNumberOfComponents(3);
399  this->Modified();
400  return this->Data->Resize(numPoints);
401 }
402 
403 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
404 {
405  double p[3] = { x, y, z };
406  this->Data->SetTuple(id, p);
407 }
408 
409 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
410 {
411  double p[3] = { x, y, z };
412  this->Data->InsertTuple(id, p);
413 }
414 
415 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
416 {
417  double p[3] = { x, y, z };
418  return this->Data->InsertNextTuple(p);
419 }
420 
421 VTK_ABI_NAMESPACE_END
422 #endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:166
list of point or cell ids
Definition: vtkIdList.h:144
a simple class to control print indentation
Definition: vtkIndent.h:120
abstract base class for most VTK objects
Definition: vtkObject.h:83
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:150
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:275
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:195
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:271
void SetDataTypeToChar()
Definition: vtkPoints.h:192
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
vtkDataArray * GetData()
Definition: vtkPoints.h:178
static vtkPoints * New(int dataType)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:291
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:196
virtual void ComputeBounds()
Determine (xmin,xmax, ymin,ymax, zmin,zmax) bounds of points.
double * GetBounds()
Return the bounds of the points.
void SetDataTypeToLong()
Definition: vtkPoints.h:198
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:303
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:207
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:212
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:199
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:193
static vtkPoints * New()
virtual void SetData(vtkDataArray *)
Set/Get the underlying data array.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:197
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:259
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:194
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:242
void SetDataTypeToDouble()
Definition: vtkPoints.h:201
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:389
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:396
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:287
void SetDataTypeToBit()
Definition: vtkPoints.h:191
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:321
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:313
virtual void SetDataType(int dataType)
Specify the underlying data type of the object.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:250
void SetDataTypeToFloat()
Definition: vtkPoints.h:200
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:322
record modification and/or execution time
Definition: vtkTimeStamp.h:56
void GetBounds(T a, double bds[6])
int vtkTypeBool
Definition: vtkABI.h:71
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:327
#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:282
#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)