1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkSource.h,v $
6 Date: $Date: 2002/12/26 18:24:22 $
7 Version: $Revision: 1.70 $
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 vtkSource - abstract class specifies interface for visualization network source
19 // .SECTION Description
20 // vtkSource is an abstract object that specifies behavior and interface
21 // of source objects. Source objects are objects that begin visualization
22 // pipeline. Sources include readers (read data from file or communications
23 // port) and procedural sources (generate data programmatically). vtkSource
24 // objects are also objects that generate output data. In this sense
25 // vtkSource is used as a superclass to vtkFilter.
27 // Concrete subclasses of vtkSource must define Update() and Execute()
28 // methods. The public method Update() invokes network execution and will
29 // bring the network up-to-date. The protected Execute() method actually
30 // does the work of data creation/generation. The difference between the two
31 // methods is that Update() implements input consistency checks and modified
32 // time comparisons and then invokes the Execute() which is an implementation
33 // of a particular algorithm.
35 // An important feature of subclasses of vtkSource is that it is possible
36 // to control the memory-management model (i.e., retain output versus delete
37 // output data). If enabled the ReleaseDataFlag enables the deletion of the
38 // output data once the downstream process object finishes processing the
39 // data (please see text).
42 // vtkProcessObject vtkDataSetReader vtkFilter vtkPolyDataSource
43 // vtkStructuredGridSource vtkStructuredPointsSource vtkUnstructuredGridSource
48 #include "vtkProcessObject.h"
53 class VTK_COMMON_EXPORT vtkSource : public vtkProcessObject
56 vtkTypeRevisionMacro(vtkSource,vtkProcessObject);
57 void PrintSelf(ostream& os, vtkIndent indent);
60 // Bring object up-to-date before execution. Update() checks modified
61 // time against last execution time, and re-executes object if necessary.
62 virtual void Update();
65 // Like update, but make sure the update extent is the whole extent in
67 virtual void UpdateWholeExtent();
70 // Updates any global information about the data
71 // (like spacing for images)
72 virtual void UpdateInformation();
75 virtual void PropagateUpdateExtent(vtkDataObject *output);
78 virtual void TriggerAsynchronousUpdate();
81 virtual void UpdateData(vtkDataObject *output);
84 // What is the input update extent that is required to produce the
85 // desired output? By default, the whole input is always required but
86 // this is overridden in many subclasses.
87 virtual void ComputeInputUpdateExtents( vtkDataObject *output );
90 // Turn on/off flag to control whether this object's data is released
91 // after being used by a source.
92 virtual void SetReleaseDataFlag(int);
93 virtual int GetReleaseDataFlag();
94 vtkBooleanMacro(ReleaseDataFlag,int);
97 // Handle the source/data loop.
98 virtual void UnRegister(vtkObjectBase *o);
101 // Test to see if this object is in a reference counting loop.
102 virtual int InRegisterLoop(vtkObject *);
105 // Return an array with all the inputs of this process object.
106 // This is useful for tracing back in the pipeline to construct
108 vtkDataObject **GetOutputs();
109 vtkGetMacro(NumberOfOutputs,int);
112 // Release/disconnect all outputs of this source. This is intended to be
113 // called prior to Delete() if the user is concerned about outputs holding
114 // on to the filter/source.
115 void UnRegisterAllOutputs(void);
118 // Return what index output the passed in output is, return -1 if it
119 // does not match any of the outputs
120 int GetOutputIndex(vtkDataObject *out);
123 // The reader should set this code at the end of the update.
124 // The error code contains a possible error that occured while
126 vtkGetMacro( ErrorCode, unsigned long );
133 // This method is the one that should be used by subclasses, right now the
134 // default implementation is to call the backwards compatibility method
135 virtual void ExecuteData(vtkDataObject *vtkNotUsed(output)) {
139 // This method is the old style execute method
140 virtual void Execute();
142 // By default, UpdateInformation calls this method to copy information
143 // unmodified from the input to the output.
144 virtual void ExecuteInformation();
146 // Called to allocate the input array. Copies old inputs.
147 void SetNumberOfOutputs(int num);
149 // method used internally for getting an output.
150 vtkDataObject *GetOutput(int idx);
152 // protected methods for setting inputs.
153 virtual void SetNthOutput(int num, vtkDataObject *output);
154 virtual void AddOutput(vtkDataObject *output);
155 virtual void RemoveOutput(vtkDataObject *output);
157 vtkDataObject **Outputs; // An Array of the outputs to the filter
160 // Time when ExecuteInformation was last called.
161 vtkTimeStamp InformationTime;
164 // The reader should set this code at the end of the update.
165 // The error code contains a possible error that occured while
167 vtkSetMacro( ErrorCode, unsigned long );
169 vtkSource(const vtkSource&); // Not implemented.
170 void operator=(const vtkSource&); // Not implemented.
172 unsigned long ErrorCode;