1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

OCC22322 Improvement of Extrema performance

This commit is contained in:
ASH
2011-05-19 10:50:52 +00:00
committed by bugmaster
parent ae07527556
commit 92d1589b7f
33 changed files with 3246 additions and 2609 deletions

View File

@@ -1,22 +1,15 @@
// File: BRepExtrema_ExtFF.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
// modified by mps (juillet 96 ): on utilise BRepAdaptor a la place de
// GeomAdaptor dans Initialize et Perform.
#include <BRepExtrema_ExtFF.ixx>
#include <BRepExtrema_ExtFF.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Geom_Curve.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <TopoDS.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom_Surface.hxx>
#include <Extrema_POnSurf.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_HSurface.hxx>
@@ -26,22 +19,12 @@
//purpose :
//=======================================================================
BRepExtrema_ExtFF::BRepExtrema_ExtFF()
{
}
//=======================================================================
//function : BRepExtrema_ExtFF
//purpose :
//=======================================================================
BRepExtrema_ExtFF::BRepExtrema_ExtFF
(const TopoDS_Face& F1,
const TopoDS_Face& F2)
BRepExtrema_ExtFF::BRepExtrema_ExtFF(const TopoDS_Face& F1, const TopoDS_Face& F2)
{
Initialize(F2);
Perform(F1,F2);
}
//=======================================================================
//function : Initialize
//purpose :
@@ -51,11 +34,10 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
{
BRepAdaptor_Surface Surf(F2);
myHS = new BRepAdaptor_HSurface(Surf);
Standard_Real Tol = BRep_Tool::Tolerance(F2);
const Standard_Real Tol = BRep_Tool::Tolerance(F2);
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(F2, U1, U2, V1, V2);
myExtrem.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
}
//=======================================================================
@@ -63,156 +45,52 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1,
const TopoDS_Face& F2)
void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
{
Standard_Real U1, U2, V1, V2;
Standard_Integer i;
mySqDist.Clear();
myPointsOnS1.Clear();
myPointsOnS2.Clear();
BRepAdaptor_Surface Surf1(F1);
Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
const Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(F1, U1, U2, V1, V2);
myExtrem.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
// exploration des points et classification:
BRepClass_FaceClassifier classifier;
gp_Pnt2d Puv;
TopAbs_State state1, state2;
Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
Extrema_POnSurf P1, P2;
mynbext = 0;
if (!myExtSS.IsDone())
return;
if (myExtrem.IsParallel()) {
mySqDist.Append(myExtrem.SquareDistance(1));
mynbext = 1;
}
else {
for (i = 1; i <= myExtrem.NbExt(); i++) {
myExtrem.Points(i, P1, P2);
if (myExtSS.IsParallel())
mySqDist.Append(myExtSS.SquareDistance(1));
else
{
// Exploration of points and classification
BRepClass_FaceClassifier classifier;
const Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
Extrema_POnSurf P1, P2;
Standard_Integer i;
for (i = 1; i <= myExtSS.NbExt(); i++)
{
myExtSS.Points(i, P1, P2);
P1.Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(F1, Puv, Tol1);
state1 = classifier.State();
P2.Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(F2, Puv, Tol2);
state2 = classifier.State();
if((state1 == TopAbs_ON || state1 == TopAbs_IN) &&
(state2 == TopAbs_ON || state2 == TopAbs_IN)) {
mynbext++;
mySqDist.Append(myExtrem.SquareDistance(i));
myPointsOnS1.Append(P1);
myPointsOnS2.Append(P2);
const gp_Pnt2d Puv1(U1, U2);
classifier.Perform(F1, Puv1, Tol1);
const TopAbs_State state1 = classifier.State();
if (state1 == TopAbs_ON || state1 == TopAbs_IN)
{
P2.Parameter(U1, U2);
const gp_Pnt2d Puv2(U1, U2);
classifier.Perform(F2, Puv2, Tol2);
const TopAbs_State state2 = classifier.State();
if (state2 == TopAbs_ON || state2 == TopAbs_IN)
{
mySqDist.Append(myExtSS.SquareDistance(i));
myPointsOnS1.Append(P1);
myPointsOnS2.Append(P2);
}
}
}
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtFF::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : IsParallel
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtFF::IsParallel()const
{
return myExtrem.IsParallel();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtFF::NbExt() const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
return mynbext;
}
//=======================================================================
//function : SquareDistance
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtFF::SquareDistance
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
return mySqDist.Value(N);
}
//=======================================================================
//function : ParameterOnFace1
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::ParameterOnFace1(const Standard_Integer N,
Standard_Real& U,
Standard_Real& V) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
myPointsOnS1.Value(N).Parameter(U, V);
}
//=======================================================================
//function : PointOnFace1
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtFF::PointOnFace1
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPointsOnS1.Value(N).Value();
return P;
}
//=======================================================================
//function : ParameterOnFace2
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::ParameterOnFace2(const Standard_Integer N,
Standard_Real& U,
Standard_Real& V) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
myPointsOnS2.Value(N).Parameter(U, V);
}
//=======================================================================
//function : PointOnFace1
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtFF::PointOnFace2
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPointsOnS2.Value(N).Value();
return P;
}