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 =========================================================================*/
41 #ifndef vtkAlgorithm_h
42 #define vtkAlgorithm_h
43 
44 #include "vtkCommonExecutionModelModule.h" // For export macro
45 #include "vtkObject.h"
46 
47 class vtkAbstractArray;
48 class vtkAlgorithmInternals;
49 class vtkAlgorithmOutput;
50 class vtkCollection;
51 class vtkDataArray;
52 class vtkDataObject;
53 class vtkExecutive;
54 class vtkInformation;
61 
62 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
63 {
64 public:
65  static vtkAlgorithm* New();
66  vtkTypeMacro(vtkAlgorithm, vtkObject);
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
90  {
93  DEFAULT_PRECISION
94  };
95 
100  int HasExecutive();
101 
106  vtkExecutive* GetExecutive();
107 
113  virtual void SetExecutive(vtkExecutive* executive);
114 
138  virtual vtkTypeBool ProcessRequest(
139  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
140 
145  vtkTypeBool ProcessRequest(
146  vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
147 
153  virtual int ComputePipelineMTime(vtkInformation* request, vtkInformationVector** inInfoVec,
154  vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
155 
163  virtual int ModifyRequest(vtkInformation* request, int when);
164 
171  vtkInformation* GetInputPortInformation(int port);
172 
179  vtkInformation* GetOutputPortInformation(int port);
180 
182 
185  vtkGetObjectMacro(Information, vtkInformation);
186  virtual void SetInformation(vtkInformation*);
188 
192  int GetNumberOfInputPorts();
193 
197  int GetNumberOfOutputPorts();
198 
200 
203  bool UsesGarbageCollector() const override { return true; }
205 
207 
211  vtkSetMacro(AbortExecute, vtkTypeBool);
212  vtkGetMacro(AbortExecute, vtkTypeBool);
213  vtkBooleanMacro(AbortExecute, vtkTypeBool);
215 
217 
220  vtkGetMacro(Progress, double);
222 
228  void UpdateProgress(double amount);
229 
231 
243  void SetProgressShiftScale(double shift, double scale);
244  vtkGetMacro(ProgressShift, double);
245  vtkGetMacro(ProgressScale, double);
247 
249 
256  void SetProgressText(const char* ptext);
257  vtkGetStringMacro(ProgressText);
259 
261 
265  vtkGetMacro(ErrorCode, unsigned long);
267 
268  // left public for performance since it is used in inner loops
270 
275  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
279  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
283  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
287  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
291  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
295  static vtkInformationIntegerKey* INPUT_PORT();
299  static vtkInformationIntegerKey* INPUT_CONNECTION();
300 
309  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
310 
323  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
324 
326 
334  virtual void SetInputArrayToProcess(
335  int idx, int port, int connection, int fieldAssociation, const char* name);
336  virtual void SetInputArrayToProcess(
337  int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
338  virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
340 
364  virtual void SetInputArrayToProcess(int idx, int port, int connection,
365  const char* fieldAssociation, const char* attributeTypeorName);
366 
370  vtkInformation* GetInputArrayInformation(int idx);
371 
372  // from here down are convenience methods that really are executive methods
373 
377  void RemoveAllInputs();
378 
383  vtkDataObject* GetOutputDataObject(int port);
384 
389  vtkDataObject* GetInputDataObject(int port, int connection);
390 
392 
405  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
406  virtual void SetInputConnection(vtkAlgorithmOutput* input);
408 
410 
419  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
420  virtual void AddInputConnection(vtkAlgorithmOutput* input);
422 
432  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
433 
437  virtual void RemoveInputConnection(int port, int idx);
438 
442  virtual void RemoveAllInputConnections(int port);
443 
452  virtual void SetInputDataObject(int port, vtkDataObject* data);
453  virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
454 
460  virtual void AddInputDataObject(int port, vtkDataObject* data);
461  virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
462 
469  vtkAlgorithmOutput* GetOutputPort(int index);
471 
475  int GetNumberOfInputConnections(int port);
476 
480  int GetTotalNumberOfInputConnections();
481 
485  vtkAlgorithmOutput* GetInputConnection(int port, int index);
486 
491  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
492 
496  vtkAlgorithm* GetInputAlgorithm(int port, int index);
497 
502 
507  vtkExecutive* GetInputExecutive(int port, int index);
508 
513 
522  vtkInformation* GetInputInformation(int port, int index);
523 
528 
536  vtkInformation* GetOutputInformation(int port);
537 
539 
542  virtual void Update(int port);
543  virtual void Update();
545 
568  virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
569 
575  virtual vtkTypeBool Update(vtkInformation* requests);
576 
583  virtual int UpdatePiece(
584  int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
585 
591  virtual int UpdateExtent(const int extents[6]);
592 
599  virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
600  const int extents[6] = nullptr);
601 
605  virtual void UpdateInformation();
606 
610  virtual void UpdateDataObject();
611 
615  virtual void PropagateUpdateExtent();
616 
620  virtual void UpdateWholeExtent();
621 
626  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
627 
628  //======================================================================
629  // The following block of code is to support old style VTK applications. If
630  // you are using these calls there are better ways to do it in the new
631  // pipeline
632  //======================================================================
633 
635 
638  virtual void SetReleaseDataFlag(int);
639  virtual int GetReleaseDataFlag();
640  void ReleaseDataFlagOn();
641  void ReleaseDataFlagOff();
643 
644  //========================================================================
645 
647 
653  int UpdateExtentIsEmpty(vtkInformation* pinfo, vtkDataObject* output);
654  int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
656 
661  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
662 
664 
669  int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
670  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
671  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
672  {
673  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
674  }
675  void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
676  void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
677  void GetUpdateExtent(int port, int extent[6]);
679 
681 
686  int GetUpdatePiece() { return this->GetUpdatePiece(0); }
687  int GetUpdatePiece(int port);
689  int GetUpdateNumberOfPieces(int port);
690  int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
691  int GetUpdateGhostLevel(int port);
693 
695 
704  void SetProgressObserver(vtkProgressObserver*);
705  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
707 
708 protected:
709  vtkAlgorithm();
710  ~vtkAlgorithm() override;
711 
712  // Keys used to indicate that input/output port information has been
713  // filled.
714  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
715 
716  // Arbitrary extra information associated with this algorithm
718 
724  virtual int FillInputPortInformation(int port, vtkInformation* info);
725 
731  virtual int FillOutputPortInformation(int port, vtkInformation* info);
732 
736  virtual void SetNumberOfInputPorts(int n);
737 
741  virtual void SetNumberOfOutputPorts(int n);
742 
743  // Helper methods to check input/output port index ranges.
744  int InputPortIndexInRange(int index, const char* action);
745  int OutputPortIndexInRange(int index, const char* action);
746 
751  int GetInputArrayAssociation(int idx, vtkInformationVector** inputVector);
752 
754 
762  int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
763  int GetInputArrayAssociation(int idx, vtkDataObject* input);
765 
767 
771  vtkDataArray* GetInputArrayToProcess(int idx, vtkInformationVector** inputVector);
772  vtkDataArray* GetInputArrayToProcess(
773  int idx, vtkInformationVector** inputVector, int& association);
775 
777 
785  vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
786  vtkDataArray* GetInputArrayToProcess(
787  int idx, int connection, vtkInformationVector** inputVector, int& association);
788  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input);
789  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
791 
793 
797  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkInformationVector** inputVector);
798  vtkAbstractArray* GetInputAbstractArrayToProcess(
799  int idx, vtkInformationVector** inputVector, int& association);
801 
803 
811  vtkAbstractArray* GetInputAbstractArrayToProcess(
812  int idx, int connection, vtkInformationVector** inputVector);
813  vtkAbstractArray* GetInputAbstractArrayToProcess(
814  int idx, int connection, vtkInformationVector** inputVector, int& association);
815  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input);
816  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input, int& association);
818 
826  vtkInformation* GetInputArrayFieldInformation(int idx, vtkInformationVector** inputVector);
827 
834  virtual vtkExecutive* CreateDefaultExecutive();
835 
837 
841  vtkSetMacro(ErrorCode, unsigned long);
842  unsigned long ErrorCode;
844 
845  // Progress/Update handling
846  double Progress;
848 
849  // Garbage collection support.
850  void ReportReferences(vtkGarbageCollector*) override;
851 
852  // executive methods below
853 
860  virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
861 
868  virtual void SetNumberOfInputConnections(int port, int n);
869 
871 
879  {
880  this->SetInputDataObject(port, input);
881  }
883  {
884  this->AddInputDataObject(port, input);
885  }
886 
888 
889 private:
890  vtkExecutive* Executive;
891  vtkInformationVector* InputPortInformation;
892  vtkInformationVector* OutputPortInformation;
893  vtkAlgorithmInternals* AlgorithmInternal;
894  static void ConnectionAdd(
895  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
896  static void ConnectionRemove(
897  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
898  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
899  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
900 
901 private:
902  vtkAlgorithm(const vtkAlgorithm&) = delete;
903  void operator=(const vtkAlgorithm&) = delete;
904 
905  double ProgressShift;
906  double ProgressScale;
907 };
908 
909 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:470
abstract base class for most VTK objects
Definition: vtkObject.h:62
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:89
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:676
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:686
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:669
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:501
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:527
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:461
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:49
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:878
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:882
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:62
vtkInformation * Information
Definition: vtkAlgorithm.h:717
a simple class to control print indentation
Definition: vtkIndent.h:39
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:688
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
#define VTK_SIZEHINT(...)
Key for String vector values.
char * ProgressText
Definition: vtkAlgorithm.h:847
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:453
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file...
Definition: vtkAlgorithm.h:841
double Progress
Definition: vtkAlgorithm.h:846
create and manipulate ordered lists of objects
Definition: vtkCollection.h:55
int GetUpdateGhostLevel()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:690
bool UsesGarbageCollector() const override
Participate in garbage collection.
Definition: vtkAlgorithm.h:203
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:887
general representation of visualization data
Definition: vtkDataObject.h:65
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:265
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:512
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:671
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:870