#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_HypothesesUtils.h"
+#include "SMESHGUI_MeshEditPreview.h"
+#include "SMESH_ActorUtils.h"
#include "SMDS_SetIterator.hxx"
-#include <SMDS_Mesh.hxx>
+#include "SMDS_Mesh.hxx"
#include "GEOMBase.h"
#include "GEOM_Actor.h"
(new QFrame(father))->setFrameStyle(QFrame::HLine | QFrame::Sunken);\
}
-enum TCol { COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, NB_COLUMNS };
+enum TCol {
+ COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
+};
using namespace SMESH;
{
char* myBuf;
MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
- ~MemoryReserve() { delete [] myBuf; }
+ void release() { delete [] myBuf; myBuf = 0; }
+ ~MemoryReserve() { release(); }
};
// =========================================================================================
/*!
* \brief Return a list of selected rows
*/
- bool getSelectedRows(QTable* table, list< int > & rows)
+ int getSelectedRows(QTable* table, list< int > & rows)
{
rows.clear();
int nbSel = table->numSelections();
if (rows.empty() && table->currentRow() > -1 )
rows.push_back( table->currentRow() );
- return !rows.empty();
+ return rows.size();
}
} // namespace SMESH
myTable = new QTable( 1, NB_COLUMNS, myCompErrorGroup, "myTable");
myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup, "myShowBtn");
myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup, "myPublishBtn");
+ myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup, "myBadMeshBtn");
myTable->setReadOnly( TRUE );
myTable->hideColumn( COL_PUBLISHED );
myTable->hideColumn( COL_SHAPEID );
+ myTable->hideColumn( COL_BAD_MESH );
myTable->setColumnStretchable( COL_ERROR, 1 );
for ( int col = 0; col < NB_COLUMNS; ++col ) {
QString header;
grpLayout->setAlignment(Qt::AlignTop);
grpLayout->setSpacing(SPACING);
grpLayout->setMargin(MARGIN);
- grpLayout->addMultiCellWidget( myTable, 0, 2, 0, 0 );
+ grpLayout->addMultiCellWidget( myTable, 0, 3, 0, 0 );
grpLayout->addWidget ( myShowBtn, 0, 1 );
grpLayout->addWidget ( myPublishBtn, 1, 1 );
- grpLayout->setRowStretch( 2, 1 );
+ grpLayout->addWidget ( myBadMeshBtn, 2, 1 );
+ grpLayout->setRowStretch( 3, 1 );
// Hypothesis definition errors
{
myDlg = new SMESHGUI_ComputeDlg;
myTShapeDisplayer = new TShapeDisplayer();
+ myBadMeshDisplayer = 0;
+
//myHelpFileName = "/files/about_meshes.htm"; // V3
myHelpFileName = "about_meshes_page.html"; // V4
// connect signals and slots
connect(myDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
+ connect(myDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
connect(table(),SIGNAL(selectionChanged()), SLOT(currentCellChanged()));
connect(table(),SIGNAL(currentChanged(int,int)), SLOT(currentCellChanged()));
}
// check selection
- SMESH::SMESH_Mesh_var aMesh;
+ myMesh = SMESH::SMESH_Mesh::_nil();
myMainShape = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr *Sel = selectionMgr();
}
Handle(SALOME_InteractiveObject) IObject = selected.First();
- aMesh = SMESH::GetMeshByIO(IObject);
- if (aMesh->_is_nil()) {
+ myMesh = SMESH::GetMeshByIO(IObject);
+ if (myMesh->_is_nil()) {
SUIT_MessageBox::warn1(desktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_NO_AVAILABLE_DATA"),
bool computeFailed = true, memoryLack = false;
- _PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
- myMainShape = aMesh->GetShapeToMesh();
- bool hasShape = aMesh->HasShapeToMesh();
+ _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
+ myMainShape = myMesh->GetShapeToMesh();
+ bool hasShape = myMesh->HasShapeToMesh();
bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
if ( shapeOK && aMeshSObj )
{
myDlg->myMeshName->setText( aMeshSObj->GetName() );
SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
- SMESH::algo_error_array_var errors = gen->GetAlgoState(aMesh,myMainShape);
+ SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
if ( errors->length() > 0 ) {
aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
}
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- if (gen->Compute(aMesh, myMainShape))
+ if (gen->Compute(myMesh, myMainShape))
computeFailed = false;
}
catch(const SALOME::SALOME_Exception & S_ex){
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- aCompErrors = gen->GetComputeErrors( aMesh, myMainShape );
+ aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
// check if there are memory problems
for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
// NPAL16631: if ( !memoryLack )
{
- SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);
+ SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
update( UF_ObjBrowser | UF_Model );
// SHOW MESH
Sel->setSelectedObjects( selected );
}
}
+
+ if ( memoryLack )
+ aMemoryReserve.release();
+
myDlg->setCaption(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
myDlg->myMemoryLackGroup->hide();
}
else if ( noCompError && noHypoError )
{
- myDlg->myFullInfo->SetInfoByMesh( aMesh );
+ myDlg->myFullInfo->SetInfoByMesh( myMesh );
myDlg->myFullInfo->show();
myDlg->myBriefInfo->hide();
myDlg->myHypErrorGroup->hide();
else
{
QTable* tbl = myDlg->myTable;
- myDlg->myBriefInfo->SetInfoByMesh( aMesh );
+ myDlg->myBriefInfo->SetInfoByMesh( myMesh );
myDlg->myBriefInfo->show();
myDlg->myFullInfo->hide();
else tbl->showColumn( COL_SHAPE );
tbl->setColumnWidth( COL_ERROR, 200 );
+ bool hasBadMesh = false;
for ( int row = 0; row < aCompErrors->length(); ++row )
{
SMESH::ComputeError & err = aCompErrors[ row ];
text = ( !hasShape || getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
tbl->setText( row, COL_PUBLISHED, text ); // if text=="", "PUBLISH" button enabled
+ text = err.hasBadMesh ? "hasBadMesh" : "";
+ tbl->setText( row, COL_BAD_MESH, text );
+ if ( err.hasBadMesh ) hasBadMesh = true;
+
tbl->item( row, COL_ERROR )->setWordWrap( TRUE );
tbl->adjustRow( row );
}
tbl->adjustColumn( COL_ALGO );
tbl->adjustColumn( COL_SHAPE );
+ if ( hasBadMesh )
+ myDlg->myBadMeshBtn->show();
+ else
+ myDlg->myBadMeshBtn->hide();
+
tbl->setCurrentCell(0,0);
currentCellChanged(); // to update buttons
}
{
SMESHGUI_Operation::stopOperation();
myTShapeDisplayer->SetVisibility( false );
+ if ( myBadMeshDisplayer ) {
+ myBadMeshDisplayer->SetVisibility( false );
+ // delete it in order not to have problems at its destruction when the viewer
+ // where it worked is dead due to e.g. study closing
+ delete myBadMeshDisplayer;
+ myBadMeshDisplayer = 0;
+ }
}
//================================================================================
currentCellChanged(); // to update buttons
}
+//================================================================================
+/*!
+ * \brief show mesh elements preventing computation of a submesh of current row
+ */
+//================================================================================
+
+void SMESHGUI_ComputeOp::onShowBadMesh()
+{
+ myTShapeDisplayer->SetVisibility( false );
+ list< int > rows;
+ if ( getSelectedRows( table(), rows ) == 1 ) {
+ bool hasBadMesh = ( !table()->text(rows.front(), COL_BAD_MESH).isEmpty() );
+ if ( hasBadMesh ) {
+ int curSub = table()->text(rows.front(), COL_SHAPEID).toInt();
+ SMESHGUI* gui = getSMESHGUI();
+ SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
+ SVTK_ViewWindow* view = GetViewWindow( gui );
+ if ( myBadMeshDisplayer ) delete myBadMeshDisplayer;
+ myBadMeshDisplayer = new SMESHGUI_MeshEditPreview( view );
+ SMESH::MeshPreviewStruct_var aMeshData = gen->GetBadInputElements(myMesh,curSub);
+ vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
+ vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
+ // delete property !!!!!!!!!!
+ vtkProperty* prop = vtkProperty::New();
+ prop->SetLineWidth( aLineWidth * 3 );
+ prop->SetPointSize( aPointSize * 3 );
+ prop->SetColor( 250, 0, 250 );
+ myBadMeshDisplayer->GetActor()->SetProperty( prop );
+ myBadMeshDisplayer->SetData( aMeshData._retn() );
+ }
+ }
+}
+
//================================================================================
/*!
* \brief SLOT called when a selected cell in table() changed
void SMESHGUI_ComputeOp::currentCellChanged()
{
myTShapeDisplayer->SetVisibility( false );
+ if ( myBadMeshDisplayer )
+ myBadMeshDisplayer->SetVisibility( false );
- bool publishEnable = 0, showEnable = 0, showOnly = 1;
+ bool publishEnable = 0, showEnable = 0, showOnly = 1, hasBadMesh = 0;
list< int > rows;
list< int >::iterator row;
- getSelectedRows( table(), rows );
+ int nbSelected = getSelectedRows( table(), rows );
for ( row = rows.begin(); row != rows.end(); ++row )
{
bool hasData = ( !table()->text(*row, COL_SHAPE).isEmpty() );
else {
showEnable = true;
}
+
+ if ( !table()->text(*row, COL_BAD_MESH).isEmpty() )
+ hasBadMesh = true;
}
myDlg->myPublishBtn->setEnabled( publishEnable );
- myDlg->myShowBtn->setEnabled( showEnable );
+ myDlg->myShowBtn ->setEnabled( showEnable );
+ myDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
}
//================================================================================
SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
{
- if ( myTShapeDisplayer ) delete myTShapeDisplayer;
+ delete myTShapeDisplayer;
+ if ( myBadMeshDisplayer )
+ delete myBadMeshDisplayer;
}
//================================================================================