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();
371  static vtkInformationIntegerKey* MANAGES_METAINFORMATION();
373 
374 protected:
375  vtkAlgorithm();
376  ~vtkAlgorithm();
377 
378  // Keys used to indicate that input/output port information has been
379  // filled.
380  static vtkInformationIntegerKey* PORT_REQUIREMENTS_FILLED();
381 
382  // Arbitrary extra information associated with this algorithm
384 
388  virtual int FillInputPortInformation(int port, vtkInformation* info);
389 
393  virtual int FillOutputPortInformation(int port, vtkInformation* info);
394 
396  virtual void SetNumberOfInputPorts(int n);
397 
399  virtual void SetNumberOfOutputPorts(int n);
400 
401  // Helper methods to check input/output port index ranges.
402  int InputPortIndexInRange(int index, const char* action);
403  int OutputPortIndexInRange(int index, const char* action);
404 
408  int GetInputArrayAssociation(int idx, vtkInformationVector **inputVector);
409 
411 
417  int GetInputArrayAssociation(int idx, int connection,
418  vtkInformationVector **inputVector);
419  int GetInputArrayAssociation(int idx, vtkDataObject* input);
421 
422 
424 
426  vtkDataArray *GetInputArrayToProcess(int idx,vtkInformationVector **inputVector);
427  vtkDataArray *GetInputArrayToProcess(int idx,
428  vtkInformationVector **inputVector,
429  int& association);
431 
433 
439  vtkDataArray *GetInputArrayToProcess(int idx,
440  int connection,
441  vtkInformationVector **inputVector);
442  vtkDataArray *GetInputArrayToProcess(int idx,
443  int connection,
444  vtkInformationVector **inputVector,
445  int& association);
446  vtkDataArray *GetInputArrayToProcess(int idx,
447  vtkDataObject* input);
448  vtkDataArray *GetInputArrayToProcess(int idx,
449  vtkDataObject* input,
450  int& association);
452 
453 
455 
457  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,vtkInformationVector **inputVector);
458  vtkAbstractArray *GetInputAbstractArrayToProcess
459  (int idx, vtkInformationVector **inputVector, int& association);
461 
463 
469  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
470  int connection,
471  vtkInformationVector **inputVector);
472  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
473  int connection,
474  vtkInformationVector **inputVector,
475  int& association);
476  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
477  vtkDataObject* input);
478  vtkAbstractArray *GetInputAbstractArrayToProcess(int idx,
479  vtkDataObject* input,
480  int& association);
482 
483 
484 
486 
491  vtkInformation *GetInputArrayFieldInformation(int idx,
492  vtkInformationVector **inputVector);
494 
495 
500  virtual vtkExecutive* CreateDefaultExecutive();
501 
503 
505  vtkSetMacro( ErrorCode, unsigned long );
506  unsigned long ErrorCode;
508 
509  // Progress/Update handling
510  double Progress;
512 
513  // Garbage collection support.
514  virtual void ReportReferences(vtkGarbageCollector*);
515 
516  // executive methods below
517 
519 
523  virtual void SetNthInputConnection(int port, int index,
524  vtkAlgorithmOutput* input);
526 
531  virtual void SetNumberOfInputConnections(int port, int n);
532 
534 
535 private:
536  vtkExecutive* Executive;
537  vtkInformationVector* InputPortInformation;
538  vtkInformationVector* OutputPortInformation;
539  vtkAlgorithmInternals* AlgorithmInternal;
540  static void ConnectionAdd(vtkAlgorithm* producer, int producerPort,
541  vtkAlgorithm* consumer, int consumerPort);
542  static void ConnectionRemove(vtkAlgorithm* producer, int producerPort,
543  vtkAlgorithm* consumer, int consumerPort);
544  static void ConnectionRemoveAllInput(vtkAlgorithm* consumer, int port);
545  static void ConnectionRemoveAllOutput(vtkAlgorithm* producer, int port);
546 
547 private:
548  vtkAlgorithm(const vtkAlgorithm&); // Not implemented.
549  void operator=(const vtkAlgorithm&); // Not implemented.
550 };
551 
552 #endif