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 "vtkObject.h"
44 
45 class vtkAbstractArray;
46 class vtkAlgorithmInternals;
47 class vtkAlgorithmOutput;
48 class vtkCollection;
49 class vtkDataArray;
50 class vtkDataObject;
51 class vtkExecutive;
52 class vtkInformation;
58 
60 {
61 public:
62  static vtkAlgorithm *New();
63  vtkTypeMacro(vtkAlgorithm,vtkObject);
64  void PrintSelf(ostream& os, vtkIndent indent);
65 
68  int HasExecutive();
69 
72  vtkExecutive* GetExecutive();
73 
77  virtual void SetExecutive(vtkExecutive* executive);
78 
80 
94  virtual int ProcessRequest(vtkInformation* request,
95  vtkInformationVector** inInfo,
96  vtkInformationVector* outInfo);
98 
100 
102  int ProcessRequest(vtkInformation* request,
103  vtkCollection* inInfo,
104  vtkInformationVector* outInfo);
106 
108 
111  virtual int
112  ComputePipelineMTime(vtkInformation* request,
113  vtkInformationVector** inInfoVec,
114  vtkInformationVector* outInfoVec,
115  int requestFromOutputPort,
116  unsigned long* mtime);
118 
124  virtual int ModifyRequest(vtkInformation* request, int when);
125 
130  vtkInformation* GetInputPortInformation(int port);
131 
136  vtkInformation* GetOutputPortInformation(int port);
137 
139 
140  vtkGetObjectMacro(Information, vtkInformation);
141  virtual void SetInformation(vtkInformation*);
143 
145  int GetNumberOfInputPorts();
146 
148  int GetNumberOfOutputPorts();
149 
151 
152  virtual void Register(vtkObjectBase* o);
153  virtual void UnRegister(vtkObjectBase* o);
155 
157 
159  vtkSetMacro(AbortExecute,int);
160  vtkGetMacro(AbortExecute,int);
161  vtkBooleanMacro(AbortExecute,int);
163 
165 
166  vtkSetClampMacro(Progress,double,0.0,1.0);
167  vtkGetMacro(Progress,double);
169 
173  void UpdateProgress(double amount);
174 
176 
181  void SetProgressText(const char* ptext);
182  vtkGetStringMacro(ProgressText);
184 
186 
188  vtkGetMacro( ErrorCode, unsigned long );
190 
191  // left public for performance since it is used in inner loops
192  int AbortExecute;
193 
195 
196  static vtkInformationIntegerKey* INPUT_IS_OPTIONAL();
197  static vtkInformationIntegerKey* INPUT_IS_REPEATABLE();
198  static vtkInformationInformationVectorKey* INPUT_REQUIRED_FIELDS();
199  static vtkInformationStringVectorKey* INPUT_REQUIRED_DATA_TYPE();
200  static vtkInformationInformationVectorKey* INPUT_ARRAYS_TO_PROCESS();
201  static vtkInformationIntegerKey* INPUT_PORT();
202  static vtkInformationIntegerKey* INPUT_CONNECTION();
204 
205 
207 
213  virtual void SetInputArrayToProcess(int idx, int port, int connection,
214  int fieldAssociation,
215  const char *name);
216  virtual void SetInputArrayToProcess(int idx, int port, int connection,
217  int fieldAssociation,
218  int fieldAttributeType);
219  virtual void SetInputArrayToProcess(int idx, vtkInformation *info);
221 
223 
237  virtual void SetInputArrayToProcess(int idx, int port, int connection,
238  const char* fieldAssociation,
239  const char* attributeTypeorName);
241 
243  vtkInformation *GetInputArrayInformation(int idx);
244 
245  // from here down are convenience methods that really are executive methods
246 
247 
248 
250  void RemoveAllInputs();
251 
254  vtkDataObject* GetOutputDataObject(int port);
255 
257 
259  vtkDataObject *GetInputDataObject(int port,
260  int connection);
262 
264 
273  virtual void SetInputConnection(int port, vtkAlgorithmOutput* input);
274  virtual void SetInputConnection(vtkAlgorithmOutput* input);
276 
278 
283  virtual void AddInputConnection(int port, vtkAlgorithmOutput* input);
284  virtual void AddInputConnection(vtkAlgorithmOutput* input);
286 
293  virtual void RemoveInputConnection(int port, vtkAlgorithmOutput* input);
294 
296 
300  vtkAlgorithmOutput* GetOutputPort(int index);
302  return this->GetOutputPort(0); }
304 
306  int GetNumberOfInputConnections(int port);
307 
309  int GetTotalNumberOfInputConnections();
310 
312  vtkAlgorithmOutput* GetInputConnection(int port, int index);
313 
315  virtual void Update();
316 
319  virtual void UpdateInformation();
320 
322  virtual void UpdateWholeExtent();
323 
326  void ConvertTotalInputToPortConnection(int ind, int& port, int& conn);
327 
328  //======================================================================
329  //The following block of code is to support old style VTK applications. If
330  //you are using these calls there are better ways to do it in the new
331  //pipeline
332  //======================================================================
333 
335 
336  virtual void SetReleaseDataFlag(int);
337  virtual int GetReleaseDataFlag();
338  void ReleaseDataFlagOn();
339  void ReleaseDataFlagOff();
341 
342  //========================================================================
343 
345 
349  int UpdateExtentIsEmpty(vtkDataObject *output);
350  int UpdateExtentIsEmpty(vtkInformation *pinfo, int extentType);
352 
355  static void SetDefaultExecutivePrototype(vtkExecutive* proto);
356 
360  virtual double ComputePriority();
361 
363 
365  static vtkInformationIntegerKey* PRESERVES_DATASET();
366  static vtkInformationIntegerKey* PRESERVES_GEOMETRY();
367  static vtkInformationIntegerKey* PRESERVES_BOUNDS();
368  static vtkInformationIntegerKey* PRESERVES_TOPOLOGY();
369  static vtkInformationIntegerKey* PRESERVES_ATTRIBUTES();
370  static vtkInformationIntegerKey* PRESERVES_RANGES();
372 
373 protected:
374  vtkAlgorithm();
375  ~vtkAlgorithm();
376 
377  // Keys used to indicate that input/output port information has been
378  // filled.
379  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
380 
381  // Arbitrary extra information associated with this algorithm
383 
387  virtual int FillInputPortInformation(int port, vtkInformation* info);
388 
392  virtual int FillOutputPortInformation(int port, vtkInformation* info);
393 
395  virtual void SetNumberOfInputPorts(int n);
396 
398  virtual void SetNumberOfOutputPorts(int n);
399 
400  // Helper methods to check input/output port index ranges.
401  int InputPortIndexInRange(int index, const char* action);
402  int OutputPortIndexInRange(int index, const char* action);
403 
407  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
408 
410 
416  int GetInputArrayAssociation(int idx, int connection,
417  vtkInformationVector **inputVector);
418  int GetInputArrayAssociation(int idx, vtkDataObject* input);
420 
421 
423 
425  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
426  vtkDataArray *GetInputArrayToProcess(int idx,
427  vtkInformationVector **inputVector,
428  int& association);
430 
432 
438  vtkDataArray *GetInputArrayToProcess(int idx,
439  int connection,
440  vtkInformationVector **inputVector);
441  vtkDataArray *GetInputArrayToProcess(int idx,
442  int connection,
443  vtkInformationVector **inputVector,
444  int& association);
445  vtkDataArray *GetInputArrayToProcess(int idx,
446  vtkDataObject* input);
447  vtkDataArray *GetInputArrayToProcess(int idx,
448  vtkDataObject* input,
449  int& association);
451 
452 
454 
456  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
457  vtkAbstractArray *GetInputAbstractArrayToProcess
458  (int idx, vtkInformationVector **inputVector, int& association);
460 
462 
468  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
469  int connection,
470  vtkInformationVector **inputVector);
471  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
472  int connection,
473  vtkInformationVector **inputVector,
474  int& association);
475  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
476  vtkDataObject* input);
477  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
478  vtkDataObject* input,
479  int& association);
481 
482 
483 
485 
490  vtkInformation *GetInputArrayFieldInformation(int idx,
491  vtkInformationVector **inputVector);
493 
494 
499  virtual vtkExecutive* CreateDefaultExecutive();
500 
502 
504  vtkSetMacro( ErrorCode, unsigned long );
505  unsigned long ErrorCode;
507 
508  // Progress/Update handling
509  double Progress;
511 
512  // Garbage collection support.
513  virtual void ReportReferences(vtkGarbageCollector*);
514 
515  // executive methods below
516 
518 
522  virtual void SetNthInputConnection(int port, int index,
523  vtkAlgorithmOutput* input);
525 
530  virtual void SetNumberOfInputConnections(int port, int n);
531 
532  static vtkExecutive* DefaultExecutivePrototype;
533 
534 private:
535  vtkExecutive* Executive;
536  vtkInformationVector* InputPortInformation;
537  vtkInformationVector* OutputPortInformation;
538  vtkAlgorithmInternals* AlgorithmInternal;
539  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
540  vtkAlgorithm* consumer, int consumerPort);
541  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
542  vtkAlgorithm* consumer, int consumerPort);
543  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
544  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
545 
546 private:
547  vtkAlgorithm(const vtkAlgorithm&); // Not implemented.
548  void operator=(const vtkAlgorithm&); // Not implemented.
549 };
550 
551 #endif
vtkAlgorithmOutput * GetOutputPort()
Definition: vtkAlgorithm.h:301
abstract base class for most VTK objects
Definition: vtkObject.h:60
virtual void Register(vtkObjectBase *o)
Store vtkAlgorithm input/output information.
#define VTK_FILTERING_EXPORT
Abstract superclass for all arrays.
Key for string values in vtkInformation.
Detect and break reference loops.
Proxy object to connect input/output ports.
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:59
vtkInformation * Information
Definition: vtkAlgorithm.h:382
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual void ReportReferences(vtkGarbageCollector *)
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
Key for String vector values.
char * ProgressText
Definition: vtkAlgorithm.h:510
unsigned long ErrorCode
Definition: vtkAlgorithm.h:504
double Progress
Definition: vtkAlgorithm.h:509
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:51
Store zero or more vtkInformation instances.
static vtkObject * New()
helper class to get VTK data object types as string and instantiate them
static vtkExecutive * DefaultExecutivePrototype
Definition: vtkAlgorithm.h:532