]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Additional fix for bug 0019898 : Bouding box gives strange values on a sphere.
authormkr <mkr@opencascade.com>
Tue, 5 Aug 2008 14:19:36 +0000 (14:19 +0000)
committermkr <mkr@opencascade.com>
Tue, 5 Aug 2008 14:19:36 +0000 (14:19 +0000)
src/MeasureGUI/Makefile.am
src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx

index e2462292fc323abc7f993b32d8017133de9add65..d0d17512123e907ba2fc644895fda65e6281457b 100644 (file)
@@ -105,6 +105,7 @@ libMeasureGUI_la_CPPFLAGS = \
        -I$(srcdir)/../OBJECT \
        -I$(srcdir)/../GEOMClient \
        -I$(srcdir)/../GEOMImpl \
+       -I$(srcdir)/../GEOM \
        -I$(top_builddir)/idl \
        -I$(top_builddir)/salome_adm/unix
 
index 7023827cdea0cccf03dd2777ea864f08a8e1fed2..39d443310caca64ba349082e81a317905ecf06c4 100644 (file)
 #include "GEOMBase.h"
 #include "GEOM_Displayer.h"
 
+#include <GEOM_Function.hxx>
+#include <GEOM_Object.hxx>
+
 #include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRep_Tool.hxx>
+#include <BRep_TFace.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopExp_Explorer.hxx>
 
 #include "utilities.h"
 #include "SUIT_Session.h"
@@ -161,8 +170,64 @@ bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax,
   {
     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 )
     {