VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/ExecutionModel/vtkAlgorithm.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkAlgorithm.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 =========================================================================*/
00040 #ifndef vtkAlgorithm_h
00041 #define vtkAlgorithm_h
00042 
00043 #include "vtkCommonExecutionModelModule.h" // For export macro
00044 #include "vtkObject.h"
00045 
00046 class vtkAbstractArray;
00047 class vtkAlgorithmInternals;
00048 class vtkAlgorithmOutput;
00049 class vtkCollection;
00050 class vtkDataArray;
00051 class vtkDataObject;
00052 class vtkExecutive;
00053 class vtkInformation;
00054 class vtkInformationInformationVectorKey;
00055 class vtkInformationIntegerKey;
00056 class vtkInformationStringKey;
00057 class vtkInformationStringVectorKey;
00058 class vtkInformationVector;
00059 class vtkProgressObserver;
00060 
00061 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
00062 {
00063 public:
00064   static vtkAlgorithm *New();
00065   vtkTypeMacro(vtkAlgorithm,vtkObject);
00066   void PrintSelf(ostream& os, vtkIndent indent);
00067 
00069 
00080   enum DesiredOutputPrecision
00081     {
00082     SINGLE_PRECISION,
00083     DOUBLE_PRECISION,
00084     DEFAULT_PRECISION
00085     };
00087 
00090   int HasExecutive();
00091 
00094   vtkExecutive* GetExecutive();
00095 
00099   virtual void SetExecutive(vtkExecutive* executive);
00100 
00102 
00116   virtual int ProcessRequest(vtkInformation* request,
00117                              vtkInformationVector** inInfo,
00118                              vtkInformationVector* outInfo);
00120 
00122 
00124   int ProcessRequest(vtkInformation* request,
00125                      vtkCollection* inInfo,
00126                      vtkInformationVector* outInfo);
00128 
00130 
00133   virtual int
00134   ComputePipelineMTime(vtkInformation* request,
00135                        vtkInformationVector** inInfoVec,
00136                        vtkInformationVector* outInfoVec,
00137                        int requestFromOutputPort,
00138                        unsigned long* mtime);
00140 
00146   virtual int ModifyRequest(vtkInformation* request, int when);
00147 
00152   vtkInformation* GetInputPortInformation(int port);
00153 
00158   vtkInformation* GetOutputPortInformation(int port);
00159 
00161 
00162   vtkGetObjectMacro(Information, vtkInformation);
00163   virtual void SetInformation(vtkInformation*);
00165 
00167   int GetNumberOfInputPorts();
00168 
00170   int GetNumberOfOutputPorts();
00171 
00173 
00174   virtual void Register(vtkObjectBase* o);
00175   virtual void UnRegister(vtkObjectBase* o);
00177 
00179 
00181   vtkSetMacro(AbortExecute,int);
00182   vtkGetMacro(AbortExecute,int);
00183   vtkBooleanMacro(AbortExecute,int);
00185 
00187 
00188   vtkSetClampMacro(Progress,double,0.0,1.0);
00189   vtkGetMacro(Progress,double);
00191 
00195   void UpdateProgress(double amount);
00196 
00198 
00203   void SetProgressText(const char* ptext);
00204   vtkGetStringMacro(ProgressText);
00206 
00208 
00210   vtkGetMacro( ErrorCode, unsigned long );
00212 
00213   // left public for performance since it is used in inner loops
00214   int AbortExecute;
00215 
00218   static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
00220   static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
00222   static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
00224   static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
00226   static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
00228   static vtkInformationIntegerKey* INPUT_PORT();
00230   static vtkInformationIntegerKey* INPUT_CONNECTION();
00231 
00237   static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
00238 
00247   static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
00248 
00249 
00251 
00257   virtual void SetInputArrayToProcess(int idx, int port, int connection,
00258                               int fieldAssociation,
00259                               const char *name);
00260   virtual void SetInputArrayToProcess(int idx, int port, int connection,
00261                               int fieldAssociation,
00262                               int fieldAttributeType);
00263   virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
00265 
00267 
00281   virtual void SetInputArrayToProcess(int idx, int port, int connection,
00282                               const char* fieldAssociation,
00283                               const char* attributeTypeorName);
00285 
00287   vtkInformation *GetInputArrayInformation(int idx);
00288 
00289   // from here down are convenience methods that really are executive methods
00290 
00291 
00292 
00294   void RemoveAllInputs();
00295 
00298   vtkDataObject* GetOutputDataObject(int port);
00299 
00301 
00303   vtkDataObject *GetInputDataObject(int port,
00304                                     int connection);
00306 
00308 
00317   virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
00318   virtual void SetInputConnection(vtkAlgorithmOutput* input);
00320 
00322 
00327   virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
00328   virtual void AddInputConnection(vtkAlgorithmOutput* input);
00330 
00337   virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
00338 
00340   virtual void RemoveInputConnection(int port, int idx);
00341 
00343   virtual void RemoveAllInputConnections(int port);
00344 
00346 
00353   virtual void SetInputDataObject(int port, vtkDataObject* data);
00354   virtual void SetInputDataObject(vtkDataObject* data)
00355     { this->SetInputDataObject(0, data); }
00357 
00359 
00362   virtual void AddInputDataObject(int port, vtkDataObject* data);
00363   virtual void AddInputDataObject(vtkDataObject* data)
00364     { this->AddInputDataObject(0, data); }
00366 
00368 
00372   vtkAlgorithmOutput* GetOutputPort(int index);
00373   vtkAlgorithmOutput* GetOutputPort() {
00374     return this->GetOutputPort(0); }
00376 
00378   int GetNumberOfInputConnections(int port);
00379 
00381   int GetTotalNumberOfInputConnections();
00382 
00384   vtkAlgorithmOutput* GetInputConnection(int port, int index);
00385 
00388   vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
00389 
00391   vtkAlgorithm* GetInputAlgorithm(int port, int index);
00392 
00394 
00395   vtkAlgorithm* GetInputAlgorithm()
00396   {
00397     return this->GetInputAlgorithm(0, 0);
00398   }
00400 
00402   vtkExecutive* GetInputExecutive(int port, int index);
00403 
00405 
00406   vtkExecutive* GetInputExecutive()
00407   {
00408     return this->GetInputExecutive(0, 0);
00409   }
00411 
00418   vtkInformation* GetInputInformation(int port, int index);
00419 
00421 
00422   vtkInformation* GetInputInformation()
00423   {
00424     return this->GetInputInformation(0, 0);
00425   }
00427 
00432   vtkInformation* GetOutputInformation(int port);
00433 
00435 
00436   virtual void Update(int port);
00437   virtual void Update();
00439 
00440 
00442   virtual void UpdateInformation();
00443 
00445   virtual void UpdateDataObject();
00446 
00448   virtual void PropagateUpdateExtent();
00449 
00451   virtual void UpdateWholeExtent();
00452 
00455   void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
00456 
00457   //======================================================================
00458   //The following block of code is to support old style VTK applications. If
00459   //you are using these calls there are better ways to do it in the new
00460   //pipeline
00461   //======================================================================
00462 
00464 
00465   virtual void SetReleaseDataFlag(int);
00466   virtual int GetReleaseDataFlag();
00467   void ReleaseDataFlagOn();
00468   void ReleaseDataFlagOff();
00470 
00471   //========================================================================
00472 
00474 
00478   int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
00479   int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
00481 
00484   static void SetDefaultExecutivePrototype(vtkExecutive* proto);
00485 
00490   int SetUpdateExtentToWholeExtent(int port);
00491 
00495   int SetUpdateExtentToWholeExtent();
00496 
00498 
00499   void SetUpdateExtent(int port,
00500                        int piece,int numPieces, int ghostLevel);
00502 
00504 
00506   void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
00507   {
00508     this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
00509   }
00511 
00513   void SetUpdateExtent(int port, int extent[6]);
00514 
00516 
00517   void SetUpdateExtent(int extent[6])
00518   {
00519     this->SetUpdateExtent(0, extent);
00520   }
00522 
00524 
00526   int* GetUpdateExtent()
00527   {
00528     return this->GetUpdateExtent(0);
00529   }
00530   int* GetUpdateExtent(int port);
00531   void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
00532                        int& z0, int& z1)
00533   {
00534     this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
00535   }
00536   void GetUpdateExtent(int port,
00537                        int& x0, int& x1, int& y0, int& y1,
00538                        int& z0, int& z1);
00539   void GetUpdateExtent(int extent[6])
00540   {
00541     this->GetUpdateExtent(0, extent);
00542   }
00543   void GetUpdateExtent(int port, int extent[6]);
00545 
00547 
00549   int GetUpdatePiece()
00550   {
00551     return this->GetUpdatePiece(0);
00552   }
00553   int GetUpdatePiece(int port);
00554   int GetUpdateNumberOfPieces()
00555   {
00556     return this->GetUpdateNumberOfPieces(0);
00557   }
00558   int GetUpdateNumberOfPieces(int port);
00559   int GetUpdateGhostLevel()
00560   {
00561     return this->GetUpdateGhostLevel(0);
00562   }
00563   int GetUpdateGhostLevel(int port);
00565 
00567 
00573   void SetProgressObserver(vtkProgressObserver*);
00574   vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
00576 
00577 protected:
00578   vtkAlgorithm();
00579   ~vtkAlgorithm();
00580 
00581   // Keys used to indicate that input/output port information has been
00582   // filled.
00583   static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
00584 
00585   // Arbitrary extra information associated with this algorithm
00586   vtkInformation* Information;
00587 
00591   virtual int FillInputPortInformation(int port, vtkInformation* info);
00592 
00596   virtual int FillOutputPortInformation(int port, vtkInformation* info);
00597 
00599   virtual void SetNumberOfInputPorts(int n);
00600 
00602   virtual void SetNumberOfOutputPorts(int n);
00603 
00604   // Helper methods to check input/output port index ranges.
00605   int InputPortIndexInRange(int index, const char* action);
00606   int OutputPortIndexInRange(int index, const char* action);
00607 
00611   int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
00612 
00614 
00620   int GetInputArrayAssociation(int idx, int connection,
00621                                vtkInformationVector **inputVector);
00622   int GetInputArrayAssociation(int idx, vtkDataObject* input);
00624 
00625 
00627 
00629   vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
00630   vtkDataArray *GetInputArrayToProcess(int idx,
00631                                        vtkInformationVector **inputVector,
00632                                        int& association);
00634 
00636 
00642   vtkDataArray *GetInputArrayToProcess(int idx,
00643                                        int connection,
00644                                        vtkInformationVector **inputVector);
00645   vtkDataArray *GetInputArrayToProcess(int idx,
00646                                        int connection,
00647                                        vtkInformationVector **inputVector,
00648                                        int& association);
00649   vtkDataArray *GetInputArrayToProcess(int idx,
00650                                        vtkDataObject* input);
00651   vtkDataArray *GetInputArrayToProcess(int idx,
00652                                        vtkDataObject* input,
00653                                        int& association);
00655 
00656 
00658 
00660   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
00661   vtkAbstractArray *GetInputAbstractArrayToProcess
00662     (int idx, vtkInformationVector **inputVector, int& association);
00664 
00666 
00672   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00673                                        int connection,
00674                                        vtkInformationVector **inputVector);
00675   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00676                                        int connection,
00677                                        vtkInformationVector **inputVector,
00678                                        int& association);
00679   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00680                                        vtkDataObject* input);
00681   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00682                                        vtkDataObject* input,
00683                                        int& association);
00685 
00686 
00687 
00689 
00694   vtkInformation *GetInputArrayFieldInformation(int idx,
00695                                                 vtkInformationVector **inputVector);
00697 
00698 
00703   virtual vtkExecutive* CreateDefaultExecutive();
00704 
00706 
00708   vtkSetMacro( ErrorCode, unsigned long );
00709   unsigned long ErrorCode;
00711 
00712   // Progress/Update handling
00713   double Progress;
00714   char  *ProgressText;
00715 
00716   // Garbage collection support.
00717   virtual void ReportReferences(vtkGarbageCollector*);
00718 
00719   // executive methods below
00720 
00722 
00726   virtual void SetNthInputConnection(int port, int index,
00727                                      vtkAlgorithmOutput* input);
00729 
00734   virtual void SetNumberOfInputConnections(int port, int n);
00735 
00736   static vtkExecutive* DefaultExecutivePrototype;
00737 
00739 
00743   void SetInputDataInternal(int port, vtkDataObject *input)
00744     { this->SetInputDataObject(port, input); }
00745   void AddInputDataInternal(int port, vtkDataObject *input)
00746     { this->AddInputDataObject(port, input); }
00748 
00749   vtkProgressObserver* ProgressObserver;
00750 
00751 private:
00752   vtkExecutive* Executive;
00753   vtkInformationVector* InputPortInformation;
00754   vtkInformationVector* OutputPortInformation;
00755   vtkAlgorithmInternals* AlgorithmInternal;
00756   static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
00757                             vtkAlgorithm* consumer, int consumerPort);
00758   static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
00759                                vtkAlgorithm* consumer, int consumerPort);
00760   static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
00761   static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
00762 
00763 private:
00764   vtkAlgorithm(const vtkAlgorithm&);  // Not implemented.
00765   void operator=(const vtkAlgorithm&);  // Not implemented.
00766 };
00767 
00768 #endif