OCC22322 Improvement of Extrema performance
[occt.git] / src / BRepExtrema / BRepExtrema_ExtCC.cxx
CommitLineData
7fd59977 1// File: BRepExtrema_ExtCC.cxx
2// Created: Wed Dec 15 16:48:53 1993
3// Author: Christophe MARION
7fd59977 4
92d1589b
A
5#include <BRepExtrema_ExtCC.hxx>
6
7fd59977 7#include <BRep_Tool.hxx>
7fd59977 8#include <Extrema_POnCurv.hxx>
9#include <BRepAdaptor_Curve.hxx>
10#include <BRepAdaptor_HCurve.hxx>
11
12
13//=======================================================================
14//function : BRepExtrema_ExtCC
15//purpose :
16//=======================================================================
17
92d1589b 18BRepExtrema_ExtCC::BRepExtrema_ExtCC(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
7fd59977 19{
20 Initialize(E2);
21 Perform(E1);
22}
23
24//=======================================================================
25//function : Initialize
26//purpose :
27//=======================================================================
28
29void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
30{
31 Standard_Real V1,V2;
32 BRepAdaptor_Curve Curv(E2);
33 myHC = new BRepAdaptor_HCurve(Curv);
34 BRep_Tool::Range(E2,V1,V2);
92d1589b 35 myExtCC.SetCurve(2,myHC->Curve(),V1,V2);
7fd59977 36}
37
38//=======================================================================
39//function : Perform
40//purpose :
41//=======================================================================
42
43void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
44{
45 Standard_Real U1, U2;
46 BRepAdaptor_Curve Curv(E1);
47 Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
48 BRep_Tool::Range(E1,U1,U2);
92d1589b
A
49 myExtCC.SetCurve (1, HC->Curve(), U1, U2);
50 myExtCC.Perform();
7fd59977 51}
52
53//=======================================================================
54//function : ParameterOnE1
55//purpose :
56//=======================================================================
57
92d1589b 58Standard_Real BRepExtrema_ExtCC::ParameterOnE1(const Standard_Integer N) const
7fd59977 59{
60 Extrema_POnCurv POnE1, POnE2;
92d1589b 61 myExtCC.Points(N, POnE1, POnE2);
7fd59977 62 return POnE1.Parameter();
63}
64
65//=======================================================================
66//function : PointOnE1
67//purpose :
68//=======================================================================
69
92d1589b 70gp_Pnt BRepExtrema_ExtCC::PointOnE1(const Standard_Integer N) const
7fd59977 71{
72 Extrema_POnCurv POnE1, POnE2;
92d1589b
A
73 myExtCC.Points(N, POnE1, POnE2);
74 return POnE1.Value();
7fd59977 75}
76
77//=======================================================================
78//function : ParameterOnE2
79//purpose :
80//=======================================================================
81
92d1589b 82Standard_Real BRepExtrema_ExtCC::ParameterOnE2(const Standard_Integer N) const
7fd59977 83{
84 Extrema_POnCurv POnE1, POnE2;
92d1589b 85 myExtCC.Points(N, POnE1, POnE2);
7fd59977 86 return POnE2.Parameter();
87}
88
89//=======================================================================
90//function : PointOnE2
91//purpose :
92//=======================================================================
93
92d1589b 94gp_Pnt BRepExtrema_ExtCC::PointOnE2(const Standard_Integer N) const
7fd59977 95{
96 Extrema_POnCurv POnE1, POnE2;
92d1589b
A
97 myExtCC.Points(N, POnE1, POnE2);
98 return POnE2.Value();
7fd59977 99}
100
101
102//=======================================================================
103//function : TrimmedSquareDistances
104//purpose :
105//=======================================================================
106
107void BRepExtrema_ExtCC::TrimmedSquareDistances
108 (Standard_Real& dist11,
109 Standard_Real& dist12,
110 Standard_Real& dist21,
111 Standard_Real& dist22,
112 gp_Pnt& pnt11,
113 gp_Pnt& pnt12,
114 gp_Pnt& pnt21,
115 gp_Pnt& pnt22) const
116{
92d1589b
A
117 myExtCC.TrimmedSquareDistances(dist11,dist12,dist21,dist22,
118 pnt11,pnt12,pnt21,pnt22);
7fd59977 119}