VTK  9.3.20231205
vtkPoints.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
126 #ifndef vtkPoints_h
127 #define vtkPoints_h
128 
129 #include "vtkCommonCoreModule.h" // For export macro
130 #include "vtkObject.h"
131 
132 #include "vtkDataArray.h" // Needed for inline methods
133 
134 VTK_ABI_NAMESPACE_BEGIN
135 class vtkIdList;
136 
137 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
138 {
139 public:
140  static vtkPoints* New(int dataType);
141 
142  static vtkPoints* New();
143 
144  vtkTypeMacro(vtkPoints, vtkObject);
145  void PrintSelf(ostream& os, vtkIndent indent) override;
146 
150  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
151 
155  virtual void Initialize();
156 
165  virtual void SetData(vtkDataArray*);
166  vtkDataArray* GetData() { return this->Data; }
167 
172  virtual int GetDataType() const;
173 
178  virtual void SetDataType(int dataType);
179  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
180  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
181  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
182  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
183  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
184  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
185  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
186  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
187  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
188  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
189  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
190 
195  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
196 
200  virtual void Squeeze() { this->Data->Squeeze(); }
201 
205  virtual void Reset();
206 
208 
213  virtual void DeepCopy(vtkPoints* ad);
214  virtual void ShallowCopy(vtkPoints* ad);
216 
225  unsigned long GetActualMemorySize();
226 
230  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
231 
238  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
239  {
240  return this->Data->GetTuple(id);
241  }
242 
247  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
248  VTK_SIZEHINT(3)
249  {
250  this->Data->GetTuple(id, x);
251  }
252 
259  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
260  {
261  this->Data->SetTuple(id, x);
262  }
263  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
264  {
265  this->Data->SetTuple(id, x);
266  }
267  void SetPoint(vtkIdType id, double x, double y, double z)
268  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
269 
271 
275  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
276  {
277  this->Data->InsertTuple(id, x);
278  }
279  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
280  {
281  this->Data->InsertTuple(id, x);
282  }
283  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
285 
292  {
293  this->Data->InsertTuples(dstIds, srcIds, source->Data);
294  }
295 
302  {
303  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
304  }
305 
309  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
310  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
311  vtkIdType InsertNextPoint(double x, double y, double z);
312 
318  void SetNumberOfPoints(vtkIdType numPoints);
319 
324  vtkTypeBool Resize(vtkIdType numPoints);
325 
329  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
330 
334  virtual void ComputeBounds();
335 
339  double* GetBounds() VTK_SIZEHINT(6);
340 
344  void GetBounds(double bounds[6]);
345 
349  vtkMTimeType GetMTime() override;
350 
356  void Modified() override;
357 
358 protected:
359  vtkPoints(int dataType = VTK_FLOAT);
360  ~vtkPoints() override;
361 
362  double Bounds[6];
363  vtkTimeStamp ComputeTime; // Time at which bounds computed
364  vtkDataArray* Data; // Array which represents data
365 
366 private:
367  vtkPoints(const vtkPoints&) = delete;
368  void operator=(const vtkPoints&) = delete;
369 };
370 
371 inline void vtkPoints::Reset()
372 {
373  this->Data->Reset();
374  this->Modified();
375 }
376 
378 {
379  this->Data->SetNumberOfComponents(3);
380  this->Data->SetNumberOfTuples(numPoints);
381  this->Modified();
382 }
383 
385 {
386  this->Data->SetNumberOfComponents(3);
387  this->Modified();
388  return this->Data->Resize(numPoints);
389 }
390 
391 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
392 {
393  double p[3] = { x, y, z };
394  this->Data->SetTuple(id, p);
395 }
396 
397 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
398 {
399  double p[3] = { x, y, z };
400  this->Data->InsertTuple(id, p);
401 }
402 
403 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
404 {
405  double p[3] = { x, y, z };
406  return this->Data->InsertNextTuple(p);
407 }
408 
409 VTK_ABI_NAMESPACE_END
410 #endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
list of point or cell ids
Definition: vtkIdList.h:132
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:138
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:263
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:183
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:259
void SetDataTypeToChar()
Definition: vtkPoints.h:180
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
vtkDataArray * GetData()
Definition: vtkPoints.h:166
static vtkPoints * New(int dataType)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:279
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:184
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:186
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:291
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:195
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:200
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:187
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:181
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:185
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:247
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:182
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:230
void SetDataTypeToDouble()
Definition: vtkPoints.h:189
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:377
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:384
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:275
void SetDataTypeToBit()
Definition: vtkPoints.h:179
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:309
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:301
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:238
void SetDataTypeToFloat()
Definition: vtkPoints.h:188
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:310
record modification and/or execution time
Definition: vtkTimeStamp.h:44
void GetBounds(T a, double bds[6])
int vtkTypeBool
Definition: vtkABI.h:64
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_SHORT
Definition: vtkType.h:36
int vtkIdType
Definition: vtkType.h:315
#define VTK_UNSIGNED_INT
Definition: vtkType.h:39
#define VTK_DOUBLE
Definition: vtkType.h:43
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:35
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:37
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_INT
Definition: vtkType.h:38
#define VTK_FLOAT
Definition: vtkType.h:42
#define VTK_CHAR
Definition: vtkType.h:33
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:41
#define VTK_BIT
Definition: vtkType.h:32
#define VTK_LONG
Definition: vtkType.h:40
#define VTK_SIZEHINT(...)
#define VTK_EXPECTS(x)