VTK  9.0.3
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 =========================================================================*/
32 #ifndef vtkAlgorithm_h
33 #define vtkAlgorithm_h
34 
35 #include "vtkCommonExecutionModelModule.h" // For export macro
36 #include "vtkObject.h"
37 
38 class vtkAbstractArray;
39 class vtkAlgorithmInternals;
40 class vtkAlgorithmOutput;
41 class vtkCollection;
42 class vtkDataArray;
43 class vtkDataObject;
44 class vtkExecutive;
45 class vtkInformation;
52 
53 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
54 {
55 public:
56  static vtkAlgorithm* New();
57  vtkTypeMacro(vtkAlgorithm, vtkObject);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
81  {
84  DEFAULT_PRECISION
85  };
86 
91  int HasExecutive();
92 
98 
104  virtual void SetExecutive(vtkExecutive* executive);
105 
130  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
131 
137  vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
138 
144  virtual int ComputePipelineMTime(vtkInformation* request, vtkInformationVector** inInfoVec,
145  vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
146 
154  virtual int ModifyRequest(vtkInformation* request, int when);
155 
163 
171 
173 
176  vtkGetObjectMacro(Information, vtkInformation);
179 
184 
189 
191 
194  void Register(vtkObjectBase* o) override;
195  void UnRegister(vtkObjectBase* o) override;
197 
199 
203  vtkSetMacro(AbortExecute, vtkTypeBool);
204  vtkGetMacro(AbortExecute, vtkTypeBool);
205  vtkBooleanMacro(AbortExecute, vtkTypeBool);
207 
209 
212  vtkGetMacro(Progress, double);
214 
219  VTK_LEGACY(void SetProgress(double));
220 
226  void UpdateProgress(double amount);
227 
229 
241  void SetProgressShiftScale(double shift, double scale);
242  vtkGetMacro(ProgressShift, double);
243  vtkGetMacro(ProgressScale, double);
245 
247 
254  void SetProgressText(const char* ptext);
255  vtkGetStringMacro(ProgressText);
257 
259 
263  vtkGetMacro(ErrorCode, unsigned long);
265 
266  // left public for performance since it is used in inner loops
268 
298 
308 
322 
324 
333  int idx, int port, int connection, int fieldAssociation, const char* name);
335  int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
336  virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
338 
362  virtual void SetInputArrayToProcess(int idx, int port, int connection,
363  const char* fieldAssociation, const char* attributeTypeorName);
364 
369 
370  // from here down are convenience methods that really are executive methods
371 
376 
382 
387  vtkDataObject* GetInputDataObject(int port, int connection);
388 
390 
403  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
406 
408 
417  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
420 
430  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
431 
435  virtual void RemoveInputConnection(int port, int idx);
436 
440  virtual void RemoveAllInputConnections(int port);
441 
451  virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
452 
459  virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
460 
469 
474 
479 
484 
489  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
490 
495 
500 
506 
511 
521 
526 
535 
537 
540  virtual void Update(int port);
541  virtual void Update();
543 
566  virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
567 
573  virtual vtkTypeBool Update(vtkInformation* requests);
574 
581  virtual int UpdatePiece(
582  int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
583 
589  virtual int UpdateExtent(const int extents[6]);
590 
597  virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
598  const int extents[6] = nullptr);
599 
603  virtual void UpdateInformation();
604 
608  virtual void UpdateDataObject();
609 
613  virtual void PropagateUpdateExtent();
614 
618  virtual void UpdateWholeExtent();
619 
624  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
625 
626  //======================================================================
627  // The following block of code is to support old style VTK applications. If
628  // you are using these calls there are better ways to do it in the new
629  // pipeline
630  //======================================================================
631 
633 
636  virtual void SetReleaseDataFlag(int);
637  virtual int GetReleaseDataFlag();
641 
642  //========================================================================
643 
645 
652  int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
654 
660 
662 
667  int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
669  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
670  {
671  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
672  }
673  void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
674  void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
675  void GetUpdateExtent(int port, int extent[6]);
677 
679 
684  int GetUpdatePiece() { return this->GetUpdatePiece(0); }
688  int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
691 
693 
703  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
705 
706 protected:
708  ~vtkAlgorithm() override;
709 
710  // Keys used to indicate that input/output port information has been
711  // filled.
713 
714  // Arbitrary extra information associated with this algorithm
716 
723 
730 
734  virtual void SetNumberOfInputPorts(int n);
735 
739  virtual void SetNumberOfOutputPorts(int n);
740 
741  // Helper methods to check input/output port index ranges.
742  int InputPortIndexInRange(int index, const char* action);
743  int OutputPortIndexInRange(int index, const char* action);
744 
749  int GetInputArrayAssociation(int idx, vtkInformationVector** inputVector);
750 
752 
760  int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
763 
765 
771  int idx, vtkInformationVector** inputVector, int& association);
773 
775 
783  vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
785  int idx, int connection, vtkInformationVector** inputVector, int& association);
787  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
789 
791 
797  int idx, vtkInformationVector** inputVector, int& association);
799 
801 
810  int idx, int connection, vtkInformationVector** inputVector);
812  int idx, int connection, vtkInformationVector** inputVector, int& association);
814  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input, int& association);
816 
825 
833 
835 
839  vtkSetMacro(ErrorCode, unsigned long);
840  unsigned long ErrorCode;
842 
843  // Progress/Update handling
844  double Progress;
846 
847  // Garbage collection support.
849 
850  // executive methods below
851 
858  virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
859 
866  virtual void SetNumberOfInputConnections(int port, int n);
867 
869 
877  {
878  this->SetInputDataObject(port, input);
879  }
881  {
882  this->AddInputDataObject(port, input);
883  }
884 
886 
887 private:
888  vtkExecutive* Executive;
889  vtkInformationVector* InputPortInformation;
890  vtkInformationVector* OutputPortInformation;
891  vtkAlgorithmInternals* AlgorithmInternal;
892  static void ConnectionAdd(
893  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
894  static void ConnectionRemove(
895  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
896  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
897  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
898 
899 private:
900  vtkAlgorithm(const vtkAlgorithm&) = delete;
901  void operator=(const vtkAlgorithm&) = delete;
902 
903  double ProgressShift;
904  double ProgressScale;
905 };
906 
907 #endif
Abstract superclass for all arrays.
Proxy object to connect input/output ports.
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:54
virtual void UpdateDataObject()
Create output object(s).
int GetUpdatePiece(int port)
void UpdateProgress(double amount)
Update the progress of the process object.
static vtkAlgorithm * New()
vtkDataObject * GetInputDataObject(int port, int connection)
Get the data object that will contain the algorithm input for the given port and given connection.
int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector)
Get the assocition of the actual data array for the input array specified by idx, this is only reason...
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
Remove a connection from the given input port index.
virtual void SetNumberOfOutputPorts(int n)
Set the number of output ports provided by the algorithm.
virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput *input)
Replace the Nth connection on the given input port.
int GetUpdateGhostLevel()
Definition: vtkAlgorithm.h:688
static vtkInformationIntegerKey * PORT_REQUIREMENTS_FILLED()
void GetUpdateExtent(int port, int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
int GetInputArrayAssociation(int idx, vtkDataObject *input)
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:459
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:451
int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType)
int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output)
This detects when the UpdateExtent will generate no data This condition is satisfied when the UpdateE...
void GetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:674
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:684
vtkInformation * Information
Definition: vtkAlgorithm.h:715
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkDataObject *input, int &association)
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:510
virtual vtkTypeBool Update(vtkInformation *requests)
Convenience method to update an algorithm after passing requests to its first output port.
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Fill the output port information objects for this algorithm.
virtual void RemoveAllInputConnections(int port)
Removes all input connections.
virtual int ComputePipelineMTime(vtkInformation *request, vtkInformationVector **inInfoVec, vtkInformationVector *outInfoVec, int requestFromOutputPort, vtkMTimeType *mtime)
A special version of ProcessRequest meant specifically for the pipeline modified time request.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkInformationVector **inputVector)
Get the actual data array for the input array specified by idx, this is only reasonable during the RE...
virtual void AddInputConnection(vtkAlgorithmOutput *input)
virtual vtkTypeBool Update(int port, vtkInformationVector *requests)
This method enables the passing of data requests to the algorithm to be used during execution (in add...
vtkAlgorithmOutput * GetInputConnection(int port, int index)
Get the algorithm output port connected to an input port.
int * GetUpdateExtent(int port)
vtkInformation * GetOutputPortInformation(int port)
Get the information object associated with an output port.
virtual int UpdatePiece(int piece, int numPieces, int ghostLevels, const int extents[6]=nullptr)
Convenience method to update an algorithm after passing requests to its first output port.
virtual void SetInputArrayToProcess(int idx, int port, int connection, const char *fieldAssociation, const char *attributeTypeorName)
String based versions of SetInputArrayToProcess().
virtual vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo)
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
int GetNumberOfOutputPorts()
Get the number of output ports provided by the algorithm.
virtual int ModifyRequest(vtkInformation *request, int when)
This method gives the algorithm a chance to modify the contents of a request before or after (specifi...
void ReleaseDataFlagOff()
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:876
void UnRegister(vtkObjectBase *o) override
Decrease the reference count (release by another object).
int GetNumberOfInputPorts()
Get the number of input ports used by the algorithm.
int GetInputArrayAssociation(int idx, int connection, vtkInformationVector **inputVector)
Filters that have multiple connections on one port can use this signature.
vtkDataObject * GetOutputDataObject(int port)
Get the data object that will contain the algorithm output for the given port.
vtkAlgorithm * GetInputAlgorithm(int port, int index)
Returns the algorithm connected to a port-index pair.
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:525
void ReleaseDataFlagOn()
void SetProgressShiftScale(double shift, double scale)
Specify the shift and scale values to use to apply to the progress amount when UpdateProgress is call...
vtkDataArray * GetInputArrayToProcess(int idx, int connection, vtkInformationVector **inputVector)
Filters that have multiple connections on one port can use this signature.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:499
void SetProgress(double)
SetProgress is deprecated.
unsigned long ErrorCode
Definition: vtkAlgorithm.h:839
void GetUpdateExtent(int port, int extent[6])
int GetUpdateGhostLevel(int port)
virtual void SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name)
Set the input data arrays that this algorithm will process.
virtual void AddInputDataObject(int port, vtkDataObject *data)
Add the data-object as an input to this given port.
vtkExecutive * GetInputExecutive(int port, int index)
Returns the executive associated with a particular input connection.
int OutputPortIndexInRange(int index, const char *action)
static void SetDefaultExecutivePrototype(vtkExecutive *proto)
If the DefaultExecutivePrototype is set, a copy of it is created in CreateDefaultExecutive() using Ne...
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, int connection, vtkInformationVector **inputVector)
Filters that have multiple connections on one port can use this signature.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkDataObject *input)
vtkDataArray * GetInputArrayToProcess(int idx, vtkInformationVector **inputVector)
Get the actual data array for the input array specified by idx, this is only reasonable during the RE...
vtkDataArray * GetInputArrayToProcess(int idx, vtkDataObject *input)
vtkDataArray * GetInputArrayToProcess(int idx, vtkInformationVector **inputVector, int &association)
void ReportReferences(vtkGarbageCollector *) override
vtkExecutive * GetExecutive()
Get this algorithm's executive.
char * ProgressText
Definition: vtkAlgorithm.h:845
vtkAlgorithm * GetInputAlgorithm(int port, int index, int &algPort)
Returns the algorithm and the output port index of that algorithm connected to a port-index pair.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkInformationVector **inputVector, int &association)
void SetProgressObserver(vtkProgressObserver *)
If an ProgressObserver is set, the algorithm will report progress through it rather than directly.
vtkDataArray * GetInputArrayToProcess(int idx, vtkDataObject *input, int &association)
virtual void SetInputArrayToProcess(int idx, vtkInformation *info)
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
virtual void UpdateWholeExtent()
Bring this algorithm's outputs up-to-date.
vtkDataArray * GetInputArrayToProcess(int idx, int connection, vtkInformationVector **inputVector, int &association)
virtual void SetNumberOfInputConnections(int port, int n)
Set the number of input connections on the given input port.
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
int GetTotalNumberOfInputConnections()
Get the total number of inputs for this algorithm.
virtual void SetInputConnection(vtkAlgorithmOutput *input)
void ConvertTotalInputToPortConnection(int ind, int &port, int &conn)
Convenience routine to convert from a linear ordering of input connections to a port/connection pair.
virtual void SetExecutive(vtkExecutive *executive)
Set this algorithm's executive.
int GetNumberOfInputConnections(int port)
Get the number of inputs currently connected to a port.
void SetProgressText(const char *ptext)
Set the current text message associated with the progress state.
vtkInformation * GetInputArrayFieldInformation(int idx, vtkInformationVector **inputVector)
This method takes in an index (as specified in SetInputArrayToProcess) and a pipeline information vec...
virtual void PropagateUpdateExtent()
Propagate meta-data upstream.
virtual void Update(int port)
Bring this algorithm's outputs up-to-date.
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:263
virtual int UpdateExtent(const int extents[6])
Convenience method to update an algorithm after passing requests to its first output port.
void Register(vtkObjectBase *o) override
Participate in garbage collection.
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:468
int GetUpdateNumberOfPieces()
Definition: vtkAlgorithm.h:686
vtkTypeBool ProcessRequest(vtkInformation *request, vtkCollection *inInfo, vtkInformationVector *outInfo)
Version of ProcessRequest() that is wrapped.
vtkInformation * GetInputPortInformation(int port)
Get the information object associated with an input port.
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:81
virtual void SetReleaseDataFlag(int)
Turn release data flag on or off for all output ports.
virtual void SetInputDataObject(int port, vtkDataObject *data)
Sets the data-object as an input on the given port index.
void GetUpdateExtent(int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
Definition: vtkAlgorithm.h:669
vtkInformation * GetInputArrayInformation(int idx)
Get the info object for the specified input array to this algorithm.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, int connection, vtkInformationVector **inputVector, int &association)
virtual void SetNumberOfInputPorts(int n)
Set the number of input ports used by the algorithm.
virtual void RemoveInputConnection(int port, int idx)
Remove a connection given by index idx.
virtual void SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, int fieldAttributeType)
int HasExecutive()
Check whether this algorithm has an assigned executive.
vtkAlgorithmOutput * GetOutputPort(int index)
Get a proxy object corresponding to the given output port of this algorithm.
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:667
vtkInformation * GetOutputInformation(int port)
Return the information object that is associated with a particular output port.
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:885
virtual int GetReleaseDataFlag()
virtual void UpdateInformation()
Bring the algorithm's information up-to-date.
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:880
~vtkAlgorithm() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
int GetUpdateNumberOfPieces(int port)
int InputPortIndexInRange(int index, const char *action)
double Progress
Definition: vtkAlgorithm.h:844
vtkInformation * GetInputInformation(int port, int index)
Return the information object that is associated with a particular input connection.
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=nullptr)
Convenience method to update an algorithm after passing requests to its first output port.
virtual void SetInformation(vtkInformation *)
virtual void Update()
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:868
virtual void AddInputConnection(int port, vtkAlgorithmOutput *input)
Add a connection to the given input port index.
void RemoveAllInputs()
Remove all the input data.
create and manipulate ordered lists of objects
Definition: vtkCollection.h:53
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
general representation of visualization data
Definition: vtkDataObject.h:60
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:47
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:34
Key for integer values in vtkInformation.
Key for string values in vtkInformation.
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:64
abstract base class for most VTK objects
Definition: vtkObject.h:54
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkInformationIntegerKey * INPUT_PORT()
static vtkInformationIntegerKey * INPUT_IS_OPTIONAL()
Keys used to specify input port requirements.
static vtkInformationIntegerKey * INPUT_CONNECTION()
static vtkInformationInformationVectorKey * INPUT_ARRAYS_TO_PROCESS()
static vtkInformationStringVectorKey * INPUT_REQUIRED_DATA_TYPE()
static vtkInformationInformationVectorKey * INPUT_REQUIRED_FIELDS()
static vtkInformationIntegerKey * CAN_HANDLE_PIECE_REQUEST()
Key that tells the pipeline that a particular algorithm can or cannot handle piece request.
static vtkInformationIntegerKey * CAN_PRODUCE_SUB_EXTENT()
This key tells the executive that a particular output port is capable of producing an arbitrary subex...
static vtkInformationIntegerKey * INPUT_IS_REPEATABLE()
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ scale
Definition: vtkX3D.h:235
@ time
Definition: vtkX3D.h:503
@ extent
Definition: vtkX3D.h:351
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
@ data
Definition: vtkX3D.h:321
int vtkTypeBool
Definition: vtkABI.h:69
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
#define VTK_SIZEHINT(...)