// 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.

#include "HLRBRep_Curve.hxx"
#include "GeomAbs_CurveType.hxx"
#include "GeomAbs_Shape.hxx"
#include "gp_Vec2d.hxx"
#include "gp_Lin2d.hxx"
#include "gp_Circ2d.hxx"
#include "gp_Elips2d.hxx"
#include "gp_Parab2d.hxx"
#include "gp_Hypr2d.hxx"
#include "Geom2d_BezierCurve.hxx"
#include "Geom2d_BSplineCurve.hxx"
#include "NCollection_Array1.hxx"

#define IS_C2_COMPOSITE 0

//=================================================================================================

inline double HLRBRep_CurveTool::FirstParameter(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->FirstParameter());
}

//=================================================================================================

inline double HLRBRep_CurveTool::LastParameter(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->LastParameter());
}

//=================================================================================================

inline GeomAbs_Shape HLRBRep_CurveTool::Continuity(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Continuity());
}

//=================================================================================================

inline int HLRBRep_CurveTool::NbIntervals(const HLRBRep_CurvePtr C)
{
#if IS_C2_COMPOSITE
  return (((HLRBRep_Curve*)C)->NbIntervals(GeomAbs_C2));
#else
  return (((HLRBRep_Curve*)C)->NbIntervals(GeomAbs_C1));
#endif
}

//=================================================================================================

inline void HLRBRep_CurveTool::Intervals(const HLRBRep_CurvePtr C, NCollection_Array1<double>& Tab)
{
#if IS_C2_COMPOSITE
  ((HLRBRep_Curve*)C)->Intervals(Tab, GeomAbs_C2);
#else
  ((HLRBRep_Curve*)C)->Intervals(Tab, GeomAbs_C1);
#endif
}

//=================================================================================================

inline void HLRBRep_CurveTool::GetInterval(const HLRBRep_CurvePtr /*C*/,
                                           const int                         i,
                                           const NCollection_Array1<double>& Tab,
                                           double&                           a,
                                           double&                           b)
{
  a = Tab.Value(i);
  b = Tab.Value(i + 1);
}

//=================================================================================================

inline bool HLRBRep_CurveTool::IsClosed(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->IsClosed());
}

//=================================================================================================

inline bool HLRBRep_CurveTool::IsPeriodic(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->IsPeriodic());
}

//=================================================================================================

inline double HLRBRep_CurveTool::Period(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Period());
}

//=================================================================================================

inline gp_Pnt2d HLRBRep_CurveTool::Value(const HLRBRep_CurvePtr C, const double U)
{
  return (((HLRBRep_Curve*)C)->Value(U));
}

//=================================================================================================

inline void HLRBRep_CurveTool::D0(const HLRBRep_CurvePtr C, const double U, gp_Pnt2d& P)
{
  ((HLRBRep_Curve*)C)->D0(U, P);
}

//=================================================================================================

inline void HLRBRep_CurveTool::D1(const HLRBRep_CurvePtr C,
                                  const double           U,
                                  gp_Pnt2d&              P,
                                  gp_Vec2d&              T)
{
  ((HLRBRep_Curve*)C)->D1(U, P, T);
}

//=================================================================================================

inline void HLRBRep_CurveTool::D2(const HLRBRep_CurvePtr C,
                                  const double           U,
                                  gp_Pnt2d&              P,
                                  gp_Vec2d&              T,
                                  gp_Vec2d&              N)
{
  ((HLRBRep_Curve*)C)->D2(U, P, T, N);
}

//=================================================================================================

inline void HLRBRep_CurveTool::D3(const HLRBRep_CurvePtr C,
                                  const double           U,
                                  gp_Pnt2d&              P,
                                  gp_Vec2d&              V1,
                                  gp_Vec2d&              V2,
                                  gp_Vec2d&              V3)
{
  ((HLRBRep_Curve*)C)->D3(U, P, V1, V2, V3);
}

//=================================================================================================

inline gp_Vec2d HLRBRep_CurveTool::DN(const HLRBRep_CurvePtr C, const double U, const int N)
{
  return (((HLRBRep_Curve*)C)->DN(U, N));
}

//=================================================================================================

inline double HLRBRep_CurveTool::Resolution(const HLRBRep_CurvePtr C, const double R3d)
{
  return (((HLRBRep_Curve*)C)->Resolution(R3d));
}

//=================================================================================================

inline GeomAbs_CurveType HLRBRep_CurveTool::GetType(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->GetType());
}

//=================================================================================================

inline GeomAbs_CurveType HLRBRep_CurveTool::TheType(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->GetType());
}

//=================================================================================================

inline gp_Lin2d HLRBRep_CurveTool::Line(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Line());
}

//=================================================================================================

inline gp_Circ2d HLRBRep_CurveTool::Circle(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Circle());
}

//=================================================================================================

inline gp_Elips2d HLRBRep_CurveTool::Ellipse(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Ellipse());
}

//=================================================================================================

inline gp_Parab2d HLRBRep_CurveTool::Parabola(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Parabola());
}

//=================================================================================================

inline gp_Hypr2d HLRBRep_CurveTool::Hyperbola(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Hyperbola());
}

//=================================================================================================

inline occ::handle<Geom2d_BezierCurve> HLRBRep_CurveTool::Bezier(const HLRBRep_CurvePtr /*C*/)
{
#ifdef OCCT_DEBUG
  std::cout << "  HLRBRep_CurveTool::Bezier : Not Implemented " << std::endl;
#endif
  //-- return(((HLRBRep_Curve *)C)->Bezier());
  return (nullptr);
}

//=================================================================================================

inline occ::handle<Geom2d_BSplineCurve> HLRBRep_CurveTool::BSpline(const HLRBRep_CurvePtr /*C*/)
{
#ifdef OCCT_DEBUG
  std::cout << "  HLRBRep_CurveTool::BSpline : Not Implemented " << std::endl;
#endif
  //-- return(((HLRBRep_Curve *)C)->BSpline());
  return (nullptr);
}

//=================================================================================================

inline double HLRBRep_CurveTool::EpsX(const HLRBRep_CurvePtr /*C*/)
{
  return (1e-10);
}

//=================================================================================================

inline int HLRBRep_CurveTool::Degree(const HLRBRep_CurvePtr C)
{
  return (((HLRBRep_Curve*)C)->Degree());
}
