0024048: "Basic Runtime Checks" option of VS projects should be equal to "RTC1"
[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
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22
23#include <BRepBlend_CurvPointRadInv.ixx>
24
25//=======================================================================
26//function : BRepBlend_CurvPointRadInv
27//purpose :
28//=======================================================================
29
30BRepBlend_CurvPointRadInv::BRepBlend_CurvPointRadInv
31(const Handle(Adaptor3d_HCurve)& C1,
32 const Handle(Adaptor3d_HCurve)& C2) : curv1(C1), curv2(C2)
33{
34}
35
36//=======================================================================
37//function : Set
38//purpose :
39//=======================================================================
40
41void BRepBlend_CurvPointRadInv::Set(const Standard_Integer Choix)
42{
43 choix = Choix;
44}
45
46//=======================================================================
47//function : NbEquations
48//purpose :
49//=======================================================================
50
51Standard_Integer BRepBlend_CurvPointRadInv::NbEquations() const
52{
53 return 2;
54}
55
56//=======================================================================
57//function : Value
58//purpose :
59//=======================================================================
60
61Standard_Boolean BRepBlend_CurvPointRadInv::Value(const math_Vector& X,
62 math_Vector& F)
63{
64 Standard_Real theD;
65 gp_Pnt ptcur1, ptcur2;
66 gp_Vec d1cur1, d1cur2;
67 gp_XYZ nplan;//, ref;
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;
74 return Standard_True;
75}
76
77//=======================================================================
78//function : Derivatives
79//purpose :
80//=======================================================================
81
82Standard_Boolean BRepBlend_CurvPointRadInv::Derivatives(const math_Vector& X,
83 math_Matrix& D)
84{
85 gp_Pnt ptcur1, ptcur2;
86 gp_Vec d1cur1,d2cur1, d1cur2, nplan, dnplan;
87 Standard_Real theD, dtheD, normd1cur1, unsurnormd1cur1;
88
89 curv1->D2(X(1), ptcur1, d1cur1, d2cur1);
90
91 normd1cur1 = d1cur1.Magnitude();
92 unsurnormd1cur1 = 1. / normd1cur1;
93 nplan = unsurnormd1cur1 * d1cur1;
94 theD = -(nplan.XYZ().Dot(ptcur1.XYZ()));
95 dnplan.SetLinearForm(-nplan.Dot(d2cur1), nplan, d2cur1);
96 dnplan.Multiply(unsurnormd1cur1);
97 dtheD = - nplan.XYZ().Dot(d1cur1.XYZ()) - dnplan.XYZ().Dot(ptcur1.XYZ());
98 D(1,1) = dnplan.XYZ().Dot(point.XYZ()) + dtheD;
99 D(1,2) = 0.;
100 curv2->D1(X(2), ptcur2, d1cur2);
101 D(2,1) = dnplan.XYZ().Dot(ptcur2.XYZ()) + dtheD;
102 D(2,2) = nplan.Dot(d1cur2);
103
104 return Standard_True;
105}
106
107//=======================================================================
108//function : Values
109//purpose :
110//=======================================================================
111
112Standard_Boolean BRepBlend_CurvPointRadInv::Values(const math_Vector& X,
113 math_Vector& F,
114 math_Matrix& D)
115{
116 Standard_Boolean Retour;
117
118 Retour = Value(X, F);
119 Retour = Derivatives(X, D);
120
121 return Standard_True;
122}
123
124//=======================================================================
125//function : Set
126//purpose :
127//=======================================================================
128
129void BRepBlend_CurvPointRadInv::Set(const gp_Pnt& P)
130{
131 point = P;
132}
133
134//=======================================================================
135//function : GetTolerance
136//purpose :
137//=======================================================================
138
139void BRepBlend_CurvPointRadInv::GetTolerance(math_Vector& Tolerance,
140 const Standard_Real Tol) const
141{
142 Tolerance(1) = curv1->Resolution(Tol);
143 Tolerance(2) = curv2->Resolution(Tol);
144}
145
146//=======================================================================
147//function : GetBounds
148//purpose :
149//=======================================================================
150
151void BRepBlend_CurvPointRadInv::GetBounds(math_Vector& InfBound,
152 math_Vector& SupBound) const
153{
154 InfBound(1) = curv1->FirstParameter();
155 SupBound(1) = curv1->LastParameter();
156 InfBound(2) = curv2->FirstParameter();
157 SupBound(2) = curv2->LastParameter();
158
159}
160
161//=======================================================================
162//function : IsSolution
163//purpose :
164//=======================================================================
165
166Standard_Boolean BRepBlend_CurvPointRadInv::IsSolution(const math_Vector& Sol,
167 const Standard_Real Tol)
168{
169 math_Vector valsol(1, 2);
170 Value(Sol,valsol);
171 if (Abs(valsol(1)) <= Tol &&
172 Abs(valsol(2)) <= Tol ) {
173 return Standard_True;
174 }
175 return Standard_False;
176}
177
178
179