VTK  9.0.20200710
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 =========================================================================*/
23 #ifndef vtkPoints_h
24 #define vtkPoints_h
25 
26 #include "vtkCommonCoreModule.h" // For export macro
27 #include "vtkObject.h"
28 
29 #include "vtkDataArray.h" // Needed for inline methods
30 
31 class vtkIdList;
32 
33 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject
34 {
35 public:
36  static vtkPoints* New(int dataType);
37 
38  static vtkPoints* New();
39 
40  vtkTypeMacro(vtkPoints, vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42 
46  virtual vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
47 
51  virtual void Initialize();
52 
61  virtual void SetData(vtkDataArray*);
62  vtkDataArray* GetData() { return this->Data; }
63 
68  virtual int GetDataType() const;
69 
74  virtual void SetDataType(int dataType);
75  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
76  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
77  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
78  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
79  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
80  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
81  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
82  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
83  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
84  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
85  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
86 
91  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
92 
96  virtual void Squeeze() { this->Data->Squeeze(); }
97 
101  virtual void Reset();
102 
104 
109  virtual void DeepCopy(vtkPoints* ad);
110  virtual void ShallowCopy(vtkPoints* ad);
112 
121  unsigned long GetActualMemorySize();
122 
126  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
127 
134  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
135  {
136  return this->Data->GetTuple(id);
137  }
138 
143  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
144  VTK_SIZEHINT(3)
145  {
146  this->Data->GetTuple(id, x);
147  }
148 
155  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
156  {
157  this->Data->SetTuple(id, x);
158  }
159  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
160  {
161  this->Data->SetTuple(id, x);
162  }
163  void SetPoint(vtkIdType id, double x, double y, double z)
164  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
165 
167 
171  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
172  {
173  this->Data->InsertTuple(id, x);
174  }
175  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
176  {
177  this->Data->InsertTuple(id, x);
178  }
179  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
181 
188  {
189  this->Data->InsertTuples(dstIds, srcIds, source->Data);
190  }
191 
198  {
199  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
200  }
201 
205  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
206  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
207  vtkIdType InsertNextPoint(double x, double y, double z);
208 
214  void SetNumberOfPoints(vtkIdType numPoints);
215 
220  vtkTypeBool Resize(vtkIdType numPoints);
221 
225  void GetPoints(vtkIdList* ptId, vtkPoints* outPoints);
226 
230  virtual void ComputeBounds();
231 
235  double* GetBounds() VTK_SIZEHINT(6);
236 
240  void GetBounds(double bounds[6]);
241 
245  vtkMTimeType GetMTime() override;
246 
252  void Modified() override;
253 
254 protected:
255  vtkPoints(int dataType = VTK_FLOAT);
256  ~vtkPoints() override;
257 
258  double Bounds[6];
259  vtkTimeStamp ComputeTime; // Time at which bounds computed
260  vtkDataArray* Data; // Array which represents data
261 
262 private:
263  vtkPoints(const vtkPoints&) = delete;
264  void operator=(const vtkPoints&) = delete;
265 };
266 
267 inline void vtkPoints::Reset()
268 {
269  this->Data->Reset();
270  this->Modified();
271 }
272 
274 {
275  this->Data->SetNumberOfComponents(3);
276  this->Data->SetNumberOfTuples(numPoints);
277  this->Modified();
278 }
279 
281 {
282  this->Data->SetNumberOfComponents(3);
283  this->Modified();
284  return this->Data->Resize(numPoints);
285 }
286 
287 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
288 {
289  double p[3] = { x, y, z };
290  this->Data->SetTuple(id, p);
291 }
292 
293 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
294 {
295  double p[3] = { x, y, z };
296  this->Data->InsertTuple(id, p);
297 }
298 
299 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
300 {
301  double p[3] = { x, y, z };
302  return this->Data->InsertNextTuple(p);
303 }
304 
305 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkPoints::InsertNextPoint
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:205
vtkPoints::SetDataTypeToUnsignedShort
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:79
vtkPoints::SetDataTypeToShort
void SetDataTypeToShort()
Definition: vtkPoints.h:78
vtkPoints::SetNumberOfPoints
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:273
vtkPoints::Resize
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:280
VTK_EXPECTS
#define VTK_EXPECTS(x)
Definition: vtkWrappingHints.h:44
vtkPoints::Squeeze
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:96
vtkPoints::InsertPoint
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:171
vtkIdType
int vtkIdType
Definition: vtkType.h:330
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:51
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
VTK_UNSIGNED_SHORT
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:49
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkPoints::InsertNextPoint
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:206
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkPoints::GetVoidPointer
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:91
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkPoints::GetPoint
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:143
vtkPoints::InsertPoints
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:197
vtkPoints::GetNumberOfPoints
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints.h:126
vtkPoints::SetDataTypeToUnsignedLong
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:83
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkAbstractArray::Reset
void Reset()
Reset to an empty state, without freeing any memory.
Definition: vtkAbstractArray.h:304
vtkPoints::SetDataTypeToChar
void SetDataTypeToChar()
Definition: vtkPoints.h:76
vtkPoints::GetPoint
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:134
vtkBlockSortHelper::GetBounds
void GetBounds(T a, double bds[6])
Definition: vtkBlockSortHelper.h:37
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkPoints::GetData
vtkDataArray * GetData()
Definition: vtkPoints.h:62
vtkPoints::SetDataTypeToInt
void SetDataTypeToInt()
Definition: vtkPoints.h:80
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:54
vtkPoints::SetDataTypeToUnsignedInt
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:81
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:55
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:47
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_LONG
#define VTK_LONG
Definition: vtkType.h:52
vtkPoints::SetDataTypeToDouble
void SetDataTypeToDouble()
Definition: vtkPoints.h:85
vtkObject.h
VTK_UNSIGNED_LONG
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:53
vtkPoints::SetPoint
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:159
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:48
vtkDataArray.h
vtkPoints::SetDataTypeToLong
void SetDataTypeToLong()
Definition: vtkPoints.h:82
vtkPoints::SetDataTypeToFloat
void SetDataTypeToFloat()
Definition: vtkPoints.h:84
vtkPoints::InsertPoint
void InsertPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:175
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
VTK_BIT
#define VTK_BIT
Definition: vtkType.h:44
VTK_INT
#define VTK_INT
Definition: vtkType.h:50
vtkPoints::InsertPoints
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:187
vtkPoints::SetDataTypeToUnsignedChar
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:77
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints::SetPoint
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:155
vtkPoints::SetDataTypeToBit
void SetDataTypeToBit()
Definition: vtkPoints.h:75
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285