VTK  9.5.2
vtkAlgorithm.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
25 @par Tests:
26 @ref c2_vtk_t_vtkAlgorithm "vtkAlgorithm (Tests)"
27*/
29#ifndef vtkAlgorithm_h
30#define vtkAlgorithm_h
31
32#include "vtkCommonExecutionModelModule.h" // For export macro
33#include "vtkObject.h"
34#include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
35
36VTK_ABI_NAMESPACE_BEGIN
38class vtkAlgorithmInternals;
40class vtkCollection;
41class vtkDataArray;
43class vtkExecutive;
44class vtkInformation;
51
52class VTKCOMMONEXECUTIONMODEL_EXPORT VTK_MARSHALMANUAL vtkAlgorithm : public vtkObject
53{
54public:
55 static vtkAlgorithm* New();
56 vtkTypeMacro(vtkAlgorithm, vtkObject);
57 void PrintSelf(ostream& os, vtkIndent indent) override;
58
85
91
97
103 virtual void SetExecutive(vtkExecutive* executive);
104
129 vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
130
136 vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
137
144 vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
153 virtual int ModifyRequest(vtkInformation* request, int when);
162
170
172
175 vtkGetObjectMacro(Information, vtkInformation);
178
183
188
190
193 bool UsesGarbageCollector() const override { return true; }
195
200
202
208 vtkBooleanMacro(AbortExecute, vtkTypeBool);
210
212
215 vtkGetMacro(Progress, double);
217
223 void UpdateProgress(double amount);
224
229
231
237 {
238 this->ContainerAlgorithm = containerAlg;
239 }
240 vtkAlgorithm* GetContainerAlgorithm() { return this->ContainerAlgorithm; }
242
244
251 vtkSetMacro(AbortOutput, bool);
252 vtkGetMacro(AbortOutput, bool);
256
268 void SetProgressShiftScale(double shift, double scale);
269 vtkGetMacro(ProgressShift, double);
270 vtkGetMacro(ProgressScale, double);
272
274
281 void SetProgressText(const char* ptext);
282 vtkGetStringMacro(ProgressText);
284
286
290 vtkGetMacro(ErrorCode, unsigned long);
292
293 // left public for performance since it is used in inner loops
294 std::atomic<vtkTypeBool> AbortExecute;
295
325
335
349
355
357
366 void SetInputArrayToProcess(const char* name, int fieldAssociation);
387 int idx, int port, int connection, int fieldAssociation, const char* name);
403 int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
404
410 virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
411
437 virtual void SetInputArrayToProcess(int idx, int port, int connection,
438 const char* fieldAssociation, const char* attributeTypeorName);
445
446 // from here down are convenience methods that really are executive methods
447
458
463 vtkDataObject* GetInputDataObject(int port, int connection);
464
466
479 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
482
484
493 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
496
506 virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
507
511 virtual void RemoveInputConnection(int port, int idx);
512
516 virtual void RemoveAllInputConnections(int port);
517
526 virtual void SetInputDataObject(int port, vtkDataObject* data);
527 virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
528
534 virtual void AddInputDataObject(int port, vtkDataObject* data);
535 virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
536
545
550
555
560
565 vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
566
570 vtkAlgorithm* GetInputAlgorithm(int port, int index);
571
576
581 vtkExecutive* GetInputExecutive(int port, int index);
582
587
596 vtkInformation* GetInputInformation(int port, int index);
602
611
613
617 virtual void Update(int port);
619 virtual void Update();
621
644 virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
645
659 virtual int UpdatePiece(
660 int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
661
668 virtual int UpdateExtent(const int extents[6]);
669
677 virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
678 const int extents[6] = nullptr);
684 virtual void UpdateInformation();
685
689 virtual void UpdateDataObject();
690
694 virtual void PropagateUpdateExtent();
697 * Bring this algorithm's outputs up-to-date.
698 */
700 virtual void UpdateWholeExtent();
706 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
707
708 //======================================================================
709 // The following block of code is to support old style VTK applications. If
710 // you are using these calls there are better ways to do it in the new
711 // pipeline
712 //======================================================================
723
724 //========================================================================
725
727
734 int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
736
742
744
749 int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
750 int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
751 void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
752 {
753 this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
754 }
755 void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
756 void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
757 void GetUpdateExtent(int port, int extent[6]);
759
761
766 int GetUpdatePiece() { return this->GetUpdatePiece(0); }
767 int GetUpdatePiece(int port);
770 int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
771 int GetUpdateGhostLevel(int port);
773
775
787
789
799 void SetNoPriorTemporalAccessInformationKey(int key);
800 void SetNoPriorTemporalAccessInformationKey();
802
808
809protected:
811 ~vtkAlgorithm() override;
812
813 // Time stamp to store the last time any filter was aborted.
815
816 // Time stamp to store the last time this filter checked for an
817 // abort.
819
820 // Keys used to indicate that input/output port information has been
821 // filled.
823
824 // Arbitrary extra information associated with this algorithm
826
832
838 virtual int FillInputPortInformation(int port, vtkInformation* info);
839
845 virtual int FillOutputPortInformation(int port, vtkInformation* info);
846
850 virtual void SetNumberOfInputPorts(int n);
851
855 virtual void SetNumberOfOutputPorts(int n);
856
857 // Helper methods to check input/output port index ranges.
858 int InputPortIndexInRange(int index, const char* action);
859 int OutputPortIndexInRange(int index, const char* action);
860
866
868
876 int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
879
881
887 int idx, vtkInformationVector** inputVector, int& association);
889
891
899 vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
901 int idx, int connection, vtkInformationVector** inputVector, int& association);
903 vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
905
907
913 int idx, vtkInformationVector** inputVector, int& association);
915
917
926 int idx, int connection, vtkInformationVector** inputVector);
928 int idx, int connection, vtkInformationVector** inputVector, int& association);
932
941
949
951
955 vtkSetMacro(ErrorCode, unsigned long);
956 unsigned long ErrorCode;
958
959 // Progress/Update handling
960 double Progress;
962
963 // Garbage collection support.
965
966 // executive methods below
967
974 virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
975
982 virtual void SetNumberOfInputConnections(int port, int n);
983
985
992 void SetInputDataInternal(int port, vtkDataObject* input)
993 {
994 this->SetInputDataObject(port, input);
995 }
996 void AddInputDataInternal(int port, vtkDataObject* input)
997 {
998 this->AddInputDataObject(port, input);
999 }
1000
1002
1003private:
1004 vtkExecutive* Executive;
1005 vtkInformationVector* InputPortInformation;
1006 vtkInformationVector* OutputPortInformation;
1007 vtkAlgorithmInternals* AlgorithmInternal;
1008 static void ConnectionAdd(
1009 vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
1010 static void ConnectionRemove(
1011 vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
1012 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
1013 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
1014
1015 vtkAlgorithm(const vtkAlgorithm&) = delete;
1016 void operator=(const vtkAlgorithm&) = delete;
1017
1018 double ProgressShift;
1019 double ProgressScale;
1020 vtkAlgorithm* ContainerAlgorithm;
1021 bool AbortOutput;
1022};
1023
1024VTK_ABI_NAMESPACE_END
1025#endif
Abstract superclass for all arrays.
Proxy object to connect input/output ports.
Superclass for all sources, filters, and sinks in VTK.
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.
void UpdateProgress(double amount)
Update the progress of the process object.
void SetInputArrayToProcess(const char *name, int fieldAssociation)
Set the input data arrays that this algorithm will process.
vtkInformation * GetInputArrayInformation(int idx)
Get the info object for the specified input array to this algorithm.
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
Remove a connection from the given input port index.
int GetUpdateGhostLevel()
These functions return the update extent for output ports that use piece extents.
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.
virtual void AddInputDataObject(vtkDataObject *data)
virtual void SetInputDataObject(vtkDataObject *data)
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.
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
vtkAlgorithm * GetContainerAlgorithm()
Set/get a Container algorithm for this algorithm.
virtual vtkTypeBool Update(vtkInformation *requests)
Convenience method to update an algorithm after passing requests to its first output port.
void SetContainerAlgorithm(vtkAlgorithm *containerAlg)
Set/get a Container algorithm for this algorithm.
vtkDataObject * GetOutputDataObject(int port)
Get the data object that will contain the algorithm output for the given port.
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0).
vtkExecutive * GetInputExecutive(int port, int index)
Returns the executive associated with a particular input connection.
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.
virtual void AddInputConnection(vtkAlgorithmOutput *input)
Add a connection to the given input port index.
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.
virtual void SetInputArrayToProcess(int idx, int port, int connection, const char *fieldAssociation, const char *attributeTypeorName)
Set the input data arrays that this algorithm will process.
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.
int GetNumberOfInputPorts()
Get the number of input ports used by the algorithm.
void ReleaseDataFlagOn()
Turn release data flag on or off for all output ports.
void SetProgressShiftScale(double shift, double scale)
Specify the shift and scale values to use to apply to the progress amount when UpdateProgress is call...
virtual VTK_UNBLOCKTHREADS 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.
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0).
void GetUpdateExtent(int port, int extent[6])
These functions return the update extent for output ports that use 3D extents.
virtual void SetReleaseDataFlag(vtkTypeBool)
Turn release data flag on or off for all output ports.
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 SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name)
Set the input data arrays that this algorithm will process.
vtkTypeBool HasExecutive()
Check whether this algorithm has an assigned executive.
virtual void AddInputDataObject(int port, vtkDataObject *data)
Add the data-object as an input to this given port.
vtkAlgorithmOutput * GetOutputPort()
virtual VTK_UNBLOCKTHREADS void Update()
Bring this algorithm's outputs up-to-date.
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).
bool CheckAbort()
Checks to see if this filter should abort.
vtkAlgorithm * GetInputAlgorithm(int port, int index)
Returns the algorithm connected to a port-index pair.
virtual VTK_UNBLOCKTHREADS void UpdateInformation()
Bring the algorithm's information up-to-date.
static vtkAlgorithm * New()
void SetProgressObserver(vtkProgressObserver *)
If an ProgressObserver is set, the algorithm will report progress through it rather than directly.
virtual void SetInputArrayToProcess(int idx, vtkInformation *info)
Set the input data arrays that this algorithm will process.
void SetAbortExecuteAndUpdateTime()
Set AbortExecute Flag and update LastAbortTime.
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)
Set the connection for the given input port index.
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.
bool UsesGarbageCollector() const override
Participate in garbage collection.
virtual vtkTypeBool GetReleaseDataFlag()
Turn release data flag on or off for all output ports.
int GetNumberOfInputConnections(int port)
Get the number of inputs currently connected to a port.
virtual VTK_UNBLOCKTHREADS void Update(int port)
Bring this algorithm's outputs up-to-date.
void SetProgressText(const char *ptext)
Set the current text message associated with the progress state.
virtual void PropagateUpdateExtent()
Propagate meta-data upstream.
std::atomic< vtkTypeBool > AbortExecute
vtkExecutive * GetExecutive()
Get this algorithm's executive.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents.
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.
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)
These functions return the update extent for output ports that use 3D extents.
virtual VTK_UNBLOCKTHREADS void UpdateWholeExtent()
Bring this algorithm's outputs up-to-date.
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)
Set the input data arrays that this algorithm will process.
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
vtkDataObject * GetInputDataObject(int port, int connection)
Get the data object that will contain the algorithm input for the given port and given connection.
vtkAlgorithmOutput * GetOutputPort(int index)
Get a proxy object corresponding to the given output port of this algorithm.
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.
vtkInformation * GetInputInformation(int port, int index)
Return the information object that is associated with a particular input connection.
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this algorithm.
virtual void AddInputConnection(int port, vtkAlgorithmOutput *input)
Add a connection to the given input port index.
void RemoveAllInputs()
Remove all the input data.
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.
virtual VTK_UNBLOCKTHREADS int UpdateExtent(const int extents[6])
Convenience method to update an algorithm after passing requests to its first output port.
create and manipulate ordered lists of objects
general representation of visualization data
Superclass for all pipeline executives in VTK.
Detect and break reference loops.
a simple class to control print indentation
Definition vtkIndent.h:29
Key for integer values in vtkInformation.
Key for string values in vtkInformation.
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
virtual void ReportReferences(vtkGarbageCollector *)
Basic class to optionally replace vtkAlgorithm progress functionality.
record modification and/or execution time
static vtkInformationStringVectorKey * INPUT_REQUIRED_DATA_TYPE()
static vtkInformationIntegerKey * INPUT_IS_OPTIONAL()
Keys used to specify input port requirements.
static vtkInformationIntegerKey * CAN_HANDLE_PIECE_REQUEST()
Key that tells the pipeline that a particular algorithm can or cannot handle piece request.
static vtkInformationIntegerKey * INPUT_PORT()
static vtkInformationInformationVectorKey * INPUT_REQUIRED_FIELDS()
static vtkInformationInformationVectorKey * INPUT_ARRAYS_TO_PROCESS()
static vtkInformationIntegerKey * INPUT_CONNECTION()
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 * ABORTED()
static vtkInformationIntegerKey * INPUT_IS_REPEATABLE()
int vtkTypeBool
Definition vtkABI.h:64
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Fill the output port information objects for this algorithm.
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
void AddInputDataInternal(int port, vtkDataObject *input)
virtual void SetNumberOfInputConnections(int port, int n)
Set the number of input connections on the given input port.
virtual void SetNumberOfOutputPorts(int n)
Set the number of output ports provided by the algorithm.
void SetInputDataInternal(int port, vtkDataObject *input)
These methods are used by subclasses to implement methods to set data objects directly as input.
*unsigned long ErrorCode
static vtkTimeStamp LastAbortTime
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
vtkTimeStamp LastAbortCheckTime
char * ProgressText
~vtkAlgorithm() override
vtkProgressObserver * ProgressObserver
**vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, vtkInformationVector **inputVector, int &association)
**vtkDataArray * GetInputArrayToProcess(int idx, vtkInformationVector **inputVector, int &association)
vtkInformation * Information
static vtkInformationIntegerKey * PORT_REQUIREMENTS_FILLED()
vtkAlgorithm()
*double Progress
bool CheckUpstreamAbort()
Checks to see if an upstream filter has been aborted.
int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector)
Get the association of the actual data array for the input array specified by idx,...
virtual void SetNumberOfInputPorts(int n)
Set the number of input ports used by the algorithm.
virtual void SetInputDataObject(int port, vtkDataObject *data)
Sets the data-object as an input on the given port index.
vtkAlgorithm vtkObject RemoveNoPriorTemporalAccessInformationKey()
Removes any information key vtkStreamingDemandDrivenPipeline::NO_PRIOR_TEMPORAL_ACCESS() to all outpu...
virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput *input)
Replace the Nth connection on the given input port.
static vtkExecutive * DefaultExecutivePrototype
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
int OutputPortIndexInRange(int index, const char *action)
virtual void AddInputDataObject(int port, vtkDataObject *data)
Add the data-object as an input to this given port.
*vtkInformation * GetInputArrayFieldInformation(int idx, vtkInformationVector **inputVector)
This method takes in an index (as specified in SetInputArrayToProcess) and a pipeline information vec...
int InputPortIndexInRange(int index, const char *action)
#define vtkDataArray
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_SIZEHINT(...)
#define VTK_UNBLOCKTHREADS
#define VTK_MARSHALMANUAL