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 "vtkCommonCoreModule.h" // For export macro 00032 #include "vtkObject.h" 00033 00034 #include "vtkDataArray.h" // Needed for inline methods 00035 00036 class vtkIdList; 00037 class vtkPoints; 00038 00039 class VTKCOMMONCORE_EXPORT vtkPoints : public vtkObject 00040 { 00041 public: 00042 //BTX 00043 static vtkPoints *New(int dataType); 00044 //ETX 00045 static vtkPoints *New(); 00046 00047 vtkTypeMacro(vtkPoints,vtkObject); 00048 void PrintSelf(ostream& os, vtkIndent indent); 00049 00051 virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000); 00052 00054 virtual void Initialize(); 00055 00057 00063 virtual void SetData(vtkDataArray *); 00064 vtkDataArray *GetData() {return this->Data;}; 00066 00069 virtual int GetDataType(); 00070 00072 00073 virtual void SetDataType(int dataType); 00074 void SetDataTypeToBit() {this->SetDataType(VTK_BIT);}; 00075 void SetDataTypeToChar() {this->SetDataType(VTK_CHAR);}; 00076 void SetDataTypeToUnsignedChar() {this->SetDataType(VTK_UNSIGNED_CHAR);}; 00077 void SetDataTypeToShort() {this->SetDataType(VTK_SHORT);}; 00078 void SetDataTypeToUnsignedShort() {this->SetDataType(VTK_UNSIGNED_SHORT);}; 00079 void SetDataTypeToInt() {this->SetDataType(VTK_INT);}; 00080 void SetDataTypeToUnsignedInt() {this->SetDataType(VTK_UNSIGNED_INT);}; 00081 void SetDataTypeToLong() {this->SetDataType(VTK_LONG);}; 00082 void SetDataTypeToUnsignedLong() {this->SetDataType(VTK_UNSIGNED_LONG);}; 00083 void SetDataTypeToFloat() {this->SetDataType(VTK_FLOAT);}; 00084 void SetDataTypeToDouble() {this->SetDataType(VTK_DOUBLE);}; 00086 00089 void *GetVoidPointer(const int id) {return this->Data->GetVoidPointer(id);}; 00090 00092 virtual void Squeeze() {this->Data->Squeeze();}; 00093 00095 virtual void Reset() {this->Data->Reset();}; 00096 00098 00101 virtual void DeepCopy(vtkPoints *ad); 00102 virtual void ShallowCopy(vtkPoints *ad); 00104 00111 unsigned long GetActualMemorySize(); 00112 00114 vtkIdType GetNumberOfPoints() { return this->Data->GetNumberOfTuples();}; 00115 00120 double *GetPoint(vtkIdType id) { return this->Data->GetTuple(id);}; 00121 00123 void GetPoint(vtkIdType id, double x[3]) { this->Data->GetTuple(id,x);}; 00124 00126 00129 void SetPoint(vtkIdType id, const float x[3]) { this->Data->SetTuple(id,x);}; 00130 void SetPoint(vtkIdType id, const double x[3]) { this->Data->SetTuple(id,x);}; 00131 void SetPoint(vtkIdType id, double x, double y, double z); 00133 00135 00137 void InsertPoint(vtkIdType id, const float x[3]) 00138 { this->Data->InsertTuple(id,x);}; 00139 void InsertPoint(vtkIdType id, const double x[3]) 00140 {this->Data->InsertTuple(id,x);}; 00141 void InsertPoint(vtkIdType id, double x, double y, double z); 00143 00145 00146 vtkIdType InsertNextPoint(const float x[3]) { 00147 return this->Data->InsertNextTuple(x);}; 00148 vtkIdType InsertNextPoint(const double x[3]) { 00149 return this->Data->InsertNextTuple(x);}; 00150 vtkIdType InsertNextPoint(double x, double y, double z); 00152 00156 void SetNumberOfPoints(vtkIdType number); 00157 00160 int Resize(vtkIdType numPoints); 00161 00163 void GetPoints(vtkIdList *ptId, vtkPoints *fp); 00164 00166 virtual void ComputeBounds(); 00167 00169 double *GetBounds(); 00170 00172 void GetBounds(double bounds[6]); 00173 00174 protected: 00175 vtkPoints(int dataType=VTK_FLOAT); 00176 ~vtkPoints(); 00177 00178 double Bounds[6]; 00179 vtkTimeStamp ComputeTime; // Time at which bounds computed 00180 vtkDataArray *Data; // Array which represents data 00181 00182 private: 00183 vtkPoints(const vtkPoints&); // Not implemented. 00184 void operator=(const vtkPoints&); // Not implemented. 00185 }; 00186 00187 inline void vtkPoints::SetNumberOfPoints(vtkIdType number) 00188 { 00189 this->Data->SetNumberOfComponents(3); 00190 this->Data->SetNumberOfTuples(number); 00191 } 00192 00193 inline int vtkPoints::Resize(vtkIdType numPoints) 00194 { 00195 this->Data->SetNumberOfComponents(3); 00196 return this->Data->Resize(numPoints); 00197 } 00198 00199 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z) 00200 { 00201 double p[3]; 00202 p[0] = x; 00203 p[1] = y; 00204 p[2] = z; 00205 this->Data->SetTuple(id,p); 00206 } 00207 00208 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z) 00209 { 00210 double p[3]; 00211 00212 p[0] = x; 00213 p[1] = y; 00214 p[2] = z; 00215 this->Data->InsertTuple(id,p); 00216 } 00217 00218 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z) 00219 { 00220 double p[3]; 00221 00222 p[0] = x; 00223 p[1] = y; 00224 p[2] = z; 00225 return this->Data->InsertNextTuple(p); 00226 } 00227 00228 #endif 00229