blob: 61d4abc50003d5fa3dc376aa1e5878c3f0594d73 [file] [edit]
// Created on: 1996-07-03
// Created by: Joelle CHAUVET
// Copyright (c) 1996-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 <AdvApprox_PrefCutting.hxx>
#include <Precision.hxx>
AdvApprox_PrefCutting::AdvApprox_PrefCutting(const NCollection_Array1<double>& CutPnts)
: myPntOfCutting(1, CutPnts.Length())
{
myPntOfCutting = CutPnts;
}
bool AdvApprox_PrefCutting::Value(const double a, const double b, double& cuttingvalue) const
{
// Minimum length of a parametric interval: PConfusion()
// for F(U,V): EPS1=1.e-9 (cf. MMEPS1)
constexpr double lgmin = 10 * Precision::PConfusion();
int i;
double cut, mil = (a + b) / 2, dist = std::abs((a - b) / 2);
cut = mil;
for (i = myPntOfCutting.Lower(); i <= myPntOfCutting.Upper(); i++)
{
if ((dist - lgmin) > std::abs(mil - myPntOfCutting.Value(i)))
{
cut = myPntOfCutting.Value(i);
dist = std::abs(mil - myPntOfCutting.Value(i));
}
}
cuttingvalue = cut;
return (std::abs(cut - a) >= lgmin && std::abs(b - cut) >= lgmin);
}