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