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 
37  static vtkPoints *New(int dataType);
38 
39  static vtkPoints *New();
40 
41  vtkTypeMacro(vtkPoints,vtkObject);
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
47  virtual int Allocate(vtkIdType sz, vtkIdType ext = 1000);
48 
52  virtual void Initialize();
53 
62  virtual void SetData(vtkDataArray *);
63  vtkDataArray *GetData() { return this->Data; }
64 
69  virtual int GetDataType();
70 
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)
135  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
136  VTK_SIZEHINT(3)
137  { return this->Data->GetTuple(id); }
138 
143  void GetPoint(vtkIdType id, double x[3])
144  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
145  VTK_SIZEHINT(3)
146  { this->Data->GetTuple(id,x); }
147 
154  void SetPoint(vtkIdType id, const float x[3])
155  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
156  { this->Data->SetTuple(id,x); }
157  void SetPoint(vtkIdType id, const double x[3])
158  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints())
159  { this->Data->SetTuple(id,x); }
160  void SetPoint(vtkIdType id, double x, double y, double z)
161  VTK_EXPECTS(0 <= id && id < GetNumberOfPoints());
162 
164 
168  void InsertPoint(vtkIdType id, const float x[3])
169  VTK_EXPECTS(0 <= id)
170  { this->Data->InsertTuple(id,x);};
171  void InsertPoint(vtkIdType id, const double x[3])
172  VTK_EXPECTS(0 <= id)
173  {this->Data->InsertTuple(id,x);};
174  void InsertPoint(vtkIdType id, double x, double y, double z)
175  VTK_EXPECTS(0 <= id);
177 
184  { this->Data->InsertTuples(dstIds, srcIds, source->Data); }
185 
191  void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
192  vtkPoints* source)
193  { this->Data->InsertTuples(dstStart, n, srcStart, source->Data); }
194 
198  vtkIdType InsertNextPoint(const float x[3])
199  { return this->Data->InsertNextTuple(x); }
200  vtkIdType InsertNextPoint(const double x[3])
201  { return this->Data->InsertNextTuple(x); }
202  vtkIdType InsertNextPoint(double x, double y, double z);
203 
209  void SetNumberOfPoints(vtkIdType numPoints);
210 
215  int Resize(vtkIdType numPoints);
216 
220  void GetPoints(vtkIdList *ptId, vtkPoints *fp);
221 
225  virtual void ComputeBounds();
226 
230  double *GetBounds() VTK_SIZEHINT(6);
231 
235  void GetBounds(double bounds[6]);
236 
240  vtkMTimeType GetMTime() override;
241 
247  void Modified() override;
248 
249 protected:
250  vtkPoints(int dataType = VTK_FLOAT);
251  ~vtkPoints() override;
252 
253  double Bounds[6];
254  vtkTimeStamp ComputeTime; // Time at which bounds computed
255  vtkDataArray *Data; // Array which represents data
256 
257 private:
258  vtkPoints(const vtkPoints&) = delete;
259  void operator=(const vtkPoints&) = delete;
260 };
261 
262 inline void vtkPoints::Reset()
263 {
264  this->Data->Reset();
265  this->Modified();
266 }
267 
269 {
270  this->Data->SetNumberOfComponents(3);
271  this->Data->SetNumberOfTuples(numPoints);
272  this->Modified();
273 }
274 
275 inline int vtkPoints::Resize(vtkIdType numPoints)
276 {
277  this->Data->SetNumberOfComponents(3);
278  this->Modified();
279  return this->Data->Resize(numPoints);
280 }
281 
282 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
283 {
284  double p[3] = { x, y, z };
285  this->Data->SetTuple(id, p);
286 }
287 
288 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
289 {
290  double p[3] = { x, y, z };
291  this->Data->InsertTuple(id, p);
292 }
293 
294 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
295 {
296  double p[3] = { x, y, z };
297  return this->Data->InsertNextTuple(p);
298 }
299 
300 #endif
301 
void SetDataTypeToInt()
Definition: vtkPoints.h:80
void SetDataTypeToFloat()
Definition: vtkPoints.h:84
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:77
int Resize(vtkIdType numPoints)
Resize the internal array while conserving the data.
Definition: vtkPoints.h:275
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:143
#define VTK_UNSIGNED_INT
Definition: vtkType.h:55
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:200
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkIdType GetNumberOfPoints()
Return number of points in array.
Definition: vtkPoints.h:126
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:157
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
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:183
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:53
void SetDataTypeToLong()
Definition: vtkPoints.h:82
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkIdType InsertNextPoint(const float x[3])
Insert point into next available slot.
Definition: vtkPoints.h:198
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:154
int vtkIdType
Definition: vtkType.h:345
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:81
void SetDataTypeToChar()
Definition: vtkPoints.h:76
#define VTK_DOUBLE
Definition: vtkType.h:59
#define VTK_FLOAT
Definition: vtkType.h:58
void InsertPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:168
a simple class to control print indentation
Definition: vtkIndent.h:33
void * GetVoidPointer(const int id)
Return a void pointer.
Definition: vtkPoints.h:91
list of point or cell ids
Definition: vtkIdList.h:30
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
#define VTK_SHORT
Definition: vtkType.h:52
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:83
#define VTK_CHAR
Definition: vtkType.h:49
#define VTK_LONG
Definition: vtkType.h:56
virtual void Modified()
Update the modification time for this object.
double * GetPoint(vtkIdType id)
Return a pointer to a double point x[3] for a specific id.
Definition: vtkPoints.h:134
void SetNumberOfPoints(vtkIdType numPoints)
Specify the number of points for this object to hold.
Definition: vtkPoints.h:268
#define VTK_SIZEHINT(...)
void Reset()
Reset to an empty state, without freeing any memory.
boost::graph_traits< vtkGraph *>::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void SetDataTypeToBit()
Definition: vtkPoints.h:75
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:51
void SetDataTypeToShort()
Definition: vtkPoints.h:78
#define VTK_BIT
Definition: vtkType.h:48
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:79
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:57
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Copy n consecutive points starting at srcStart from the source array to this array, starting at the dstStart location.
Definition: vtkPoints.h:191
vtkDataArray * GetData()
Definition: vtkPoints.h:63
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void Squeeze()
Reclaim any extra memory.
Definition: vtkPoints.h:96
void SetDataTypeToDouble()
Definition: vtkPoints.h:85
#define VTK_EXPECTS(x)
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:171
#define VTK_INT
Definition: vtkType.h:54
represent and manipulate 3D points
Definition: vtkPoints.h:33