VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkPoints2D.h
Go to the documentation of this file.
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();
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 numPoints);
00156 
00159   int Resize(vtkIdType numPoints);
00160 
00162   void GetPoints(vtkIdList *ptId, vtkPoints2D *fp);
00163 
00165   virtual void ComputeBounds();
00166 
00168   double *GetBounds();
00169 
00171   void GetBounds(double bounds[4]);
00172 
00173 protected:
00174   vtkPoints2D(int dataType = VTK_FLOAT);
00175   ~vtkPoints2D();
00176 
00177   double Bounds[4];
00178   vtkTimeStamp ComputeTime; // Time at which bounds computed
00179   vtkDataArray *Data;  // Array which represents data
00180 
00181 private:
00182   vtkPoints2D(const vtkPoints2D&);  // Not implemented.
00183   void operator=(const vtkPoints2D&);  // Not implemented.
00184 };
00185 
00186 inline void vtkPoints2D::Reset()
00187 {
00188   this->Data->Reset();
00189   this->Modified();
00190 }
00191 
00192 inline void vtkPoints2D::SetNumberOfPoints(vtkIdType numPoints)
00193 {
00194   this->Data->SetNumberOfComponents(2);
00195   this->Data->SetNumberOfTuples(numPoints);
00196   this->Modified();
00197 }
00198 
00199 inline int vtkPoints2D::Resize(vtkIdType numPoints)
00200 {
00201   this->Data->SetNumberOfComponents(2);
00202   this->Modified();
00203   return this->Data->Resize(numPoints);
00204 }
00205 
00206 inline void vtkPoints2D::SetPoint(vtkIdType id, double x, double y)
00207 {
00208   double p[2] = { x, y };
00209   this->Data->SetTuple(id, p);
00210 }
00211 
00212 inline void vtkPoints2D::InsertPoint(vtkIdType id, double x, double y)
00213 {
00214   double p[2] = { x, y };
00215   this->Data->InsertTuple(id, p);
00216 }
00217 
00218 inline vtkIdType vtkPoints2D::InsertNextPoint(double x, double y)
00219 {
00220   double p[2] = { x, y };
00221   return this->Data->InsertNextTuple(p);
00222 }
00223 
00224 #endif