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();
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 
217 
218  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
219  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
220  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
221  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
222  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
223  static vtkInformationIntegerKey* INPUT_PORT();
224  static vtkInformationIntegerKey* INPUT_CONNECTION();
226 
227 
229 
235  virtual void SetInputArrayToProcess(int idx, int port, int connection,
236  int fieldAssociation,
237  const char *name);
238  virtual void SetInputArrayToProcess(int idx, int port, int connection,
239  int fieldAssociation,
240  int fieldAttributeType);
241  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
243 
245 
259  virtual void SetInputArrayToProcess(int idx, int port, int connection,
260  const char* fieldAssociation,
261  const char* attributeTypeorName);
263 
265  vtkInformation *GetInputArrayInformation(int idx);
266 
267  // from here down are convenience methods that really are executive methods
268 
269 
270 
272  void RemoveAllInputs();
273 
276  vtkDataObject* GetOutputDataObject(int port);
277 
279 
281  vtkDataObject *GetInputDataObject(int port,
282  int connection);
284 
286 
295  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
296  virtual void SetInputConnection(vtkAlgorithmOutput* input);
298 
300 
305  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
306  virtual void AddInputConnection(vtkAlgorithmOutput* input);
308 
315  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
316 
318  virtual void RemoveInputConnection(int port, int idx);
319 
321  virtual void RemoveAllInputConnections(int port);
322 
324 
331  virtual void SetInputDataObject(int port, vtkDataObject* data);
333  { this->SetInputDataObject(0, data); }
335 
337 
340  virtual void AddInputDataObject(int port, vtkDataObject* data);
342  { this->AddInputDataObject(0, data); }
344 
346 
350  vtkAlgorithmOutput* GetOutputPort(int index);
352  return this->GetOutputPort(0); }
354 
356  int GetNumberOfInputConnections(int port);
357 
359  int GetTotalNumberOfInputConnections();
360 
362  vtkAlgorithmOutput* GetInputConnection(int port, int index);
363 
366  vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
367 
369  vtkAlgorithm* GetInputAlgorithm(int port, int index);
370 
372 
374  {
375  return this->GetInputAlgorithm(0, 0);
376  }
378 
380  vtkExecutive* GetInputExecutive(int port, int index);
381 
383 
385  {
386  return this->GetInputExecutive(0, 0);
387  }
389 
396  vtkInformation* GetInputInformation(int port, int index);
397 
399 
401  {
402  return this->GetInputInformation(0, 0);
403  }
405 
410  vtkInformation* GetOutputInformation(int port);
411 
413 
414  virtual void Update(int port);
415  virtual void Update();
417 
418 
420  virtual void UpdateInformation();
421 
423  virtual void PropagateUpdateExtent();
424 
426  virtual void UpdateWholeExtent();
427 
430  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
431 
432  //======================================================================
433  //The following block of code is to support old style VTK applications. If
434  //you are using these calls there are better ways to do it in the new
435  //pipeline
436  //======================================================================
437 
439 
440  virtual void SetReleaseDataFlag(int);
441  virtual int GetReleaseDataFlag();
442  void ReleaseDataFlagOn();
443  void ReleaseDataFlagOff();
445 
446  //========================================================================
447 
449 
453  int UpdateExtentIsEmpty(vtkInformation *pinfo, vtkDataObject *output);
454  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
456 
459  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
460 
464  virtual double ComputePriority();
465 
467 
469  static vtkInformationIntegerKey* PRESERVES_DATASET();
470  static vtkInformationIntegerKey* PRESERVES_GEOMETRY();
471  static vtkInformationIntegerKey* PRESERVES_BOUNDS();
472  static vtkInformationIntegerKey* PRESERVES_TOPOLOGY();
473  static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES();
474  static vtkInformationIntegerKey* PRESERVES_RANGES();
475  static vtkInformationIntegerKey* MANAGES_METAINFORMATION();
477 
482  int SetUpdateExtentToWholeExtent(int port);
483 
487  int SetUpdateExtentToWholeExtent();
488 
490 
491  void SetUpdateExtent(int port,
492  int piece,int numPieces, int ghostLevel);
494 
496 
498  void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
499  {
500  this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
501  }
503 
505  void SetUpdateExtent(int port, int extent[6]);
506 
508 
509  void SetUpdateExtent(int extent[6])
510  {
511  this->SetUpdateExtent(0, extent);
512  }
514 
516 
519  {
520  return this->GetUpdateExtent(0);
521  }
522  int* GetUpdateExtent(int port);
523  void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
524  int& z0, int& z1)
525  {
526  this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
527  }
528  void GetUpdateExtent(int port,
529  int& x0, int& x1, int& y0, int& y1,
530  int& z0, int& z1);
531  void GetUpdateExtent(int extent[6])
532  {
533  this->GetUpdateExtent(0, extent);
534  }
535  void GetUpdateExtent(int port, int extent[6]);
537 
539 
542  {
543  return this->GetUpdatePiece(0);
544  }
545  int GetUpdatePiece(int port);
547  {
548  return this->GetUpdateNumberOfPieces(0);
549  }
550  int GetUpdateNumberOfPieces(int port);
552  {
553  return this->GetUpdateGhostLevel(0);
554  }
555  int GetUpdateGhostLevel(int port);
557 
559 
565  void SetProgressObserver(vtkProgressObserver*);
566  vtkGetObjectMacro(ProgressObserver, vtkProgressObserver);
568 
569 protected:
570  vtkAlgorithm();
571  ~vtkAlgorithm();
572 
573  // Keys used to indicate that input/output port information has been
574  // filled.
575  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
576 
577  // Arbitrary extra information associated with this algorithm
579 
583  virtual int FillInputPortInformation(int port, vtkInformation* info);
584 
588  virtual int FillOutputPortInformation(int port, vtkInformation* info);
589 
591  virtual void SetNumberOfInputPorts(int n);
592 
594  virtual void SetNumberOfOutputPorts(int n);
595 
596  // Helper methods to check input/output port index ranges.
597  int InputPortIndexInRange(int index, const char* action);
598  int OutputPortIndexInRange(int index, const char* action);
599 
603  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
604 
606 
612  int GetInputArrayAssociation(int idx, int connection,
613  vtkInformationVector **inputVector);
614  int GetInputArrayAssociation(int idx, vtkDataObject* input);
616 
617 
619 
621  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
622  vtkDataArray *GetInputArrayToProcess(int idx,
623  vtkInformationVector **inputVector,
624  int& association);
626 
628 
634  vtkDataArray *GetInputArrayToProcess(int idx,
635  int connection,
636  vtkInformationVector **inputVector);
637  vtkDataArray *GetInputArrayToProcess(int idx,
638  int connection,
639  vtkInformationVector **inputVector,
640  int& association);
641  vtkDataArray *GetInputArrayToProcess(int idx,
643  vtkDataArray *GetInputArrayToProcess(int idx,
645  int& association);
647 
648 
650 
652  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
653  vtkAbstractArray *GetInputAbstractArrayToProcess
654  (int idx, vtkInformationVector **inputVector, int& association);
656 
658 
664  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
665  int connection,
666  vtkInformationVector **inputVector);
667  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
668  int connection,
669  vtkInformationVector **inputVector,
670  int& association);
671  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
673  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
675  int& association);
677 
678 
679 
681 
686  vtkInformation *GetInputArrayFieldInformation(int idx,
687  vtkInformationVector **inputVector);
689 
690 
695  virtual vtkExecutive* CreateDefaultExecutive();
696 
698 
700  vtkSetMacro( ErrorCode, unsigned long );
701  unsigned long ErrorCode;
703 
704  // Progress/Update handling
705  double Progress;
707 
708  // Garbage collection support.
709  virtual void ReportReferences(vtkGarbageCollector*);
710 
711  // executive methods below
712 
714 
718  virtual void SetNthInputConnection(int port, int index,
721 
726  virtual void SetNumberOfInputConnections(int port, int n);
727 
729 
731 
736  { this->SetInputDataObject(port, input); }
738  { this->AddInputDataObject(port, input); }
740 
742 
743 private:
744  vtkExecutive* Executive;
745  vtkInformationVector* InputPortInformation;
746  vtkInformationVector* OutputPortInformation;
747  vtkAlgorithmInternals* AlgorithmInternal;
748  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
749  vtkAlgorithm* consumer, int consumerPort);
750  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
751  vtkAlgorithm* consumer, int consumerPort);
752  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
753  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
754 
755 private:
756  vtkAlgorithm(const vtkAlgorithm&); // Not implemented.
757  void operator=(const vtkAlgorithm&); // Not implemented.
758 };
759 
760 #endif
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: vtkgl.h:11339
#define VTKCOMMONEXECUTIONMODEL_EXPORT
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:351
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual void Register(vtkObjectBase *o)
void GetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:531
GLuint index
Definition: vtkgl.h:11983
int GetUpdatePiece()
Definition: vtkAlgorithm.h:541
Store vtkAlgorithm input/output information.
void SetUpdateExtent(int extent[6])
Definition: vtkAlgorithm.h:509
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
int * GetUpdateExtent()
Definition: vtkAlgorithm.h:518
Abstract superclass for all arrays.
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
vtkAlgorithm * GetInputAlgorithm()
Definition: vtkAlgorithm.h:373
vtkInformation * GetInputInformation()
Definition: vtkAlgorithm.h:400
virtual void AddInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:341
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
virtual void Update()
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:48
void SetInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:735
Key for string values in vtkInformation.
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
Detect and break reference loops.
Proxy object to connect input/output ports.
void AddInputDataInternal(int port, vtkDataObject *input)
Definition: vtkAlgorithm.h:737
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:61
vtkInformation * Information
Definition: vtkAlgorithm.h:578
GLuint const GLchar * name
Definition: vtkgl.h:11983
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:546
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
abstract base class for most VTK objects
Definition: vtkObjectBase.h:58
#define vtkGetStringMacro(name)
Definition: vtkSetGet.h:120
Key for String vector values.
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
char * ProgressText
Definition: vtkAlgorithm.h:706
virtual void SetInputDataObject(vtkDataObject *data)
Definition: vtkAlgorithm.h:332
void SetUpdateExtent(int piece, int numPieces, int ghostLevel)
Definition: vtkAlgorithm.h:498
unsigned long ErrorCode
Definition: vtkAlgorithm.h:700
double Progress
Definition: vtkAlgorithm.h:705
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:52
int GetUpdateGhostLevel()
Definition: vtkAlgorithm.h:551
GLclampd n
Definition: vtkgl.h:14370
Store zero or more vtkInformation instances.
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
static vtkObject * New()
vtkProgressObserver * ProgressObserver
Definition: vtkAlgorithm.h:741
general representation of visualization data
Definition: vtkDataObject.h:64
vtkExecutive * GetInputExecutive()
Definition: vtkAlgorithm.h:384
void GetUpdateExtent(int &x0, int &x1, int &y0, int &y1, int &z0, int &z1)
Definition: vtkAlgorithm.h:523
Basic class to optionally replace vtkAlgorithm progress functionality.
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:728
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69