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
void SetDataTypeToDouble()
Definition: vtkPoints2D.h:79
void InsertPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:134
void SetNumberOfPoints(vtkIdType number)
Definition: vtkPoints2D.h:178
#define VTK_UNSIGNED_INT
Definition: vtkType.h:32
abstract base class for most VTK objects
Definition: vtkObject.h:60
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:30
void SetDataTypeToUnsignedChar()
Definition: vtkPoints2D.h:71
void * GetVoidPointer(const int id)
Definition: vtkPoints2D.h:84
virtual void Reset()
Definition: vtkPoints2D.h:90
void InsertPoint(vtkIdType id, const float x[2])
Definition: vtkPoints2D.h:132
record modification and/or execution time
Definition: vtkTimeStamp.h:33
vtkDataArray * GetData()
Definition: vtkPoints2D.h:59
virtual void SetNumberOfTuples(vtkIdType number)=0
int vtkIdType
Definition: vtkType.h:255
void GetPoint(vtkIdType id, double x[2])
Definition: vtkPoints2D.h:118
void SetDataTypeToUnsignedShort()
Definition: vtkPoints2D.h:73
#define VTK_DOUBLE
Definition: vtkType.h:36
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
#define VTK_FLOAT
Definition: vtkType.h:35
vtkTimeStamp ComputeTime
Definition: vtkPoints2D.h:170
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
represent and manipulate 2D points
Definition: vtkPoints2D.h:34
list of point or cell ids
Definition: vtkIdList.h:34
void SetPoint(vtkIdType id, const float x[2])
Definition: vtkPoints2D.h:124
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
#define VTK_SHORT
Definition: vtkType.h:29
#define VTK_CHAR
Definition: vtkType.h:26
#define VTK_LONG
Definition: vtkType.h:33
#define VTK_COMMON_EXPORT
void SetDataTypeToUnsignedInt()
Definition: vtkPoints2D.h:75
virtual void Squeeze()
Definition: vtkPoints2D.h:87
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
vtkDataArray * Data
Definition: vtkPoints2D.h:171
void SetPoint(vtkIdType id, const double x[2])
Definition: vtkPoints2D.h:125
virtual void SetNumberOfComponents(int)
double * GetPoint(vtkIdType id)
Definition: vtkPoints2D.h:115
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:28
vtkIdType InsertNextPoint(const float x[2])
Definition: vtkPoints2D.h:141
void SetDataTypeToInt()
Definition: vtkPoints2D.h:74
#define VTK_BIT
Definition: vtkType.h:25
void SetDataTypeToBit()
Definition: vtkPoints2D.h:69
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:34
vtkIdType GetNumberOfPoints()
Definition: vtkPoints2D.h:109
void SetDataTypeToChar()
Definition: vtkPoints2D.h:70
void SetDataTypeToFloat()
Definition: vtkPoints2D.h:78
static vtkObject * New()
void SetDataTypeToUnsignedLong()
Definition: vtkPoints2D.h:77
void SetDataTypeToShort()
Definition: vtkPoints2D.h:72
vtkIdType InsertNextPoint(const double x[2])
Definition: vtkPoints2D.h:143
void SetDataTypeToLong()
Definition: vtkPoints2D.h:76
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
#define VTK_INT
Definition: vtkType.h:31