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 00159 void GetPoints(vtkIdList *ptId, vtkPoints *fp); 00160 00162 virtual void ComputeBounds(); 00163 00165 double *GetBounds(); 00166 00168 void GetBounds(double bounds[6]); 00169 00170 protected: 00171 vtkPoints(int dataType=VTK_FLOAT); 00172 ~vtkPoints(); 00173 00174 double Bounds[6]; 00175 vtkTimeStamp ComputeTime; // Time at which bounds computed 00176 vtkDataArray *Data; // Array which represents data 00177 00178 private: 00179 vtkPoints(const vtkPoints&); // Not implemented. 00180 void operator=(const vtkPoints&); // Not implemented. 00181 }; 00182 00183 inline void vtkPoints::SetNumberOfPoints(vtkIdType number) 00184 { 00185 this->Data->SetNumberOfComponents(3); 00186 this->Data->SetNumberOfTuples(number); 00187 } 00188 00189 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z) 00190 { 00191 double p[3]; 00192 p[0] = x; 00193 p[1] = y; 00194 p[2] = z; 00195 this->Data->SetTuple(id,p); 00196 } 00197 00198 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z) 00199 { 00200 double p[3]; 00201 00202 p[0] = x; 00203 p[1] = y; 00204 p[2] = z; 00205 this->Data->InsertTuple(id,p); 00206 } 00207 00208 inline vtkIdType vtkPoints::InsertNextPoint(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 return this->Data->InsertNextTuple(p); 00216 } 00217 00218 #endif 00219