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 =========================================================================*/
32 #ifndef vtkAlgorithm_h
33 #define vtkAlgorithm_h
34 
35 #include "vtkCommonExecutionModelModule.h" // For export macro
36 #include "vtkObject.h"
37 
38 class vtkAbstractArray;
39 class vtkAlgorithmInternals;
40 class vtkAlgorithmOutput;
41 class vtkCollection;
42 class vtkDataArray;
43 class vtkDataObject;
44 class vtkExecutive;
45 class vtkInformation;
52 
53 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
54 {
55 public:
56  static vtkAlgorithm* New();
57  vtkTypeMacro(vtkAlgorithm, vtkObject);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
81  {
84  DEFAULT_PRECISION
85  };
86 
91  int HasExecutive();
92 
97  vtkExecutive* GetExecutive();
98 
104  virtual void SetExecutive(vtkExecutive* executive);
105 
129  virtual vtkTypeBool ProcessRequest(
130  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo);
131 
136  vtkTypeBool ProcessRequest(
137  vtkInformation* request, vtkCollection* inInfo, vtkInformationVector* outInfo);
138 
144  virtual int ComputePipelineMTime(vtkInformation* request, vtkInformationVector** inInfoVec,
145  vtkInformationVector* outInfoVec, int requestFromOutputPort, vtkMTimeType* mtime);
146 
154  virtual int ModifyRequest(vtkInformation* request, int when);
155 
162  vtkInformation* GetInputPortInformation(int port);
163 
170  vtkInformation* GetOutputPortInformation(int port);
171 
173 
176  vtkGetObjectMacro(Information, vtkInformation);
177  virtual void SetInformation(vtkInformation*);
179 
183  int GetNumberOfInputPorts();
184 
188  int GetNumberOfOutputPorts();
189 
191 
194  void Register(vtkObjectBase* o) override;
195  void UnRegister(vtkObjectBase* o) override;
197 
199 
203  vtkSetMacro(AbortExecute, vtkTypeBool);
204  vtkGetMacro(AbortExecute, vtkTypeBool);
205  vtkBooleanMacro(AbortExecute, vtkTypeBool);
207 
209 
212  vtkGetMacro(Progress, double);
214 
219  VTK_LEGACY(void SetProgress(double));
220 
226  void UpdateProgress(double amount);
227 
229 
241  void SetProgressShiftScale(double shift, double scale);
242  vtkGetMacro(ProgressShift, double);
243  vtkGetMacro(ProgressScale, double);
245 
247 
254  void SetProgressText(const char* ptext);
255  vtkGetStringMacro(ProgressText);
257 
259 
263  vtkGetMacro(ErrorCode, unsigned long);
265 
266  // left public for performance since it is used in inner loops
268 
273  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
277  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
281  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
285  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
289  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
293  static vtkInformationIntegerKey* INPUT_PORT();
297  static vtkInformationIntegerKey* INPUT_CONNECTION();
298 
307  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
308 
321  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
322 
324 
332  virtual void SetInputArrayToProcess(
333  int idx, int port, int connection, int fieldAssociation, const char* name);
334  virtual void SetInputArrayToProcess(
335  int idx, int port, int connection, int fieldAssociation, int fieldAttributeType);
336  virtual void SetInputArrayToProcess(int idx, vtkInformation* info);
338 
362  virtual void SetInputArrayToProcess(int idx, int port, int connection,
363  const char* fieldAssociation, const char* attributeTypeorName);
364 
368  vtkInformation* GetInputArrayInformation(int idx);
369 
370  // from here down are convenience methods that really are executive methods
371 
375  void RemoveAllInputs();
376 
381  vtkDataObject* GetOutputDataObject(int port);
382 
387  vtkDataObject* GetInputDataObject(int port, int connection);
388 
390 
403  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
404  virtual void SetInputConnection(vtkAlgorithmOutput* input);
406 
408 
417  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
418  virtual void AddInputConnection(vtkAlgorithmOutput* input);
420 
430  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
431 
435  virtual void RemoveInputConnection(int port, int idx);
436 
440  virtual void RemoveAllInputConnections(int port);
441 
450  virtual void SetInputDataObject(int port, vtkDataObject* data);
451  virtual void SetInputDataObject(vtkDataObject* data) { this->SetInputDataObject(0, data); }
452 
458  virtual void AddInputDataObject(int port, vtkDataObject* data);
459  virtual void AddInputDataObject(vtkDataObject* data) { this->AddInputDataObject(0, data); }
460 
467  vtkAlgorithmOutput* GetOutputPort(int index);
469 
473  int GetNumberOfInputConnections(int port);
474 
478  int GetTotalNumberOfInputConnections();
479 
483  vtkAlgorithmOutput* GetInputConnection(int port, int index);
484 
489  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
490 
494  vtkAlgorithm* GetInputAlgorithm(int port, int index);
495 
500 
505  vtkExecutive* GetInputExecutive(int port, int index);
506 
511 
520  vtkInformation* GetInputInformation(int port, int index);
521 
526 
534  vtkInformation* GetOutputInformation(int port);
535 
537 
540  virtual void Update(int port);
541  virtual void Update();
543 
566  virtual vtkTypeBool Update(int port, vtkInformationVector* requests);
567 
573  virtual vtkTypeBool Update(vtkInformation* requests);
574 
581  virtual int UpdatePiece(
582  int piece, int numPieces, int ghostLevels, const int extents[6] = nullptr);
583 
589  virtual int UpdateExtent(const int extents[6]);
590 
597  virtual int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
598  const int extents[6] = nullptr);
599 
603  virtual void UpdateInformation();
604 
608  virtual void UpdateDataObject();
609 
613  virtual void PropagateUpdateExtent();
614 
618  virtual void UpdateWholeExtent();
619 
624  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
625 
626  //======================================================================
627  // The following block of code is to support old style VTK applications. If
628  // you are using these calls there are better ways to do it in the new
629  // pipeline
630  //======================================================================
631 
633 
636  virtual void SetReleaseDataFlag(int);
637  virtual int GetReleaseDataFlag();
638  void ReleaseDataFlagOn();
639  void ReleaseDataFlagOff();
641 
642  //========================================================================
643 
645 
651  int UpdateExtentIsEmpty(vtkInformation* pinfo, vtkDataObject* output);
652  int UpdateExtentIsEmpty(vtkInformation* pinfo, int extentType);
654 
659  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
660 
662 
667  int* GetUpdateExtent() VTK_SIZEHINT(6) { return this->GetUpdateExtent(0); }
668  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
669  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1, int& z0, int& z1)
670  {
671  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
672  }
673  void GetUpdateExtent(int port, int& x0, int& x1, int& y0, int& y1, int& z0, int& z1);
674  void GetUpdateExtent(int extent[6]) { this->GetUpdateExtent(0, extent); }
675  void GetUpdateExtent(int port, int extent[6]);
677 
679 
684  int GetUpdatePiece() { return this->GetUpdatePiece(0); }
685  int GetUpdatePiece(int port);
687  int GetUpdateNumberOfPieces(int port);
688  int GetUpdateGhostLevel() { return this->GetUpdateGhostLevel(0); }
689  int GetUpdateGhostLevel(int port);
691 
693 
702  void SetProgressObserver(vtkProgressObserver*);
703  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
705 
706 protected:
707  vtkAlgorithm();
708  ~vtkAlgorithm() override;
709 
710  // Keys used to indicate that input/output port information has been
711  // filled.
712  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
713 
714  // Arbitrary extra information associated with this algorithm
716 
722  virtual int FillInputPortInformation(int port, vtkInformation* info);
723 
729  virtual int FillOutputPortInformation(int port, vtkInformation* info);
730 
734  virtual void SetNumberOfInputPorts(int n);
735 
739  virtual void SetNumberOfOutputPorts(int n);
740 
741  // Helper methods to check input/output port index ranges.
742  int InputPortIndexInRange(int index, const char* action);
743  int OutputPortIndexInRange(int index, const char* action);
744 
749  int GetInputArrayAssociation(int idx, vtkInformationVector** inputVector);
750 
752 
760  int GetInputArrayAssociation(int idx, int connection, vtkInformationVector** inputVector);
761  int GetInputArrayAssociation(int idx, vtkDataObject* input);
763 
765 
769  vtkDataArray* GetInputArrayToProcess(int idx, vtkInformationVector** inputVector);
770  vtkDataArray* GetInputArrayToProcess(
771  int idx, vtkInformationVector** inputVector, int& association);
773 
775 
783  vtkDataArray* GetInputArrayToProcess(int idx, int connection, vtkInformationVector** inputVector);
784  vtkDataArray* GetInputArrayToProcess(
785  int idx, int connection, vtkInformationVector** inputVector, int& association);
786  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input);
787  vtkDataArray* GetInputArrayToProcess(int idx, vtkDataObject* input, int& association);
789 
791 
795  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkInformationVector** inputVector);
796  vtkAbstractArray* GetInputAbstractArrayToProcess(
797  int idx, vtkInformationVector** inputVector, int& association);
799 
801 
809  vtkAbstractArray* GetInputAbstractArrayToProcess(
810  int idx, int connection, vtkInformationVector** inputVector);
811  vtkAbstractArray* GetInputAbstractArrayToProcess(
812  int idx, int connection, vtkInformationVector** inputVector, int& association);
813  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input);
814  vtkAbstractArray* GetInputAbstractArrayToProcess(int idx, vtkDataObject* input, int& association);
816 
824  vtkInformation* GetInputArrayFieldInformation(int idx, vtkInformationVector** inputVector);
825 
832  virtual vtkExecutive* CreateDefaultExecutive();
833 
835 
839  vtkSetMacro(ErrorCode, unsigned long);
840  unsigned long ErrorCode;
842 
843  // Progress/Update handling
844  double Progress;
846 
847  // Garbage collection support.
848  void ReportReferences(vtkGarbageCollector*) override;
849 
850  // executive methods below
851 
858  virtual void SetNthInputConnection(int port, int index, vtkAlgorithmOutput* input);
859 
866  virtual void SetNumberOfInputConnections(int port, int n);
867 
869 
877  {
878  this->SetInputDataObject(port, input);
879  }
881  {
882  this->AddInputDataObject(port, input);
883  }
884 
886 
887 private:
888  vtkExecutive* Executive;
889  vtkInformationVector* InputPortInformation;
890  vtkInformationVector* OutputPortInformation;
891  vtkAlgorithmInternals* AlgorithmInternal;
892  static void ConnectionAdd(
893  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
894  static void ConnectionRemove(
895  vtkAlgorithm* producer, int producerPort, vtkAlgorithm* consumer, int consumerPort);
896  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
897  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
898 
899 private:
900  vtkAlgorithm(const vtkAlgorithm&) = delete;
901  void operator=(const vtkAlgorithm&) = delete;
902 
903  double ProgressShift;
904  double ProgressScale;
905 };
906 
907 #endif
vtkAlgorithm::AbortExecute
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:263
vtkAlgorithm::Information
vtkInformation * Information
Definition: vtkAlgorithm.h:715
vtkInformationStringKey
Key for string values in vtkInformation.
Definition: vtkInformationStringKey.h:33
vtkAlgorithm::GetUpdateExtent
void GetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:674
vtkAlgorithm::DOUBLE_PRECISION
Definition: vtkAlgorithm.h:83
vtkX3D::scale
Definition: vtkX3D.h:235
vtkAlgorithm::GetOutputPort
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:468
vtkAlgorithm::AddInputDataObject
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:459
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:53
vtkAlgorithm::SetInputDataObject
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:451
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:688
vtkAlgorithm::ErrorCode
unsigned long ErrorCode
Definition: vtkAlgorithm.h:839
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkAlgorithm::GetUpdatePiece
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:684
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:876
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:669
vtkAlgorithm::ProgressObserver
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:885
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:686
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:63
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAlgorithm::GetUpdateExtent
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:667
vtkAlgorithm::ProgressText
char * ProgressText
Definition: vtkAlgorithm.h:845
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:844
vtkX3D::name
Definition: vtkX3D.h:225
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:94
vtkObject.h
vtkAlgorithm::SINGLE_PRECISION
Definition: vtkAlgorithm.h:82
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:75
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:64
vtkX3D::info
Definition: vtkX3D.h:382
vtkAlgorithm::GetInputInformation
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:525
vtkAlgorithm::GetInputAlgorithm
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:499
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:510
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:36
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkAlgorithm::DefaultExecutivePrototype
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:868
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:880
vtkAlgorithm::DesiredOutputPrecision
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:80
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:298