diff --git a/resources/SMESH_en.xml b/resources/SMESH_en.xml
index 7d314c75d..6702d3e21 100644
--- a/resources/SMESH_en.xml
+++ b/resources/SMESH_en.xml
@@ -24,6 +24,7 @@
+
@@ -185,6 +186,7 @@
+
diff --git a/resources/SMESH_fr.xml b/resources/SMESH_fr.xml
index d5dbf4640..e25d5ef35 100644
--- a/resources/SMESH_fr.xml
+++ b/resources/SMESH_fr.xml
@@ -24,6 +24,7 @@
+
diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx
index 9427c8d61..d56b7424a 100644
--- a/src/SMESHGUI/SMESHGUI.cxx
+++ b/src/SMESHGUI/SMESHGUI.cxx
@@ -260,6 +260,7 @@ using namespace std;
if ( !aMesh->_is_nil() ) {
QString aFilter, aTitle = QObject::tr("Export mesh");
QMap aFilterMap;
+ QMap aFilterMapSTL;
switch ( theCommandID ) {
case 125:
case 122:
@@ -299,6 +300,36 @@ using namespace std;
aFilter = QObject::tr("IDEAS files (*.unv)");
}
break;
+ case 140:
+ case 141:
+ {
+ // export STL
+ /*
+ there must be check on others mesh elements not equal triangles
+ */
+ if (aMesh->NbTriangles() < 1) {
+ int aRet = SUIT_MessageBox::warn1
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
+ QObject::tr("SMESH_BUT_OK"));
+ return;
+ }
+ if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
+ int aRet = SUIT_MessageBox::warn2
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
+ QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
+ 0, 1, 0);
+ if (aRet)
+ return;
+ }
+
+ aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
+ aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
+ }
+ break;
default:
return;
}
@@ -306,13 +337,35 @@ using namespace std;
QString aFilename;
SMESH::MED_VERSION aFormat;
// Init the parameter with the default value
+ bool aIsASCII_STL = true;
bool toCreateGroups = false;
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
if ( resMgr )
toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
- if ( theCommandID != 122 && theCommandID != 125 )
+ if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
+
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
+
+ else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
+ QStringList filters;
+ QMap::const_iterator it = aFilterMapSTL.begin();
+ for ( ; it != aFilterMapSTL.end(); ++it )
+ filters.push_back( it.key() );
+
+ SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
+ fd->setCaption( aTitle );
+ fd->setFilters( filters );
+ fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
+ bool is_ok = false;
+ while (!is_ok) {
+ fd->exec();
+ aFilename = fd->selectedFile();
+ aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
+ is_ok = true;
+ }
+ delete fd;
+ }
else {
QStringList filters;
QMap::const_iterator it = aFilterMap.begin();
@@ -381,6 +434,10 @@ using namespace std;
case 123:
aMesh->ExportUNV( aFilename.latin1() );
break;
+ case 140:
+ case 141:
+ aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
+ break;
default:
break;
}
@@ -1150,6 +1207,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case 124:
case 125:
case 126:
+ case 140:
+ case 141:
{
::ExportMeshToFile(theCommandID);
break;
@@ -2347,9 +2406,11 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( 121, "DAT" );
createSMESHAction( 122, "MED" );
createSMESHAction( 123, "UNV" );
+ createSMESHAction( 140, "STL" );
createSMESHAction( 124, "EXPORT_DAT" );
createSMESHAction( 125, "EXPORT_MED" );
createSMESHAction( 126, "EXPORT_UNV" );
+ createSMESHAction( 141, "EXPORT_STL" );
createSMESHAction( 33, "DELETE", "ICON_DELETE" );
createSMESHAction( 5105, "SEL_FILTER_LIB" );
createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
@@ -2472,6 +2533,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createMenu( 121, exportId, -1 );
createMenu( 122, exportId, -1 );
createMenu( 123, exportId, -1 );
+ createMenu( 140, exportId, -1 ); // export to stl STL
createMenu( separator(), fileId, 10 );
@@ -2693,6 +2755,7 @@ void SMESHGUI::initialize( CAM_Application* app )
QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
+ createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
popupMgr()->insert( separator(), -1, 0 );
diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po
index a3320a865..41cf35f58 100644
--- a/src/SMESHGUI/SMESH_msg_en.po
+++ b/src/SMESHGUI/SMESH_msg_en.po
@@ -1349,6 +1349,13 @@ msgid "SMESH_EXPORT_UNV"
msgstr "During export mesh with name - \"%1\" to UNV\n"
" pyramid's elements will be missed"
+msgid "SMESH_EXPORT_STL1"
+msgstr "Mesh - \"%1\" does not contain triangles"
+
+msgid "SMESH_EXPORT_STL2"
+msgstr "Mesh - \"%1\" contains another than triangles elements,"
+ " they are ignored during writing to STL"
+
msgid "SMESH_EXPORT_MED_DUPLICATED_GRP"
msgstr "There are duplicated group names in mesh \"%1\".\n"
"You can cancel exporting and rename them,\n"
@@ -2109,6 +2116,9 @@ msgstr "UNV file"
msgid "MEN_MED"
msgstr "MED file"
+msgid "MEN_STL"
+msgstr "STL file"
+
msgid "MEN_EXPORT_DAT"
msgstr "Export to DAT file"
@@ -2118,6 +2128,9 @@ msgstr "Export to UNV file"
msgid "MEN_EXPORT_MED"
msgstr "Export to MED file"
+msgid "MEN_EXPORT_STL"
+msgstr "Export to STL file"
+
msgid "MEN_DELETE"
msgstr "Delete"
@@ -2480,6 +2493,9 @@ msgstr "Export to UNV file"
msgid "TOP_EXPORT_MED"
msgstr "Export to MED file"
+msgid "TOP_EXPORT_STL"
+msgstr "Export to STL file"
+
msgid "TOP_DELETE"
msgstr "Delete"
@@ -2790,6 +2806,9 @@ msgstr "Export to UNV file"
msgid "STB_EXPORT_MED"
msgstr "Export to MED file"
+msgid "STB_EXPORT_STL"
+msgstr "Export to STL file"
+
msgid "STB_DELETE"
msgstr "Delete"