b311480e |
1 | // Created on: 1997-03-28 |
2 | // Created by: Philippe MANGIN |
3 | // Copyright (c) 1997-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 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <ChFi3d_SearchSing.hxx> |
19 | #include <Geom_Curve.hxx> |
7fd59977 |
20 | #include <gp_Pnt.hxx> |
21 | #include <gp_Vec.hxx> |
22 | |
23 | ChFi3d_SearchSing::ChFi3d_SearchSing(const Handle(Geom_Curve)& C1, |
24 | const Handle(Geom_Curve)& C2) |
25 | { |
26 | myC1 = C1; |
27 | myC2 = C2; |
28 | } |
29 | |
30 | |
31 | |
32 | Standard_Boolean ChFi3d_SearchSing::Value(const Standard_Real X, |
33 | Standard_Real& F) |
34 | { |
35 | gp_Pnt P1, P2; |
36 | gp_Vec V1, V2; |
37 | myC1->D1(X, P1, V1); |
38 | myC2->D1(X, P2, V2); |
39 | gp_Vec V(P1,P2); |
40 | F = V * (V2-V1); |
41 | return Standard_True; |
42 | } |
43 | |
44 | Standard_Boolean ChFi3d_SearchSing::Derivative(const Standard_Real X, |
45 | Standard_Real& D ) |
46 | { |
47 | gp_Pnt P1, P2; |
48 | gp_Vec V1, V2, W1, W2; |
49 | myC1->D2(X, P1, V1, W1); |
50 | myC2->D2(X, P2, V2, W2); |
51 | gp_Vec V(P1,P2), VPrim; |
52 | VPrim = V2 -V1; |
53 | D = VPrim.SquareMagnitude() + (V * (W2-W1)); |
54 | return Standard_True; |
55 | } |
56 | |
57 | Standard_Boolean ChFi3d_SearchSing::Values(const Standard_Real X, |
58 | Standard_Real& F, |
59 | Standard_Real& D ) |
60 | { |
61 | gp_Pnt P1, P2; |
62 | gp_Vec V1, V2, W1, W2; |
63 | myC1->D2(X, P1, V1, W1); |
64 | myC2->D2(X, P2, V2, W2); |
65 | gp_Vec V(P1,P2), VPrim; |
66 | VPrim = V2 -V1; |
67 | F = V * VPrim; |
68 | D = VPrim.SquareMagnitude() + (V * (W2-W1)); |
69 | return Standard_True; |
70 | } |