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
9 // under the terms of the GNU Lesser General Public 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 <BRepBlend_CurvPointRadInv.ixx>
19 //=======================================================================
20 //function : BRepBlend_CurvPointRadInv
22 //=======================================================================
24 BRepBlend_CurvPointRadInv::BRepBlend_CurvPointRadInv
25 (const Handle(Adaptor3d_HCurve)& C1,
26 const Handle(Adaptor3d_HCurve)& C2) : curv1(C1), curv2(C2)
30 //=======================================================================
33 //=======================================================================
35 void BRepBlend_CurvPointRadInv::Set(const Standard_Integer Choix)
40 //=======================================================================
41 //function : NbEquations
43 //=======================================================================
45 Standard_Integer BRepBlend_CurvPointRadInv::NbEquations() const
50 //=======================================================================
53 //=======================================================================
55 Standard_Boolean BRepBlend_CurvPointRadInv::Value(const math_Vector& X,
59 gp_Pnt ptcur1, ptcur2;
60 gp_Vec d1cur1, d1cur2;
62 curv1->D1(X(1),ptcur1, d1cur1);
63 nplan = d1cur1.Normalized().XYZ();
64 theD = -(nplan.Dot(ptcur1.XYZ()));
65 curv2->D1(X(2), ptcur2, d1cur2);
66 F(1) = nplan.Dot(point.XYZ()) + theD;
67 F(2) = nplan.Dot(ptcur2.XYZ()) + theD;
71 //=======================================================================
72 //function : Derivatives
74 //=======================================================================
76 Standard_Boolean BRepBlend_CurvPointRadInv::Derivatives(const math_Vector& X,
79 gp_Pnt ptcur1, ptcur2;
80 gp_Vec d1cur1,d2cur1, d1cur2, nplan, dnplan;
81 Standard_Real dtheD, normd1cur1, unsurnormd1cur1;
83 curv1->D2(X(1), ptcur1, d1cur1, d2cur1);
85 normd1cur1 = d1cur1.Magnitude();
86 unsurnormd1cur1 = 1. / normd1cur1;
87 nplan = unsurnormd1cur1 * d1cur1;
88 dnplan.SetLinearForm(-nplan.Dot(d2cur1), nplan, d2cur1);
89 dnplan.Multiply(unsurnormd1cur1);
90 dtheD = - nplan.XYZ().Dot(d1cur1.XYZ()) - dnplan.XYZ().Dot(ptcur1.XYZ());
91 D(1,1) = dnplan.XYZ().Dot(point.XYZ()) + dtheD;
93 curv2->D1(X(2), ptcur2, d1cur2);
94 D(2,1) = dnplan.XYZ().Dot(ptcur2.XYZ()) + dtheD;
95 D(2,2) = nplan.Dot(d1cur2);
100 //=======================================================================
103 //=======================================================================
105 Standard_Boolean BRepBlend_CurvPointRadInv::Values(const math_Vector& X,
112 return Standard_True;
115 //=======================================================================
118 //=======================================================================
120 void BRepBlend_CurvPointRadInv::Set(const gp_Pnt& P)
125 //=======================================================================
126 //function : GetTolerance
128 //=======================================================================
130 void BRepBlend_CurvPointRadInv::GetTolerance(math_Vector& Tolerance,
131 const Standard_Real Tol) const
133 Tolerance(1) = curv1->Resolution(Tol);
134 Tolerance(2) = curv2->Resolution(Tol);
137 //=======================================================================
138 //function : GetBounds
140 //=======================================================================
142 void BRepBlend_CurvPointRadInv::GetBounds(math_Vector& InfBound,
143 math_Vector& SupBound) const
145 InfBound(1) = curv1->FirstParameter();
146 SupBound(1) = curv1->LastParameter();
147 InfBound(2) = curv2->FirstParameter();
148 SupBound(2) = curv2->LastParameter();
152 //=======================================================================
153 //function : IsSolution
155 //=======================================================================
157 Standard_Boolean BRepBlend_CurvPointRadInv::IsSolution(const math_Vector& Sol,
158 const Standard_Real Tol)
160 math_Vector valsol(1, 2);
162 if (Abs(valsol(1)) <= Tol &&
163 Abs(valsol(2)) <= Tol ) {
164 return Standard_True;
166 return Standard_False;