From 4876a76c00507cba3b615ca6f517b7cc6cf90dfc Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 2 Apr 2009 09:01:59 +0000 Subject: [PATCH] 0020231: A min distance bug with torus and vertex Make GetMinDistance() return 0.0 for a vertex inside a solid --- src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx | 39 +++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index d77245838..61237649d 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -89,21 +89,22 @@ #include #include -#include -#include #include #include +#include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC +#include +#include #include +#include #include #include -#include -#include -#include #include +#include //============================================================================= @@ -1644,6 +1645,34 @@ Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance OCC_CATCH_SIGNALS; #endif + // Issue 0020231: A min distance bug with torus and vertex. + // Make GetMinDistance() return zero if a sole VERTEX is inside any of SOLIDs + + // which of shapes consists of only one vertex? + TopExp_Explorer exp1(aShape1,TopAbs_VERTEX), exp2(aShape2,TopAbs_VERTEX); + TopoDS_Shape V1 = exp1.More() ? exp1.Current() : TopoDS_Shape(); + TopoDS_Shape V2 = exp2.More() ? exp2.Current() : TopoDS_Shape(); + exp1.Next(); exp2.Next(); + if ( exp1.More() ) V1.Nullify(); + if ( exp2.More() ) V2.Nullify(); + // vertex and container of solids + TopoDS_Shape V = V1.IsNull() ? V2 : V1; + TopoDS_Shape S = V1.IsNull() ? aShape1 : aShape2; + if ( !V.IsNull() ) { + // classify vertex against solids + gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( V ) ); + for ( exp1.Init( S, TopAbs_SOLID ); exp1.More(); exp1.Next() ) { + BRepClass3d_SolidClassifier classifier( exp1.Current(), p, 1e-6); + if ( classifier.State() == TopAbs_IN ) { + p.Coord(X1, Y1, Z1); + p.Coord(X2, Y2, Z2); + SetErrorCode(OK); + return 0.0; + } + } + } + // End Issue 0020231 + // skl 30.06.2008 // additional workaround for bugs 19899, 19908 and 19910 from Mantis gp_Pnt Ptmp1, Ptmp2;