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 "vtkCommonCoreModule.h" // For export macro 00029 #include "vtkObject.h" 00030 00031 #include "vtkDataArray.h" // Needed for inline methods 00032 00033 class vtkIdList; 00034 00035 class VTKCOMMONCORE_EXPORT vtkPoints2D : public vtkObject 00036 { 00037 public: 00038 //BTX 00039 static vtkPoints2D *New(int dataType); 00040 //ETX 00041 static vtkPoints2D *New(); 00042 00043 vtkTypeMacro(vtkPoints2D, vtkObject); 00044 void PrintSelf(ostream& os, vtkIndent indent); 00045 00047 virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000); 00048 00050 virtual void Initialize(); 00051 00053 00059 virtual void SetData(vtkDataArray *); 00060 vtkDataArray *GetData() {return this->Data;} 00062 00065 virtual int GetDataType(); 00066 00068 00069 virtual void SetDataType(int dataType); 00070 void SetDataTypeToBit() {this->SetDataType(VTK_BIT);} 00071 void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);} 00072 void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);} 00073 void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);} 00074 void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);} 00075 void SetDataTypeToInt() {this->SetDataType(VTK_INT);} 00076 void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);} 00077 void SetDataTypeToLong() {this->SetDataType(VTK_LONG);} 00078 void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);} 00079 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);} 00080 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);} 00082 00085 void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);}; 00086 00088 virtual void Squeeze() {this->Data->Squeeze();}; 00089 00091 virtual void Reset() {this->Data->Reset();}; 00092 00094 00097 virtual void DeepCopy(vtkPoints2D *ad); 00098 virtual void ShallowCopy(vtkPoints2D *ad); 00100 00107 unsigned long GetActualMemorySize(); 00108 00110 vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();} 00111 00116 double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);} 00117 00119 void GetPoint(vtkIdType id, double x[2]) { this->Data->GetTuple(id,x);} 00120 00122 00125 void SetPoint(vtkIdType id, const float x[2]) { this->Data->SetTuple(id,x);} 00126 void SetPoint(vtkIdType id, const double x[2]) { this->Data->SetTuple(id,x);} 00127 void SetPoint(vtkIdType id, double x, double y); 00129 00131 00133 void InsertPoint(vtkIdType id, const float x[2]) 00134 { this->Data->InsertTuple(id,x);} 00135 void InsertPoint(vtkIdType id, const double x[2]) 00136 {this->Data->InsertTuple(id,x);} 00137 void InsertPoint(vtkIdType id, double x, double y); 00139 00141 00142 vtkIdType InsertNextPoint(const float x[2]) { 00143 return this->Data->InsertNextTuple(x);} 00144 vtkIdType InsertNextPoint(const double x[2]) { 00145 return this->Data->InsertNextTuple(x);} 00146 vtkIdType InsertNextPoint(double x, double y); 00148 00150 void RemovePoint(vtkIdType id) {this->Data->RemoveTuple(id);} 00151 00155 void SetNumberOfPoints(vtkIdType number); 00156 00158 void GetPoints(vtkIdList *ptId, vtkPoints2D *fp); 00159 00161 virtual void ComputeBounds(); 00162 00164 double *GetBounds(); 00165 00167 void GetBounds(double bounds[4]); 00168 00169 protected: 00170 vtkPoints2D(int dataType=VTK_FLOAT); 00171 ~vtkPoints2D(); 00172 00173 double Bounds[4]; 00174 vtkTimeStamp ComputeTime; // Time at which bounds computed 00175 vtkDataArray *Data; // Array which represents data 00176 00177 private: 00178 vtkPoints2D(const vtkPoints2D&); // Not implemented. 00179 void operator=(const vtkPoints2D&); // Not implemented. 00180 }; 00181 00182 inline void vtkPoints2D::SetNumberOfPoints(vtkIdType number) 00183 { 00184 this->Data->SetNumberOfComponents(2); 00185 this->Data->SetNumberOfTuples(number); 00186 } 00187 00188 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y) 00189 { 00190 double p[2] = { x, y }; 00191 this->Data->SetTuple(id,p); 00192 } 00193 00194 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y) 00195 { 00196 double p[2] = { x, y }; 00197 this->Data->InsertTuple(id,p); 00198 } 00199 00200 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y) 00201 { 00202 double p[2] = { x, y }; 00203 return this->Data->InsertNextTuple(p); 00204 } 00205 00206 #endif