File: vtkProgrammableSource.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (115 lines) | stat: -rw-r--r-- 4,294 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkProgrammableSource
 * @brief   generate source dataset via a user-specified function
 *
 * vtkProgrammableSource is a source object that is programmable by the
 * user. To use this object, you must specify a function that creates the
 * output.  It is possible to generate an output dataset of any (concrete)
 * type; it is up to the function to properly initialize and define the
 * output. Typically, you use one of the methods to get a concrete output
 * type (e.g., GetPolyDataOutput() or GetStructuredPointsOutput()), and
 * then manipulate the output in the user-specified function.
 *
 * Example use of this include writing a function to read a data file or
 * interface to another system. (You might want to do this in favor of
 * deriving a new class.) Another important use of this class is that it
 * allows users of interpreters (e.g., Java) the ability to write
 * source objects without having to recompile C++ code or generate new
 * libraries.
 * @sa
 * vtkProgrammableFilter vtkProgrammableAttributeDataFilter
 * vtkProgrammableDataObjectSource
 */

#ifndef vtkProgrammableSource_h
#define vtkProgrammableSource_h

#include "vtkDataObjectAlgorithm.h"
#include "vtkFiltersSourcesModule.h" // For export macro

VTK_ABI_NAMESPACE_BEGIN
class vtkGraph;
class vtkMolecule;
class vtkPolyData;
class vtkRectilinearGrid;
class vtkStructuredGrid;
class vtkStructuredPoints;
class vtkTable;
class vtkUnstructuredGrid;

class VTKFILTERSSOURCES_EXPORT vtkProgrammableSource : public vtkDataObjectAlgorithm
{
public:
  static vtkProgrammableSource* New();
  vtkTypeMacro(vtkProgrammableSource, vtkDataObjectAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  /**
   * Signature definition for programmable method callbacks. Methods passed
   * to SetExecuteMethod, SetExecuteMethodArgDelete or
   * SetRequestInformationMethod must conform to this signature.
   * The presence of this typedef is useful for reference and for external
   * analysis tools, but it cannot be used in the method signatures in these
   * header files themselves because it prevents the internal VTK wrapper
   * generators from wrapping these methods.
   */
  typedef void (*ProgrammableMethodCallbackType)(void* arg);

  /**
   * Specify the function to use to generate the source data. Note
   * that the function takes a single (void *) argument.
   */
  void SetExecuteMethod(void (*f)(void*), void* arg);

  /**
   * Set the arg delete method. This is used to free user memory.
   */
  void SetExecuteMethodArgDelete(void (*f)(void*));

  /**
   * Specify the function to use to fill in information about the source data.
   */
  void SetRequestInformationMethod(void (*f)(void*));

  ///@{
  /**
   * Get the output as a concrete type. This method is typically used by the
   * writer of the source function to get the output as a particular type
   * (i.e., it essentially does type casting). It is the users responsibility
   * to know the correct type of the output data.
   */
  vtkPolyData* GetPolyDataOutput();
  vtkStructuredPoints* GetStructuredPointsOutput();
  vtkStructuredGrid* GetStructuredGridOutput();
  vtkUnstructuredGrid* GetUnstructuredGridOutput();
  vtkRectilinearGrid* GetRectilinearGridOutput();
  vtkGraph* GetGraphOutput();
  vtkMolecule* GetMoleculeOutput();
  vtkTable* GetTableOutput();
  ///@}

protected:
  vtkProgrammableSource();
  ~vtkProgrammableSource() override;

  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
  int RequestDataObject(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
  int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  ProgrammableMethodCallbackType ExecuteMethod; // function to invoke
  ProgrammableMethodCallbackType ExecuteMethodArgDelete;
  void* ExecuteMethodArg;
  ProgrammableMethodCallbackType RequestInformationMethod; // function to invoke

  vtkTimeStamp ExecuteTime;
  int RequestedDataType;

private:
  vtkProgrammableSource(const vtkProgrammableSource&) = delete;
  void operator=(const vtkProgrammableSource&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif