VTK
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();
69 
73  virtual void SetDataType(int dataType);
74  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
75  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
76  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
77  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
78  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
79  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
80  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
81  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
82  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
83  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
84  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
85 
90  void* GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
91 
95  virtual void Squeeze() { this->Data->Squeeze(); }
96 
100  virtual void Reset();
101 
103 
108  virtual void DeepCopy(vtkPoints* ad);
109  virtual void ShallowCopy(vtkPoints* ad);
111 
120  unsigned long GetActualMemorySize();
121 
125  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
126 
133  double* GetPoint(vtkIdType id) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints()) VTK_SIZEHINT(3)
134  {
135  return this->Data->GetTuple(id);
136  }
137 
142  void GetPoint(vtkIdType id, double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
143  VTK_SIZEHINT(3)
144  {
145  this->Data->GetTuple(id, x);
146  }
147 
154  void SetPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
155  {
156  this->Data->SetTuple(id, x);
157  }
158  void SetPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
159  {
160  this->Data->SetTuple(id, x);
161  }
162  void SetPoint(vtkIdType id, double x, double y, double z)
163  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
164 
166 
170  void InsertPoint(vtkIdType id, const float x[3]) VTK_EXPECTS(0 <= id)
171  {
172  this->Data->InsertTuple(id, x);
173  }
174  void InsertPoint(vtkIdType id, const double x[3]) VTK_EXPECTS(0 <= id)
175  {
176  this->Data->InsertTuple(id, x);
177  }
178  void InsertPoint(vtkIdType id, double x, double y, double z) VTK_EXPECTS(0 <= id);
180 
187  {
188  this->Data->InsertTuples(dstIds, srcIds, source->Data);
189  }
190 
197  {
198  this->Data->InsertTuples(dstStart, n, srcStart, source->Data);
199  }
200 
204  vtkIdType InsertNextPoint(const float x[3]) { return this->Data->InsertNextTuple(x); }
205  vtkIdType InsertNextPoint(const double x[3]) { return this->Data->InsertNextTuple(x); }
206  vtkIdType InsertNextPoint(double x, double y, double z);
207 
213  void SetNumberOfPoints(vtkIdType numPoints);
214 
219  vtkTypeBool Resize(vtkIdType numPoints);
220 
224  void GetPoints(vtkIdList* ptId, vtkPoints* fp);
225 
229  virtual void ComputeBounds();
230 
234  double* GetBounds() VTK_SIZEHINT(6);
235 
239  void GetBounds(double bounds[6]);
240 
244  vtkMTimeType GetMTime() override;
245 
251  void Modified() override;
252 
253 protected:
254  vtkPoints(int dataType = VTK_FLOAT);
255  ~vtkPoints() override;
256 
257  double Bounds[6];
258  vtkTimeStamp ComputeTime; // Time at which bounds computed
259  vtkDataArray* Data; // Array which represents data
260 
261 private:
262  vtkPoints(const vtkPoints&) = delete;
263  void operator=(const vtkPoints&) = delete;
264 };
265 
266 inline void vtkPoints::Reset()
267 {
268  this->Data->Reset();
269  this->Modified();
270 }
271 
273 {
274  this->Data->SetNumberOfComponents(3);
275  this->Data->SetNumberOfTuples(numPoints);
276  this->Modified();
277 }
278 
280 {
281  this->Data->SetNumberOfComponents(3);
282  this->Modified();
283  return this->Data->Resize(numPoints);
284 }
285 
286 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
287 {
288  double p[3] = { x, y, z };
289  this->Data->SetTuple(id, p);
290 }
291 
292 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
293 {
294  double p[3] = { x, y, z };
295  this->Data->InsertTuple(id, p);
296 }
297 
298 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
299 {
300  double p[3] = { x, y, z };
301  return this->Data->InsertNextTuple(p);
302 }
303 
304 #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:204
vtkPoints::SetDataTypeToUnsignedShort
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:78
vtkPoints::SetDataTypeToShort
void SetDataTypeToShort()
Definition: vtkPoints.h:77
vtkPoints::SetNumberOfPoints
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:272
vtkPoints::Resize
vtkTypeBool Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:279
VTK_EXPECTS
#define VTK_EXPECTS(x)
Definition: vtkWrappingHints.h:44
vtkPoints::Squeeze
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:95
vtkPoints::InsertPoint
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:170
vtkIdType
int vtkIdType
Definition: vtkType.h:349
VTK_UNSIGNED_INT
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
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:53
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkPoints::InsertNextPoint
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:205
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkPoints::GetVoidPointer
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:90
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:142
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:196
vtkPoints::GetNumberOfPoints
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints.h:125
vtkPoints::SetDataTypeToUnsignedLong
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:82
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:75
vtkPoints::GetPoint
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:133
VTK_CHAR
#define VTK_CHAR
Definition: vtkType.h:49
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:79
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:58
vtkPoints::SetDataTypeToUnsignedInt
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:80
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:59
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
VTK_UNSIGNED_CHAR
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
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:56
vtkPoints::SetDataTypeToDouble
void SetDataTypeToDouble()
Definition: vtkPoints.h:84
vtkObject.h
VTK_UNSIGNED_LONG
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:57
vtkPoints::SetPoint
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:158
VTK_SHORT
#define VTK_SHORT
Definition: vtkType.h:52
vtkDataArray.h
vtkPoints::SetDataTypeToLong
void SetDataTypeToLong()
Definition: vtkPoints.h:81
vtkPoints::SetDataTypeToFloat
void SetDataTypeToFloat()
Definition: vtkPoints.h:83
vtkPoints::InsertPoint
void InsertPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:174
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:48
VTK_INT
#define VTK_INT
Definition: vtkType.h:54
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:186
vtkPoints::SetDataTypeToUnsignedChar
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:76
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints::SetPoint
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:154
vtkPoints::SetDataTypeToBit
void SetDataTypeToBit()
Definition: vtkPoints.h:74
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:304