0024624: Lost word in license statement in source files
[occt.git] / src / BRepBlend / BRepBlend_CurvPointRadInv.cxx
CommitLineData
b311480e 1// Created on: 1997-02-12
2// Created by: Laurent BOURESCHE
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <BRepBlend_CurvPointRadInv.ixx>
18
19//=======================================================================
20//function : BRepBlend_CurvPointRadInv
21//purpose :
22//=======================================================================
23
24BRepBlend_CurvPointRadInv::BRepBlend_CurvPointRadInv
25(const Handle(Adaptor3d_HCurve)& C1,
26 const Handle(Adaptor3d_HCurve)& C2) : curv1(C1), curv2(C2)
27{
28}
29
30//=======================================================================
31//function : Set
32//purpose :
33//=======================================================================
34
35void BRepBlend_CurvPointRadInv::Set(const Standard_Integer Choix)
36{
37 choix = Choix;
38}
39
40//=======================================================================
41//function : NbEquations
42//purpose :
43//=======================================================================
44
45Standard_Integer BRepBlend_CurvPointRadInv::NbEquations() const
46{
47 return 2;
48}
49
50//=======================================================================
51//function : Value
52//purpose :
53//=======================================================================
54
55Standard_Boolean BRepBlend_CurvPointRadInv::Value(const math_Vector& X,
56 math_Vector& F)
57{
58 Standard_Real theD;
59 gp_Pnt ptcur1, ptcur2;
60 gp_Vec d1cur1, d1cur2;
61 gp_XYZ nplan;//, ref;
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;
68 return Standard_True;
69}
70
71//=======================================================================
72//function : Derivatives
73//purpose :
74//=======================================================================
75
76Standard_Boolean BRepBlend_CurvPointRadInv::Derivatives(const math_Vector& X,
77 math_Matrix& D)
78{
79 gp_Pnt ptcur1, ptcur2;
80 gp_Vec d1cur1,d2cur1, d1cur2, nplan, dnplan;
96a95605 81 Standard_Real dtheD, normd1cur1, unsurnormd1cur1;
7fd59977 82
83 curv1->D2(X(1), ptcur1, d1cur1, d2cur1);
84
85 normd1cur1 = d1cur1.Magnitude();
86 unsurnormd1cur1 = 1. / normd1cur1;
87 nplan = unsurnormd1cur1 * d1cur1;
7fd59977 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;
92 D(1,2) = 0.;
93 curv2->D1(X(2), ptcur2, d1cur2);
94 D(2,1) = dnplan.XYZ().Dot(ptcur2.XYZ()) + dtheD;
95 D(2,2) = nplan.Dot(d1cur2);
96
97 return Standard_True;
98}
99
100//=======================================================================
101//function : Values
102//purpose :
103//=======================================================================
104
105Standard_Boolean BRepBlend_CurvPointRadInv::Values(const math_Vector& X,
106 math_Vector& F,
107 math_Matrix& D)
108{
96a95605
DB
109 Value(X, F);
110 Derivatives(X, D);
7fd59977 111
112 return Standard_True;
113}
114
115//=======================================================================
116//function : Set
117//purpose :
118//=======================================================================
119
120void BRepBlend_CurvPointRadInv::Set(const gp_Pnt& P)
121{
122 point = P;
123}
124
125//=======================================================================
126//function : GetTolerance
127//purpose :
128//=======================================================================
129
130void BRepBlend_CurvPointRadInv::GetTolerance(math_Vector& Tolerance,
131 const Standard_Real Tol) const
132{
133 Tolerance(1) = curv1->Resolution(Tol);
134 Tolerance(2) = curv2->Resolution(Tol);
135}
136
137//=======================================================================
138//function : GetBounds
139//purpose :
140//=======================================================================
141
142void BRepBlend_CurvPointRadInv::GetBounds(math_Vector& InfBound,
143 math_Vector& SupBound) const
144{
145 InfBound(1) = curv1->FirstParameter();
146 SupBound(1) = curv1->LastParameter();
147 InfBound(2) = curv2->FirstParameter();
148 SupBound(2) = curv2->LastParameter();
149
150}
151
152//=======================================================================
153//function : IsSolution
154//purpose :
155//=======================================================================
156
157Standard_Boolean BRepBlend_CurvPointRadInv::IsSolution(const math_Vector& Sol,
158 const Standard_Real Tol)
159{
160 math_Vector valsol(1, 2);
161 Value(Sol,valsol);
162 if (Abs(valsol(1)) <= Tol &&
163 Abs(valsol(2)) <= Tol ) {
164 return Standard_True;
165 }
166 return Standard_False;
167}
168
169
170