// Created on: 1995-01-27
// Created by: Jacques GOUSSARD
// Copyright (c) 1995-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 "IntPatch_Point.hxx"
#include "Geom_Surface.hxx"

//=================================================================================================

inline GeomInt_IntSS::GeomInt_IntSS()
    : myNbrestr(0),
      myTolReached2d(0.0),
      myTolReached3d(0.0),
      myTolCheck(1.e-7),
      myTolAngCheck(1.e-6)
{
}

//=================================================================================================

inline GeomInt_IntSS::GeomInt_IntSS(const occ::handle<Geom_Surface>& S1,
                                    const occ::handle<Geom_Surface>& S2,
                                    const double                     Tol,
                                    const bool                       Approx,
                                    const bool                       ApproxS1,
                                    const bool                       ApproxS2)
    : myNbrestr(0),
      myTolReached2d(0.0),
      myTolReached3d(0.0),
      myTolCheck(1.e-7),
      myTolAngCheck(1.e-6)
{
  Perform(S1, S2, Tol, Approx, ApproxS1, ApproxS2);
}

//=======================================================================
// function : Perform
// purpose  : Intersection of Adapted surfaces
//=======================================================================
inline void GeomInt_IntSS::Perform(const occ::handle<GeomAdaptor_Surface>& HS1,
                                   const occ::handle<GeomAdaptor_Surface>& HS2,
                                   const double                            Tol,
                                   const bool                              Approx,
                                   const bool                              ApproxS1,
                                   const bool                              ApproxS2)
{
  myHS1 = HS1;
  myHS2 = HS2;
  InternalPerform(Tol, Approx, ApproxS1, ApproxS2, false, 0., 0., 0., 0.);
}

//=======================================================================
// function : Perform
// purpose  : Intersection of Adapted surfaces with a Starting Point
//=======================================================================
inline void GeomInt_IntSS::Perform(const occ::handle<GeomAdaptor_Surface>& HS1,
                                   const occ::handle<GeomAdaptor_Surface>& HS2,
                                   const double                            Tol,
                                   const double                            U1,
                                   const double                            V1,
                                   const double                            U2,
                                   const double                            V2,
                                   const bool                              Approx,
                                   const bool                              ApproxS1,
                                   const bool                              ApproxS2)
{
  myHS1 = HS1;
  myHS2 = HS2;
  InternalPerform(Tol, Approx, ApproxS1, ApproxS2, true, U1, V1, U2, V2);
}

//=================================================================================================

inline bool GeomInt_IntSS::IsDone() const
{
  return myIntersector.IsDone();
}

//=================================================================================================

inline double GeomInt_IntSS::TolReached2d() const
{
  return myTolReached2d;
}

//=================================================================================================

inline double GeomInt_IntSS::TolReached3d() const
{
  return myTolReached3d;
}

//=================================================================================================

inline int GeomInt_IntSS::NbLines() const
{
  return sline.Length() - myNbrestr;
}

//=================================================================================================

inline int GeomInt_IntSS::NbBoundaries() const
{
  StdFail_NotDone_Raise_if(!myIntersector.IsDone(), "GeomInt_IntSS::NbBoundaries() - no result");
  return myNbrestr;
}

//=================================================================================================

inline int GeomInt_IntSS::NbPoints() const
{
  return myIntersector.NbPnts();
}

//=================================================================================================

inline gp_Pnt GeomInt_IntSS::Point(const int Index) const
{
  return myIntersector.Point(Index).Value();
}
