// Created on: 1992-04-06
// Created by: Jacques GOUSSARD
// 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 "Standard_DomainError.hxx"

#include "gp_Lin.hxx"
#include "gp_Circ.hxx"
#include "gp_Elips.hxx"
#include "gp_Parab.hxx"
#include "gp_Hypr.hxx"

#include "Precision.hxx"

inline void IntPatch_GLine::SetFirstPoint(const int IndFirst)
{
  fipt = true;
  indf = IndFirst;
}

inline void IntPatch_GLine::SetLastPoint(const int IndLast)
{
  lapt = true;
  indl = IndLast;
}

inline gp_Lin IntPatch_GLine::Line() const
{
  if (typ != IntPatch_Lin)
  {
    throw Standard_DomainError();
  }
  return gp_Lin(pos.Axis());
}

inline gp_Circ IntPatch_GLine::Circle() const
{
  if (typ != IntPatch_Circle)
  {
    throw Standard_DomainError();
  }
  return gp_Circ(pos, par1);
}

inline gp_Elips IntPatch_GLine::Ellipse() const
{
  if (typ != IntPatch_Ellipse)
  {
    throw Standard_DomainError();
  }
  return gp_Elips(pos, par1, par2);
}

inline gp_Parab IntPatch_GLine::Parabola() const
{
  if (typ != IntPatch_Parabola)
  {
    throw Standard_DomainError();
  }
  return gp_Parab(pos, par1);
}

inline gp_Hypr IntPatch_GLine::Hyperbola() const
{
  if (typ != IntPatch_Hyperbola)
  {
    throw Standard_DomainError();
  }
  return gp_Hypr(pos, par1, par2);
}

inline bool IntPatch_GLine::HasFirstPoint() const
{
  return fipt;
}

inline bool IntPatch_GLine::HasLastPoint() const
{
  return lapt;
}

inline const IntPatch_Point& IntPatch_GLine::FirstPoint() const
{
  if (!fipt)
  {
    throw Standard_DomainError();
  }
  return svtx(indf);
}

inline const IntPatch_Point& IntPatch_GLine::LastPoint() const
{
  if (!lapt)
  {
    throw Standard_DomainError();
  }
  return svtx(indl);
}

inline int IntPatch_GLine::NbVertex() const
{
  return svtx.Length();
}

inline const IntPatch_Point& IntPatch_GLine::Vertex(const int Index) const
{
  return svtx(Index);
}
