VTK  9.1.0
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=========================================================================*/
50#ifndef vtkAlgorithm_h
51#define vtkAlgorithm_h
52
53#include "vtkCommonExecutionModelModule.h" // For export macro
54#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
55#include "vtkObject.h"
56
58class vtkAlgorithmInternals;
60class vtkCollection;
61class vtkDataArray;
62class vtkDataObject;
63class vtkExecutive;
64class vtkInformation;
71
72class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
73{
74public:
75 static vtkAlgorithm* New();
76 vtkTypeMacro(vtkAlgorithm, vtkObject);
77 void PrintSelf(ostream& os, vtkIndent indent) override;
78
100 {
103 DEFAULT_PRECISION
104 };
105
111
117
123 virtual void SetExecutive(vtkExecutive* executive);
124
149 vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
150
156 vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
157
164 vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
165
173 virtual int ModifyRequest(vtkInformation* request, int when);
174
182
190
192
195 vtkGetObjectMacro(Information, vtkInformation);
198
203
208
210
213 void Register(vtkObjectBase* o) override;
214 void UnRegister(vtkObjectBase* o) override;
216
218
222 vtkSetMacro(AbortExecute, vtkTypeBool);
223 vtkGetMacro(AbortExecute, vtkTypeBool);
224 vtkBooleanMacro(AbortExecute, vtkTypeBool);
226
228
231 vtkGetMacro(Progress, double);
233
238 VTK_DEPRECATED_IN_9_0_0("Use vtkAlgorithm::UpdateProgress")
239 void SetProgress(double);
240
246 void UpdateProgress(double amount);
247
249
261 void SetProgressShiftScale(double shift, double scale);
262 vtkGetMacro(ProgressShift, double);
263 vtkGetMacro(ProgressScale, double);
265
267
274 void SetProgressText(const char* ptext);
275 vtkGetStringMacro(ProgressText);
277
279
283 vtkGetMacro(ErrorCode, unsigned long);
285
286 // left public for performance since it is used in inner loops
287 vtkTypeBool AbortExecute;
288
293 static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
297 static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
301 static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
305 static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
309 static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
313 static vtkInformationIntegerKey* INPUT_PORT();
317 static vtkInformationIntegerKey* INPUT_CONNECTION();
318
327 static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
328
341 static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
342
344
352 virtual void SetInputArrayToProcess(
353 int idx, int port, int connection, int fieldAssociation, const char* name);
354 virtual void SetInputArrayToProcess(
355 int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
356 virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
358
382 virtual void SetInputArrayToProcess(int idx, int port, int connection,
383 const char* fieldAssociation, const char* attributeTypeorName);
384
388 vtkInformation* GetInputArrayInformation(int idx);
389
390 // from here down are convenience methods that really are executive methods
391
395 void RemoveAllInputs();
396
401 vtkDataObject* GetOutputDataObject(int port);
402
407 vtkDataObject* GetInputDataObject(int port, int connection);
408
410
423 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
424 virtual void SetInputConnection(vtkAlgorithmOutput* input);
426
428
437 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
438 virtual void AddInputConnection(vtkAlgorithmOutput* input);
440
450 virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
451
455 virtual void RemoveInputConnection(int port, int idx);
456
460 virtual void RemoveAllInputConnections(int port);
461
470 virtual void SetInputDataObject(int port, vtkDataObject* data);
471 virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
472
478 virtual void AddInputDataObject(int port, vtkDataObject* data);
479 virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
480
489
494
499
504
509 vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
510
514 vtkAlgorithm* GetInputAlgorithm(int port, int index);
515
520
525 vtkExecutive* GetInputExecutive(int port, int index);
526
531
540 vtkInformation* GetInputInformation(int port, int index);
541
546
555
557
560 virtual void Update(int port);
561 virtual void Update();
563
586 virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
587
594
601 virtual int UpdatePiece(
602 int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
603
609 virtual int UpdateExtent(const int extents[6]);
610
617 virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
618 const int extents[6] = nullptr);
619
623 virtual void UpdateInformation();
624
628 virtual void UpdateDataObject();
629
633 virtual void PropagateUpdateExtent();
634
638 virtual void UpdateWholeExtent();
639
644 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
645
646 //======================================================================
647 // The following block of code is to support old style VTK applications. If
648 // you are using these calls there are better ways to do it in the new
649 // pipeline
650 //======================================================================
651
653
656 virtual void SetReleaseDataFlag(int);
657 virtual int GetReleaseDataFlag();
661
662 //========================================================================
663
665
672 int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
674
680
682
687 int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
688 int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
689 void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
690 {
691 this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
692 }
693 void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
694 void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
695 void GetUpdateExtent(int port, int extent[6]);
697
699
704 int GetUpdatePiece() { return this->GetUpdatePiece(0); }
705 int GetUpdatePiece(int port);
708 int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
709 int GetUpdateGhostLevel(int port);
711
713
723 vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
725
726protected:
728 ~vtkAlgorithm() override;
729
730 // Keys used to indicate that input/output port information has been
731 // filled.
733
734 // Arbitrary extra information associated with this algorithm
736
742 virtual int FillInputPortInformation(int port, vtkInformation* info);
743
749 virtual int FillOutputPortInformation(int port, vtkInformation* info);
750
754 virtual void SetNumberOfInputPorts(int n);
755
759 virtual void SetNumberOfOutputPorts(int n);
760
761 // Helper methods to check input/output port index ranges.
762 int InputPortIndexInRange(int index, const char* action);
763 int OutputPortIndexInRange(int index, const char* action);
764
770
772
780 int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
783
785
791 int idx, vtkInformationVector** inputVector, int& association);
793
795
803 vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
805 int idx, int connection, vtkInformationVector** inputVector, int& association);
807 vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
809
811
817 int idx, vtkInformationVector** inputVector, int& association);
819
821
830 int idx, int connection, vtkInformationVector** inputVector);
832 int idx, int connection, vtkInformationVector** inputVector, int& association);
836
845
853
855
859 vtkSetMacro(ErrorCode, unsigned long);
860 unsigned long ErrorCode;
862
863 // Progress/Update handling
864 double Progress;
866
867 // Garbage collection support.
869
870 // executive methods below
871
878 virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
879
886 virtual void SetNumberOfInputConnections(int port, int n);
887
889
896 void SetInputDataInternal(int port, vtkDataObject* input)
897 {
898 this->SetInputDataObject(port, input);
899 }
900 void AddInputDataInternal(int port, vtkDataObject* input)
901 {
902 this->AddInputDataObject(port, input);
903 }
904
906
907private:
908 vtkExecutive* Executive;
909 vtkInformationVector* InputPortInformation;
910 vtkInformationVector* OutputPortInformation;
911 vtkAlgorithmInternals* AlgorithmInternal;
912 static void ConnectionAdd(
913 vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
914 static void ConnectionRemove(
915 vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
916 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
917 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
918
919private:
920 vtkAlgorithm(const vtkAlgorithm&) = delete;
921 void operator=(const vtkAlgorithm&) = delete;
922
923 double ProgressShift;
924 double ProgressScale;
925};
926
927#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:73
virtual void UpdateDataObject()
Create output object(s).
vtkAlgorithmOutput * GetInputConnection(int port, int index)
Get the algorithm output port connected to an input port.
int GetUpdatePiece(int port)
These functions return the update extent for output ports that use piece extents.
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...
vtkDataArray * GetInputArrayToProcess(int idx, int connection, vtkInformationVector **inputVector)
Filters that have multiple connections on one port can use this signature.
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 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()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:708
void GetUpdateExtent(int port, 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.
vtkInformation * GetOutputPortInformation(int port)
Get the information object associated with an output port.
int GetInputArrayAssociation(int idx, vtkDataObject *input)
Filters that have multiple connections on one port can use this signature.
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:479
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:471
int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType)
This detects when the UpdateExtent will generate no data This condition is satisfied when the UpdateE...
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])
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:694
vtkInformation * GetInputArrayFieldInformation(int idx, vtkInformationVector **inputVector)
This method takes in an index (as specified in SetInputArrayToProcess) and a pipeline information vec...
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:704
vtkInformation * Information
Definition: vtkAlgorithm.h:735
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.
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:530
vtkExecutive * GetInputExecutive(int port, int index)
Returns the executive associated with a particular input connection.
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.
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...
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.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, int connection, vtkInformationVector **inputVector, int &association)
Filters that have multiple connections on one port can use this signature.
static vtkInformationIntegerKey * PORT_REQUIREMENTS_FILLED()
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()
Turn release data flag on or off for all output ports.
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:896
void UnRegister(vtkObjectBase *o) override
Participate in garbage collection.
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.
void ReleaseDataFlagOn()
Turn release data flag on or off for all output ports.
vtkDataArray * GetInputArrayToProcess(int idx, int connection, vtkInformationVector **inputVector, int &association)
Filters that have multiple connections on one port can use this signature.
vtkDataArray * GetInputArrayToProcess(int idx, vtkInformationVector **inputVector, int &association)
Get the actual data array for the input array specified by idx, this is only reasonable during the RE...
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:545
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file.
Definition: vtkAlgorithm.h:860
void GetUpdateExtent(int port, int extent[6])
These functions return the update extent for output ports that use 3D extents.
vtkInformation * GetOutputInformation(int port)
Return the information object that is associated with a particular output port.
vtkInformation * GetInputPortInformation(int port)
Get the information object associated with an input port.
int GetUpdateGhostLevel(int port)
These functions return the update extent for output ports that use piece extents.
int * GetUpdateExtent(int port)
These functions return the update extent for output ports that use 3D extents.
virtual void AddInputDataObject(int port, vtkDataObject *data)
Add the data-object as an input to this given port.
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:488
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...
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:519
void ReportReferences(vtkGarbageCollector *) override
char * ProgressText
Definition: vtkAlgorithm.h:865
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, int connection, vtkInformationVector **inputVector)
Filters that have multiple connections on one port can use this signature.
vtkAlgorithm * GetInputAlgorithm(int port, int index)
Returns the algorithm connected to a port-index pair.
static vtkAlgorithm * New()
void SetProgressObserver(vtkProgressObserver *)
If an ProgressObserver is set, the algorithm will report progress through it rather than directly.
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...
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.
virtual void SetNumberOfInputConnections(int port, int n)
Set the number of input connections on the given input port.
int GetTotalNumberOfInputConnections()
Get the total number of inputs for this algorithm.
vtkDataArray * GetInputArrayToProcess(int idx, vtkDataObject *input)
Filters that have multiple connections on one port can use this signature.
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.
virtual void PropagateUpdateExtent()
Propagate meta-data upstream.
virtual void Update(int port)
Bring this algorithm's outputs up-to-date.
vtkExecutive * GetExecutive()
Get this algorithm's executive.
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.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:706
vtkTypeBool ProcessRequest(vtkInformation *request, vtkCollection *inInfo, vtkInformationVector *outInfo)
Version of ProcessRequest() that is wrapped.
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:100
virtual void SetReleaseDataFlag(int)
Turn release data flag on or off for all output ports.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkInformationVector **inputVector, int &association)
Get the actual data array for the input array specified by idx, this is only reasonable during the RE...
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:689
vtkDataArray * GetInputArrayToProcess(int idx, vtkDataObject *input, int &association)
Filters that have multiple connections on one port can use this signature.
virtual void SetNumberOfInputPorts(int n)
Set the number of input ports used by the algorithm.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkDataObject *input, int &association)
Filters that have multiple connections on one port can use this signature.
int HasExecutive()
Check whether this algorithm has an assigned executive.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkDataObject *input)
Filters that have multiple connections on one port can use this signature.
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:687
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:905
virtual int GetReleaseDataFlag()
Turn release data flag on or off for all output ports.
virtual void UpdateInformation()
Bring the algorithm's information up-to-date.
vtkAlgorithmOutput * GetOutputPort(int index)
Get a proxy object corresponding to the given output port of this algorithm.
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:900
~vtkAlgorithm() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetUpdateNumberOfPieces(int port)
These functions return the update extent for output ports that use piece extents.
int InputPortIndexInRange(int index, const char *action)
double Progress
Definition: vtkAlgorithm.h:864
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 *)
Set/Get the information object associated with this algorithm.
virtual void Update()
Bring this algorithm's outputs up-to-date.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:888
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.
create and manipulate ordered lists of objects
Definition: vtkCollection.h:53
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:59
general representation of visualization data
Definition: vtkDataObject.h:69
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:56
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:43
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:79
abstract base class for most VTK objects
Definition: vtkObject.h:72
Basic class to optionally replace vtkAlgorithm progress functionality.
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_0_0(reason)
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)