From 0aaa28ad2d469d56876be704969ae1253f9b7303 Mon Sep 17 00:00:00 2001 From: mkr Date: Tue, 5 Aug 2008 14:26:52 +0000 Subject: [PATCH] Additional fix for bug 0019898 : Bouding box gives strange values on a sphere. --- src/MeasureGUI/Makefile.am | 1 + src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx | 65 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/MeasureGUI/Makefile.am b/src/MeasureGUI/Makefile.am index b49aa8aa6..c916457c7 100644 --- a/src/MeasureGUI/Makefile.am +++ b/src/MeasureGUI/Makefile.am @@ -119,6 +119,7 @@ libMeasureGUI_la_CPPFLAGS = \ -I$(srcdir)/../OBJECT \ -I$(srcdir)/../GEOMClient \ -I$(srcdir)/../GEOMImpl \ + -I$(srcdir)/../GEOM \ -I$(top_builddir)/src/DlgRef \ -I$(top_builddir)/idl \ -I$(top_builddir)/salome_adm/unix diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx index b478e6158..561d58c31 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx @@ -28,7 +28,16 @@ #include +#include +#include + #include +#include +#include +#include +#include +#include +#include #include #include @@ -154,8 +163,64 @@ bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax, return false; else { try { + Handle(Poly_Triangulation) Trtn = 0; + + Handle(GEOM_Object) anObject = GEOM_Engine::GetEngine()->GetObject(myObj->GetStudyID(), myObj->GetEntry()); + if (!anObject.IsNull()) + { + Handle(GEOM_Function) aRefShape = anObject->GetLastFunction(); + if (!aRefShape.IsNull()) + { + TopoDS_Shape aShape = aRefShape->GetValue(); + if (!aShape.IsNull()) + { + TopLoc_Location l; + Handle(Poly_Triangulation) T; + TopExp_Explorer ex; + for (ex.Init(aShape,TopAbs_FACE); ex.More(); ex.Next()) { + const TopoDS_Face& F = TopoDS::Face(ex.Current()); + + BRepAdaptor_Surface surf(F); + if (surf.GetType() == GeomAbs_Sphere) + { + T = BRep_Tool::Triangulation(F, l); + if (!T.IsNull()) { + Handle(Poly_Triangulation) NullTrtn = 0; + (*((Handle(BRep_TFace)*)&F.TShape()))->Triangulation(NullTrtn); + Trtn = T; + break; + } + } + else + break; + } + } + } + } + GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBoundingBox( myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax ); + + if (!Trtn.IsNull()) + { + Handle(GEOM_Function) aRefShape = anObject->GetLastFunction(); + if (!aRefShape.IsNull()) + { + TopoDS_Shape aShape = aRefShape->GetValue(); + if (!aShape.IsNull()) + { + TopLoc_Location l; + Handle(Poly_Triangulation) T; + TopExp_Explorer ex; + for (ex.Init(aShape,TopAbs_FACE); ex.More(); ex.Next()) { + const TopoDS_Face& F = TopoDS::Face(ex.Current()); + (*((Handle(BRep_TFace)*)&F.TShape()))->Triangulation(Trtn); + break; + } + } + } + } + } catch( const SALOME::SALOME_Exception& e ) { SalomeApp_Tools::QtCatchCorbaException( e ); -- 2.39.2