namespace X3DTK {
namespace MESH {

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

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

template<class MData, class VData, class EData, class FData, bool RW>
X3D::X3DNode *TemplateX3DBuilder<MData, VData, EData, FData, RW>::build(SFNode N)
{
  Singleton<TemplateX3DBuilderStateVariables<MData, VData, EData, FData, RW> >::getInstance()->init();
  traverse(N);
  Singleton<TemplateX3DBuilderStateVariables<MData, VData, EData, FData, RW> >::getInstance()->finish();

  return Singleton<TemplateX3DBuilderStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getRoot();
}

template<class MData, class VData, class EData, class FData, bool RW>
X3D::Scene *TemplateX3DBuilder<MData, VData, EData, FData, RW>::build(Scene *S)
{
  return static_cast<X3D::Scene *>(build(static_cast<SFNode>(S)));
}

}
}


