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 =========================================================================*/
40 #ifndef vtkAlgorithm_h
41 #define vtkAlgorithm_h
42 
43 #include "vtkCommonExecutionModelModule.h" // For export macro
44 #include "vtkObject.h"
45 
46 class vtkAbstractArray;
47 class vtkAlgorithmInternals;
48 class vtkAlgorithmOutput;
49 class vtkCollection;
50 class vtkDataArray;
51 class vtkDataObject;
52 class vtkExecutive;
53 class vtkInformation;
60 
62 {
63 public:
64  static vtkAlgorithm *New();
65  vtkTypeMacro(vtkAlgorithm,vtkObject);
66  void PrintSelf(ostream& os, vtkIndent indent);
67 
69 
81  {
84  DEFAULT_PRECISION
85  };
87 
90  int HasExecutive();
91 
94  vtkExecutive* GetExecutive();
95 
99  virtual void SetExecutive(vtkExecutive* executive);
100 
102 
116  virtual int ProcessRequest(vtkInformation* request,
117  vtkInformationVector** inInfo,
118  vtkInformationVector* outInfo);
120 
122 
124  int ProcessRequest(vtkInformation* request,
125  vtkCollection* inInfo,
126  vtkInformationVector* outInfo);
128 
130 
133  virtual int
134  ComputePipelineMTime(vtkInformation* request,
135  vtkInformationVector** inInfoVec,
136  vtkInformationVector* outInfoVec,
137  int requestFromOutputPort,
138  unsigned long* mtime);
140 
146  virtual int ModifyRequest(vtkInformation* request, int when);
147 
152  vtkInformation* GetInputPortInformation(int port);
153 
158  vtkInformation* GetOutputPortInformation(int port);
159 
161 
162  vtkGetObjectMacro(Information, vtkInformation);
163  virtual void SetInformation(vtkInformation*);
165 
167  int GetNumberOfInputPorts();
168 
170  int GetNumberOfOutputPorts();
171 
173 
174  virtual void Register(vtkObjectBase* o);
175  virtual void UnRegister(vtkObjectBase* o);
177 
179 
181  vtkSetMacro(AbortExecute,int);
182  vtkGetMacro(AbortExecute,int);
183  vtkBooleanMacro(AbortExecute,int);
185 
187 
188  vtkSetClampMacro(Progress,double,0.0,1.0);
189  vtkGetMacro(Progress,double);
191 
195  void UpdateProgress(double amount);
196 
198 
203  void SetProgressText(const char* ptext);
204  vtkGetStringMacro(ProgressText);
206 
208 
210  vtkGetMacro( ErrorCode, unsigned long );
212 
213  // left public for performance since it is used in inner loops
214  int AbortExecute;
215 
218  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
220  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
222  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
224  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
226  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
228  static vtkInformationIntegerKey* INPUT_PORT();
230  static vtkInformationIntegerKey* INPUT_CONNECTION();
231 
237  static vtkInformationIntegerKey* CAN_PRODUCE_SUB_EXTENT();
238 
247  static vtkInformationIntegerKey* CAN_HANDLE_PIECE_REQUEST();
248 
249 
251 
257  virtual void SetInputArrayToProcess(int idx, int port, int connection,
258  int fieldAssociation,
259  const char *name);
260  virtual void SetInputArrayToProcess(int idx, int port, int connection,
261  int fieldAssociation,
262  int fieldAttributeType);
263  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
265 
267 
281  virtual void SetInputArrayToProcess(int idx, int port, int connection,
282  const char* fieldAssociation,
283  const char* attributeTypeorName);
285 
287  vtkInformation *GetInputArrayInformation(int idx);
288 
289  // from here down are convenience methods that really are executive methods
290 
291 
292 
294  void RemoveAllInputs();
295 
298  vtkDataObject* GetOutputDataObject(int port);
299 
301 
303  vtkDataObject *GetInputDataObject(int port,
304  int connection);
306 
308 
317  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
318  virtual void SetInputConnection(vtkAlgorithmOutput* input);
320 
322 
327  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
328  virtual void AddInputConnection(vtkAlgorithmOutput* input);
330 
337  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
338 
340  virtual void RemoveInputConnection(int port, int idx);
341 
343  virtual void RemoveAllInputConnections(int port);
344 
346 
353  virtual void SetInputDataObject(int port, vtkDataObject* data);
355  { this->SetInputDataObject(0, data); }
357 
359 
362  virtual void AddInputDataObject(int port, vtkDataObject* data);
364  { this->AddInputDataObject(0, data); }
366 
368 
372  vtkAlgorithmOutput* GetOutputPort(int index);
374  return this->GetOutputPort(0); }
376 
378  int GetNumberOfInputConnections(int port);
379 
381  int GetTotalNumberOfInputConnections();
382 
384  vtkAlgorithmOutput* GetInputConnection(int port, int index);
385 
388  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
389 
391  vtkAlgorithm* GetInputAlgorithm(int port, int index);
392 
394 
396  {
397  return this->GetInputAlgorithm(0, 0);
398  }
400 
402  vtkExecutive* GetInputExecutive(int port, int index);
403 
405 
407  {
408  return this->GetInputExecutive(0, 0);
409  }
411 
418  vtkInformation* GetInputInformation(int port, int index);
419 
421 
423  {
424  return this->GetInputInformation(0, 0);
425  }
427 
432  vtkInformation* GetOutputInformation(int port);
433 
435 
436  virtual void Update(int port);
437  virtual void Update();
439 
440 
442  virtual void UpdateInformation();
443 
445  virtual void UpdateDataObject();
446 
448  virtual void PropagateUpdateExtent();
449 
451  virtual void UpdateWholeExtent();
452 
455  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
456 
457  //======================================================================
458  //The following block of code is to support old style VTK applications. If
459  //you are using these calls there are better ways to do it in the new
460  //pipeline
461  //======================================================================
462 
464 
465  virtual void SetReleaseDataFlag(int);
466  virtual int GetReleaseDataFlag();
467  void ReleaseDataFlagOn();
468  void ReleaseDataFlagOff();
470 
471  //========================================================================
472 
474 
478  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
479  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
481 
484  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
485 
490  int SetUpdateExtentToWholeExtent(int port);
491 
495  int SetUpdateExtentToWholeExtent();
496 
498 
499  void SetUpdateExtent(int port,
500  int piece,int numPieces, int ghostLevel);
502 
504 
506  void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
507  {
508  this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
509  }
511 
513  void SetUpdateExtent(int port, int extent[6]);
514 
516 
517  void SetUpdateExtent(int extent[6])
518  {
519  this->SetUpdateExtent(0, extent);
520  }
522 
524 
527  {
528  return this->GetUpdateExtent(0);
529  }
530  int* GetUpdateExtent(int port);
531  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
532  int& z0, int& z1)
533  {
534  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
535  }
536  void GetUpdateExtent(int port,
537  int& x0, int& x1, int& y0, int& y1,
538  int& z0, int& z1);
539  void GetUpdateExtent(int extent[6])
540  {
541  this->GetUpdateExtent(0, extent);
542  }
543  void GetUpdateExtent(int port, int extent[6]);
545 
547 
550  {
551  return this->GetUpdatePiece(0);
552  }
553  int GetUpdatePiece(int port);
555  {
556  return this->GetUpdateNumberOfPieces(0);
557  }
558  int GetUpdateNumberOfPieces(int port);
560  {
561  return this->GetUpdateGhostLevel(0);
562  }
563  int GetUpdateGhostLevel(int port);
565 
567 
573  void SetProgressObserver(vtkProgressObserver*);
574  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
576 
577 protected:
578  vtkAlgorithm();
579  ~vtkAlgorithm();
580 
581  // Keys used to indicate that input/output port information has been
582  // filled.
583  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
584 
585  // Arbitrary extra information associated with this algorithm
587 
591  virtual int FillInputPortInformation(int port, vtkInformation* info);
592 
596  virtual int FillOutputPortInformation(int port, vtkInformation* info);
597 
599  virtual void SetNumberOfInputPorts(int n);
600 
602  virtual void SetNumberOfOutputPorts(int n);
603 
604  // Helper methods to check input/output port index ranges.
605  int InputPortIndexInRange(int index, const char* action);
606  int OutputPortIndexInRange(int index, const char* action);
607 
611  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
612 
614 
620  int GetInputArrayAssociation(int idx, int connection,
621  vtkInformationVector **inputVector);
622  int GetInputArrayAssociation(int idx, vtkDataObject* input);
624 
625 
627 
629  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
630  vtkDataArray *GetInputArrayToProcess(int idx,
631  vtkInformationVector **inputVector,
632  int& association);
634 
636 
642  vtkDataArray *GetInputArrayToProcess(int idx,
643  int connection,
644  vtkInformationVector **inputVector);
645  vtkDataArray *GetInputArrayToProcess(int idx,
646  int connection,
647  vtkInformationVector **inputVector,
648  int& association);
649  vtkDataArray *GetInputArrayToProcess(int idx,
650  vtkDataObject* input);
651  vtkDataArray *GetInputArrayToProcess(int idx,
652  vtkDataObject* input,
653  int& association);
655 
656 
658 
660  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
661  vtkAbstractArray *GetInputAbstractArrayToProcess
662  (int idx, vtkInformationVector **inputVector, int& association);
664 
666 
672  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
673  int connection,
674  vtkInformationVector **inputVector);
675  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
676  int connection,
677  vtkInformationVector **inputVector,
678  int& association);
679  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
680  vtkDataObject* input);
681  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
682  vtkDataObject* input,
683  int& association);
685 
686 
687 
689 
694  vtkInformation *GetInputArrayFieldInformation(int idx,
695  vtkInformationVector **inputVector);
697 
698 
703  virtual vtkExecutive* CreateDefaultExecutive();
704 
706 
708  vtkSetMacro( ErrorCode, unsigned long );
709  unsigned long ErrorCode;
711 
712  // Progress/Update handling
713  double Progress;
715 
716  // Garbage collection support.
717  virtual void ReportReferences(vtkGarbageCollector*);
718 
719  // executive methods below
720 
722 
726  virtual void SetNthInputConnection(int port, int index,
727  vtkAlgorithmOutput* input);
729 
734  virtual void SetNumberOfInputConnections(int port, int n);
735 
737 
739 
744  { this->SetInputDataObject(port, input); }
746  { this->AddInputDataObject(port, input); }
748 
750 
751 private:
752  vtkExecutive* Executive;
753  vtkInformationVector* InputPortInformation;
754  vtkInformationVector* OutputPortInformation;
755  vtkAlgorithmInternals* AlgorithmInternal;
756  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
757  vtkAlgorithm* consumer, int consumerPort);
758  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
759  vtkAlgorithm* consumer, int consumerPort);
760  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
761  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
762 
763 private:
764  vtkAlgorithm(const vtkAlgorithm&); // Not implemented.
765  void operator=(const vtkAlgorithm&); // Not implemented.
766 };
767 
768 #endif
#define VTKCOMMONEXECUTIONMODEL_EXPORT
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:373
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual void Register(vtkObjectBase *o)
void GetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:539
int GetUpdatePiece()
Definition: vtkAlgorithm.h:549
Store vtkAlgorithm input/output information.
void SetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:517
int * GetUpdateExtent()
Definition: vtkAlgorithm.h:526
Abstract superclass for all arrays.
vtkAlgorithm * GetInputAlgorithm()
Definition: vtkAlgorithm.h:395
vtkInformation * GetInputInformation()
Definition: vtkAlgorithm.h:422
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:363
virtual void Update()
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:51
void SetInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:743
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:745
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:61
vtkInformation * Information
Definition: vtkAlgorithm.h:586
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void ReportReferences(vtkGarbageCollector *)
Key for integer values in vtkInformation.
int GetUpdateNumberOfPieces()
Definition: vtkAlgorithm.h:554
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
Key for String vector values.
char * ProgressText
Definition: vtkAlgorithm.h:714
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:354
void SetUpdateExtent(int piece, int numPieces, int ghostLevel)
Definition: vtkAlgorithm.h:506
unsigned long ErrorCode
Definition: vtkAlgorithm.h:708
double Progress
Definition: vtkAlgorithm.h:713
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:52
int GetUpdateGhostLevel()
Definition: vtkAlgorithm.h:559
Store zero or more vtkInformation instances.
static vtkObject * New()
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:749
general representation of visualization data
Definition: vtkDataObject.h:64
vtkExecutive * GetInputExecutive()
Definition: vtkAlgorithm.h:406
void GetUpdateExtent(int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
Definition: vtkAlgorithm.h:531
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:736