VTK  9.3.0
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
26 #ifndef vtkPoints_h
27 #define vtkPoints_h
28 
29 #include "vtkCommonCoreModule.h" // For export macro
30 #include "vtkObject.h"
31 
32 #include "vtkDataArray.h" // Needed for inline methods
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkIdList;
36 
37 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
38 {
39 public:
40  static vtkPoints* New(int dataType);
41 
42  static vtkPoints* New();
43 
44  vtkTypeMacro(vtkPoints, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
50  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
51 
55  virtual void Initialize();
56 
65  virtual void SetData(vtkDataArray*);
66  vtkDataArray* GetData() { return this->Data; }
67 
72  virtual int GetDataType() const;
73 
78  virtual void SetDataType(int dataType);
79  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
80  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
81  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
82  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
83  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
84  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
85  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
86  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
87  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
88  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
89  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
90 
95  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
96 
100  virtual void Squeeze() { this->Data->Squeeze(); }
101 
105  virtual void Reset();
106 
108 
113  virtual void DeepCopy(vtkPoints* ad);
114  virtual void ShallowCopy(vtkPoints* ad);
116 
125  unsigned long GetActualMemorySize();
126 
130  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
131 
138  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
139  {
140  return this->Data->GetTuple(id);
141  }
142 
147  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
148  VTK_SIZEHINT(3)
149  {
150  this->Data->GetTuple(id, x);
151  }
152 
159  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
160  {
161  this->Data->SetTuple(id, x);
162  }
163  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
164  {
165  this->Data->SetTuple(id, x);
166  }
167  void SetPoint(vtkIdType id, double x, double y, double z)
168  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
169 
171 
175  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
176  {
177  this->Data->InsertTuple(id, x);
178  }
179  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
180  {
181  this->Data->InsertTuple(id, x);
182  }
183  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
185 
192  {
193  this->Data->InsertTuples(dstIds, srcIds, source->Data);
194  }
195 
202  {
203  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
204  }
205 
209  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
210  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
211  vtkIdType InsertNextPoint(double x, double y, double z);
212 
218  void SetNumberOfPoints(vtkIdType numPoints);
219 
224  vtkTypeBool Resize(vtkIdType numPoints);
225 
229  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
230 
234  virtual void ComputeBounds();
235 
239  double* GetBounds() VTK_SIZEHINT(6);
240 
244  void GetBounds(double bounds[6]);
245 
249  vtkMTimeType GetMTime() override;
250 
256  void Modified() override;
257 
258 protected:
259  vtkPoints(int dataType = VTK_FLOAT);
260  ~vtkPoints() override;
261 
262  double Bounds[6];
263  vtkTimeStamp ComputeTime; // Time at which bounds computed
264  vtkDataArray* Data; // Array which represents data
265 
266 private:
267  vtkPoints(const vtkPoints&) = delete;
268  void operator=(const vtkPoints&) = delete;
269 };
270 
271 inline void vtkPoints::Reset()
272 {
273  this->Data->Reset();
274  this->Modified();
275 }
276 
278 {
279  this->Data->SetNumberOfComponents(3);
280  this->Data->SetNumberOfTuples(numPoints);
281  this->Modified();
282 }
283 
285 {
286  this->Data->SetNumberOfComponents(3);
287  this->Modified();
288  return this->Data->Resize(numPoints);
289 }
290 
291 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
292 {
293  double p[3] = { x, y, z };
294  this->Data->SetTuple(id, p);
295 }
296 
297 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
298 {
299  double p[3] = { x, y, z };
300  this->Data->InsertTuple(id, p);
301 }
302 
303 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
304 {
305  double p[3] = { x, y, z };
306  return this->Data->InsertNextTuple(p);
307 }
308 
309 VTK_ABI_NAMESPACE_END
310 #endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
list of point or cell ids
Definition: vtkIdList.h:32
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:38
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:163
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:83
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:159
void SetDataTypeToChar()
Definition: vtkPoints.h:80
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
vtkDataArray * GetData()
Definition: vtkPoints.h:66
static vtkPoints * New(int dataType)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:179
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:84
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:86
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:191
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:95
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:100
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:87
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:81
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:85
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:147
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:82
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:130
void SetDataTypeToDouble()
Definition: vtkPoints.h:89
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:277
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:284
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:175
void SetDataTypeToBit()
Definition: vtkPoints.h:79
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:209
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:201
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:138
void SetDataTypeToFloat()
Definition: vtkPoints.h:88
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:210
record modification and/or execution time
Definition: vtkTimeStamp.h:34
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)