VTK  9.2.6
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 =========================================================================*/
38 #ifndef vtkPoints_h
39 #define vtkPoints_h
40 
41 #include "vtkCommonCoreModule.h" // For export macro
42 #include "vtkObject.h"
43 
44 #include "vtkDataArray.h" // Needed for inline methods
45 
46 class vtkIdList;
47 
48 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
49 {
50 public:
51  static vtkPoints* New(int dataType);
52 
53  static vtkPoints* New();
54 
55  vtkTypeMacro(vtkPoints, vtkObject);
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
61  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
62 
66  virtual void Initialize();
67 
76  virtual void SetData(vtkDataArray*);
77  vtkDataArray* GetData() { return this->Data; }
78 
83  virtual int GetDataType() const;
84 
89  virtual void SetDataType(int dataType);
90  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
91  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
92  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
93  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
94  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
95  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
96  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
97  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
98  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
99  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
100  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
101 
106  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
107 
111  virtual void Squeeze() { this->Data->Squeeze(); }
112 
116  virtual void Reset();
117 
119 
124  virtual void DeepCopy(vtkPoints* ad);
125  virtual void ShallowCopy(vtkPoints* ad);
127 
136  unsigned long GetActualMemorySize();
137 
141  vtkIdType GetNumberOfPoints() const { return this->Data->GetNumberOfTuples(); }
142 
149  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
150  {
151  return this->Data->GetTuple(id);
152  }
153 
158  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
159  VTK_SIZEHINT(3)
160  {
161  this->Data->GetTuple(id, x);
162  }
163 
170  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
171  {
172  this->Data->SetTuple(id, x);
173  }
174  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
175  {
176  this->Data->SetTuple(id, x);
177  }
178  void SetPoint(vtkIdType id, double x, double y, double z)
179  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
180 
182 
186  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
187  {
188  this->Data->InsertTuple(id, x);
189  }
190  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
191  {
192  this->Data->InsertTuple(id, x);
193  }
194  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
196 
203  {
204  this->Data->InsertTuples(dstIds, srcIds, source->Data);
205  }
206 
213  {
214  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
215  }
216 
220  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
221  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
222  vtkIdType InsertNextPoint(double x, double y, double z);
223 
229  void SetNumberOfPoints(vtkIdType numPoints);
230 
235  vtkTypeBool Resize(vtkIdType numPoints);
236 
240  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
241 
245  virtual void ComputeBounds();
246 
250  double* GetBounds() VTK_SIZEHINT(6);
251 
255  void GetBounds(double bounds[6]);
256 
260  vtkMTimeType GetMTime() override;
261 
267  void Modified() override;
268 
269 protected:
270  vtkPoints(int dataType = VTK_FLOAT);
271  ~vtkPoints() override;
272 
273  double Bounds[6];
274  vtkTimeStamp ComputeTime; // Time at which bounds computed
275  vtkDataArray* Data; // Array which represents data
276 
277 private:
278  vtkPoints(const vtkPoints&) = delete;
279  void operator=(const vtkPoints&) = delete;
280 };
281 
282 inline void vtkPoints::Reset()
283 {
284  this->Data->Reset();
285  this->Modified();
286 }
287 
289 {
290  this->Data->SetNumberOfComponents(3);
291  this->Data->SetNumberOfTuples(numPoints);
292  this->Modified();
293 }
294 
296 {
297  this->Data->SetNumberOfComponents(3);
298  this->Modified();
299  return this->Data->Resize(numPoints);
300 }
301 
302 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
303 {
304  double p[3] = { x, y, z };
305  this->Data->SetTuple(id, p);
306 }
307 
308 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
309 {
310  double p[3] = { x, y, z };
311  this->Data->InsertTuple(id, p);
312 }
313 
314 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
315 {
316  double p[3] = { x, y, z };
317  return this->Data->InsertNextTuple(p);
318 }
319 
320 #endif
void Reset()
Reset to an empty state, without freeing any memory.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:65
list of point or cell ids
Definition: vtkIdList.h:43
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract base class for most VTK objects
Definition: vtkObject.h:72
virtual void Modified()
Update the modification time for this object.
represent and manipulate 3D points
Definition: vtkPoints.h:49
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:174
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:94
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:170
void SetDataTypeToChar()
Definition: vtkPoints.h:91
void GetPoints(vtkIdList *ptId, vtkPoints *outPoints)
Given a list of pt ids, return an array of points.
vtkDataArray * GetData()
Definition: vtkPoints.h:77
static vtkPoints * New(int dataType)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:190
virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate initial memory size.
void SetDataTypeToInt()
Definition: vtkPoints.h:95
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:97
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:202
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:106
virtual void Initialize()
Return object to instantiated state.
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:111
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:98
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:92
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:96
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:158
virtual int GetDataType() const
Return the underlying data type.
void SetDataTypeToShort()
Definition: vtkPoints.h:93
vtkIdType GetNumberOfPoints() const
Return number of points in array.
Definition: vtkPoints.h:141
void SetDataTypeToDouble()
Definition: vtkPoints.h:100
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:288
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:295
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:186
void SetDataTypeToBit()
Definition: vtkPoints.h:90
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:220
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:212
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:149
void SetDataTypeToFloat()
Definition: vtkPoints.h:99
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:221
record modification and/or execution time
Definition: vtkTimeStamp.h:45
void GetBounds(T a, double bds[6])
int vtkTypeBool
Definition: vtkABI.h:69
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:332
#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:287
#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)