VTK  9.3.20240329
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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
132 
133 #include "vtkDataArray.h" // Needed for inline methods
134 
135 VTK_ABI_NAMESPACE_BEGIN
136 class vtkIdList;
137 
138 class VTKCOMMONCORE_EXPORT VTK_MARSHALAUTO vtkPoints : public vtkObject
139 {
140 public:
141  static vtkPoints* New(int dataType);
142 
143  static vtkPoints* New();
144 
145  vtkTypeMacro(vtkPoints, vtkObject);
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
151  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
152 
156  virtual void Initialize();
157 
166  virtual void SetData(vtkDataArray*);
167  vtkDataArray* GetData() { return this->Data; }
168 
173  virtual int GetDataType() const;
174 
179  virtual void SetDataType(int dataType);
180  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
181  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
182  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
183  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
184  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
185  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
186  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
187  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
188  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
189  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
190  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
191 
196  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
197 
201  virtual void Squeeze() { this->Data->Squeeze(); }
202 
206  virtual void Reset();
207 
209 
214  virtual void DeepCopy(vtkPoints* ad);
215  virtual void ShallowCopy(vtkPoints* ad);
217 
226  unsigned long GetActualMemorySize();
227 
231  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
232 
239  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
240  {
241  return this->Data->GetTuple(id);
242  }
243 
248  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
249  VTK_SIZEHINT(3)
250  {
251  this->Data->GetTuple(id, x);
252  }
253 
260  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
261  {
262  this->Data->SetTuple(id, x);
263  }
264  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
265  {
266  this->Data->SetTuple(id, x);
267  }
268  void SetPoint(vtkIdType id, double x, double y, double z)
269  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
270 
272 
276  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
277  {
278  this->Data->InsertTuple(id, x);
279  }
280  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
281  {
282  this->Data->InsertTuple(id, x);
283  }
284  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
286 
293  {
294  this->Data->InsertTuples(dstIds, srcIds, source->Data);
295  }
296 
303  {
304  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
305  }
306 
310  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
311  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
312  vtkIdType InsertNextPoint(double x, double y, double z);
313 
319  void SetNumberOfPoints(vtkIdType numPoints);
320 
325  vtkTypeBool Resize(vtkIdType numPoints);
326 
330  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
331 
335  virtual void ComputeBounds();
336 
340  double* GetBounds() VTK_SIZEHINT(6);
341 
345  void GetBounds(double bounds[6]);
346 
350  vtkMTimeType GetMTime() override;
351 
357  void Modified() override;
358 
359 protected:
360  vtkPoints(int dataType = VTK_FLOAT);
361  ~vtkPoints() override;
362 
363  double Bounds[6];
364  vtkTimeStamp ComputeTime; // Time at which bounds computed
365  vtkDataArray* Data; // Array which represents data
366 
367 private:
368  vtkPoints(const vtkPoints&) = delete;
369  void operator=(const vtkPoints&) = delete;
370 };
371 
372 inline void vtkPoints::Reset()
373 {
374  this->Data->Reset();
375  this->Modified();
376 }
377 
379 {
380  this->Data->SetNumberOfComponents(3);
381  this->Data->SetNumberOfTuples(numPoints);
382  this->Modified();
383 }
384 
386 {
387  this->Data->SetNumberOfComponents(3);
388  this->Modified();
389  return this->Data->Resize(numPoints);
390 }
391 
392 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
393 {
394  double p[3] = { x, y, z };
395  this->Data->SetTuple(id, p);
396 }
397 
398 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
399 {
400  double p[3] = { x, y, z };
401  this->Data->InsertTuple(id, p);
402 }
403 
404 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
405 {
406  double p[3] = { x, y, z };
407  return this->Data->InsertNextTuple(p);
408 }
409 
410 VTK_ABI_NAMESPACE_END
411 #endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:155
list of point or cell ids
Definition: vtkIdList.h:133
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:139
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:264
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:184
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:260
void SetDataTypeToChar()
Definition: vtkPoints.h:181
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
vtkDataArray * GetData()
Definition: vtkPoints.h:167
static vtkPoints * New(int dataType)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:280
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:185
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:187
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:292
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:196
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:201
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:188
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:182
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:186
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:248
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:183
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:231
void SetDataTypeToDouble()
Definition: vtkPoints.h:190
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:378
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:385
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:276
void SetDataTypeToBit()
Definition: vtkPoints.h:180
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:310
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:302
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:239
void SetDataTypeToFloat()
Definition: vtkPoints.h:189
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:311
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)
#define VTK_MARSHALAUTO