5bafa089477158987e84eed068e7b16fe1f77a3a
[occt.git] / src / Extrema / Extrema_LocateExtCC2d.cxx
1 // Created on: 1994-07-06
2 // Created by: Laurent PAINNOT
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 <Extrema_LocateExtCC2d.hxx>
18
19 #include <GeomAbs_CurveType.hxx>
20 #include <StdFail_NotDone.hxx>
21 #include <Extrema_POnCurv2d.hxx>
22 #include <Precision.hxx>
23
24 #include <Adaptor2d_Curve2d.hxx>
25 #include <Extrema_Curve2dTool.hxx>
26 #include <Extrema_LocECC2d.hxx>
27
28
29 //=======================================================================
30 //function : Extrema_LocateExtCC2d
31 //purpose  : 
32 //=======================================================================
33
34 Extrema_LocateExtCC2d::Extrema_LocateExtCC2d (const Adaptor2d_Curve2d&       C1,
35                                               const Adaptor2d_Curve2d&       C2,
36                                               const Standard_Real U0,
37                                               const Standard_Real V0)
38 {
39   Standard_Real TolU = Extrema_Curve2dTool::Resolution(C1, Precision::Confusion());
40   Standard_Real TolV = Extrema_Curve2dTool::Resolution(C2, Precision::Confusion());
41   Extrema_POnCurv2d P1, P2;
42
43   // Non implemente pour l instant: l appel a Geom2dExtrema_ExtCC.
44
45
46   Extrema_LocECC2d Xtrem(C1, C2, U0, V0, TolU, TolV);   
47   // Exploitation
48
49   myDone = Xtrem.IsDone();
50   if (Xtrem.IsDone()) {
51     mySqDist = Xtrem.SquareDistance();
52     Xtrem.Point(P1, P2);
53     myPoint1 = P1;
54     myPoint2 = P2;
55   }
56
57 }
58
59
60
61
62 //=======================================================================
63 //function : IsDone
64 //purpose  : 
65 //=======================================================================
66
67 Standard_Boolean Extrema_LocateExtCC2d::IsDone () const {
68
69   return myDone;
70 }
71
72
73 //=======================================================================
74 //function : Value
75 //purpose  : 
76 //=======================================================================
77
78 Standard_Real Extrema_LocateExtCC2d::SquareDistance() const {
79
80   if (!IsDone())
81   {
82     throw StdFail_NotDone();
83   }
84   return mySqDist;
85 }
86
87
88
89 //=======================================================================
90 //function : Point
91 //purpose  : 
92 //=======================================================================
93
94 void Extrema_LocateExtCC2d::Point (Extrema_POnCurv2d& P1, 
95                                    Extrema_POnCurv2d& P2) const 
96 {
97   if (!IsDone())
98   {
99     throw StdFail_NotDone();
100   }
101   P1 = myPoint1;
102   P2 = myPoint2;
103 }