VTK
vtkAlgorithm.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAlgorithm.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
38#ifndef vtkAlgorithm_h
39#define vtkAlgorithm_h
40
41#include "vtkCommonExecutionModelModule.h" // For export macro
42#include "vtkObject.h"
43
45class vtkAlgorithmInternals;
47class vtkCollection;
48class vtkDataArray;
49class vtkDataObject;
50class vtkExecutive;
51class vtkInformation;
58
59class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
60{
61public:
62 static vtkAlgorithm *New();
63 vtkTypeMacro(vtkAlgorithm,vtkObject);
64 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
65
80 {
83 DEFAULT_PRECISION
84 };
85
91
97
103 virtual void SetExecutive(vtkExecutive* executive);
104
128 virtual int ProcessRequest(vtkInformation* request,
129 vtkInformationVector** inInfo,
130 vtkInformationVector* outInfo);
131
137 vtkCollection* inInfo,
138 vtkInformationVector* outInfo);
139
145 virtual int
147 vtkInformationVector** inInfoVec,
148 vtkInformationVector* outInfoVec,
149 int requestFromOutputPort,
150 vtkMTimeType* mtime);
151
159 virtual int ModifyRequest(vtkInformation* request, int when);
160
168
176
178
181 vtkGetObjectMacro(Information, vtkInformation);
184
189
194
196
199 void Register(vtkObjectBase* o) VTK_OVERRIDE;
200 void UnRegister(vtkObjectBase* o) VTK_OVERRIDE;
202
204
208 vtkSetMacro(AbortExecute,int);
209 vtkGetMacro(AbortExecute,int);
210 vtkBooleanMacro(AbortExecute,int);
212
214
217 vtkSetClampMacro(Progress,double,0.0,1.0);
218 vtkGetMacro(Progress,double);
220
226 void UpdateProgress(double amount);
227
229
236 void SetProgressText(const char* ptext);
237 vtkGetStringMacro(ProgressText);
239
241
245 vtkGetMacro( ErrorCode, unsigned long );
247
248 // left public for performance since it is used in inner loops
250
280
290
304
305
307
315 virtual void SetInputArrayToProcess(int idx, int port, int connection,
316 int fieldAssociation,
317 const char *name);
318 virtual void SetInputArrayToProcess(int idx, int port, int connection,
319 int fieldAssociation,
320 int fieldAttributeType);
323
347 virtual void SetInputArrayToProcess(int idx, int port, int connection,
348 const char* fieldAssociation,
349 const char* attributeTypeorName);
350
355
356 // from here down are convenience methods that really are executive methods
357
358
359
364
370
376 int connection);
377
379
392 virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
395
397
406 virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
409
420
424 virtual void RemoveInputConnection(int port, int idx);
425
430
441 { this->SetInputDataObject(0, data); }
442
450 { this->AddInputDataObject(0, data); }
451
460 return this->GetOutputPort(0); }
461
466
471
476
481 vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
482
487
492 {
493 return this->GetInputAlgorithm(0, 0);
494 }
495
501
506 {
507 return this->GetInputExecutive(0, 0);
508 }
509
519
524 {
525 return this->GetInputInformation(0, 0);
526 }
527
536
538
541 virtual void Update(int port);
542 virtual void Update();
544
567 virtual int Update(int port, vtkInformationVector* requests);
568
574 virtual int Update(vtkInformation* requests);
575
582 virtual int UpdatePiece(
583 int piece, int numPieces, int ghostLevels, const int extents[6]=0);
584
590 virtual int UpdateExtent(const int extents[6]);
591
598 virtual int UpdateTimeStep(double time,
599 int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0);
600
604 virtual void UpdateInformation();
605
609 virtual void UpdateDataObject();
610
614 virtual void PropagateUpdateExtent();
615
619 virtual void UpdateWholeExtent();
620
625 void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
626
627 //======================================================================
628 //The following block of code is to support old style VTK applications. If
629 //you are using these calls there are better ways to do it in the new
630 //pipeline
631 //======================================================================
632
634
637 virtual void SetReleaseDataFlag(int);
638 virtual int GetReleaseDataFlag();
642
643 //========================================================================
644
646
653 int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
655
661
667 VTK_LEGACY(int SetUpdateExtentToWholeExtent(int port));
668
675
679 VTK_LEGACY(void SetUpdateExtent(int port,
680 int piece,int numPieces, int ghostLevel));
681
686 VTK_LEGACY(void SetUpdateExtent(
687 int piece,int numPieces, int ghostLevel));
688
692 VTK_LEGACY(void SetUpdateExtent(int port, int extent[6]));
693
697 VTK_LEGACY(void SetUpdateExtent(int extent[6]));
698
700
706 {
707 return this->GetUpdateExtent(0);
708 }
710 void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
711 int& z0, int& z1)
712 {
713 this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
714 }
716 int& x0, int& x1, int& y0, int& y1,
717 int& z0, int& z1);
719 {
720 this->GetUpdateExtent(0, extent);
721 }
722 void GetUpdateExtent(int port, int extent[6]);
724
726
732 {
733 return this->GetUpdatePiece(0);
734 }
737 {
738 return this->GetUpdateNumberOfPieces(0);
739 }
742 {
743 return this->GetUpdateGhostLevel(0);
744 }
747
749
759 vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
761
762protected:
764 ~vtkAlgorithm() VTK_OVERRIDE;
765
766 // Keys used to indicate that input/output port information has been
767 // filled.
768 static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
769
770 // Arbitrary extra information associated with this algorithm
771 vtkInformation* Information;
772
778 virtual int FillInputPortInformation(int port, vtkInformation* info);
779
785 virtual int FillOutputPortInformation(int port, vtkInformation* info);
786
790 virtual void SetNumberOfInputPorts(int n);
791
795 virtual void SetNumberOfOutputPorts(int n);
796
797 // Helper methods to check input/output port index ranges.
798 int InputPortIndexInRange(int index, const char* action);
799 int OutputPortIndexInRange(int index, const char* action);
800
805 int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
806
808
816 int GetInputArrayAssociation(int idx, int connection,
817 vtkInformationVector **inputVector);
818 int GetInputArrayAssociation(int idx, vtkDataObject* input);
820
821
823
827 vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
828 vtkDataArray *GetInputArrayToProcess(int idx,
829 vtkInformationVector **inputVector,
830 int& association);
832
834
842 vtkDataArray *GetInputArrayToProcess(int idx,
843 int connection,
844 vtkInformationVector **inputVector);
845 vtkDataArray *GetInputArrayToProcess(int idx,
846 int connection,
847 vtkInformationVector **inputVector,
848 int& association);
849 vtkDataArray *GetInputArrayToProcess(int idx,
850 vtkDataObject* input);
851 vtkDataArray *GetInputArrayToProcess(int idx,
852 vtkDataObject* input,
853 int& association);
855
856
858
862 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
863 vtkAbstractArray *GetInputAbstractArrayToProcess
864 (int idx, vtkInformationVector **inputVector, int& association);
866
868
876 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
877 int connection,
878 vtkInformationVector **inputVector);
879 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
880 int connection,
881 vtkInformationVector **inputVector,
882 int& association);
883 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
884 vtkDataObject* input);
885 vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
886 vtkDataObject* input,
887 int& association);
889
890
891
899 vtkInformation *GetInputArrayFieldInformation(int idx,
900 vtkInformationVector **inputVector);
901
902
909 virtual vtkExecutive* CreateDefaultExecutive();
910
912
916 vtkSetMacro( ErrorCode, unsigned long );
917 unsigned long ErrorCode;
919
920 // Progress/Update handling
921 double Progress;
922 char *ProgressText;
923
924 // Garbage collection support.
925 void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;
926
927 // executive methods below
928
935 virtual void SetNthInputConnection(int port, int index,
936 vtkAlgorithmOutput* input);
937
944 virtual void SetNumberOfInputConnections(int port, int n);
945
946 static vtkExecutive* DefaultExecutivePrototype;
947
954 void SetInputDataInternal(int port, vtkDataObject *input)
955 { this->SetInputDataObject(port, input); }
957 { this->AddInputDataObject(port, input); }
958
960
961private:
962 vtkExecutive* Executive;
963 vtkInformationVector* InputPortInformation;
964 vtkInformationVector* OutputPortInformation;
965 vtkAlgorithmInternals* AlgorithmInternal;
966 static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
967 vtkAlgorithm* consumer, int consumerPort);
968 static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
969 vtkAlgorithm* consumer, int consumerPort);
970 static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
971 static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
972
973private:
974 vtkAlgorithm(const vtkAlgorithm&) VTK_DELETE_FUNCTION;
975 void operator=(const vtkAlgorithm&) VTK_DELETE_FUNCTION;
976};
977
978#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:60
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)
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.
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
Remove a connection from the given input port index.
int GetUpdateGhostLevel()
Definition: vtkAlgorithm.h:741
void GetUpdateExtent(int port, int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
vtkInformation * GetOutputPortInformation(int port)
Get the information object associated with an output port.
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:449
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:440
int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType)
void SetUpdateExtent(int extent[6])
Convenience function equivalent to SetUpdateExtent(0, extent)
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:718
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:731
int SetUpdateExtentToWholeExtent(int port)
If the whole output extent is required, this method can be called to set the output update extent to ...
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:505
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)
virtual int Update(int port, vtkInformationVector *requests)
This method enables the passing of data requests to the algorithm to be used during execution (in add...
virtual void SetInputArrayToProcess(int idx, int port, int connection, const char *fieldAssociation, const char *attributeTypeorName)
String based versions of SetInputArrayToProcess().
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 UnRegister(vtkObjectBase *o) override
Decrease the reference count (release by another object).
int GetNumberOfInputPorts()
Get the number of input ports used by the algorithm.
void ReleaseDataFlagOn()
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0)
Convenience method to update an algorithm after passing requests to its first output port.
virtual int UpdatePiece(int piece, int numPieces, int ghostLevels, const int extents[6]=0)
Convenience method to update an algorithm after passing requests to its first output port.
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:523
void GetUpdateExtent(int port, int extent[6])
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)
int * GetUpdateExtent(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.
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:459
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:491
virtual int Update(vtkInformation *requests)
Convenience method to update an algorithm after passing requests to its first output port.
int SetUpdateExtentToWholeExtent()
Convenience function equivalent to SetUpdateExtentToWholeExtent(0) This method assumes that the whole...
void SetUpdateExtent(int port, int extent[6])
Set the output update extent for data objects that use 3D extents.
virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo)
Upstream/Downstream requests form the generalized interface through which executives invoke a algorit...
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)
virtual void UpdateWholeExtent()
Bring this algorithm's outputs up-to-date.
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.
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()
Definition: vtkAlgorithm.h:736
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:80
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:710
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 ProcessRequest(vtkInformation *request, vtkCollection *inInfo, vtkInformationVector *outInfo)
Version of ProcessRequest() that is wrapped.
int HasExecutive()
Check whether this algorithm has an assigned executive.
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:705
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:959
virtual int GetReleaseDataFlag()
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:956
~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)
vtkInformation * GetInputInformation(int port, int index)
Return the information object that is associated with a particular input connection.
virtual void SetInformation(vtkInformation *)
virtual void Update()
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 unsorted lists of objects
Definition: vtkCollection.h:52
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
general representation of visualization data
Definition: vtkDataObject.h:65
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:50
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:40
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:66
abstract base class for most VTK objects
Definition: vtkObject.h:60
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:376
@ port
Definition: vtkX3D.h:447
@ time
Definition: vtkX3D.h:497
@ extent
Definition: vtkX3D.h:345
@ name
Definition: vtkX3D.h:219
@ index
Definition: vtkX3D.h:246
@ data
Definition: vtkX3D.h:315
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248