VTK
dox/Filtering/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 "vtkObject.h"
00044 
00045 class vtkAbstractArray;
00046 class vtkAlgorithmInternals;
00047 class vtkAlgorithmOutput;
00048 class vtkCollection;
00049 class vtkDataArray;
00050 class vtkDataObject;
00051 class vtkExecutive;
00052 class vtkInformation;
00053 class vtkInformationInformationVectorKey;
00054 class vtkInformationIntegerKey;
00055 class vtkInformationStringKey;
00056 class vtkInformationStringVectorKey;
00057 class vtkInformationVector;
00058 
00059 class VTK_FILTERING_EXPORT vtkAlgorithm : public vtkObject
00060 {
00061 public:
00062   static vtkAlgorithm *New();
00063   vtkTypeMacro(vtkAlgorithm,vtkObject);
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065 
00068   int HasExecutive();
00069 
00072   vtkExecutive* GetExecutive();
00073 
00077   virtual void SetExecutive(vtkExecutive* executive);
00078 
00080 
00094   virtual int ProcessRequest(vtkInformation* request,
00095                              vtkInformationVector** inInfo,
00096                              vtkInformationVector* outInfo);
00098 
00100 
00102   int ProcessRequest(vtkInformation* request,
00103                      vtkCollection* inInfo,
00104                      vtkInformationVector* outInfo);
00106 
00108 
00111   virtual int
00112   ComputePipelineMTime(vtkInformation* request,
00113                        vtkInformationVector** inInfoVec,
00114                        vtkInformationVector* outInfoVec,
00115                        int requestFromOutputPort,
00116                        unsigned long* mtime);
00118 
00124   virtual int ModifyRequest(vtkInformation* request, int when);
00125 
00130   vtkInformation* GetInputPortInformation(int port);
00131 
00136   vtkInformation* GetOutputPortInformation(int port);
00137 
00139 
00140   vtkGetObjectMacro(Information, vtkInformation);
00141   virtual void SetInformation(vtkInformation*);
00143 
00145   int GetNumberOfInputPorts();
00146 
00148   int GetNumberOfOutputPorts();
00149 
00151 
00152   virtual void Register(vtkObjectBase* o);
00153   virtual void UnRegister(vtkObjectBase* o);
00155 
00157 
00159   vtkSetMacro(AbortExecute,int);
00160   vtkGetMacro(AbortExecute,int);
00161   vtkBooleanMacro(AbortExecute,int);
00163 
00165 
00166   vtkSetClampMacro(Progress,double,0.0,1.0);
00167   vtkGetMacro(Progress,double);
00169 
00173   void UpdateProgress(double amount);
00174 
00176 
00181   void SetProgressText(const char* ptext);
00182   vtkGetStringMacro(ProgressText);
00184 
00186 
00188   vtkGetMacro( ErrorCode, unsigned long );
00190 
00191   // left public for performance since it is used in inner loops
00192   int AbortExecute;
00193 
00195 
00196   static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
00197   static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
00198   static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
00199   static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
00200   static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
00201   static vtkInformationIntegerKey* INPUT_PORT();
00202   static vtkInformationIntegerKey* INPUT_CONNECTION();
00204 
00205 
00207 
00213   virtual void SetInputArrayToProcess(int idx, int port, int connection,
00214                               int fieldAssociation,
00215                               const char *name);
00216   virtual void SetInputArrayToProcess(int idx, int port, int connection,
00217                               int fieldAssociation,
00218                               int fieldAttributeType);
00219   virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
00221 
00223 
00237   virtual void SetInputArrayToProcess(int idx, int port, int connection,
00238                               const char* fieldAssociation,
00239                               const char* attributeTypeorName);
00241 
00243   vtkInformation *GetInputArrayInformation(int idx);
00244 
00245   // from here down are convenience methods that really are executive methods
00246 
00247 
00248 
00250   void RemoveAllInputs();
00251 
00254   vtkDataObject* GetOutputDataObject(int port);
00255 
00257 
00259   vtkDataObject *GetInputDataObject(int port,
00260                                     int connection);
00262 
00264 
00273   virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
00274   virtual void SetInputConnection(vtkAlgorithmOutput* input);
00276 
00278 
00283   virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
00284   virtual void AddInputConnection(vtkAlgorithmOutput* input);
00286 
00293   virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
00294 
00296 
00300   vtkAlgorithmOutput* GetOutputPort(int index);
00301   vtkAlgorithmOutput* GetOutputPort() {
00302     return this->GetOutputPort(0); }
00304 
00306   int GetNumberOfInputConnections(int port);
00307 
00309   int GetTotalNumberOfInputConnections();
00310 
00312   vtkAlgorithmOutput* GetInputConnection(int port, int index);
00313 
00315   virtual void Update();
00316 
00319   virtual void UpdateInformation();
00320 
00322   virtual void UpdateWholeExtent();
00323 
00326   void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
00327 
00328   //======================================================================
00329   //The following block of code is to support old style VTK applications. If
00330   //you are using these calls there are better ways to do it in the new
00331   //pipeline
00332   //======================================================================
00333 
00335 
00336   virtual void SetReleaseDataFlag(int);
00337   virtual int GetReleaseDataFlag();
00338   void ReleaseDataFlagOn();
00339   void ReleaseDataFlagOff();
00341 
00342   //========================================================================
00343 
00345 
00349   int UpdateExtentIsEmpty(vtkDataObject *output);
00350   int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
00352 
00355   static void SetDefaultExecutivePrototype(vtkExecutive* proto);
00356 
00360   virtual double ComputePriority();
00361 
00363 
00365   static vtkInformationIntegerKey* PRESERVES_DATASET();
00366   static vtkInformationIntegerKey* PRESERVES_GEOMETRY();
00367   static vtkInformationIntegerKey* PRESERVES_BOUNDS();
00368   static vtkInformationIntegerKey* PRESERVES_TOPOLOGY();
00369   static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES();
00370   static vtkInformationIntegerKey* PRESERVES_RANGES();
00371   static vtkInformationIntegerKey* MANAGES_METAINFORMATION();
00373 
00374 protected:
00375   vtkAlgorithm();
00376   ~vtkAlgorithm();
00377 
00378   // Keys used to indicate that input/output port information has been
00379   // filled.
00380   static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
00381 
00382   // Arbitrary extra information associated with this algorithm
00383   vtkInformation* Information;
00384 
00388   virtual int FillInputPortInformation(int port, vtkInformation* info);
00389 
00393   virtual int FillOutputPortInformation(int port, vtkInformation* info);
00394 
00396   virtual void SetNumberOfInputPorts(int n);
00397 
00399   virtual void SetNumberOfOutputPorts(int n);
00400 
00401   // Helper methods to check input/output port index ranges.
00402   int InputPortIndexInRange(int index, const char* action);
00403   int OutputPortIndexInRange(int index, const char* action);
00404 
00408   int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
00409 
00411 
00417   int GetInputArrayAssociation(int idx, int connection,
00418                                vtkInformationVector **inputVector);
00419   int GetInputArrayAssociation(int idx, vtkDataObject* input);
00421 
00422 
00424 
00426   vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
00427   vtkDataArray *GetInputArrayToProcess(int idx,
00428                                        vtkInformationVector **inputVector,
00429                                        int& association);
00431 
00433 
00439   vtkDataArray *GetInputArrayToProcess(int idx,
00440                                        int connection,
00441                                        vtkInformationVector **inputVector);
00442   vtkDataArray *GetInputArrayToProcess(int idx,
00443                                        int connection,
00444                                        vtkInformationVector **inputVector,
00445                                        int& association);
00446   vtkDataArray *GetInputArrayToProcess(int idx,
00447                                        vtkDataObject* input);
00448   vtkDataArray *GetInputArrayToProcess(int idx,
00449                                        vtkDataObject* input,
00450                                        int& association);
00452 
00453 
00455 
00457   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
00458   vtkAbstractArray *GetInputAbstractArrayToProcess
00459     (int idx, vtkInformationVector **inputVector, int& association);
00461 
00463 
00469   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00470                                        int connection,
00471                                        vtkInformationVector **inputVector);
00472   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00473                                        int connection,
00474                                        vtkInformationVector **inputVector,
00475                                        int& association);
00476   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00477                                        vtkDataObject* input);
00478   vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
00479                                        vtkDataObject* input,
00480                                        int& association);
00482 
00483 
00484 
00486 
00491   vtkInformation *GetInputArrayFieldInformation(int idx,
00492                                                 vtkInformationVector **inputVector);
00494 
00495 
00500   virtual vtkExecutive* CreateDefaultExecutive();
00501 
00503 
00505   vtkSetMacro( ErrorCode, unsigned long );
00506   unsigned long ErrorCode;
00508 
00509   // Progress/Update handling
00510   double Progress;
00511   char  *ProgressText;
00512 
00513   // Garbage collection support.
00514   virtual void ReportReferences(vtkGarbageCollector*);
00515 
00516   // executive methods below
00517 
00519 
00523   virtual void SetNthInputConnection(int port, int index,
00524                                      vtkAlgorithmOutput* input);
00526 
00531   virtual void SetNumberOfInputConnections(int port, int n);
00532 
00533   static vtkExecutive* DefaultExecutivePrototype;
00534 
00535 private:
00536   vtkExecutive* Executive;
00537   vtkInformationVector* InputPortInformation;
00538   vtkInformationVector* OutputPortInformation;
00539   vtkAlgorithmInternals* AlgorithmInternal;
00540   static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
00541                             vtkAlgorithm* consumer, int consumerPort);
00542   static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
00543                                vtkAlgorithm* consumer, int consumerPort);
00544   static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
00545   static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
00546 
00547 private:
00548   vtkAlgorithm(const vtkAlgorithm&);  // Not implemented.
00549   void operator=(const vtkAlgorithm&);  // Not implemented.
00550 };
00551 
00552 #endif