Mantis issue 0020589: EDF 1171 GEOM : Check compound of blocks: crash.

This commit is contained in:
jfa 2009-11-18 09:51:48 +00:00
parent 8318d78792
commit fdb8899989

View File

@ -22,7 +22,7 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : MeasureGUI_CheckCompoundOfBlocksDlg.cxx // File : MeasureGUI_CheckCompoundOfBlocksDlg.cxx
// Author : Vladimir KLYACHIN, Open CASCADE S.A.S. (vladimir.klyachin@opencascade.com) // Author : Vladimir KLYACHIN, Open CASCADE S.A.S. (vladimir.klyachin@opencascade.com)
//
#include "MeasureGUI_CheckCompoundOfBlocksDlg.h" #include "MeasureGUI_CheckCompoundOfBlocksDlg.h"
#include "MeasureGUI_Widgets.h" #include "MeasureGUI_Widgets.h"
@ -123,8 +123,8 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::Init()
connect( myGrp->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect( myGrp->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGrp->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( myGrp->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ); this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_BLOCKS_COMPOUND") ); initName( tr( "GEOM_BLOCKS_COMPOUND") );
buttonOk()->setEnabled( false ); buttonOk()->setEnabled( false );
@ -236,7 +236,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::ActivateThisDialog()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBlocks, bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBlocks,
GEOM::GEOM_IBlocksOperations::BCErrors& theErrors) GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
{ {
if ( myObj->_is_nil() ) if ( myObj->_is_nil() )
return false; return false;
@ -245,7 +245,9 @@ bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBloc
try { try {
GEOM::GEOM_IBlocksOperations::BCErrors_var aErrs; GEOM::GEOM_IBlocksOperations::BCErrors_var aErrs;
theIsCompoundOfBlocks = anOper->CheckCompoundOfBlocks( myObj, aErrs ); theIsCompoundOfBlocks = anOper->CheckCompoundOfBlocks( myObj, aErrs );
theErrors = aErrs; if (anOper->IsDone() && aErrs->length() > 0)
//if (anOper->IsDone() && !aErrs._is_nil())
theErrors = aErrs;
} }
catch ( const SALOME::SALOME_Exception& e ) { catch ( const SALOME::SALOME_Exception& e ) {
SalomeApp_Tools::QtCatchCorbaException( e ); SalomeApp_Tools::QtCatchCorbaException( e );
@ -266,6 +268,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
bool isCompoundOfBlocks; bool isCompoundOfBlocks;
GEOM::GEOM_IBlocksOperations::BCErrors aErrs; GEOM::GEOM_IBlocksOperations::BCErrors aErrs;
if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) { if ( !getBCErrors( isCompoundOfBlocks, aErrs ) ) {
aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_FAILED" );
myGrp->TextView1->setText( aMsg ); myGrp->TextView1->setText( aMsg );
myGrp->ListBox1->clear(); myGrp->ListBox1->clear();
myGrp->ListBox2->clear(); myGrp->ListBox2->clear();
@ -277,7 +280,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" ); aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" );
buttonOk()->setEnabled( false ); buttonOk()->setEnabled( false );
buttonApply()->setEnabled( false ); buttonApply()->setEnabled( false );
} }
else { else {
aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" ); aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" );
buttonOk()->setEnabled( true ); buttonOk()->setEnabled( true );
@ -295,29 +298,29 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
aErrStr = ""; aErrStr = "";
switch ( aErrs[i].error ) { switch ( aErrs[i].error ) {
case GEOM::GEOM_IBlocksOperations::NOT_BLOCK : case GEOM::GEOM_IBlocksOperations::NOT_BLOCK :
aErrStr = "Not a Block"; aErrStr = "Not a Block";
break; break;
case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE : case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE :
aErrStr = "Extra Edge"; aErrStr = "Extra Edge";
break; break;
case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION : case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION :
aErrStr = "Invalid Connection"; aErrStr = "Invalid Connection";
aErrStr += aConSfx; aErrStr += aConSfx;
aErrStr += QString::number( aConNum ); aErrStr += QString::number( aConNum );
aConNum++; aConNum++;
break; break;
case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED : case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED :
aErrStr = "Not Connected"; aErrStr = "Not Connected";
break; break;
case GEOM::GEOM_IBlocksOperations::NOT_GLUED : case GEOM::GEOM_IBlocksOperations::NOT_GLUED :
aErrStr = "Not Glued"; aErrStr = "Not Glued";
aErrStr += aGluedSfx; aErrStr += aGluedSfx;
aErrStr += QString::number( aGluedNum ); aErrStr += QString::number( aGluedNum );
aGluedNum++; aGluedNum++;
break; break;
default : default :
aErrStr = ""; aErrStr = "";
break; break;
} }
if ( !aErrStr.isEmpty() ) if ( !aErrStr.isEmpty() )
aErrList.append( aErrStr ); aErrList.append( aErrStr );
@ -355,11 +358,11 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
myGrp->ListBox2->clear(); myGrp->ListBox2->clear();
return; return;
} }
GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aCurItem]; GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aCurItem];
GEOM::ListOfLong aObjLst = aErr.incriminated; GEOM::ListOfLong aObjLst = aErr.incriminated;
TopoDS_Shape aSelShape; TopoDS_Shape aSelShape;
TopoDS_Shape aSubShape; TopoDS_Shape aSubShape;
TopTools_IndexedMapOfShape anIndices; TopTools_IndexedMapOfShape anIndices;
QStringList aSubShapeList; QStringList aSubShapeList;
QString aSubShapeName( "" ); QString aSubShapeName( "" );
@ -369,8 +372,8 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
for ( int i = 0, n = aObjLst.length(); i < n; i++ ) { for ( int i = 0, n = aObjLst.length(); i < n; i++ ) {
aSubShapeName = ""; aSubShapeName = "";
aSubShape = anIndices.FindKey(aObjLst[i]); aSubShape = anIndices.FindKey(aObjLst[i]);
if ( GEOMBase::GetShapeTypeString( aSubShape, aTypeString ) ) if ( GEOMBase::GetShapeTypeString( aSubShape, aTypeString ) )
aSubShapeName = QString( aTypeString ) + QString( "_" ) + QString::number( aObjLst[i] ); aSubShapeName = QString( aTypeString ) + QString( "_" ) + QString::number( aObjLst[i] );
if ( !aSubShapeName.isEmpty() ) if ( !aSubShapeName.isEmpty() )
aSubShapeList.append( aSubShapeName ); aSubShapeList.append( aSubShapeName );
} }
@ -391,7 +394,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
return; return;
QList<int> aIds; QList<int> aIds;
for ( int i = 0, n = myGrp->ListBox2->count(); i < n; i++ ) { for ( int i = 0, n = myGrp->ListBox2->count(); i < n; i++ ) {
if ( myGrp->ListBox2->item( i )->isSelected() ) if ( myGrp->ListBox2->item( i )->isSelected() )
aIds.append( i ); aIds.append( i );
} }
if ( aIds.count() < 1 ) if ( aIds.count() < 1 )
@ -404,11 +407,11 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
myGrp->ListBox2->clear(); myGrp->ListBox2->clear();
return; return;
} }
GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aErrCurItem]; GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aErrCurItem];
GEOM::ListOfLong aObjLst = aErr.incriminated; GEOM::ListOfLong aObjLst = aErr.incriminated;
TopoDS_Shape aSelShape; TopoDS_Shape aSelShape;
TopoDS_Shape aSubShape; TopoDS_Shape aSubShape;
TopTools_IndexedMapOfShape anIndices; TopTools_IndexedMapOfShape anIndices;
if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) { if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) {
QString aMess; QString aMess;
@ -426,7 +429,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
getDisplayer()->SetToActivate( false ); getDisplayer()->SetToActivate( false );
aPrs = !aSubShape.IsNull() ? getDisplayer()->BuildPrs( aSubShape ) : 0; aPrs = !aSubShape.IsNull() ? getDisplayer()->BuildPrs( aSubShape ) : 0;
if ( aPrs ) if ( aPrs )
displayPreview( aPrs, true ); displayPreview( aPrs, true );
} }
catch ( const SALOME::SALOME_Exception& e ) { catch ( const SALOME::SALOME_Exception& e ) {
SalomeApp_Tools::QtCatchCorbaException( e ); SalomeApp_Tools::QtCatchCorbaException( e );