From: ptv Date: Thu, 3 Sep 2009 07:29:36 +0000 (+0000) Subject: implementation corrected according to remarks from QA team X-Git-Tag: V5_1_3rc1~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b7382ba6df8e4f96434a3c32cb327e6dcea69213;p=modules%2Fgeom.git implementation corrected according to remarks from QA team --- diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index 28941e9e2..3014eec2b 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -935,6 +935,7 @@ void BasicGUI_PointDlg::addSubshapesToStudy() void BasicGUI_PointDlg::ClickParamCoord() { updateParamCoord( true ); + displayPreview(); } //================================================================================= diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 9a5ebb4c8..f1d64125d 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -64,6 +62,35 @@ GEOMImpl_PointDriver::GEOMImpl_PointDriver() { } +//======================================================================= +//function : getExtremaSolution +//purpose : local function +//======================================================================= +static Standard_Boolean getExtremaSolution +(GEOMImpl_IPoint& thePI, + TopoDS_Shape& theRefShape, + gp_Pnt& thePnt) +{ + gp_Pnt anInitPnt( thePI.GetX(), thePI.GetY(), thePI.GetZ() ); + BRepBuilderAPI_MakeVertex mkVertex (anInitPnt); + TopoDS_Vertex anInitV = TopoDS::Vertex(mkVertex.Shape()); + + BRepExtrema_DistShapeShape anExt( anInitV, theRefShape ); + if ( !anExt.IsDone() || anExt.NbSolution() < 1 ) + return Standard_False; + thePnt = anExt.PointOnShape2(1); + Standard_Real aMinDist2 = anInitPnt.SquareDistance( thePnt ); + for ( Standard_Integer j = 2, jn = anExt.NbSolution(); j <= jn; j++ ) + { + gp_Pnt aPnt = anExt.PointOnShape2(j); + Standard_Real aDist2 = anInitPnt.SquareDistance( aPnt ); + if ( aDist2 > aMinDist2) + continue; + aMinDist2 = aDist2; + thePnt = aPnt; + } + return Standard_True; +} //======================================================================= //function : Execute @@ -114,15 +141,10 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const Standard_TypeMismatch::Raise ("Point On Curve creation aborted : curve shape is not an edge"); } - Standard_Real aFP, aLP; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFP, aLP); - gp_Pnt anInitPnt( aPI.GetX(), aPI.GetY(), aPI.GetZ() ); - GeomAPI_ProjectPointOnCurve aProj(anInitPnt, aCurve/*, aFP, aLP*/); - if ( aProj.NbPoints() <= 0 ) { + if (!getExtremaSolution( aPI, aRefShape, aPnt ) ) { Standard_ConstructionError::Raise ("Point On Curve creation aborted : cannot project point"); } - aPnt = aProj.NearestPoint(); } else if (aType == POINT_SURFACE_PAR) { Handle(GEOM_Function) aRefCurve = aPI.GetSurface(); @@ -147,20 +169,10 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const Standard_TypeMismatch::Raise ("Point On Surface creation aborted : surface shape is not a face"); } - TopoDS_Face F = TopoDS::Face(aRefShape); - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F); - Standard_Real U1,U2,V1,V2; - //aSurf->Bounds(U1,U2,V1,V2); - ShapeAnalysis::GetFaceUVBounds(F,U1,U2,V1,V2); - - gp_Pnt anInitPnt( aPI.GetX(), aPI.GetY(), aPI.GetZ() ); - GeomAPI_ProjectPointOnSurf aProj( anInitPnt, aSurf/*, - U1,U2,V1,V2, Precision::Confusion()*/ ); - if ( !aProj.IsDone() ) { + if (!getExtremaSolution( aPI, aRefShape, aPnt ) ) { Standard_ConstructionError::Raise ("Point On Surface creation aborted : cannot project point"); } - aPnt = aProj.NearestPoint(); } else if (aType == POINT_LINES_INTERSECTION) { Handle(GEOM_Function) aRef1 = aPI.GetLine1();