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) VTK_OVERRIDE;
59 
74  {
77  DEFAULT_PRECISION
78  };
79 
84  int HasExecutive();
85 
90  vtkExecutive* GetExecutive();
91 
97  virtual void SetExecutive(vtkExecutive* executive);
98 
122  virtual int ProcessRequest(vtkInformation* request,
123  vtkInformationVector** inInfo,
124  vtkInformationVector* outInfo);
125 
130  int ProcessRequest(vtkInformation* request,
131  vtkCollection* inInfo,
132  vtkInformationVector* outInfo);
133 
139  virtual int
140  ComputePipelineMTime(vtkInformation* request,
141  vtkInformationVector** inInfoVec,
142  vtkInformationVector* outInfoVec,
143  int requestFromOutputPort,
144  vtkMTimeType* mtime);
145 
153  virtual int ModifyRequest(vtkInformation* request, int when);
154 
161  vtkInformation* GetInputPortInformation(int port);
162 
169  vtkInformation* GetOutputPortInformation(int port);
170 
172 
175  vtkGetObjectMacro(Information, vtkInformation);
176  virtual void SetInformation(vtkInformation*);
178 
182  int GetNumberOfInputPorts();
183 
187  int GetNumberOfOutputPorts();
188 
190 
193  void Register(vtkObjectBase* o) VTK_OVERRIDE;
194  void UnRegister(vtkObjectBase* o) VTK_OVERRIDE;
196 
198 
202  vtkSetMacro(AbortExecute,int);
203  vtkGetMacro(AbortExecute,int);
204  vtkBooleanMacro(AbortExecute,int);
206 
208 
211  vtkSetClampMacro(Progress,double,0.0,1.0);
212  vtkGetMacro(Progress,double);
214 
220  void UpdateProgress(double amount);
221 
223 
230  void SetProgressText(const char* ptext);
231  vtkGetStringMacro(ProgressText);
233 
235 
239  vtkGetMacro( ErrorCode, unsigned long );
241 
242  // left public for performance since it is used in inner loops
243  int AbortExecute;
244 
249  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
253  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
257  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
261  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
265  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
269  static vtkInformationIntegerKey* INPUT_PORT();
273  static vtkInformationIntegerKey* INPUT_CONNECTION();
274 
283  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
284 
297  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
298 
299 
301 
309  virtual void SetInputArrayToProcess(int idx, int port, int connection,
310  int fieldAssociation,
311  const char *name);
312  virtual void SetInputArrayToProcess(int idx, int port, int connection,
313  int fieldAssociation,
314  int fieldAttributeType);
315  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
317 
341  virtual void SetInputArrayToProcess(int idx, int port, int connection,
342  const char* fieldAssociation,
343  const char* attributeTypeorName);
344 
348  vtkInformation *GetInputArrayInformation(int idx);
349 
350  // from here down are convenience methods that really are executive methods
351 
352 
353 
357  void RemoveAllInputs();
358 
363  vtkDataObject* GetOutputDataObject(int port);
364 
369  vtkDataObject *GetInputDataObject(int port,
370  int connection);
371 
373 
386  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
387  virtual void SetInputConnection(vtkAlgorithmOutput* input);
389 
391 
400  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
401  virtual void AddInputConnection(vtkAlgorithmOutput* input);
403 
413  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
414 
418  virtual void RemoveInputConnection(int port, int idx);
419 
423  virtual void RemoveAllInputConnections(int port);
424 
433  virtual void SetInputDataObject(int port, vtkDataObject* data);
435  { this->SetInputDataObject(0, data); }
436 
442  virtual void AddInputDataObject(int port, vtkDataObject* data);
444  { this->AddInputDataObject(0, data); }
445 
452  vtkAlgorithmOutput* GetOutputPort(int index);
454  return this->GetOutputPort(0); }
455 
459  int GetNumberOfInputConnections(int port);
460 
464  int GetTotalNumberOfInputConnections();
465 
469  vtkAlgorithmOutput* GetInputConnection(int port, int index);
470 
475  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
476 
480  vtkAlgorithm* GetInputAlgorithm(int port, int index);
481 
486  {
487  return this->GetInputAlgorithm(0, 0);
488  }
489 
494  vtkExecutive* GetInputExecutive(int port, int index);
495 
500  {
501  return this->GetInputExecutive(0, 0);
502  }
503 
512  vtkInformation* GetInputInformation(int port, int index);
513 
518  {
519  return this->GetInputInformation(0, 0);
520  }
521 
529  vtkInformation* GetOutputInformation(int port);
530 
532 
535  virtual void Update(int port);
536  virtual void Update();
538 
561  virtual int Update(int port, vtkInformationVector* requests);
562 
568  virtual int Update(vtkInformation* requests);
569 
576  virtual int UpdatePiece(
577  int piece, int numPieces, int ghostLevels, const int extents[6]=0);
578 
584  virtual int UpdateExtent(const int extents[6]);
585 
592  virtual int UpdateTimeStep(double time,
593  int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0);
594 
598  virtual void UpdateInformation();
599 
603  virtual void UpdateDataObject();
604 
608  virtual void PropagateUpdateExtent();
609 
613  virtual void UpdateWholeExtent();
614 
619  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
620 
621  //======================================================================
622  //The following block of code is to support old style VTK applications. If
623  //you are using these calls there are better ways to do it in the new
624  //pipeline
625  //======================================================================
626 
628 
631  virtual void SetReleaseDataFlag(int);
632  virtual int GetReleaseDataFlag();
633  void ReleaseDataFlagOn();
634  void ReleaseDataFlagOff();
636 
637  //========================================================================
638 
640 
646  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
647  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
649 
654  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
655 
661  VTK_LEGACY(int SetUpdateExtentToWholeExtent(int port));
662 
668  VTK_LEGACY(int SetUpdateExtentToWholeExtent());
669 
673  VTK_LEGACY(void SetUpdateExtent(int port,
674  int piece,int numPieces, int ghostLevel));
675 
680  VTK_LEGACY(void SetUpdateExtent(
681  int piece,int numPieces, int ghostLevel));
682 
686  VTK_LEGACY(void SetUpdateExtent(int port, int extent[6]));
687 
691  VTK_LEGACY(void SetUpdateExtent(int extent[6]));
692 
694 
700  {
701  return this->GetUpdateExtent(0);
702  }
703  int* GetUpdateExtent(int port);
704  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
705  int& z0, int& z1)
706  {
707  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
708  }
709  void GetUpdateExtent(int port,
710  int& x0, int& x1, int& y0, int& y1,
711  int& z0, int& z1);
712  void GetUpdateExtent(int extent[6])
713  {
714  this->GetUpdateExtent(0, extent);
715  }
716  void GetUpdateExtent(int port, int extent[6]);
718 
720 
726  {
727  return this->GetUpdatePiece(0);
728  }
729  int GetUpdatePiece(int port);
731  {
732  return this->GetUpdateNumberOfPieces(0);
733  }
734  int GetUpdateNumberOfPieces(int port);
736  {
737  return this->GetUpdateGhostLevel(0);
738  }
739  int GetUpdateGhostLevel(int port);
741 
743 
752  void SetProgressObserver(vtkProgressObserver*);
753  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
755 
756 protected:
757  vtkAlgorithm();
758  ~vtkAlgorithm() VTK_OVERRIDE;
759 
760  // Keys used to indicate that input/output port information has been
761  // filled.
762  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
763 
764  // Arbitrary extra information associated with this algorithm
765  vtkInformation* Information;
766 
772  virtual int FillInputPortInformation(int port, vtkInformation* info);
773 
779  virtual int FillOutputPortInformation(int port, vtkInformation* info);
780 
784  virtual void SetNumberOfInputPorts(int n);
785 
789  virtual void SetNumberOfOutputPorts(int n);
790 
791  // Helper methods to check input/output port index ranges.
792  int InputPortIndexInRange(int index, const char* action);
793  int OutputPortIndexInRange(int index, const char* action);
794 
799  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
800 
802 
810  int GetInputArrayAssociation(int idx, int connection,
811  vtkInformationVector **inputVector);
812  int GetInputArrayAssociation(int idx, vtkDataObject* input);
814 
815 
817 
821  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
822  vtkDataArray *GetInputArrayToProcess(int idx,
823  vtkInformationVector **inputVector,
824  int& association);
826 
828 
836  vtkDataArray *GetInputArrayToProcess(int idx,
837  int connection,
838  vtkInformationVector **inputVector);
839  vtkDataArray *GetInputArrayToProcess(int idx,
840  int connection,
841  vtkInformationVector **inputVector,
842  int& association);
843  vtkDataArray *GetInputArrayToProcess(int idx,
844  vtkDataObject* input);
845  vtkDataArray *GetInputArrayToProcess(int idx,
846  vtkDataObject* input,
847  int& association);
849 
850 
852 
856  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
857  vtkAbstractArray *GetInputAbstractArrayToProcess
858  (int idx, vtkInformationVector **inputVector, int& association);
860 
862 
870  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
871  int connection,
872  vtkInformationVector **inputVector);
873  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
874  int connection,
875  vtkInformationVector **inputVector,
876  int& association);
877  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
878  vtkDataObject* input);
879  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
880  vtkDataObject* input,
881  int& association);
883 
884 
885 
893  vtkInformation *GetInputArrayFieldInformation(int idx,
894  vtkInformationVector **inputVector);
895 
896 
903  virtual vtkExecutive* CreateDefaultExecutive();
904 
906 
910  vtkSetMacro( ErrorCode, unsigned long );
911  unsigned long ErrorCode;
913 
914  // Progress/Update handling
915  double Progress;
916  char *ProgressText;
917 
918  // Garbage collection support.
919  void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;
920 
921  // executive methods below
922 
929  virtual void SetNthInputConnection(int port, int index,
930  vtkAlgorithmOutput* input);
931 
938  virtual void SetNumberOfInputConnections(int port, int n);
939 
940  static vtkExecutive* DefaultExecutivePrototype;
941 
948  void SetInputDataInternal(int port, vtkDataObject *input)
949  { this->SetInputDataObject(port, input); }
951  { this->AddInputDataObject(port, input); }
952 
954 
955 private:
956  vtkExecutive* Executive;
957  vtkInformationVector* InputPortInformation;
958  vtkInformationVector* OutputPortInformation;
959  vtkAlgorithmInternals* AlgorithmInternal;
960  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
961  vtkAlgorithm* consumer, int consumerPort);
962  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
963  vtkAlgorithm* consumer, int consumerPort);
964  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
965  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
966 
967 private:
968  vtkAlgorithm(const vtkAlgorithm&) VTK_DELETE_FUNCTION;
969  void operator=(const vtkAlgorithm&) VTK_DELETE_FUNCTION;
970 };
971 
972 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:453
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:73
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:712
int GetUpdatePiece()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:725
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
int * GetUpdateExtent()
These functions return the update extent for output ports that use 3D extents.
Definition: vtkAlgorithm.h:699
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Equivalent to GetInputAlgorithm(0, 0).
Definition: vtkAlgorithm.h:485
vtkInformation * GetInputInformation()
Equivalent to GetInputInformation(0, 0)
Definition: vtkAlgorithm.h:517
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:443
virtual void Update()
Updates the extensions string.
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:46
Key for string values in vtkInformation.
Detect and break reference loops.
Proxy object to connect input/output ports.
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:950
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:53
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
a simple class to control print indentation
Definition: vtkIndent.h:33
Key for integer values in vtkInformation.
int GetUpdateNumberOfPieces()
These functions return the update extent for output ports that use piece extents. ...
Definition: vtkAlgorithm.h:730
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
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:434
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:735
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:953
general representation of visualization data
Definition: vtkDataObject.h:58
vtkExecutive * GetInputExecutive()
Equivalent to GetInputExecutive(0, 0)
Definition: vtkAlgorithm.h:499
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:704
Basic class to optionally replace vtkAlgorithm progress functionality.