namespace X3DTK {
namespace MESH {

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

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

template<class MData, class VData, class EData, class FData, bool RW>
void TemplateStatsCalculator<MData, VData, EData, FData, RW>::calculate(X3DNode *N)
{
  Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->init();
  traverse(N);
  Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->finish(); 
}

template<class MData, class VData, class EData, class FData, bool RW>
void TemplateStatsCalculator<MData, VData, EData, FData, RW>::setSelectedNodes(const MFNode &selectedNodes)
{
  Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->setSelectedNodes(selectedNodes);
}

template<class MData, class VData, class EData, class FData, bool RW>
MFNode TemplateStatsCalculator<MData, VData, EData, FData, RW>::getSelectedNodes() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getSelectedNodes();
}

template<class MData, class VData, class EData, class FData, bool RW>
unsigned int TemplateStatsCalculator<MData, VData, EData, FData, RW>::getModelFaces() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getModelFaces();
}

template<class MData, class VData, class EData, class FData, bool RW>
unsigned int TemplateStatsCalculator<MData, VData, EData, FData, RW>::getModelVertices() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getModelVertices();
}

template<class MData, class VData, class EData, class FData, bool RW>
unsigned int TemplateStatsCalculator<MData, VData, EData, FData, RW>::getModelEdges() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getModelEdges();
}

template<class MData, class VData, class EData, class FData, bool RW>
unsigned int TemplateStatsCalculator<MData, VData, EData, FData, RW>::getFacesOf(SFNode N) const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getFacesOf(N);
}

template<class MData, class VData, class EData, class FData, bool RW>
unsigned int TemplateStatsCalculator<MData, VData, EData, FData, RW>::getVerticesOf(SFNode N) const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getVerticesOf(N);
}

template<class MData, class VData, class EData, class FData, bool RW>
unsigned int TemplateStatsCalculator<MData, VData, EData, FData, RW>::getEdgesOf(SFNode N) const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getEdgesOf(N);
}

template<class MData, class VData, class EData, class FData, bool RW>
const SFMatrix34f &TemplateStatsCalculator<MData, VData, EData, FData, RW>::getMatrixOf(SFNode N)
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getMatrixOf(N);
}

template<class MData, class VData, class EData, class FData, bool RW>
const TemplateMeshInfo<MData, VData, EData, FData, RW> &TemplateStatsCalculator<MData, VData, EData, FData, RW>::getModelMeshInfo() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getModelMeshInfo();
}

template<class MData, class VData, class EData, class FData, bool RW>
const std::list<std::pair<SFNode, TemplateMeshInfo<MData, VData, EData, FData, RW> > > &TemplateStatsCalculator<MData, VData, EData, FData, RW>::getMeshInfoList() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getMeshInfoList();
}

template<class MData, class VData, class EData, class FData, bool RW>
const TemplateVertexInfo<MData, VData, EData, FData, RW> &TemplateStatsCalculator<MData, VData, EData, FData, RW>::getModelVertexInfo() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getModelVertexInfo();
}

template<class MData, class VData, class EData, class FData, bool RW>
const std::list<std::pair<SFNode, TemplateVertexInfo<MData, VData, EData, FData, RW> > > &TemplateStatsCalculator<MData, VData, EData, FData, RW>::getVertexInfoList() const
{
  return Singleton<TemplateStatsCalculatorStateVariables<MData, VData, EData, FData, RW> >::getInstance()->getVertexInfoList();
}


}
}  
