From 1e24540dc13ff14d4d6aef2716d2c11b0f7cb4b1 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 11 Feb 2015 11:46:14 +0000 Subject: [PATCH] EgtInterface 1.6b2 : - razionalizzazione - modificati comandi per creazione superfici per gestione piani di regioni con buchi - aggiunta SplitCurve. --- API.h | 8 ++ API_GdbCreateCurve.cpp | 12 ++- API_GdbCreateSurf.cpp | 184 ++++++++++++++++++++++++++++++++++++----- API_GdbModify.cpp | 2 + API_GdbModifyCurve.cpp | 46 ++++++++++- API_GdbObjAttribs.cpp | 4 +- API_General.cpp | 17 +++- API_Lua.cpp | 8 +- EInDllMain.cpp | 5 ++ EgtInterface.rc | Bin 11718 -> 11718 bytes EgtInterface.vcxproj | 8 +- GseContext.h | 1 + LUA_GdbCreateSurf.cpp | 91 ++++++++++++++++---- LUA_GdbModify.cpp | 2 +- LUA_GdbModifyCurve.cpp | 17 ++++ 15 files changed, 345 insertions(+), 60 deletions(-) diff --git a/API.h b/API.h index 136d1b6..610b5c8 100644 --- a/API.h +++ b/API.h @@ -21,6 +21,7 @@ //---------------------------------------------------------------------------- ILogger* GetLogger( void) ; ILogger* GetCmdLogger( void) ; +bool SetCmdLog( bool bVal) ; bool IsCmdLog( void) ; //--------------------------- General ---------------------------------------- @@ -54,6 +55,13 @@ int EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, int EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) ; int EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefType) ; +//--------------------------- GeomDBCreateSurface ---------------------------- +int EgtCreateSurfTriMeshByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) ; +int EgtCreateSurfTriMeshByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) ; +int EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) ; + //--------------------------- GdbModify -------------------------------------- bool EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType) ; bool EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase) ; diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index 595f75e..961c8d1 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -914,7 +914,7 @@ __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls PNTVECTOR vPnt ; vPnt.reserve( nDegree + 1) ; for ( int i = 0 ; i <= nDegree ; ++i) { - vPnt.push_back( Point3d( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2])) ; + vPnt.emplace_back( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2]) ; } return EgtCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ; } @@ -978,7 +978,7 @@ __stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const double PNTUVECTOR vPntW ; vPntW.reserve( nDegree + 1) ; for ( int i = 0 ; i <= nDegree ; ++i) { - vPntW.push_back( make_pair( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3])) ; + vPntW.emplace_back( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3]) ; } return EgtCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ; } @@ -1382,7 +1382,7 @@ EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) while ( PL.GetNextPoint( ptP)) sPnt += ",{" + ToString( ptP) + "}" ; string sLua = "EgtCurveCompoFromPoints(" + ToString( nParentId) + ",{" + - sPnt + "},{" + + sPnt + "}," + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -1437,7 +1437,7 @@ EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefTy while ( PA.GetNextPoint( ptP, dB)) sPnt += ",{" + ToString( ptP) + "," + ToString( dB) + "}" ; string sLua = "EgtCurveCompoFromPointBulges(" + ToString( nParentId) + ",{" + - sPnt + "},{" + + sPnt + "}," + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -1533,8 +1533,12 @@ __stdcall EgtCreateRectangle3P( int nParentId, const double ptIni[3], PL.AddUPoint( 2, ptCrossL) ; PL.AddUPoint( 3, Point3d( ptCrossL) - vtLatoX) ; PL.AddUPoint( 4, ptIniL) ; + // disabilito log dei comandi e salvo stato precedente + bool bPrevCmdLog = SetCmdLog( false) ; // creo la curva e la inserisco nel GDB nId = EgtCreateCurveCompoFromPoints( nParentId, PL, RTY_LOC) ; + // ripristino precedente stato dei comandi + SetCmdLog( bPrevCmdLog) ; // ne sistemo il vettore estrusione ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; if ( pCurve != nullptr) diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index f225ae6..33c8707 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -28,7 +28,7 @@ using namespace std ; //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinTol) +__stdcall EgtCreateSurfTriMeshByFlatContour( int nParentId, int nCrvId, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -40,15 +40,15 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; bOk = bOk && ( CrvLoc.Get() != nullptr) ; // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByContour( *CrvLoc.Get(), dLinTol) : nullptr) ; + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByFlatContour( CrvLoc.Get(), dLinTol) : nullptr) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSurfTmByContour(" + ToString( nParentId) + "," + - ToString( nCrvId) + "," + - ToString( dLinTol) + ")" + + string sLua = "EgtSurfTmByFlatContour(" + ToString( nParentId) + "," + + ToString( nCrvId) + "," + + ToString( dLinTol) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -58,8 +58,19 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const double vtExtr[3], - BOOL bCapEnds, double dLinTol, int nRefType) +__stdcall EgtCreateSurfTriMeshByRegion( int nParentId, int nNumId, const int nCrvIds[], double dLinTol) +{ + INTVECTOR vCrvIds ; + vCrvIds.reserve( nNumId) ; + for ( int i = 0 ; i < nNumId ; ++i) { + vCrvIds.push_back( nCrvIds[i]) ; + } + return EgtCreateSurfTriMeshByRegion( nParentId, vCrvIds, dLinTol) ; +} + +//------------------------------------------------------------------------------- +int +EgtCreateSurfTriMeshByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -67,24 +78,159 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub // recupero il riferimento locale Frame3d frLoc ; bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; - // recupero la curva in locale - CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ; - bOk = bOk && ( CrvLoc.Get() != nullptr) ; - // porto in locale il vettore estrusione - Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ; + // recupero le curve in locale + CURVELOCALVECTOR vCrvLoc ; + vCrvLoc.reserve( vCrvIds.size()) ; + ICURVEPVECTOR vCrvP ; + vCrvP.reserve( vCrvIds.size()) ; + for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { + vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ; + vCrvP.push_back( const_cast( vCrvLoc[i].Get())) ; + bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ; + } // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByExtrusion( *CrvLoc.Get(), vtExtrL, ( bCapEnds != FALSE), dLinTol) : nullptr) ; + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRegion( vCrvP, dLinTol) : nullptr) ; + bOk = bOk && ( pSTM != nullptr) ; + // elimino punti ripetuti + bOk = bOk && pSTM->DoCompacting() ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + "," + - ToString( nCrvId) + ",{" + + string sIds ; + for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) + sIds += ToString( vCrvIds[i]) + "," ; + sIds.pop_back() ; + string sLua = "EgtSurfTmByRegion(" + ToString( nParentId) + ",{" + + sIds + "}," + + ToString( dLinTol) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nNumId, const int nCrvIds[], + const double vtExtr[3], double dLinTol, int nRefType) +{ + INTVECTOR vCrvIds ; + vCrvIds.reserve( nNumId) ; + for ( int i = 0 ; i < nNumId ; ++i) { + vCrvIds.push_back( nCrvIds[i]) ; + } + return EgtCreateSurfTriMeshByExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; +} + +//------------------------------------------------------------------------------- +int +EgtCreateSurfTriMeshByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // recupero le curve in locale + CURVELOCALVECTOR vCrvLoc ; + vCrvLoc.reserve( vCrvIds.size()) ; + ICURVEPVECTOR vCrvP ; + vCrvP.reserve( vCrvIds.size()) ; + for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { + vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ; + vCrvP.push_back( const_cast( vCrvLoc[i].Get())) ; + bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ; + } + // porto in locale il vettore estrusione + Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ; + // creo le superfici e le inserisco nel DB + int nFirstId = GDB_ID_NULL ; + for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) { + // calcolo la superficie + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByExtrusion( vCrvP[i], vtExtrL, false, dLinTol) : nullptr) ; + // inserisco la superficie nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + bOk = bOk && ( nNewId != GDB_ID_NULL) ; + if ( bOk && nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + } + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sIds ; + for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) + sIds += ToString( vCrvIds[i]) + "," ; + sIds.pop_back() ; + string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + ",{" + + sIds + "},{" + ToString( Vector3d( vtExtr)) + "}," + - ( bCapEnds ? "true" : "false") + "," + ToString( dLinTol) + "," + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nFirstId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nFirstId ; +} + +//------------------------------------------------------------------------------- +int +__stdcall EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, int nNumId, const int nCrvIds[], + const double vtExtr[3], double dLinTol, int nRefType) +{ + INTVECTOR vCrvIds ; + vCrvIds.reserve( nNumId) ; + for ( int i = 0 ; i < nNumId ; ++i) { + vCrvIds.push_back( nCrvIds[i]) ; + } + return EgtCreateSurfTriMeshByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; +} + +//------------------------------------------------------------------------------- +int +EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // recupero le curve in locale + CURVELOCALVECTOR vCrvLoc ; + vCrvLoc.reserve( vCrvIds.size()) ; + ICURVEPVECTOR vCrvP ; + vCrvP.reserve( vCrvIds.size()) ; + for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) { + vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ; + vCrvP.push_back( const_cast( vCrvLoc[i].Get())) ; + bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ; + } + // porto in locale il vettore estrusione + Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ; + int nNewId = GDB_ID_NULL ; + // creo la superficie + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRegionExtrusion( vCrvP, vtExtrL, dLinTol) : nullptr) ; + // inserisco la superficie nel DB + nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sIds ; + for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) + sIds += ToString( vCrvIds[i]) + "," ; + sIds.pop_back() ; + string sLua = "EgtSurfTmByRegionExtrusion(" + ToString( nParentId) + ",{" + + sIds + "},{" + + ToString( Vector3d( vtExtr)) + "}," + + ToString( dLinTol) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -111,7 +257,7 @@ __stdcall EgtCreateSurfTriMeshByRevolve( int nParentId, int nCrvId, Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ; Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRevolve( *CrvLoc.Get(), ptAxL, vtAxL, ( bCapEnds != FALSE), dLinTol) : nullptr) ; + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRevolve( CrvLoc.Get(), ptAxL, vtAxL, ( bCapEnds != FALSE), dLinTol) : nullptr) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; EgtSetModified() ; @@ -150,7 +296,7 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ; Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByScrewing( *CrvLoc.Get(), ptAxL, vtAxL, dAngRotDeg, dMove, dLinTol) : nullptr) ; + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByScrewing( CrvLoc.Get(), ptAxL, vtAxL, dAngRotDeg, dMove, dLinTol) : nullptr) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; EgtSetModified() ; @@ -188,7 +334,7 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ; bOk = bOk && ( CrvLoc2.Get() != nullptr) ; // calcolo la superficie - ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshRuled( *CrvLoc1.Get(), *CrvLoc2.Get(), dLinTol) : nullptr) ; + ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ; // inserisco la superficie trimesh nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ; EgtSetModified() ; diff --git a/API_GdbModify.cpp b/API_GdbModify.cpp index 468b9ee..f93d52a 100644 --- a/API_GdbModify.cpp +++ b/API_GdbModify.cpp @@ -187,6 +187,8 @@ EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase) // eseguo la cucitura bOk = bOk && pStm->DoSewing( *pStmS, frStm) ; } + // compatto + bOk = bOk && pStm->DoCompacting() ; // se richiesto, cancello le superfici cucite alla prima if ( bOk && bErase) { for ( size_t i = 1 ; i < vIds.size() ; ++ i) diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index 5fe3134..0b97236 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -469,6 +469,44 @@ __stdcall EgtTrimExtendCurveByLen( int nId, double dLen, const double ptNear[3], return ( bOk ? TRUE : FALSE) ; } +//---------------------------------------------------------------------------- +BOOL +__stdcall EgtSplitCurve( int nId, int nParts) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero la curva + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pCurve != nullptr) ; + // il numero di parti non può essere inferiore a 1 + nParts = max( nParts, 1) ; + // lunghezza totale della curva + double dLenTot = 0 ; + bOk = bOk && pCurve->GetLength( dLenTot) ; + // lunghezza di una parte + double dLen = dLenTot / nParts ; + // eseguo la divisione + for ( int i = 1; i < nParts ; ++ i) { + // copio la curva + int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_BEFORE) ; + ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ; + bOk = bOk && ( pCopyCrv != nullptr) ; + // tengo la prima parte della copia e la seconda parte dell'originale + bOk = bOk && pCopyCrv->TrimEndAtLen( dLen) ; + bOk = bOk && pCurve->TrimStartAtLen( dLen) ; + } + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSplitCurve(" + ToString( nId) + "," + + ToString( nParts) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return ( bOk ? TRUE : FALSE) ; +} + //---------------------------------------------------------------------------- BOOL __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType) @@ -507,12 +545,12 @@ __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType) // se il punto di taglio è interno, devo realmente tagliare if ( bIsInside) { // copio la curva - int nCopyId = GDB_ID_NULL ; - if ( bOk && ( nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER)) == GDB_ID_NULL) - bOk = false ; + int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ; + ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ; + bOk = bOk && ( pCopyCrv != nullptr) ; // tengo la prima parte dell'originale e la seconda parte della copia bOk = bOk && pCurve->TrimEndAtParam( dU) ; - bOk = bOk && ( EgtTrimCurveStartAtParam( nCopyId, dU) != FALSE) ; + bOk = bOk && pCopyCrv->TrimStartAtParam( dU) ; } EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index 34fb735..83b89b0 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -203,7 +203,7 @@ __stdcall EgtSetMark( int nId) VERIFY_GEOMDB( pGeomDB, FALSE) // imposto l'evidenziazione bool bOk = pGeomDB->SetMark( nId) ; - EgtSetModified() ; + // non produce modifica perchè mark ignorato in salvataggio return ( bOk ? TRUE : FALSE) ; } @@ -215,7 +215,7 @@ __stdcall EgtResetMark( int nId) VERIFY_GEOMDB( pGeomDB, FALSE) // cancello l'evidenziazione bool bOk = pGeomDB->ResetMark( nId) ; - EgtSetModified() ; + // non produce modifica perchè mark ignorato in salvataggio return ( bOk ? TRUE : FALSE) ; } diff --git a/API_General.cpp b/API_General.cpp index 31ed86a..8eb8608 100644 --- a/API_General.cpp +++ b/API_General.cpp @@ -37,7 +37,7 @@ static bool s_bCmdLog = false ; //----------------------------------------------------------------------------- BOOL -__stdcall EgtInit( int nDebug, const wchar_t* sLogFile) +__stdcall EgtInit( int nDebug, const wchar_t* sLogFile, const wchar_t* sLogMsg) { // cancello eventuali vecchi contesti ClearAllGseContexts() ; @@ -59,6 +59,9 @@ __stdcall EgtInit( int nDebug, const wchar_t* sLogFile) // dichiaro inizio programma LOG_DATETIME( s_pGenLog, " Init") + // eventuale messaggio dall'applicazione + if ( sLogMsg != nullptr && sLogMsg[0] != L'\0') + LOG_INFO( s_pGenLog, LPSTR( WtoA( sLogMsg))) // versione dell'interfaccia LOG_INFO( s_pGenLog, GetEInVersion()) // versione delle librerie @@ -180,14 +183,14 @@ __stdcall EgtSetCommandLogger( const wchar_t* sLogFile) void __stdcall EgtEnableCommandLogger( void) { - s_bCmdLog = true ; + SetCmdLog( true) ; } //----------------------------------------------------------------------------- void __stdcall EgtDisableCommandLogger( void) { - s_bCmdLog = false ; + SetCmdLog( false) ; } //----------------------------------------------------------------------------- @@ -257,6 +260,14 @@ GetCmdLogger( void) return s_pCmdLog ; } +//----------------------------------------------------------------------------- +bool +SetCmdLog( bool bVal) +{ + swap( bVal, s_bCmdLog) ; + return bVal ; +} + //----------------------------------------------------------------------------- bool IsCmdLog( void) diff --git a/API_Lua.cpp b/API_Lua.cpp index 3759752..18dd5e4 100644 --- a/API_Lua.cpp +++ b/API_Lua.cpp @@ -52,15 +52,13 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal) BOOL __stdcall EgtLuaExecLine( const wchar_t* wsLine) { - // disabilito il log dei comandi - bool bPrevCmdLog = IsCmdLog() ; - EgtDisableCommandLogger() ; + // disabilito log dei comandi e salvo stato precedente + bool bPrevCmdLog = SetCmdLog( false) ; // eseguo il comando string sLine = wstrztoA( wsLine) ; bool bOk = LuaExecLine( sLine) ; // ripristino lo stato originale del log dei comandi - if ( bPrevCmdLog) - EgtEnableCommandLogger() ; + SetCmdLog( bPrevCmdLog) ; // se richiesto, salvo il comando Lua if ( IsCmdLog()) { string sLua = sLine + diff --git a/EInDllMain.cpp b/EInDllMain.cpp index d9bb7e4..996691e 100644 --- a/EInDllMain.cpp +++ b/EInDllMain.cpp @@ -50,6 +50,11 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) // if ( IsDbgPresent) // return 0 ; //#endif + // se debug, imposto stampe memory leaks all'uscita + #if defined ( _DEBUG) + _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) ; + #endif + // eseguo s_hModule = hModule ; EGT_TRACE( "EgtInterface.dll Initializing!\n") ; } diff --git a/EgtInterface.rc b/EgtInterface.rc index 621aad5fbbfa04f2e3ee965a4b437a5e7ac74fda..3ad5505876ed7f409fb93c6d6a6d28009584c538 100644 GIT binary patch delta 111 zcmX>WeJpyzFE&P_%^&$rGEF|hS;uHJ`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07g?Nt^fc4 delta 111 zcmX>WeJpyzFE&QQ%^&$rGEF|hS;uHN`Jtfh<^rw;7OzIAO+TQQ4Xt~E@c}o07PdfrT_o{ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index 32a9bd2..64c1784 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -147,14 +147,14 @@ copy $(TargetPath) \EgtProg\DllD64 Level3 Use - Full + MaxSpeed true true WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Speed AnySuitable true - false + true true StreamingSIMDExtensions2 @@ -177,13 +177,13 @@ copy $(TargetPath) \EgtProg\Dll32 Level3 Use - Full + MaxSpeed true true WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Speed AnySuitable - false + true true true diff --git a/GseContext.h b/GseContext.h index 79151fd..0fc0441 100644 --- a/GseContext.h +++ b/GseContext.h @@ -16,6 +16,7 @@ #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGrScene.h" #include "/EgtDev/Include/EGnCmdParser.h" +#define NOMINMAX #include //---------------------------------------------------------------------------- diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 0268a81..35d2b36 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -23,21 +23,47 @@ using namespace std ; +//------------------------------------------------------------------------------- +static const double LIN_TOL_DEF = 0.05 ; + //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByContour( lua_State* L) +LuaCreateSurfTriMeshByFlatContour( lua_State* L) { // 2 o 3 parametri : ParentId, CrvId [, dTol] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; LuaCheckParam( L, 2, nCrvId) - double dLinTol = 0.1 ; + double dLinTol = LIN_TOL_DEF ; if ( lua_gettop( L) >= 3) LuaCheckParam( L, 3, dLinTol) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByContour( nParentId, nCrvId, dLinTol) ; + int nId = EgtCreateSurfTriMeshByFlatContour( nParentId, nCrvId, dLinTol) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTriMeshByRegion( lua_State* L) +{ + // 2 o 3 parametri : ParentId, CrvIds [, dTol] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vCrvIds ; + LuaCheckParam( L, 2, vCrvIds) + double dLinTol = LIN_TOL_DEF ; + if ( lua_gettop( L) >= 3) + LuaCheckParam( L, 3, dLinTol) ; + LuaClearStack( L) ; + // creo STM riempiendo una regione (piana) + int nId = EgtCreateSurfTriMeshByRegion( nParentId, vCrvIds, dLinTol) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -50,25 +76,52 @@ LuaCreateSurfTriMeshByContour( lua_State* L) static int LuaCreateSurfTriMeshByExtrusion( lua_State* L) { - // 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr, bCapEnds [, dTol] [, sRefType] + // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) - int nCrvId ; - LuaCheckParam( L, 2, nCrvId) + INTVECTOR vCrvIds ; + LuaCheckParam( L, 2, vCrvIds) Vector3d vtExtr ; LuaCheckParam( L, 3, vtExtr) - bool bCapEnds ; - LuaCheckParam( L, 4, bCapEnds) - double dLinTol = 0.1 ; + double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; - if ( LuaGetParam( L, 5, dLinTol)) - LuaGetRefType( L, 6, nRefType) ; - else + if ( LuaGetParam( L, 4, dLinTol)) LuaGetRefType( L, 5, nRefType) ; + else + LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; - // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, nCrvId, vtExtr.v, - ( bCapEnds ? TRUE : FALSE), dLinTol, nRefType) ; + // creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi + int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, vCrvIds, vtExtr, + dLinTol, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTriMeshByRegionExtrusion( lua_State* L) +{ + // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vCrvIds ; + LuaCheckParam( L, 2, vCrvIds) + Vector3d vtExtr ; + LuaCheckParam( L, 3, vtExtr) + double dLinTol = LIN_TOL_DEF ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 4, dLinTol)) + LuaGetRefType( L, 5, nRefType) ; + else + LuaGetRefType( L, 4, nRefType) ; + LuaClearStack( L) ; + // creo STM estrudendo uno o più percorsi, con aggiunta dei tappi + int nId = EgtCreateSurfTriMeshByRegionExtrusion( nParentId, vCrvIds, vtExtr, + dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -126,7 +179,7 @@ LuaCreateSurfTriMeshByScrewing( lua_State* L) LuaCheckParam( L, 5, dAngRotDeg) double dMove ; LuaCheckParam( L, 6, dMove) - double dLinTol = 0.1 ; + double dLinTol = LIN_TOL_DEF ; int nRefType = RTY_DEFAULT ; if ( LuaGetParam( L, 7, dLinTol)) LuaGetRefType( L, 8, nRefType) ; @@ -154,7 +207,7 @@ LuaCreateSurfTriMeshRuled( lua_State* L) LuaCheckParam( L, 2, nCrvId1) int nCrvId2 ; LuaCheckParam( L, 3, nCrvId2) - double dLinTol = 0.1 ; + double dLinTol = LIN_TOL_DEF ; if ( lua_gettop( L) >= 4) LuaCheckParam( L, 4, dLinTol) ; LuaClearStack( L) ; @@ -173,8 +226,10 @@ bool LuaInstallGdbCreateSurf( lua_State* L) { try { - lua_register( L, "EgtSurfTmByContour", LuaCreateSurfTriMeshByContour) ; + lua_register( L, "EgtSurfTmByFlatContour", LuaCreateSurfTriMeshByFlatContour) ; + lua_register( L, "EgtSurfTmByRegion", LuaCreateSurfTriMeshByRegion) ; lua_register( L, "EgtSurfTmByExtrusion", LuaCreateSurfTriMeshByExtrusion) ; + lua_register( L, "EgtSurfTmByRegionExtrusion", LuaCreateSurfTriMeshByRegionExtrusion) ; lua_register( L, "EgtSurfTmByRevolve", LuaCreateSurfTriMeshByRevolve) ; lua_register( L, "EgtSurfTmByScrewing", LuaCreateSurfTriMeshByScrewing) ; lua_register( L, "EgtSurfTmRuled", LuaCreateSurfTriMeshRuled) ; diff --git a/LUA_GdbModify.cpp b/LUA_GdbModify.cpp index b4ed3b8..5b07422 100644 --- a/LUA_GdbModify.cpp +++ b/LUA_GdbModify.cpp @@ -88,7 +88,7 @@ LuaSurfTmDoSewing( lua_State* L) if ( lua_gettop( L) >= 2) LuaCheckParam( L, 2, bErase) ; LuaClearStack( L) ; - // eseguo inversione superfici + // eseguo cucitura superfici bool bOk = EgtSurfTmDoSewing( vId, bErase) ; // restituisco il risultato LuaSetReturn( L, bOk) ; diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 1951039..dad3c89 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -245,6 +245,22 @@ LuaTrimExtendCurveByLen( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSplitCurve( lua_State* L) +{ + // 2 parametri : Id, nParts + int nId ; + LuaCheckParam( L, 1, nId) + int nParts ; + LuaCheckParam( L, 2, nParts) + LuaClearStack( L) ; + // divido la curva nel punto + bool bOk = ( EgtSplitCurve( nId, nParts) != FALSE) ; + LuaSetReturn( L, bOk) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaSplitCurveAtPoint( lua_State* L) @@ -333,6 +349,7 @@ LuaInstallGdbModifyCurve( lua_State* L) lua_register( L, "EgtTrimCurveEndAtParam", LuaTrimCurveEndAtParam) ; lua_register( L, "EgtTrimCurveStartEndAtParam", LuaTrimCurveStartEndAtParam) ; lua_register( L, "EgtTrimExtendCurveByLen", LuaTrimExtendCurveByLen) ; + lua_register( L, "EgtSplitCurve", LuaSplitCurve) ; lua_register( L, "EgtSplitCurveAtPoint", LuaSplitCurveAtPoint) ; lua_register( L, "EgtModifyCurveArcRadius", LuaModifyCurveArcRadius) ; lua_register( L, "EgtExplodeCurveCompo", LuaExplodeCurveCompo) ;