0030480: Visualization - Clear of Select3D_SensitiveGroup does not update internal...
[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),surf2(S2),curv(C)
33 {
34 }
35
36 //=======================================================================
37 //function : NbEquations
38 //purpose  : 
39 //=======================================================================
40
41 Standard_Integer BlendFunc_GenChamfInv::NbEquations () const
42 {
43   return 4;
44 }
45
46 //=======================================================================
47 //function : Set
48 //purpose  : 
49 //=======================================================================
50
51 void BlendFunc_GenChamfInv::Set(const Standard_Boolean OnFirst, const Handle(Adaptor2d_HCurve2d)& C)
52 {
53   first = OnFirst;
54   csurf = C;
55 }
56
57 //=======================================================================
58 //function : GetTolerance
59 //purpose  : 
60 //=======================================================================
61
62 void BlendFunc_GenChamfInv::GetTolerance(math_Vector& Tolerance, const Standard_Real Tol) const
63 {
64   Tolerance(1) = csurf->Resolution(Tol);
65   Tolerance(2) = curv->Resolution(Tol);
66   if (first) {
67     Tolerance(3) = surf2->UResolution(Tol);
68     Tolerance(4) = surf2->VResolution(Tol);
69   }
70   else {
71     Tolerance(3) = surf1->UResolution(Tol);
72     Tolerance(4) = surf1->VResolution(Tol);
73   }
74 }
75
76
77 //=======================================================================
78 //function : GetBounds
79 //purpose  : 
80 //=======================================================================
81
82 void BlendFunc_GenChamfInv::GetBounds(math_Vector& InfBound, math_Vector& SupBound) const
83 {
84   InfBound(1) = csurf->FirstParameter();
85   InfBound(2) = curv->FirstParameter();
86   SupBound(1) = csurf->LastParameter();
87   SupBound(2) = curv->LastParameter();
88
89   if (first) {
90     InfBound(3) = surf2->FirstUParameter();
91     InfBound(4) = surf2->FirstVParameter();
92     SupBound(3) = surf2->LastUParameter();
93     SupBound(4) = surf2->LastVParameter();
94     if(!Precision::IsInfinite(InfBound(3)) &&
95        !Precision::IsInfinite(SupBound(3))) {
96       const Standard_Real range = (SupBound(3) - InfBound(3));
97       InfBound(3) -= range;
98       SupBound(3) += range;
99     }
100     if(!Precision::IsInfinite(InfBound(4)) &&
101        !Precision::IsInfinite(SupBound(4))) {
102       const Standard_Real range = (SupBound(4) - InfBound(4));
103       InfBound(4) -= range;
104       SupBound(4) += range;
105     }
106   }
107   else {
108     InfBound(3) = surf1->FirstUParameter();
109     InfBound(4) = surf1->FirstVParameter();
110     SupBound(3) = surf1->LastUParameter();
111     SupBound(4) = surf1->LastVParameter();
112     if(!Precision::IsInfinite(InfBound(3)) &&
113        !Precision::IsInfinite(SupBound(3))) {
114       const Standard_Real range = (SupBound(3) - InfBound(3));
115       InfBound(3) -= range;
116       SupBound(3) += range;
117     }
118     if(!Precision::IsInfinite(InfBound(4)) &&
119        !Precision::IsInfinite(SupBound(4))) {
120       const Standard_Real range = (SupBound(4) - InfBound(4));
121       InfBound(4) -= range;
122       SupBound(4) += range;
123     }
124   }    
125 }
126
127 //=======================================================================
128 //function : Values
129 //purpose  : 
130 //=======================================================================
131
132 Standard_Boolean BlendFunc_GenChamfInv::Values(const math_Vector& X, math_Vector& F, math_Matrix& D)
133 {
134   Value(X,F);
135   Derivatives(X,D);
136   return Standard_True;
137 }