<?xml version="1.0" encoding="UTF-8"?>
<scxml xmlns="http://camitk.imag.fr/3/smallScxml" initial="Initialize" xmlns:camitk="http://camitk.imag.fr/3/asm" xsi:schemaLocation="http://camitk.imag.fr/3/smallScxml/../resources/smallScxml.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <state id="Initialize">
  <onentry>
   <camitk:onState>
    <camitk:description><![CDATA[This pipeline will process several actions on the input component(s): <br /> <ul><li>Open File</li><li>Reconstruction</li><li>Save</li>]]></camitk:description>
   </camitk:onState>
  </onentry>
  <transition target="Open Input" event="Next"/>
 </state>
 <state id="Open Input">
  <onentry>
   <camitk:onState>
    <camitk:description>Open data (component) from a given file</camitk:description>
    <camitk:action>
     <camitk:name>Open File</camitk:name>
     <camitk:parameters>
      <camitk:parameter name="File Name" value="input-1.mha" type="QString"/>
     </camitk:parameters>
     <camitk:outputs>
      <camitk:component name="image" type="ImageComponent"/>
     </camitk:outputs>
    </camitk:action>
   </camitk:onState>
  </onentry>
  <transition target="Initialize" event="Back"/>
  <transition target="Apply Marching Cube" event="Next"/>
 </state>
 <state id="Apply Marching Cube">
  <onentry>
   <camitk:onState>
    <camitk:description>&lt;br /> Marching cubes is a simple algorithm for creating a triangle mesh from an implicit function (one of the form f(x, y, z) = 0).&lt;br /> It works by iterating ("marching") over a uniform grid of cubes superimposed over a region of the function. If all 8 vertices of the cube are positive, or all 8 vertices are negative, the cube is entirely above or entirely below the surface and no triangles are emitted. Otherwise, the cube straddles the function and some triangles and vertices are generated. Since each vertex can either be positive or negative, there are technically 28 possible configurations, but many of these are equivalent to one another. &lt;br/> &lt;br/>This action uses this algorithm to build a 3D surfacic mesh of the input image.</camitk:description>
    <camitk:action>
     <camitk:name>Reconstruction</camitk:name>
     <camitk:parameters>
      <camitk:parameter name="Threshold" value="127.5" type="double"/>
      <camitk:parameter name="Keep only largest component?" value="true" type="bool"/>
      <camitk:parameter name="Subsample original image?" value="true" type="bool"/>
      <camitk:parameter name="Subsampled image width (X)" value="32" type="int"/>
      <camitk:parameter name="Subsampled image height (Y)" value="32" type="int"/>
      <camitk:parameter name="Subsampled image depth (Z)" value="32" type="int"/>
     </camitk:parameters>
     <camitk:inputs>
      <camitk:component name="image" type="ImageComponent"/>
     </camitk:inputs>
     <camitk:outputs>
      <camitk:component name="output-1.vtk" type="MeshComponent"/>
     </camitk:outputs>
    </camitk:action>
   </camitk:onState>
  </onentry>
  <transition target="Open Input" event="Back">
  <transition target="Save Marching Cube Result as output-1.vtk" event="Next"/>
   <onTransition>
    <camitk:close>
     <camitk:component name="image" type="ImageComponent"/>
    </camitk:close>
   </onTransition>
  </transition>
 </state>
 <state id="Save Marching Cube Result as output-1.vtk">
  <onentry>
   <camitk:onState>
    <camitk:description>Save all the top-level of the selected components</camitk:description>
    <camitk:action>
     <camitk:name>Save</camitk:name>
     <camitk:parameters/>
     <camitk:inputs>
      <camitk:component name="output-1.vtk" type="MeshComponent"/>
     </camitk:inputs>
    </camitk:action>
   </camitk:onState>
  </onentry>
  <transition target="Apply Marching Cube" event="Back">
   <onTransition>
    <camitk:close>
     <camitk:component name="output-1.vtk" type="MeshComponent"/>
    </camitk:close>
   </onTransition>
  </transition>
  <transition target="Close output-1.vtk" event="Next"/>
 </state>
 
 <state id="Close output-1.vtk">
  <onentry>
   <camitk:onState>
    <camitk:description>Close the currently selected components</camitk:description>
    <camitk:action>
     <camitk:name>Close</camitk:name>
     <camitk:parameters/>
     <camitk:inputs>
      <camitk:component name="output-1.vtk" type="MeshComponent"/>
     </camitk:inputs>
    </camitk:action>
   </camitk:onState>
  </onentry>
  <transition target="Save Marching Cube Result as output-1.vtk" event="Back"/>
  <transition target="Bye" event="Next"/>
 </state>
 
 <state id="Bye" final="true">
  <onentry>
   <camitk:onState>
    <camitk:description><![CDATA[Thanks you for using the CamiTK Action State Machine !]]></camitk:description>
   </camitk:onState>
  </onentry>
  <transition target="Initialize" event="Back to the beginning">
   <onTransition>
    <camitk:close>
     <camitk:component name="image" type="ImageComponent"/>
     <camitk:component name="output-1.vtk" type="MeshComponent"/>
    </camitk:close>
   </onTransition>
  </transition>
 </state>
</scxml>
