// 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 <StdFail_NotDone.hxx>
#include <IntSurf_LineOn2S.hxx>

inline Standard_Boolean IntWalk_PWalking::IsDone() const {
  return done; 
}

inline Standard_Integer IntWalk_PWalking::NbPoints() const {
  if(!done) throw StdFail_NotDone();
  return line->NbPoints();
}

inline const IntSurf_PntOn2S& IntWalk_PWalking::Value
  (const Standard_Integer Index) const
{
  if (!done) throw StdFail_NotDone();
  return line->Value(Index);
}


inline const Handle(IntSurf_LineOn2S)& IntWalk_PWalking::Line () const {

  if (!done) throw StdFail_NotDone();
  return line;
}


inline Standard_Boolean IntWalk_PWalking::TangentAtFirst() const{ 
  if(!done) throw StdFail_NotDone();
  return tgfirst;
}

inline Standard_Boolean IntWalk_PWalking::TangentAtLast() const{ 
  if(!done) throw StdFail_NotDone();
  return tglast;
}

inline Standard_Boolean IntWalk_PWalking::IsClosed() const{ 
  if(!done) throw StdFail_NotDone();
  return close;
}

inline const gp_Dir& IntWalk_PWalking::TangentAtLine(Standard_Integer& theIndex) const
{
  if(!done) throw StdFail_NotDone();
  theIndex = myTangentIdx;
  return tgdir;
}

#define REGLAGE 0

inline void IntWalk_PWalking::AddAPoint(const IntSurf_PntOn2S& POn2S) { 
#if REGLAGE
  Standard_Integer n=line->NbPoints()+1;
  if (n == 1)
  {
    std::cout << "Dump of WL" << std::endl;
  }

  if(n) { 
    Standard_Real u1,v1,u2,v2;
    POn2S.Parameters(u1,v1,u2,v2);
    printf("point p%d  %+10.20f %+10.20f %+10.20f\n",
           n, POn2S.Value().X(), POn2S.Value().Y(), POn2S.Value().Z());
    fflush(stdout);
  }
#endif
  line->Add(POn2S);
  myTangentIdx = Max(myTangentIdx, 1);
}


