mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-05 23:04:20 +05:00
0020749: EDF 1291 SMESH : Create 2D Mesh from 2D improvement
This commit is contained in:
parent
1057b2c9fc
commit
e62fe64c08
@ -16,235 +16,389 @@
|
|||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
// File : SMESHGUI_Make2DFrom3D.cxx
|
||||||
|
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
|
||||||
|
|
||||||
// File : SMESHGUI_Make2DFrom3DOp.cxx
|
|
||||||
// Author : Open CASCADE S.A.S.
|
|
||||||
// SMESH includes
|
|
||||||
//
|
|
||||||
#include "SMESHGUI_Make2DFrom3DOp.h"
|
#include "SMESHGUI_Make2DFrom3DOp.h"
|
||||||
|
|
||||||
#include "SMESHGUI.h"
|
#include "SMESHGUI.h"
|
||||||
#include "SMESHGUI_Utils.h"
|
#include "SMESHGUI_Utils.h"
|
||||||
#include "SMESHGUI_VTKUtils.h"
|
|
||||||
#include "SMESHGUI_MeshUtils.h"
|
#include "SMESHGUI_MeshUtils.h"
|
||||||
#include "SMESHGUI_MeshInfosBox.h"
|
#include "SMESH_TypeFilter.hxx"
|
||||||
|
#include "SMESH_LogicalFilter.hxx"
|
||||||
|
|
||||||
// SALOME GUI includes
|
// SALOME GUI includes
|
||||||
#include <LightApp_SelectionMgr.h>
|
#include <LightApp_UpdateFlags.h>
|
||||||
|
#include <SalomeApp_Tools.h>
|
||||||
|
#include <SalomeApp_Study.h>
|
||||||
#include <SUIT_Desktop.h>
|
#include <SUIT_Desktop.h>
|
||||||
#include <SUIT_MessageBox.h>
|
#include <SUIT_MessageBox.h>
|
||||||
#include <SUIT_ResourceMgr.h>
|
|
||||||
#include <SUIT_OverrideCursor.h>
|
#include <SUIT_OverrideCursor.h>
|
||||||
|
|
||||||
#include <SALOME_ListIO.hxx>
|
|
||||||
|
|
||||||
// SALOME KERNEL includes
|
|
||||||
#include <SALOMEDS_SObject.hxx>
|
|
||||||
#include <SALOMEDSClient_SObject.hxx>
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
// IDL includes
|
// IDL includes
|
||||||
#include <SALOMEconfig.h>
|
#include <SALOMEconfig.h>
|
||||||
#include CORBA_SERVER_HEADER(SMESH_Gen)
|
#include CORBA_SERVER_HEADER(SMESH_Group)
|
||||||
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
|
|
||||||
|
|
||||||
#include <QFrame>
|
// Qt includes
|
||||||
#include <QLabel>
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QPushButton>
|
#include <QRadioButton>
|
||||||
#include <QVBoxLayout>
|
#include <QLineEdit>
|
||||||
|
#include <QCheckBox>
|
||||||
// MESH includes
|
#include <QHBoxLayout>
|
||||||
#include "SMDSAbs_ElementType.hxx"
|
#include <QGridLayout>
|
||||||
#include "SMDSAbs_ElementType.hxx"
|
|
||||||
|
|
||||||
|
|
||||||
#define SPACING 6
|
#define SPACING 6
|
||||||
#define MARGIN 11
|
#define MARGIN 11
|
||||||
|
|
||||||
// =========================================================================================
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Dialog to show creted mesh statistic
|
\class SMESHGUI_CopyMeshDlg
|
||||||
*/
|
\brief Copy Mesh dialog box
|
||||||
//=======================================================================
|
*/
|
||||||
|
|
||||||
SMESHGUI_Make2DFrom3DDlg::SMESHGUI_Make2DFrom3DDlg( QWidget* parent )
|
SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( QWidget* parent )
|
||||||
: SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ )
|
: SMESHGUI_Dialog( parent, false, true, OK | Apply | Close | Help )
|
||||||
{
|
{
|
||||||
|
// title
|
||||||
setWindowTitle( tr("CAPTION") );
|
setWindowTitle( tr("CAPTION") );
|
||||||
QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
|
|
||||||
|
// mesh
|
||||||
|
setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
|
||||||
|
createObject( tr( "MESH" ), mainFrame(), Mesh );
|
||||||
|
|
||||||
|
// mode
|
||||||
|
QGroupBox* aModeGrp = new QGroupBox( tr( "MODE" ), mainFrame() );
|
||||||
|
QHBoxLayout* aModeGrpLayout = new QHBoxLayout( aModeGrp );
|
||||||
|
aModeGrpLayout->setMargin( MARGIN );
|
||||||
|
aModeGrpLayout->setSpacing( SPACING );
|
||||||
|
my2dFrom3dRB = new QRadioButton( tr( "2D_FROM_3D" ), aModeGrp );
|
||||||
|
my1dFrom2dRB = new QRadioButton( tr( "1D_FROM_2D" ), aModeGrp );
|
||||||
|
my1dFrom3dRB = new QRadioButton( tr( "1D_FROM_3D" ), aModeGrp );
|
||||||
|
aModeGrpLayout->addWidget( my2dFrom3dRB );
|
||||||
|
aModeGrpLayout->addWidget( my1dFrom2dRB );
|
||||||
|
aModeGrpLayout->addWidget( my1dFrom3dRB );
|
||||||
|
|
||||||
|
// target
|
||||||
|
QGroupBox* aTargetGrp = new QGroupBox( tr( "TARGET" ), mainFrame() );
|
||||||
|
QGridLayout* aTargetGrpLayout = new QGridLayout( aTargetGrp );
|
||||||
|
aTargetGrpLayout->setMargin( MARGIN );
|
||||||
|
aTargetGrpLayout->setSpacing( SPACING );
|
||||||
|
myThisMeshRB = new QRadioButton( tr( "THIS_MESH" ), aTargetGrp );
|
||||||
|
myNewMeshRB = new QRadioButton( tr( "NEW_MESH" ), aTargetGrp );
|
||||||
|
myMeshName = new QLineEdit( aTargetGrp );
|
||||||
|
myCopyCheck = new QCheckBox( tr( "COPY_SRC" ), aTargetGrp );
|
||||||
|
myMissingCheck = new QCheckBox( tr( "MISSING_ONLY" ), aTargetGrp );
|
||||||
|
aTargetGrpLayout->addWidget( myThisMeshRB, 0, 0 );
|
||||||
|
aTargetGrpLayout->addWidget( myNewMeshRB, 1, 0 );
|
||||||
|
aTargetGrpLayout->addWidget( myMeshName, 1, 1 );
|
||||||
|
aTargetGrpLayout->addWidget( myCopyCheck, 2, 0 );
|
||||||
|
aTargetGrpLayout->addWidget( myMissingCheck, 2, 1 );
|
||||||
|
myGroupCheck = new QCheckBox( tr( "CREATE_GROUP" ), mainFrame() );
|
||||||
|
myGroupName = new QLineEdit( mainFrame() );
|
||||||
|
|
||||||
|
// layout
|
||||||
|
QGridLayout* aDlgLay = new QGridLayout( mainFrame() );
|
||||||
aDlgLay->setMargin( 0 );
|
aDlgLay->setMargin( 0 );
|
||||||
aDlgLay->setSpacing( SPACING );
|
aDlgLay->setSpacing( SPACING );
|
||||||
QFrame* aMainFrame = createMainFrame(mainFrame());
|
aDlgLay->addWidget( objectWg( Mesh, Label ), 0, 0 );
|
||||||
aDlgLay->addWidget(aMainFrame);
|
aDlgLay->addWidget( objectWg( Mesh, Btn ), 0, 1 );
|
||||||
aDlgLay->setStretchFactor(aMainFrame, 1);
|
aDlgLay->addWidget( objectWg( Mesh, Control ), 0, 2 );
|
||||||
|
aDlgLay->addWidget( aModeGrp, 1, 0, 1, 3 );
|
||||||
|
aDlgLay->addWidget( aTargetGrp, 2, 0, 1, 3 );
|
||||||
|
aDlgLay->addWidget( myGroupCheck, 3, 0 );
|
||||||
|
aDlgLay->addWidget( myGroupName, 3, 1, 1, 2 );
|
||||||
|
|
||||||
|
// connect signals
|
||||||
|
connect( myThisMeshRB, SIGNAL( clicked() ), this, SLOT( onTargetChanged() ) );
|
||||||
|
connect( myNewMeshRB, SIGNAL( clicked() ), this, SLOT( onTargetChanged() ) );
|
||||||
|
connect( myGroupCheck, SIGNAL( clicked() ), this, SLOT( onGroupChecked() ) );
|
||||||
|
|
||||||
|
// init dlg
|
||||||
|
my2dFrom3dRB->setChecked( true );
|
||||||
|
myThisMeshRB->setChecked( true );
|
||||||
|
myMissingCheck->setChecked( true );
|
||||||
|
onTargetChanged();
|
||||||
|
onGroupChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========================================================================================
|
SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
|
||||||
/*!
|
|
||||||
* \brief Dialog destructor
|
|
||||||
*/
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
SMESHGUI_Make2DFrom3DDlg::~SMESHGUI_Make2DFrom3DDlg()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
SMESH::Bnd_Dimension SMESHGUI_CopyMeshDlg::mode() const
|
||||||
// function : createMainFrame()
|
|
||||||
// purpose : Create frame containing dialog's fields
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
QFrame* SMESHGUI_Make2DFrom3DDlg::createMainFrame (QWidget* theParent)
|
|
||||||
{
|
{
|
||||||
QFrame* aFrame = new QFrame(theParent);
|
if ( my2dFrom3dRB->isChecked() )
|
||||||
|
return SMESH::BND_2DFROM3D;
|
||||||
SUIT_ResourceMgr* rm = resourceMgr();
|
else if ( my1dFrom2dRB->isChecked() )
|
||||||
QPixmap iconCompute (rm->loadPixmap("SMESH", tr("ICON_2D_FROM_3D")));
|
return SMESH::BND_1DFROM2D;
|
||||||
|
else
|
||||||
// Mesh name
|
return SMESH::BND_1DFROM3D;
|
||||||
QGroupBox* nameBox = new QGroupBox(tr("SMESH_MESHINFO_NAME"), aFrame );
|
}
|
||||||
QHBoxLayout* nameBoxLayout = new QHBoxLayout(nameBox);
|
|
||||||
nameBoxLayout->setMargin(MARGIN); nameBoxLayout->setSpacing(SPACING);
|
bool SMESHGUI_CopyMeshDlg::needNewMesh() const
|
||||||
myMeshName = new QLabel(nameBox);
|
{
|
||||||
nameBoxLayout->addWidget(myMeshName);
|
return myNewMeshRB->isChecked();
|
||||||
|
}
|
||||||
// Mesh Info
|
|
||||||
|
QString SMESHGUI_CopyMeshDlg::getNewMeshName() const
|
||||||
myFullInfo = new SMESHGUI_MeshInfosBox(true, aFrame);
|
{
|
||||||
|
return myMeshName->text().trimmed();
|
||||||
// add all widgets to aFrame
|
}
|
||||||
QVBoxLayout* aLay = new QVBoxLayout(aFrame);
|
|
||||||
aLay->setMargin( 0 );
|
void SMESHGUI_CopyMeshDlg::setNewMeshName( const QString& name )
|
||||||
aLay->setSpacing( 0 );
|
{
|
||||||
aLay->addWidget( nameBox );
|
myMeshName->setText( name );
|
||||||
aLay->addWidget( myFullInfo );
|
}
|
||||||
|
|
||||||
((QPushButton*) button( OK ))->setDefault( true );
|
bool SMESHGUI_CopyMeshDlg::needGroup() const
|
||||||
return aFrame;
|
{
|
||||||
|
return myGroupCheck->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SMESHGUI_CopyMeshDlg::getGroupName() const
|
||||||
|
{
|
||||||
|
return myGroupName->text().trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESHGUI_CopyMeshDlg::setGroupName( const QString& name )
|
||||||
|
{
|
||||||
|
myGroupName->setText( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SMESHGUI_CopyMeshDlg::copySource() const
|
||||||
|
{
|
||||||
|
return myCopyCheck->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SMESHGUI_CopyMeshDlg::copyMissingOnly() const
|
||||||
|
{
|
||||||
|
return myMissingCheck->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESHGUI_CopyMeshDlg::onTargetChanged()
|
||||||
|
{
|
||||||
|
myMeshName->setEnabled( myNewMeshRB->isChecked() );
|
||||||
|
myCopyCheck->setEnabled( myNewMeshRB->isChecked() );
|
||||||
|
myMissingCheck->setEnabled( myNewMeshRB->isChecked() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESHGUI_CopyMeshDlg::onGroupChecked()
|
||||||
|
{
|
||||||
|
myGroupName->setEnabled( myGroupCheck->isChecked() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
/*!
|
/*!
|
||||||
* \brief set name of the mesh
|
\class SMESHGUI_Make2DFrom3DOp
|
||||||
|
\brief Copy Mesh operation class
|
||||||
*/
|
*/
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
void SMESHGUI_Make2DFrom3DDlg::SetMeshName(const QString& theName)
|
|
||||||
{
|
|
||||||
myMeshName->setText( theName );
|
|
||||||
}
|
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
/*!
|
|
||||||
* \brief set mesh info
|
|
||||||
*/
|
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
void SMESHGUI_Make2DFrom3DDlg::SetMeshInfo(const SMESH::long_array& theInfo)
|
|
||||||
{
|
|
||||||
myFullInfo->SetMeshInfo( theInfo );
|
|
||||||
}
|
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
/*!
|
|
||||||
* \brief Constructor
|
|
||||||
*/
|
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
SMESHGUI_Make2DFrom3DOp::SMESHGUI_Make2DFrom3DOp()
|
SMESHGUI_Make2DFrom3DOp::SMESHGUI_Make2DFrom3DOp()
|
||||||
: SMESHGUI_Operation()
|
: SMESHGUI_SelectionOp()
|
||||||
{
|
{
|
||||||
myDlg = new SMESHGUI_Make2DFrom3DDlg(desktop());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
|
||||||
/*!
|
|
||||||
* \brief Desctructor
|
|
||||||
*/
|
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
SMESHGUI_Make2DFrom3DOp::~SMESHGUI_Make2DFrom3DOp()
|
SMESHGUI_Make2DFrom3DOp::~SMESHGUI_Make2DFrom3DOp()
|
||||||
{
|
{
|
||||||
|
if ( myDlg )
|
||||||
|
delete myDlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
LightApp_Dialog* SMESHGUI_Make2DFrom3DOp::dlg() const
|
||||||
/*!
|
{
|
||||||
* \brief perform it's intention action: compute 2D mesh on 3D
|
return myDlg;
|
||||||
*/
|
}
|
||||||
//================================================================================
|
|
||||||
|
|
||||||
void SMESHGUI_Make2DFrom3DOp::startOperation()
|
void SMESHGUI_Make2DFrom3DOp::startOperation()
|
||||||
{
|
{
|
||||||
myMesh = SMESH::SMESH_Mesh::_nil();
|
if( !myDlg )
|
||||||
|
myDlg = new SMESHGUI_CopyMeshDlg( desktop() );
|
||||||
|
|
||||||
// check selection
|
mySrc = SMESH::SMESH_IDSource::_nil();
|
||||||
LightApp_SelectionMgr *Sel = selectionMgr();
|
|
||||||
SALOME_ListIO selected; Sel->selectedObjects( selected );
|
|
||||||
|
|
||||||
int nbSel = selected.Extent();
|
myHelpFileName = "copy_mesh_page.html";
|
||||||
if (nbSel != 1) {
|
|
||||||
SUIT_MessageBox::warning(desktop(),
|
|
||||||
tr("SMESH_WRN_WARNING"),
|
|
||||||
tr("SMESH_WRN_NO_AVAILABLE_DATA"));
|
|
||||||
onCancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(SALOME_InteractiveObject) anIO = selected.First();
|
SMESHGUI_SelectionOp::startOperation();
|
||||||
myMesh = SMESH::GetMeshByIO(anIO);
|
|
||||||
if (myMesh->_is_nil()) {
|
|
||||||
SUIT_MessageBox::warning(desktop(),
|
|
||||||
tr("SMESH_WRN_WARNING"),
|
|
||||||
tr("SMESH_WRN_NO_AVAILABLE_DATA"));
|
|
||||||
onCancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SMESHGUI_Operation::startOperation();
|
myDlg->activateObject( SMESHGUI_CopyMeshDlg::Mesh );
|
||||||
|
myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
|
||||||
|
myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
|
||||||
|
myDlg->show();
|
||||||
|
|
||||||
|
selectionDone();
|
||||||
// backup mesh info before 2D mesh computation
|
|
||||||
SMESH::long_array_var anOldInfo = myMesh->GetMeshInfo();
|
|
||||||
|
|
||||||
|
|
||||||
if (!compute2DMesh()) {
|
|
||||||
SUIT_MessageBox::warning(desktop(),
|
|
||||||
tr("SMESH_WRN_WARNING"),
|
|
||||||
tr("SMESH_WRN_COMPUTE_FAILED"));
|
|
||||||
onCancel();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// get new mesh statistic
|
|
||||||
SMESH::long_array_var aNewInfo = myMesh->GetMeshInfo();
|
|
||||||
// get difference in mesh statistic from old to new
|
|
||||||
for ( int i = SMDSEntity_Node; i < SMDSEntity_Last; i++ )
|
|
||||||
aNewInfo[i] -= anOldInfo[i];
|
|
||||||
|
|
||||||
// update presentation
|
|
||||||
SMESH::Update(anIO, SMESH::eDisplay);
|
|
||||||
|
|
||||||
// show computated result
|
|
||||||
_PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
|
|
||||||
if ( aMeshSObj )
|
|
||||||
myDlg->SetMeshName( aMeshSObj->GetName().c_str() );
|
|
||||||
myDlg->SetMeshInfo( aNewInfo );
|
|
||||||
myDlg->show(); /*exec();*/
|
|
||||||
commit();
|
|
||||||
SMESHGUI::Modified();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
void SMESHGUI_Make2DFrom3DOp::selectionDone()
|
||||||
/*!
|
{
|
||||||
* \brief compute 2D mesh on initial 3D
|
if ( !dlg() ) return;
|
||||||
*/
|
|
||||||
//================================================================================
|
if ( dlg()->isVisible() ) {
|
||||||
|
try {
|
||||||
|
QStringList names, ids;
|
||||||
|
LightApp_Dialog::TypesList types;
|
||||||
|
selected( names, types, ids );
|
||||||
|
if ( names.count() == 1 )
|
||||||
|
myDlg->selectObject( names, types, ids );
|
||||||
|
else
|
||||||
|
myDlg->clearSelection();
|
||||||
|
}
|
||||||
|
catch ( const SALOME::SALOME_Exception& S_ex ) {
|
||||||
|
SalomeApp_Tools::QtCatchCorbaException( S_ex );
|
||||||
|
}
|
||||||
|
catch ( ... ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SUIT_SelectionFilter* SMESHGUI_Make2DFrom3DOp::createFilter( const int theId ) const
|
||||||
|
{
|
||||||
|
SUIT_SelectionFilter* f = 0;
|
||||||
|
if ( theId == SMESHGUI_CopyMeshDlg::Mesh ) {
|
||||||
|
QList<SUIT_SelectionFilter*> filters;
|
||||||
|
filters.append( new SMESH_TypeFilter( MESHorSUBMESH ) );
|
||||||
|
filters.append( new SMESH_TypeFilter( GROUP ) );
|
||||||
|
f = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SMESHGUI_Make2DFrom3DOp::isValid( QString& msg ) const
|
||||||
|
{
|
||||||
|
if ( !dlg() ) return false;
|
||||||
|
|
||||||
|
// check if any source data is selected
|
||||||
|
QString entry = myDlg->selectedObject( SMESHGUI_CopyMeshDlg::Mesh );
|
||||||
|
SMESH::SMESH_IDSource_var obj;
|
||||||
|
_PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entry.toLatin1().constData() );
|
||||||
|
if ( sobj )
|
||||||
|
obj = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );
|
||||||
|
|
||||||
|
if ( obj->_is_nil() ) {
|
||||||
|
msg = tr( "SMESH_ERR_NO_INPUT_MESH" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if source contains elements of required type
|
||||||
|
SMESH::Bnd_Dimension mode = myDlg->mode();
|
||||||
|
SMESH::array_of_ElementType_var types = obj->GetTypes();
|
||||||
|
|
||||||
|
bool has3d = false;
|
||||||
|
bool has2d = false;
|
||||||
|
for ( int i = 0; i < types->length(); i++ ) {
|
||||||
|
if ( types[i] == SMESH::VOLUME ) has3d = true;
|
||||||
|
else if ( types[i] == SMESH::FACE ) has2d = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( mode == SMESH::BND_2DFROM3D || mode == SMESH::BND_1DFROM3D ) && !has3d ) {
|
||||||
|
msg = tr( "SMESH_ERR_NO_3D_ELEMENTS" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if ( mode == SMESH::BND_1DFROM2D && !has2d ) {
|
||||||
|
msg = tr( "SMESH_ERR_NO_2D_ELEMENTS" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if new mesh name is specified
|
||||||
|
if ( myDlg->needNewMesh() && myDlg->getNewMeshName().isEmpty() ) {
|
||||||
|
msg = tr( "SMESH_ERR_MESH_NAME_NOT_SPECIFIED" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if group name is specified
|
||||||
|
if ( myDlg->needGroup() && myDlg->getGroupName().isEmpty() ) {
|
||||||
|
msg = tr( "SMESH_ERR_GRP_NAME_NOT_SPECIFIED" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SMESHGUI_Make2DFrom3DOp::compute2DMesh()
|
bool SMESHGUI_Make2DFrom3DOp::compute2DMesh()
|
||||||
{
|
{
|
||||||
SUIT_OverrideCursor wc;
|
SUIT_OverrideCursor wc;
|
||||||
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
|
|
||||||
return aMeshEditor->Make2DMeshFrom3D();
|
bool ok = false;
|
||||||
|
try {
|
||||||
|
QString entry = myDlg->selectedObject( SMESHGUI_CopyMeshDlg::Mesh );
|
||||||
|
_PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entry.toLatin1().constData() );
|
||||||
|
SMESH::SMESH_IDSource_var obj = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );
|
||||||
|
|
||||||
|
SMESH::Bnd_Dimension mode = myDlg->mode();
|
||||||
|
QString meshName = myDlg->needNewMesh() ? myDlg->getNewMeshName() : QString();
|
||||||
|
QString groupName = myDlg->needGroup() ? myDlg->getGroupName() : QString();
|
||||||
|
bool copySrc = myDlg->copySource();
|
||||||
|
bool copyAll = !myDlg->copyMissingOnly();
|
||||||
|
|
||||||
|
SMESH::SMESH_Mesh_var srcMesh = SMESH::SMESH_Mesh::_narrow( obj );
|
||||||
|
if ( CORBA::is_nil( srcMesh ) ) {
|
||||||
|
SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow( obj );
|
||||||
|
if ( !CORBA::is_nil( subMesh ) )
|
||||||
|
srcMesh = subMesh->GetFather();
|
||||||
|
}
|
||||||
|
if ( CORBA::is_nil( srcMesh ) ) {
|
||||||
|
SMESH::SMESH_GroupBase_var grp = SMESH::SMESH_GroupBase::_narrow( obj );
|
||||||
|
if ( !CORBA::is_nil( grp ) )
|
||||||
|
srcMesh = grp->GetMesh();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !CORBA::is_nil( srcMesh ) ) {
|
||||||
|
SMESH::SMESH_MeshEditor_var aMeshEditor = srcMesh->GetMeshEditor();
|
||||||
|
SMESH::SMESH_Group_var newGrp;
|
||||||
|
SMESH::SMESH_Mesh_var mesh = aMeshEditor->MakeBoundaryMesh( obj.in(),
|
||||||
|
mode,
|
||||||
|
meshName.toLatin1().constData(),
|
||||||
|
groupName.toLatin1().constData(),
|
||||||
|
copySrc,
|
||||||
|
copyAll,
|
||||||
|
newGrp.out() );
|
||||||
|
if ( !mesh->_is_nil() ) {
|
||||||
|
#ifdef WITHGENERICOBJ
|
||||||
|
mesh->Destroy();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if ( !newGrp->_is_nil() ) {
|
||||||
|
#ifdef WITHGENERICOBJ
|
||||||
|
newGrp->Destroy();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( ... ) {
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SMESHGUI_Make2DFrom3DOp::onApply()
|
||||||
|
{
|
||||||
|
if ( isStudyLocked() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QString msg;
|
||||||
|
if ( !isValid( msg ) ) {
|
||||||
|
dlg()->show();
|
||||||
|
if ( msg != "" )
|
||||||
|
SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), msg );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool res = false;
|
||||||
|
try {
|
||||||
|
res = compute2DMesh();
|
||||||
|
}
|
||||||
|
catch ( const SALOME::SALOME_Exception& S_ex ) {
|
||||||
|
SalomeApp_Tools::QtCatchCorbaException( S_ex );
|
||||||
|
}
|
||||||
|
catch ( ... ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( res ) {
|
||||||
|
SMESHGUI::Modified();
|
||||||
|
update( UF_ObjBrowser | UF_Model );
|
||||||
|
myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
|
||||||
|
myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -16,70 +16,97 @@
|
|||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
|
||||||
// SMESH SMESHGUI : GUI for SMESH component
|
|
||||||
// File : SMESHGUI_Make2DFrom3D.h
|
// File : SMESHGUI_Make2DFrom3D.h
|
||||||
// Author : Open CASCADE S.A.S.
|
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
|
||||||
//
|
|
||||||
#ifndef SMESHGUI_Make2DFrom3DOp_H
|
#ifndef SMESHGUI_Make2DFrom3DOp_H
|
||||||
#define SMESHGUI_Make2DFrom3DOp_H
|
#define SMESHGUI_Make2DFrom3DOp_H
|
||||||
|
|
||||||
// SMESH includes
|
// SMESH includes
|
||||||
#include "SMESH_SMESHGUI.hxx"
|
#include "SMESH_SMESHGUI.hxx"
|
||||||
|
|
||||||
#include "SMESHGUI_Dialog.h"
|
#include "SMESHGUI_Dialog.h"
|
||||||
#include "SMESHGUI_Operation.h"
|
#include "SMESHGUI_SelectionOp.h"
|
||||||
|
|
||||||
// IDL includes
|
|
||||||
#include <SALOMEconfig.h>
|
#include <SALOMEconfig.h>
|
||||||
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
|
||||||
|
|
||||||
class QFrame;
|
class QCheckBox;
|
||||||
class SMESHGUI_MeshInfosBox;
|
class QLineEdit;
|
||||||
|
class QRadioButton;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Dialog to show result mesh statistic
|
* \brief Dialog to show result mesh statistic
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SMESHGUI_Make2DFrom3DDlg : public SMESHGUI_Dialog
|
class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public SMESHGUI_Dialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SMESHGUI_Make2DFrom3DDlg( QWidget* );
|
enum { Mesh };
|
||||||
virtual ~SMESHGUI_Make2DFrom3DDlg();
|
|
||||||
|
|
||||||
void SetMeshName(const QString& theName);
|
SMESHGUI_CopyMeshDlg( QWidget* );
|
||||||
void SetMeshInfo(const SMESH::long_array& theInfo);
|
virtual ~SMESHGUI_CopyMeshDlg();
|
||||||
|
|
||||||
private:
|
SMESH::Bnd_Dimension mode() const;
|
||||||
QFrame* createMainFrame( QWidget* );
|
|
||||||
|
|
||||||
private:
|
bool needNewMesh() const;
|
||||||
QLabel* myMeshName;
|
QString getNewMeshName() const;
|
||||||
SMESHGUI_MeshInfosBox* myFullInfo;
|
void setNewMeshName( const QString& );
|
||||||
|
|
||||||
|
bool needGroup() const;
|
||||||
|
QString getGroupName() const;
|
||||||
|
void setGroupName( const QString& );
|
||||||
|
|
||||||
|
bool copySource() const;
|
||||||
|
bool copyMissingOnly() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTargetChanged();
|
||||||
|
void onGroupChecked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QRadioButton* my2dFrom3dRB;
|
||||||
|
QRadioButton* my1dFrom2dRB;
|
||||||
|
QRadioButton* my1dFrom3dRB;
|
||||||
|
QRadioButton* myThisMeshRB;
|
||||||
|
QRadioButton* myNewMeshRB;
|
||||||
|
QLineEdit* myMeshName;
|
||||||
|
QCheckBox* myCopyCheck;
|
||||||
|
QCheckBox* myMissingCheck;
|
||||||
|
QCheckBox* myGroupCheck;
|
||||||
|
QLineEdit* myGroupName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Operation to compute 2D mesh on 3D
|
* \brief Operation to compute 2D mesh on 3D
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SMESHGUI_Make2DFrom3DOp : public SMESHGUI_Operation
|
class SMESHGUI_EXPORT SMESHGUI_Make2DFrom3DOp : public SMESHGUI_SelectionOp
|
||||||
{
|
{
|
||||||
public:
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
SMESHGUI_Make2DFrom3DOp();
|
SMESHGUI_Make2DFrom3DOp();
|
||||||
virtual ~SMESHGUI_Make2DFrom3DOp();
|
virtual ~SMESHGUI_Make2DFrom3DOp();
|
||||||
|
|
||||||
protected:
|
virtual LightApp_Dialog* dlg() const;
|
||||||
virtual void startOperation();
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
virtual void startOperation();
|
||||||
|
virtual void selectionDone();
|
||||||
|
virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
||||||
|
bool isValid( QString& ) const;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
virtual bool onApply();
|
||||||
|
|
||||||
|
private:
|
||||||
bool compute2DMesh();
|
bool compute2DMesh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SMESH::SMESH_Mesh_var myMesh;
|
SMESH::SMESH_IDSource_var mySrc;
|
||||||
QPointer<SMESHGUI_Make2DFrom3DDlg> myDlg;
|
QPointer<SMESHGUI_CopyMeshDlg> myDlg;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SMESHGUI_Make2DFrom3DOp_H
|
#endif // SMESHGUI_Make2DFrom3DOp_H
|
||||||
|
@ -82,4 +82,44 @@ namespace SMESH
|
|||||||
}
|
}
|
||||||
return baseName;
|
return baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString UniqueName(const QString& theBaseName, _PTR(SObject) theParent, const QString& thePostfix)
|
||||||
|
{
|
||||||
|
QString baseName = thePostfix.isEmpty() ?
|
||||||
|
theBaseName : theBaseName + "_" + thePostfix;
|
||||||
|
QString name = baseName;
|
||||||
|
if ( _PTR(Study) aStudy = GetActiveStudyDocument() ) {
|
||||||
|
_PTR(SObject) p = theParent;
|
||||||
|
if ( !p ) p = aStudy->FindComponent( "SMESH" );
|
||||||
|
if ( p ) {
|
||||||
|
_PTR(ChildIterator) iter = aStudy->NewChildIterator( p );
|
||||||
|
int idx = 0;
|
||||||
|
while( true ) {
|
||||||
|
bool found = false;
|
||||||
|
for ( ; iter->More(); iter->Next() ) {
|
||||||
|
_PTR(SObject) so = iter->Value();
|
||||||
|
if ( !so ) continue; // skip bad objects
|
||||||
|
_PTR(SObject) ref;
|
||||||
|
if ( so->ReferencedObject( ref ) ) continue; // skip references
|
||||||
|
QString n = so->GetName().c_str();
|
||||||
|
if ( !n.isEmpty() && n == name ) {
|
||||||
|
QStringList names = name.split("_", QString::KeepEmptyParts);
|
||||||
|
if ( names.count() > 0 ) {
|
||||||
|
bool ok;
|
||||||
|
names.last().toInt( &ok );
|
||||||
|
if ( ok )
|
||||||
|
names.removeLast();
|
||||||
|
}
|
||||||
|
names.append( QString::number( ++idx ) );
|
||||||
|
name = names.join( "_" );
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !found ) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
} // end of namespace SMESH
|
} // end of namespace SMESH
|
||||||
|
@ -36,10 +36,15 @@
|
|||||||
// SALOME GUI includes
|
// SALOME GUI includes
|
||||||
#include <SALOME_InteractiveObject.hxx>
|
#include <SALOME_InteractiveObject.hxx>
|
||||||
|
|
||||||
|
// SALOME KERNEL includes
|
||||||
|
#include <SALOMEDSClient_definitions.hxx>
|
||||||
|
|
||||||
// IDL includes
|
// IDL includes
|
||||||
#include <SALOMEconfig.h>
|
#include <SALOMEconfig.h>
|
||||||
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
||||||
|
|
||||||
|
class SALOMEDSClient_SObject;
|
||||||
|
|
||||||
namespace SMESH
|
namespace SMESH
|
||||||
{
|
{
|
||||||
SMESHGUI_EXPORT
|
SMESHGUI_EXPORT
|
||||||
@ -47,6 +52,8 @@ namespace SMESH
|
|||||||
|
|
||||||
SMESHGUI_EXPORT
|
SMESHGUI_EXPORT
|
||||||
QString UniqueMeshName( const QString&, const QString& = QString() );
|
QString UniqueMeshName( const QString&, const QString& = QString() );
|
||||||
|
SMESHGUI_EXPORT
|
||||||
|
QString UniqueName( const QString&, _PTR(SObject) = _PTR(SObject)(), const QString& = QString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SMESHGUI_MESHUTILS_H
|
#endif // SMESHGUI_MESHUTILS_H
|
||||||
|
@ -5257,4 +5257,78 @@ It is impossible to read point coordinates from file</translation>
|
|||||||
<translation>Construct group with newly created elements</translation>
|
<translation>Construct group with newly created elements</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>SMESHGUI_CopyMeshDlg</name>
|
||||||
|
<message>
|
||||||
|
<source>CAPTION</source>
|
||||||
|
<translation>Copy mesh elements</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>MESH</source>
|
||||||
|
<translation>Mesh, submesh or group</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>MODE</source>
|
||||||
|
<translation>Mode</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>2D_FROM_3D</source>
|
||||||
|
<translation>2D from 3D</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>1D_FROM_3D</source>
|
||||||
|
<translation>1D from 3D</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>1D_FROM_2D</source>
|
||||||
|
<translation>1D from 2D</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>TARGET</source>
|
||||||
|
<translation>Target</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>THIS_MESH</source>
|
||||||
|
<translation>This mesh</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>NEW_MESH</source>
|
||||||
|
<translation>New mesh</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>COPY_SRC</source>
|
||||||
|
<translation>Copy source mesh</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>MISSING_ONLY</source>
|
||||||
|
<translation>Copy missing elements only</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>CREATE_GROUP</source>
|
||||||
|
<translation>Create group</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>SMESHGUI_Make2DFrom3DOp</name>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_ERR_NO_INPUT_MESH</source>
|
||||||
|
<translation>Source mesh, sub-mesh or group is not specified</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_ERR_NO_3D_ELEMENTS</source>
|
||||||
|
<translation>The source object does not contain 3D elements</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_ERR_NO_2D_ELEMENTS</source>
|
||||||
|
<translation>The source object does not contain 2D elements</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_ERR_MESH_NAME_NOT_SPECIFIED</source>
|
||||||
|
<translation>New mesh name is not specified</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>SMESH_ERR_GRP_NAME_NOT_SPECIFIED</source>
|
||||||
|
<translation>Group name is not specified</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
Loading…
Reference in New Issue
Block a user