1 // Created on: 1995-07-18
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Extrema_Curve2dTool.hxx>
18 #include <Adaptor2d_Curve2d.hxx>
19 #include <TColStd_HArray1OfReal.hxx>
20 #include <Precision.hxx>
21 #include <GCPnts_TangentialDeflection.hxx>
23 //=======================================================================
24 //function : DeflCurvIntervals
26 //=======================================================================
27 Handle(TColStd_HArray1OfReal)
28 Extrema_Curve2dTool::DeflCurvIntervals(const Adaptor2d_Curve2d& C)
30 const Standard_Real epsd = 1.e-3;
31 const Standard_Real maxdefl = 1.e3;
32 const Standard_Real mindefl = 1.e-3;
33 Handle(TColStd_HArray1OfReal) Intervals;
34 Standard_Integer nbpnts = 23, i;
36 Standard_Real tf = C.FirstParameter(), tl = C.LastParameter();
37 gp_Pnt2d aP = C.Value(tf);
38 for (i = 2; i <= nbpnts; ++i)
40 Standard_Real t = (tf * (nbpnts - i) + (i - 1) * tl) / (nbpnts - 1);
41 gp_Pnt2d aP1 = C.Value(t);
42 L += aP.Distance(aP1);
45 Standard_Real dLdt = L / (tl - tf);
46 if (L <= Precision::Confusion() || dLdt < epsd || (tl - tf) > 10000.)
49 Intervals = new TColStd_HArray1OfReal(1, nbpnts);
50 Intervals->SetValue(1, tf);
51 Intervals->SetValue(nbpnts, tl);
55 Standard_Real aDefl = Max(0.01 * L / (2. * M_PI), mindefl);
59 Intervals = new TColStd_HArray1OfReal(1, nbpnts);
60 Intervals->SetValue(1, tf);
61 Intervals->SetValue(nbpnts, tl);
64 Standard_Real aMinLen = Max(.00001*L, Precision::Confusion());
65 Standard_Real aTol = Max(0.00001*(tl - tf), Precision::PConfusion());
66 GCPnts_TangentialDeflection aPntGen(C, M_PI / 6, aDefl, 2, aTol, aMinLen);
67 nbpnts = aPntGen.NbPoints();
68 Intervals = new TColStd_HArray1OfReal(1, nbpnts);
69 for (i = 1; i <= nbpnts; ++i)
71 Intervals->SetValue(i, aPntGen.Parameter(i));