From be54bcf382fac421e2f42ab471832ea619e28cea Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 5 Jul 2018 10:28:52 +0000 Subject: [PATCH] EgtExecutor 1.9g1 : - aggiunta gestione import punti in Exe e LUA - corretta gestione regione sotto con lati inclinati interni di pezzi piatti (flatParts) - aggiunta funzione Exe e Lua CAvGetToolOutline per avere profilo di utensile in uso nella CollisionAvoidance. --- DllExchange.cpp | 22 ++++- DllExchange.h | 6 +- EXE_CAvTool.cpp | 23 +++++ EXE_Const.h | 6 +- EXE_Exchange.cpp | 129 ++++++++++++++++--------- EXE_NstCreateFlatParts.cpp | 193 +++++++++++++++++++++++++------------ EgtExecutor.rc | Bin 16146 -> 16146 bytes LUA_CAvTool.cpp | 18 +++- LUA_Exchange.cpp | 76 +++++++++------ 9 files changed, 326 insertions(+), 147 deletions(-) diff --git a/DllExchange.cpp b/DllExchange.cpp index e8241c6..e3eccd1 100644 --- a/DllExchange.cpp +++ b/DllExchange.cpp @@ -1,13 +1,13 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2015 +// EgalTech 2015-2018 //---------------------------------------------------------------------------- -// File : DllExchange.cpp Data : 27.03.15 Versione : 1.6c9 +// File : DllExchange.cpp Data : 03.07.18 Versione : 1.9g1 // Contenuto : Funzioni di gestione della libreria opzionale EgtExchange. // // // // Modifiche : 27.03.15 DS Creazione modulo. -// +// 03.07.18 DS Aggiunto ImportPnt. // //---------------------------------------------------------------------------- @@ -40,6 +40,7 @@ static const char* EEX_CREATEIMPORTBTL = "CreateImportBtl" ; static const char* EEX_CREATEIMPORTCNC = "CreateImportCnc" ; static const char* EEX_CREATEIMPORTCSF = "CreateImportCsf" ; static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ; +static const char* EEX_CREATEIMPORTPNT = "CreateImportPnt" ; static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ; static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ; static const char* EEX_CREATEEXPORTSTL = "CreateExportStl" ; @@ -197,6 +198,21 @@ MyCreateImportDxf( void) return pFun() ; } +//----------------------------------------------------------------------------- +IImportPnt* +MyCreateImportPnt( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IImportPnt* (* PF_CreateImportPnt) ( void) ; + PF_CreateImportPnt pFun = (PF_CreateImportPnt)GetProcAddress( s_hEEx, EEX_CREATEIMPORTPNT) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + //----------------------------------------------------------------------------- IImportStl* MyCreateImportStl( void) diff --git a/DllExchange.h b/DllExchange.h index 630374a..9083a18 100644 --- a/DllExchange.h +++ b/DllExchange.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2015 +// EgalTech 2015-2018 //---------------------------------------------------------------------------- -// File : DllGraphics.h Data : 27.03.15 Versione : 1.6c9 +// File : DllGraphics.h Data : 03.07.18 Versione : 1.9g1 // Contenuto : Dichiarazioni funzioni per libreria opzionale EgtGraphics. // // @@ -20,6 +20,7 @@ class IImportBtl ; class IImportCnc ; class IImportCsf ; class IImportDxf ; +class IImportPnt ; class IImportStl ; class IExportDxf ; class IExportStl ; @@ -36,6 +37,7 @@ IImportBtl* MyCreateImportBtl( void) ; IImportCnc* MyCreateImportCnc( void) ; IImportCsf* MyCreateImportCsf( void) ; IImportDxf* MyCreateImportDxf( void) ; +IImportPnt* MyCreateImportPnt( void) ; IImportStl* MyCreateImportStl( void) ; IExportDxf* MyCreateExportDxf( void) ; IExportStl* MyCreateExportStl( void) ; diff --git a/EXE_CAvTool.cpp b/EXE_CAvTool.cpp index 41c3659..2ee65e3 100644 --- a/EXE_CAvTool.cpp +++ b/EXE_CAvTool.cpp @@ -66,6 +66,29 @@ ExeCAvSetGenTool( int nToolSectId) return s_pCAvTlStm->SetGenTool( pCC) ; } +//---------------------------------------------------------------------------- +int +ExeCAvGetToolOutline( int nDestGrpId) +{ + if ( IsNull( s_pCAvTlStm)) + return GDB_ID_NULL ; + // verifico DB geometrico + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero outline dell'utensile + const ICurveComposite* pCC = s_pCAvTlStm->GetToolOutline() ; + if ( pCC == nullptr || ! pCC->IsValid()) + return GDB_ID_NULL ; + // ne faccio una copia + PtrOwner pCopy( pCC->Clone()) ; + if ( IsNull( pCopy)) + return GDB_ID_NULL ; + // inserisco la copia nel DB geometrico + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCopy)) ; + ExeSetModified() ; + return nId ; +} + //---------------------------------------------------------------------------- double ExeCAvToolPosStm( const Point3d& ptP, const Vector3d& vtAx, int nSurfTmId, const Vector3d& vtMove, int nRefType) diff --git a/EXE_Const.h b/EXE_Const.h index 115a6a0..5650d02 100644 --- a/EXE_Const.h +++ b/EXE_Const.h @@ -30,10 +30,12 @@ const std::string CRV_ORIG = "ORIG" ; const std::string NST_PARTREG_LAYER = "Region" ; const std::string NST_PARTUPREG_LAYER = "UpReg" ; const std::string NST_PARTDOWNREG_LAYER = "DwnReg" ; -const std::string NST_EXT_LAYER = "OutLoop" ; -const std::string NST_EXT_ORIG_LAYER = "OutLoop.orig" ; +const std::string NST_OUT_LAYER = "OutLoop" ; +const std::string NST_OUT_ORIG_LAYER = "OutLoop.orig" ; const std::string NST_IN_LAYER = "InLoop" ; +const std::string NST_IN_ORIG_LAYER = "InLoop.orig" ; const std::string NST_ON_LAYER = "OnPath" ; +const std::string NST_KEY_COPY = "Copy" ; const std::string NST_KEY_SIDEANG = "SideAng" ; const std::string NST_KEY_OFFSET = "Offset" ; const std::string NST_KEY_DEPTH = "Depth" ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 5cb7f57..4e8f23d 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -26,6 +26,7 @@ #include "/EgtDev/Include/EExImportBtl.h" #include "/EgtDev/Include/EExExportStl.h" #include "/EgtDev/Include/EExExportDxf.h" +#include "/EgtDev/Include/EExImportPnt.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -61,6 +62,8 @@ ExeGetFileType( const string& sFilePath) return FT_BTL ; else if ( sFileExt == "PNG" || sFileExt == "JPG" || sFileExt == "JPEG" || sFileExt == "BMP") return FT_IMG ; + else if ( sFileExt == "PNT" || sFileExt == "XYZ") + return FT_PNT ; else if ( sFileExt == "TSC") return FT_TSC ; else if ( sFileExt == "LUA") @@ -75,58 +78,25 @@ ExeGetFileType( const string& sFilePath) //----------------------------------------------------------------------------- bool -ExeImportDxf( const string& sFilePath, double dScaleFactor) +ExeImportBtl( const string& sFilePath, int nFlag) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) bool bOk = true ; - // importo il file DXF - // aggiungo un gruppo pezzo - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + // importo il file BTL // preparo l'importatore - PtrOwner pImpDxf( MyCreateImportDxf()) ; - bOk = bOk && ! IsNull( pImpDxf) ; - // eseguo l'importazione - bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ; + PtrOwner pImpBtl( MyCreateImportBtl()) ; + bOk = bOk && ! IsNull( pImpBtl) ; + // eseguo l'importazione (direttamente nella radice) + bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, nFlag) ; // aggiorno stato file corrente if ( pGseCtx->m_sFilePath.empty()) pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtImportDxf('" + StringToLuaString( sFilePath) + "'," + - ToString( dScaleFactor) + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - -//----------------------------------------------------------------------------- -bool -ExeImportStl( const string& sFilePath, double dScaleFactor) -{ - GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_GEOMDB( pGseCtx, false) - bool bOk = true ; - // importo il file STL - // aggiungo un gruppo pezzo e un gruppo layer - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; - // preparo l'importatore - PtrOwner pImpStl( MyCreateImportStl()) ; - bOk = bOk && ! IsNull( pImpStl) ; - // eseguo l'importazione - bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ; - // aggiorno stato file corrente - if ( pGseCtx->m_sFilePath.empty()) - pGseCtx->m_sFilePath = sFilePath ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtImportStl('" + StringToLuaString( sFilePath) + "'," + - ToString( dScaleFactor) + ")" + + string sLua = "EgtImportBtl('" + StringToLuaString( sFilePath) + "'," + + ToString( nFlag) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -193,24 +163,56 @@ ExeImportCsf( const string& sFilePath) //----------------------------------------------------------------------------- bool -ExeImportBtl( const string& sFilePath, int nFlag) +ExeImportDxf( const string& sFilePath, double dScaleFactor) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) bool bOk = true ; - // importo il file BTL + // importo il file DXF + // aggiungo un gruppo pezzo + int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; // preparo l'importatore - PtrOwner pImpBtl( MyCreateImportBtl()) ; - bOk = bOk && ! IsNull( pImpBtl) ; - // eseguo l'importazione (direttamente nella radice) - bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, nFlag) ; + PtrOwner pImpDxf( MyCreateImportDxf()) ; + bOk = bOk && ! IsNull( pImpDxf) ; + // eseguo l'importazione + bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ; // aggiorno stato file corrente if ( pGseCtx->m_sFilePath.empty()) pGseCtx->m_sFilePath = sFilePath ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtImportBtl('" + StringToLuaString( sFilePath) + "'," + + string sLua = "EgtImportDxf('" + StringToLuaString( sFilePath) + "'," + + ToString( dScaleFactor) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +ExeImportPnt( const string& sFilePath, int nFlag) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + bool bOk = true ; + // importo il file PNT + // aggiungo un gruppo pezzo + int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpPnt( MyCreateImportPnt()) ; + bOk = bOk && ! IsNull( pImpPnt) ; + // eseguo l'importazione + bOk = bOk && pImpPnt->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, nFlag) ; + // aggiorno stato file corrente + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtImportPnt('" + StringToLuaString( sFilePath) + "'," + ToString( nFlag) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -219,6 +221,37 @@ ExeImportBtl( const string& sFilePath, int nFlag) return bOk ; } +//----------------------------------------------------------------------------- +bool +ExeImportStl( const string& sFilePath, double dScaleFactor) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + bool bOk = true ; + // importo il file STL + // aggiungo un gruppo pezzo e un gruppo layer + int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpStl( MyCreateImportStl()) ; + bOk = bOk && ! IsNull( pImpStl) ; + // eseguo l'importazione + bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ; + // aggiorno stato file corrente + if ( pGseCtx->m_sFilePath.empty()) + pGseCtx->m_sFilePath = sFilePath ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtImportStl('" + StringToLuaString( sFilePath) + "'," + + ToString( dScaleFactor) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeExportDxf( int nId, const string& sFilePath) diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index 4a2e9a9..86a4f12 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -520,7 +520,7 @@ VerifyAndAdjustFlatParts( void) if ( ! IsNull( pOutCrv)) { int nOutLoopId = ExeCreateGroup( pPar->GetId(), Frame3d(), RTY_GLOB) ; bOk = bOk && nOutLoopId != GDB_ID_NULL ; - bOk = bOk && pGeomDB->SetName( nOutLoopId, NST_EXT_LAYER) ; + bOk = bOk && pGeomDB->SetName( nOutLoopId, NST_OUT_LAYER) ; pGeomDB->AddGeoObj( GDB_ID_NULL, nOutLoopId, Release( pOutCrv)) ; } // creo nuovi layer in cui copiare gli eventuali contorni interni @@ -832,7 +832,7 @@ ExeCalcFlatPartUpRegion( int nPartId, bool bCalc) return true ; // recupero il layer esterno - int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ; + int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_LAYER) ; if ( nOlId == GDB_ID_NULL) return false ; // se il pezzo non ha lati esterni con offset negativo non devo fare alcunchè @@ -926,60 +926,31 @@ ExeCalcFlatPartUpRegion( int nPartId, bool bCalc) } //---------------------------------------------------------------------------- -bool -ExeCalcFlatPartDownRegion( int nPartId, double dH) +static bool +AdjustLayerForSideAngle( IGeomDB* pGeomDB, int nLayOrigId, const string& sLayOrig, int nLayReg, double dH) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - - // ripristino lo stato originale - pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTDOWNREG_LAYER)) ; - int nOlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_ORIG_LAYER) ; - if ( nOlOrigId != GDB_ID_NULL) { - pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER)) ; - pGeomDB->SetName( nOlOrigId, NST_EXT_LAYER) ; - pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ; - } - // se spessore nullo, non devo fare altro - if ( dH < EPS_SMALL) - return true ; - // recupero il layer esterno - int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_EXT_LAYER) ; - if ( nOlId == GDB_ID_NULL) + // creo una copia del layer + int nLayId = pGeomDB->Copy( nLayOrigId, GDB_ID_NULL, nLayOrigId, GDB_AFTER) ; + if ( nLayId == GDB_ID_NULL) return false ; - // se il pezzo non ha lati esterni inclinati non devo fare alcunchè - bool bAllVertSides = true ; - int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ; - while ( nCrvId != GDB_ID_NULL) { - double dSideAng ; - if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) { - bAllVertSides = false ; - break ; - } - nCrvId = pGeomDB->GetNext( nCrvId) ; - } - if ( bAllVertSides) - return true ; - - // creo una copia del layer esterno - nOlOrigId = pGeomDB->Copy( nOlId, GDB_ID_NULL, nOlId, GDB_AFTER) ; - if ( nOlOrigId == GDB_ID_NULL) + pGeomDB->SetName( nLayOrigId, sLayOrig) ; + pGeomDB->SetInfo( nLayOrigId, NST_KEY_COPY, nLayId) ; + pGeomDB->SetStatus( nLayOrigId, GDB_ST_OFF) ; + // creo un layer temporaneo + const string sTmpLayName = "TmpLay" ; + Frame3d frLay ; + pGeomDB->GetGroupFrame( nLayId, frLay) ; + int nTmpLayId = pGeomDB->AddGroup( GDB_ID_NULL, pGeomDB->GetParentId( nLayId), frLay) ; + if ( nTmpLayId == GDB_ID_NULL) return false ; - pGeomDB->SetName( nOlOrigId, NST_EXT_ORIG_LAYER) ; - pGeomDB->SetStatus( nOlOrigId, GDB_ST_OFF) ; - // creo il layer per la regione sotto (con il medesimo riferimento del layer esterno) - Frame3d frOl ; - pGeomDB->GetGroupFrame( nOlId, frOl) ; - int nDwnRegId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, frOl) ; - if ( nDwnRegId == GDB_ID_NULL) - return false ; - pGeomDB->SetName( nDwnRegId, NST_PARTDOWNREG_LAYER) ; + pGeomDB->SetName( nTmpLayId, sTmpLayName) ; + pGeomDB->SetLevel( nTmpLayId, GDB_LV_TEMP) ; // copio le entità del contorno esterno e le offsetto opportunamente - nCrvId = pGeomDB->GetFirstInGroup( nOlId) ; + int nCrvId = pGeomDB->GetFirstInGroup( nLayId) ; while ( nCrvId != GDB_ID_NULL) { - // copio la curva nel gruppo downregion - int nNewId = pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nDwnRegId) ; + // copio la curva nel gruppo temporaneo + int nNewId = pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nTmpLayId) ; if ( nNewId == GDB_ID_NULL) return false ; // determino ed eseguo offset @@ -997,7 +968,7 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH) nCrvId = pGeomDB->GetNext( nCrvId) ; } // aggiusto tra loro le entità offsettate - int nFirstCrvId = pGeomDB->GetFirstInGroup( nDwnRegId) ; + int nFirstCrvId = pGeomDB->GetFirstInGroup( nTmpLayId) ; ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nFirstCrvId)) ; int nNextCrvId = pGeomDB->GetNext( nFirstCrvId) ; ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nNextCrvId)) ; @@ -1015,8 +986,8 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH) if ( pCrv1 == nullptr || pCrv2 == nullptr || ! AdjustCurves( pCrv1, pCrv2)) return false ; - // eventuali allungamenti per le curve del loop esterno - for ( int nCrvId = pGeomDB->GetFirstInGroup( nOlId) ; + // eventuali allungamenti/accorciamenti per le curve del loop + for ( int nCrvId = pGeomDB->GetFirstInGroup( nLayId) ; nCrvId != GDB_ID_NULL ; nCrvId = pGeomDB->GetNext( nCrvId)) { // recupero il nome @@ -1024,7 +995,7 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH) if ( ! pGeomDB->GetName( nCrvId, sName)) continue ; // recupero curva con lo stesso nome nel gruppo della regione sotto - int nCrvDrId = pGeomDB->GetFirstNameInGroup( nDwnRegId, sName) ; + int nCrvDrId = pGeomDB->GetFirstNameInGroup( nTmpLayId, sName) ; if ( nCrvDrId == GDB_ID_NULL) continue ; // verifico siano curve @@ -1072,24 +1043,122 @@ ExeCalcFlatPartDownRegion( int nPartId, double dH) } } } - - // creo la regione + // concateno le curve del layer temporaneo PtrOwner pCompo( CreateCurveComposite()) ; if ( IsNull( pCompo)) return false ; + for ( int nCrvId = pGeomDB->GetFirstInGroup( nTmpLayId) ; + nCrvId != GDB_ID_NULL ; + nCrvId = pGeomDB->GetFirstInGroup( nTmpLayId)) { + ICurve* pCrv = GetCurve( pGeomDB->RemoveGeoObjAndErase( nCrvId)) ; + if ( pCrv != nullptr) + pCompo->AddCurve( pCrv) ; + else + pGeomDB->Erase( nCrvId) ; + } + // cancello il layer temporaneo + pGeomDB->Erase( nTmpLayId) ; + // inserisco la curva concatenata nel layer della regione + if ( pGeomDB->AddGeoObj( GDB_ID_NULL, nLayReg, Release( pCompo)) == GDB_ID_NULL) + return false ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +ExeCalcFlatPartDownRegion( int nPartId, double dH) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + + // ripristino lo stato originale + pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_PARTDOWNREG_LAYER)) ; + int nOlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_ORIG_LAYER) ; + if ( nOlOrigId != GDB_ID_NULL) { + pGeomDB->Erase( pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_LAYER)) ; + pGeomDB->SetName( nOlOrigId, NST_OUT_LAYER) ; + pGeomDB->SetStatus( nOlOrigId, GDB_ST_ON) ; + } + for ( int nIlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_IN_ORIG_LAYER) ; + nIlOrigId != GDB_ID_NULL ; + nIlOrigId = pGeomDB->GetFirstNameInGroup( nPartId, NST_IN_ORIG_LAYER)) { + int nCopyId = GDB_ID_NULL ; + pGeomDB->GetInfo( nIlOrigId, NST_KEY_COPY, nCopyId) ; + if ( nCopyId != GDB_ID_NULL) + pGeomDB->Erase( nCopyId) ; + pGeomDB->SetName( nIlOrigId, NST_IN_LAYER) ; + pGeomDB->SetStatus( nIlOrigId, GDB_ST_ON) ; + } + + // se spessore nullo, non devo fare altro + if ( dH < EPS_SMALL) + return true ; + + // recupero i layer esterno ed interni (primo sempre esterno) + INTVECTOR vLayId ; + int nOlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_OUT_LAYER) ; + if ( nOlId == GDB_ID_NULL) + return false ; + vLayId.push_back( nOlId) ; + for ( int nIlId = pGeomDB->GetFirstNameInGroup( nPartId, NST_IN_LAYER) ; + nIlId != GDB_ID_NULL ; + nIlId = pGeomDB->GetNextName( nIlId, NST_IN_LAYER)) + vLayId.push_back( nIlId) ; + // se il pezzo non ha lati esterni o interni inclinati all'infuori non devo fare alcunchè + bool bAllVertSides = true ; + for ( size_t i = 0 ; i < vLayId.size() ; ++ i) { + int nCrvId = pGeomDB->GetFirstInGroup( vLayId[i]) ; + while ( nCrvId != GDB_ID_NULL) { + double dSideAng ; + if ( pGeomDB->GetInfo( nCrvId, NST_KEY_SIDEANG, dSideAng) && abs( dSideAng) > EPS_ANG_SMALL) { + bAllVertSides = false ; + break ; + } + nCrvId = pGeomDB->GetNext( nCrvId) ; + } + } + if ( bAllVertSides) + return true ; + + // assegno un nome alle curve dei layer che ne sono prive + for ( size_t i = 0 ; i < vLayId.size() ; ++ i) { + int nCnt = 0 ; + for ( int nCrvId = pGeomDB->GetFirstInGroup( vLayId[i]) ; + nCrvId != GDB_ID_NULL ; + nCrvId = pGeomDB->GetNext( nCrvId)) { + if ( ! pGeomDB->ExistsName( nCrvId) && ( pGeomDB->GetGeoType( nCrvId) & GEO_CURVE) != 0) { + ++ nCnt ; + pGeomDB->SetName( nCrvId, "B" + ToString( nCnt)) ; + } + } + } + + // creo il layer per la regione sotto (con il medesimo riferimento del layer esterno) + Frame3d frOl ; + pGeomDB->GetGroupFrame( nOlId, frOl) ; + int nDwnRegId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, frOl) ; + if ( nDwnRegId == GDB_ID_NULL) + return false ; + pGeomDB->SetName( nDwnRegId, NST_PARTDOWNREG_LAYER) ; + + // modifico i layer e creo i contorni per la nuova regione + for ( size_t i = 0 ; i < vLayId.size() ; ++ i) { + string sLayOrig = ( i == 0 ? NST_OUT_ORIG_LAYER : NST_IN_ORIG_LAYER) ; + if ( ! AdjustLayerForSideAngle( pGeomDB, vLayId[i], sLayOrig, nDwnRegId, dH)) + return false ; + } + + // creo la regione + SurfFlatRegionByContours SfrCntr( false) ; for ( int nCrvId = pGeomDB->GetFirstInGroup( nDwnRegId) ; nCrvId != GDB_ID_NULL ; nCrvId = pGeomDB->GetFirstInGroup( nDwnRegId)) { ICurve* pCrv = GetCurve( pGeomDB->RemoveGeoObjAndErase( nCrvId)) ; - if ( pCrv != nullptr) { - pCompo->AddCurve( pCrv) ; - pGeomDB->RemoveGeoObjAndErase( nCrvId) ; - } + if ( pCrv != nullptr) + SfrCntr.AddCurve( pCrv) ; else pGeomDB->Erase( nCrvId) ; } - SurfFlatRegionByContours SfrCntr( false) ; - SfrCntr.AddCurve( Release( pCompo)) ; int nSfrId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDwnRegId, SfrCntr.GetSurf()) ; if ( nSfrId == GDB_ID_NULL) return false ; diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 2556c024923b8229fd72de9ccc86d387b8649545..3debab3e96761d77757d488f6d9e29440b31cec0 100644 GIT binary patch delta 103 zcmbPKH>qyJH#Syt1|0^&&A-{4nVHjp3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(qXMFs#q;T|CX delta 103 zcmbPKH>qyJH#Sx?1|0^|&A-{4nVHjo3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(qXMFs#vogO&= diff --git a/LUA_CAvTool.cpp b/LUA_CAvTool.cpp index ded2454..6bc1347 100644 --- a/LUA_CAvTool.cpp +++ b/LUA_CAvTool.cpp @@ -44,7 +44,7 @@ LuaCAvSetStdTool( lua_State* L) static int LuaCAvSetAdvTool( lua_State* L) { - // 5 parametri : dToolLen, dToolDiam, dToolCornR + // 5 parametri : dToolLen, dToolDiam, dTipLen, dTipDiam, dToolCornR double dToolLen ; LuaCheckParam( L, 1, dToolLen) double dToolDiam ; @@ -78,6 +78,21 @@ LuaCAvSetGenTool( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCAvGetToolOutline( lua_State* L) +{ + // 1 parametro : nDestGrpId + int nDestGrpId ; + LuaCheckParam( L, 1, nDestGrpId) + LuaClearStack( L) ; + // recupero profilo dell'utensile per Collision Avoidance + int nId = ExeCAvGetToolOutline( nDestGrpId) ; + // restituisco il risultato + LuaSetParam( L, nId) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCAvToolPosStm( lua_State* L) @@ -134,6 +149,7 @@ LuaInstallCAvTool( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtCAvSetStdTool", LuaCAvSetStdTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCAvSetAdvTool", LuaCAvSetAdvTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCAvSetGenTool", LuaCAvSetGenTool) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCAvGetToolOutline", LuaCAvGetToolOutline) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCAvToolPosStm", LuaCAvToolPosStm) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCAvToolPathStm", LuaCAvToolPathStm) ; return bOk ; diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index 425e437..d410aac 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -23,33 +23,16 @@ using namespace std ; //------------------------------------------------------------------------------- static int -LuaImportDxf( lua_State* L) +LuaImportBtl( lua_State* L) { - // 1 o 2 parametri : path del file da importare [, Fattore di scala] + // 1 o 2 : FilePath [, Flag] string sFilePath ; LuaCheckParam( L, 1, sFilePath) - double dScaleFactor = 1.0 ; - LuaGetParam( L, 2, dScaleFactor) ; + int nFlag = EIB_FLAG_NONE ; + LuaGetParam( L, 2, nFlag) ; LuaClearStack( L) ; // apro il file - bool bOk = ExeImportDxf( sFilePath, dScaleFactor) ; - // restituisco il risultato - LuaSetParam( L, bOk) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaImportStl( lua_State* L) -{ - // 1 o 2 parametri : path del file da importare [, Fattore di scala] - string sFilePath ; - LuaCheckParam( L, 1, sFilePath) - double dScaleFactor = 1.0 ; - LuaGetParam( L, 2, dScaleFactor) ; - LuaClearStack( L) ; - // apro il file - bool bOk = ExeImportStl( sFilePath, dScaleFactor) ; + bool bOk = ExeImportBtl( sFilePath, nFlag) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ; @@ -89,16 +72,50 @@ LuaImportCsf( lua_State* L) //------------------------------------------------------------------------------- static int -LuaImportBtl( lua_State* L) +LuaImportDxf( lua_State* L) { - // 1 o 2 : FilePath [, Flag] + // 1 o 2 parametri : path del file da importare [, Fattore di scala] string sFilePath ; LuaCheckParam( L, 1, sFilePath) - int nFlag = EIB_FLAG_NONE ; + double dScaleFactor = 1.0 ; + LuaGetParam( L, 2, dScaleFactor) ; + LuaClearStack( L) ; + // apro il file + bool bOk = ExeImportDxf( sFilePath, dScaleFactor) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaImportPnt( lua_State* L) +{ + // 1 o 2 parametri : FilePath [, Flag] + string sFilePath ; + LuaCheckParam( L, 1, sFilePath) + int nFlag = 0 ; LuaGetParam( L, 2, nFlag) ; LuaClearStack( L) ; // apro il file - bool bOk = ExeImportBtl( sFilePath, nFlag) ; + bool bOk = ExeImportPnt( sFilePath, nFlag) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaImportStl( lua_State* L) +{ + // 1 o 2 parametri : path del file da importare [, Fattore di scala] + string sFilePath ; + LuaCheckParam( L, 1, sFilePath) + double dScaleFactor = 1.0 ; + LuaGetParam( L, 2, dScaleFactor) ; + LuaClearStack( L) ; + // apro il file + bool bOk = ExeImportStl( sFilePath, dScaleFactor) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ; @@ -143,11 +160,12 @@ bool LuaInstallExchange( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtImportDxf", LuaImportDxf) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtImportStl", LuaImportStl) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtImportBtl", LuaImportBtl) ; bOk = bOk && luaMgr.RegisterFunction( "EgtImportCnc", LuaImportCnc) ; bOk = bOk && luaMgr.RegisterFunction( "EgtImportCsf", LuaImportCsf) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtImportBtl", LuaImportBtl) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtImportDxf", LuaImportDxf) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtImportPnt", LuaImportPnt) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtImportStl", LuaImportStl) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExportDxf", LuaExportDxf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExportStl", LuaExportStl) ; return bOk ;