VTK  9.0.1
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 =========================================================================*/
35 #ifndef vtkAlgorithm_h
36 #define vtkAlgorithm_h
37 
38 #include "vtkCommonExecutionModelModule.h" // For export macro
39 #include "vtkObject.h"
40 
41 class vtkAbstractArray;
42 class vtkAlgorithmInternals;
43 class vtkAlgorithmOutput;
44 class vtkCollection;
45 class vtkDataArray;
46 class vtkDataObject;
47 class vtkExecutive;
48 class vtkInformation;
55 
56 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
57 {
58 public:
59  static vtkAlgorithm* New();
60  vtkTypeMacro(vtkAlgorithm, vtkObject);
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
84  {
87  DEFAULT_PRECISION
88  };
89 
94  int HasExecutive();
95 
100  vtkExecutive* GetExecutive();
101 
107  virtual void SetExecutive(vtkExecutive* executive);
108 
132  virtual vtkTypeBool ProcessRequest(
133  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
134 
139  vtkTypeBool ProcessRequest(
140  vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
141 
147  virtual int ComputePipelineMTime(vtkInformation* request, vtkInformationVector** inInfoVec,
148  vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
149 
157  virtual int ModifyRequest(vtkInformation* request, int when);
158 
165  vtkInformation* GetInputPortInformation(int port);
166 
173  vtkInformation* GetOutputPortInformation(int port);
174 
176 
179  vtkGetObjectMacro(Information, vtkInformation);
180  virtual void SetInformation(vtkInformation*);
182 
186  int GetNumberOfInputPorts();
187 
191  int GetNumberOfOutputPorts();
192 
194 
197  void Register(vtkObjectBase* o) override;
198  void UnRegister(vtkObjectBase* o) override;
200 
202 
206  vtkSetMacro(AbortExecute, vtkTypeBool);
207  vtkGetMacro(AbortExecute, vtkTypeBool);
208  vtkBooleanMacro(AbortExecute, vtkTypeBool);
210 
212 
215  vtkGetMacro(Progress, double);
217 
222  VTK_LEGACY(void SetProgress(double));
223 
229  void UpdateProgress(double amount);
230 
232 
244  void SetProgressShiftScale(double shift, double scale);
245  vtkGetMacro(ProgressShift, double);
246  vtkGetMacro(ProgressScale, double);
248 
250 
257  void SetProgressText(const char* ptext);
258  vtkGetStringMacro(ProgressText);
260 
262 
266  vtkGetMacro(ErrorCode, unsigned long);
268 
269  // left public for performance since it is used in inner loops
271 
276  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
280  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
284  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
288  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
292  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
296  static vtkInformationIntegerKey* INPUT_PORT();
300  static vtkInformationIntegerKey* INPUT_CONNECTION();
301 
310  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
311 
324  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
325 
327 
335  virtual void SetInputArrayToProcess(
336  int idx, int port, int connection, int fieldAssociation, const char* name);
337  virtual void SetInputArrayToProcess(
338  int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
339  virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
341 
365  virtual void SetInputArrayToProcess(int idx, int port, int connection,
366  const char* fieldAssociation, const char* attributeTypeorName);
367 
371  vtkInformation* GetInputArrayInformation(int idx);
372 
373  // from here down are convenience methods that really are executive methods
374 
378  void RemoveAllInputs();
379 
384  vtkDataObject* GetOutputDataObject(int port);
385 
390  vtkDataObject* GetInputDataObject(int port, int connection);
391 
393 
406  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
407  virtual void SetInputConnection(vtkAlgorithmOutput* input);
409 
411 
420  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
421  virtual void AddInputConnection(vtkAlgorithmOutput* input);
423 
433  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
434 
438  virtual void RemoveInputConnection(int port, int idx);
439 
443  virtual void RemoveAllInputConnections(int port);
444 
453  virtual void SetInputDataObject(int port, vtkDataObject* data);
454  virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
455 
461  virtual void AddInputDataObject(int port, vtkDataObject* data);
462  virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
463 
470  vtkAlgorithmOutput* GetOutputPort(int index);
472 
476  int GetNumberOfInputConnections(int port);
477 
481  int GetTotalNumberOfInputConnections();
482 
486  vtkAlgorithmOutput* GetInputConnection(int port, int index);
487 
492  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
493 
497  vtkAlgorithm* GetInputAlgorithm(int port, int index);
498 
503 
508  vtkExecutive* GetInputExecutive(int port, int index);
509 
514 
523  vtkInformation* GetInputInformation(int port, int index);
524 
529 
537  vtkInformation* GetOutputInformation(int port);
538 
540 
543  virtual void Update(int port);
544  virtual void Update();
546 
569  virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
570 
576  virtual vtkTypeBool Update(vtkInformation* requests);
577 
584  virtual int UpdatePiece(
585  int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
586 
592  virtual int UpdateExtent(const int extents[6]);
593 
600  virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
601  const int extents[6] = nullptr);
602 
606  virtual void UpdateInformation();
607 
611  virtual void UpdateDataObject();
612 
616  virtual void PropagateUpdateExtent();
617 
621  virtual void UpdateWholeExtent();
622 
627  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
628 
629  //======================================================================
630  // The following block of code is to support old style VTK applications. If
631  // you are using these calls there are better ways to do it in the new
632  // pipeline
633  //======================================================================
634 
636 
639  virtual void SetReleaseDataFlag(int);
640  virtual int GetReleaseDataFlag();
641  void ReleaseDataFlagOn();
642  void ReleaseDataFlagOff();
644 
645  //========================================================================
646 
648 
654  int UpdateExtentIsEmpty(vtkInformation* pinfo, vtkDataObject* output);
655  int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
657 
662  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
663 
665 
670  int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
671  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
672  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
673  {
674  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
675  }
676  void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
677  void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
678  void GetUpdateExtent(int port, int extent[6]);
680 
682 
687  int GetUpdatePiece() { return this->GetUpdatePiece(0); }
688  int GetUpdatePiece(int port);
690  int GetUpdateNumberOfPieces(int port);
691  int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
692  int GetUpdateGhostLevel(int port);
694 
696 
705  void SetProgressObserver(vtkProgressObserver*);
706  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
708 
709 protected:
710  vtkAlgorithm();
711  ~vtkAlgorithm() override;
712 
713  // Keys used to indicate that input/output port information has been
714  // filled.
715  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
716 
717  // Arbitrary extra information associated with this algorithm
719 
725  virtual int FillInputPortInformation(int port, vtkInformation* info);
726 
732  virtual int FillOutputPortInformation(int port, vtkInformation* info);
733 
737  virtual void SetNumberOfInputPorts(int n);
738 
742  virtual void SetNumberOfOutputPorts(int n);
743 
744  // Helper methods to check input/output port index ranges.
745  int InputPortIndexInRange(int index, const char* action);
746  int OutputPortIndexInRange(int index, const char* action);
747 
752  int GetInputArrayAssociation(int idx, vtkInformationVector** inputVector);
753 
755 
763  int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
764  int GetInputArrayAssociation(int idx, vtkDataObject* input);
766 
768 
772  vtkDataArray* GetInputArrayToProcess(int idx, vtkInformationVector** inputVector);
773  vtkDataArray* GetInputArrayToProcess(
774  int idx, vtkInformationVector** inputVector, int& association);
776 
778 
786  vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
787  vtkDataArray* GetInputArrayToProcess(
788  int idx, int connection, vtkInformationVector** inputVector, int& association);
789  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input);
790  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
792 
794 
798  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkInformationVector** inputVector);
799  vtkAbstractArray* GetInputAbstractArrayToProcess(
800  int idx, vtkInformationVector** inputVector, int& association);
802 
804 
812  vtkAbstractArray* GetInputAbstractArrayToProcess(
813  int idx, int connection, vtkInformationVector** inputVector);
814  vtkAbstractArray* GetInputAbstractArrayToProcess(
815  int idx, int connection, vtkInformationVector** inputVector, int& association);
816  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input);
817  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input, int& association);
819 
827  vtkInformation* GetInputArrayFieldInformation(int idx, vtkInformationVector** inputVector);
828 
835  virtual vtkExecutive* CreateDefaultExecutive();
836 
838 
842  vtkSetMacro(ErrorCode, unsigned long);
843  unsigned long ErrorCode;
845 
846  // Progress/Update handling
847  double Progress;
849 
850  // Garbage collection support.
851  void ReportReferences(vtkGarbageCollector*) override;
852 
853  // executive methods below
854 
861  virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
862 
869  virtual void SetNumberOfInputConnections(int port, int n);
870 
872 
880  {
881  this->SetInputDataObject(port, input);
882  }
884  {
885  this->AddInputDataObject(port, input);
886  }
887 
889 
890 private:
891  vtkExecutive* Executive;
892  vtkInformationVector* InputPortInformation;
893  vtkInformationVector* OutputPortInformation;
894  vtkAlgorithmInternals* AlgorithmInternal;
895  static void ConnectionAdd(
896  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
897  static void ConnectionRemove(
898  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
899  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
900  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
901 
902 private:
903  vtkAlgorithm(const vtkAlgorithm&) = delete;
904  void operator=(const vtkAlgorithm&) = delete;
905 
906  double ProgressShift;
907  double ProgressScale;
908 };
909 
910 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:471
abstract base class for most VTK objects
Definition: vtkObject.h:56
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:83
virtual void Register(vtkObjectBase *o)
Increase the reference count (mark as used by another object).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetUpdateExtent(int extent[6])
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:677
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:687
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:670
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:502
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:528
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:462
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:46
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:879
Key for string values in vtkInformation.
Detect and break reference loops.
Proxy object to connect input/output ports.
int vtkTypeBool
Definition: vtkABI.h:69
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:883
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:56
vtkInformation * Information
Definition: vtkAlgorithm.h:718
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void ReportReferences(vtkGarbageCollector *)
Key for integer values in vtkInformation.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:689
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
abstract base class for most VTK objects
Definition: vtkObjectBase.h:63
#define VTK_SIZEHINT(...)
Key for String vector values.
char * ProgressText
Definition: vtkAlgorithm.h:848
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:454
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file...
Definition: vtkAlgorithm.h:842
double Progress
Definition: vtkAlgorithm.h:847
create and manipulate ordered lists of objects
Definition: vtkCollection.h:52
int GetUpdateGhostLevel()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:691
Store zero or more vtkInformation instances.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:888
general representation of visualization data
Definition: vtkDataObject.h:59
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:266
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:513
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:672
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:871