1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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,41 +1,27 @@
// File: BRepExtrema_ExtPF.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
// modified by MPS (june 96) : on utilise BRepClass_FaceClassifier seulement
// si IsDone de Extrema est vrai
#include <BRepExtrema_ExtPF.ixx>
#include <BRepExtrema_ExtPF.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <gp_Pnt2d.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_HSurface.hxx>
//=======================================================================
//function : BRepExtrema_ExtPF
//purpose :
//=======================================================================
BRepExtrema_ExtPF::BRepExtrema_ExtPF()
BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace,
const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
{
}
//=======================================================================
//function : BRepExtrema_ExtPF
//purpose :
//=======================================================================
BRepExtrema_ExtPF::BRepExtrema_ExtPF
(const TopoDS_Vertex& V,
const TopoDS_Face& E)
{
Initialize(E);
Perform(V, E);
Initialize(TheFace,TheFlag,TheAlgo);
Perform(TheVertex,TheFace);
}
//=======================================================================
@@ -43,15 +29,18 @@ BRepExtrema_ExtPF::BRepExtrema_ExtPF
//purpose :
//=======================================================================
void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& F)
void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
{
// cette surface doit etre en champ. Extrema ne fait
// pas de copie et prend seulement un pointeur dessus.
mySurf.Initialize(F, Standard_False);
Standard_Real Tol = BRep_Tool::Tolerance(F);
mySurf.Initialize(TheFace, Standard_False);
const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(F, U1, U2, V1, V2);
myExtrem.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
myExtPS.SetFlag(TheFlag);
myExtPS.SetAlgo(TheAlgo);
myExtPS.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
}
//=======================================================================
@@ -59,95 +48,31 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& F)
//purpose :
//=======================================================================
void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& V,
const TopoDS_Face& E)
void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace)
{
mySqDist.Clear();
myPoints.Clear();
gp_Pnt P = BRep_Tool::Pnt(V);
myExtrem.Perform(P);
// exploration des points et classification:
if (myExtrem.IsDone()) {
BRepClass_FaceClassifier classifier;
gp_Pnt2d Puv;
Standard_Real U1, U2;
TopAbs_State state;
Standard_Real Tol = BRep_Tool::Tolerance(E);
mynbext = 0;
for (Standard_Integer i = 1; i <= myExtrem.NbExt(); i++) {
myExtrem.Point(i).Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(E, Puv, Tol);
state = classifier.State();
if(state == TopAbs_ON || state == TopAbs_IN) {
mynbext++;
mySqDist.Append(myExtrem.SquareDistance(i));
myPoints.Append(myExtrem.Point(i));
const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
myExtPS.Perform(P);
// Exploration of points and classification
if (myExtPS.IsDone())
{
BRepClass_FaceClassifier classifier;
Standard_Real U1, U2;
const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++)
{
myExtPS.Point(i).Parameter(U1, U2);
const gp_Pnt2d Puv(U1, U2);
classifier.Perform(TheFace, Puv, Tol);
const TopAbs_State state = classifier.State();
if(state == TopAbs_ON || state == TopAbs_IN)
{
mySqDist.Append(myExtPS.SquareDistance(i));
myPoints.Append(myExtPS.Point(i));
}
}
}
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtPF::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtPF::NbExt() const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
return mynbext;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtPF::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 : Parameters
//purpose :
//=======================================================================
void BRepExtrema_ExtPF::Parameter(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();
myPoints.Value(N).Parameter(U, V);
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtPF::Point
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPoints.Value(N).Value();
return P;
}