SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
svkAlgorithmPortMapper Class Reference

#include <svkAlgorithmPortMapper.h>

Inheritance diagram for svkAlgorithmPortMapper:

Classes

struct  svkInputPortInfo
 
struct  svkOutputPortInfo
 

Public Types

enum  svkXMLDataType {
  SVK_BOOL = 0, SVK_INT, SVK_DOUBLE, SVK_STRING,
  SVK_IMAGE_DATA, SVK_MR_IMAGE_DATA, SVK_MRS_IMAGE_DATA, SVK_4D_IMAGE_DATA,
  SVK_XML
}
 

Public Member Functions

 vtkTypeMacro (svkAlgorithmPortMapper, vtkObject)
 
void SetAlgorithm (vtkAlgorithm *algo)
 Set the internal algorithm whos input ports are to be set. More...
 
void InitializeOutputPort (int port, string name, int type)
 Initialize any output ports. More...
 
vtkAlgorithmOutput * GetOutputPort (string name)
 Get the output port by name. More...
 
vtkAlgorithmOutput * GetOutputPort (int port)
 Get the output port by port number. More...
 
int GetNumberOfOutputPorts ()
 Returns the number of output ports. More...
 
string GetXMLTagForOutputPort (int port)
 Get the xml tag name for the given output port number. More...
 
int FillOutputPortInformation (int port, vtkInformation *info)
 All ports must be initialized with InitializeOutputPort BEFORE this method is called. More...
 
void InitializeInputPort (int port, string name, int type, bool required=true, bool repeatable=false)
 This method sets up the inputs for FillInputPortInformation. Must be called before FillInputPortInformation. More...
 
void SetInputConnection (int port, vtkAlgorithmOutput *output)
 Set the input connection to the internal algorithm. More...
 
int GetNumberOfInputPorts ()
 Returns the number of input ports. More...
 
void SetInputPortsFromXML (vtkXMLDataElement *element)
 Parses an XML element and uses it to set the input ports of the algorithm. Converts image filename strings to svkImageData objects. More...
 
int FillInputPortInformation (int port, vtkInformation *info)
 All ports must be initialized with InitializeInputPort BEFORE this method is called. More...
 
void SetDoubleInputPortValue (int port, double value)
 Basic setter. Wraps value in vtkDataObject subclass. More...
 
svkDoubleGetDoubleInputPortValue (int port, int connection=0)
 Basic getter. More...
 
void SetIntInputPortValue (int port, int value)
 Basic setter. Wraps value in vtkDataObject subclass. More...
 
svkIntGetIntInputPortValue (int port)
 Basic getter. More...
 
void SetStringInputPortValue (int port, string value)
 Basic setter. Wraps value in vtkDataObject subclass. More...
 
svkStringGetStringInputPortValue (int port)
 Basic getter. More...
 
void SetBoolInputPortValueUsingString (int port, string value)
 Basic setter. Wraps value in vtkDataObject subclass. More...
 
void SetBoolInputPortValue (int port, bool value)
 Basic setter. Wraps value in vtkDataObject subclass. More...
 
svkBoolGetBoolInputPortValue (int port)
 Basic getter. More...
 
void SetXMLInputPortValue (int port, vtkXMLDataElement *value)
 Basic setter. Wraps value in vtkDataObject subclass. More...
 
svkXMLGetXMLInputPortValue (int port)
 Basic getter. More...
 
void SetMRImageInputPortValue (int port, string filename)
 Setter that converts a filename into an svkImageData object. More...
 
svkMrsImageDataGetMRSImageInputPortValue (int port, int connection=0)
 Basic getter. More...
 
void SetMRSImageInputPortValue (int port, string filename)
 Setter that converts a filename into an svkImageData object. More...
 
svkImageDataGetImageInputPortValue (int port, int connection=0)
 Basic getter. More...
 
svkMriImageDataGetMRImageInputPortValue (int port, int connection=0)
 Basic getter. More...
 
string GetInputPortName (int port)
 Returns string names used to identify the input port. More...
 
string GetOutputPortName (int port)
 Returns string names used to identify the output port. More...
 
string GetXMLTagForInputPort (int port)
 Returns string names used in XML configuration files for input port. More...
 
string GetXMLTagForAlgorithm ()
 Returns string names used in XML configuration files for input port. More...
 
bool GetInputPortRequired (int port)
 Returns true if the port is required. More...
 
bool GetInputPortRepeatable (int port)
 Returns true if the port is repeatable. More...
 
