0020749: EDF 1291 SMESH : Create 2D Mesh from 2D improvement

This commit is contained in:
vsr 2010-10-08 13:21:03 +00:00
parent 1057b2c9fc
commit e62fe64c08
5 changed files with 505 additions and 203 deletions

View File

@ -16,235 +16,389 @@
//
// 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.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_MeshInfosBox.h"
#include "SMESH_TypeFilter.hxx"
#include "SMESH_LogicalFilter.hxx"
// 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_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_OverrideCursor.h>
#include <SALOME_ListIO.hxx>
// SALOME KERNEL includes
#include <SALOMEDS_SObject.hxx>
#include <SALOMEDSClient_SObject.hxx>
// Qt includes
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#include CORBA_SERVER_HEADER(SMESH_Group)
#include <QFrame>
#include <QLabel>
#include <QPixmap>
// Qt includes
#include <QGroupBox>
#include <QPushButton>
#include <QVBoxLayout>
// MESH includes
#include "SMDSAbs_ElementType.hxx"
#include "SMDSAbs_ElementType.hxx"
#include <QRadioButton>
#include <QLineEdit>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QGridLayout>
#define SPACING 6
#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_Dialog( parent, false, true, Close/* | Help*/ )
SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( QWidget* parent )
: SMESHGUI_Dialog( parent, false, true, OK | Apply | Close | Help )
{
// title
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->setSpacing( SPACING );
QFrame* aMainFrame = createMainFrame(mainFrame());
aDlgLay->addWidget(aMainFrame);
aDlgLay->setStretchFactor(aMainFrame, 1);
aDlgLay->addWidget( objectWg( Mesh, Label ), 0, 0 );
aDlgLay->addWidget( objectWg( Mesh, Btn ), 0, 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();
}
// =========================================================================================
/*!
* \brief Dialog destructor
*/
//=======================================================================
SMESHGUI_Make2DFrom3DDlg::~SMESHGUI_Make2DFrom3DDlg()
SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
{
}
//=======================================================================
// function : createMainFrame()
// purpose : Create frame containing dialog's fields
//=======================================================================
QFrame* SMESHGUI_Make2DFrom3DDlg::createMainFrame (QWidget* theParent)
SMESH::Bnd_Dimension SMESHGUI_CopyMeshDlg::mode() const
{
QFrame* aFrame = new QFrame(theParent);
SUIT_ResourceMgr* rm = resourceMgr();
QPixmap iconCompute (rm->loadPixmap("SMESH", tr("ICON_2D_FROM_3D")));
// Mesh name
QGroupBox* nameBox = new QGroupBox(tr("SMESH_MESHINFO_NAME"), aFrame );
QHBoxLayout* nameBoxLayout = new QHBoxLayout(nameBox);
nameBoxLayout->setMargin(MARGIN); nameBoxLayout->setSpacing(SPACING);
myMeshName = new QLabel(nameBox);
nameBoxLayout->addWidget(myMeshName);
// Mesh Info
myFullInfo = new SMESHGUI_MeshInfosBox(true, aFrame);
// add all widgets to aFrame
QVBoxLayout* aLay = new QVBoxLayout(aFrame);
aLay->setMargin( 0 );
aLay->setSpacing( 0 );
aLay->addWidget( nameBox );
aLay->addWidget( myFullInfo );
((QPushButton*) button( OK ))->setDefault( true );
return aFrame;
if ( my2dFrom3dRB->isChecked() )
return SMESH::BND_2DFROM3D;
else if ( my1dFrom2dRB->isChecked() )
return SMESH::BND_1DFROM2D;
else
return SMESH::BND_1DFROM3D;
}
bool SMESHGUI_CopyMeshDlg::needNewMesh() const
{
return myNewMeshRB->isChecked();
}
QString SMESHGUI_CopyMeshDlg::getNewMeshName() const
{
return myMeshName->text().trimmed();
}
void SMESHGUI_CopyMeshDlg::setNewMeshName( const QString& name )
{
myMeshName->setText( name );
}
bool SMESHGUI_CopyMeshDlg::needGroup() const
{
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_Operation()
: SMESHGUI_SelectionOp()
{
myDlg = new SMESHGUI_Make2DFrom3DDlg(desktop());
}
//================================================================================
/*!
* \brief Desctructor
*/
//================================================================================
SMESHGUI_Make2DFrom3DOp::~SMESHGUI_Make2DFrom3DOp()
{
if ( myDlg )
delete myDlg;
}
//================================================================================
/*!
* \brief perform it's intention action: compute 2D mesh on 3D
*/
//================================================================================
LightApp_Dialog* SMESHGUI_Make2DFrom3DOp::dlg() const
{
return myDlg;
}
void SMESHGUI_Make2DFrom3DOp::startOperation()
{
myMesh = SMESH::SMESH_Mesh::_nil();
if( !myDlg )
myDlg = new SMESHGUI_CopyMeshDlg( desktop() );
mySrc = SMESH::SMESH_IDSource::_nil();
// check selection
LightApp_SelectionMgr *Sel = selectionMgr();
SALOME_ListIO selected; Sel->selectedObjects( selected );
myHelpFileName = "copy_mesh_page.html";
int nbSel = selected.Extent();
if (nbSel != 1) {
SUIT_MessageBox::warning(desktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_NO_AVAILABLE_DATA"));
onCancel();
return;
}
SMESHGUI_SelectionOp::startOperation();
Handle(SALOME_InteractiveObject) anIO = selected.First();
myMesh = SMESH::GetMeshByIO(anIO);
if (myMesh->_is_nil()) {
SUIT_MessageBox::warning(desktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_NO_AVAILABLE_DATA"));
onCancel();
return;
}
myDlg->activateObject( SMESHGUI_CopyMeshDlg::Mesh );
myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
myDlg->show();
SMESHGUI_Operation::startOperation();
// 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();
selectionDone();
}
//================================================================================
/*!
* \brief compute 2D mesh on initial 3D
*/
//================================================================================
void SMESHGUI_Make2DFrom3DOp::selectionDone()
{
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()
{
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;
}

View File

@ -16,70 +16,97 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESHGUI : GUI for SMESH component
// 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
#define SMESHGUI_Make2DFrom3DOp_H
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
#include "SMESHGUI_Dialog.h"
#include "SMESHGUI_Operation.h"
#include "SMESHGUI_SelectionOp.h"
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
class QFrame;
class SMESHGUI_MeshInfosBox;
class QCheckBox;
class QLineEdit;
class QRadioButton;
/*!
* \brief Dialog to show result mesh statistic
*/
class SMESHGUI_Make2DFrom3DDlg : public SMESHGUI_Dialog
class SMESHGUI_EXPORT SMESHGUI_CopyMeshDlg : public SMESHGUI_Dialog
{
Q_OBJECT
public:
SMESHGUI_Make2DFrom3DDlg( QWidget* );
virtual ~SMESHGUI_Make2DFrom3DDlg();
public:
enum { Mesh };
void SetMeshName(const QString& theName);
void SetMeshInfo(const SMESH::long_array& theInfo);
SMESHGUI_CopyMeshDlg( QWidget* );
virtual ~SMESHGUI_CopyMeshDlg();
private:
QFrame* createMainFrame( QWidget* );
SMESH::Bnd_Dimension mode() const;
private:
QLabel* myMeshName;
SMESHGUI_MeshInfosBox* myFullInfo;
bool needNewMesh() const;
QString getNewMeshName() const;
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
*/
class SMESHGUI_Make2DFrom3DOp : public SMESHGUI_Operation
class SMESHGUI_EXPORT SMESHGUI_Make2DFrom3DOp : public SMESHGUI_SelectionOp
{
public:
Q_OBJECT
public:
SMESHGUI_Make2DFrom3DOp();
virtual ~SMESHGUI_Make2DFrom3DOp();
protected:
virtual void startOperation();
virtual LightApp_Dialog* dlg() const;
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();
private:
SMESH::SMESH_Mesh_var myMesh;
QPointer<SMESHGUI_Make2DFrom3DDlg> myDlg;
private:
SMESH::SMESH_IDSource_var mySrc;
QPointer<SMESHGUI_CopyMeshDlg> myDlg;
};
#endif // SMESHGUI_Make2DFrom3DOp_H

View File

@ -82,4 +82,44 @@ namespace SMESH
}
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

View File

@ -36,10 +36,15 @@
// SALOME GUI includes
#include <SALOME_InteractiveObject.hxx>
// SALOME KERNEL includes
#include <SALOMEDSClient_definitions.hxx>
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class SALOMEDSClient_SObject;
namespace SMESH
{
SMESHGUI_EXPORT
@ -47,6 +52,8 @@ namespace SMESH
SMESHGUI_EXPORT
QString UniqueMeshName( const QString&, const QString& = QString() );
SMESHGUI_EXPORT
QString UniqueName( const QString&, _PTR(SObject) = _PTR(SObject)(), const QString& = QString() );
}
#endif // SMESHGUI_MESHUTILS_H

View File

@ -5257,4 +5257,78 @@ It is impossible to read point coordinates from file</translation>
<translation>Construct group with newly created elements</translation>
</message>
</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>