SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkAlgorithmPortMapper.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  */
41 
42 
43 #ifndef SVK_ALGORITHM_PORT_MAPPER_H
44 #define SVK_ALGORITHM_PORT_MAPPER_H
45 
46 
47 #include <vtkObject.h>
48 #include <vtkObjectFactory.h>
49 #include <vtkInformation.h>
50 
51 #include <svkImageData.h>
52 #include <svkMriImageData.h>
53 #include <svkImageAlgorithm.h>
54 #include <svkDcmHeader.h>
55 #include <svkUtils.h>
56 #include <svkDouble.h>
57 #include <svkString.h>
58 #include <svkInt.h>
59 #include <svkBool.h>
60 #include <svkXML.h>
61 #include <vtkAlgorithmOutput.h>
62 #include <svkImageReaderFactory.h>
63 #include <string>
64 
65 namespace svk {
66 
67 
68 using namespace std;
69 
70 
99 class svkAlgorithmPortMapper : public vtkObject
100 {
101 
102  public:
103 
104  typedef enum {
105  SVK_BOOL = 0,
113  SVK_XML
114  } svkXMLDataType;
115 
117  string name;
118  int type;
119  bool required;
121  };
122 
124  string name;
125  int type;
126  };
127 
128  static svkAlgorithmPortMapper* New();
129  vtkTypeMacro( svkAlgorithmPortMapper, vtkObject);
130 
132  void SetAlgorithm( vtkAlgorithm* algo );
133 
135  void InitializeOutputPort( int port, string name, int type );
136 
138  vtkAlgorithmOutput* GetOutputPort( string name );
139 
141  vtkAlgorithmOutput* GetOutputPort( int port );
142 
144  int GetNumberOfOutputPorts( );
145 
147  string GetXMLTagForOutputPort( int port );
148 
150  int FillOutputPortInformation( int port, vtkInformation* info );
151 
153  void InitializeInputPort( int port, string name, int type, bool required = true, bool repeatable = false );
154 
156  void SetInputConnection( int port, vtkAlgorithmOutput* output );
157 
159  int GetNumberOfInputPorts( );
160 
162  void SetInputPortsFromXML( vtkXMLDataElement* element );
163 
165  int FillInputPortInformation( int port, vtkInformation* info );
166 
168  void SetDoubleInputPortValue( int port, double value );
170  svkDouble* GetDoubleInputPortValue( int port, int connection = 0 );
171 
173  void SetIntInputPortValue( int port, int value );
175  svkInt* GetIntInputPortValue( int port );
176 
178  void SetStringInputPortValue( int port, string value );
180  svkString* GetStringInputPortValue( int port);
181 
183  void SetBoolInputPortValueUsingString( int port, string value );
185  void SetBoolInputPortValue( int port, bool value );
187  svkBool* GetBoolInputPortValue( int port);
188 
190  void SetXMLInputPortValue( int port, vtkXMLDataElement* value );
192  svkXML* GetXMLInputPortValue( int port);
193 
195  void SetMRImageInputPortValue( int port, string filename );
196 
198  svkMrsImageData* GetMRSImageInputPortValue( int port, int connection = 0);
199 
201  void SetMRSImageInputPortValue( int port, string filename );
202 
204  svkImageData* GetImageInputPortValue( int port, int connection = 0);
205 
207  svkMriImageData* GetMRImageInputPortValue( int port, int connection = 0);
208 
210  string GetInputPortName( int port );
211 
213  string GetOutputPortName( int port );
214 
216  string GetXMLTagForInputPort( int port );
217 
219  string GetXMLTagForAlgorithm( );
220 
222  bool GetInputPortRequired( int port );
223 
225  bool GetInputPortRepeatable( int port );
226 
228  string GetXMLInputPortPrefix( );
229 
231  void SetXMLPortPrefix( string prefix );
232 
234  string GetXMLAlgorithmPrefix( );
235 
237  void SetXMLAlgorithmPrefix( string prefix );
238 
240  string GetXSD( );
241 
243  virtual vtkDataObject* GetAlgorithmInputPort( int port, int index = 0 );
244 
246  virtual void SetAlgorithmInputPort( int port, vtkDataObject* input );
247 
249  void PrintSelf( ostream &os, vtkIndent indent );
250 
252  static string GetClassTypeFromDataType( int type );
253 
255  int GetInputPortNumber( string name );
256 
258  int GetInputPortType( int port );
259 
260  protected:
261 
264 
266  string portPrefix;
267 
270 
272  vector<svkInputPortInfo> inputPorts;
273 
275  vector<svkOutputPortInfo> outputPorts;
276 
277 
278 
279  private:
280 
282  void SetInputPortFromXML( int port, vtkXMLDataElement* parameterElement );
283 
285  vtkAlgorithm* algo;
286 
287 };
288 
289 
290 } //svk
291 
292 
293 #endif //SVK_ALGORITHM_PORT_MAPPER_H
294 
Definition: svkAlgorithmPortMapper.h:111
Definition: svkMrsImageData.h:66
string name
Definition: svkAlgorithmPortMapper.h:117
Definition: svkAlgorithmPortMapper.h:108
Definition: svkBool.h:59
Definition: svkAlgorithmPortMapper.h:107
int type
Definition: svkAlgorithmPortMapper.h:125
Definition: svkDouble.h:59
Definition: svkXML.h:60
bool repeatable
Definition: svkAlgorithmPortMapper.h:120
string algorithmPrefix
The XML prefix used for the algorithm.
Definition: svkAlgorithmPortMapper.h:269
Definition: svkAlgorithmPortMapper.h:123
int type
Definition: svkAlgorithmPortMapper.h:118
bool required
Definition: svkAlgorithmPortMapper.h:119
vector< svkOutputPortInfo > outputPorts
Stores the names for each parameter. Used to search the XML and print the state.
Definition: svkAlgorithmPortMapper.h:275
vector< svkInputPortInfo > inputPorts
Stores the names for each parameter. Used to search the XML and print the state.
Definition: svkAlgorithmPortMapper.h:272
Definition: svkAlgorithmPortMapper.h:112
Definition: svkAlgorithmPortMapper.h:106
Definition: svkAlgorithmPortMapper.h:110
Definition: svkMriImageData.h:72
Definition: svkAlgorithmPortMapper.h:109
Definition: svkImageData.h:107
string portPrefix
The XML prefix used for the arguments.
Definition: svkAlgorithmPortMapper.h:266
Definition: svkString.h:60
Definition: svkAlgorithmPortMapper.h:99
Definition: svkInt.h:59
string name
Definition: svkAlgorithmPortMapper.h:124
Definition: svkAlgorithmPortMapper.h:116