mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-27 09:50:34 +05:00
Improvement:
Adding support of export to STL format (ASCII and Binary modes)
This commit is contained in:
parent
3cf3be138c
commit
6c0166b6e1
@ -24,6 +24,7 @@
|
|||||||
<popup-item item-id="121" pos-id="" label-id="DAT File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="121" pos-id="" label-id="DAT File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
<popup-item item-id="122" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="122" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
<popup-item item-id="123" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="123" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
|
<popup-item item-id="140" pos-id="" label-id="STL File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
</submenu>
|
</submenu>
|
||||||
<endsubmenu />
|
<endsubmenu />
|
||||||
<separator pos-id="10"/>
|
<separator pos-id="10"/>
|
||||||
@ -185,6 +186,7 @@
|
|||||||
<separator pos-id=""/>
|
<separator pos-id=""/>
|
||||||
<popup-item item-id="122" pos-id="" label-id="Export to MED" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="122" pos-id="" label-id="Export to MED" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
<popup-item item-id="123" pos-id="" label-id="Export to UNV" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="123" pos-id="" label-id="Export to UNV" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
|
<popup-item item-id="140" pos-id="" label-id="Export to STL" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
</popupmenu>
|
</popupmenu>
|
||||||
|
|
||||||
<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="SubMesh">
|
<popupmenu label-id="Popup for ObjectBrowser" context-id="" parent-id="ObjectBrowser" object-id="SubMesh">
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
<popup-item item-id="121" pos-id="" label-id="DAT File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="121" pos-id="" label-id="DAT File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
<popup-item item-id="122" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="122" pos-id="" label-id="MED File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
<popup-item item-id="123" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
<popup-item item-id="123" pos-id="" label-id="UNV File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
|
<popup-item item-id="140" pos-id="" label-id="STL File" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
|
||||||
</submenu>
|
</submenu>
|
||||||
<endsubmenu />
|
<endsubmenu />
|
||||||
<separator pos-id="10"/>
|
<separator pos-id="10"/>
|
||||||
|
@ -260,6 +260,7 @@ using namespace std;
|
|||||||
if ( !aMesh->_is_nil() ) {
|
if ( !aMesh->_is_nil() ) {
|
||||||
QString aFilter, aTitle = QObject::tr("Export mesh");
|
QString aFilter, aTitle = QObject::tr("Export mesh");
|
||||||
QMap<QString, SMESH::MED_VERSION> aFilterMap;
|
QMap<QString, SMESH::MED_VERSION> aFilterMap;
|
||||||
|
QMap<QString, int> aFilterMapSTL;
|
||||||
switch ( theCommandID ) {
|
switch ( theCommandID ) {
|
||||||
case 125:
|
case 125:
|
||||||
case 122:
|
case 122:
|
||||||
@ -299,6 +300,36 @@ using namespace std;
|
|||||||
aFilter = QObject::tr("IDEAS files (*.unv)");
|
aFilter = QObject::tr("IDEAS files (*.unv)");
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -306,13 +337,35 @@ using namespace std;
|
|||||||
QString aFilename;
|
QString aFilename;
|
||||||
SMESH::MED_VERSION aFormat;
|
SMESH::MED_VERSION aFormat;
|
||||||
// Init the parameter with the default value
|
// Init the parameter with the default value
|
||||||
|
bool aIsASCII_STL = true;
|
||||||
bool toCreateGroups = false;
|
bool toCreateGroups = false;
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
if ( resMgr )
|
if ( resMgr )
|
||||||
toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
|
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);
|
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 {
|
else {
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
|
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
|
||||||
@ -381,6 +434,10 @@ using namespace std;
|
|||||||
case 123:
|
case 123:
|
||||||
aMesh->ExportUNV( aFilename.latin1() );
|
aMesh->ExportUNV( aFilename.latin1() );
|
||||||
break;
|
break;
|
||||||
|
case 140:
|
||||||
|
case 141:
|
||||||
|
aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1150,6 +1207,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
|||||||
case 124:
|
case 124:
|
||||||
case 125:
|
case 125:
|
||||||
case 126:
|
case 126:
|
||||||
|
case 140:
|
||||||
|
case 141:
|
||||||
{
|
{
|
||||||
::ExportMeshToFile(theCommandID);
|
::ExportMeshToFile(theCommandID);
|
||||||
break;
|
break;
|
||||||
@ -2347,9 +2406,11 @@ void SMESHGUI::initialize( CAM_Application* app )
|
|||||||
createSMESHAction( 121, "DAT" );
|
createSMESHAction( 121, "DAT" );
|
||||||
createSMESHAction( 122, "MED" );
|
createSMESHAction( 122, "MED" );
|
||||||
createSMESHAction( 123, "UNV" );
|
createSMESHAction( 123, "UNV" );
|
||||||
|
createSMESHAction( 140, "STL" );
|
||||||
createSMESHAction( 124, "EXPORT_DAT" );
|
createSMESHAction( 124, "EXPORT_DAT" );
|
||||||
createSMESHAction( 125, "EXPORT_MED" );
|
createSMESHAction( 125, "EXPORT_MED" );
|
||||||
createSMESHAction( 126, "EXPORT_UNV" );
|
createSMESHAction( 126, "EXPORT_UNV" );
|
||||||
|
createSMESHAction( 141, "EXPORT_STL" );
|
||||||
createSMESHAction( 33, "DELETE", "ICON_DELETE" );
|
createSMESHAction( 33, "DELETE", "ICON_DELETE" );
|
||||||
createSMESHAction( 5105, "SEL_FILTER_LIB" );
|
createSMESHAction( 5105, "SEL_FILTER_LIB" );
|
||||||
createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
|
createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
|
||||||
@ -2472,6 +2533,7 @@ void SMESHGUI::initialize( CAM_Application* app )
|
|||||||
createMenu( 121, exportId, -1 );
|
createMenu( 121, exportId, -1 );
|
||||||
createMenu( 122, exportId, -1 );
|
createMenu( 122, exportId, -1 );
|
||||||
createMenu( 123, exportId, -1 );
|
createMenu( 123, exportId, -1 );
|
||||||
|
createMenu( 140, exportId, -1 ); // export to stl STL
|
||||||
|
|
||||||
createMenu( separator(), fileId, 10 );
|
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() );
|
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( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
|
||||||
createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
|
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
|
createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
|
||||||
popupMgr()->insert( separator(), -1, 0 );
|
popupMgr()->insert( separator(), -1, 0 );
|
||||||
|
|
||||||
|
@ -1349,6 +1349,13 @@ msgid "SMESH_EXPORT_UNV"
|
|||||||
msgstr "During export mesh with name - \"%1\" to UNV\n"
|
msgstr "During export mesh with name - \"%1\" to UNV\n"
|
||||||
" pyramid's elements will be missed"
|
" 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"
|
msgid "SMESH_EXPORT_MED_DUPLICATED_GRP"
|
||||||
msgstr "There are duplicated group names in mesh \"%1\".\n"
|
msgstr "There are duplicated group names in mesh \"%1\".\n"
|
||||||
"You can cancel exporting and rename them,\n"
|
"You can cancel exporting and rename them,\n"
|
||||||
@ -2109,6 +2116,9 @@ msgstr "UNV file"
|
|||||||
msgid "MEN_MED"
|
msgid "MEN_MED"
|
||||||
msgstr "MED file"
|
msgstr "MED file"
|
||||||
|
|
||||||
|
msgid "MEN_STL"
|
||||||
|
msgstr "STL file"
|
||||||
|
|
||||||
msgid "MEN_EXPORT_DAT"
|
msgid "MEN_EXPORT_DAT"
|
||||||
msgstr "Export to DAT file"
|
msgstr "Export to DAT file"
|
||||||
|
|
||||||
@ -2118,6 +2128,9 @@ msgstr "Export to UNV file"
|
|||||||
msgid "MEN_EXPORT_MED"
|
msgid "MEN_EXPORT_MED"
|
||||||
msgstr "Export to MED file"
|
msgstr "Export to MED file"
|
||||||
|
|
||||||
|
msgid "MEN_EXPORT_STL"
|
||||||
|
msgstr "Export to STL file"
|
||||||
|
|
||||||
msgid "MEN_DELETE"
|
msgid "MEN_DELETE"
|
||||||
msgstr "Delete"
|
msgstr "Delete"
|
||||||
|
|
||||||
@ -2480,6 +2493,9 @@ msgstr "Export to UNV file"
|
|||||||
msgid "TOP_EXPORT_MED"
|
msgid "TOP_EXPORT_MED"
|
||||||
msgstr "Export to MED file"
|
msgstr "Export to MED file"
|
||||||
|
|
||||||
|
msgid "TOP_EXPORT_STL"
|
||||||
|
msgstr "Export to STL file"
|
||||||
|
|
||||||
msgid "TOP_DELETE"
|
msgid "TOP_DELETE"
|
||||||
msgstr "Delete"
|
msgstr "Delete"
|
||||||
|
|
||||||
@ -2790,6 +2806,9 @@ msgstr "Export to UNV file"
|
|||||||
msgid "STB_EXPORT_MED"
|
msgid "STB_EXPORT_MED"
|
||||||
msgstr "Export to MED file"
|
msgstr "Export to MED file"
|
||||||
|
|
||||||
|
msgid "STB_EXPORT_STL"
|
||||||
|
msgstr "Export to STL file"
|
||||||
|
|
||||||
msgid "STB_DELETE"
|
msgid "STB_DELETE"
|
||||||
msgstr "Delete"
|
msgstr "Delete"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user