// Created on: 1992-11-24
// 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 <IntCurve_IntConicConic.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
#include <Precision.hxx>

IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen()
{
  done = false;
}

//=================================================================================================

IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Lin2d&        Lin1,
                                                             const IntRes2d_Domain& D1,
                                                             const ThePCurve&       C2,
                                                             const IntRes2d_Domain& D2,
                                                             const double           TolConf,
                                                             const double           Tol)
{
  Perform(Lin1, D1, C2, D2, TolConf, Tol);
}

//=================================================================================================

IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Circ2d&       Circ1,
                                                             const IntRes2d_Domain& D1,
                                                             const ThePCurve&       C2,
                                                             const IntRes2d_Domain& D2,
                                                             const double           TolConf,
                                                             const double           Tol)
{
  Perform(Circ1, D1, C2, D2, TolConf, Tol);
}

//=================================================================================================

IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Parab2d&      Parab1,
                                                             const IntRes2d_Domain& D1,
                                                             const ThePCurve&       C2,
                                                             const IntRes2d_Domain& D2,
                                                             const double           TolConf,
                                                             const double           Tol)
{
  Perform(Parab1, D1, C2, D2, TolConf, Tol);
}

//=================================================================================================

IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Elips2d&      Elips1,
                                                             const IntRes2d_Domain& D1,
                                                             const ThePCurve&       C2,
                                                             const IntRes2d_Domain& D2,
                                                             const double           TolConf,
                                                             const double           Tol)
{
  Perform(Elips1, D1, C2, D2, TolConf, Tol);
}

//=================================================================================================

IntCurve_UserIntConicCurveGen::IntCurve_UserIntConicCurveGen(const gp_Hypr2d&       Hyper1,
                                                             const IntRes2d_Domain& D1,
                                                             const ThePCurve&       C2,
                                                             const IntRes2d_Domain& D2,
                                                             const double           TolConf,
                                                             const double           Tol)
{
  Perform(Hyper1, D1, C2, D2, TolConf, Tol);
}

//-------------------------------------------------------------------------------------

//=================================================================================================

