// Created on: 1993-08-18
// Created by: Christophe MARION
// Copyright (c) 1993-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 "gp_Pnt.hxx"
#include "gp_Vec.hxx"
#include "gp_Lin.hxx"
#include "gp_Circ.hxx"
#include "gp_Elips.hxx"
#include "gp_Hypr.hxx"
#include "gp_Parab.hxx"
#include "ElCLib.hxx"

#include "NCollection_Array1.hxx"
#include "NCollection_HArray1.hxx"

inline double HLRBRep_LineTool::FirstParameter(const gp_Lin&)
{
  return RealFirst();
}

inline double HLRBRep_LineTool::LastParameter(const gp_Lin&)
{
  return RealLast();
}

inline GeomAbs_Shape HLRBRep_LineTool::Continuity(const gp_Lin&)
{
  return GeomAbs_CN;
}

inline int HLRBRep_LineTool::NbIntervals(const gp_Lin&, const GeomAbs_Shape)
{
  return 1;
}

inline void HLRBRep_LineTool::Intervals(const gp_Lin&,
                                        NCollection_Array1<double>&,
                                        const GeomAbs_Shape)
{
}

inline double HLRBRep_LineTool::IntervalFirst(const gp_Lin&)
{
  return RealFirst();
}

inline double HLRBRep_LineTool::IntervalLast(const gp_Lin&)
{
  return RealLast();
}

inline GeomAbs_Shape HLRBRep_LineTool::IntervalContinuity(const gp_Lin&)
{
  return GeomAbs_CN;
}

inline bool HLRBRep_LineTool::IsClosed(const gp_Lin&)
{
  return false;
}

inline bool HLRBRep_LineTool::IsPeriodic(const gp_Lin&)
{
  return false;
}

inline double HLRBRep_LineTool::Period(const gp_Lin&)
{
  return 0.;
}

inline gp_Pnt HLRBRep_LineTool::Value(const gp_Lin& C, const double U)
{
  return ElCLib::Value(U, C);
}

inline void HLRBRep_LineTool::D0(const gp_Lin& C, const double U, gp_Pnt& P)
{
  P = ElCLib::Value(U, C);
}

inline void HLRBRep_LineTool::D1(const gp_Lin& C, const double U, gp_Pnt& P, gp_Vec& V)
{
  ElCLib::D1(U, C, P, V);
}

inline void HLRBRep_LineTool::D2(const gp_Lin& C, const double U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2)
{
  ElCLib::D1(U, C, P, V1);
  V2 = gp_Vec(0, 0, 0);
}

inline void HLRBRep_LineTool::D3(const gp_Lin& C,
                                 const double  U,
                                 gp_Pnt&       P,
                                 gp_Vec&       V1,
                                 gp_Vec&       V2,
                                 gp_Vec&       V3)
{
  ElCLib::D1(U, C, P, V1);
  V2 = V3 = gp_Vec(0, 0, 0);
}

inline gp_Vec HLRBRep_LineTool::DN(const gp_Lin& C, const double U, const int N)
{
  return ElCLib::DN(U, C, N);
}

inline double HLRBRep_LineTool::Resolution(const gp_Lin&, const double R3D)
{
  return R3D;
}

inline GeomAbs_CurveType HLRBRep_LineTool::GetType(const gp_Lin&)
{
  return GeomAbs_Line;
}

inline gp_Lin HLRBRep_LineTool::Line(const gp_Lin& C)
{
  return C;
}

inline gp_Circ HLRBRep_LineTool::Circle(const gp_Lin&)
{
  return gp_Circ();
}

inline gp_Elips HLRBRep_LineTool::Ellipse(const gp_Lin&)
{
  return gp_Elips();
}

inline gp_Hypr HLRBRep_LineTool::Hyperbola(const gp_Lin&)
{
  return gp_Hypr();
}

inline gp_Parab HLRBRep_LineTool::Parabola(const gp_Lin&)
{
  return gp_Parab();
}

inline occ::handle<Geom_BezierCurve> HLRBRep_LineTool::Bezier(const gp_Lin&)
{
  occ::handle<Geom_BezierCurve> NullCurve;
  return NullCurve;
}

inline occ::handle<Geom_BSplineCurve> HLRBRep_LineTool::BSpline(const gp_Lin&)
{
  occ::handle<Geom_BSplineCurve> NullCurve;
  return NullCurve;
}

inline int HLRBRep_LineTool::Degree(const gp_Lin&)
{
  return 1;
}

inline int HLRBRep_LineTool::NbPoles(const gp_Lin&)
{
  return 0;
}

inline void HLRBRep_LineTool::Poles(const gp_Lin&, NCollection_Array1<gp_Pnt>&) {}

inline bool HLRBRep_LineTool::IsRational(const gp_Lin&)
{
  return false;
}

inline void HLRBRep_LineTool::PolesAndWeights(const gp_Lin&,
                                              NCollection_Array1<gp_Pnt>&,
                                              NCollection_Array1<double>&)
{
}

inline int HLRBRep_LineTool::NbKnots(const gp_Lin&)
{
  return 0;
}

inline void HLRBRep_LineTool::KnotsAndMultiplicities(const gp_Lin&,
                                                     NCollection_Array1<double>&,
                                                     NCollection_Array1<int>&)
{
}

inline int HLRBRep_LineTool::NbSamples(const gp_Lin&, const double, const double)
{
  return 3;
}

inline occ::handle<NCollection_HArray1<double>> HLRBRep_LineTool::SamplePars(const gp_Lin&,
                                                                             const double U0,
                                                                             const double U1,
                                                                             const double,
                                                                             const int)
{
  occ::handle<NCollection_HArray1<double>> aPars = new NCollection_HArray1<double>(1, 3);
  aPars->SetValue(1, U0);
  aPars->SetValue(2, (U0 + U1) * 0.5);
  aPars->SetValue(3, U1);
  return aPars;
}

inline void HLRBRep_LineTool::SamplePars(const gp_Lin&                             C,
                                         const double                              U0,
                                         const double                              U1,
                                         const double                              Defl,
                                         const int                                 NbMin,
                                         occ::handle<NCollection_HArray1<double>>& Pars)
{
  Pars = SamplePars(C, U0, U1, Defl, NbMin);
}
