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) VTK_OVERRIDE;
65 
80  {
83  DEFAULT_PRECISION
84  };
85 
90  int HasExecutive();
91 
96  vtkExecutive* GetExecutive();
97 
103  virtual void SetExecutive(vtkExecutive* executive);
104 
128  virtual int ProcessRequest(vtkInformation* request,
129  vtkInformationVector** inInfo,
130  vtkInformationVector* outInfo);
131 
136  int ProcessRequest(vtkInformation* request,
137  vtkCollection* inInfo,
138  vtkInformationVector* outInfo);
139 
145  virtual int
146  ComputePipelineMTime(vtkInformation* request,
147  vtkInformationVector** inInfoVec,
148  vtkInformationVector* outInfoVec,
149  int requestFromOutputPort,
150  vtkMTimeType* mtime);
151 
159  virtual int ModifyRequest(vtkInformation* request, int when);
160 
167  vtkInformation* GetInputPortInformation(int port);
168 
175  vtkInformation* GetOutputPortInformation(int port);
176 
178 
181  vtkGetObjectMacro(Information, vtkInformation);
182  virtual void SetInformation(vtkInformation*);
184 
188  int GetNumberOfInputPorts();
189 
193  int GetNumberOfOutputPorts();
194 
196 
199  void Register(vtkObjectBase* o) VTK_OVERRIDE;
200  void UnRegister(vtkObjectBase* o) VTK_OVERRIDE;
202 
204 
208  vtkSetMacro(AbortExecute,int);
209  vtkGetMacro(AbortExecute,int);
210  vtkBooleanMacro(AbortExecute,int);
212 
214 
217  vtkSetClampMacro(Progress,double,0.0,1.0);
218  vtkGetMacro(Progress,double);
220 
226  void UpdateProgress(double amount);
227 
229 
236  void SetProgressText(const char* ptext);
237  vtkGetStringMacro(ProgressText);
239 
241 
245  vtkGetMacro( ErrorCode, unsigned long );
247 
248  // left public for performance since it is used in inner loops
249  int AbortExecute;
250 
255  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
259  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
263  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
267  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
271  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
275  static vtkInformationIntegerKey* INPUT_PORT();
279  static vtkInformationIntegerKey* INPUT_CONNECTION();
280 
289  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
290 
303  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
304 
305 
307 
315  virtual void SetInputArrayToProcess(int idx, int port, int connection,
316  int fieldAssociation,
317  const char *name);
318  virtual void SetInputArrayToProcess(int idx, int port, int connection,
319  int fieldAssociation,
320  int fieldAttributeType);
321  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
323 
347  virtual void SetInputArrayToProcess(int idx, int port, int connection,
348  const char* fieldAssociation,
349  const char* attributeTypeorName);
350 
354  vtkInformation *GetInputArrayInformation(int idx);
355 
356  // from here down are convenience methods that really are executive methods
357 
358 
359 
363  void RemoveAllInputs();
364 
369  vtkDataObject* GetOutputDataObject(int port);
370 
375  vtkDataObject *GetInputDataObject(int port,
376  int connection);
377 
379 
392  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
393  virtual void SetInputConnection(vtkAlgorithmOutput* input);
395 
397 
406  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
407  virtual void AddInputConnection(vtkAlgorithmOutput* input);
409 
419  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
420 
424  virtual void RemoveInputConnection(int port, int idx);
425 
429  virtual void RemoveAllInputConnections(int port);
430 
439  virtual void SetInputDataObject(int port, vtkDataObject* data);
441  { this->SetInputDataObject(0, data); }
442 
448  virtual void AddInputDataObject(int port, vtkDataObject* data);
450  { this->AddInputDataObject(0, data); }
451 
458  vtkAlgorithmOutput* GetOutputPort(int index);
460  return this->GetOutputPort(0); }
461 
465  int GetNumberOfInputConnections(int port);
466 
470  int GetTotalNumberOfInputConnections();
471 
475  vtkAlgorithmOutput* GetInputConnection(int port, int index);
476 
481  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
482 
486  vtkAlgorithm* GetInputAlgorithm(int port, int index);
487 
492  {
493  return this->GetInputAlgorithm(0, 0);
494  }
495 
500  vtkExecutive* GetInputExecutive(int port, int index);
501 
506  {
507  return this->GetInputExecutive(0, 0);
508  }
509 
518  vtkInformation* GetInputInformation(int port, int index);
519 
524  {
525  return this->GetInputInformation(0, 0);
526  }
527 
535  vtkInformation* GetOutputInformation(int port);
536 
538 
541  virtual void Update(int port);
542  virtual void Update();
544 
567  virtual int Update(int port, vtkInformationVector* requests);
568 
574  virtual int Update(vtkInformation* requests);
575 
582  virtual int UpdatePiece(
583  int piece, int numPieces, int ghostLevels, const int extents[6]=0);
584 
590  virtual int UpdateExtent(const int extents[6]);
591 
598  virtual int UpdateTimeStep(double time,
599  int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0);
600 
604  virtual void UpdateInformation();
605 
609  virtual void UpdateDataObject();
610 
614  virtual void PropagateUpdateExtent();
615 
619  virtual void UpdateWholeExtent();
620 
625  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
626 
627  //======================================================================
628  //The following block of code is to support old style VTK applications. If
629  //you are using these calls there are better ways to do it in the new
630  //pipeline
631  //======================================================================
632 
634 
637  virtual void SetReleaseDataFlag(int);
638  virtual int GetReleaseDataFlag();
639  void ReleaseDataFlagOn();
640  void ReleaseDataFlagOff();
642 
643  //========================================================================
644 
646 
652  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
653  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
655 
660  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
661 
667  VTK_LEGACY(int SetUpdateExtentToWholeExtent(int port));
668 
674  VTK_LEGACY(int SetUpdateExtentToWholeExtent());
675 
679  VTK_LEGACY(void SetUpdateExtent(int port,
680  int piece,int numPieces, int ghostLevel));
681 
686  VTK_LEGACY(void SetUpdateExtent(
687  int piece,int numPieces, int ghostLevel));
688 
692  VTK_LEGACY(void SetUpdateExtent(int port, int extent[6]));
693 
697  VTK_LEGACY(void SetUpdateExtent(int extent[6]));
698 
700 
706  {
707  return this->GetUpdateExtent(0);
708  }
709  int* GetUpdateExtent(int port);
710  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
711  int& z0, int& z1)
712  {
713  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
714  }
715  void GetUpdateExtent(int port,
716  int& x0, int& x1, int& y0, int& y1,
717  int& z0, int& z1);
718  void GetUpdateExtent(int extent[6])
719  {
720  this->GetUpdateExtent(0, extent);
721  }
722  void GetUpdateExtent(int port, int extent[6]);
724 
726 
732  {
733  return this->GetUpdatePiece(0);
734  }
735  int GetUpdatePiece(int port);
737  {
738  return this->GetUpdateNumberOfPieces(0);
739  }
740  int GetUpdateNumberOfPieces(int port);
742  {
743  return this->GetUpdateGhostLevel(0);
744  }
745  int GetUpdateGhostLevel(int port);
747 
749 
758  void SetProgressObserver(vtkProgressObserver*);
759  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
761 
762 protected:
763  vtkAlgorithm();
764  ~vtkAlgorithm() VTK_OVERRIDE;
765 
766  // Keys used to indicate that input/output port information has been
767  // filled.
768  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
769 
770  // Arbitrary extra information associated with this algorithm
771  vtkInformation* Information;
772 
778  virtual int FillInputPortInformation(int port, vtkInformation* info);
779 
785  virtual int FillOutputPortInformation(int port, vtkInformation* info);
786 
790  virtual void SetNumberOfInputPorts(int n);
791 
795  virtual void SetNumberOfOutputPorts(int n);
796 
797  // Helper methods to check input/output port index ranges.
798  int InputPortIndexInRange(int index, const char* action);
799  int OutputPortIndexInRange(int index, const char* action);
800 
805  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
806 
808 
816  int GetInputArrayAssociation(int idx, int connection,
817  vtkInformationVector **inputVector);
818  int GetInputArrayAssociation(int idx, vtkDataObject* input);
820 
821 
823 
827  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
828  vtkDataArray *GetInputArrayToProcess(int idx,
829  vtkInformationVector **inputVector,
830  int& association);
832 
834 
842  vtkDataArray *GetInputArrayToProcess(int idx,
843  int connection,
844  vtkInformationVector **inputVector);
845  vtkDataArray *GetInputArrayToProcess(int idx,
846  int connection,
847  vtkInformationVector **inputVector,
848  int& association);
849  vtkDataArray *GetInputArrayToProcess(int idx,
850  vtkDataObject* input);
851  vtkDataArray *GetInputArrayToProcess(int idx,
852  vtkDataObject* input,
853  int& association);
855 
856 
858 
862  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
863  vtkAbstractArray *GetInputAbstractArrayToProcess
864  (int idx, vtkInformationVector **inputVector, int& association);
866 
868 
876  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
877  int connection,
878  vtkInformationVector **inputVector);
879  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
880  int connection,
881  vtkInformationVector **inputVector,
882  int& association);
883  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
884  vtkDataObject* input);
885  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
886  vtkDataObject* input,
887  int& association);
889 
890 
891 
899  vtkInformation *GetInputArrayFieldInformation(int idx,
900  vtkInformationVector **inputVector);
901 
902 
909  virtual vtkExecutive* CreateDefaultExecutive();
910 
912 
916  vtkSetMacro( ErrorCode, unsigned long );
917  unsigned long ErrorCode;
919 
920  // Progress/Update handling
921  double Progress;
922  char *ProgressText;
923 
924  // Garbage collection support.
925  void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;
926 
927  // executive methods below
928 
935  virtual void SetNthInputConnection(int port, int index,
936  vtkAlgorithmOutput* input);
937 
944  virtual void SetNumberOfInputConnections(int port, int n);
945 
946  static vtkExecutive* DefaultExecutivePrototype;
947 
954  void SetInputDataInternal(int port, vtkDataObject *input)
955  { this->SetInputDataObject(port, input); }
957  { this->AddInputDataObject(port, input); }
958 
960 
961 private:
962  vtkExecutive* Executive;
963  vtkInformationVector* InputPortInformation;
964  vtkInformationVector* OutputPortInformation;
965  vtkAlgorithmInternals* AlgorithmInternal;
966  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
967  vtkAlgorithm* consumer, int consumerPort);
968  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
969  vtkAlgorithm* consumer, int consumerPort);
970  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
971  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
972 
973 private:
974  vtkAlgorithm(const vtkAlgorithm&) VTK_DELETE_FUNCTION;
975  void operator=(const vtkAlgorithm&) VTK_DELETE_FUNCTION;
976 };
977 
978 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:459
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:79
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:718
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:731
Store vtkAlgorithm input/output information.
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:705
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:491
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:523
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:449
virtual void Update()
Updates the extensions string.
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:49
Key for string values in vtkInformation.
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
Detect and break reference loops.
Proxy object to connect input/output ports.
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:956
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:59
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
a simple class to control print indentation
Definition: vtkIndent.h:39
Key for integer values in vtkInformation.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:736
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
Key for String vector values.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:440
create and manipulate unsorted 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:741
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:959
general representation of visualization data
Definition: vtkDataObject.h:64
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:505
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:710
Basic class to optionally replace vtkAlgorithm progress functionality.