1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkProcessObject.h,v $
6 Date: $Date: 2003/01/06 20:36:14 $
7 Version: $Revision: 1.34 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkProcessObject - abstract class specifies interface for visualization filters
20 // .SECTION Description
21 // vtkProcessObject is an abstract object that specifies behavior and
22 // interface of visualization network process objects (sources, filters,
23 // mappers). Source objects are creators of visualization data; filters
24 // input, process, and output visualization data; and mappers transform data
25 // into another form (like rendering primitives or write data to a file).
27 // vtkProcessObject provides a mechanism for invoking the methods
28 // StartMethod() and EndMethod() before and after object execution (via
29 // Execute()). These are convenience methods you can use for any purpose
30 // (e.g., debugging info, highlighting/notifying user interface, etc.) These
31 // methods accept a single void* pointer that can be used to send data to the
32 // methods. It is also possible to specify a function to delete the argument
33 // via StartMethodArgDelete and EndMethodArgDelete.
35 // Another method, ProgressMethod() can be specified. Some filters invoke this
36 // method periodically during their execution. The use is similar to that of
37 // StartMethod() and EndMethod(). Filters may also check their AbortExecute
38 // flag to determine whether to prematurely end their execution.
40 // An important feature of subclasses of vtkProcessObject is that it is
41 // possible to control the memory-management model (i.e., retain output
42 // versus delete output data). If enabled the ReleaseDataFlag enables the
43 // deletion of the output data once the downstream process object finishes
44 // processing the data (please see text).
47 // vtkDataObject vtkSource vtkFilter vtkMapper vtkWriter
49 #ifndef __vtkProcessObject_h
50 #define __vtkProcessObject_h
52 #include "vtkObject.h"
56 class VTK_COMMON_EXPORT vtkProcessObject : public vtkObject
59 vtkTypeRevisionMacro(vtkProcessObject,vtkObject);
60 void PrintSelf(ostream& os, vtkIndent indent);
63 // Specify function to be called before object executes.
64 void SetStartMethod(void (*f)(void *), void *arg);
67 // Specify function to be called to show progress of filter
68 void SetProgressMethod(void (*f)(void *), void *arg);
71 // Specify function to be called after object executes.
72 void SetEndMethod(void (*f)(void *), void *arg);
75 // Set the arg delete method. This is used to free user memory.
76 void SetStartMethodArgDelete(void (*f)(void *));
79 // Set the arg delete method. This is used to free user memory.
80 void SetProgressMethodArgDelete(void (*f)(void *));
83 // Set the arg delete method. This is used to free user memory.
84 void SetEndMethodArgDelete(void (*f)(void *));
87 // Set/Get the AbortExecute flag for the process object. Process objects
88 // may handle premature termination of execution in different ways.
89 vtkSetMacro(AbortExecute,int);
90 vtkGetMacro(AbortExecute,int);
91 vtkBooleanMacro(AbortExecute,int);
94 // Set/Get the execution progress of a process object.
95 vtkSetClampMacro(Progress,float,0.0f,1.0f);
96 vtkGetMacro(Progress,float);
99 // Update the progress of the process object. If a ProgressMethod exists,
100 // executes it. Then set the Progress ivar to amount. The parameter amount
101 // should range between (0,1).
102 void UpdateProgress(float amount);
105 // Set the current text message associated with the progress state.
106 // This may be used by a calling process/GUI.
107 vtkSetStringMacro(ProgressText);
108 vtkGetStringMacro(ProgressText);
110 // left public for performance since it is used in inner loops
114 // Return an array with all the inputs of this process object.
115 // This is useful for tracing back in the pipeline to construct
117 vtkDataObject **GetInputs() {return this->Inputs;}
118 vtkGetMacro(NumberOfInputs,int);
121 // This method will rearrange the input array so that all NULL entries
123 void SqueezeInputArray();
126 // Remove all the input data.
127 void RemoveAllInputs();
133 // Progress/Update handling
134 unsigned long StartTag;
135 unsigned long ProgressTag;
136 unsigned long EndTag;
141 int NumberOfRequiredInputs;
142 vtkDataObject **Inputs; //An array of the inputs to the filter
143 // Temporary arrays used internally.
144 // It is only valid after SortInputsByLocality is called.
145 vtkDataObject **SortedInputs; // Inputs sorted by locality
146 // We need a second array for an effficeint search.
147 // This array is never valid.
148 vtkDataObject **SortedInputs2;
149 void SortInputsByLocality();
150 // A helper method for quicksort.
151 void SortMerge(vtkDataObject **a1, int l1,
152 vtkDataObject **a2, int l2,
153 vtkDataObject **results);
155 // Called to allocate the input array. Copies old inputs.
156 void SetNumberOfInputs(int num);
158 // protected methods for setting inputs.
159 virtual void SetNthInput(int num, vtkDataObject *input);
160 virtual void AddInput(vtkDataObject *input);
161 virtual void RemoveInput(vtkDataObject *input);
164 vtkProcessObject(const vtkProcessObject&); // Not implemented.
165 void operator=(const vtkProcessObject&); // Not implemented.