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 
44 class vtkAbstractArray;
45 class vtkAlgorithmInternals;
46 class vtkAlgorithmOutput;
47 class vtkCollection;
48 class vtkDataArray;
49 class vtkDataObject;
50 class vtkExecutive;
51 class vtkInformation;
58 
59 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
60 {
61 public:
62  static vtkAlgorithm *New();
63  vtkTypeMacro(vtkAlgorithm,vtkObject);
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
81  {
84  DEFAULT_PRECISION
85  };
86 
91  int HasExecutive();
92 
97  vtkExecutive* GetExecutive();
98 
104  virtual void SetExecutive(vtkExecutive* executive);
105 
129  virtual int ProcessRequest(vtkInformation* request,
130  vtkInformationVector** inInfo,
131  vtkInformationVector* outInfo);
132 
137  int ProcessRequest(vtkInformation* request,
138  vtkCollection* inInfo,
139  vtkInformationVector* outInfo);
140 
146  virtual int
147  ComputePipelineMTime(vtkInformation* request,
148  vtkInformationVector** inInfoVec,
149  vtkInformationVector* outInfoVec,
150  int requestFromOutputPort,
151  vtkMTimeType* mtime);
152 
160  virtual int ModifyRequest(vtkInformation* request, int when);
161 
168  vtkInformation* GetInputPortInformation(int port);
169 
176  vtkInformation* GetOutputPortInformation(int port);
177 
179 
182  vtkGetObjectMacro(Information, vtkInformation);
183  virtual void SetInformation(vtkInformation*);
185 
189  int GetNumberOfInputPorts();
190 
194  int GetNumberOfOutputPorts();
195 
197 
200  void Register(vtkObjectBase* o) override;
201  void UnRegister(vtkObjectBase* o) override;
203 
205 
209  vtkSetMacro(AbortExecute,vtkTypeBool);
210  vtkGetMacro(AbortExecute,vtkTypeBool);
211  vtkBooleanMacro(AbortExecute,vtkTypeBool);
213 
215 
218  vtkSetClampMacro(Progress,double,0.0,1.0);
219  vtkGetMacro(Progress,double);
221 
227  void UpdateProgress(double amount);
228 
230 
237  void SetProgressText(const char* ptext);
238  vtkGetStringMacro(ProgressText);
240 
242 
246  vtkGetMacro( ErrorCode, unsigned long );
248 
249  // left public for performance since it is used in inner loops
251 
256  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
260  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
264  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
268  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
272  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
276  static vtkInformationIntegerKey* INPUT_PORT();
280  static vtkInformationIntegerKey* INPUT_CONNECTION();
281 
290  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
291 
304  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
305 
306 
308 
316  virtual void SetInputArrayToProcess(int idx, int port, int connection,
317  int fieldAssociation,
318  const char *name);
319  virtual void SetInputArrayToProcess(int idx, int port, int connection,
320  int fieldAssociation,
321  int fieldAttributeType);
322  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
324 
348  virtual void SetInputArrayToProcess(int idx, int port, int connection,
349  const char* fieldAssociation,
350  const char* attributeTypeorName);
351 
355  vtkInformation *GetInputArrayInformation(int idx);
356 
357  // from here down are convenience methods that really are executive methods
358 
359 
360 
364  void RemoveAllInputs();
365 
370  vtkDataObject* GetOutputDataObject(int port);
371 
376  vtkDataObject *GetInputDataObject(int port,
377  int connection);
378 
380 
393  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
394  virtual void SetInputConnection(vtkAlgorithmOutput* input);
396 
398 
407  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
408  virtual void AddInputConnection(vtkAlgorithmOutput* input);
410 
420  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
421 
425  virtual void RemoveInputConnection(int port, int idx);
426 
430  virtual void RemoveAllInputConnections(int port);
431 
440  virtual void SetInputDataObject(int port, vtkDataObject* data);
442  { this->SetInputDataObject(0, data); }
443 
449  virtual void AddInputDataObject(int port, vtkDataObject* data);
450  virtual void AddInputDataObject(vtkDataObject* data)
451  { this->AddInputDataObject(0, data); }
452 
459  vtkAlgorithmOutput* GetOutputPort(int index);
461  return this->GetOutputPort(0); }
462 
466  int GetNumberOfInputConnections(int port);
467 
471  int GetTotalNumberOfInputConnections();
472 
476  vtkAlgorithmOutput* GetInputConnection(int port, int index);
477 
482  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
483 
487  vtkAlgorithm* GetInputAlgorithm(int port, int index);
488 
493  {
494  return this->GetInputAlgorithm(0, 0);
495  }
496 
501  vtkExecutive* GetInputExecutive(int port, int index);
502 
507  {
508  return this->GetInputExecutive(0, 0);
509  }
510 
519  vtkInformation* GetInputInformation(int port, int index);
520 
525  {
526  return this->GetInputInformation(0, 0);
527  }
528 
536  vtkInformation* GetOutputInformation(int port);
537 
539 
542  virtual void Update(int port);
543  virtual void Update();
545 
568  virtual int Update(int port, vtkInformationVector* requests);
569 
575  virtual int 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,
600  int piece=-1, int numPieces=1, int ghostLevels=0, 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 
670  {
671  return this->GetUpdateExtent(0);
672  }
673  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
674  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
675  int& z0, int& z1)
676  {
677  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
678  }
679  void GetUpdateExtent(int port,
680  int& x0, int& x1, int& y0, int& y1,
681  int& z0, int& z1);
682  void GetUpdateExtent(int extent[6])
683  {
684  this->GetUpdateExtent(0, extent);
685  }
686  void GetUpdateExtent(int port, int extent[6]);
688 
690 
696  {
697  return this->GetUpdatePiece(0);
698  }
699  int GetUpdatePiece(int port);
701  {
702  return this->GetUpdateNumberOfPieces(0);
703  }
704  int GetUpdateNumberOfPieces(int port);
706  {
707  return this->GetUpdateGhostLevel(0);
708  }
709  int GetUpdateGhostLevel(int port);
711 
713 
722  void SetProgressObserver(vtkProgressObserver*);
723  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
725 
726 protected:
727  vtkAlgorithm();
728  ~vtkAlgorithm() override;
729 
730  // Keys used to indicate that input/output port information has been
731  // filled.
732  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
733 
734  // Arbitrary extra information associated with this algorithm
736 
742  virtual int FillInputPortInformation(int port, vtkInformation* info);
743 
749  virtual int FillOutputPortInformation(int port, vtkInformation* info);
750 
754  virtual void SetNumberOfInputPorts(int n);
755 
759  virtual void SetNumberOfOutputPorts(int n);
760 
761  // Helper methods to check input/output port index ranges.
762  int InputPortIndexInRange(int index, const char* action);
763  int OutputPortIndexInRange(int index, const char* action);
764 
769  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
770 
772 
780  int GetInputArrayAssociation(int idx, int connection,
781  vtkInformationVector **inputVector);
782  int GetInputArrayAssociation(int idx, vtkDataObject* input);
784 
785 
787 
791  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
792  vtkDataArray *GetInputArrayToProcess(int idx,
793  vtkInformationVector **inputVector,
794  int& association);
796 
798 
806  vtkDataArray *GetInputArrayToProcess(int idx,
807  int connection,
808  vtkInformationVector **inputVector);
809  vtkDataArray *GetInputArrayToProcess(int idx,
810  int connection,
811  vtkInformationVector **inputVector,
812  int& association);
813  vtkDataArray *GetInputArrayToProcess(int idx,
814  vtkDataObject* input);
815  vtkDataArray *GetInputArrayToProcess(int idx,
816  vtkDataObject* input,
817  int& association);
819 
820 
822 
826  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
827  vtkAbstractArray *GetInputAbstractArrayToProcess
828  (int idx, vtkInformationVector **inputVector, int& association);
830 
832 
840  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
841  int connection,
842  vtkInformationVector **inputVector);
843  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
844  int connection,
845  vtkInformationVector **inputVector,
846  int& association);
847  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
848  vtkDataObject* input);
849  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
850  vtkDataObject* input,
851  int& association);
853 
854 
855 
863  vtkInformation *GetInputArrayFieldInformation(int idx,
864  vtkInformationVector **inputVector);
865 
866 
873  virtual vtkExecutive* CreateDefaultExecutive();
874 
876 
880  vtkSetMacro( ErrorCode, unsigned long );
881  unsigned long ErrorCode;
883 
884  // Progress/Update handling
885  double Progress;
887 
888  // Garbage collection support.
889  void ReportReferences(vtkGarbageCollector*) override;
890 
891  // executive methods below
892 
899  virtual void SetNthInputConnection(int port, int index,
900  vtkAlgorithmOutput* input);
901 
908  virtual void SetNumberOfInputConnections(int port, int n);
909 
911 
918  void SetInputDataInternal(int port, vtkDataObject *input)
919  { this->SetInputDataObject(port, input); }
920  void AddInputDataInternal(int port, vtkDataObject *input)
921  { this->AddInputDataObject(port, input); }
922 
924 
925 private:
926  vtkExecutive* Executive;
927  vtkInformationVector* InputPortInformation;
928  vtkInformationVector* OutputPortInformation;
929  vtkAlgorithmInternals* AlgorithmInternal;
930  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
931  vtkAlgorithm* consumer, int consumerPort);
932  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
933  vtkAlgorithm* consumer, int consumerPort);
934  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
935  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
936 
937 private:
938  vtkAlgorithm(const vtkAlgorithm&) = delete;
939  void operator=(const vtkAlgorithm&) = delete;
940 };
941 
942 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:460
abstract base class for most VTK objects
Definition: vtkObject.h:59
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:80
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:682
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:695
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
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:492
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:524
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:450
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:918
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:920
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:59
vtkInformation * Information
Definition: vtkAlgorithm.h:735
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
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:700
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
#define VTK_SIZEHINT(...)
Key for String vector values.
char * ProgressText
Definition: vtkAlgorithm.h:886
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:441
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file...
Definition: vtkAlgorithm.h:880
double Progress
Definition: vtkAlgorithm.h:885
create and manipulate ordered lists of objects
Definition: vtkCollection.h:51
int GetUpdateGhostLevel()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:705
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:923
general representation of visualization data
Definition: vtkDataObject.h:64
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:246
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:506
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:674
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:910