if ( !aMesh->_is_nil() ) {
QString aFilter, aTitle = QObject::tr("Export mesh");
QMap<QString, SMESH::MED_VERSION> aFilterMap;
+ QMap<QString, int> aFilterMapSTL;
switch ( theCommandID ) {
case 125:
case 122:
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;
}
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<QString, int>::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<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
case 123:
aMesh->ExportUNV( aFilename.latin1() );
break;
+ case 140:
+ case 141:
+ aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
+ break;
default:
break;
}
case 124:
case 125:
case 126:
+ case 140:
+ case 141:
{
::ExportMeshToFile(theCommandID);
break;
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" );
createMenu( 121, exportId, -1 );
createMenu( 122, exportId, -1 );
createMenu( 123, exportId, -1 );
+ createMenu( 140, exportId, -1 ); // export to stl STL
createMenu( separator(), fileId, 10 );
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 );
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"
msgid "MEN_MED"
msgstr "MED file"
+msgid "MEN_STL"
+msgstr "STL file"
+
msgid "MEN_EXPORT_DAT"
msgstr "Export to DAT file"
msgid "MEN_EXPORT_MED"
msgstr "Export to MED file"
+msgid "MEN_EXPORT_STL"
+msgstr "Export to STL file"
+
msgid "MEN_DELETE"
msgstr "Delete"
msgid "TOP_EXPORT_MED"
msgstr "Export to MED file"
+msgid "TOP_EXPORT_STL"
+msgstr "Export to STL file"
+
msgid "TOP_DELETE"
msgstr "Delete"
msgid "STB_EXPORT_MED"
msgstr "Export to MED file"
+msgid "STB_EXPORT_STL"
+msgstr "Export to STL file"
+
msgid "STB_DELETE"
msgstr "Delete"