namespace X3DTK {
namespace MESH {

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

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

template<class MData, class VData, class EData, class FData, bool RW>
void TemplateNormalsInverter<MData, VData, EData, FData, RW>::invert(Scene *S)
{
  invert(static_cast<X3DNode *>(S));
  
  S->getProcessHistory().addEntry("MESH::TemplateNormalsInverter");
}

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

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

}
}  
