0024683: Convertation of the generic classes to the non-generic. Part 1
[occt.git] / src / Geom2dLProp / Geom2dLProp_FuncCurNul.cxx
1 // Created on: 1994-09-05
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <Geom2dLProp_FuncCurNul.ixx>
18
19 #include <gp_Pnt2d.hxx>
20 #include <Geom2dLProp_Curve2dTool.hxx>
21
22 #include <gp.hxx>
23 #include <Precision.hxx>
24
25 //=============================================================================
26 //function :
27 // purpose :
28 //=============================================================================
29 Geom2dLProp_FuncCurNul::Geom2dLProp_FuncCurNul(const Handle(Geom2d_Curve)& C)
30 :theCurve(C)
31 {
32 }
33
34 //=============================================================================
35 //function : Value 
36 // purpose : F = (V1^V2.Z)/||V1||*||V2||
37 //=============================================================================
38 Standard_Boolean Geom2dLProp_FuncCurNul::Value (const Standard_Real  X,
39                                                 Standard_Real& F)
40 {
41   Standard_Real D;
42   return Values(X,F,D);
43 }
44
45 //=============================================================================
46 //function : Derivative
47 // purpose :
48 //=============================================================================
49 Standard_Boolean Geom2dLProp_FuncCurNul::Derivative(const Standard_Real  X,
50                                                     Standard_Real& D)
51 {  
52   Standard_Real F;
53   return Values(X,F,D);
54 }
55
56 //=============================================================================
57 //function : Values
58 // purpose : F = (V1^V2.Z)/||V1||*||V2||
59 //=============================================================================
60 Standard_Boolean Geom2dLProp_FuncCurNul::Values (const Standard_Real  X,
61                                                  Standard_Real& F,
62                                                  Standard_Real& D)
63 {
64   gp_Pnt2d P1;
65   gp_Vec2d V1,V2,V3;
66   Geom2dLProp_Curve2dTool::D3(theCurve,X,P1,V1,V2,V3);
67   Standard_Real CP1  = V1.Crossed(V2);
68   Standard_Real CP2  = V1.Crossed(V3);
69   Standard_Real V1V2 = V1.Dot(V2);
70   Standard_Real V2V3 = V2.Dot(V3);
71   Standard_Real NV1  = V1.Magnitude();
72   Standard_Real NV2  = V2.Magnitude();
73
74   F = 0. ;
75   D = 0. ;
76
77 /*
78   if (Abs(CP1) < 1.e-4) {
79     return Standard_True;
80   } else */
81
82   if (NV2 < 1.e-4) {
83     return Standard_True;
84   } else if (NV1*NV2 < gp::Resolution()) {
85     return Standard_False;
86   } else {
87     F   = CP1/(NV1*NV2);
88     D   = (CP2 - CP1*V1V2/(NV1*NV1) - CP1*V2V3/(NV2*NV2))/(NV1*NV2);
89   }
90   return Standard_True;
91   
92 }
93
94
95