VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPoints2D.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00025 #ifndef __vtkPoints2D_h 00026 #define __vtkPoints2D_h 00027 00028 #include "vtkObject.h" 00029 00030 #include "vtkDataArray.h" // Needed for inline methods 00031 00032 class vtkIdList; 00033 00034 class VTK_COMMON_EXPORT vtkPoints2D : public vtkObject 00035 { 00036 public: 00037 //BTX 00038 static vtkPoints2D *New(int dataType); 00039 //ETX 00040 static vtkPoints2D *New(); 00041 00042 vtkTypeMacro(vtkPoints2D, vtkObject); 00043 void PrintSelf(ostream& os, vtkIndent indent); 00044 00046 virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000); 00047 00049 virtual void Initialize(); 00050 00052 00058 virtual void SetData(vtkDataArray *); 00059 vtkDataArray *GetData() {return this->Data;} 00061 00064 virtual int GetDataType(); 00065 00067 00068 virtual void SetDataType(int dataType); 00069 void SetDataTypeToBit() {this->SetDataType(VTK_BIT);} 00070 void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);} 00071 void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);} 00072 void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);} 00073 void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);} 00074 void SetDataTypeToInt() {this->SetDataType(VTK_INT);} 00075 void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);} 00076 void SetDataTypeToLong() {this->SetDataType(VTK_LONG);} 00077 void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);} 00078 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);} 00079 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);} 00081 00084 void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);}; 00085 00087 virtual void Squeeze() {this->Data->Squeeze();}; 00088 00090 virtual void Reset() {this->Data->Reset();}; 00091 00093 00096 virtual void DeepCopy(vtkPoints2D *ad); 00097 virtual void ShallowCopy(vtkPoints2D *ad); 00099 00106 unsigned long GetActualMemorySize(); 00107 00109 vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();} 00110 00115 double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);} 00116 00118 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x);} 00119 00121 00124 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x);} 00125 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x);} 00126 void SetPoint(vtkIdType id, double x, double y); 00128 00130 00132 void InsertPoint(vtkIdType id, const float x[2]) 00133 { this->Data->InsertTuple(id,x);} 00134 void InsertPoint(vtkIdType id, const double x[2]) 00135 {this->Data->InsertTuple(id,x);} 00136 void InsertPoint(vtkIdType id, double x, double y); 00138 00140 00141 vtkIdType InsertNextPoint(const float x[2]) { 00142 return this->Data->InsertNextTuple(x);} 00143 vtkIdType InsertNextPoint(const double x[2]) { 00144 return this->Data->InsertNextTuple(x);} 00145 vtkIdType InsertNextPoint(double x, double y); 00147 00149 void RemovePoint(vtkIdType id) {this->Data->RemoveTuple(id);} 00150 00154 void SetNumberOfPoints(vtkIdType number); 00155 00157 void GetPoints(vtkIdList *ptId, vtkPoints2D *fp); 00158 00160 virtual void ComputeBounds(); 00161 00163 double *GetBounds(); 00164 00166 void GetBounds(double bounds[4]); 00167 00168 protected: 00169 vtkPoints2D(int dataType=VTK_FLOAT); 00170 ~vtkPoints2D(); 00171 00172 double Bounds[4]; 00173 vtkTimeStamp ComputeTime; // Time at which bounds computed 00174 vtkDataArray *Data; // Array which represents data 00175 00176 private: 00177 vtkPoints2D(const vtkPoints2D&); // Not implemented. 00178 void operator=(const vtkPoints2D&); // Not implemented. 00179 }; 00180 00181 inline void vtkPoints2D::SetNumberOfPoints(vtkIdType number) 00182 { 00183 this->Data->SetNumberOfComponents(2); 00184 this->Data->SetNumberOfTuples(number); 00185 } 00186 00187 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y) 00188 { 00189 double p[2] = { x, y }; 00190 this->Data->SetTuple(id,p); 00191 } 00192 00193 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y) 00194 { 00195 double p[2] = { x, y }; 00196 this->Data->InsertTuple(id,p); 00197 } 00198 00199 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y) 00200 { 00201 double p[2] = { x, y }; 00202 return this->Data->InsertNextTuple(p); 00203 } 00204 00205 #endif