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_Curve.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_Curve)& C1,
29 const Handle(Adaptor3d_Curve)& C2)
36 //=======================================================================
39 //=======================================================================
41 void BRepBlend_CurvPointRadInv::Set(const Standard_Integer Choix)
46 //=======================================================================
47 //function : NbEquations
49 //=======================================================================
51 Standard_Integer BRepBlend_CurvPointRadInv::NbEquations() const
56 //=======================================================================
59 //=======================================================================
61 Standard_Boolean BRepBlend_CurvPointRadInv::Value(const math_Vector& X,
65 gp_Pnt ptcur1, ptcur2;
66 gp_Vec d1cur1, d1cur2;
68 curv1->D1(X(1),ptcur1, d1cur1);
69 nplan = d1cur1.Normalized().XYZ();
70 theD = -(nplan.Dot(ptcur1.XYZ()));
71 curv2->D1(X(2), ptcur2, d1cur2);
72 F(1) = nplan.Dot(point.XYZ()) + theD;
73 F(2) = nplan.Dot(ptcur2.XYZ()) + theD;
77 //=======================================================================
78 //function : Derivatives
80 //=======================================================================
82 Standard_Boolean BRepBlend_CurvPointRadInv::Derivatives(const math_Vector& X,
85 gp_Pnt ptcur1, ptcur2;
86 gp_Vec d1cur1,d2cur1, d1cur2, nplan, dnplan;
87 Standard_Real dtheD, normd1cur1, unsurnormd1cur1;
89 curv1->D2(X(1), ptcur1, d1cur1, d2cur1);
91 normd1cur1 = d1cur1.Magnitude();
92 unsurnormd1cur1 = 1. / normd1cur1;
93 nplan = unsurnormd1cur1 * d1cur1;
94 dnplan.SetLinearForm(-nplan.Dot(d2cur1), nplan, d2cur1);
95 dnplan.Multiply(unsurnormd1cur1);
96 dtheD = - nplan.XYZ().Dot(d1cur1.XYZ()) - dnplan.XYZ().Dot(ptcur1.XYZ());
97 D(1,1) = dnplan.XYZ().Dot(point.XYZ()) + dtheD;
99 curv2->D1(X(2), ptcur2, d1cur2);
100 D(2,1) = dnplan.XYZ().Dot(ptcur2.XYZ()) + dtheD;
101 D(2,2) = nplan.Dot(d1cur2);
103 return Standard_True;
106 //=======================================================================
109 //=======================================================================
111 Standard_Boolean BRepBlend_CurvPointRadInv::Values(const math_Vector& X,
118 return Standard_True;
121 //=======================================================================
124 //=======================================================================
126 void BRepBlend_CurvPointRadInv::Set(const gp_Pnt& P)
131 //=======================================================================
132 //function : GetTolerance
134 //=======================================================================
136 void BRepBlend_CurvPointRadInv::GetTolerance(math_Vector& Tolerance,
137 const Standard_Real Tol) const
139 Tolerance(1) = curv1->Resolution(Tol);
140 Tolerance(2) = curv2->Resolution(Tol);
143 //=======================================================================
144 //function : GetBounds
146 //=======================================================================
148 void BRepBlend_CurvPointRadInv::GetBounds(math_Vector& InfBound,
149 math_Vector& SupBound) const
151 InfBound(1) = curv1->FirstParameter();
152 SupBound(1) = curv1->LastParameter();
153 InfBound(2) = curv2->FirstParameter();
154 SupBound(2) = curv2->LastParameter();
158 //=======================================================================
159 //function : IsSolution
161 //=======================================================================
163 Standard_Boolean BRepBlend_CurvPointRadInv::IsSolution(const math_Vector& Sol,
164 const Standard_Real Tol)
166 math_Vector valsol(1, 2);
168 if (Abs(valsol(1)) <= Tol &&
169 Abs(valsol(2)) <= Tol ) {
170 return Standard_True;
172 return Standard_False;