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) VTK_OVERRIDE;
43 
47  virtual int Allocate(const vtkIdType sz, const 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) { return this->Data->GetTuple(id); }
135 
140  void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x); }
141 
147  void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x); }
148  void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x); }
149  void SetPoint(vtkIdType id, double x, double y, double z);
150 
152 
156  void InsertPoint(vtkIdType id, const float x[3])
157  { this->Data->InsertTuple(id,x);};
158  void InsertPoint(vtkIdType id, const double x[3])
159  {this->Data->InsertTuple(id,x);};
160  void InsertPoint(vtkIdType id, double x, double y, double z);
162 
169  { this->Data->InsertTuples(dstIds, srcIds, source->Data); }
170 
176  void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
177  vtkPoints* source)
178  { this->Data->InsertTuples(dstStart, n, srcStart, source->Data); }
179 
183  vtkIdType InsertNextPoint(const float x[3])
184  { return this->Data->InsertNextTuple(x); }
185  vtkIdType InsertNextPoint(const double x[3])
186  { return this->Data->InsertNextTuple(x); }
187  vtkIdType InsertNextPoint(double x, double y, double z);
188 
194  void SetNumberOfPoints(vtkIdType numPoints);
195 
200  int Resize(vtkIdType numPoints);
201 
205  void GetPoints(vtkIdList *ptId, vtkPoints *fp);
206 
210  virtual void ComputeBounds();
211 
215  double *GetBounds();
216 
220  void GetBounds(double bounds[6]);
221 
225  vtkMTimeType GetMTime() VTK_OVERRIDE;
226 
227 protected:
228  vtkPoints(int dataType = VTK_FLOAT);
229  ~vtkPoints() VTK_OVERRIDE;
230 
231  double Bounds[6];
232  vtkTimeStamp ComputeTime; // Time at which bounds computed
233  vtkDataArray *Data; // Array which represents data
234 
235 private:
236  vtkPoints(const vtkPoints&) VTK_DELETE_FUNCTION;
237  void operator=(const vtkPoints&) VTK_DELETE_FUNCTION;
238 };
239 
240 inline void vtkPoints::Reset()
241 {
242  this->Data->Reset();
243  this->Modified();
244 }
245 
247 {
248  this->Data->SetNumberOfComponents(3);
249  this->Data->SetNumberOfTuples(numPoints);
250  this->Modified();
251 }
252 
253 inline int vtkPoints::Resize(vtkIdType numPoints)
254 {
255  this->Data->SetNumberOfComponents(3);
256  this->Modified();
257  return this->Data->Resize(numPoints);
258 }
259 
260 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
261 {
262  double p[3] = { x, y, z };
263  this->Data->SetTuple(id, p);
264 }
265 
266 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
267 {
268  double p[3] = { x, y, z };
269  this->Data->InsertTuple(id, p);
270 }
271 
272 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
273 {
274  double p[3] = { x, y, z };
275  return this->Data->InsertNextTuple(p);
276 }
277 
278 #endif
279 
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:253
void GetPoint(vtkIdType id, double x[3])
Copy point components into user provided array v[3] for specified id.
Definition: vtkPoints.h:140
#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:185
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:148
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:168
#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:183
void SetPoint(vtkIdType id, const float x[3])
Insert point into object.
Definition: vtkPoints.h:147
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:156
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
virtual vtkMTimeType GetMTime()
Return this object's modified time.
#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:246
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:176
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
void InsertPoint(vtkIdType id, const double x[3])
Insert point into object.
Definition: vtkPoints.h:158
#define VTK_INT
Definition: vtkType.h:54
represent and manipulate 3D points
Definition: vtkPoints.h:33