/// This file is part of the X3DToolKit library
/// Copyright (C) 2002-2004  Yannick Le Goc (legoc@imag.fr)

/// http://artis.imag.fr/Members/Yannick.Legoc/X3D/

/// This library is free software; you can redistribute it and/or
/// modify it under the terms of the GNU Lesser General Public
/// License as published by the Free Software Foundation; either
/// version 2.1 of the License, or (at your option) any later version.

/// This library is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
/// Lesser General Public License for more details.

/// You should have received a copy of the GNU Lesser General Public
/// License along with this library; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#ifndef X3DTK_GL_TRIANGLESTRIPSET_H
#define X3DTK_GL_TRIANGLESTRIPSET_H

#include "GL_X3DComposedGeometryNode.h"

#include <vector>

namespace X3DTK {
namespace GL {

/*! \brief Class declared in <b><X3DTK/GL/scenegraph.h></b> providing the GL implementation
 *  of X3D::TriangleStripSet.
 *
 *  \ingroup GLSceneGraph
 */
 
class TriangleStripSet : public X3DComposedGeometryNode
{
public:
  /// Constructor.
  TriangleStripSet();
  /// Constructor.
  virtual ~TriangleStripSet();
  
  /// Sets the N3F_V3F vertexArrayArray.  
  void setN3F_V3F_vertexArrayArray(const std::vector<std::vector<N3F_V3F> > &N3F_V3F_vertexArrayArray);  
  /// Sets the N3F_V3F vertexStripArrayArray.  
  void setT2F_N3F_V3F_vertexArrayArray(const std::vector<std::vector<T2F_N3F_V3F> > &T2F_N3F_V3F_vertexArrayArray);  
  /// Sets the C4F_N3F_V3F vertexStripArrayArray.  
  void setC4F_N3F_V3F_vertexArrayArray(const std::vector<std::vector<C4F_N3F_V3F> > &C4F_N3F_V3F_vertexArrayArray);  
  /// Sets the C4F_N3F_V3F vertexStripArrayArray.  
  void setT2F_C4F_N3F_V3F_vertexArrayArray(const std::vector<std::vector<T2F_C4F_N3F_V3F> > &T2F_C4F_N3F_V3F_vertexArrayArray);  
  
  /// Gets the N3F_V3F vertexArrayArray.  
  inline std::vector<std::vector<N3F_V3F> > &N3F_V3F_vertexArrayArray() {return _N3F_V3F_vertexArrayArray;};  
  /// Gets the N3F_V3F vertexArrayArray.  
  inline std::vector<std::vector<T2F_N3F_V3F> > &T2F_N3F_V3F_vertexArrayArray() {return _T2F_N3F_V3F_vertexArrayArray;};  
  /// Gets the C4F_N3F_V3F vertexArrayArray.  
  inline std::vector<std::vector<C4F_N3F_V3F> > &C4F_N3F_V3F_vertexArrayArray() {return _C4F_N3F_V3F_vertexArrayArray;};  
  /// Gets the T2F_C4F_N3F_V3F vertexArrayArray.  
  inline std::vector<std::vector<T2F_C4F_N3F_V3F> > &T2F_C4F_N3F_V3F_vertexArrayArray() {return _T2F_C4F_N3F_V3F_vertexArrayArray;};  
  
  /// Sets the vertices duplicated attribute.
  void setVerticesDuplicated(bool value);
  /// Sets the vertices duplicated attribute.
  inline bool getVerticesDuplicated() const {return _verticesDuplicated;};
  
  /// Updates the attributes of the node.
  virtual void update();
  /// Renders the node in an openGL context.
  virtual void draw() const;  

private:    
  /// N3F_V3F vertexStripArrayArray.  
  std::vector<std::vector<N3F_V3F> > _N3F_V3F_vertexArrayArray;  
  /// N3F_V3F vertexStripArrayArray.  
  std::vector<std::vector<T2F_N3F_V3F> > _T2F_N3F_V3F_vertexArrayArray;  
  /// C4F_N3F_V3F vertexStripArrayArray.  
  std::vector<std::vector<C4F_N3F_V3F> > _C4F_N3F_V3F_vertexArrayArray;  
  /// C4F_N3F_V3F vertexStripArrayArray.  
  std::vector<std::vector<T2F_C4F_N3F_V3F> > _T2F_C4F_N3F_V3F_vertexArrayArray;  

  /// Computes the vertex Array with no color and no texCoord.
  void computeNoColorNoTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray);
  /// Computes the vertex Array with color and no texCoord.
  void computeColorNoTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray);
  /// Computes the vertex Array with no color and texCoord.
  void computeNoColorTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray);
  /// Computes the vertex Array with color and texCoord.
  void computeColorTexCoord(const MFVec3f &vertexArray, const MFVec3f &normalArray);
  /// Computes the normals.
  void computeArrays(const MFVec3f &vertexArray, MFVec3f &normalArray);

  bool _verticesDuplicated;

};

}
}

#endif
