VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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;
54 class vtkInformationInformationVectorKey;
55 class vtkInformationIntegerKey;
56 class vtkInformationStringKey;
57 class vtkInformationStringVectorKey;
58 class vtkInformationVector;
59 
60 class VTKCOMMONEXECUTIONMODEL_EXPORT vtkAlgorithm : public vtkObject
61 {
62 public:
63  static vtkAlgorithm *New();
64  vtkTypeMacro(vtkAlgorithm,vtkObject);
65  void PrintSelf(ostream& os, vtkIndent indent);
66 
68 
76  {
79  DEFAULT_PRECISION
80  };
82 
85  int HasExecutive();
86 
89  vtkExecutive* GetExecutive();
90 
94  virtual void SetExecutive(vtkExecutive* executive);
95 
97 
111  virtual int ProcessRequest(vtkInformation* request,
112  vtkInformationVector** inInfo,
113  vtkInformationVector* outInfo);
115 
117 
119  int ProcessRequest(vtkInformation* request,
120  vtkCollection* inInfo,
121  vtkInformationVector* outInfo);
123 
125 
128  virtual int
129  ComputePipelineMTime(vtkInformation* request,
130  vtkInformationVector** inInfoVec,
131  vtkInformationVector* outInfoVec,
132  int requestFromOutputPort,
133  unsigned long* mtime);
135 
141  virtual int ModifyRequest(vtkInformation* request, int when);
142 
147  vtkInformation* GetInputPortInformation(int port);
148 
153  vtkInformation* GetOutputPortInformation(int port);
154 
156 
157  vtkGetObjectMacro(Information, vtkInformation);
158  virtual void SetInformation(vtkInformation*);
160 
162  int GetNumberOfInputPorts();
163 
165  int GetNumberOfOutputPorts();
166 
168 
169  virtual void Register(vtkObjectBase* o);
170  virtual void UnRegister(vtkObjectBase* o);
172 
174 
176  vtkSetMacro(AbortExecute,int);
177  vtkGetMacro(AbortExecute,int);
178  vtkBooleanMacro(AbortExecute,int);
180 
182 
183  vtkSetClampMacro(Progress,double,0.0,1.0);
184  vtkGetMacro(Progress,double);
186 
190  void UpdateProgress(double amount);
191 
193 
198  void SetProgressText(const char* ptext);
199  vtkGetStringMacro(ProgressText);
201 
203 
205  vtkGetMacro( ErrorCode, unsigned long );
207 
208  // left public for performance since it is used in inner loops
209  int AbortExecute;
210 
212 
213  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
214  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
215  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
216  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
217  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
218  static vtkInformationIntegerKey* INPUT_PORT();
219  static vtkInformationIntegerKey* INPUT_CONNECTION();
221 
222 
224 
230  virtual void SetInputArrayToProcess(int idx, int port, int connection,
231  int fieldAssociation,
232  const char *name);
233  virtual void SetInputArrayToProcess(int idx, int port, int connection,
234  int fieldAssociation,
235  int fieldAttributeType);
236  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
238 
240 
254  virtual void SetInputArrayToProcess(int idx, int port, int connection,
255  const char* fieldAssociation,
256  const char* attributeTypeorName);
258 
260  vtkInformation *GetInputArrayInformation(int idx);
261 
262  // from here down are convenience methods that really are executive methods
263 
264 
265 
267  void RemoveAllInputs();
268 
271  vtkDataObject* GetOutputDataObject(int port);
272 
274 
276  vtkDataObject *GetInputDataObject(int port,
277  int connection);
279 
281 
290  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
291  virtual void SetInputConnection(vtkAlgorithmOutput* input);
293 
295 
300  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
301  virtual void AddInputConnection(vtkAlgorithmOutput* input);
303 
310  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
311 
313  virtual void RemoveInputConnection(int port, int idx);
314 
316  virtual void RemoveAllInputConnections(int port);
317 
319 
326  virtual void SetInputDataObject(int port, vtkDataObject* data);
327  virtual void SetInputDataObject(vtkDataObject* data)
328  { this->SetInputDataObject(0, data); }
330 
332 
335  virtual void AddInputDataObject(int port, vtkDataObject* data);
336  virtual void AddInputDataObject(vtkDataObject* data)
337  { this->AddInputDataObject(0, data); }
339 
341 
345  vtkAlgorithmOutput* GetOutputPort(int index);
347  return this->GetOutputPort(0); }
349 
351  int GetNumberOfInputConnections(int port);
352 
354  int GetTotalNumberOfInputConnections();
355 
357  vtkAlgorithmOutput* GetInputConnection(int port, int index);
358 
361  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
362 
364  vtkAlgorithm* GetInputAlgorithm(int port, int index);
365 
367 
369  {
370  return this->GetInputAlgorithm(0, 0);
371  }
373 
375  vtkExecutive* GetInputExecutive(int port, int index);
376 
378 
380  {
381  return this->GetInputExecutive(0, 0);
382  }
384 
391  vtkInformation* GetInputInformation(int port, int index);
392 
394 
395  vtkInformation* GetInputInformation()
396  {
397  return this->GetInputInformation(0, 0);
398  }
400 
405  vtkInformation* GetOutputInformation(int port);
406 
408 
409  virtual void Update(int port);
410  virtual void Update();
412 
413 
415  virtual void UpdateInformation();
416 
418  virtual void PropagateUpdateExtent();
419 
421  virtual void UpdateWholeExtent();
422 
425  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
426 
427  //======================================================================
428  //The following block of code is to support old style VTK applications. If
429  //you are using these calls there are better ways to do it in the new
430  //pipeline
431  //======================================================================
432 
434 
435  virtual void SetReleaseDataFlag(int);
436  virtual int GetReleaseDataFlag();
437  void ReleaseDataFlagOn();
438  void ReleaseDataFlagOff();
440 
441  //========================================================================
442 
444 
448  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
449  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
451 
454  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
455 
459  virtual double ComputePriority();
460 
462 
464  static vtkInformationIntegerKey* PRESERVES_DATASET();
465  static vtkInformationIntegerKey* PRESERVES_GEOMETRY();
466  static vtkInformationIntegerKey* PRESERVES_BOUNDS();
467  static vtkInformationIntegerKey* PRESERVES_TOPOLOGY();
468  static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES();
469  static vtkInformationIntegerKey* PRESERVES_RANGES();
470  static vtkInformationIntegerKey* MANAGES_METAINFORMATION();
472 
477  int SetUpdateExtentToWholeExtent(int port);
478 
482  int SetUpdateExtentToWholeExtent();
483 
485 
486  void SetUpdateExtent(int port,
487  int piece,int numPieces, int ghostLevel);
489 
491 
493  void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
494  {
495  this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
496  }
498 
500  void SetUpdateExtent(int port, int extent[6]);
501 
503 
504  void SetUpdateExtent(int extent[6])
505  {
506  this->SetUpdateExtent(0, extent);
507  }
509 
511 
514  {
515  return this->GetUpdateExtent(0);
516  }
517  int* GetUpdateExtent(int port);
518  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
519  int& z0, int& z1)
520  {
521  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
522  }
523  void GetUpdateExtent(int port,
524  int& x0, int& x1, int& y0, int& y1,
525  int& z0, int& z1);
526  void GetUpdateExtent(int extent[6])
527  {
528  this->GetUpdateExtent(0, extent);
529  }
530  void GetUpdateExtent(int port, int extent[6]);
532 
534 
537  {
538  return this->GetUpdatePiece(0);
539  }
540  int GetUpdatePiece(int port);
542  {
543  return this->GetUpdateNumberOfPieces(0);
544  }
545  int GetUpdateNumberOfPieces(int port);
547  {
548  return this->GetUpdateGhostLevel(0);
549  }
550  int GetUpdateGhostLevel(int port);
552 
553 protected:
554  vtkAlgorithm();
555  ~vtkAlgorithm();
556 
557  // Keys used to indicate that input/output port information has been
558  // filled.
559  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
560 
561  // Arbitrary extra information associated with this algorithm
562  vtkInformation* Information;
563 
567  virtual int FillInputPortInformation(int port, vtkInformation* info);
568 
572  virtual int FillOutputPortInformation(int port, vtkInformation* info);
573 
575  virtual void SetNumberOfInputPorts(int n);
576 
578  virtual void SetNumberOfOutputPorts(int n);
579 
580  // Helper methods to check input/output port index ranges.
581  int InputPortIndexInRange(int index, const char* action);
582  int OutputPortIndexInRange(int index, const char* action);
583 
587  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
588 
590 
596  int GetInputArrayAssociation(int idx, int connection,
597  vtkInformationVector **inputVector);
598  int GetInputArrayAssociation(int idx, vtkDataObject* input);
600 
601 
603 
605  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
606  vtkDataArray *GetInputArrayToProcess(int idx,
607  vtkInformationVector **inputVector,
608  int& association);
610 
612 
618  vtkDataArray *GetInputArrayToProcess(int idx,
619  int connection,
620  vtkInformationVector **inputVector);
621  vtkDataArray *GetInputArrayToProcess(int idx,
622  int connection,
623  vtkInformationVector **inputVector,
624  int& association);
625  vtkDataArray *GetInputArrayToProcess(int idx,
626  vtkDataObject* input);
627  vtkDataArray *GetInputArrayToProcess(int idx,
628  vtkDataObject* input,
629  int& association);
631 
632 
634 
636  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
637  vtkAbstractArray *GetInputAbstractArrayToProcess
638  (int idx, vtkInformationVector **inputVector, int& association);
640 
642 
648  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
649  int connection,
650  vtkInformationVector **inputVector);
651  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
652  int connection,
653  vtkInformationVector **inputVector,
654  int& association);
655  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
656  vtkDataObject* input);
657  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
658  vtkDataObject* input,
659  int& association);
661 
662 
663 
665 
670  vtkInformation *GetInputArrayFieldInformation(int idx,
671  vtkInformationVector **inputVector);
673 
674 
679  virtual vtkExecutive* CreateDefaultExecutive();
680 
682 
684  vtkSetMacro( ErrorCode, unsigned long );
685  unsigned long ErrorCode;
687 
688  // Progress/Update handling
689  double Progress;
691 
692  // Garbage collection support.
693  virtual void ReportReferences(vtkGarbageCollector*);
694 
695  // executive methods below
696 
698 
702  virtual void SetNthInputConnection(int port, int index,
703  vtkAlgorithmOutput* input);
705 
710  virtual void SetNumberOfInputConnections(int port, int n);
711 
713 
715 
719  void SetInputDataInternal(int port, vtkDataObject *input)
720  { this->SetInputDataObject(port, input); }
721  void AddInputDataInternal(int port, vtkDataObject *input)
722  { this->AddInputDataObject(port, input); }
724 
725 private:
726  vtkExecutive* Executive;
727  vtkInformationVector* InputPortInformation;
728  vtkInformationVector* OutputPortInformation;
729  vtkAlgorithmInternals* AlgorithmInternal;
730  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
731  vtkAlgorithm* consumer, int consumerPort);
732  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
733  vtkAlgorithm* consumer, int consumerPort);
734  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
735  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
736 
737 private:
738  vtkAlgorithm(const vtkAlgorithm&); // Not implemented.
739  void operator=(const vtkAlgorithm&); // Not implemented.
740 };
741 
742 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:346
void GetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:526
int GetUpdatePiece()
Definition: vtkAlgorithm.h:536
void SetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:504
int * GetUpdateExtent()
Definition: vtkAlgorithm.h:513
vtkAlgorithm * GetInputAlgorithm()
Definition: vtkAlgorithm.h:368
vtkInformation * GetInputInformation()
Definition: vtkAlgorithm.h:395
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:336
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:48
void SetInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:719
Proxy object to connect input/output ports.
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:721
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:60
vtkInformation * Information
Definition: vtkAlgorithm.h:562
int GetUpdateNumberOfPieces()
Definition: vtkAlgorithm.h:541
char * ProgressText
Definition: vtkAlgorithm.h:690
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:327
void SetUpdateExtent(int piece, int numPieces, int ghostLevel)
Definition: vtkAlgorithm.h:493
unsigned long ErrorCode
Definition: vtkAlgorithm.h:684
double Progress
Definition: vtkAlgorithm.h:689
int GetUpdateGhostLevel()
Definition: vtkAlgorithm.h:546
general representation of visualization data
Definition: vtkDataObject.h:64
vtkExecutive * GetInputExecutive()
Definition: vtkAlgorithm.h:379
void GetUpdateExtent(int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
Definition: vtkAlgorithm.h:518
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:712