File: vtkRCalculatorFilter.h

package info (click to toggle)
vtk 5.8.0-13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 130,524 kB
  • sloc: cpp: 1,129,256; ansic: 708,203; tcl: 48,526; python: 20,875; xml: 6,779; yacc: 4,208; perl: 3,121; java: 2,788; lex: 931; sh: 660; asm: 471; makefile: 299
file content (167 lines) | stat: -rw-r--r-- 5,404 bytes parent folder | download | duplicates (4)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167

/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkRCalculatorFilter.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.

=========================================================================*/
/*-------------------------------------------------------------------------
  Copyright 2009 Sandia Corporation.
  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
  the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/

// .NAME vtkRCalculatorFilter
//
// .SECTION Description
//
// This class functions as an array calculator for vtkDataArrays and VTKarray objects,
// using GNU R as the calculation engine.
//
// .SECTION See Also
//  vtkRInterface vtkRadapter
//
// .SECTION Thanks
//  Developed by Thomas Otahal at Sandia National Laboratories.
//

#ifndef __vtkRCalculatorFilter_h
#define __vtkRCalculatorFilter_h

#include "vtkDataObjectAlgorithm.h"

class vtkRInterface;
class vtkRCalculatorFilterInternals;
class vtkDataSet;
class vtkDoubleArray;

class VTK_GRAPHICS_EXPORT vtkRCalculatorFilter : public vtkDataObjectAlgorithm
{

public:
  
  static vtkRCalculatorFilter *New();

  vtkTypeMacro(vtkRCalculatorFilter, vtkDataObjectAlgorithm );
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Copies vtkDataArray named NameOfVTKArray to R with variable 
  // name NameOfRvar.  The array must exist in the input data set.
  //
  // Note: for vtkArray use "0","1","2",... for NameOfVTKArray to specify the index of
  // the vtkArray to pass to R.
  void PutArray(const char* NameOfVTKArray, const char* NameOfRvar);

  // Description:
  // Copies R variable NameOfRvar from R to the vtkDataArray named
  // NameOfVTKArray.  Will replace existing vtkDataArray with the same name.
  //
  // Note: for vtkArray use any string for NameOfVTKArray.  The array will be appended
  // to the list of vtkArrays on the output.
  void GetArray(const char* NameOfVTKArray, const char* NameOfRvar);

  // Description:
  // Clears the list of variables to be copied to R.
  void RemoveAllPutVariables();

  // Description:
  // Clears the list of variables to be copied from R.
  void RemoveAllGetVariables();

  // Description:
  // For vtkTable input to the filter.  An R list variable is created for the 
  // vtkTable input using PutTable().  The output of the filter can be set from
  // a list variable in R using GetTable()
  void PutTable(const char* NameOfRvar);
  void GetTable(const char* NameOfRvar);

  // Description:
  // Script executed by R.  Can also be set from a file.
  vtkSetStringMacro(Rscript);
  vtkGetStringMacro(Rscript);

  // Description:
  // Provide the R script executed by R from an input file.
  vtkSetStringMacro(ScriptFname);
  vtkGetStringMacro(ScriptFname);
  
  // Description:
  // Write R output to standard output.
  vtkSetMacro(Routput,int);
  vtkGetMacro(Routput,int);

  // Description:
  // Pass VTK time information to R.
  // If turned turned on, the filter will create three variables in R.
  // The variables will be update automatically as time
  // changes in the VTK pipeline.
  // VTK_TIME_STEPS - array of all available time values.
  // VTK_TIME_RANGE- array of minimum and maximum time values.
  // VTK_CURRENT_TIME - floating point time value at the current time index.
  vtkSetMacro(TimeOutput,int);
  vtkGetMacro(TimeOutput,int);

  // Description:
  // Create VTK_BLOCK_ID variable in R when processing composite data sets.
  vtkSetMacro(BlockInfoOutput,int);
  vtkGetMacro(BlockInfoOutput,int);

  // Description:
  // This is required to capture REQUEST_DATA_OBJECT requests.
  virtual int ProcessRequest(vtkInformation* request, 
                             vtkInformationVector** inputVector,
                             vtkInformationVector* outputVector);

protected:

  int SetRscriptFromFile(const char* fname);

  virtual int RequestData(vtkInformation *vtkNotUsed(request), 
                          vtkInformationVector **inputVector, 
                          vtkInformationVector *outputVector);

  // Description:
  // Creates the same output type as the input type.
  virtual int RequestDataObject(vtkInformation* request,
                                vtkInformationVector** inputVector,
                                vtkInformationVector* outputVector);

  vtkRCalculatorFilter();
  ~vtkRCalculatorFilter();

private:

  vtkRCalculatorFilter(const vtkRCalculatorFilter&);  // Not implemented.
  void operator=(const vtkRCalculatorFilter&);  // Not implemented.

  // Implementation details
  vtkRCalculatorFilterInternals* rcfi;
  int ProcessDataSet(vtkDataSet* dsinp, vtkDataSet* dsout);

  vtkRInterface* ri;
  char* Rscript;
  char* RfileScript;
  char* ScriptFname;
  int Routput;
  int TimeOutput;
  int BlockInfoOutput;
  char* OutputBuffer;
  vtkDoubleArray* CurrentTime;
  vtkDoubleArray* TimeRange;
  vtkDoubleArray* TimeSteps;
  vtkDoubleArray* BlockId;
  vtkDoubleArray* NumBlocks;

};

#endif