Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkAlgorithm.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkAlgorithm.h,v $
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 =========================================================================*/
00043 #ifndef __vtkAlgorithm_h
00044 #define __vtkAlgorithm_h
00045 
00046 #include "vtkObject.h"
00047 
00048 class vtkAlgorithmInternals;
00049 class vtkAlgorithmOutput;
00050 class vtkDataObject;
00051 class vtkExecutive;
00052 class vtkInformation;
00053 class vtkInformationInformationVectorKey;
00054 class vtkInformationIntegerKey;
00055 class vtkInformationStringKey;
00056 class vtkInformationVector;
00057 
00058 class VTK_FILTERING_EXPORT vtkAlgorithm : public vtkObject
00059 {
00060 public:
00061   static vtkAlgorithm *New();
00062   vtkTypeRevisionMacro(vtkAlgorithm,vtkObject);
00063   void PrintSelf(ostream& os, vtkIndent indent);
00064 
00067   int HasExecutive();
00068 
00071   vtkExecutive* GetExecutive();
00072 
00076   virtual void SetExecutive(vtkExecutive* executive);
00077 
00079 
00092   virtual int ProcessRequest(vtkInformation* request,
00093                                        vtkInformationVector* inInfo,
00094                                        vtkInformationVector* outInfo);
00096 
00101   vtkInformation* GetInputPortInformation(int port);
00102 
00104 
00109   vtkInformation* GetInputConnectionInformation(vtkInformationVector *inInfo,
00110                                                 int port, int connection);
00112   
00117   vtkInformation* GetOutputPortInformation(int port);
00118 
00120 
00121   vtkGetObjectMacro(Information, vtkInformation);
00122   virtual void SetInformation(vtkInformation*);
00124 
00127   vtkDataObject* GetOutputDataObject(int port);
00128 
00131   virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
00132 
00134   virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
00135 
00137   virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
00138 
00142   vtkAlgorithmOutput* GetOutputPort(int index);
00143 
00145   int GetNumberOfInputPorts();
00146 
00148   int GetNumberOfOutputPorts();
00149 
00151   int GetNumberOfInputConnections(int port);
00152 
00154   int GetTotalNumberOfInputConnections();
00155 
00157   vtkAlgorithmOutput* GetInputConnection(int port, int index);
00158 
00160   virtual void Update();
00161 
00164   virtual void UpdateInformation();
00165 
00167   virtual void UpdateWholeExtent();
00168 
00171   virtual void UnRegister(vtkObjectBase* o);
00172 
00174 
00176   vtkSetMacro(AbortExecute,int);
00177   vtkGetMacro(AbortExecute,int);
00178   vtkBooleanMacro(AbortExecute,int);
00180 
00182 
00183   vtkSetClampMacro(Progress,double,0.0,1.0);
00184   vtkGetMacro(Progress,double);
00186 
00190   void UpdateProgress(double amount);
00191 
00193 
00195   vtkSetStringMacro(ProgressText);
00196   vtkGetStringMacro(ProgressText);
00198 
00199   // left public for performance since it is used in inner loops
00200   int AbortExecute;
00201 
00203 
00204   static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
00205   static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
00206   static vtkInformationInformationVectorKey* INPUT_CONNECTION_INFORMATION();
00207   static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
00208   static vtkInformationStringKey* INPUT_REQUIRED_DATA_TYPE();
00210 
00213   void ConvertTotalInputToPortConnection(int ind, int &port, int &conn);
00214   
00215 
00216   //======================================================================
00217   //The followling block of code is to support old style VTK applications. If
00218   //you are using these calls there are better ways to do it in the new
00219   //pipeline
00220   //======================================================================
00221   
00223 
00224   void ReleaseDataFlagOn();
00225   void ReleaseDataFlagOff();
00227 
00228   //========================================================================
00229   
00230 protected:
00231   vtkAlgorithm();
00232   ~vtkAlgorithm();
00233 
00234   // Arbitrary extra information associated with this algorithm
00235   vtkInformation* Information;
00236 
00240   virtual int FillInputPortInformation(int port, vtkInformation* info);
00241 
00245   virtual int FillOutputPortInformation(int port, vtkInformation* info);
00246 
00248   virtual void SetNumberOfInputPorts(int n);
00249 
00251   virtual void SetNumberOfOutputPorts(int n);
00252 
00253   // Helper methods to check input/output port index ranges.
00254   int InputPortIndexInRange(int index, const char* action);
00255   int OutputPortIndexInRange(int index, const char* action);
00256 
00260   void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
00261 
00262   // Create a default executive.
00263   virtual vtkExecutive* CreateDefaultExecutive();
00264 
00265   // Progress/Update handling
00266   double Progress;
00267   char  *ProgressText;
00268 
00269   // Garbage collection support.
00270   virtual void ReportReferences(vtkGarbageCollector*);
00271   virtual void RemoveReferences();
00272   virtual void GarbageCollectionStarting();
00273   int GarbageCollecting;
00274 private:
00275   vtkAlgorithmInternals* AlgorithmInternal;
00276   static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
00277                             vtkAlgorithm* consumer, int consumerPort);
00278   static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
00279                                vtkAlgorithm* consumer, int consumerPort);
00280   static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
00281   static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
00282 
00283 private:
00284   vtkAlgorithm(const vtkAlgorithm&);  // Not implemented.
00285   void operator=(const vtkAlgorithm&);  // Not implemented.
00286 };
00287 
00288 #endif