namespace X3DTK {
namespace MESH {

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

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

template<class MData, class VData, class EData, class FData, bool RW>
void TemplateEdgesDrawer<MData, VData, EData, FData, RW>::draw(X3DNode *N, bool selection)
{
  #ifdef TEMPLATE_SPECIALIZATION_SUPPORTED
  if (VData::template find<MESH::VertexPointData>())
  #endif
  {
    Singleton<TemplateEdgesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->setSelectionMode(selection);
    Singleton<TemplateEdgesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->init();
    traverse(N);
    Singleton<TemplateEdgesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->finish(); 
  }  
}

template<class MData, class VData, class EData, class FData, bool RW>
TemplateVertex<MData, VData, EData, FData, RW> *TemplateEdgesDrawer<MData, VData, EData, FData, RW>::getVertex(int i) const 
{
  return Singleton<TemplateEdgesDrawerStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getVertex(i);
}

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

}
}  
