OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkProcessObject.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkProcessObject.h,v $
5   Language:  C++
6   Date:      $Date: 2003/01/06 20:36:14 $
7   Version:   $Revision: 1.34 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
17 =========================================================================*/
18 // .NAME vtkProcessObject - abstract class specifies interface for visualization filters
19 //
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).
26 //
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.
34 //
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.
39 //
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).  
45 //
46 // .SECTION See Also
47 // vtkDataObject vtkSource vtkFilter vtkMapper vtkWriter
48
49 #ifndef __vtkProcessObject_h
50 #define __vtkProcessObject_h
51
52 #include "vtkObject.h"
53
54 class vtkDataObject;
55
56 class VTK_COMMON_EXPORT vtkProcessObject : public vtkObject
57 {
58 public:
59   vtkTypeRevisionMacro(vtkProcessObject,vtkObject);
60   void PrintSelf(ostream& os, vtkIndent indent);
61
62   // Description:
63   // Specify function to be called before object executes.
64   void SetStartMethod(void (*f)(void *), void *arg);
65
66   // Description:
67   // Specify function to be called to show progress of filter
68   void SetProgressMethod(void (*f)(void *), void *arg);
69
70   // Description:
71   // Specify function to be called after object executes.
72   void SetEndMethod(void (*f)(void *), void *arg);
73
74   // Description:
75   // Set the arg delete method. This is used to free user memory.
76   void SetStartMethodArgDelete(void (*f)(void *));
77
78   // Description:
79   // Set the arg delete method. This is used to free user memory.
80   void SetProgressMethodArgDelete(void (*f)(void *));
81
82   // Description:
83   // Set the arg delete method. This is used to free user memory.
84   void SetEndMethodArgDelete(void (*f)(void *));
85
86   // Description:
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);
92
93   // Description:
94   // Set/Get the execution progress of a process object.
95   vtkSetClampMacro(Progress,float,0.0f,1.0f);
96   vtkGetMacro(Progress,float);
97
98   // Description:
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);
103
104   // Description:
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);
109
110   // left public for performance since it is used in inner loops
111   int AbortExecute;
112
113   // Description:
114   // Return an array with all the inputs of this process object.
115   // This is useful for tracing back in the pipeline to construct
116   // graphs etc.
117   vtkDataObject **GetInputs() {return this->Inputs;}
118   vtkGetMacro(NumberOfInputs,int);
119
120   // Description:
121   // This method will rearrange the input array so that all NULL entries 
122   // are removed.
123   void SqueezeInputArray();
124   
125   // Description:
126   // Remove all the input data.
127   void RemoveAllInputs();
128
129 protected:
130   vtkProcessObject();
131   ~vtkProcessObject();
132
133   // Progress/Update handling
134   unsigned long StartTag;
135   unsigned long ProgressTag;
136   unsigned long EndTag;
137   float Progress;
138   char  *ProgressText;
139
140   int NumberOfInputs;
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);
154
155   // Called to allocate the input array.  Copies old inputs.
156   void SetNumberOfInputs(int num);
157
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);
162   
163 private:
164   vtkProcessObject(const vtkProcessObject&);  // Not implemented.
165   void operator=(const vtkProcessObject&);  // Not implemented.
166 };
167
168 #endif
169