0024635: Eliminate trivial compiler warnings by GCC in Debug mode
[occt.git] / src / Bisector / Bisector_FunctionInter.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
17#include <Bisector_FunctionInter.ixx>
18#include <Geom2d_Curve.hxx>
19#include <Bisector_BisecCC.hxx>
20#include <Bisector_BisecPC.hxx>
21#include <gp_Pnt2d.hxx>
22#include <gp_Vec2d.hxx>
23#include <gp.hxx>
24#include <Precision.hxx>
25
26//=============================================================================
27//function :
28// purpose :
29//=============================================================================
30Bisector_FunctionInter::Bisector_FunctionInter ()
31{
32}
33
34//=============================================================================
35//function :
36// purpose :
37//=============================================================================
38Bisector_FunctionInter::Bisector_FunctionInter (const Handle(Geom2d_Curve)& C ,
39 const Handle(Bisector_Curve)& B1 ,
40 const Handle(Bisector_Curve)& B2 )
41{
42 curve = C;
43 bisector1 = B1;
44 bisector2 = B2;
45}
46
47//=============================================================================
48//function :
49// purpose :
50//=============================================================================
51void Bisector_FunctionInter::Perform (const Handle(Geom2d_Curve)& C ,
52 const Handle(Bisector_Curve)& B1 ,
53 const Handle(Bisector_Curve)& B2 )
54{
55 curve = C;
56 bisector1 = B1;
57 bisector2 = B2;
58}
59
60//=============================================================================
61// function : Value
62// purpose :
63///=============================================================================
64Standard_Boolean Bisector_FunctionInter::Value (const Standard_Real X,
65 Standard_Real& F)
66{
67 gp_Pnt2d PC = curve ->Value(X);
68 gp_Pnt2d PB1 = bisector1 ->Value(X);
69 gp_Pnt2d PB2 = bisector2 ->Value(X);
70
71 F = PC.Distance(PB1) - PC.Distance(PB2);
72
73 return Standard_True;
74}
75
76//=============================================================================
77//function : Derivative
78// purpose :
79//=============================================================================
80Standard_Boolean Bisector_FunctionInter::Derivative(const Standard_Real X,
81 Standard_Real& D)
82{
83 Standard_Real F;
84 return Values (X,F,D);
85}
86
87//=============================================================================
88//function : Values
89// purpose :
90//=============================================================================
91Standard_Boolean Bisector_FunctionInter::Values (const Standard_Real X,
92 Standard_Real& F,
93 Standard_Real& D)
94{
95 gp_Pnt2d PC, PB1, PB2;
96 gp_Vec2d TC, TB1, TB2;
97 Standard_Real F1, F2, DF1, DF2;
98
99 curve ->D1(X,PC ,TC);
100 bisector1 ->D1(X,PB1,TB1);
101 bisector2 ->D1(X,PB2,TB2);
102 F1 = PC.Distance(PB1);
103 F2 = PC.Distance(PB2);
104 F = F1 - F2;
105 if (Abs(F1) < gp::Resolution()) {
106 DF1 = Precision::Infinite();
107 }
108 else {
109 DF1 = ((PC.X() - PB1.X())*(TC.X() - TB1.X()) +
110 (PC.Y() - PB1.Y())*(TC.Y() - TB1.Y()) )/F1;
111 }
112 if (Abs(F2) < gp::Resolution()) {
113 DF2 = Precision::Infinite();
114 }
115 else {
116 DF2 = ((PC.X() - PB2.X())*(TC.X() - TB2.X()) +
117 (PC.Y() - PB2.Y())*(TC.Y() - TB2.Y()) )/F2;
118 }
119 D = DF1 - DF2;
120
121 return Standard_True;
122}
123