VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkPoints.h
Go to the documentation of this file.
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 
00038 class VTKCOMMONCORE_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();
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 
00147   void InsertPoints(vtkIdList *dstIds, vtkIdList *srcIds, vtkPoints *source)
00148     { this->Data->InsertTuples(dstIds, srcIds, source->Data); }
00150 
00152 
00155   void InsertPoints(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
00156                     vtkPoints* source)
00157     { this->Data->InsertTuples(dstStart, n, srcStart, source->Data); }
00159 
00161 
00162   vtkIdType InsertNextPoint(const float x[3])
00163     { return this->Data->InsertNextTuple(x); }
00164   vtkIdType InsertNextPoint(const double x[3])
00165     { return this->Data->InsertNextTuple(x); }
00166   vtkIdType InsertNextPoint(double x, double y, double z);
00168 
00172   void SetNumberOfPoints(vtkIdType numPoints);
00173 
00176   int Resize(vtkIdType numPoints);
00177 
00179   void GetPoints(vtkIdList *ptId, vtkPoints *fp);
00180 
00182   virtual void ComputeBounds();
00183 
00185   double *GetBounds();
00186 
00188   void GetBounds(double bounds[6]);
00189 
00190 protected:
00191   vtkPoints(int dataType = VTK_FLOAT);
00192   ~vtkPoints();
00193 
00194   double Bounds[6];
00195   vtkTimeStamp ComputeTime; // Time at which bounds computed
00196   vtkDataArray *Data;  // Array which represents data
00197 
00198 private:
00199   vtkPoints(const vtkPoints&);  // Not implemented.
00200   void operator=(const vtkPoints&);  // Not implemented.
00201 };
00202 
00203 inline void vtkPoints::Reset()
00204 {
00205   this->Data->Reset();
00206   this->Modified();
00207 }
00208 
00209 inline void vtkPoints::SetNumberOfPoints(vtkIdType numPoints)
00210 {
00211   this->Data->SetNumberOfComponents(3);
00212   this->Data->SetNumberOfTuples(numPoints);
00213   this->Modified();
00214 }
00215 
00216 inline int vtkPoints::Resize(vtkIdType numPoints)
00217 {
00218   this->Data->SetNumberOfComponents(3);
00219   this->Modified();
00220   return this->Data->Resize(numPoints);
00221 }
00222 
00223 inline void vtkPoints::SetPoint(vtkIdType id, double x, double y, double z)
00224 {
00225   double p[3] = { x, y, z };
00226   this->Data->SetTuple(id, p);
00227 }
00228 
00229 inline void vtkPoints::InsertPoint(vtkIdType id, double x, double y, double z)
00230 {
00231   double p[3] = { x, y, z };
00232   this->Data->InsertTuple(id, p);
00233 }
00234 
00235 inline vtkIdType vtkPoints::InsertNextPoint(double x, double y, double z)
00236 {
00237   double p[3] = { x, y, z };
00238   return this->Data->InsertNextTuple(p);
00239 }
00240 
00241 #endif
00242