VTK
vtkAlgorithm.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAlgorithm.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
38 #ifndef vtkAlgorithm_h
39 #define vtkAlgorithm_h
40 
41 #include "vtkCommonExecutionModelModule.h" // For export macro
42 #include "vtkObject.h"
43 
44 class vtkAbstractArray;
45 class vtkAlgorithmInternals;
46 class vtkAlgorithmOutput;
47 class vtkCollection;
48 class vtkDataArray;
49 class vtkDataObject;
50 class vtkExecutive;
51 class vtkInformation;
58 
59 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
60 {
61 public:
62  static vtkAlgorithm *New();
63  vtkTypeMacro(vtkAlgorithm,vtkObject);
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
87  {
90  DEFAULT_PRECISION
91  };
92 
97  int HasExecutive();
98 
103  vtkExecutive* GetExecutive();
104 
110  virtual void SetExecutive(vtkExecutive* executive);
111 
135  virtual int ProcessRequest(vtkInformation* request,
136  vtkInformationVector** inInfo,
137  vtkInformationVector* outInfo);
138 
143  int ProcessRequest(vtkInformation* request,
144  vtkCollection* inInfo,
145  vtkInformationVector* outInfo);
146 
152  virtual int
153  ComputePipelineMTime(vtkInformation* request,
154  vtkInformationVector** inInfoVec,
155  vtkInformationVector* outInfoVec,
156  int requestFromOutputPort,
157  vtkMTimeType* mtime);
158 
166  virtual int ModifyRequest(vtkInformation* request, int when);
167 
174  vtkInformation* GetInputPortInformation(int port);
175 
182  vtkInformation* GetOutputPortInformation(int port);
183 
185 
188  vtkGetObjectMacro(Information, vtkInformation);
189  virtual void SetInformation(vtkInformation*);
191 
195  int GetNumberOfInputPorts();
196 
200  int GetNumberOfOutputPorts();
201 
203 
206  void Register(vtkObjectBase* o) override;
207  void UnRegister(vtkObjectBase* o) override;
209 
211 
215  vtkSetMacro(AbortExecute,vtkTypeBool);
216  vtkGetMacro(AbortExecute,vtkTypeBool);
217  vtkBooleanMacro(AbortExecute,vtkTypeBool);
219 
221 
224  vtkGetMacro(Progress,double);
226 
231  VTK_LEGACY(void SetProgress(double));
232 
238  void UpdateProgress(double amount);
239 
241 
253  void SetProgressShiftScale(double shift, double scale);
254  vtkGetMacro(ProgressShift, double);
255  vtkGetMacro(ProgressScale, double);
257 
259 
266  void SetProgressText(const char* ptext);
267  vtkGetStringMacro(ProgressText);
269 
271 
275  vtkGetMacro( ErrorCode, unsigned long );
277 
278  // left public for performance since it is used in inner loops
280 
285  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
289  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
293  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
297  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
301  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
305  static vtkInformationIntegerKey* INPUT_PORT();
309  static vtkInformationIntegerKey* INPUT_CONNECTION();
310 
319  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
320 
333  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
334 
335 
337 
345  virtual void SetInputArrayToProcess(int idx, int port, int connection,
346  int fieldAssociation,
347  const char *name);
348  virtual void SetInputArrayToProcess(int idx, int port, int connection,
349  int fieldAssociation,
350  int fieldAttributeType);
351  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
353 
377  virtual void SetInputArrayToProcess(int idx, int port, int connection,
378  const char* fieldAssociation,
379  const char* attributeTypeorName);
380 
384  vtkInformation *GetInputArrayInformation(int idx);
385 
386  // from here down are convenience methods that really are executive methods
387 
388 
389 
393  void RemoveAllInputs();
394 
399  vtkDataObject* GetOutputDataObject(int port);
400 
405  vtkDataObject *GetInputDataObject(int port,
406  int connection);
407 
409 
422  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
423  virtual void SetInputConnection(vtkAlgorithmOutput* input);
425 
427 
436  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
437  virtual void AddInputConnection(vtkAlgorithmOutput* input);
439 
449  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
450 
454  virtual void RemoveInputConnection(int port, int idx);
455 
459  virtual void RemoveAllInputConnections(int port);
460 
469  virtual void SetInputDataObject(int port, vtkDataObject* data);
471  { this->SetInputDataObject(0, data); }
472 
478  virtual void AddInputDataObject(int port, vtkDataObject* data);
479  virtual void AddInputDataObject(vtkDataObject* data)
480  { this->AddInputDataObject(0, data); }
481 
488  vtkAlgorithmOutput* GetOutputPort(int index);
490  return this->GetOutputPort(0); }
491 
495  int GetNumberOfInputConnections(int port);
496 
500  int GetTotalNumberOfInputConnections();
501 
505  vtkAlgorithmOutput* GetInputConnection(int port, int index);
506 
511  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
512 
516  vtkAlgorithm* GetInputAlgorithm(int port, int index);
517 
522  {
523  return this->GetInputAlgorithm(0, 0);
524  }
525 
530  vtkExecutive* GetInputExecutive(int port, int index);
531 
536  {
537  return this->GetInputExecutive(0, 0);
538  }
539 
548  vtkInformation* GetInputInformation(int port, int index);
549 
554  {
555  return this->GetInputInformation(0, 0);
556  }
557 
565  vtkInformation* GetOutputInformation(int port);
566 
568 
571  virtual void Update(int port);
572  virtual void Update();
574 
597  virtual int Update(int port, vtkInformationVector* requests);
598 
604  virtual int Update(vtkInformation* requests);
605 
612  virtual int UpdatePiece(
613  int piece, int numPieces, int ghostLevels, const int extents[6]=nullptr);
614 
620  virtual int UpdateExtent(const int extents[6]);
621 
628  virtual int UpdateTimeStep(double time,
629  int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=nullptr);
630 
634  virtual void UpdateInformation();
635 
639  virtual void UpdateDataObject();
640 
644  virtual void PropagateUpdateExtent();
645 
649  virtual void UpdateWholeExtent();
650 
655  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
656 
657  //======================================================================
658  //The following block of code is to support old style VTK applications. If
659  //you are using these calls there are better ways to do it in the new
660  //pipeline
661  //======================================================================
662 
664 
667  virtual void SetReleaseDataFlag(int);
668  virtual int GetReleaseDataFlag();
669  void ReleaseDataFlagOn();
670  void ReleaseDataFlagOff();
672 
673  //========================================================================
674 
676 
682  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
683  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
685 
690  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
691 
693 
699  {
700  return this->GetUpdateExtent(0);
701  }
702  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
703  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
704  int& z0, int& z1)
705  {
706  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
707  }
708  void GetUpdateExtent(int port,
709  int& x0, int& x1, int& y0, int& y1,
710  int& z0, int& z1);
711  void GetUpdateExtent(int extent[6])
712  {
713  this->GetUpdateExtent(0, extent);
714  }
715  void GetUpdateExtent(int port, int extent[6]);
717 
719 
725  {
726  return this->GetUpdatePiece(0);
727  }
728  int GetUpdatePiece(int port);
730  {
731  return this->GetUpdateNumberOfPieces(0);
732  }
733  int GetUpdateNumberOfPieces(int port);
735  {
736  return this->GetUpdateGhostLevel(0);
737  }
738  int GetUpdateGhostLevel(int port);
740 
742 
751  void SetProgressObserver(vtkProgressObserver*);
752  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
754 
755 protected:
756  vtkAlgorithm();
757  ~vtkAlgorithm() override;
758 
759  // Keys used to indicate that input/output port information has been
760  // filled.
761  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
762 
763  // Arbitrary extra information associated with this algorithm
765 
771  virtual int FillInputPortInformation(int port, vtkInformation* info);
772 
778  virtual int FillOutputPortInformation(int port, vtkInformation* info);
779 
783  virtual void SetNumberOfInputPorts(int n);
784 
788  virtual void SetNumberOfOutputPorts(int n);
789 
790  // Helper methods to check input/output port index ranges.
791  int InputPortIndexInRange(int index, const char* action);
792  int OutputPortIndexInRange(int index, const char* action);
793 
798  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
799 
801 
809  int GetInputArrayAssociation(int idx, int connection,
810  vtkInformationVector **inputVector);
811  int GetInputArrayAssociation(int idx, vtkDataObject* input);
813 
814 
816 
820  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
821  vtkDataArray *GetInputArrayToProcess(int idx,
822  vtkInformationVector **inputVector,
823  int& association);
825 
827 
835  vtkDataArray *GetInputArrayToProcess(int idx,
836  int connection,
837  vtkInformationVector **inputVector);
838  vtkDataArray *GetInputArrayToProcess(int idx,
839  int connection,
840  vtkInformationVector **inputVector,
841  int& association);
842  vtkDataArray *GetInputArrayToProcess(int idx,
843  vtkDataObject* input);
844  vtkDataArray *GetInputArrayToProcess(int idx,
845  vtkDataObject* input,
846  int& association);
848 
849 
851 
855  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
856  vtkAbstractArray *GetInputAbstractArrayToProcess
857  (int idx, vtkInformationVector **inputVector, int& association);
859 
861 
869  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
870  int connection,
871  vtkInformationVector **inputVector);
872  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
873  int connection,
874  vtkInformationVector **inputVector,
875  int& association);
876  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
877  vtkDataObject* input);
878  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
879  vtkDataObject* input,
880  int& association);
882 
883 
884 
892  vtkInformation *GetInputArrayFieldInformation(int idx,
893  vtkInformationVector **inputVector);
894 
895 
902  virtual vtkExecutive* CreateDefaultExecutive();
903 
905 
909  vtkSetMacro( ErrorCode, unsigned long );
910  unsigned long ErrorCode;
912 
913  // Progress/Update handling
914  double Progress;
916 
917  // Garbage collection support.
918  void ReportReferences(vtkGarbageCollector*) override;
919 
920  // executive methods below
921 
928  virtual void SetNthInputConnection(int port, int index,
929  vtkAlgorithmOutput* input);
930 
937  virtual void SetNumberOfInputConnections(int port, int n);
938 
940 
947  void SetInputDataInternal(int port, vtkDataObject *input)
948  { this->SetInputDataObject(port, input); }
949  void AddInputDataInternal(int port, vtkDataObject *input)
950  { this->AddInputDataObject(port, input); }
951 
953 
954 private:
955  vtkExecutive* Executive;
956  vtkInformationVector* InputPortInformation;
957  vtkInformationVector* OutputPortInformation;
958  vtkAlgorithmInternals* AlgorithmInternal;
959  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
960  vtkAlgorithm* consumer, int consumerPort);
961  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
962  vtkAlgorithm* consumer, int consumerPort);
963  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
964  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
965 
966 private:
967  vtkAlgorithm(const vtkAlgorithm&) = delete;
968  void operator=(const vtkAlgorithm&) = delete;
969 
970  double ProgressShift;
971  double ProgressScale;
972 };
973 
974 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:489
abstract base class for most VTK objects
Definition: vtkObject.h:59
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:86
virtual void Register(vtkObjectBase *o)
Increase the reference count (mark as used by another object).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetUpdateExtent(int extent[6])
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:711
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:724
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:304
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:698
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:521
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:553
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:479
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:49
void SetInputDataInternal(int port, vtkDataObject *input)
These methods are used by subclasses to implement methods to set data objects directly as input...
Definition: vtkAlgorithm.h:947
Key for string values in vtkInformation.
Detect and break reference loops.
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:69
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:949
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:59
vtkInformation * Information
Definition: vtkAlgorithm.h:764
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void ReportReferences(vtkGarbageCollector *)
Key for integer values in vtkInformation.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:729
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
#define VTK_SIZEHINT(...)
Key for String vector values.
char * ProgressText
Definition: vtkAlgorithm.h:915
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:470
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file...
Definition: vtkAlgorithm.h:909
double Progress
Definition: vtkAlgorithm.h:914
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
int GetUpdateGhostLevel()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:734
Store zero or more vtkInformation instances.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:952
general representation of visualization data
Definition: vtkDataObject.h:64
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:275
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:535
void GetUpdateExtent(int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:703
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:939