string GetXMLInputPortPrefix ()
 Get the prefix used for the port definitions in xml. More...
 
void SetXMLPortPrefix (string prefix)
 Set the prefix used for the port definitions in xml. More...
 
string GetXMLAlgorithmPrefix ()
 Get the prefix used for the port definitions in xml. More...
 
void SetXMLAlgorithmPrefix (string prefix)
 Set the prefix used for the port definitions in xml. More...
 
string GetXSD ()
 Write the XSD for this port mappper's current initialization. More...
 
virtual vtkDataObject * GetAlgorithmInputPort (int port, int index=0)
 Handles getting data object input appropriately. More...
 
virtual void SetAlgorithmInputPort (int port, vtkDataObject *input)
 Handles setting data object input appropriately. More...
 
void PrintSelf (ostream &os, vtkIndent indent)
 Prints all input parameters set. More...
 
int GetInputPortNumber (string name)
 Returns the port number for a given parameter string. More...
 
int GetInputPortType (int port)
 Gets the type for a given input port. More...
 

Static Public Member Functions

static svkAlgorithmPortMapperNew ()
 
static string GetClassTypeFromDataType (int type)
 Returns string class name for a given type. More...
 

Protected Member Functions

 svkAlgorithmPortMapper ()
 
 ~svkAlgorithmPortMapper ()
 

Protected Attributes

string portPrefix
 The XML prefix used for the arguments. More...
 
string algorithmPrefix
 The XML prefix used for the algorithm. More...
 
vector< svkInputPortInfoinputPorts
 Stores the names for each parameter. Used to search the XML and print the state. More...
 
vector< svkOutputPortInfooutputPorts
 Stores the names for each parameter. Used to search the XML and print the state. More...
 

Detailed Description

This class is a helper class that can be used with any vtkAlgorithm. It provides an interface for using the input ports for a vtkAlgorithm to store all the parameters necessary to execute the algorithm. Additionally an XML file can be supplied with the names given to each input port as tags that surround the data to be given to that port. This way an algorithm can be configured and run using a simple XML file. If the data type given is an image, a filename will be assumed and the output of the appropriate reader will be set into the given port. For example if you had four inputs to an algorithm called svkMyAlgorithm and the input ports were named INPUT_IMAGE, PARAMETER_ONE, PARAMETER_TWO, and PARAMETER_THREE, then your XML would appear something like this:

<svkMyAlgorithm>

<INPUT_IMAGE>image.idf</INPUT_IMAGE>

<PARAMETER_ONE>1</PARAMETER_ONE>

<PARAMETER_TWO>1</PARAMETER_TWO>

<PARAMETER_THREE>Data Mask</PARAMETER_THREE>

</svkMyAlgorithm>

This class uses vtkDataObject-wrapped types (svkDouble, svkInt, svkString, svkBool, svkXML) to fill input ports that are not of type vtkDataObject.

Member Enumeration Documentation

Enumerator
SVK_BOOL 
SVK_INT 
SVK_DOUBLE 
SVK_STRING 
SVK_IMAGE_DATA 
SVK_MR_IMAGE_DATA 
SVK_MRS_IMAGE_DATA 
SVK_4D_IMAGE_DATA 
SVK_XML 

Constructor & Destructor Documentation

svkAlgorithmPortMapper ( )
protected
~svkAlgorithmPortMapper ( )
protected

Member Function Documentation

int FillInputPortInformation ( int  port,
vtkInformation *  info 
)
int FillOutputPortInformation ( int  port,
vtkInformation *  info 
)
vtkDataObject * GetAlgorithmInputPort ( int  port,
int  index = 0 
)
virtual
svkBool * GetBoolInputPortValue ( int  port)
string GetClassTypeFromDataType ( int  type)
static
svkDouble * GetDoubleInputPortValue ( int  port,
int  connection = 0 
)
svkImageData * GetImageInputPortValue ( int  port,
int  connection = 0 
)
string GetInputPortName ( int  port)

Returns string names used to identify the input port.

Returns the name of the given parameter port.

References svkAlgorithmPortMapper::inputPorts.

Referenced by svkAlgorithmPortMapper::GetXMLTagForInputPort(), svkAlgorithmPortMapper::GetXSD(), and svkAlgorithmPortMapper::PrintSelf().

int GetInputPortNumber ( string  name)

Returns the port number for a given parameter string.

Returns the port number for the given parameter name. Returns -1 if the port does not exist.

References svkAlgorithmPortMapper::inputPorts.

bool GetInputPortRepeatable ( int  port)

Returns true if the port is repeatable.

