namespace X3DTK {
namespace MESH {

template<class MData, class VData, class EData, class FData, bool RW>
TemplateMeshSimplifier<MData, VData, EData, FData, RW>::TemplateMeshSimplifier()
: X3DOnePassProcessor()
{
  setGraphTraversal(new DFSGraphTraversal());
  setComponentVisitor(new TemplateMeshSimplifierCoreVisitor<MData, VData, EData, FData, RW>());
}
template<class MData, class VData, class EData, class FData, bool RW>
TemplateMeshSimplifier<MData, VData, EData, FData, RW>::~TemplateMeshSimplifier()
{
  Singleton<TemplateMeshSimplifierStateVariables<MData, VData, EData, FData, RW> >::removeInstance();
}
template<class MData, class VData, class EData, class FData, bool RW>
TemplateMesh<MData, VData, EData, FData, RW> *TemplateMeshSimplifier<MData, VData, EData, FData, RW>::build(Scene *S)
{
  Singleton<TemplateMeshSimplifierStateVariables<MData, VData, EData, FData, RW> >::getInstance()->init();
  traverse(S);
  Singleton<TemplateMeshSimplifierStateVariables<MData, VData, EData, FData, RW> >::getInstance()->finish(); 
  
  return Singleton<TemplateMeshSimplifierStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getMesh();
}

}
}  
