VTK
dox/Common/DataModel/vtkDataSet.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDataSet.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 =========================================================================*/
00045 #ifndef __vtkDataSet_h
00046 #define __vtkDataSet_h
00047 
00048 #include "vtkCommonDataModelModule.h" // For export macro
00049 #include "vtkDataObject.h"
00050 
00051 class vtkCell;
00052 class vtkCellData;
00053 class vtkCellIterator;
00054 class vtkCellTypes;
00055 class vtkExtentTranslator;
00056 class vtkGenericCell;
00057 class vtkIdList;
00058 class vtkPointData;
00059 
00060 class VTKCOMMONDATAMODEL_EXPORT vtkDataSet : public vtkDataObject
00061 {
00062 public:
00063   vtkTypeMacro(vtkDataSet,vtkDataObject);
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065 
00069   virtual void CopyStructure(vtkDataSet *ds) = 0;
00070 
00073   virtual void CopyAttributes(vtkDataSet *ds);
00074 
00077   virtual vtkIdType GetNumberOfPoints() = 0;
00078 
00081   virtual vtkIdType GetNumberOfCells() = 0;
00082 
00085   virtual double *GetPoint(vtkIdType ptId) = 0;
00086 
00090   virtual void GetPoint(vtkIdType id, double x[3]);
00091 
00093   virtual vtkCellIterator* NewCellIterator();
00094 
00097   virtual vtkCell *GetCell(vtkIdType cellId) = 0;
00098 
00103   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell) = 0;
00104 
00113   virtual void GetCellBounds(vtkIdType cellId, double bounds[6]);
00114 
00118   virtual int GetCellType(vtkIdType cellId) = 0;
00119 
00127   virtual void GetCellTypes(vtkCellTypes *types);
00128 
00132   virtual void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) = 0;
00133 
00137   virtual void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) = 0;
00138 
00140 
00144   virtual void GetCellNeighbors(vtkIdType cellId, vtkIdList *ptIds,
00145                                 vtkIdList *cellIds);
00147 
00149 
00153   vtkIdType FindPoint(double x, double y, double z)
00154     {
00155     double xyz[3];
00156     xyz[0] = x; xyz[1] = y; xyz[2] = z;
00157     return this->FindPoint (xyz);
00158     }
00159   virtual vtkIdType FindPoint(double x[3]) = 0;
00161 
00163 
00171   virtual vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
00172                              double tol2, int& subId, double pcoords[3],
00173                              double *weights) = 0;
00175 
00177 
00182   virtual vtkIdType FindCell(double x[3], vtkCell *cell,
00183                              vtkGenericCell *gencell, vtkIdType cellId,
00184                              double tol2, int& subId, double pcoords[3],
00185                              double *weights) = 0;
00187 
00189 
00195   virtual vtkCell *FindAndGetCell(double x[3], vtkCell *cell, vtkIdType cellId,
00196                                   double tol2, int& subId, double pcoords[3],
00197                                   double *weights);
00199 
00202   unsigned long int GetMTime();
00203 
00206   vtkCellData *GetCellData() {return this->CellData;};
00207 
00210   vtkPointData *GetPointData() {return this->PointData;};
00211 
00214   virtual void Squeeze();
00215 
00218   virtual void ComputeBounds();
00219 
00222   double *GetBounds();
00223 
00227   void GetBounds(double bounds[6]);
00228 
00230   double *GetCenter();
00231 
00234   void GetCenter(double center[3]);
00235 
00239   double GetLength();
00240 
00242   void Initialize();
00243 
00252   virtual void GetScalarRange(double range[2]);
00253 
00261   double *GetScalarRange();
00262 
00266   virtual int GetMaxCellSize() = 0;
00267 
00273   unsigned long GetActualMemorySize();
00274 
00276 
00277   int GetDataObjectType()
00278     {return VTK_DATA_SET;}
00280 
00282 
00283   void ShallowCopy(vtkDataObject *src);
00284   void DeepCopy(vtkDataObject *src);
00286 
00287 //BTX
00288   enum FieldDataType
00289   {
00290     DATA_OBJECT_FIELD=0,
00291     POINT_DATA_FIELD=1,
00292     CELL_DATA_FIELD=2
00293   };
00294 //ETX
00295 
00302   int CheckAttributes();
00303 
00305 
00307   virtual void GenerateGhostLevelArray(int update_piece,
00308                                        int update_num_pieces,
00309                                        int update_ghost_level,
00310                                        int* whole_extent,
00311                                        vtkExtentTranslator* translator);
00313 
00314   //BTX
00316 
00317   static vtkDataSet* GetData(vtkInformation* info);
00318   static vtkDataSet* GetData(vtkInformationVector* v, int i=0);
00319   //ETX
00321 
00326   virtual vtkFieldData* GetAttributesAsFieldData(int type);
00327 
00330   virtual vtkIdType GetNumberOfElements(int type);
00331 
00332 protected:
00333   // Constructor with default bounds (0,1, 0,1, 0,1).
00334   vtkDataSet();
00335   ~vtkDataSet();
00336 
00339   virtual void ComputeScalarRange();
00340 
00341   vtkCellData *CellData;   // Scalars, vectors, etc. associated w/ each cell
00342   vtkPointData *PointData;   // Scalars, vectors, etc. associated w/ each point
00343   vtkTimeStamp ComputeTime; // Time at which bounds, center, etc. computed
00344   double Bounds[6];  // (xmin,xmax, ymin,ymax, zmin,zmax) geometric bounds
00345   double Center[3];
00346 
00347   // Cached scalar range
00348   double ScalarRange[2];
00349 
00350   // Time at which scalar range is computed
00351   vtkTimeStamp ScalarRangeComputeTime;
00352 
00353 private:
00354   void InternalDataSetCopy(vtkDataSet *src);
00355   //BTX
00356   friend class vtkImageAlgorithmToDataSetFriendship;
00357   //ETX
00358 private:
00359   vtkDataSet(const vtkDataSet&);  // Not implemented.
00360   void operator=(const vtkDataSet&);    // Not implemented.
00361 };
00362 
00363 inline void vtkDataSet::GetPoint(vtkIdType id, double x[3])
00364 {
00365   double *pt = this->GetPoint(id);
00366   x[0] = pt[0]; x[1] = pt[1]; x[2] = pt[2];
00367 }
00368 
00369 #endif