0024428: Implementation of LGPL license
[occt.git] / src / BRepExtrema / BRepExtrema_ExtCC.cxx
1 // Created on: 1993-12-15
2 // Created by: Christophe MARION
3 // Copyright (c) 1993-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
9 // under the terms of the GNU Lesser General Public 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 <BRepExtrema_ExtCC.hxx>
18
19 #include <BRep_Tool.hxx>
20 #include <Extrema_POnCurv.hxx>
21 #include <BRepAdaptor_Curve.hxx>
22 #include <BRepAdaptor_HCurve.hxx>
23
24
25 //=======================================================================
26 //function : BRepExtrema_ExtCC
27 //purpose  : 
28 //=======================================================================
29
30 BRepExtrema_ExtCC::BRepExtrema_ExtCC(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
31 {
32   Initialize(E2);
33   Perform(E1);
34 }
35
36 //=======================================================================
37 //function : Initialize
38 //purpose  : 
39 //=======================================================================
40
41 void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
42 {
43   Standard_Real V1,V2;
44   BRepAdaptor_Curve Curv(E2);
45   myHC = new BRepAdaptor_HCurve(Curv);
46   BRep_Tool::Range(E2,V1,V2);
47   myExtCC.SetCurve(2,myHC->Curve(),V1,V2);
48 }
49
50 //=======================================================================
51 //function : Perform
52 //purpose  : 
53 //=======================================================================
54
55 void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
56 {
57   Standard_Real U1, U2;
58   BRepAdaptor_Curve Curv(E1);
59   Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
60   BRep_Tool::Range(E1,U1,U2);
61   myExtCC.SetCurve (1, HC->Curve(), U1, U2);
62   myExtCC.Perform();
63 }
64
65 //=======================================================================
66 //function : ParameterOnE1
67 //purpose  : 
68 //=======================================================================
69
70 Standard_Real BRepExtrema_ExtCC::ParameterOnE1(const Standard_Integer N) const
71 {
72   Extrema_POnCurv POnE1, POnE2;
73   myExtCC.Points(N, POnE1, POnE2);
74   return POnE1.Parameter();
75 }
76
77 //=======================================================================
78 //function : PointOnE1
79 //purpose  : 
80 //=======================================================================
81
82 gp_Pnt BRepExtrema_ExtCC::PointOnE1(const Standard_Integer N) const
83 {
84   Extrema_POnCurv POnE1, POnE2;
85   myExtCC.Points(N, POnE1, POnE2);
86   return POnE1.Value();
87 }
88
89 //=======================================================================
90 //function : ParameterOnE2
91 //purpose  : 
92 //=======================================================================
93
94 Standard_Real BRepExtrema_ExtCC::ParameterOnE2(const Standard_Integer N) const
95 {
96   Extrema_POnCurv POnE1, POnE2;
97   myExtCC.Points(N, POnE1, POnE2);
98   return POnE2.Parameter();
99 }
100
101 //=======================================================================
102 //function : PointOnE2
103 //purpose  : 
104 //=======================================================================
105
106 gp_Pnt BRepExtrema_ExtCC::PointOnE2(const Standard_Integer N) const
107 {
108   Extrema_POnCurv POnE1, POnE2;
109   myExtCC.Points(N, POnE1, POnE2);
110   return POnE2.Value();
111 }
112
113
114 //=======================================================================
115 //function : TrimmedSquareDistances
116 //purpose  : 
117 //=======================================================================
118
119 void BRepExtrema_ExtCC::TrimmedSquareDistances
120   (Standard_Real& dist11,
121    Standard_Real& dist12,
122    Standard_Real& dist21,
123    Standard_Real& dist22,
124    gp_Pnt& pnt11,
125    gp_Pnt& pnt12,
126    gp_Pnt& pnt21,
127    gp_Pnt& pnt22) const
128 {
129   myExtCC.TrimmedSquareDistances(dist11,dist12,dist21,dist22,
130                                  pnt11,pnt12,pnt21,pnt22);
131 }