22314: EDF 2594 SMESH: Preview "Union of triangles" result

This commit is contained in:
kga 2013-11-20 09:12:48 +00:00
parent 4e198a53df
commit 7e624b26fa
3 changed files with 96 additions and 17 deletions

View File

@ -34,6 +34,7 @@
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_MeshEditPreview.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
@ -105,7 +106,7 @@ SMESHGUI_MultiEditDlg
::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
const int theMode,
const bool the3d2d):
QDialog(SMESH::GetDesktop(theModule)),
SMESHGUI_PreviewDlg(theModule),
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
mySMESHGUI(theModule)
@ -1080,6 +1081,11 @@ SMESHGUI_UnionOfTrianglesDlg
{
setWindowTitle(tr("CAPTION"));
//Preview check box
myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), mySelGrp);
QGridLayout* aLay = (QGridLayout*)(mySelGrp->layout());
aLay->addWidget(myPreviewCheckBox, aLay->rowCount(), 0, 1, aLay->columnCount());
myComboBoxFunctor->setEnabled(true);
myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
@ -1102,6 +1108,14 @@ SMESHGUI_UnionOfTrianglesDlg
((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp);
myCriterionGrp->show();
connect(myComboBoxFunctor, SIGNAL(activated(int)), this, SLOT(toDisplaySimulation()));
connect(myMaxAngleSpin, SIGNAL(valueChanged(int)), this, SLOT(toDisplaySimulation()));
connect(this, SIGNAL(ListContensChanged()), this, SLOT(toDisplaySimulation()));
connectPreviewControl(); //To Connect preview check box
myPreviewCheckBox->setChecked(false);
onDisplaySimulation(false);
myHelpFileName = "uniting_set_of_triangles_page.html";
}
@ -1148,7 +1162,47 @@ bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito
ok = theEditor->TriToQuadObject(obj, aCriterion, aMaxAngle);
return ok;
}
void SMESHGUI_UnionOfTrianglesDlg::onDisplaySimulation( bool toDisplayPreview )
{
if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) {
if ( isValid( true ) ) {
try{
SUIT_OverrideCursor aWaitCursor;
// get Ids of elements
SMESH::SMESH_IDSource_var obj;
SMESH::long_array_var anElemIds = getIds( obj );
SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
double aMaxAngle = myMaxAngleSpin->GetValue() * M_PI / 180.0;
if ( CORBA::is_nil( obj ) )
aMeshEditor->TriToQuad( anElemIds.inout(), aCriterion, aMaxAngle );
else
aMeshEditor->TriToQuadObject( obj, aCriterion, aMaxAngle );
SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
vtkProperty* aProp = vtkProperty::New();
aProp->SetRepresentationToWireframe();
aProp->SetColor( 250, 0, 250 );
aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 3 );
mySimulation->GetActor()->SetProperty( aProp );
aProp->Delete();
mySimulation->SetData( aMeshPreviewStruct._retn() );
} catch ( ... ) {
hidePreview();
}
} else {
hidePreview();
}
} else {
hidePreview();
}
}
/*!
* Class : SMESHGUI_CuttingOfQuadsDlg
@ -1270,6 +1324,7 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
if (myPreviewActor != 0)
erasePreview();
SUIT_OverrideCursor aWaitCursor;
// get Ids of elements
SMESH::SMESH_IDSource_var obj;
SMESH::long_array_var anElemIds = getIds(obj);
@ -1291,6 +1346,10 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
return;
}
if ( anElemIds->length() == 0 ) {
anElemIds = obj->GetIDs();
}
//Create grid
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();

View File

@ -28,6 +28,7 @@
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
#include "SMESHGUI_PreviewDlg.h"
// Qt includes
#include <QDialog>
@ -64,7 +65,7 @@ class QButtonGroup;
* union of two neighboring triangles
*/
class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public QDialog
class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public SMESHGUI_PreviewDlg
{
Q_OBJECT
@ -197,6 +198,9 @@ protected:
const SMESH::long_array&,
SMESH::SMESH_IDSource_ptr obj );
protected slots:
virtual void onDisplaySimulation( bool );
private:
SMESHGUI_SpinBox* myMaxAngleSpin;
};

View File

@ -277,12 +277,16 @@ namespace MeshEditor_I {
void arrayToSet(const SMESH::long_array & IDs,
const SMESHDS_Mesh* aMesh,
TIDSortedElemSet& aMap,
const SMDSAbs_ElementType aType = SMDSAbs_All )
const SMDSAbs_ElementType aType = SMDSAbs_All,
SMDS_MeshElement::Filter* aFilter = NULL)
{
SMDS_MeshElement::NonNullFilter filter1;
SMDS_MeshElement::TypeFilter filter2( aType );
SMDS_MeshElement::Filter & filter =
( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter&) filter1 : filter2;
if ( aFilter == NULL )
aFilter = ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter*) &filter1 : (SMDS_MeshElement::Filter*) &filter2;
SMDS_MeshElement::Filter & filter = *aFilter;
if ( aType == SMDSAbs_Node )
for (int i=0; i<IDs.length(); i++) {
@ -1721,8 +1725,16 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE
initData();
SMESHDS_Mesh* aMesh = getMeshDS();
TIDSortedElemSet faces;
arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
TIDSortedElemSet faces,copyFaces;
SMDS_MeshElement::GeomFilter triaFilter(SMDSGeom_TRIANGLE);
arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face, & triaFilter);
TIDSortedElemSet* workElements = & faces;
if ( myIsPreviewMode ) {
SMDSAbs_ElementType select = SMDSAbs_Face;
getPreviewMesh( SMDSAbs_Face )->Copy( faces, copyFaces, select );
workElements = & copyFaces;
}
SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
@ -1732,12 +1744,13 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE
else
aCrit = aNumericalFunctor->GetNumericalFunctor();
// Update Python script
TPythonDump() << "isDone = " << this << ".TriToQuad( "
<< IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
if ( !myIsPreviewMode ) {
// Update Python script
TPythonDump() << "isDone = " << this << ".TriToQuad( "
<< IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
}
bool stat = getEditor().TriToQuad( faces, aCrit, MaxAngle );
bool stat = getEditor().TriToQuad( *workElements, aCrit, MaxAngle );
declareMeshModified( /*isReComputeSafe=*/!stat );
return stat;
@ -1766,12 +1779,14 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
SMESH::NumericalFunctor_i* aNumericalFunctor =
SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
if ( !myIsPreviewMode ) {
SMESH::NumericalFunctor_i* aNumericalFunctor =
SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
// Update Python script
aTPythonDump << "isDone = " << this << ".TriToQuadObject("
<< theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
// Update Python script
aTPythonDump << "isDone = " << this << ".TriToQuadObject("
<< theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
}
return isDone;
@ -1965,6 +1980,7 @@ CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
int id = getEditor().BestSplit(quad, aCrit);
declareMeshModified( /*isReComputeSafe=*/ id < 1 );
return id;
}
SMESH_CATCH( SMESH::throwCorbaException );