/// 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_X3D_COORDINATEDEFORMER
#define X3DTK_X3D_COORDINATEDEFORMER

#include "X3DTypes.h"
#include "X3D_X3DGroupingNode.h"
#include "X3D_X3DBoundedObject.h"

namespace X3DTK {
namespace X3D {

/*! \brief Base class declared in <b><X3DTK/X3D/scenegraph.h></b>, part of the <a href="../../doc/X3DSpecs/Part01/components/nurbs.html">
 *  NURBS component</a> defining a CoordinateDeformer
 *  (<a href="../../doc/X3DSpecs/Part01/components/nurbs.html#CoordinateDeformer">
 *  documentation</a>).
 *
 *  \ingroup X3DSceneGraph
 */ 

class CoordinateDeformer : public X3DGroupingNode, public X3DBoundedObject
{
public:
  /// Constructor.
  CoordinateDeformer();
  /// Constructs a CoordinateDeformer from it attribute.
  CoordinateDeformer(const MFVec3f &controlPoint,
                     const MFNode  &inputCoord,
                     const MFNode  &inputTransform,
                     const MFNode  &outputCoord,
                     const MFFloat &weight);
  /// Clones the node.
  virtual SFNode clone() const;
  /// Virtual destructor.
  virtual ~CoordinateDeformer();
  
  /// Gets the children list.
  virtual MFNode getChildList() const;
      
  /// Adds a child to the Children attribute. Returns TRUE if succeeds.
  virtual bool addChild(const SFNode &N);
  /// Sets the child. Behaves like addChild.
  virtual bool setChild(const SFNode &N);
  
  /// Sets the controlPoint attribute.
  void setControlPoint(const MFVec3f &controlPoint);
  /// Sets the inputCoord attribute.
  void setInputCoord(const MFNode &inputCoord);
  /// Sets the inputTransform attribute.
  void setInputTransform(const MFNode &inputTransform);
  /// Sets the outputCoord attribute.
  void setOutputCoord(const MFNode &outputCoord);
  /// Sets the weight attribute.
  void setWeight(const MFFloat &weight);
  
  /// Gets the controlPoint attribute.
  inline const MFVec3f &getControlPoint() const {return _controlPoint;};
  /// Gets the inputCoord attribute.
  inline const MFNode &getInputCoord() const {return _inputCoord;};
  /// Gets the inputTransform attribute.
  inline const MFNode &getInputTransform() const {return _inputTransform;};
  /// Gets the outputCoord attribute.
  inline const MFNode &getOutputCoord() const {return _outputCoord;};
  /// Gets the weight attribute.
  inline const MFFloat &getWeight() const {return _weight;};
  
  /// Loads the attributes from a X3DFileElement e.
  virtual void load(const X3DFileElement *element);
  /// Writes the attributes of the node.
  virtual SFString &write(SFString &output) const;

protected:
  /// Copy constructor.  
  CoordinateDeformer(const CoordinateDeformer &N);

private:
  /// Set of control points of dimension _uDimension * _vDimension.
  MFVec3f _controlPoint;
  /// Set of Coordinate nodes.
  MFNode _inputCoord;
  /// Set of Transform nodes.
  MFNode _inputTransform;
  /// Set of Coordinate nodes.
  MFNode _outputCoord;
  /// Weight value assigned to each control point.
  MFFloat _weight;
  /// Number of control points in the u direction.
  SFInt32 _uDimension;
  /// Knot vector in the u direction.
  MFDouble _uKnot;
  /// Order in the u direction.
  SFInt32 _uOrder;
  /// Number of control points in the v direction.
  SFInt32 _vDimension;
  /// Knot vector in the v direction.
  MFDouble _vKnot;
  /// Order in the v direction.
  SFInt32 _vOrder;
  /// Number of control points in the w direction.
  SFInt32 _wDimension;
  /// Knot vector in the w direction.
  MFDouble _wKnot;
  /// Order in the w direction.
  SFInt32 _wOrder;
};

}
}

#endif