Returns true of the requested port number is a repeatable port.

References svkAlgorithmPortMapper::inputPorts.

Referenced by svkAlgorithmPortMapper::GetXSD(), and svkAlgorithmPortMapper::SetInputPortsFromXML().

bool GetInputPortRequired ( int  port)

Returns true if the port is required.

Returns true of the requested port number is a required port.

References svkAlgorithmPortMapper::inputPorts.

Referenced by svkAlgorithmPortMapper::GetXSD().

int GetInputPortType ( int  port)
svkInt * GetIntInputPortValue ( int  port)
svkMriImageData * GetMRImageInputPortValue ( int  port,
int  connection = 0 
)
svkMrsImageData * GetMRSImageInputPortValue ( int  port,
int  connection = 0 
)
int GetNumberOfInputPorts ( )

Returns the number of input ports.

Gets the number of input ports for the internal algorithm.

int GetNumberOfOutputPorts ( )

Returns the number of output ports.

Gets the number of output ports for the internal algorithm.

Referenced by svkImageAlgorithmPipeline::InitializeAlgorithmForTag().

vtkAlgorithmOutput * GetOutputPort ( string  name)

Get the output port by name.

Get the output of a given port by string name.

References svkAlgorithmPortMapper::outputPorts.

Referenced by svkImageAlgorithmPipeline::InitializeAlgorithmForTag().

vtkAlgorithmOutput * GetOutputPort ( int  port)

Get the output port by port number.

Get the output of a given port using its number

string GetOutputPortName ( int  port)

Returns string names used to identify the output port.

Returns the name of the given parameter port.

References svkAlgorithmPortMapper::outputPorts.

Referenced by svkAlgorithmPortMapper::GetXSD().

svkString * GetStringInputPortValue ( int  port)
string GetXMLAlgorithmPrefix ( )

Get the prefix used for the port definitions in xml.

Get the prefix used for the port definitions in xml

References svkAlgorithmPortMapper::algorithmPrefix.

Referenced by svkAlgorithmPortMapper::GetXMLTagForAlgorithm().

string GetXMLInputPortPrefix ( )

Get the prefix used for the port definitions in xml.

Get the prefix used for the port definitions in xml

References svkAlgorithmPortMapper::portPrefix.

Referenced by svkAlgorithmPortMapper::GetXMLTagForInputPort(), and svkAlgorithmPortMapper::GetXMLTagForOutputPort().

svkXML * GetXMLInputPortValue ( int  port)
string GetXMLTagForAlgorithm ( )

Returns string names used in XML configuration files for input port.

Gets the XML tag with the appropriate prefix.

References svkAlgorithmPortMapper::GetXMLAlgorithmPrefix().

string GetXMLTagForInputPort ( int  port)

Returns string names used in XML configuration files for input port.

Gets the XML tag with the appropriate prefix.

References svkAlgorithmPortMapper::GetInputPortName(), and svkAlgorithmPortMapper::GetXMLInputPortPrefix().

Referenced by svkAlgorithmPortMapper::SetInputPortsFromXML().

string GetXMLTagForOutputPort ( int  port)

Get the xml tag name for the given output port number.

Get the xml tag associated with a given output port.

References svkAlgorithmPortMapper::GetXMLInputPortPrefix(), and svkAlgorithmPortMapper::outputPorts.

Referenced by svkImageAlgorithmPipeline::InitializeAlgorithmForTag().

string GetXSD ( )
void InitializeInputPort ( int  port,
string  name,
int  type,
bool  required = true,
bool  repeatable = false 
)

This method sets up the inputs for FillInputPortInformation. Must be called before FillInputPortInformation.

This method initializes a given input port. This MUST be called in the constructor of the subclass, and only there before setting any of the inputs.

References svkAlgorithmPortMapper::GetAlgorithmInputPort(), and svkAlgorithmPortMapper::inputPorts.

Referenced by svkDCEBasicFit::svkDCEBasicFit(), svkDCEQuantify::svkDCEQuantify(), svkImageAlgorithmPipeline::svkImageAlgorithmPipeline(), svkImageCopy::svkImageCopy(), svkImageMathematics::svkImageMathematics(), svkImageStatistics::svkImageStatistics(), svkImageThreshold::svkImageThreshold(), svkMrsSingleVoxelSincExtraction::svkMrsSingleVoxelSincExtraction(), and svkObliqueReslice::svkObliqueReslice().

void InitializeOutputPort ( int  port,
string  name,
int  type 
)
static svkAlgorithmPortMapper* New ( )
static
void PrintSelf ( ostream &  os,
vtkIndent  indent 
)

