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 "vtkObject.h"
32 
33 #include "vtkDataArray.h" // Needed for inline methods
34 
35 class vtkIdList;
36 class vtkPoints;
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() {this->Data->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 
145  vtkIdType InsertNextPoint(const float x[3]) {
146  return this->Data->InsertNextTuple(x);};
147  vtkIdType InsertNextPoint(const double x[3]) {
148  return this->Data->InsertNextTuple(x);};
149  vtkIdType InsertNextPoint(double x, double y, double z);
151 
155  void SetNumberOfPoints(vtkIdType number);
156 
158  void GetPoints(vtkIdList *ptId, vtkPoints *fp);
159 
161  virtual void ComputeBounds();
162 
164  double *GetBounds();
165 
167  void GetBounds(double bounds[6]);
168 
169 protected:
170  vtkPoints(int dataType=VTK_FLOAT);
171  ~vtkPoints();
172 
173  double Bounds[6];
174  vtkTimeStamp ComputeTime; // Time at which bounds computed
175  vtkDataArray *Data; // Array which represents data
176 
177 private:
178  vtkPoints(const vtkPoints&); // Not implemented.
179  void operator=(const vtkPoints&); // Not implemented.
180 };
181 
183 {
184  this->Data->SetNumberOfComponents(3);
185  this->Data->SetNumberOfTuples(number);
186 }
187 
188 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
189 {
190  double p[3];
191  p[0] = x;
192  p[1] = y;
193  p[2] = z;
194  this->Data->SetTuple(id,p);
195 }
196 
197 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
198 {
199  double p[3];
200 
201  p[0] = x;
202  p[1] = y;
203  p[2] = z;
204  this->Data->InsertTuple(id,p);
205 }
206 
207 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
208 {
209  double p[3];
210 
211  p[0] = x;
212  p[1] = y;
213  p[2] = z;
214  return this->Data->InsertNextTuple(p);
215 }
216 
217 #endif
218 
void SetDataTypeToInt()
Definition: vtkPoints.h:78
void SetDataTypeToFloat()
Definition: vtkPoints.h:82
void SetDataTypeToUnsignedChar()
Definition: vtkPoints.h:75
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:60
vtkIdType InsertNextPoint(const double x[3])
Definition: vtkPoints.h:147
vtkIdType GetNumberOfPoints()
Definition: vtkPoints.h:113
void SetPoint(vtkIdType id, const double x[3])
Definition: vtkPoints.h:129
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:30
void SetDataTypeToLong()
Definition: vtkPoints.h:80
record modification and/or execution time
Definition: vtkTimeStamp.h:33
vtkIdType InsertNextPoint(const float x[3])
Definition: vtkPoints.h:145
void SetPoint(vtkIdType id, const float x[3])
Definition: vtkPoints.h:128
virtual void SetNumberOfTuples(vtkIdType number)=0
void SetNumberOfPoints(vtkIdType number)
Definition: vtkPoints.h:182
vtkDataArray * Data
Definition: vtkPoints.h:175
int vtkIdType
Definition: vtkType.h:255
void SetDataTypeToUnsignedInt()
Definition: vtkPoints.h:79
void SetDataTypeToChar()
Definition: vtkPoints.h:74
#define VTK_DOUBLE
Definition: vtkType.h:36
virtual void Reset()
Definition: vtkPoints.h:94
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)
a simple class to control print indentation
Definition: vtkIndent.h:37
void * GetVoidPointer(const int id)
Definition: vtkPoints.h:88
list of point or cell ids
Definition: vtkIdList.h:34
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
#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
#define VTK_COMMON_EXPORT
double * GetPoint(vtkIdType id)
Definition: vtkPoints.h:119
vtkTimeStamp ComputeTime
Definition: vtkPoints.h:174
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
virtual void SetNumberOfComponents(int)
void SetDataTypeToBit()
Definition: vtkPoints.h:73
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:28
void SetDataTypeToShort()
Definition: vtkPoints.h:76
#define VTK_BIT
Definition: vtkType.h:25
void SetDataTypeToUnsignedShort()
Definition: vtkPoints.h:77
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:34
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