diff --git a/EgtExchange.rc b/EgtExchange.rc index 7f8d8c1..4e9bb64 100644 Binary files a/EgtExchange.rc and b/EgtExchange.rc differ diff --git a/Export3MF.cpp b/Export3MF.cpp index 70a6cb7..fbc9cc8 100644 --- a/Export3MF.cpp +++ b/Export3MF.cpp @@ -30,6 +30,9 @@ using namespace std ; using namespace Lib3MF ; +//---------------------------------------------------------------------------- +static string sInfoNamespace = "CustomInfo" ; + //---------------------------------------------------------------------------- IExport3MF* CreateExport3MF( void) @@ -87,6 +90,17 @@ Export3MF::Export( IGeomDB* pGDB, int nId, const string& sFile) if ( IsNull( pIter)) return false ; pIter->GoTo( nId) ; + + // assegno le info dell'oggetto al modello + PMetaDataGroup metaDataGrp = m_model->GetMetaDataGroup() ; + STRVECTOR vInfo ; + pIter->GetAllInfo( vInfo) ; + for ( const string& sInfo : vInfo) { + string sKey, sVal ; + SplitFirst( sInfo, "=", sKey, sVal) ; + metaDataGrp->AddMetaData( sInfoNamespace, sKey, sVal, "xs:string", 0) ; + } + // esporto l'oggetto e i suoi eventuali figli if ( ! ExportObject( *pIter)) return false ; @@ -143,16 +157,16 @@ Export3MF::ExportObject( const IGdbIterator& iIter) Color cCol ; bool bCol = GetColor( cCol, iIter.GetGDB(), iIter.GetId()) ; // recupero le proprietà - string sSliceNbr ; - iIter.GetInfo( "SliceNbr", sSliceNbr) ; + STRVECTOR vInfo ; + iIter.GetAllInfo( vInfo) ; // emetto l'oggetto switch ( pGeoObj->GetType()) { case SRF_TRIMESH : - if ( ! ExportSTM( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, sSliceNbr)) + if ( ! ExportSTM( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, vInfo)) return false ; break ; case SRF_FLATRGN : - if ( ! ExportSFR( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, sSliceNbr)) + if ( ! ExportSFR( sName, pGeoObj, frFrame, bCol ? &cCol : nullptr, vInfo)) return false ; break ; default : @@ -191,8 +205,7 @@ Export3MF::TestFilter( int nLev, int nMode, int nStat) //---------------------------------------------------------------------------- bool -Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, - const string& sSliceNbr) +Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, const STRVECTOR& vInfo) { // verifico oggetto const ISurfFlatRegion* pSFR = GetSurfFlatRegion( pGeoObj) ; @@ -200,13 +213,12 @@ Export3MF::ExportSFR( const string& sName, const IGeoObj* pGeoObj, const Frame3d return false ; // ricavo la trimesh equivalente const ISurfTriMesh* pStm = pSFR->GetAuxSurf() ; - return ExportSTM( sName, pStm, frFrame, pCol, sSliceNbr) ; + return ExportSTM( sName, pStm, frFrame, pCol, vInfo) ; } //---------------------------------------------------------------------------- bool -Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, - const string& sSliceNbr) +Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, const STRVECTOR& vInfo) { // verifico oggetto const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ; @@ -258,10 +270,14 @@ Export3MF::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d Lib3MF_uint32 nColId = ColorHandler3MF( pCol) ; meshObject->SetObjectLevelProperty( 1, nColId) ; } - - // assegno il layer - if ( ! sSliceNbr.empty()) - meshObject->SetPartNumber( sSliceNbr) ; + + // assegno le info + PMetaDataGroup metaDataGrp = meshObject->GetMetaDataGroup() ; + for ( const string& sInfo : vInfo) { + string sKey, sVal ; + SplitFirst( sInfo, "=", sKey, sVal) ; + metaDataGrp->AddMetaData( sInfoNamespace, sKey, sVal, "xs:string", 0) ; + } m_model->AddBuildItem( meshObject.get(), m_wrapper->GetIdentityTransform()) ; return true ; diff --git a/Export3MF.h b/Export3MF.h index 11d4691..56cb3bf 100644 --- a/Export3MF.h +++ b/Export3MF.h @@ -33,10 +33,10 @@ class Export3MF : public IExport3MF bool ExportObject( const IGdbIterator& iIter) ; bool ScanGroup( const IGdbIterator& iIter) ; bool TestFilter( int nLev, int nMode, int nStat) ; - bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, - const std::string& sSliceNbr) ; - bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, - const std::string& sSliceNbr) ; + bool ExportSFR( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, + const STRVECTOR& vInfo) ; + bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, const Color* pCol, + const STRVECTOR& vInfo) ; Lib3MF_uint32 ColorHandler3MF( const Color* pCol) ; bool GetColor( Color& pCol, const IGeomDB * pGBD, const int& nId) ;