Prints all input parameters set.

PrintSelf method calls parent class PrintSelf, then prints all parameters.

References svkAlgorithmPortMapper::GetAlgorithmInputPort(), and svkAlgorithmPortMapper::GetInputPortName().

Referenced by svkGenericAlgorithmWithPortMapper::PrintSelf(), svkImageAlgorithmWithPortMapper::PrintSelf(), and svkImageMathematics::PrintSelf().

void SetAlgorithm ( vtkAlgorithm *  algo)

Set the internal algorithm whos input ports are to be set.

Sets the algorithm that the inputs will be mapped to.

Referenced by svkGenericAlgorithmWithPortMapper::GetPortMapper(), svkImageAlgorithmWithPortMapper::GetPortMapper(), svkDCEBasicFit::GetPortMapper(), and svkImageMathematics::GetPortMapper().

void SetAlgorithmInputPort ( int  port,
vtkDataObject *  input 
)
virtual
void SetBoolInputPortValue ( int  port,
bool  value 
)
void SetBoolInputPortValueUsingString ( int  port,
string  value 
)
void SetDoubleInputPortValue ( int  port,
double  value 
)
void SetInputConnection ( int  port,
vtkAlgorithmOutput *  output 
)

Set the input connection to the internal algorithm.

Set the input connection to a the internal algorithm.

void SetInputPortsFromXML ( vtkXMLDataElement *  element)

Parses an XML element and uses it to set the input ports of the algorithm. Converts image filename strings to svkImageData objects.

Extracts input port parameters from an XML element and maps them to the internal algorithm.

References svkAlgorithmPortMapper::GetInputPortRepeatable(), and svkAlgorithmPortMapper::GetXMLTagForInputPort().

Referenced by svkImageAlgorithmPipeline::InitializeAlgorithmForTag(), svkGenericAlgorithmWithPortMapper::SetInputPortsFromXML(), and svkImageAlgorithmWithPortMapper::SetInputPortsFromXML().

void SetIntInputPortValue ( int  port,
int  value 
)
void SetMRImageInputPortValue ( int  port,
string  filename 
)

Setter that converts a filename into an svkImageData object.

Sets an MRI image port. If the input is a filename and a reader will be instantiated to read the file.

References svkImageReaderFactory::CreateImageReader2(), svkUtils::FilePathExists(), svkAlgorithmPortMapper::GetInputPortType(), svkImageReader2::GetOutput(), svkImageReaderFactory::New(), svkAlgorithmPortMapper::SetAlgorithmInputPort(), and svkAlgorithmPortMapper::SVK_MR_IMAGE_DATA.

void SetMRSImageInputPortValue ( int  port,
string  filename 
)

Setter that converts a filename into an svkImageData object.

Sets an MRS image port. If the input is a filename and a reader will be instantiated to read the file.

References svkImageReaderFactory::CreateImageReader2(), svkAlgorithmPortMapper::GetInputPortType(), svkImageReader2::GetOutput(), svkImageReaderFactory::New(), svkAlgorithmPortMapper::SetAlgorithmInputPort(), and svkAlgorithmPortMapper::SVK_MRS_IMAGE_DATA.

void SetStringInputPortValue ( int  port,
string  value 
)
void SetXMLAlgorithmPrefix ( string  prefix)

Set the prefix used for the port definitions in xml.

Set the prefix used for the port definitions in xml

References svkAlgorithmPortMapper::algorithmPrefix.

void SetXMLInputPortValue ( int  port,
vtkXMLDataElement *  value 
)

Basic setter. Wraps value in vtkDataObject subclass.

Parameter port setter.

References svkAlgorithmPortMapper::GetInputPortType(), svkXML::New(), svkAlgorithmPortMapper::SetAlgorithmInputPort(), and svkAlgorithmPortMapper::SVK_XML.

void SetXMLPortPrefix ( string  prefix)

Set the prefix used for the port definitions in xml.

Set the XML tag prefix for the input/output ports.

References svkAlgorithmPortMapper::portPrefix.

Referenced by svkImageAlgorithmPipeline::svkImageAlgorithmPipeline().

vtkTypeMacro ( svkAlgorithmPortMapper  ,
vtkObject   
)

Member Data Documentation

string algorithmPrefix
protected
vector<svkInputPortInfo> inputPorts
protected
vector<svkOutputPortInfo> outputPorts
protected
string portPrefix
protected

The documentation for this class was generated from the following files: