File: vtkProgrammableAttributeDataFilter.h

package info (click to toggle)
vtk7 7.1.1%2Bdfsg1-12
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 125,776 kB
  • sloc: cpp: 1,539,582; ansic: 106,521; python: 78,038; tcl: 47,013; xml: 8,142; yacc: 5,040; java: 4,439; perl: 3,132; lex: 1,926; sh: 1,500; makefile: 122; objc: 83
file content (153 lines) | stat: -rw-r--r-- 6,403 bytes parent folder | download | duplicates (2)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkProgrammableAttributeDataFilter.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/**
 * @class   vtkProgrammableAttributeDataFilter
 * @brief   manipulate attribute (cell and point) data via a user-specified function
 *
 * vtkProgrammableAttributeDataFilter is a filter that allows you to write a
 * custom procedure to manipulate attribute data - either point or cell
 * data. For example, you could generate scalars based on a complex formula;
 * convert vectors to normals; compute scalar values as a function of
 * vectors, texture coords, and/or any other point data attribute; and so
 * on. The filter takes multiple inputs (input plus an auxiliary input list),
 * so you can write procedures that combine several dataset point
 * attributes. Note that the output of the filter is the same type
 * (topology/geometry) as the input.
 *
 * The filter works as follows. It operates like any other filter (i.e.,
 * checking and managing modified and execution times, processing Update()
 * and Execute() methods, managing release of data, etc.), but the difference
 * is that the Execute() method simply invokes a user-specified function with
 * an optional (void *) argument (typically the "this" pointer in C++). It is
 * also possible to specify a function to delete the argument via
 * ExecuteMethodArgDelete().
 *
 * To use the filter, you write a procedure to process the input datasets,
 * process the data, and generate output data. Typically, this means grabbing
 * the input point or cell data (using GetInput() and maybe GetInputList()),
 * operating on it (creating new point and cell attributes such as scalars,
 * vectors, etc.), and then setting the point and/or cell attributes in the
 * output dataset (you'll need to use GetOutput() to access the output).
 * (Note: besides C++, it is possible to do the same thing in Tcl, Java, or
 * other languages that wrap the C++ core.) Remember, proper filter protocol
 * requires that you don't modify the input data - you create new output data
 * from the input.
 *
 * @warning
 * This filter operates on any combination of the filter input plus a list of
 * additional inputs (at a minimum you must set the filter input via
 * SetInput()).  It is up to you check whether the input is valid, and to
 * insure that the output is valid. Also, you have to write the control
 * structure for the traversal and operation on the point and cell attribute
 * data.
 *
 * @warning
 * By default the output point and cell data will be copied through from the
 * input point data (using reference counting).  You can control this using
 * the output's CopyAllOff() flag, or by using individual flags for each
 * point data field (i.e., scalars, vectors, etc.)
 *
 * @warning
 * The output of this filter is the abstract type vtkDataSet, even if your
 * input is a concrete type like vtkPolyData. Thus you may need to use
 * vtkCastToConcrete to obtain the output as a particular concrete type, or
 * one of the special methods of the superclass (e.g.,
 * vtkDataSetAlgorithm::GetPolyDataOutput) to retrieve output of the
 * correct type.
 *
 * @warning
 * The filter correctly manages modified time and network execution in most
 * cases. However, if you change the definition of the filter function,
 * you'll want to send a manual Modified() method to the filter to force it
 * to reexecute.
*/

#ifndef vtkProgrammableAttributeDataFilter_h
#define vtkProgrammableAttributeDataFilter_h

#include "vtkFiltersProgrammableModule.h" // For export macro
#include "vtkDataSetAlgorithm.h"

class vtkDataSetCollection;

class VTKFILTERSPROGRAMMABLE_EXPORT vtkProgrammableAttributeDataFilter : public vtkDataSetAlgorithm
{
public:
  static vtkProgrammableAttributeDataFilter *New();
  vtkTypeMacro(vtkProgrammableAttributeDataFilter,vtkDataSetAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent);

  /**
   * Add a dataset to the list of data to process.
   */
  void AddInput(vtkDataSet *in);

  /**
   * Remove a dataset from the list of data to process.
   */
  void RemoveInput(vtkDataSet *in);

  /**
   * Return the list of inputs.
   */
  vtkDataSetCollection *GetInputList() {return this->InputList;};

  /**
   * Signature definition for programmable method callbacks. Methods passed to
   * SetExecuteMethod or SetExecuteMethodArgDelete 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 operate on the point attribute 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 *));

protected:
  vtkProgrammableAttributeDataFilter();
  ~vtkProgrammableAttributeDataFilter();

  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
  vtkDataSetCollection *InputList; //list of datasets to process
  ProgrammableMethodCallbackType ExecuteMethod; //function to invoke
  ProgrammableMethodCallbackType ExecuteMethodArgDelete;
  void *ExecuteMethodArg;

  void ReportReferences(vtkGarbageCollector*) VTK_OVERRIDE;

private:
  // hide the superclass' AddInput() from the user and the compiler
  void AddInput(vtkDataObject *)
    { vtkErrorMacro( << "AddInput() must be called with a vtkDataSet not a vtkDataObject."); };

private:
  vtkProgrammableAttributeDataFilter(const vtkProgrammableAttributeDataFilter&) VTK_DELETE_FUNCTION;
  void operator=(const vtkProgrammableAttributeDataFilter&) VTK_DELETE_FUNCTION;
};

#endif