void IntCurve_UserIntConicCurveGen::Perform(const gp_Lin2d&        Lin1,
                                            const IntRes2d_Domain& D1,
                                            const ThePCurve&       C2,
                                            const IntRes2d_Domain& D2,
                                            const double           TolConf,
                                            const double           Tol)
{
  this->ResetFields();
  int NbInterC2 = ThePCurveTool::NbIntervals(C2);
  if (NbInterC2 > 1)
  {
    double ParamInf, ParamSup;
    double D2FirstParam = D2.FirstParameter();
    double D2LastParam  = D2.LastParameter();
    bool   Ok           = true;
    param1inf           = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
    param1sup           = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
    param2inf           = ThePCurveTool::FirstParameter(C2);
    param2sup           = ThePCurveTool::LastParameter(C2);
    IntRes2d_Domain DomainC2NumInter;

    NCollection_Array1<double> Tab2(1, NbInterC2 + 1);
    ThePCurveTool::Intervals(C2, Tab2);

    for (int NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
    {
      ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
      if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
        Ok = false;
      else
      {
        if (ParamInf < D2FirstParam)
          ParamInf = D2FirstParam;
        if (ParamSup > D2LastParam)
          ParamSup = D2LastParam;
        if ((ParamSup - ParamInf) > RealEpsilon())
        {
          DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
                                     ParamInf,
                                     D2.FirstTolerance(),
                                     ThePCurveTool::Value(C2, ParamSup),
                                     ParamSup,
                                     D2.LastTolerance());
          InternalPerform(Lin1, D1, C2, DomainC2NumInter, TolConf, Tol, true);
        }
      }
    }
  }
  else
  {
    InternalPerform(Lin1, D1, C2, D2, TolConf, Tol, false);
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::Perform(const gp_Circ2d&       Circ1,
                                            const IntRes2d_Domain& D1,
                                            const ThePCurve&       C2,
                                            const IntRes2d_Domain& D2,
                                            const double           TolConf,
                                            const double           Tol)
{
  this->ResetFields();
  int NbInterC2 = ThePCurveTool::NbIntervals(C2);
  if (NbInterC2 > 1)
  {
    double ParamInf, ParamSup;
    double D2FirstParam = D2.FirstParameter();
    double D2LastParam  = D2.LastParameter();
    bool   Ok           = true;

    param1inf = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
    param1sup = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
    param2inf = ThePCurveTool::FirstParameter(C2);
    param2sup = ThePCurveTool::LastParameter(C2);
    IntRes2d_Domain DomainC2NumInter;

    NCollection_Array1<double> Tab2(1, NbInterC2 + 1);
    ThePCurveTool::Intervals(C2, Tab2);

    for (int NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
    {
      ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
      if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
        Ok = false;
      else
      {
        if (ParamInf < D2FirstParam)
          ParamInf = D2FirstParam;
        if (ParamSup > D2LastParam)
          ParamSup = D2LastParam;
        if ((ParamSup - ParamInf) > RealEpsilon())
        {
          DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
                                     ParamInf,
                                     D2.FirstTolerance(),
                                     ThePCurveTool::Value(C2, ParamSup),
                                     ParamSup,
                                     D2.LastTolerance());
          InternalPerform(Circ1, D1, C2, DomainC2NumInter, TolConf, Tol, true);
        }
      }
    }
  }
  else
  {
    InternalPerform(Circ1, D1, C2, D2, TolConf, Tol, false);
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::Perform(const gp_Parab2d&      Parab1,
                                            const IntRes2d_Domain& D1,
                                            const ThePCurve&       C2,
                                            const IntRes2d_Domain& D2,
                                            const double           TolConf,
                                            const double           Tol)
{
  this->ResetFields();
  int NbInterC2 = ThePCurveTool::NbIntervals(C2);
  if (NbInterC2 > 1)
  {
    double ParamInf, ParamSup;
    double D2FirstParam = D2.FirstParameter();
    double D2LastParam  = D2.LastParameter();
    bool   Ok           = true;
    param1inf           = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
    param1sup           = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
    param2inf           = ThePCurveTool::FirstParameter(C2);
    param2sup           = ThePCurveTool::LastParameter(C2);
    IntRes2d_Domain DomainC2NumInter;

    NCollection_Array1<double> Tab2(1, NbInterC2 + 1);
    ThePCurveTool::Intervals(C2, Tab2);

    for (int NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
    {
      ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
      if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
        Ok = false;
      else
      {
        if (ParamInf < D2FirstParam)
          ParamInf = D2FirstParam;
        if (ParamSup > D2LastParam)
          ParamSup = D2LastParam;
        if ((ParamSup - ParamInf) > RealEpsilon())
        {
          DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
                                     ParamInf,
                                     D2.FirstTolerance(),
                                     ThePCurveTool::Value(C2, ParamSup),
                                     ParamSup,
                                     D2.LastTolerance());
          InternalPerform(Parab1, D1, C2, DomainC2NumInter, TolConf, Tol, true);
        }
      }
    }
  }
  else
  {
    InternalPerform(Parab1, D1, C2, D2, TolConf, Tol, false);
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::Perform(const gp_Elips2d&      Elips1,
                                            const IntRes2d_Domain& D1,
                                            const ThePCurve&       C2,
                                            const IntRes2d_Domain& D2,
                                            const double           TolConf,
                                            const double           Tol)
{
  this->ResetFields();
  int NbInterC2 = ThePCurveTool::NbIntervals(C2);
  if (NbInterC2 > 1)
  {
    double ParamInf, ParamSup;
    double D2FirstParam = D2.FirstParameter();
    double D2LastParam  = D2.LastParameter();
    bool   Ok           = true;
    param1inf           = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
    param1sup           = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
    param2inf           = ThePCurveTool::FirstParameter(C2);
    param2sup           = ThePCurveTool::LastParameter(C2);
    IntRes2d_Domain DomainC2NumInter;

    NCollection_Array1<double> Tab2(1, NbInterC2 + 1);
    ThePCurveTool::Intervals(C2, Tab2);

    for (int NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
    {
      ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
      if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
        Ok = false;
      else
      {
        if (ParamInf < D2FirstParam)
          ParamInf = D2FirstParam;
        if (ParamSup > D2LastParam)
          ParamSup = D2LastParam;
        if ((ParamSup - ParamInf) > RealEpsilon())
        {
          DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
                                     ParamInf,
                                     D2.FirstTolerance(),
                                     ThePCurveTool::Value(C2, ParamSup),
                                     ParamSup,
                                     D2.LastTolerance());
          InternalPerform(Elips1, D1, C2, DomainC2NumInter, TolConf, Tol, true);
        }
      }
    }
  }
  else
  {
    InternalPerform(Elips1, D1, C2, D2, TolConf, Tol, false);
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::Perform(const gp_Hypr2d&       Hyper1,
                                            const IntRes2d_Domain& D1,
                                            const ThePCurve&       C2,
                                            const IntRes2d_Domain& D2,
                                            const double           TolConf,
                                            const double           Tol)
{
  this->ResetFields();
  int NbInterC2 = ThePCurveTool::NbIntervals(C2);
  if (NbInterC2 > 1)
  {
    double ParamInf, ParamSup;
    double D2FirstParam = D2.FirstParameter();
    double D2LastParam  = D2.LastParameter();
    bool   Ok           = true;
    param1inf           = (D1.HasFirstPoint()) ? D1.FirstParameter() : -Precision::Infinite();
    param1sup           = (D1.HasLastPoint()) ? D1.LastParameter() : Precision::Infinite();
    param2inf           = ThePCurveTool::FirstParameter(C2);
    param2sup           = ThePCurveTool::LastParameter(C2);
    IntRes2d_Domain DomainC2NumInter;

    NCollection_Array1<double> Tab2(1, NbInterC2 + 1);
    ThePCurveTool::Intervals(C2, Tab2);

    for (int NumInterC2 = 1; Ok && (NumInterC2 <= NbInterC2); NumInterC2++)
    {
      ThePCurveTool::GetInterval(C2, NumInterC2, Tab2, ParamInf, ParamSup);
      if ((ParamInf > D2LastParam) || (ParamSup < D2FirstParam))
        Ok = false;
      else
      {
        if (ParamInf < D2FirstParam)
          ParamInf = D2FirstParam;
        if (ParamSup > D2LastParam)
          ParamSup = D2LastParam;
        if ((ParamSup - ParamInf) > RealEpsilon())
        {
          DomainC2NumInter.SetValues(ThePCurveTool::Value(C2, ParamInf),
                                     ParamInf,
                                     D2.FirstTolerance(),
                                     ThePCurveTool::Value(C2, ParamSup),
                                     ParamSup,
                                     D2.LastTolerance());
          InternalPerform(Hyper1, D1, C2, DomainC2NumInter, TolConf, Tol, true);
        }
      }
    }
  }
  else
  {
    InternalPerform(Hyper1, D1, C2, D2, TolConf, Tol, false);
  }
}

//----------------------------------------------------------------------
//-- InternalPerform
//-- Suppose des Courbes Lin...Hypr
//-- Si Composite == True
//--     Les Resultats sont Ajoutes
//-- Sinon
//--     Les Resultats sont Copies
//----------------------------------------------------------------------
void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Lin2d&        Lin1,
                                                    const IntRes2d_Domain& D1,
                                                    const ThePCurve&       C2,
                                                    const IntRes2d_Domain& D2,
                                                    const double           TolConf,
                                                    const double           Tol,
                                                    const bool             Composite)
{

  GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);

  switch (typ2)
  {

    case GeomAbs_Line: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Lin1, D1, ThePCurveTool::Line(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Circle: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Lin1, D1, ThePCurveTool::Circle(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Ellipse: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Lin1, D1, ThePCurveTool::Ellipse(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Parabola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Lin1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Hyperbola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Lin1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    default: {
      intconicurv.SetReversedParameters(false);
      intconicurv.Perform(Lin1, D1, C2, D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconicurv);
      }
    }
    break;
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Circ2d&       Circ1,
                                                    const IntRes2d_Domain& D1,
                                                    const ThePCurve&       C2,
                                                    const IntRes2d_Domain& D2,
                                                    const double           TolConf,
                                                    const double           Tol,
                                                    const bool             Composite)
{

  GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);

  switch (typ2)
  {

    case GeomAbs_Line: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Line(C2), D2, Circ1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Circle: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Circ1, D1, ThePCurveTool::Circle(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Ellipse: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Circ1, D1, ThePCurveTool::Ellipse(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Parabola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Circ1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Hyperbola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Circ1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    default: {
      intconicurv.SetReversedParameters(false);
      intconicurv.Perform(Circ1, D1, C2, D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconicurv);
      }
    }
    break;
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Elips2d&      Elips1,
                                                    const IntRes2d_Domain& D1,
                                                    const ThePCurve&       C2,
                                                    const IntRes2d_Domain& D2,
                                                    const double           TolConf,
                                                    const double           Tol,
                                                    const bool             Composite)
{

  GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);

  switch (typ2)
  {

    case GeomAbs_Line: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Line(C2), D2, Elips1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Circle: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Circle(C2), D2, Elips1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Ellipse: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Elips1, D1, ThePCurveTool::Ellipse(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Parabola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Elips1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Hyperbola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Elips1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    default: {
      intconicurv.SetReversedParameters(false);
      intconicurv.Perform(Elips1, D1, C2, D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconicurv);
      }
    }
    break;
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Parab2d&      Parab1,
                                                    const IntRes2d_Domain& D1,
                                                    const ThePCurve&       C2,
                                                    const IntRes2d_Domain& D2,
                                                    const double           TolConf,
                                                    const double           Tol,
                                                    const bool             Composite)
{

  GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);

  switch (typ2)
  {

    case GeomAbs_Line: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Line(C2), D2, Parab1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Circle: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Circle(C2), D2, Parab1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Ellipse: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Ellipse(C2), D2, Parab1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Parabola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Parab1, D1, ThePCurveTool::Parabola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Hyperbola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Parab1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    default: {
      intconicurv.SetReversedParameters(false);
      intconicurv.Perform(Parab1, D1, C2, D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconicurv);
      }
    }
    break;
  }
}

//=================================================================================================

void IntCurve_UserIntConicCurveGen::InternalPerform(const gp_Hypr2d&       Hyper1,
                                                    const IntRes2d_Domain& D1,
                                                    const ThePCurve&       C2,
                                                    const IntRes2d_Domain& D2,
                                                    const double           TolConf,
                                                    const double           Tol,
                                                    const bool             Composite)
{

  GeomAbs_CurveType typ2 = ThePCurveTool::GetType(C2);

  switch (typ2)
  {

    case GeomAbs_Line: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Line(C2), D2, Hyper1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Circle: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Circle(C2), D2, Hyper1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Ellipse: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Ellipse(C2), D2, Hyper1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Parabola: {
      intconiconi.SetReversedParameters(true);
      intconiconi.Perform(ThePCurveTool::Parabola(C2), D2, Hyper1, D1, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    case GeomAbs_Hyperbola: {
      intconiconi.SetReversedParameters(false);
      intconiconi.Perform(Hyper1, D1, ThePCurveTool::Hyperbola(C2), D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconiconi, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconiconi);
      }
    }
    break;

    default: {
      intconicurv.SetReversedParameters(false);
      intconicurv.Perform(Hyper1, D1, C2, D2, TolConf, Tol);
      if (Composite)
      {
        this->Append(intconicurv, param1inf, param1sup, param2inf, param2sup);
      }
      else
      {
        this->SetValues(intconicurv);
      }
    }
    break;
  }
}

//--------------------------------------------------------------------------------
