VTK
dox/Filters/AMR/vtkAMRResampleFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003  Program:   Visualization Toolkit
00004  Module:    vtkAMRResampleFilter.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  =========================================================================*/
00035 #ifndef __vtkAMRResampleFilter_h
00036 #define __vtkAMRResampleFilter_h
00037 
00038 #include "vtkFiltersAMRModule.h" // For export macro
00039 #include "vtkMultiBlockDataSetAlgorithm.h"
00040 #include <vector> // For STL vector
00041 
00042 class vtkInformation;
00043 class vtkInformationVector;
00044 class vtkUniformGrid;
00045 class vtkOverlappingAMR;
00046 class vtkMultiBlockDataSet;
00047 class vtkMultiProcessController;
00048 class vtkFieldData;
00049 class vtkCellData;
00050 class vtkPointData;
00051 class vtkIndent;
00052 
00053 class vtkAMRBox;
00054 class VTKFILTERSAMR_EXPORT vtkAMRResampleFilter : public vtkMultiBlockDataSetAlgorithm
00055 {
00056 public:
00057   static vtkAMRResampleFilter *New();
00058   vtkTypeMacro(vtkAMRResampleFilter,vtkMultiBlockDataSetAlgorithm);
00059   void PrintSelf(ostream &oss, vtkIndent indent);
00060 
00062 
00064   vtkSetVector3Macro(NumberOfSamples,int);
00065   vtkGetVector3Macro(NumberOfSamples,int);
00067 
00069 
00070   vtkSetMacro(TransferToNodes,int);
00071   vtkGetMacro(TransferToNodes,int);
00073 
00075 
00077   vtkSetMacro(DemandDrivenMode,int);
00078   vtkGetMacro(DemandDrivenMode,int);
00080 
00082 
00083   vtkSetMacro(NumberOfPartitions,int);
00084   vtkGetMacro(NumberOfPartitions,int);
00086 
00088 
00089   vtkSetVector3Macro(Min,double);
00090   vtkGetVector3Macro(Min,double);
00092 
00094 
00095   vtkSetVector3Macro(Max,double);
00096   vtkGetVector3Macro(Max,double);
00098 
00100 
00101   vtkSetMacro(UseBiasVector,bool);
00102   vtkGetMacro(UseBiasVector,bool);
00104 
00106 
00109   vtkSetVector3Macro(BiasVector,double);
00110   vtkGetVector3Macro(BiasVector,double);
00112 
00114 
00115   vtkSetMacro(Controller, vtkMultiProcessController*);
00116   vtkGetMacro(Controller, vtkMultiProcessController*);
00118 
00119   // Standard pipeline routines
00120 
00122 
00124   virtual int RequestInformation(
00125       vtkInformation *rqst,
00126       vtkInformationVector **inputVector,
00127       vtkInformationVector *outputVector );
00129 
00130   virtual int RequestData(
00131        vtkInformation*,vtkInformationVector**,vtkInformationVector*);
00132   virtual int FillInputPortInformation(int port, vtkInformation *info);
00133   virtual int FillOutputPortInformation(int port, vtkInformation *info);
00134 
00136 
00137   virtual int RequestUpdateExtent(
00138       vtkInformation*, vtkInformationVector**, vtkInformationVector* );
00140 
00141 
00142 protected:
00143   vtkAMRResampleFilter();
00144   virtual ~vtkAMRResampleFilter();
00145 
00146   vtkOverlappingAMR *AMRMetaData;
00147   vtkMultiBlockDataSet *ROI; // Pointer to the region of interest.
00148   int NumberOfSamples[3];
00149   int GridNumberOfSamples[3];
00150   double Min[3];
00151   double Max[3];
00152   double GridMin[3];
00153   double GridMax[3];
00154   int LevelOfResolution;
00155   int NumberOfPartitions;
00156   int TransferToNodes;
00157   int DemandDrivenMode;
00158   vtkMultiProcessController *Controller;
00159   bool UseBiasVector;
00160   double BiasVector[3];
00161 
00162   // Debugging Stuff
00163   int NumberOfBlocksTestedForLevel;
00164   int NumberOfBlocksTested;
00165   int NumberOfBlocksVisSkipped;
00166   int NumberOfTimesFoundOnDonorLevel;
00167   int NumberOfTimesLevelUp;
00168   int NumberOfTimesLevelDown;
00169   int NumberOfFailedPoints;
00170   double AverageLevel;
00171 // BTX
00172   std::vector< int > BlocksToLoad; // Holds the ids of the blocks to load.
00173 // ETX
00174 
00176   bool IsParallel();
00177 
00180   bool IsRegionMine( const int regionIdx );
00181 
00184   int GetRegionProcessId( const int regionIdx );
00185 
00187 
00189   void ComputeCellCentroid(
00190       vtkUniformGrid *g, const vtkIdType cellIdx, double c[3] );
00192 
00197   void InitializeFields( vtkFieldData *f, vtkIdType size, vtkCellData *src );
00198 
00200 
00201   void CopyData( vtkFieldData *target, vtkIdType targetIdx,
00202                  vtkCellData *src, vtkIdType srcIdx );
00204 
00208   bool FoundDonor(double q[3],vtkUniformGrid *&donorGrid,int &cellIdx);
00209 
00210 
00212 
00215   bool SearchForDonorGridAtLevel(
00216       double q[3], vtkOverlappingAMR *amrds,
00217       unsigned int level, unsigned int& gridId,
00218       int &donorCellIdx);
00220 
00222 
00226   int ProbeGridPointInAMR(
00227     double q[3], unsigned int &donorLevel, unsigned int& donorGridId,
00228       vtkOverlappingAMR *amrds, unsigned int maxLevel, bool useCached);
00230 
00232 
00237   int ProbeGridPointInAMRGraph(double q[3],
00238                                unsigned int &donorLevel,  unsigned int &donorGridId,
00239                                vtkOverlappingAMR *amrds, unsigned int maxLevel, bool useCached);
00241 
00243 
00245   void TransferToCellCenters(
00246       vtkUniformGrid *g, vtkOverlappingAMR *amrds );
00248 
00250 
00252   void TransferToGridNodes(
00253       vtkUniformGrid *g, vtkOverlappingAMR *amrds );
00255 
00257 
00258   void TransferSolution(
00259       vtkUniformGrid *g, vtkOverlappingAMR *amrds);
00261 
00263 
00264   void ExtractRegion(
00265       vtkOverlappingAMR *amrds, vtkMultiBlockDataSet *mbds,
00266       vtkOverlappingAMR *metadata );
00268 
00271   bool IsBlockWithinBounds( double *grd );
00272 
00276   void ComputeAMRBlocksToLoad( vtkOverlappingAMR *metadata );
00277 
00279 
00280   void ComputeRegionParameters(
00281       vtkOverlappingAMR *amrds,
00282       int N[3], double min[3], double max[3], double h[3] );
00284 
00286 
00287   void GetDomainParameters(
00288       vtkOverlappingAMR *amr,
00289       double domainMin[3], double domainMax[3], double h[3],
00290       int dims[3], double &rf );
00292 
00294 
00295   bool RegionIntersectsWithAMR(
00296       double domainMin[3], double domainMax[3],
00297       double regionMin[3], double regionMax[3] );
00299 
00301 
00303   void AdjustNumberOfSamplesInRegion(const double Rh[3],
00304       const bool outside[6], int N[3] );
00306 
00308 
00311   void ComputeLevelOfResolution(
00312       const int N[3], const double h0[3], const double L[3], const double rf);
00314 
00316 
00321   void SnapBounds(
00322     const double h0[3], const double domainMin[3], const double domainMax[3],
00323     const int dims[3], bool outside[6] );
00325 
00327 
00331   void ComputeAndAdjustRegionParameters(
00332       vtkOverlappingAMR *amrds, double h[3] );
00334 
00336   void GetRegion( double h[3] );
00337 
00339   bool GridsIntersect( double *g1, double *g2 );
00340 
00342   vtkUniformGrid* GetReferenceGrid( vtkOverlappingAMR *amrds );
00343 
00353   void SearchGridDecendants(double q[3],
00354                             vtkOverlappingAMR *amrds,
00355                             unsigned int maxLevel,
00356                             unsigned int &level,
00357                             unsigned int &gridId,
00358                             int &id);
00360 
00362 
00364   bool SearchGridAncestors(double q[3],
00365                            vtkOverlappingAMR *amrds,
00366                            unsigned int &level,
00367                            unsigned int &gridId,
00368                            int &id);
00370 
00371 
00372 private:
00373   vtkAMRResampleFilter(const vtkAMRResampleFilter&); // Not implemented
00374   void operator=(const vtkAMRResampleFilter&); // Not implemented
00375 
00376 };
00377 
00378 #endif /* __vtkAMRResampleFilter_h */