0026788: Compiler warnings when OCCT_DEBUG is enabled
[occt.git] / src / Bisector / Bisector_FunctionH.cxx
CommitLineData
b311480e 1// Created on: 1994-04-05
2// Created by: Yves FRICAUD
3// Copyright (c) 1994-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
42cf5bc1 17
18#include <Bisector_FunctionH.hxx>
7fd59977 19#include <Geom2d_Curve.hxx>
42cf5bc1 20#include <gp_Pnt2d.hxx>
21#include <gp_Vec2d.hxx>
7fd59977 22
23//=============================================================================
24//function :
25// purpose :
26//=============================================================================
27Bisector_FunctionH::Bisector_FunctionH (const Handle(Geom2d_Curve)& C2,
28 const gp_Pnt2d& P1,
29 const gp_Vec2d& T1)
30 :p1(P1),t1(T1)
31{
32 t1.Normalize();
33 curve2 = C2;
34}
35
36//=============================================================================
37//function : Value
38// purpose :
39// F = P1P2.(||T2||T1 + T2)
40//=============================================================================
41Standard_Boolean Bisector_FunctionH::Value (const Standard_Real X,
42 Standard_Real& F)
43{
44 gp_Pnt2d P2 ; // point sur C2.
45 gp_Vec2d T2 ; // tangente a C2 en V.
46 curve2->D1(X,P2,T2);
47
48 Standard_Real NormT2 = T2.Magnitude();
49 Standard_Real Ax = NormT2*t1.X() - T2.X();
50 Standard_Real Ay = NormT2*t1.Y() - T2.Y();
51
52 F = (p1.X() - P2.X())*Ax + (p1.Y() - P2.Y())*Ay;
53
54 return Standard_True;
55}
56
57//=============================================================================
58//function : Derivative
59// purpose :
60//=============================================================================
61Standard_Boolean Bisector_FunctionH::Derivative(const Standard_Real X,
62 Standard_Real& D)
63{
64 Standard_Real F;
65 return Values (X,F,D);
66}
67
68//=============================================================================
69//function : Values
70// purpose :
71//=============================================================================
72Standard_Boolean Bisector_FunctionH::Values (const Standard_Real X,
73 Standard_Real& F,
74 Standard_Real& D)
75{
76 gp_Pnt2d P2 ; // point sur C2.
77 gp_Vec2d T2 ; // tangente a C2 en V.
78 gp_Vec2d T2v ; // derivee seconde a C2 en V.
79
80 curve2->D2(X,P2,T2,T2v);
81
82 Standard_Real NormT2 = T2.Magnitude();
83 Standard_Real Ax = NormT2*t1.X() - T2.X();
84 Standard_Real Ay = NormT2*t1.Y() - T2.Y();
85
86 F = (p1.X() - P2.X())*Ax + (p1.Y() - P2.Y())*Ay;
87
88 Standard_Real Scal = T2.Dot(T2v)/NormT2;
89 Standard_Real dAx = Scal*t1.X() - T2v.X();
90 Standard_Real dAy = Scal*t1.Y() - T2v.Y();
91
92 D = - T2.X()*Ax - T2.Y()*Ay + (p1.X() - P2.X())*dAx + (p1.Y() - P2.Y())*dAy;
93
94
95 return Standard_True;
96
97}
98