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 
75  {
78  DEFAULT_PRECISION
79  };
80 
85  int HasExecutive();
86 
91  vtkExecutive* GetExecutive();
92 
98  virtual void SetExecutive(vtkExecutive* executive);
99 
123  virtual int ProcessRequest(vtkInformation* request,
124  vtkInformationVector** inInfo,
125  vtkInformationVector* outInfo);
126 
131  int ProcessRequest(vtkInformation* request,
132  vtkCollection* inInfo,
133  vtkInformationVector* outInfo);
134 
140  virtual int
141  ComputePipelineMTime(vtkInformation* request,
142  vtkInformationVector** inInfoVec,
143  vtkInformationVector* outInfoVec,
144  int requestFromOutputPort,
145  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  vtkSetClampMacro(Progress,double,0.0,1.0);
213  vtkGetMacro(Progress,double);
215 
221  void UpdateProgress(double amount);
222 
224 
231  void SetProgressText(const char* ptext);
232  vtkGetStringMacro(ProgressText);
234 
236 
240  vtkGetMacro( ErrorCode, unsigned long );
242 
243  // left public for performance since it is used in inner loops
245 
250  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
254  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
258  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
262  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
266  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
270  static vtkInformationIntegerKey* INPUT_PORT();
274  static vtkInformationIntegerKey* INPUT_CONNECTION();
275 
284  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
285 
298  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
299 
300 
302 
310  virtual void SetInputArrayToProcess(int idx, int port, int connection,
311  int fieldAssociation,
312  const char *name);
313  virtual void SetInputArrayToProcess(int idx, int port, int connection,
314  int fieldAssociation,
315  int fieldAttributeType);
316  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
318 
342  virtual void SetInputArrayToProcess(int idx, int port, int connection,
343  const char* fieldAssociation,
344  const char* attributeTypeorName);
345 
349  vtkInformation *GetInputArrayInformation(int idx);
350 
351  // from here down are convenience methods that really are executive methods
352 
353 
354 
358  void RemoveAllInputs();
359 
364  vtkDataObject* GetOutputDataObject(int port);
365 
370  vtkDataObject *GetInputDataObject(int port,
371  int connection);
372 
374 
387  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
388  virtual void SetInputConnection(vtkAlgorithmOutput* input);
390 
392 
401  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
402  virtual void AddInputConnection(vtkAlgorithmOutput* input);
404 
414  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
415 
419  virtual void RemoveInputConnection(int port, int idx);
420 
424  virtual void RemoveAllInputConnections(int port);
425 
434  virtual void SetInputDataObject(int port, vtkDataObject* data);
436  { this->SetInputDataObject(0, data); }
437 
443  virtual void AddInputDataObject(int port, vtkDataObject* data);
445  { this->AddInputDataObject(0, data); }
446 
453  vtkAlgorithmOutput* GetOutputPort(int index);
455  return this->GetOutputPort(0); }
456 
460  int GetNumberOfInputConnections(int port);
461 
465  int GetTotalNumberOfInputConnections();
466 
470  vtkAlgorithmOutput* GetInputConnection(int port, int index);
471 
476  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
477 
481  vtkAlgorithm* GetInputAlgorithm(int port, int index);
482 
487  {
488  return this->GetInputAlgorithm(0, 0);
489  }
490 
495  vtkExecutive* GetInputExecutive(int port, int index);
496 
501  {
502  return this->GetInputExecutive(0, 0);
503  }
504 
513  vtkInformation* GetInputInformation(int port, int index);
514 
519  {
520  return this->GetInputInformation(0, 0);
521  }
522 
530  vtkInformation* GetOutputInformation(int port);
531 
533 
536  virtual void Update(int port);
537  virtual void Update();
539 
562  virtual int Update(int port, vtkInformationVector* requests);
563 
569  virtual int Update(vtkInformation* requests);
570 
577  virtual int UpdatePiece(
578  int piece, int numPieces, int ghostLevels, const int extents[6]=nullptr);
579 
585  virtual int UpdateExtent(const int extents[6]);
586 
593  virtual int UpdateTimeStep(double time,
594  int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=nullptr);
595 
599  virtual void UpdateInformation();
600 
604  virtual void UpdateDataObject();
605 
609  virtual void PropagateUpdateExtent();
610 
614  virtual void UpdateWholeExtent();
615 
620  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
621 
622  //======================================================================
623  //The following block of code is to support old style VTK applications. If
624  //you are using these calls there are better ways to do it in the new
625  //pipeline
626  //======================================================================
627 
629 
632  virtual void SetReleaseDataFlag(int);
633  virtual int GetReleaseDataFlag();
634  void ReleaseDataFlagOn();
635  void ReleaseDataFlagOff();
637 
638  //========================================================================
639 
641 
647  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
648  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
650 
655  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
656 
658 
664  {
665  return this->GetUpdateExtent(0);
666  }
667  int* GetUpdateExtent(int port) VTK_SIZEHINT(6);
668  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
669  int& z0, int& z1)
670  {
671  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
672  }
673  void GetUpdateExtent(int port,
674  int& x0, int& x1, int& y0, int& y1,
675  int& z0, int& z1);
676  void GetUpdateExtent(int extent[6])
677  {
678  this->GetUpdateExtent(0, extent);
679  }
680  void GetUpdateExtent(int port, int extent[6]);
682 
684 
690  {
691  return this->GetUpdatePiece(0);
692  }
693  int GetUpdatePiece(int port);
695  {
696  return this->GetUpdateNumberOfPieces(0);
697  }
698  int GetUpdateNumberOfPieces(int port);
700  {
701  return this->GetUpdateGhostLevel(0);
702  }
703  int GetUpdateGhostLevel(int port);
705 
707 
716  void SetProgressObserver(vtkProgressObserver*);
717  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
719 
720 protected:
721  vtkAlgorithm();
722  ~vtkAlgorithm() override;
723 
724  // Keys used to indicate that input/output port information has been
725  // filled.
726  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
727 
728  // Arbitrary extra information associated with this algorithm
730 
736  virtual int FillInputPortInformation(int port, vtkInformation* info);
737 
743  virtual int FillOutputPortInformation(int port, vtkInformation* info);
744 
748  virtual void SetNumberOfInputPorts(int n);
749 
753  virtual void SetNumberOfOutputPorts(int n);
754 
755  // Helper methods to check input/output port index ranges.
756  int InputPortIndexInRange(int index, const char* action);
757  int OutputPortIndexInRange(int index, const char* action);
758 
763  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
764 
766 
774  int GetInputArrayAssociation(int idx, int connection,
775  vtkInformationVector **inputVector);
776  int GetInputArrayAssociation(int idx, vtkDataObject* input);
778 
779 
781 
785  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
786  vtkDataArray *GetInputArrayToProcess(int idx,
787  vtkInformationVector **inputVector,
788  int& association);
790 
792 
800  vtkDataArray *GetInputArrayToProcess(int idx,
801  int connection,
802  vtkInformationVector **inputVector);
803  vtkDataArray *GetInputArrayToProcess(int idx,
804  int connection,
805  vtkInformationVector **inputVector,
806  int& association);
807  vtkDataArray *GetInputArrayToProcess(int idx,
808  vtkDataObject* input);
809  vtkDataArray *GetInputArrayToProcess(int idx,
810  vtkDataObject* input,
811  int& association);
813 
814 
816 
820  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
821  vtkAbstractArray *GetInputAbstractArrayToProcess
822  (int idx, vtkInformationVector **inputVector, int& association);
824 
826 
834  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
835  int connection,
836  vtkInformationVector **inputVector);
837  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
838  int connection,
839  vtkInformationVector **inputVector,
840  int& association);
841  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
842  vtkDataObject* input);
843  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
844  vtkDataObject* input,
845  int& association);
847 
848 
849 
857  vtkInformation *GetInputArrayFieldInformation(int idx,
858  vtkInformationVector **inputVector);
859 
860 
867  virtual vtkExecutive* CreateDefaultExecutive();
868 
870 
874  vtkSetMacro( ErrorCode, unsigned long );
875  unsigned long ErrorCode;
877 
878  // Progress/Update handling
879  double Progress;
881 
882  // Garbage collection support.
883  void ReportReferences(vtkGarbageCollector*) override;
884 
885  // executive methods below
886 
893  virtual void SetNthInputConnection(int port, int index,
894  vtkAlgorithmOutput* input);
895 
902  virtual void SetNumberOfInputConnections(int port, int n);
903 
905 
913  { this->SetInputDataObject(port, input); }
915  { this->AddInputDataObject(port, input); }
916 
918 
919 private:
920  vtkExecutive* Executive;
921  vtkInformationVector* InputPortInformation;
922  vtkInformationVector* OutputPortInformation;
923  vtkAlgorithmInternals* AlgorithmInternal;
924  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
925  vtkAlgorithm* consumer, int consumerPort);
926  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
927  vtkAlgorithm* consumer, int consumerPort);
928  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
929  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
930 
931 private:
932  vtkAlgorithm(const vtkAlgorithm&) = delete;
933  void operator=(const vtkAlgorithm&) = delete;
934 };
935 
936 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:454
abstract base class for most VTK objects
Definition: vtkObject.h:53
DesiredOutputPrecision
Values used for setting the desired output precision for various algorithms.
Definition: vtkAlgorithm.h:74
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:676
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:689
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:663
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:486
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:518
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:444
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:912
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:914
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:53
vtkInformation * Information
Definition: vtkAlgorithm.h:729
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:694
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
#define VTK_SIZEHINT(...)
char * ProgressText
Definition: vtkAlgorithm.h:880
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:435
unsigned long ErrorCode
The error code contains a possible error that occurred while reading or writing the file.
Definition: vtkAlgorithm.h:874
double Progress
Definition: vtkAlgorithm.h:879
create and manipulate ordered lists of objects
Definition: vtkCollection.h:48
int GetUpdateGhostLevel()
These functions return the update extent for output ports that use piece extents.
Definition: vtkAlgorithm.h:699
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:917
general representation of visualization data
Definition: vtkDataObject.h:58
vtkTypeBool AbortExecute
Definition: vtkAlgorithm.h:240
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:500
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:668
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:904