VTK
vtkPoints2D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPoints2D.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 =========================================================================*/
25 #ifndef __vtkPoints2D_h
26 #define __vtkPoints2D_h
27 
28 #include "vtkObject.h"
29 
30 #include "vtkDataArray.h" // Needed for inline methods
31 
32 class vtkIdList;
33 
35 {
36 public:
37 //BTX
38  static vtkPoints2D *New(int dataType);
39 //ETX
40  static vtkPoints2D *New();
41 
42  vtkTypeMacro(vtkPoints2D, vtkObject);
43  void PrintSelf(ostream& os, vtkIndent indent);
44 
46  virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
47 
49  virtual void Initialize();
50 
52 
58  virtual void SetData(vtkDataArray *);
59  vtkDataArray *GetData() {return this->Data;}
61 
64  virtual int GetDataType();
65 
67 
68  virtual void SetDataType(int dataType);
69  void SetDataTypeToBit() {this->SetDataType(VTK_BIT);}
70  void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);}
71  void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);}
72  void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);}
73  void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);}
74  void SetDataTypeToInt() {this->SetDataType(VTK_INT);}
75  void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);}
76  void SetDataTypeToLong() {this->SetDataType(VTK_LONG);}
77  void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);}
78  void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);}
79  void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);}
81 
84  void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);};
85 
87  virtual void Squeeze() {this->Data->Squeeze();};
88 
90  virtual void Reset() {this->Data->Reset();};
91 
93 
96  virtual void DeepCopy(vtkPoints2D *ad);
97  virtual void ShallowCopy(vtkPoints2D *ad);
99 
106  unsigned long GetActualMemorySize();
107 
109  vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();}
110 
115  double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);}
116 
118  void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x);}
119 
121 
124  void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x);}
125  void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x);}
126  void SetPoint(vtkIdType id, double x, double y);
128 
130 
132  void InsertPoint(vtkIdType id, const float x[2])
133  { this->Data->InsertTuple(id,x);}
134  void InsertPoint(vtkIdType id, const double x[2])
135  {this->Data->InsertTuple(id,x);}
136  void InsertPoint(vtkIdType id, double x, double y);
138 
140 
141  vtkIdType InsertNextPoint(const float x[2]) {
142  return this->Data->InsertNextTuple(x);}
143  vtkIdType InsertNextPoint(const double x[2]) {
144  return this->Data->InsertNextTuple(x);}
145  vtkIdType InsertNextPoint(double x, double y);
147 
149  void RemovePoint(vtkIdType id) {this->Data->RemoveTuple(id);}
150 
154  void SetNumberOfPoints(vtkIdType number);
155 
157  void GetPoints(vtkIdList *ptId, vtkPoints2D *fp);
158 
160  virtual void ComputeBounds();
161 
163  double *GetBounds();
164 
166  void GetBounds(double bounds[4]);
167 
168 protected:
169  vtkPoints2D(int dataType=VTK_FLOAT);
170  ~vtkPoints2D();
171 
172  double Bounds[4];
173  vtkTimeStamp ComputeTime; // Time at which bounds computed
174  vtkDataArray *Data; // Array which represents data
175 
176 private:
177  vtkPoints2D(const vtkPoints2D&); // Not implemented.
178  void operator=(const vtkPoints2D&); // Not implemented.
179 };
180 
182 {
183  this->Data->SetNumberOfComponents(2);
184  this->Data->SetNumberOfTuples(number);
185 }
186 
187 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
188 {
189  double p[2] = { x, y };
190  this->Data->SetTuple(id,p);
191 }
192 
193 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
194 {
195  double p[2] = { x, y };
196  this->Data->InsertTuple(id,p);
197 }
198 
199 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
200 {
201  double p[2] = { x, y };
202  return this->Data->InsertNextTuple(p);
203 }
204 
205 #endif