VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPoints.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 =========================================================================*/ 00028 #ifndef __vtkPoints_h 00029 #define __vtkPoints_h 00030 00031 #include "vtkObject.h" 00032 00033 #include "vtkDataArray.h" // Needed for inline methods 00034 00035 class vtkIdList; 00036 class vtkPoints; 00037 00038 class VTK_COMMON_EXPORT vtkPoints : public vtkObject 00039 { 00040 public: 00041 //BTX 00042 static vtkPoints *New(int dataType); 00043 //ETX 00044 static vtkPoints *New(); 00045 00046 vtkTypeMacro(vtkPoints,vtkObject); 00047 void PrintSelf(ostream& os, vtkIndent indent); 00048 00050 virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000); 00051 00053 virtual void Initialize(); 00054 00056 00062 virtual void SetData(vtkDataArray *); 00063 vtkDataArray *GetData() {return this->Data;}; 00065 00068 virtual int GetDataType(); 00069 00071 00072 virtual void SetDataType(int dataType); 00073 void SetDataTypeToBit() {this->SetDataType(VTK_BIT);}; 00074 void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);}; 00075 void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);}; 00076 void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);}; 00077 void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);}; 00078 void SetDataTypeToInt() {this->SetDataType(VTK_INT);}; 00079 void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);}; 00080 void SetDataTypeToLong() {this->SetDataType(VTK_LONG);}; 00081 void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);}; 00082 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);}; 00083 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);}; 00085 00088 void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);}; 00089 00091 virtual void Squeeze() {this->Data->Squeeze();}; 00092 00094 virtual void Reset() {this->Data->Reset();}; 00095 00097 00100 virtual void DeepCopy(vtkPoints *ad); 00101 virtual void ShallowCopy(vtkPoints *ad); 00103 00110 unsigned long GetActualMemorySize(); 00111 00113 vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();}; 00114 00119 double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);}; 00120 00122 void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x);}; 00123 00125 00128 void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x);}; 00129 void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x);}; 00130 void SetPoint(vtkIdType id, double x, double y, double z); 00132 00134 00136 void InsertPoint(vtkIdType id, const float x[3]) 00137 { this->Data->InsertTuple(id,x);}; 00138 void InsertPoint(vtkIdType id, const double x[3]) 00139 {this->Data->InsertTuple(id,x);}; 00140 void InsertPoint(vtkIdType id, double x, double y, double z); 00142 00144 00145 vtkIdType InsertNextPoint(const float x[3]) { 00146 return this->Data->InsertNextTuple(x);}; 00147 vtkIdType InsertNextPoint(const double x[3]) { 00148 return this->Data->InsertNextTuple(x);}; 00149 vtkIdType InsertNextPoint(double x, double y, double z); 00151 00155 void SetNumberOfPoints(vtkIdType number); 00156 00158 void GetPoints(vtkIdList *ptId, vtkPoints *fp); 00159 00161 virtual void ComputeBounds(); 00162 00164 double *GetBounds(); 00165 00167 void GetBounds(double bounds[6]); 00168 00169 protected: 00170 vtkPoints(int dataType=VTK_FLOAT); 00171 ~vtkPoints(); 00172 00173 double Bounds[6]; 00174 vtkTimeStamp ComputeTime; // Time at which bounds computed 00175 vtkDataArray *Data; // Array which represents data 00176 00177 private: 00178 vtkPoints(const vtkPoints&); // Not implemented. 00179 void operator=(const vtkPoints&); // Not implemented. 00180 }; 00181 00182 inline void vtkPoints::SetNumberOfPoints(vtkIdType number) 00183 { 00184 this->Data->SetNumberOfComponents(3); 00185 this->Data->SetNumberOfTuples(number); 00186 } 00187 00188 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z) 00189 { 00190 double p[3]; 00191 p[0] = x; 00192 p[1] = y; 00193 p[2] = z; 00194 this->Data->SetTuple(id,p); 00195 } 00196 00197 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z) 00198 { 00199 double p[3]; 00200 00201 p[0] = x; 00202 p[1] = y; 00203 p[2] = z; 00204 this->Data->InsertTuple(id,p); 00205 } 00206 00207 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z) 00208 { 00209 double p[3]; 00210 00211 p[0] = x; 00212 p[1] = y; 00213 p[2] = z; 00214 return this->Data->InsertNextTuple(p); 00215 } 00216 00217 #endif 00218