0026674: Performance regression in BRepExtrema_DistShapeShape in OCCT 6.9.0 in compar...
[occt.git] / src / BRepExtrema / BRepExtrema_ExtCC.cxx
CommitLineData
b311480e 1// Created on: 1993-12-15
2// Created by: Christophe MARION
3// Copyright (c) 1993-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
92d1589b
A
17#include <BRepExtrema_ExtCC.hxx>
18
7fd59977 19#include <BRep_Tool.hxx>
7fd59977 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
92d1589b 30BRepExtrema_ExtCC::BRepExtrema_ExtCC(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
7fd59977 31{
32 Initialize(E2);
33 Perform(E1);
34}
35
36//=======================================================================
37//function : Initialize
38//purpose :
39//=======================================================================
40
41void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
42{
43 Standard_Real V1,V2;
44 BRepAdaptor_Curve Curv(E2);
45 myHC = new BRepAdaptor_HCurve(Curv);
0e4e1240 46 Standard_Real Tol = Min(BRep_Tool::Tolerance(E2), Precision::Confusion());
47 Tol = Max(Curv.Resolution(Tol), Precision::PConfusion());
7fd59977 48 BRep_Tool::Range(E2,V1,V2);
92d1589b 49 myExtCC.SetCurve(2,myHC->Curve(),V1,V2);
0e4e1240 50 myExtCC.SetTolerance(2, Tol);
7fd59977 51}
52
53//=======================================================================
54//function : Perform
55//purpose :
56//=======================================================================
57
58void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
59{
60 Standard_Real U1, U2;
61 BRepAdaptor_Curve Curv(E1);
62 Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
0e4e1240 63 Standard_Real Tol = Min(BRep_Tool::Tolerance(E1), Precision::Confusion());
64 Tol = Max(Curv.Resolution(Tol), Precision::PConfusion());
7fd59977 65 BRep_Tool::Range(E1,U1,U2);
92d1589b 66 myExtCC.SetCurve (1, HC->Curve(), U1, U2);
0e4e1240 67 myExtCC.SetTolerance(1, Tol);
836d7b64 68 myExtCC.SetSingleSolutionFlag(Standard_True);
92d1589b 69 myExtCC.Perform();
7fd59977 70}
71
72//=======================================================================
73//function : ParameterOnE1
74//purpose :
75//=======================================================================
76
92d1589b 77Standard_Real BRepExtrema_ExtCC::ParameterOnE1(const Standard_Integer N) const
7fd59977 78{
79 Extrema_POnCurv POnE1, POnE2;
92d1589b 80 myExtCC.Points(N, POnE1, POnE2);
7fd59977 81 return POnE1.Parameter();
82}
83
84//=======================================================================
85//function : PointOnE1
86//purpose :
87//=======================================================================
88
92d1589b 89gp_Pnt BRepExtrema_ExtCC::PointOnE1(const Standard_Integer N) const
7fd59977 90{
91 Extrema_POnCurv POnE1, POnE2;
92d1589b
A
92 myExtCC.Points(N, POnE1, POnE2);
93 return POnE1.Value();
7fd59977 94}
95
96//=======================================================================
97//function : ParameterOnE2
98//purpose :
99//=======================================================================
100
92d1589b 101Standard_Real BRepExtrema_ExtCC::ParameterOnE2(const Standard_Integer N) const
7fd59977 102{
103 Extrema_POnCurv POnE1, POnE2;
92d1589b 104 myExtCC.Points(N, POnE1, POnE2);
7fd59977 105 return POnE2.Parameter();
106}
107
108//=======================================================================
109//function : PointOnE2
110//purpose :
111//=======================================================================
112
92d1589b 113gp_Pnt BRepExtrema_ExtCC::PointOnE2(const Standard_Integer N) const
7fd59977 114{
115 Extrema_POnCurv POnE1, POnE2;
92d1589b
A
116 myExtCC.Points(N, POnE1, POnE2);
117 return POnE2.Value();
7fd59977 118}
119
120
121//=======================================================================
122//function : TrimmedSquareDistances
123//purpose :
124//=======================================================================
125
126void BRepExtrema_ExtCC::TrimmedSquareDistances
127 (Standard_Real& dist11,
128 Standard_Real& dist12,
129 Standard_Real& dist21,
130 Standard_Real& dist22,
131 gp_Pnt& pnt11,
132 gp_Pnt& pnt12,
133 gp_Pnt& pnt21,
134 gp_Pnt& pnt22) const
135{
92d1589b
A
136 myExtCC.TrimmedSquareDistances(dist11,dist12,dist21,dist22,
137 pnt11,pnt12,pnt21,pnt22);
7fd59977 138}