namespace X3DTK {
namespace MESH {

template<class MData, class VData, class EData, class FData, bool RW>
TemplateVerticesDrawer<MData, VData, EData, FData, RW>::TemplateVerticesDrawer()
: X3DOnePassProcessor()
{
  setGraphTraversal(new DFSGraphTraversal());
  setComponentVisitor(new TemplateVerticesDrawerCoreVisitor<MData, VData, EData, FData, RW>());
}

template<class MData, class VData, class EData, class FData, bool RW>
TemplateVerticesDrawer<MData, VData, EData, FData, RW>::~TemplateVerticesDrawer()
{
  Singleton<TemplateVerticesDrawerStateVariables<MData, VData, EData, FData, RW> >::removeInstance();
}

template<class MData, class VData, class EData, class FData, bool RW>
void TemplateVerticesDrawer<MData, VData, EData, FData, RW>::draw(X3DNode *N, bool selection)
{
  Singleton<TemplateVerticesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->setSelectionMode(selection);
  Singleton<TemplateVerticesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->init();
  traverse(N);
  Singleton<TemplateVerticesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->finish();
}

template<class MData, class VData, class EData, class FData, bool RW>
TemplateMesh<MData, VData, EData, FData, RW> *TemplateVerticesDrawer<MData, VData, EData, FData, RW>::getMesh(int i) const 
{
  return Singleton<TemplateVerticesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getMesh(i);
}

template<class MData, class VData, class EData, class FData, bool RW>
const SFMatrix34f &TemplateVerticesDrawer<MData, VData, EData, FData, RW>::getMatrix(int i) const 
{
  return Singleton<TemplateVerticesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getMatrix(i);
}

}
}
