1 // Copyright (c) 2014-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <GCPnts_DistFunction.hxx>
17 //=======================================================================
18 //function : MaxCurvLinDist
20 //=======================================================================
21 GCPnts_DistFunction::GCPnts_DistFunction(const Adaptor3d_Curve& theCurve,
22 const Standard_Real U1, const Standard_Real U2)
26 gp_Pnt P1 = theCurve.Value(U1), P2 = theCurve.Value(U2);
27 if (P1.SquareDistance(P2) > gp::Resolution())
29 myLin = gp_Lin(P1, P2.XYZ() - P1.XYZ());
34 theCurve.D0(U1 + .01*(U2-U1), P2);
35 myLin = gp_Lin(P1, P2.XYZ() - P1.XYZ());
39 //=======================================================================
42 //=======================================================================
43 Standard_Boolean GCPnts_DistFunction::Value (const Standard_Real X,
46 if (X < myU1 || X > myU2)
47 return Standard_False;
49 F = -myLin.SquareDistance(myCurve.Value(X));
53 //=======================================================================
54 //function : MaxCurvLinDistMV
56 //=======================================================================
58 GCPnts_DistFunctionMV::GCPnts_DistFunctionMV(GCPnts_DistFunction& theCurvLinDist)
59 : myMaxCurvLinDist(theCurvLinDist)
63 //=======================================================================
66 //=======================================================================
67 Standard_Boolean GCPnts_DistFunctionMV::Value (const math_Vector& X,
70 Standard_Boolean Ok = myMaxCurvLinDist.Value(X(1), F);
74 //=======================================================================
75 //function : NbVariables
77 //=======================================================================
78 Standard_Integer GCPnts_DistFunctionMV::NbVariables() const