VTK  9.2.6
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=========================================================================*/
97#ifndef vtkAlgorithm_h
98#define vtkAlgorithm_h
99
100#include "vtkCommonExecutionModelModule.h" // For export macro
101#include "vtkObject.h"
102
103class vtkAbstractArray;
104class vtkAlgorithmInternals;
106class vtkCollection;
107class vtkDataArray;
108class vtkDataObject;
109class vtkExecutive;
110class vtkInformation;
117
118class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
119{
120public:
121 static vtkAlgorithm* New();
122 vtkTypeMacro(vtkAlgorithm, vtkObject);
123 void PrintSelf(ostream& os, vtkIndent indent) override;
124
146 {
149 DEFAULT_PRECISION
150 };
151
157
163
169 virtual void SetExecutive(vtkExecutive* executive);
170
195 vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
196
202 vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
203
210 vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
211
219 virtual int ModifyRequest(vtkInformation* request, int when);
220
228
236
238
241 vtkGetObjectMacro(Information, vtkInformation);
244
249
254
256
259 bool UsesGarbageCollector() const override { return true; }
261
263
267 vtkSetMacro(AbortExecute, vtkTypeBool);
268 vtkGetMacro(AbortExecute, vtkTypeBool);
269 vtkBooleanMacro(AbortExecute, vtkTypeBool);
271
273
276 vtkGetMacro(Progress, double);
278
284 void UpdateProgress(double amount);
285
287
299 void SetProgressShiftScale(double shift, double scale);
300 vtkGetMacro(ProgressShift, double);
301 vtkGetMacro(ProgressScale, double);
303
305
312 void SetProgressText(const char* ptext);
313 vtkGetStringMacro(ProgressText);
315
317
321 vtkGetMacro(ErrorCode, unsigned long);
323
324 // left public for performance since it is used in inner loops
326
356
366
380
382
391 int idx, int port, int connection, int fieldAssociation, const char* name);
393 int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
396
420 virtual void SetInputArrayToProcess(int idx, int port, int connection,
421 const char* fieldAssociation, const char* attributeTypeorName);
422
427
428 // from here down are convenience methods that really are executive methods
429
434
440
445 vtkDataObject* GetInputDataObject(int port, int connection);
446
448
461 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
464
466
475 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
478
489
493 virtual void RemoveInputConnection(int port, int idx);
494
499
509 virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
510
517 virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
518
527
532
537
542
547 vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
548
553
558
564
569
579
584
593
595
598 virtual void Update(int port);
599 virtual void Update();
601
625
632
639 virtual int UpdatePiece(
640 int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
641
647 virtual int UpdateExtent(const int extents[6]);
648
655 virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
656 const int extents[6] = nullptr);
657
661 virtual void UpdateInformation();
662
666 virtual void UpdateDataObject();
667
671 virtual void PropagateUpdateExtent();
672
676 virtual void UpdateWholeExtent();
677
682 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
683
684 //======================================================================
685 // The following block of code is to support old style VTK applications. If
686 // you are using these calls there are better ways to do it in the new
687 // pipeline
688 //======================================================================
689
691
694 virtual void SetReleaseDataFlag(int);
695 virtual int GetReleaseDataFlag();
699
700 //========================================================================
701
703
710 int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
712
718
720
725 int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
727 void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
728 {
729 this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
730 }
731 void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
732 void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
733 void GetUpdateExtent(int port, int extent[6]);
735
737
742 int GetUpdatePiece() { return this->GetUpdatePiece(0); }
746 int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
749
751
761 vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
763
764protected:
766 ~vtkAlgorithm() override;
767
768 // Keys used to indicate that input/output port information has been
769 // filled.
771
772 // Arbitrary extra information associated with this algorithm
774
781
788
792 virtual void SetNumberOfInputPorts(int n);
793
797 virtual void SetNumberOfOutputPorts(int n);
798
799 // Helper methods to check input/output port index ranges.
800 int InputPortIndexInRange(int index, const char* action);
801 int OutputPortIndexInRange(int index, const char* action);
802
808
810
818 int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
821
823
829 int idx, vtkInformationVector** inputVector, int& association);
831
833
841 vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
843 int idx, int connection, vtkInformationVector** inputVector, int& association);
845 vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
847
849
855 int idx, vtkInformationVector** inputVector, int& association);
857
859
868 int idx, int connection, vtkInformationVector** inputVector);
870 int idx, int connection, vtkInformationVector** inputVector, int& association);
874
883
891
893
897 vtkSetMacro(ErrorCode, unsigned long);
898 unsigned long ErrorCode;
900
901 // Progress/Update handling
902 double Progress;
904
905 // Garbage collection support.
907
908 // executive methods below
909
916 virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
917
924 virtual void SetNumberOfInputConnections(int port, int n);
925
927
935 {
936 this->SetInputDataObject(port, input);
937 }
939 {
940 this->AddInputDataObject(port, input);
941 }
942
944
945private:
946 vtkExecutive* Executive;
947 vtkInformationVector* InputPortInformation;
948 vtkInformationVector* OutputPortInformation;
949 vtkAlgorithmInternals* AlgorithmInternal;
950 static void ConnectionAdd(
951 vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
952 static void ConnectionRemove(
953 vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
954 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
955 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
956
957private:
958 vtkAlgorithm(const vtkAlgorithm&) = delete;
959 void operator=(const vtkAlgorithm&) = delete;
960
961 double ProgressShift;
962 double ProgressScale;
963};
964
965#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:119
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.
vtkInformation * GetInputArrayInformation(int idx)
Get the info object for the specified input array to this algorithm.
int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector)
Get the association of the actual data array for the input array specified by idx,...
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
Remove a connection from the given input port index.
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:746
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:517
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:509
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:732
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:742
vtkInformation * Information
Definition: vtkAlgorithm.h:773
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.
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)
Definition: vtkAlgorithm.h:568
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.
vtkAbstractArray * GetInputAbstractArrayToProcess(int idx, int connection, vtkInformationVector **inputVector, int &association)
Filters that have multiple connections on one port can use this signature.
virtual void SetInputArrayToProcess(int idx, int port, int connection, const char *fieldAssociation, const char *attributeTypeorName)
String based versions of SetInputArrayToProcess().
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:934
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.
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, 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:583
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file.
Definition: vtkAlgorithm.h:898
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 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.
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:526
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:557
void ReportReferences(vtkGarbageCollector *) override
char * ProgressText
Definition: vtkAlgorithm.h:903
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.
virtual void SetInputArrayToProcess(int idx, vtkInformation *info)
Set the input data arrays that this algorithm will process.
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.
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.
vtkDataArray * GetInputArrayToProcess(int idx, vtkDataObject *input)
Filters that have multiple connections on one port can use this signature.
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.
Definition: vtkAlgorithm.h:259
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.
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:325
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.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:744
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:146
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.
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:727
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.
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 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:725
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:943
virtual int GetReleaseDataFlag()
Turn release data flag on or off for all output ports.
vtkDataObject * GetInputDataObject(int port, int connection)
Get the data object that will contain the algorithm input for the given port and given connection.
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:938
~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:902
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:926
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.
create and manipulate ordered lists of objects
Definition: vtkCollection.h:56
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
general representation of visualization data
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:79
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:119
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: vtkObject.h:79
Basic class to optionally replace vtkAlgorithm progress functionality.
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 * 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:287
#define VTK_SIZEHINT(...)