|
|
|||
File indexing completed on 2026-09-28 09:19:57
0001 // Copyright (c) 2025 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _ExtremaPC_DistanceFunction_HeaderFile 0015 #define _ExtremaPC_DistanceFunction_HeaderFile 0016 0017 #include <Adaptor3d_Curve.hxx> 0018 #include <gp_Pnt.hxx> 0019 #include <gp_Vec.hxx> 0020 #include <Standard_DefineAlloc.hxx> 0021 0022 //! @brief Distance function for point-curve extrema computation. 0023 //! 0024 //! Implements the function F(u) = (C(u) - P) . C'(u) and its derivative 0025 //! F'(u) = C'(u) . C'(u) + (C(u) - P) . C''(u). 0026 //! 0027 //! The roots of F(u) = 0 correspond to the extrema (local minima and maxima) 0028 //! of the squared distance function D(u) = ||C(u) - P||^2. 0029 //! 0030 //! This class provides the interface required by MathRoot::FindAllRootsWithDerivative. 0031 class ExtremaPC_DistanceFunction 0032 { 0033 public: 0034 DEFINE_STANDARD_ALLOC 0035 0036 //! Constructor. 0037 //! @param theCurve the curve adaptor 0038 //! @param theP the query point 0039 ExtremaPC_DistanceFunction(const Adaptor3d_Curve& theCurve, const gp_Pnt& theP) 0040 : myCurve(&theCurve), 0041 myP(theP) 0042 { 0043 } 0044 0045 //! Computes F(u) = (C(u) - P) . C'(u). 0046 //! @param theU parameter value 0047 //! @param theF output: function value 0048 //! @return true if computation succeeded 0049 bool Value(double theU, double& theF) const 0050 { 0051 gp_Pnt aPt; 0052 gp_Vec aD1; 0053 myCurve->D1(theU, aPt, aD1); 0054 0055 gp_Vec aVec(myP, aPt); 0056 theF = aVec.Dot(aD1); 0057 return true; 0058 } 0059 0060 //! Computes F(u) and F'(u). 0061 //! F(u) = (C(u) - P) . C'(u) 0062 //! F'(u) = C'(u) . C'(u) + (C(u) - P) . C''(u) 0063 //! @param theU parameter value 0064 //! @param theF output: function value 0065 //! @param theDF output: derivative value 0066 //! @return true if computation succeeded 0067 bool Values(double theU, double& theF, double& theDF) const 0068 { 0069 gp_Pnt aPt; 0070 gp_Vec aD1, aD2; 0071 myCurve->D2(theU, aPt, aD1, aD2); 0072 0073 gp_Vec aVec(myP, aPt); 0074 theF = aVec.Dot(aD1); 0075 theDF = aD1.Dot(aD1) + aVec.Dot(aD2); 0076 return true; 0077 } 0078 0079 //! Computes the derivative F'(u). 0080 //! @param theU parameter value 0081 //! @param theDF output: derivative value 0082 //! @return true if computation succeeded 0083 bool Derivative(double theU, double& theDF) const 0084 { 0085 double aF; 0086 return Values(theU, aF, theDF); 0087 } 0088 0089 //! Returns the first parameter of the curve. 0090 double FirstParameter() const { return myCurve->FirstParameter(); } 0091 0092 //! Returns the last parameter of the curve. 0093 double LastParameter() const { return myCurve->LastParameter(); } 0094 0095 //! Returns the query point. 0096 const gp_Pnt& Point() const { return myP; } 0097 0098 //! Returns the curve. 0099 const Adaptor3d_Curve& Curve() const { return *myCurve; } 0100 0101 private: 0102 const Adaptor3d_Curve* myCurve; //!< Curve adaptor (not owned) 0103 gp_Pnt myP; //!< Query point 0104 }; 0105 0106 #endif // _ExtremaPC_DistanceFunction_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|