// Created on: 1992-10-22
// Created by: Laurent BUCHARD
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _Geom2dInt_Geom2dCurveTool_HeaderFile
#define _Geom2dInt_Geom2dCurveTool_HeaderFile

#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>

#include <GeomAbs_CurveType.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
#include <Standard_Integer.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
#include <NCollection_Array1.hxx>
class Adaptor2d_Curve2d;
class gp_Pnt2d;
class gp_Vec2d;

//! This class provides a Geom2dCurveTool as < Geom2dCurveTool from IntCurve >
//! from a Tool as < Geom2dCurveTool from Adaptor3d > .
class Geom2dInt_Geom2dCurveTool
{
public:
  DEFINE_STANDARD_ALLOC

  static GeomAbs_CurveType GetType(const Adaptor2d_Curve2d& C);

  static bool IsComposite(const Adaptor2d_Curve2d& C);

  //! Returns the Lin2d from gp corresponding to the curve C.
  //! This method is called only when TheType returns
  //! GeomAbs_Line.
  static gp_Lin2d Line(const Adaptor2d_Curve2d& C);

  //! Returns the Circ2d from gp corresponding to the curve C.
  //! This method is called only when TheType returns
  //! GeomAbs_Circle.
  static gp_Circ2d Circle(const Adaptor2d_Curve2d& C);

  //! Returns the Elips2d from gp corresponding to the curve C.
  //! This method is called only when TheType returns
  //! GeomAbs_Ellipse.
  static gp_Elips2d Ellipse(const Adaptor2d_Curve2d& C);

  //! Returns the Parab2d from gp corresponding to the curve C.
  //! This method is called only when TheType returns
  //! GeomAbs_Parabola.
  static gp_Parab2d Parabola(const Adaptor2d_Curve2d& C);

  //! Returns the Hypr2d from gp corresponding to the curve C.
  //! This method is called only when TheType returns
  //! GeomAbs_Hyperbola.
  static gp_Hypr2d Hyperbola(const Adaptor2d_Curve2d& C);

  static double EpsX(const Adaptor2d_Curve2d& C);

  static double EpsX(const Adaptor2d_Curve2d& C, const double Eps_XYZ);

  Standard_EXPORT static int NbSamples(const Adaptor2d_Curve2d& C);

  Standard_EXPORT static int NbSamples(const Adaptor2d_Curve2d& C,
                                       const double             U0,
                                       const double             U1);

  static double FirstParameter(const Adaptor2d_Curve2d& C);

  static double LastParameter(const Adaptor2d_Curve2d& C);

  static gp_Pnt2d Value(const Adaptor2d_Curve2d& C, const double X);

  static void D0(const Adaptor2d_Curve2d& C, const double U, gp_Pnt2d& P);

  static void D1(const Adaptor2d_Curve2d& C, const double U, gp_Pnt2d& P, gp_Vec2d& T);

  static void D2(const Adaptor2d_Curve2d& C, const double U, gp_Pnt2d& P, gp_Vec2d& T, gp_Vec2d& N);

  static void D3(const Adaptor2d_Curve2d& C,
                 const double             U,
                 gp_Pnt2d&                P,
                 gp_Vec2d&                T,
                 gp_Vec2d&                N,
                 gp_Vec2d&                V);

  static gp_Vec2d DN(const Adaptor2d_Curve2d& C, const double U, const int N);

  //! output the number of interval of continuity C2 of
  //! the curve
  static int NbIntervals(const Adaptor2d_Curve2d& C);

  //! compute Tab.
  static void Intervals(const Adaptor2d_Curve2d& C, NCollection_Array1<double>& Tab);

  //! output the bounds of interval of index <Index>
  //! used if Type == Composite.
  static void GetInterval(const Adaptor2d_Curve2d&          C,
                          const int                         Index,
                          const NCollection_Array1<double>& Tab,
                          double&                           U1,
                          double&                           U2);

  static int Degree(const Adaptor2d_Curve2d& C);
};

#include <Geom2dInt_Geom2dCurveTool.lxx>

#endif // _Geom2dInt_Geom2dCurveTool_HeaderFile
