0031821: Coding - Uninitialized variables in TKFillet project
[occt.git] / src / BlendFunc / BlendFunc_GenChamfInv.cxx
1 // Created by: Julia GERASIMOVA
2 // Copyright (c) 2015 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <Adaptor2d_HCurve2d.hxx>
17 #include <Adaptor3d_HCurve.hxx>
18 #include <Adaptor3d_HSurface.hxx>
19 #include <BlendFunc.hxx>
20 #include <BlendFunc_ChamfInv.hxx>
21 #include <math_Matrix.hxx>
22 #include <Precision.hxx>
23
24
25 //=======================================================================
26 //function : BlendFunc_GenChamfInv
27 //purpose  : 
28 //=======================================================================
29 BlendFunc_GenChamfInv::BlendFunc_GenChamfInv(const Handle(Adaptor3d_HSurface)& S1,
30                                              const Handle(Adaptor3d_HSurface)& S2,
31                                              const Handle(Adaptor3d_HCurve)&   C)
32 : surf1(S1),
33   surf2(S2),
34   curv(C),
35   choix(0),
36   first(Standard_False)
37 {
38 }
39
40 //=======================================================================
41 //function : NbEquations
42 //purpose  : 
43 //=======================================================================
44
45 Standard_Integer BlendFunc_GenChamfInv::NbEquations () const
46 {
47   return 4;
48 }
49
50 //=======================================================================
51 //function : Set
52 //purpose  : 
53 //=======================================================================
54
55 void BlendFunc_GenChamfInv::Set(const Standard_Boolean OnFirst, const Handle(Adaptor2d_HCurve2d)& C)
56 {
57   first = OnFirst;
58   csurf = C;
59 }
60
61 //=======================================================================
62 //function : GetTolerance
63 //purpose  : 
64 //=======================================================================
65
66 void BlendFunc_GenChamfInv::GetTolerance(math_Vector& Tolerance, const Standard_Real Tol) const
67 {
68   Tolerance(1) = csurf->Resolution(Tol);
69   Tolerance(2) = curv->Resolution(Tol);
70   if (first) {
71     Tolerance(3) = surf2->UResolution(Tol);
72     Tolerance(4) = surf2->VResolution(Tol);
73   }
74   else {
75     Tolerance(3) = surf1->UResolution(Tol);
76     Tolerance(4) = surf1->VResolution(Tol);
77   }
78 }
79
80
81 //=======================================================================
82 //function : GetBounds
83 //purpose  : 
84 //=======================================================================
85
86 void BlendFunc_GenChamfInv::GetBounds(math_Vector& InfBound, math_Vector& SupBound) const
87 {
88   InfBound(1) = csurf->FirstParameter();
89   InfBound(2) = curv->FirstParameter();
90   SupBound(1) = csurf->LastParameter();
91   SupBound(2) = curv->LastParameter();
92
93   if (first) {
94     InfBound(3) = surf2->FirstUParameter();
95     InfBound(4) = surf2->FirstVParameter();
96     SupBound(3) = surf2->LastUParameter();
97     SupBound(4) = surf2->LastVParameter();
98     if(!Precision::IsInfinite(InfBound(3)) &&
99        !Precision::IsInfinite(SupBound(3))) {
100       const Standard_Real range = (SupBound(3) - InfBound(3));
101       InfBound(3) -= range;
102       SupBound(3) += range;
103     }
104     if(!Precision::IsInfinite(InfBound(4)) &&
105        !Precision::IsInfinite(SupBound(4))) {
106       const Standard_Real range = (SupBound(4) - InfBound(4));
107       InfBound(4) -= range;
108       SupBound(4) += range;
109     }
110   }
111   else {
112     InfBound(3) = surf1->FirstUParameter();
113     InfBound(4) = surf1->FirstVParameter();
114     SupBound(3) = surf1->LastUParameter();
115     SupBound(4) = surf1->LastVParameter();
116     if(!Precision::IsInfinite(InfBound(3)) &&
117        !Precision::IsInfinite(SupBound(3))) {
118       const Standard_Real range = (SupBound(3) - InfBound(3));
119       InfBound(3) -= range;
120       SupBound(3) += range;
121     }
122     if(!Precision::IsInfinite(InfBound(4)) &&
123        !Precision::IsInfinite(SupBound(4))) {
124       const Standard_Real range = (SupBound(4) - InfBound(4));
125       InfBound(4) -= range;
126       SupBound(4) += range;
127     }
128   }    
129 }
130
131 //=======================================================================
132 //function : Values
133 //purpose  : 
134 //=======================================================================
135
136 Standard_Boolean BlendFunc_GenChamfInv::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
137 {
138   Value(X,F);
139   Derivatives(X,D);
140   return Standard_True;
141 }