mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-28 08:30:33 +05:00
22314: EDF 2594 SMESH: Preview "Union of triangles" result
This commit is contained in:
parent
4e198a53df
commit
7e624b26fa
@ -34,6 +34,7 @@
|
|||||||
#include "SMESHGUI_MeshUtils.h"
|
#include "SMESHGUI_MeshUtils.h"
|
||||||
#include "SMESHGUI_FilterUtils.h"
|
#include "SMESHGUI_FilterUtils.h"
|
||||||
#include "SMESHGUI_SpinBox.h"
|
#include "SMESHGUI_SpinBox.h"
|
||||||
|
#include "SMESHGUI_MeshEditPreview.h"
|
||||||
|
|
||||||
#include <SMESH_Actor.h>
|
#include <SMESH_Actor.h>
|
||||||
#include <SMESH_TypeFilter.hxx>
|
#include <SMESH_TypeFilter.hxx>
|
||||||
@ -105,7 +106,7 @@ SMESHGUI_MultiEditDlg
|
|||||||
::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
|
::SMESHGUI_MultiEditDlg(SMESHGUI* theModule,
|
||||||
const int theMode,
|
const int theMode,
|
||||||
const bool the3d2d):
|
const bool the3d2d):
|
||||||
QDialog(SMESH::GetDesktop(theModule)),
|
SMESHGUI_PreviewDlg(theModule),
|
||||||
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
|
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
|
||||||
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
|
||||||
mySMESHGUI(theModule)
|
mySMESHGUI(theModule)
|
||||||
@ -1080,6 +1081,11 @@ SMESHGUI_UnionOfTrianglesDlg
|
|||||||
{
|
{
|
||||||
setWindowTitle(tr("CAPTION"));
|
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->setEnabled(true);
|
||||||
myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
|
myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
|
||||||
myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
|
myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
|
||||||
@ -1102,6 +1108,14 @@ SMESHGUI_UnionOfTrianglesDlg
|
|||||||
((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp);
|
((QVBoxLayout*)(myCriterionGrp->layout()))->addWidget(aMaxAngleGrp);
|
||||||
myCriterionGrp->show();
|
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";
|
myHelpFileName = "uniting_set_of_triangles_page.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,6 +1163,46 @@ bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEdito
|
|||||||
return ok;
|
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
|
* Class : SMESHGUI_CuttingOfQuadsDlg
|
||||||
@ -1270,6 +1324,7 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
|
|||||||
if (myPreviewActor != 0)
|
if (myPreviewActor != 0)
|
||||||
erasePreview();
|
erasePreview();
|
||||||
|
|
||||||
|
SUIT_OverrideCursor aWaitCursor;
|
||||||
// get Ids of elements
|
// get Ids of elements
|
||||||
SMESH::SMESH_IDSource_var obj;
|
SMESH::SMESH_IDSource_var obj;
|
||||||
SMESH::long_array_var anElemIds = getIds(obj);
|
SMESH::long_array_var anElemIds = getIds(obj);
|
||||||
@ -1291,6 +1346,10 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( anElemIds->length() == 0 ) {
|
||||||
|
anElemIds = obj->GetIDs();
|
||||||
|
}
|
||||||
|
|
||||||
//Create grid
|
//Create grid
|
||||||
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
|
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
// SMESH includes
|
// SMESH includes
|
||||||
#include "SMESH_SMESHGUI.hxx"
|
#include "SMESH_SMESHGUI.hxx"
|
||||||
|
#include "SMESHGUI_PreviewDlg.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@ -64,7 +65,7 @@ class QButtonGroup;
|
|||||||
* union of two neighboring triangles
|
* union of two neighboring triangles
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public QDialog
|
class SMESHGUI_EXPORT SMESHGUI_MultiEditDlg : public SMESHGUI_PreviewDlg
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -197,6 +198,9 @@ protected:
|
|||||||
const SMESH::long_array&,
|
const SMESH::long_array&,
|
||||||
SMESH::SMESH_IDSource_ptr obj );
|
SMESH::SMESH_IDSource_ptr obj );
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
virtual void onDisplaySimulation( bool );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SMESHGUI_SpinBox* myMaxAngleSpin;
|
SMESHGUI_SpinBox* myMaxAngleSpin;
|
||||||
};
|
};
|
||||||
|
@ -277,12 +277,16 @@ namespace MeshEditor_I {
|
|||||||
void arrayToSet(const SMESH::long_array & IDs,
|
void arrayToSet(const SMESH::long_array & IDs,
|
||||||
const SMESHDS_Mesh* aMesh,
|
const SMESHDS_Mesh* aMesh,
|
||||||
TIDSortedElemSet& aMap,
|
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::NonNullFilter filter1;
|
||||||
SMDS_MeshElement::TypeFilter filter2( aType );
|
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 )
|
if ( aType == SMDSAbs_Node )
|
||||||
for (int i=0; i<IDs.length(); i++) {
|
for (int i=0; i<IDs.length(); i++) {
|
||||||
@ -1721,8 +1725,16 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE
|
|||||||
initData();
|
initData();
|
||||||
|
|
||||||
SMESHDS_Mesh* aMesh = getMeshDS();
|
SMESHDS_Mesh* aMesh = getMeshDS();
|
||||||
TIDSortedElemSet faces;
|
TIDSortedElemSet faces,copyFaces;
|
||||||
arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
|
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 =
|
SMESH::NumericalFunctor_i* aNumericalFunctor =
|
||||||
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
|
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
|
else
|
||||||
aCrit = aNumericalFunctor->GetNumericalFunctor();
|
aCrit = aNumericalFunctor->GetNumericalFunctor();
|
||||||
|
|
||||||
// Update Python script
|
if ( !myIsPreviewMode ) {
|
||||||
TPythonDump() << "isDone = " << this << ".TriToQuad( "
|
// Update Python script
|
||||||
<< IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
|
TPythonDump() << "isDone = " << this << ".TriToQuad( "
|
||||||
|
<< IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stat = getEditor().TriToQuad( *workElements, aCrit, MaxAngle );
|
||||||
bool stat = getEditor().TriToQuad( faces, aCrit, MaxAngle );
|
|
||||||
|
|
||||||
declareMeshModified( /*isReComputeSafe=*/!stat );
|
declareMeshModified( /*isReComputeSafe=*/!stat );
|
||||||
return stat;
|
return stat;
|
||||||
@ -1766,12 +1779,14 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr
|
|||||||
SMESH::long_array_var anElementsId = theObject->GetIDs();
|
SMESH::long_array_var anElementsId = theObject->GetIDs();
|
||||||
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
|
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
|
||||||
|
|
||||||
SMESH::NumericalFunctor_i* aNumericalFunctor =
|
if ( !myIsPreviewMode ) {
|
||||||
SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
|
SMESH::NumericalFunctor_i* aNumericalFunctor =
|
||||||
|
SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
|
||||||
|
|
||||||
// Update Python script
|
// Update Python script
|
||||||
aTPythonDump << "isDone = " << this << ".TriToQuadObject("
|
aTPythonDump << "isDone = " << this << ".TriToQuadObject("
|
||||||
<< theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
|
<< theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
|
||||||
|
}
|
||||||
|
|
||||||
return isDone;
|
return isDone;
|
||||||
|
|
||||||
@ -1965,6 +1980,7 @@ CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
|
|||||||
|
|
||||||
int id = getEditor().BestSplit(quad, aCrit);
|
int id = getEditor().BestSplit(quad, aCrit);
|
||||||
declareMeshModified( /*isReComputeSafe=*/ id < 1 );
|
declareMeshModified( /*isReComputeSafe=*/ id < 1 );
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMESH_CATCH( SMESH::throwCorbaException );
|
SMESH_CATCH( SMESH::throwCorbaException );
|
||||||
|
Loading…
Reference in New Issue
Block a user