1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0024422: Wrong result done by FaceClassifier algorithm

Control of out of boundaries by finding circle-point extrema.
This commit is contained in:
nbv 2013-12-04 15:07:25 +04:00 committed by abv
parent 6bf1bdbd22
commit 73cd8a8afd
5 changed files with 690 additions and 646 deletions

View File

@ -64,12 +64,12 @@ void BRepClass_Intersector::Perform(const gp_Lin2d& L,
const Standard_Real Tol, const Standard_Real Tol,
const BRepClass_Edge& E) const BRepClass_Edge& E)
{ {
Standard_Real deb, fin, aTolZ; Standard_Real deb = 0.0, fin = 0.0, aTolZ = Tol;
Handle(Geom2d_Curve) aC2D; Handle(Geom2d_Curve) aC2D;
// //
aTolZ=Tol;
const TopoDS_Edge& EE = E.Edge(); const TopoDS_Edge& EE = E.Edge();
const TopoDS_Face& F = E.Face(); const TopoDS_Face& F = E.Face();
// //
aC2D=BRep_Tool::CurveOnSurface(EE, F, deb, fin); aC2D=BRep_Tool::CurveOnSurface(EE, F, deb, fin);
if (aC2D.IsNull()) { if (aC2D.IsNull()) {
@ -84,24 +84,30 @@ void BRepClass_Intersector::Perform(const gp_Lin2d& L,
// //
// Case of "ON": direct check of belonging to edge // Case of "ON": direct check of belonging to edge
// taking into account the tolerance // taking into account the tolerance
Extrema_ExtPC2d theExtPC2d(L.Location(), C); Extrema_ExtPC2d anExtPC2d(L.Location(), C);
Standard_Real MinDist = RealLast(), aDist; Standard_Real MinDist = RealLast(), aDist;
Standard_Integer MinInd = 0, i; Standard_Integer MinInd = 0, i;
if (theExtPC2d.IsDone()) { if (anExtPC2d.IsDone())
for (i = 1; i <= theExtPC2d.NbExt(); ++i) { {
aDist = theExtPC2d.SquareDistance(i); const Standard_Integer aNbPnts = anExtPC2d.NbExt();
if (aDist < MinDist) { for (i = 1; i <= aNbPnts; ++i)
{
aDist = anExtPC2d.SquareDistance(i);
if (aDist < MinDist)
{
MinDist = aDist; MinDist = aDist;
MinInd = i; MinInd = i;
} }
} }
} }
if (MinInd) { if (MinInd) {
MinDist = sqrt(MinDist); MinDist = sqrt(MinDist);
} }
if (MinDist <= aTolZ) { if (MinDist <= aTolZ) {
gp_Pnt2d pnt_exact = (theExtPC2d.Point(MinInd)).Value(); gp_Pnt2d pnt_exact = (anExtPC2d.Point(MinInd)).Value();
Standard_Real par = (theExtPC2d.Point(MinInd)).Parameter(); Standard_Real par = (anExtPC2d.Point(MinInd)).Parameter();
// //
RefineTolerance(F, C, par, aTolZ); RefineTolerance(F, C, par, aTolZ);
// //

View File

@ -1672,8 +1672,8 @@ Standard_Integer concatC0wire(Draw_Interpretor&, Standard_Integer n, const char*
//======================================================================= //=======================================================================
static Standard_Integer concatwire(Draw_Interpretor&, Standard_Integer n, const char** c) static Standard_Integer concatwire(Draw_Interpretor&, Standard_Integer n, const char** c)
{ GeomAbs_Shape Option=GeomAbs_C1; {
GeomAbs_Shape Option=GeomAbs_C1;
if ( n < 3 ) return 1; if ( n < 3 ) return 1;
if(n==4) //check if it's C1 or G1 if(n==4) //check if it's C1 or G1
@ -1686,8 +1686,6 @@ static Standard_Integer concatwire(Draw_Interpretor&, Standard_Integer n, const
TopoDS_Wire W = TopoDS::Wire(S) ; TopoDS_Wire W = TopoDS::Wire(S) ;
TopoDS_Wire res; TopoDS_Wire res;
res=BRepAlgo::ConcatenateWire(W,Option); //processing res=BRepAlgo::ConcatenateWire(W,Option); //processing
DBRep::Set(c[1],res); DBRep::Set(c[1],res);
return 0; return 0;

View File

@ -85,16 +85,18 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
const Standard_Real Uinf, const Standard_Real Uinf,
const Standard_Real Usup) const Standard_Real Usup)
{ {
Standard_Real radius, U1, U2;
// gp_Pnt2d OC, P1, P2, OL; // gp_Pnt2d OC, P1, P2, OL;
gp_Pnt2d OC, P1, P2; gp_Pnt2d OC(C.Location());
OC = C.Location();
myNbExt = 0; myNbExt = 0;
if (OC.IsEqual(P, Precision::Confusion())) { if (OC.IsEqual(P, Precision::Confusion())) {
myDone = Standard_False; myDone = Standard_False;
} }
else { else
{
Standard_Real radius, U1, U2;
gp_Pnt2d P1, P2;
myDone = Standard_True; myDone = Standard_True;
gp_Dir2d V(gp_Vec2d(P, OC)); gp_Dir2d V(gp_Vec2d(P, OC));
radius = C.Radius(); radius = C.Radius();
@ -105,10 +107,20 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
Standard_Real myuinf = Uinf; Standard_Real myuinf = Uinf;
ElCLib::AdjustPeriodic(Uinf, Uinf+2*M_PI, Precision::PConfusion(), myuinf, U1); ElCLib::AdjustPeriodic(Uinf, Uinf+2*M_PI, Precision::PConfusion(), myuinf, U1);
ElCLib::AdjustPeriodic(Uinf, Uinf+2*M_PI, Precision::PConfusion(), myuinf, U2); ElCLib::AdjustPeriodic(Uinf, Uinf+2*M_PI, Precision::PConfusion(), myuinf, U2);
if (((U1-2*M_PI-Uinf) < Tol) && ((U1-2*M_PI-Uinf) > -Tol)) U1 = Uinf; if (((U1-2*M_PI-Uinf) < Tol) && ((U1-2*M_PI-Uinf) > -Tol))
if (((U2-2*M_PI-Uinf) < Tol) && ((U2-2*M_PI-Uinf) > -Tol)) U2 = Uinf; {
U1 = Uinf;
P1 = OC.XY() + radius * (cos(U1) * C.XAxis().Direction().XY() + sin(U1) * C.YAxis().Direction().XY());
}
if (((Uinf-U1) < Tol) && ((U1-Usup) < Tol)) { if (((U2-2*M_PI-Uinf) < Tol) && ((U2-2*M_PI-Uinf) > -Tol))
{
U2 = Uinf;
P2 = OC.XY() + radius * (cos(U2) * C.XAxis().Direction().XY() + sin(U2) * C.YAxis().Direction().XY());
}
if (((Uinf-U1) < Tol) && ((U1-Usup) < Tol))
{
Extrema_POnCurv2d MyPOnCurve(U1, P1); Extrema_POnCurv2d MyPOnCurve(U1, P1);
mySqDist[0] = P.SquareDistance(P1); mySqDist[0] = P.SquareDistance(P1);
myPoint[0] = MyPOnCurve; myPoint[0] = MyPOnCurve;
@ -116,7 +128,8 @@ void Extrema_ExtPElC2d::Perform(const gp_Pnt2d& P,
myNbExt++; myNbExt++;
} }
if (((Uinf-U2) < Tol) && ((U2-Usup) < Tol)) { if (((Uinf-U2) < Tol) && ((U2-Usup) < Tol))
{
Extrema_POnCurv2d MyPOnCurve(U2, P2); Extrema_POnCurv2d MyPOnCurve(U2, P2);
mySqDist[myNbExt] = P.SquareDistance(P2); mySqDist[myNbExt] = P.SquareDistance(P2);
myPoint[myNbExt] = MyPOnCurve; myPoint[myNbExt] = MyPOnCurve;

View File

@ -0,0 +1,27 @@
puts "================"
puts "OCC24422"
puts "================"
puts ""
#######################################################################
# Wrong result done by FaceClassifier algorythm
#######################################################################
restore [locate_data_file bug24422_Compound.brep] b
explode b f
copy b_1 f
point p 115.945392440981 106 230.000108990528
point p_proj 230.00010899052799 1925.9453924409811
set info [b2dclassify f p_proj]
if { [regexp "The point is OUT of shape" $info] != 1 } {
puts "Error : point should be ON shape"
} else {
puts "OK: point is OUT of shape"
}
axo
fit
set only_screen_axo 1