From: jfa Date: Tue, 25 Sep 2012 13:07:23 +0000 (+0000) Subject: Mantis issue 0021864: [CEA 669] Wrong size of the bounding box. Clean triangulation... X-Git-Tag: V6_6_0a1~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9e0b80f6935d7be7d52da1012b28bc096ccaac6;p=modules%2Fgeom.git Mantis issue 0021864: [CEA 669] Wrong size of the bounding box. Clean triangulation on the Engine side. --- diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 98abba29c..df3a87a49 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -40,10 +39,8 @@ #include #include #include -//#include #include #include -//#include #include #include @@ -58,22 +55,23 @@ #include #include +#include +#include #include #include +#include #include #include #include #include #include +#include #include #include #include #include -#include -#include - #include #include #include @@ -81,48 +79,48 @@ #include #include #include +#include #include #include #include #include #include +#include +#include +#include + +#include +#include + #include -#include + +#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include -#include -#include +#include #include #include -#include -#include -#include -#include -#include - -#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 +#include +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= /*! @@ -794,10 +792,10 @@ gp_Ax3 GEOMImpl_IMeasureOperations::GetPosition (const TopoDS_Shape& theShape) if(theShape.Orientation() == TopAbs_REVERSED) { gp_Dir Vx = aResult.XDirection(); - gp_Dir N = aResult.Direction().Mirrored(Vx); + gp_Dir N = aResult.Direction().Mirrored(Vx); gp_Pnt P = aResult.Location(); aResult = gp_Ax3(P, N, Vx); - } + } } } @@ -1206,6 +1204,17 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox #if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif + BRepBuilderAPI_Copy aCopyTool (aShape); + if (!aCopyTool.IsDone()) { + SetErrorCode("GetBoundingBox Error: Bad shape detected"); + return; + } + + aShape = aCopyTool.Shape(); + + // remove triangulation to obtain more exact boundaries + BRepTools::Clean(aShape); + BRepBndLib::Add(aShape, B); B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); } @@ -1386,7 +1395,7 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections const NMTDS_ShapesDataStructure& aDS = *(aCSI.DS()); Standard_Integer aNbS = aDS.NumberOfShapesOfTheObject(); - // 3. Get the pairs of interfered shapes + // 3. Get the pairs of interfered shapes NMTDS_PInterfPool pIP = aCSI.IP(); //const NMTDS_ListOfPassKeyBoolean& aLPKB = pIP->Get(); const NMTDS_ListOfPairBoolean& aLPKB = pIP->Get(); diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx index 3544009ac..d3eb0603a 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : MeasureGUI_BndBoxDlg.cxx // Author : Nicolas REJNERI, Open CASCADE S.A.S. -// + #include "MeasureGUI_BndBoxDlg.h" #include "MeasureGUI_Widgets.h" @@ -32,37 +31,20 @@ #include #include -#include -#include - #include -#include -#include -#include -#include -#include -#include #include #include -#include - -// #include -// #include -// #include -// #include -// #include -// #include //================================================================================= // class : MeasureGUI_BndBoxDlg() -// purpose : Constructs a MeasureGUI_BndBoxDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_BndBoxDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to // true to construct a modal dialog. //================================================================================= -MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( GeometryGUI* GUI, QWidget* parent ) - : MeasureGUI_Skeleton( GUI, parent ) +MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg (GeometryGUI* GUI, QWidget* parent) + : MeasureGUI_Skeleton(GUI, parent) { QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BOUNDING_BOX" ) ) ); @@ -72,7 +54,7 @@ MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( GeometryGUI* GUI, QWidget* parent ) setWindowTitle( tr( "GEOM_BNDBOX_TITLE" ) ); /***************************************************************/ - + mainFrame()->GroupConstructors->setTitle( tr( "GEOM_BNDBOX" ) ); mainFrame()->RadioButton1->setIcon( image0 ); @@ -102,7 +84,7 @@ MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( GeometryGUI* GUI, QWidget* parent ) QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->addWidget( myGrp ); - + /***************************************************************/ myHelpFileName = "using_measurement_tools_page.html#bounding_box_anchor"; @@ -111,7 +93,6 @@ MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( GeometryGUI* GUI, QWidget* parent ) Init(); } - //================================================================================= // function : ~MeasureGUI_BndBoxDlg() // purpose : Destroys the object and frees any allocated resources @@ -120,7 +101,6 @@ MeasureGUI_BndBoxDlg::~MeasureGUI_BndBoxDlg() { } - //================================================================================= // function : Init() // purpose : @@ -140,14 +120,14 @@ void MeasureGUI_BndBoxDlg::processObject() { double aXMin, aXMax, aYMin, aYMax, aZMin, aZMax; - if ( !getParameters( aXMin, aXMax, aYMin, aYMax, aZMin, aZMax ) ) { - mySelEdit->setText( "" ); - myGrp->LineEdit11->setText( "" ); - myGrp->LineEdit12->setText( "" ); - myGrp->LineEdit21->setText( "" ); - myGrp->LineEdit22->setText( "" ); - myGrp->LineEdit31->setText( "" ); - myGrp->LineEdit32->setText( "" ); + if (!getParameters(aXMin, aXMax, aYMin, aYMax, aZMin, aZMax)) { + mySelEdit->setText(""); + myGrp->LineEdit11->setText(""); + myGrp->LineEdit12->setText(""); + myGrp->LineEdit21->setText(""); + myGrp->LineEdit22->setText(""); + myGrp->LineEdit31->setText(""); + myGrp->LineEdit32->setText(""); } else { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -168,71 +148,17 @@ void MeasureGUI_BndBoxDlg::processObject() // function : getParameters // purpose : //================================================================================= -bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax, +bool MeasureGUI_BndBoxDlg::getParameters (double& theXmin, double& theXmax, double& theYmin, double& theYmax, - double& theZmin, double& theZmax ) + double& theZmin, double& theZmax) { - if ( myObj->_is_nil() ) + if (myObj->_is_nil()) return false; - else { - GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); - try { - Handle(Poly_Triangulation) Trtn = 0; - - GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); - if ( CORBA::is_nil(aGeomGen) ) - return false; - - QString IOR = GEOMBase::GetIORFromObject( myObj ); - GEOM::GEOM_Object_var anObject = aGeomGen->GetIORFromString( IOR.toLatin1().constData() ); - if ( CORBA::is_nil(anObject) ) - return false; - - TopoDS_Shape aShape; - GEOMBase::GetShape(anObject, aShape, TopAbs_SHAPE); - if ( aShape.IsNull() ) - return false; - - 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; - } - - anOper->GetBoundingBox( myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax ); - - if (!Trtn.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 ); - return false; - } - - return anOper->IsDone(); - } + + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation()); + anOper->GetBoundingBox(myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax); + + return anOper->IsDone(); } //================================================================================= @@ -243,12 +169,11 @@ SALOME_Prs* MeasureGUI_BndBoxDlg::buildPrs() { double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax; - if ( myObj->_is_nil() || !getParameters( aXMin, aXMax, aYMin, aYMax, aZMin, aZMax ) ) + if (!getParameters(aXMin, aXMax, aYMin, aYMax, aZMin, aZMax)) return 0; - TopoDS_Shape aShape = BRepPrimAPI_MakeBox( gp_Pnt( aXMin, aYMin, aZMin ), - gp_Pnt( aXMax, aYMax, aZMax ) ).Shape(); - - return !aShape.IsNull() ? getDisplayer()->BuildPrs( aShape ) : 0; + TopoDS_Shape aShape = BRepPrimAPI_MakeBox(gp_Pnt(aXMin, aYMin, aZMin), + gp_Pnt(aXMax, aYMax, aZMax)).Shape(); + return !aShape.IsNull() ? getDisplayer()->BuildPrs(aShape) : 0; }