VTK  9.0.20200922
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 "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_0_0
46 #include "vtkObject.h"
47 
48 class vtkAbstractArray;
49 class vtkAlgorithmInternals;
50 class vtkAlgorithmOutput;
51 class vtkCollection;
52 class vtkDataArray;
53 class vtkDataObject;
54 class vtkExecutive;
55 class vtkInformation;
62 
63 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
64 {
65 public:
66  static vtkAlgorithm* New();
67  vtkTypeMacro(vtkAlgorithm, vtkObject);
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
91  {
94  DEFAULT_PRECISION
95  };
96 
101  int HasExecutive();
102 
107  vtkExecutive* GetExecutive();
108 
114  virtual void SetExecutive(vtkExecutive* executive);
115 
139  virtual vtkTypeBool ProcessRequest(
140  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
141 
146  vtkTypeBool ProcessRequest(
147  vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
148 
154  virtual int ComputePipelineMTime(vtkInformation* request, vtkInformationVector** inInfoVec,
155  vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
156 
164  virtual int ModifyRequest(vtkInformation* request, int when);
165 
172  vtkInformation* GetInputPortInformation(int port);
173 
180  vtkInformation* GetOutputPortInformation(int port);
181 
183 
186  vtkGetObjectMacro(Information, vtkInformation);
187  virtual void SetInformation(vtkInformation*);
189 
193  int GetNumberOfInputPorts();
194 
198  int GetNumberOfOutputPorts();
199 
201 
204  void Register(vtkObjectBase* o) override;
205  void UnRegister(vtkObjectBase* o) override;
207 
209 
213  vtkSetMacro(AbortExecute, vtkTypeBool);
214  vtkGetMacro(AbortExecute, vtkTypeBool);
215  vtkBooleanMacro(AbortExecute, vtkTypeBool);
217 
219 
222  vtkGetMacro(Progress, double);
224 
229  VTK_DEPRECATED_IN_9_0_0("Use vtkAlgorithm::UpdateProgress")
230  void SetProgress(double);
231 
237  void UpdateProgress(double amount);
238 
240 
252  void SetProgressShiftScale(double shift, double scale);
253  vtkGetMacro(ProgressShift, double);
254  vtkGetMacro(ProgressScale, double);
256 
258 
265  void SetProgressText(const char* ptext);
266  vtkGetStringMacro(ProgressText);
268 
270 
274  vtkGetMacro(ErrorCode, unsigned long);
276 
277  // left public for performance since it is used in inner loops
278  vtkTypeBool AbortExecute;
279 
284  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
288  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
292  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
296  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
300  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
304  static vtkInformationIntegerKey* INPUT_PORT();
308  static vtkInformationIntegerKey* INPUT_CONNECTION();
309 
318  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
319 
332  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
333 
335 
343  virtual void SetInputArrayToProcess(
344  int idx, int port, int connection, int fieldAssociation, const char* name);
345  virtual void SetInputArrayToProcess(
346  int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
347  virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
349 
373  virtual void SetInputArrayToProcess(int idx, int port, int connection,
374  const char* fieldAssociation, const char* attributeTypeorName);
375 
379  vtkInformation* GetInputArrayInformation(int idx);
380 
381  // from here down are convenience methods that really are executive methods
382 
386  void RemoveAllInputs();
387 
392  vtkDataObject* GetOutputDataObject(int port);
393 
398  vtkDataObject* GetInputDataObject(int port, int connection);
399 
401 
414  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
415  virtual void SetInputConnection(vtkAlgorithmOutput* input);
417 
419 
428  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
429  virtual void AddInputConnection(vtkAlgorithmOutput* input);
431 
441  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
442 
446  virtual void RemoveInputConnection(int port, int idx);
447 
451  virtual void RemoveAllInputConnections(int port);
452 
461  virtual void SetInputDataObject(int port, vtkDataObject* data);
462  virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
463 
469  virtual void AddInputDataObject(int port, vtkDataObject* data);
470  virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
471 
478  vtkAlgorithmOutput* GetOutputPort(int index);
480 
484  int GetNumberOfInputConnections(int port);
485 
489  int GetTotalNumberOfInputConnections();
490 
494  vtkAlgorithmOutput* GetInputConnection(int port, int index);
495 
500  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
501 
505  vtkAlgorithm* GetInputAlgorithm(int port, int index);
506 
511 
516  vtkExecutive* GetInputExecutive(int port, int index);
517 
522 
531  vtkInformation* GetInputInformation(int port, int index);
532 
537 
545  vtkInformation* GetOutputInformation(int port);
546 
548 
551  virtual void Update(int port);
552  virtual void Update();
554 
577  virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
578 
584  virtual vtkTypeBool Update(vtkInformation* requests);
585 
592  virtual int UpdatePiece(
593  int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
594 
600  virtual int UpdateExtent(const int extents[6]);
601 
608  virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
609  const int extents[6] = nullptr);
610 
614  virtual void UpdateInformation();
615 
619  virtual void UpdateDataObject();
620 
624  virtual void PropagateUpdateExtent();
625 
629  virtual void UpdateWholeExtent();
630 
635  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
636 
637  //======================================================================
638  // The following block of code is to support old style VTK applications. If
639  // you are using these calls there are better ways to do it in the new
640  // pipeline
641  //======================================================================
642 
644 
647  virtual void SetReleaseDataFlag(int);
648  virtual int GetReleaseDataFlag();
649  void ReleaseDataFlagOn();
650  void ReleaseDataFlagOff();
652 
653  //========================================================================
654 
656 
662  int UpdateExtentIsEmpty(vtkInformation* pinfo, vtkDataObject* output);
663  int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
665 
670  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
671 
673 
678  int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
679  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
680  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
681  {
682  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
683  }
684  void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
685  void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
686  void GetUpdateExtent(int port, int extent[6]);
688 
690 
695  int GetUpdatePiece() { return this->GetUpdatePiece(0); }
696  int GetUpdatePiece(int port);
698  int GetUpdateNumberOfPieces(int port);
699  int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
700  int GetUpdateGhostLevel(int port);
702 
704 
713  void SetProgressObserver(vtkProgressObserver*);
714  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
716 
717 protected:
718  vtkAlgorithm();
719  ~vtkAlgorithm() override;
720 
721  // Keys used to indicate that input/output port information has been
722  // filled.
723  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
724 
725  // Arbitrary extra information associated with this algorithm
727 
733  virtual int FillInputPortInformation(int port, vtkInformation* info);
734 
740  virtual int FillOutputPortInformation(int port, vtkInformation* info);
741 
745  virtual void SetNumberOfInputPorts(int n);
746 
750  virtual void SetNumberOfOutputPorts(int n);
751 
752  // Helper methods to check input/output port index ranges.
753  int InputPortIndexInRange(int index, const char* action);
754  int OutputPortIndexInRange(int index, const char* action);
755 
760  int GetInputArrayAssociation(int idx, vtkInformationVector** inputVector);
761 
763 
771  int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
772  int GetInputArrayAssociation(int idx, vtkDataObject* input);
774 
776 
780  vtkDataArray* GetInputArrayToProcess(int idx, vtkInformationVector** inputVector);
781  vtkDataArray* GetInputArrayToProcess(
782  int idx, vtkInformationVector** inputVector, int& association);
784 
786 
794  vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
795  vtkDataArray* GetInputArrayToProcess(
796  int idx, int connection, vtkInformationVector** inputVector, int& association);
797  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input);
798  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
800 
802 
806  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkInformationVector** inputVector);
807  vtkAbstractArray* GetInputAbstractArrayToProcess(
808  int idx, vtkInformationVector** inputVector, int& association);
810 
812 
820  vtkAbstractArray* GetInputAbstractArrayToProcess(
821  int idx, int connection, vtkInformationVector** inputVector);
822  vtkAbstractArray* GetInputAbstractArrayToProcess(
823  int idx, int connection, vtkInformationVector** inputVector, int& association);
824  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input);
825  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input, int& association);
827 
835  vtkInformation* GetInputArrayFieldInformation(int idx, vtkInformationVector** inputVector);
836 
843  virtual vtkExecutive* CreateDefaultExecutive();
844 
846 
850  vtkSetMacro(ErrorCode, unsigned long);
851  unsigned long ErrorCode;
853 
854  // Progress/Update handling
855  double Progress;
857 
858  // Garbage collection support.
859  void ReportReferences(vtkGarbageCollector*) override;
860 
861  // executive methods below
862 
869  virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
870 
877  virtual void SetNumberOfInputConnections(int port, int n);
878 
880 
888  {
889  this->SetInputDataObject(port, input);
890  }
892  {
893  this->AddInputDataObject(port, input);
894  }
895 
897 
898 private:
899  vtkExecutive* Executive;
900  vtkInformationVector* InputPortInformation;
901  vtkInformationVector* OutputPortInformation;
902  vtkAlgorithmInternals* AlgorithmInternal;
903  static void ConnectionAdd(
904  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
905  static void ConnectionRemove(
906  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
907  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
908  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
909 
910 private:
911  vtkAlgorithm(const vtkAlgorithm&) = delete;
912  void operator=(const vtkAlgorithm&) = delete;
913 
914  double ProgressShift;
915  double ProgressScale;
916 };
917 
918 #endif
vtkAlgorithm::Information
vtkInformation * Information
Definition: vtkAlgorithm.h:726
vtkInformationStringKey
Key for string values in vtkInformation.
Definition: vtkInformationStringKey.h:33
vtkAlgorithm::GetUpdateExtent
void GetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:685
vtkAlgorithm::DOUBLE_PRECISION
Definition: vtkAlgorithm.h:93
vtkX3D::scale
Definition: vtkX3D.h:235
vtkAlgorithm::GetOutputPort
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:479
vtkAlgorithm::AddInputDataObject
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:470
vtkObjectBase::Register
virtual void Register(vtkObjectBase *o)
Increase the reference count (mark as used by another object).
vtkAlgorithm
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:63
vtkAlgorithm::SetInputDataObject
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:462
vtkX3D::data
Definition: vtkX3D.h:321
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkObjectBase::ReportReferences
virtual void ReportReferences(vtkGarbageCollector *)
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkAlgorithm::GetUpdateGhostLevel
int GetUpdateGhostLevel()
Definition: vtkAlgorithm.h:699
vtkAlgorithm::ErrorCode
unsigned long ErrorCode
Definition: vtkAlgorithm.h:850
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkAlgorithm::GetUpdatePiece
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:695
vtkAlgorithm::SetInputDataInternal
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:887
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkX3D::time
Definition: vtkX3D.h:503
vtkAlgorithm::GetUpdateExtent
void GetUpdateExtent(int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
Definition: vtkAlgorithm.h:680
vtkAlgorithm::ProgressObserver
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:896
vtkX3D::port
Definition: vtkX3D.h:453
vtkExecutive
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:46
vtkCollection
create and manipulate ordered lists of objects
Definition: vtkCollection.h:52
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkAlgorithm::GetUpdateNumberOfPieces
int GetUpdateNumberOfPieces()
Definition: vtkAlgorithm.h:697
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:69
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
VTK_DEPRECATED_IN_9_0_0
#define VTK_DEPRECATED_IN_9_0_0(reason)
Definition: vtkDeprecation.h:83
vtkAlgorithm::GetUpdateExtent
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:678
vtkAlgorithm::ProgressText
char * ProgressText
Definition: vtkAlgorithm.h:856
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAlgorithm::Progress
double Progress
Definition: vtkAlgorithm.h:855
vtkX3D::name
Definition: vtkX3D.h:225
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:94
vtkObject.h
vtkAlgorithm::SINGLE_PRECISION
Definition: vtkAlgorithm.h:92
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkX3D::info
Definition: vtkX3D.h:382
vtkAlgorithm::GetInputInformation
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:536
vtkAlgorithm::GetInputAlgorithm
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:510
vtkDeprecation.h
vtkInformationStringVectorKey
Key for String vector values.
Definition: vtkInformationStringVectorKey.h:33
vtkAlgorithmOutput
Proxy object to connect input/output ports.
Definition: vtkAlgorithmOutput.h:36
vtkAlgorithm::GetInputExecutive
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:521
vtkInformationInformationVectorKey
Key for vtkInformation vectors.
Definition: vtkInformationInformationVectorKey.h:33
vtkX3D::extent
Definition: vtkX3D.h:351
vtkProgressObserver
Basic class to optionally replace vtkAlgorithm progress functionality.
Definition: vtkProgressObserver.h:39
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:59
vtkAlgorithm::DefaultExecutivePrototype
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:879
vtkX3D::index
Definition: vtkX3D.h:252
vtkObjectBase::UnRegister
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkAlgorithm::AddInputDataInternal
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:891
vtkAlgorithm::DesiredOutputPrecision
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:90
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285