};
//==========================================================================
+const std::string itkImageToImageFilterString = "ITK_ImageToImageFilter";
+const std::string vtkImageAlgorithmString = "VTK_ImageAlgorithm";
+const std::string vtkPolyDataAlgorithmString = "VTK_PolyDataAlgorithm";
+
//==========================================================================
class bbfy
{
vtkPolyDataAlgorithm,
}
BoxType;
+
BoxType mType;
bool mIsWidget;
std::string mParentBlackBox;
{
std::string name;
std::string type;
- std::string help;
+ std::string descr;
std::string special;
std::string generic_type;
}
const std::string& output_path,
bool verbose)
{
+ mIsWidget = false;
+
mFilename = filename;
mPackage = package;
mNamespace = "bb" + mPackage;
// Name
if (!BB.isAttributeSet("name"))
{
- throw bbfyException("Error : no 'name' attribute found (mandatory)");
+ throw bbfyException("Error : <blackbox> tag : no 'name' attribute found (mandatory)");
}
mName = BB.getAttribute("name");
mGeneric = false;
mType = STD;
}
- else if (bbtype=="itkImageToImageFilter")
+ else if (bbtype==itkImageToImageFilterString)
{
mType = itkImageToImageFilter;
// Looks for <itkparent> tag
if (!BB.nChildNode("itkparent"))
{
- throw bbfyException("Error : blackbox type 'itkImageToImageFilter' but no <itkparent> tag found (mandatory)");
+ throw bbfyException("Error : blackbox type '"+itkImageToImageFilterString+"' but no <itkparent> tag found (mandatory)");
}
GetTextOrClear(BB.getChildNode("itkparent"),mItkParent);
//
mGeneric = false;
if (BB.isAttributeSet("generic")) mGeneric=true;
}
- else if ((bbtype=="vtkImageAlgorithm") || (bbtype=="vtkPolyDataAlgorithm"))
+ else if (bbtype == vtkImageAlgorithmString)
{
mType = vtkImageAlgorithm;
// Looks for <vtkparent> tag
if (!BB.nChildNode("vtkparent"))
{
- throw bbfyException("Error : blackbox type 'vtkImageAlgorithm' but no <vtkparent> tag found (mandatory)");
+ throw bbfyException("Error : blackbox type '"
+ +vtkImageAlgorithmString
+ +"' but no <vtkparent> tag found (mandatory)");
}
GetTextOrClear(BB.getChildNode("vtkparent"),mVtkParent);
//
}
- else
+ else if (bbtype == vtkPolyDataAlgorithmString )
+ {
+ mType = vtkPolyDataAlgorithm;
+ // Looks for <vtkparent> tag
+ if (!BB.nChildNode("vtkparent"))
+ {
+ throw bbfyException("Error : blackbox type '"
+ +vtkPolyDataAlgorithmString
+ +"' but no <vtkparent> tag found (mandatory)");
+ }
+ GetTextOrClear(BB.getChildNode("vtkparent"),mVtkParent);
+ //
+ }
+ else
{
std::string mess("Error : blackbox type '");
mess += bbtype;
- mess += "' unknown (types are 'standard','itkfilter')";
+ mess += "' unknown. Known types :";
+ mess += "'" + itkImageToImageFilterString + "' ";
+ mess += "'" + vtkImageAlgorithmString + "' ";
+ mess += "'" + vtkPolyDataAlgorithmString + "' ";
throw bbfyException(mess);
}
}
mInclude.push_back("bbtkAtomicBlackBox.h");
}
- /*
- // Parent black box
- if (!BB.nChildNode("parentblackbox"))
- {
- throw bbfyException("Error : no <parentblackbox> tag found (mandatory)");
- }
- GetTextOrClear(BB.getChildNode("parentblackbox"),mParentBlackBox);
-
- // Package
- if (!BB.nChildNode("package"))
- {
- throw bbfyException("Error : no <package> tag found (mandatory)");
- }
- GetTextOrClear(BB.getChildNode("package"),mPackage);
- */
-
// Author
int i,j;
for (i=0,j=0; i<BB.nChildNode("author"); i++)
}
// Namespace
- /*
- mIsInNamespace = false;
if (BB.nChildNode("namespace"))
{
- mIsInNamespace = true;
GetTextOrClear(BB.getChildNode("namespace"),mNamespace);
}
- */
// UserConstructor body
if (BB.nChildNode("constructor"))
// Inputs
for (i=0,j=0; i<BB.nChildNode("input"); i++)
{
+ IO io;
XMLNode n = BB.getChildNode("input",&j);
if (!n.isAttributeSet("name"))
{
throw bbfyException("Error : <input> attribute 'name' not found (mandatory)");
}
+ io.name = n.getAttribute("name");
if (!n.isAttributeSet("type"))
{
- throw bbfyException("Error : <input> attribute 'type' not found (mandatory)");
+ throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
}
-
- IO io;
- io.name = n.getAttribute("name");
io.type = n.getAttribute("type");
- GetTextOrClear(n,io.help);
+ if (!n.isAttributeSet("description"))
+ {
+ throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
+ }
+ io.descr = n.getAttribute("description");
if (n.isAttributeSet("special"))
{
// Outputs
for (i=0,j=0; i<BB.nChildNode("output"); i++)
{
+ IO io;
XMLNode n = BB.getChildNode("output",&j);
if (!n.isAttributeSet("name"))
{
throw bbfyException("Error : <output> attribute 'name' not found (mandatory)");
}
+ io.name = n.getAttribute("name");
if (!n.isAttributeSet("type"))
{
- throw bbfyException("Error : <output> attribute 'type' not found (mandatory)");
+ throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
}
-
- IO io;
- io.name = n.getAttribute("name");
io.type = n.getAttribute("type");
- GetTextOrClear(n,io.help);
+ if (!n.isAttributeSet("description"))
+ {
+ throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
+ }
+ io.descr = n.getAttribute("description");
if (n.isAttributeSet("special"))
{
}
// If is widget
- mFile << "#ifdef _USE_WXWIDGETS_\n";
+ if (mIsWidget)
+ {
+ mFile << "#ifdef _USE_WXWIDGETS_\n";
+ }
// Prevent multiple inclusions
std::string included("__bb");
mFile << "BBTK_INPUT(";
}
mFile << mName << "," << ioi->name << ",\""
- << ioi->help << "\"," << ioi->type <<");\n";
+ << ioi->descr << "\"," << ioi->type <<");\n";
}
// Outputs
mFile << "BBTK_OUTPUT(";
}
mFile << mName << "," << ioi->name << ",\""
- << ioi->help << "\"," << ioi->type <<");\n";
+ << ioi->descr << "\"," << ioi->type <<");\n";
}
// EO black box description
// Prevent multiple inclusions
mFile << "#endif // " << included <<"\n";
// If is widget
- mFile << "#endif // _USE_WXWIDGETS_\n";
+ if (mIsWidget)
+ {
+ mFile << "#endif // _USE_WXWIDGETS_\n";
+ }
// EOF
mFile << "\n";
{
mFile << "BBTK_INPUT(";
mFile << mName << "Generic," << ioi->name << ",\""
- << ioi->help << "\"," << ioi->generic_type <<");\n";
+ << ioi->descr << "\"," << ioi->generic_type <<");\n";
}
// Outputs
{
mFile << "BBTK_OUTPUT(";
mFile << mName << "Generic," << ioi->name << ",\""
- << ioi->help << "\"," << ioi->generic_type <<");\n";
+ << ioi->descr << "\"," << ioi->generic_type <<");\n";
}
// EO black box description
}
catch (bbfyException e)
{
- std::cerr << e.mMessage << std::endl;
+ std::cerr << argv[0] << " " << argv[1] << std::endl
+ << e.mMessage << std::endl;
return 1;
}
return 0;
--- /dev/null
+description "Tests the std::Add box"
+category "test"
+
+include std
+new Add a
+set a.In1 1
+set a.In2 2
+print $a.Out$
<description>Adds its inputs</description>
<category>math</category>
- <input name="In1" type="double">First number to add</input>
- <input name="In2" type="double">Second number to add</input>
- <output name="Out" type="double">Result</output>
+ <input name="In1" type="double" description="First number to add"/>
+ <input name="In2" type="double" description="Second number to add"/>
+ <output name="Out" type="double" description="Result"/>
<process><PRE>
bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
<description>This box has multiple Void inputs and one Void output. Hence it relays any input modification to its output. It is usefull to plug different BoxChange outputs into the same BoxExecute input.</description>
<category>misc</category>
- <input name="In1" type="bbtk::Void">Input 1</input>
- <input name="In2" type="bbtk::Void">Input 2</input>
- <input name="In3" type="bbtk::Void">Input 3</input>
- <input name="In4" type="bbtk::Void">Input 4</input>
- <input name="In5" type="bbtk::Void">Input 5</input>
-
- <output name="Out" type="bbtk::Void">Output</output>
+ <input name="In1" type="bbtk::Void" description="Input 1"/>
+ <input name="In2" type="bbtk::Void" description="Input 2"/>
+ <input name="In3" type="bbtk::Void" description="Input 3"/>
+ <input name="In4" type="bbtk::Void" description="Input 4"/>
+ <input name="In5" type="bbtk::Void" description="Input 5"/>
+ <output name="Out" type="bbtk::Void" description="Output"/>
</blackbox>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="AppendPolyData" type="vtkPolyDataAlgorithm">
+<blackbox name="AppendPolyData" type="VTK_PolyDataAlgorithm">
<author>jpr at creatis.insa-lyon.fr</author>
<description><PRE>Appends one of more polygonal datasets into a single polygonal dataset</PRE></description>
<include>vtkAppendPolyData.h</include>
<vtkparent>vtkAppendPolyData</vtkparent>
-<output
- name="Out"
- type="vtkPolyData*"
- special="vtk output">
-Output Mesh
-</output>
-
-<input
- name="In1"
- type="vtkPolyData *">
-PolyData 1
-</input>
-
-<input
- name="In2"
- type="vtkPolyData *">
-PolyData 2
-</input>
-
-<input
- name="In3"
- type="vtkPolyData *">
-PolyData 3
-</input>
-
-<input
- name="In4"
- type="vtkPolyData *">
-PolyData 4
-</input>
-
-<input
- name="In5"
- type="vtkPolyData *">
-PolyData 5
-</input>
-
+<output name="Out" type="vtkPolyData*" special="vtk output" description="Output Mesh"/>
+<input name="In1" type="vtkPolyData *" description="PolyData 1"/>
+<input name="In2" type="vtkPolyData *" description="PolyData 2"/>
+<input name="In3" type="vtkPolyData *" description="PolyData 3"/>
+<input name="In4" type="vtkPolyData *" description="PolyData 4"/>
+<input name="In5" type="vtkPolyData *" description="PolyData 5"/>
<process>
<PRE>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="ConeSource" type="vtkPolyDataAlgorithm">
+<blackbox name="ConeSource" type="VTK_PolyDataAlgorithm">
<author>jpr at creatis.insa-lyon.fr</author>
<description><PRE>Creates a Cone (bbfication of vtkConeSource)</PRE></description>
<include>vtkConeSource.h</include>
<vtkparent>vtkConeSource</vtkparent>
-<output
- name="Out"
- type="vtkPolyData*"
- special="vtk output">
-Output Cone
-</output>
-
-<input
- name="Radius"
- type="double"
-special="vtk parameter">
-Cone Radius
-</input>
-
-<input
- name="Resolution"
- type="int"
-special="vtk parameter">
-Cone Resolution
-</input>
-
-<input
- name="CenterX"
- type="double">
-Center X coord
-</input>
-
-<input
- name="CenterY"
- type="double">
-Center Y coord
-</input>
-
-<input
- name="CenterZ"
- type="double">
-Center Z coord
-</input>
-
-<input
- name="DirectionX"
- type="double">
- X Direction
-</input>
-
-<input
- name="DirectionY"
- type="double">
- Y Direction
-</input>
-
-<input
- name="DirectionZ"
- type="double">
- Z Direction
-</input>
-
+<output name="Out" type="vtkPolyData*" special="vtk output" description="Output Cone"/>
+<input name="Radius" type="double" special="vtk parameter" description="Cone Radius"/>
+<input name="Resolution" type="int" special="vtk parameter" description="Cone Resolution"/>
+<input name="CenterX" type="double" description="Center X coord"/>
+<input name="CenterY" type="double" description="Center Y coord"/>
+<input name="CenterZ" type="double" description="Center Z coord"/>
+<input name="DirectionX" type="double" description="X Direction"/>
+<input name="DirectionY" type="double" description="Y Direction"/>
+<input name="DirectionZ" type="double" description="Z Direction"/>
<process>
<PRE>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="ImageAnisotropicDiffusion3D" type="vtkImageAlgorithm">
+<blackbox name="ImageAnisotropicDiffusion3D" type="VTK_ImageAlgorithm">
<author>jpr at creatis.insa-lyon.fr</author>
<description><PRE>vtkImageAnisotropicDiffusion3D diffuses an volume iteratively. The neighborhood of the diffusion is determined by the instance flags. if 'Faces' is on, the 6 voxels adjoined by faces are included in the neighborhood. If 'Edges' is on the 12 edge connected voxels are included, and if 'Corners' is on, the 8 corner connected voxels are included. 'DiffusionFactor' determines how far a pixel value moves toward its neighbors, and is insensitive to the number of neighbors chosen. The diffusion is anisotropic because it only occurs when a gradient measure is below 'GradientThreshold'. Two gradient measures exist and are toggled by the 'GradientMagnitudeThreshold' flag. When 'GradientMagnitudeThreshold' is on, the magnitude of the gradient, computed by central differences, above 'DiffusionThreshold' a voxel is not modified. The alternative measure examines each neighbor independently. The gradient between the voxel and the neighbor must be below the 'DiffusionThreshold' for diffusion to occur with THAT neighbor.</PRE></description>
<include>vtkImageData.h</include>
<vtkparent>vtkImageAnisotropicDiffusion3D</vtkparent>
-<input
- name="In"
- type="vtkImageData*"
- special="vtk input">
-Input image
-</input>
-
-<output
- name="Out"
- type="vtkImageData*"
- special="vtk output">
-Output image
-</output>
-
-
-<input
- name="DiffusionThreshold"
- type="double"
- special="vtk parameter">
-Difference threshold that stops diffusion
-</input>
-
+<input name="In" type="vtkImageData*" special="vtk input" description="Input image"/>
+<output name="Out" type="vtkImageData*" special="vtk output" description="Output image"/>
+<input name="DiffusionThreshold" type="double" special="vtk parameter" description="Difference threshold that stops diffusion"/>
</blackbox>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="ImageDilateErode3D" type="vtkImageAlgorithm">
+<blackbox name="ImageDilateErode3D" type="VTK_ImageAlgorithm">
<author>laurent.guigues at creatis.insa-lyon.fr</author>
<description><PRE>Dilates one value and erodes another. vtkImageDilateErode3D will dilate one value and erode another. It uses an elliptical foot print, and only erodes/dilates on the boundary of the two values. The filter is restricted to the X, Y, and Z axes for now. It can degenerate to a 2 or 1 dimensional filter by setting the kernel size to 1 for a specific axis. (bbfication of vtkImageDilateErode3D)</PRE></description>
<vtkparent>vtkImageDilateErode3D</vtkparent>
-<input
- name="In"
- type="vtkImageData*"
- special="vtk input">
-Input image
-</input>
-
-<output
- name="Out"
- type="vtkImageData*"
- special="vtk output">
-Output image
-</output>
-
-<input
- name="KernelSizeX"
- type="int">
-Size of the kernel in direction X
-</input>
-
-<input
- name="KernelSizeY"
- type="int">
-Size of the kernel in direction Y
-</input>
-
-<input
- name="KernelSizeZ"
- type="int">
-Size of the kernel in direction Z
-</input>
-
-<input
- name="DilateValue"
- type="double"
- special="vtk parameter">
-The dilation value
-</input>
-
-<input
- name="ErodeValue"
- type="double"
- special="vtk parameter">
-The erosion value
-</input>
+<input name="In" type="vtkImageData*" special="vtk input" description="Input image"/>
+<output name="Out" type="vtkImageData*" special="vtk output" description="Output image"/>
+<input name="KernelSizeX" type="int" description="Size of the kernel in direction X"/>
+<input name="KernelSizeY" type="int" description="Size of the kernel in direction Y"/>
+<input name="KernelSizeZ" type="int" description="Size of the kernel in direction Z"/>
+<input name="DilateValue" type="double" special="vtk parameter" description="The dilation value"/>
+<input name="ErodeValue" type="double" special="vtk parameter" description="The erosion value"/>
<process>
<PRE>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="ImageGaussianSmooth" type="vtkImageAlgorithm">
+<blackbox name="ImageGaussianSmooth" type="VTK_ImageAlgorithm">
<author>laurent.guigues at creatis.insa-lyon.fr</author>
<description><PRE>Performs a gaussian convolution of the input image (bbfication of vtkImageGaussianSmooth)</PRE></description>
<vtkparent>vtkImageGaussianSmooth</vtkparent>
-<input
- name="In"
- type="vtkImageData*"
- special="vtk input">
-Input image
-</input>
-
-<output
- name="Out"
- type="vtkImageData*"
- special="vtk output">
-Output image
-</output>
-
-<input
- name="StdDevX"
- type="double">
-Standard deviation in direction X
-</input>
-
-<input
- name="StdDevY"
- type="double">
-Standard deviation in direction Y
-</input>
-
-<input
- name="StdDevZ"
- type="double">
-Standard deviation in direction Z
-</input>
+<input name="In" type="vtkImageData*" special="vtk input" description="Input image"/>
+<output name="Out" type="vtkImageData*" special="vtk output" description="Output image"/>
+<input name="StdDevX" type="double" description="Standard deviation in direction X"/>
+<input name="StdDevY" type="double" description="Standard deviation in direction Y"/>
+<input name="StdDevZ" type="double" description="Standard deviation in direction Z"/>
<process>
<PRE>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="MetaImageReader" type="vtkImageAlgorithm">
+<blackbox name="MetaImageReader" type="VTK_ImageAlgorithm">
<author>laurent.guigues at creatis.insa-lyon.fr</author>
<description><PRE>Reads .mhd / .mha image formats (bbfication of vtkMetaImageReader)</PRE></description>
<include>vtkImageData.h</include>
<vtkparent>vtkMetaImageReader</vtkparent>
-<input
- name="In"
- type="std::string">
-Filename
-</input>
-
-<output
- name="Out"
- type="vtkImageData*"
- special="vtk output">
-Output image
-</output>
+<input name="In" type="std::string" description="Filename"/>
+<output name="Out" type="vtkImageData*" description="Output image" special="vtk output"/>
</blackbox>
<?xml version="1.0" encoding="iso-8859-1"?>
-<blackbox name="SphereSource" type="vtkPolyDataAlgorithm">
+<blackbox name="SphereSource" type="VTK_PolyDataAlgorithm">
<author>jpr@creatis.insa-lyon.fr</author>
<description><PRE>Creates a Sphere (bbfication of vtkSphereSource)</PRE></description>
<include>vtkSphereSource.h</include>
<vtkparent>vtkSphereSource</vtkparent>
-<output
- name="Out"
- type="vtkPolyData*"
- special="vtk output">
-Output Sphere
-</output>
-
-<input
- name="CenterX"
- type="double">
-Center X coord
-</input>
-
-<input
- name="CenterY"
- type="double">
-Center Y coord
-</input>
-
-<input
- name="CenterZ"
- type="double">
-Center Z coord
-</input>
-
-<input
- name="PhiResolution"
- type="int"
- special="vtk parameter">
-Sphere PhiResolution
-</input>
-
-<input
- name="Radius"
- type="double"
-special="vtk parameter">
-Sphere Radius
-</input>
-
-<input
- name="ThetaResolution"
- type="int"
-special="vtk parameter">
-Sphere ThetaResolution
-</input>
+<output name="Out" type="vtkPolyData*" description="Output Sphere" special="vtk output"/>
+<input name="CenterX" type="double" description="Center X coord"/>
+<input name="CenterY" type="double" description="Center Y coord"/>
+<input name="CenterZ" type="double" description="Center Z coord"/>
+<input name="PhiResolution" type="int" description="Sphere PhiResolution" special="vtk parameter"/>
+<input name="Radius" type="double" description="Sphere Radius" special="vtk parameter"/>
+<input name="ThetaResolution" type="int" description="Sphere ThetaResolution"special="vtk parameter"/>
<process>
<PRE>