vtk-dicom  0.8.17
vtkAlgorithm.h
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;
46 class vtkInformationInformationVectorKey;
47 class vtkInformationIntegerKey;
48 class vtkInformationStringKey;
49 class vtkInformationStringVectorKey;
50 class vtkInformationVector;
51 class vtkProgressObserver;
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  {
75  SINGLE_PRECISION,
76  DOUBLE_PRECISION,
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 
183 
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 
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);
434  virtual void SetInputDataObject(vtkDataObject* data)
435  { this->SetInputDataObject(0, data); }
436 
442  virtual void AddInputDataObject(int port, vtkDataObject* data);
443  virtual void AddInputDataObject(vtkDataObject* data)
444  { this->AddInputDataObject(0, data); }
445 
452  vtkAlgorithmOutput* GetOutputPort(int index);
453  vtkAlgorithmOutput* GetOutputPort() {
454  return this->GetOutputPort(0); }
455 
460 
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 
499  vtkExecutive* GetInputExecutive()
500  {
501  return this->GetInputExecutive(0, 0);
502  }
503 
512  vtkInformation* GetInputInformation(int port, int index);
513 
517  vtkInformation* GetInputInformation()
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);
730  int GetUpdateNumberOfPieces()
731  {
732  return this->GetUpdateNumberOfPieces(0);
733  }
734  int GetUpdateNumberOfPieces(int port);
735  int GetUpdateGhostLevel()
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); }
950  void AddInputDataInternal(int port, vtkDataObject *input)
951  { this->AddInputDataObject(port, input); }
952 
953  vtkProgressObserver* ProgressObserver;
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
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:54
virtual void UpdateDataObject()
void UpdateProgress(double amount)
vtkDataObject * GetInputDataObject(int port, int connection)
virtual void RemoveInputConnection(int port, vtkAlgorithmOutput *input)
void Register(vtkObjectBase *o) VTK_OVERRIDE
void SetUpdateExtent(int extent[6])
int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output)
int GetUpdatePiece()
Definition: vtkAlgorithm.h:725
vtkExecutive * GetInputExecutive()
Definition: vtkAlgorithm.h:499
int SetUpdateExtentToWholeExtent(int port)
static vtkInformationIntegerKey * INPUT_IS_OPTIONAL()
virtual void RemoveAllInputConnections(int port)
virtual int ComputePipelineMTime(vtkInformation *request, vtkInformationVector **inInfoVec, vtkInformationVector *outInfoVec, int requestFromOutputPort, vtkMTimeType *mtime)
void UnRegister(vtkObjectBase *o) VTK_OVERRIDE
vtkAlgorithmOutput * GetInputConnection(int port, int index)
vtkInformation * GetOutputPortInformation(int port)
virtual int Update(int port, vtkInformationVector *requests)
virtual void SetInputArrayToProcess(int idx, int port, int connection, const char *fieldAssociation, const char *attributeTypeorName)
int GetNumberOfOutputPorts()
virtual int ModifyRequest(vtkInformation *request, int when)
int GetNumberOfInputPorts()
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
vtkDataObject * GetOutputDataObject(int port)
vtkAlgorithm * GetInputAlgorithm(int port, int index)
vtkInformation * GetInputInformation()
Definition: vtkAlgorithm.h:517
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0)
virtual int UpdatePiece(int piece, int numPieces, int ghostLevels, const int extents[6]=0)
vtkAlgorithm * GetInputAlgorithm()
Definition: vtkAlgorithm.h:485
virtual void SetInputArrayToProcess(int idx, int port, int connection, int fieldAssociation, const char *name)
virtual void AddInputDataObject(int port, vtkDataObject *data)
vtkExecutive * GetInputExecutive(int port, int index)
static void SetDefaultExecutivePrototype(vtkExecutive *proto)
virtual int Update(vtkInformation *requests)
vtkExecutive * GetExecutive()
int SetUpdateExtentToWholeExtent()
void SetUpdateExtent(int port, int extent[6])
vtkAlgorithm * GetInputAlgorithm(int port, int index, int &algPort)
virtual int ProcessRequest(vtkInformation *request, vtkInformationVector **inInfo, vtkInformationVector *outInfo)
void SetProgressObserver(vtkProgressObserver *)
virtual void UpdateWholeExtent()
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
int GetTotalNumberOfInputConnections()
void ConvertTotalInputToPortConnection(int ind, int &port, int &conn)
virtual void SetExecutive(vtkExecutive *executive)
int GetNumberOfInputConnections(int port)
void SetProgressText(const char *ptext)
virtual void PropagateUpdateExtent()
virtual void Update(int port)
virtual int UpdateExtent(const int extents[6])
vtkInformation * GetInputPortInformation(int port)
DesiredOutputPrecision
Definition: vtkAlgorithm.h:74
virtual void SetReleaseDataFlag(int)
virtual void SetInputDataObject(int port, vtkDataObject *data)
vtkInformation * GetInputArrayInformation(int idx)
static vtkInformationIntegerKey * CAN_HANDLE_PIECE_REQUEST()
virtual void RemoveInputConnection(int port, int idx)
static vtkInformationIntegerKey * CAN_PRODUCE_SUB_EXTENT()
int ProcessRequest(vtkInformation *request, vtkCollection *inInfo, vtkInformationVector *outInfo)
int HasExecutive()
vtkAlgorithmOutput * GetOutputPort(int index)
int * GetUpdateExtent()
Definition: vtkAlgorithm.h:699
vtkInformation * GetOutputInformation(int port)
virtual void UpdateInformation()
vtkInformation * GetInputInformation(int port, int index)
virtual void AddInputConnection(int port, vtkAlgorithmOutput *input)
void RemoveAllInputs()
abstract base class for most VTK objects
Definition: vtkObjectBase.h:63
abstract base class for most VTK objects
Definition: vtkObject.h:54
static vtkObject * New()