1 // Created on: 1997-02-12
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1997-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.
18 #include <Adaptor3d_HCurve.hxx>
19 #include <BRepBlend_CurvPointRadInv.hxx>
21 #include <math_Matrix.hxx>
23 //=======================================================================
24 //function : BRepBlend_CurvPointRadInv
26 //=======================================================================
27 BRepBlend_CurvPointRadInv::BRepBlend_CurvPointRadInv
28 (const Handle(Adaptor3d_HCurve)& C1,
29 const Handle(Adaptor3d_HCurve)& C2) : curv1(C1), curv2(C2)
33 //=======================================================================
36 //=======================================================================
38 void BRepBlend_CurvPointRadInv::Set(const Standard_Integer Choix)
43 //=======================================================================
44 //function : NbEquations
46 //=======================================================================
48 Standard_Integer BRepBlend_CurvPointRadInv::NbEquations() const
53 //=======================================================================
56 //=======================================================================
58 Standard_Boolean BRepBlend_CurvPointRadInv::Value(const math_Vector& X,
62 gp_Pnt ptcur1, ptcur2;
63 gp_Vec d1cur1, d1cur2;
65 curv1->D1(X(1),ptcur1, d1cur1);
66 nplan = d1cur1.Normalized().XYZ();
67 theD = -(nplan.Dot(ptcur1.XYZ()));
68 curv2->D1(X(2), ptcur2, d1cur2);
69 F(1) = nplan.Dot(point.XYZ()) + theD;
70 F(2) = nplan.Dot(ptcur2.XYZ()) + theD;
74 //=======================================================================
75 //function : Derivatives
77 //=======================================================================
79 Standard_Boolean BRepBlend_CurvPointRadInv::Derivatives(const math_Vector& X,
82 gp_Pnt ptcur1, ptcur2;
83 gp_Vec d1cur1,d2cur1, d1cur2, nplan, dnplan;
84 Standard_Real dtheD, normd1cur1, unsurnormd1cur1;
86 curv1->D2(X(1), ptcur1, d1cur1, d2cur1);
88 normd1cur1 = d1cur1.Magnitude();
89 unsurnormd1cur1 = 1. / normd1cur1;
90 nplan = unsurnormd1cur1 * d1cur1;
91 dnplan.SetLinearForm(-nplan.Dot(d2cur1), nplan, d2cur1);
92 dnplan.Multiply(unsurnormd1cur1);
93 dtheD = - nplan.XYZ().Dot(d1cur1.XYZ()) - dnplan.XYZ().Dot(ptcur1.XYZ());
94 D(1,1) = dnplan.XYZ().Dot(point.XYZ()) + dtheD;
96 curv2->D1(X(2), ptcur2, d1cur2);
97 D(2,1) = dnplan.XYZ().Dot(ptcur2.XYZ()) + dtheD;
98 D(2,2) = nplan.Dot(d1cur2);
100 return Standard_True;
103 //=======================================================================
106 //=======================================================================
108 Standard_Boolean BRepBlend_CurvPointRadInv::Values(const math_Vector& X,
115 return Standard_True;
118 //=======================================================================
121 //=======================================================================
123 void BRepBlend_CurvPointRadInv::Set(const gp_Pnt& P)
128 //=======================================================================
129 //function : GetTolerance
131 //=======================================================================
133 void BRepBlend_CurvPointRadInv::GetTolerance(math_Vector& Tolerance,
134 const Standard_Real Tol) const
136 Tolerance(1) = curv1->Resolution(Tol);
137 Tolerance(2) = curv2->Resolution(Tol);
140 //=======================================================================
141 //function : GetBounds
143 //=======================================================================
145 void BRepBlend_CurvPointRadInv::GetBounds(math_Vector& InfBound,
146 math_Vector& SupBound) const
148 InfBound(1) = curv1->FirstParameter();
149 SupBound(1) = curv1->LastParameter();
150 InfBound(2) = curv2->FirstParameter();
151 SupBound(2) = curv2->LastParameter();
155 //=======================================================================
156 //function : IsSolution
158 //=======================================================================
160 Standard_Boolean BRepBlend_CurvPointRadInv::IsSolution(const math_Vector& Sol,
161 const Standard_Real Tol)
163 math_Vector valsol(1, 2);
165 if (Abs(valsol(1)) <= Tol &&
166 Abs(valsol(2)) <= Tol ) {
167 return Standard_True;
169 return Standard_False;