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 =========================================================================*/
28 #ifndef vtkPoints_h
29 #define vtkPoints_h
30 
31 #include "vtkCommonCoreModule.h" // For export macro
32 #include "vtkObject.h"
33 
34 #include "vtkDataArray.h" // Needed for inline methods
35 
36 class vtkIdList;
37 
39 {
40 public:
41 //BTX
42  static vtkPoints *New(int dataType);
43 //ETX
44  static vtkPoints *New();
45 
46  vtkTypeMacro(vtkPoints,vtkObject);
47  void PrintSelf(ostream& os, vtkIndent indent);
48 
50  virtual int Allocate(const vtkIdType sz, const vtkIdType ext = 1000);
51 
53  virtual void Initialize();
54 
56 
62  virtual void SetData(vtkDataArray *);
63  vtkDataArray *GetData() { return this->Data; }
65 
68  virtual int GetDataType();
69 
71 
72  virtual void SetDataType(int dataType);
73  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
74  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
75  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
76  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
77  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
78  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
79  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
80  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
81  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
82  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
83  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
85 
88  void *GetVoidPointer(const int id) { return this->Data->GetVoidPointer(id); }
89 
91  virtual void Squeeze() { this->Data->Squeeze(); }
92 
94  virtual void Reset();
95 
97 
100  virtual void DeepCopy(vtkPoints *ad);
101  virtual void ShallowCopy(vtkPoints *ad);
103 
110  unsigned long GetActualMemorySize();
111 
113  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples(); }
114 
119  double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id); }
120 
122  void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x); }
123 
125 
128  void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x); }
129  void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x); }
130  void SetPoint(vtkIdType id, double x, double y, double z);
132 
134 
136  void InsertPoint(vtkIdType id, const float x[3])
137  { this->Data->InsertTuple(id,x);};
138  void InsertPoint(vtkIdType id, const double x[3])
139  {this->Data->InsertTuple(id,x);};
140  void InsertPoint(vtkIdType id, double x, double y, double z);
142 
144 
148  { this->Data->InsertTuples(dstIds, srcIds, source->Data); }
150 
152 
155  void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
156  vtkPoints* source)
157  { this->Data->InsertTuples(dstStart, n, srcStart, source->Data); }
159 
161 
162  vtkIdType InsertNextPoint(const float x[3])
163  { return this->Data->InsertNextTuple(x); }
164  vtkIdType InsertNextPoint(const double x[3])
165  { return this->Data->InsertNextTuple(x); }
166  vtkIdType InsertNextPoint(double x, double y, double z);
168 
172  void SetNumberOfPoints(vtkIdType numPoints);
173 
176  int Resize(vtkIdType numPoints);
177 
179  void GetPoints(vtkIdList *ptId, vtkPoints *fp);
180 
182  virtual void ComputeBounds();
183 
185  double *GetBounds();
186 
188  void GetBounds(double bounds[6]);
189 
191  unsigned long int GetMTime();
192 
193 protected:
194  vtkPoints(int dataType = VTK_FLOAT);
195  ~vtkPoints();
196 
197  double Bounds[6];
198  vtkTimeStamp ComputeTime; // Time at which bounds computed
199  vtkDataArray *Data; // Array which represents data
200 
201 private:
202  vtkPoints(const vtkPoints&); // Not implemented.
203  void operator=(const vtkPoints&); // Not implemented.
204 };
205 
206 inline void vtkPoints::Reset()
207 {
208  this->Data->Reset();
209  this->Modified();
210 }
211 
213 {
214  this->Data->SetNumberOfComponents(3);
215  this->Data->SetNumberOfTuples(numPoints);
216  this->Modified();
217 }
218 
219 inline int vtkPoints::Resize(vtkIdType numPoints)
220 {
221  this->Data->SetNumberOfComponents(3);
222  this->Modified();
223  return this->Data->Resize(numPoints);
224 }
225 
226 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
227 {
228  double p[3] = { x, y, z };
229  this->Data->SetTuple(id, p);
230 }
231 
232 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
233 {
234  double p[3] = { x, y, z };
235  this->Data->InsertTuple(id, p);
236 }
237 
238 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
239 {
240  double p[3] = { x, y, z };
241  return this->Data->InsertNextTuple(p);
242 }
243 
244 #endif
245 
void SetDataTypeToInt()
Definition: vtkPoints.h:78
void SetDataTypeToFloat()
Definition: vtkPoints.h:82
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:75
int Resize(vtkIdType numPoints)
Definition: vtkPoints.h:219
void GetPoint(vtkIdType id, double x[3])
Definition: vtkPoints.h:122
#define VTK_UNSIGNED_INT
Definition: vtkType.h:32
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:164
vtkIdType GetNumberOfPoints()
Definition: vtkPoints.h:113
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:129
void InsertPoints(vtkIdList *dstIds, vtkIdList *srcIds, vtkPoints *source)
Definition: vtkPoints.h:147
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:30
#define VTKCOMMONCORE_EXPORT
void SetDataTypeToLong()
Definition: vtkPoints.h:80
record modification and/or execution time
Definition: vtkTimeStamp.h:34
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
vtkIdType InsertNextPoint(const float x[3])
Definition: vtkPoints.h:162
void SetPoint(vtkIdType id, const float x[3])
Definition: vtkPoints.h:128
virtual void SetNumberOfTuples(vtkIdType number)=0
vtkDataArray * Data
Definition: vtkPoints.h:199
int vtkIdType
Definition: vtkType.h:275
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:79
void SetDataTypeToChar()
Definition: vtkPoints.h:74
#define VTK_DOUBLE
Definition: vtkType.h:36
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
#define VTK_FLOAT
Definition: vtkType.h:35
void InsertPoint(vtkIdType id, const float x[3])
Definition: vtkPoints.h:136
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual unsigned long GetMTime()
a simple class to control print indentation
Definition: vtkIndent.h:38
void * GetVoidPointer(const int id)
Definition: vtkPoints.h:88
list of point or cell ids
Definition: vtkIdList.h:35
virtual int Resize(vtkIdType numTuples)=0
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTK_SHORT
Definition: vtkType.h:29
void SetDataTypeToUnsignedLong()
Definition: vtkPoints.h:81
#define VTK_CHAR
Definition: vtkType.h:26
#define VTK_LONG
Definition: vtkType.h:33
virtual void Modified()
double * GetPoint(vtkIdType id)
Definition: vtkPoints.h:119
void SetNumberOfPoints(vtkIdType numPoints)
Definition: vtkPoints.h:212
vtkTimeStamp ComputeTime
Definition: vtkPoints.h:198
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
virtual void SetNumberOfComponents(int)
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
void SetDataTypeToBit()
Definition: vtkPoints.h:73
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:28
void SetDataTypeToShort()
Definition: vtkPoints.h:76
virtual void Reset()
Definition: vtkPoints.h:206
#define VTK_BIT
Definition: vtkType.h:25
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:77
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:34
void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkPoints *source)
Definition: vtkPoints.h:155
vtkDataArray * GetData()
Definition: vtkPoints.h:63
static vtkObject * New()
virtual void Squeeze()
Definition: vtkPoints.h:91
void SetDataTypeToDouble()
Definition: vtkPoints.h:83
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
void InsertPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:138
#define VTK_INT
Definition: vtkType.h:31
represent and manipulate 3D points
Definition: vtkPoints.h:38