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 
151  void SetNumberOfPoints(vtkIdType number);
152 
154  void GetPoints(vtkIdList *ptId, vtkPoints2D *fp);
155 
157  virtual void ComputeBounds();
158 
160  double *GetBounds();
161 
163  void GetBounds(double bounds[4]);
164 
165 protected:
166  vtkPoints2D(int dataType=VTK_FLOAT);
167  ~vtkPoints2D();
168 
169  double Bounds[4];
170  vtkTimeStamp ComputeTime; // Time at which bounds computed
171  vtkDataArray *Data; // Array which represents data
172 
173 private:
174  vtkPoints2D(const vtkPoints2D&); // Not implemented.
175  void operator=(const vtkPoints2D&); // Not implemented.
176 };
177 
179 {
180  this->Data->SetNumberOfComponents(2);
181  this->Data->SetNumberOfTuples(number);
182 }
183 
184 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
185 {
186  double p[2] = { x, y };
187  this->Data->SetTuple(id,p);
188 }
189 
190 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
191 {
192  double p[2] = { x, y };
193  this->Data->InsertTuple(id,p);
194 }
195 
196 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
197 {
198  double p[2] = { x, y };
199  return this->Data->InsertNextTuple(p);
200 }
201 
202 #endif