From fd718143e6f890e9fecf364339d016d35496d44c Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 16 Apr 2015 06:55:49 +0000 Subject: [PATCH] =?UTF-8?q?EgtInterface=201.6d2=20:=20-=20in=20Lua=20in=20?= =?UTF-8?q?tutte=20le=20operazioni=20con=20creazione=20di=20pi=C3=B9=20ent?= =?UTF-8?q?it=C3=A0=20restituisco=20Id=20prima=20e=20numero=20-=20in=20Lua?= =?UTF-8?q?=20aggiunto=20oggetto=20BBox3d=20(non=20ancora=20con=20tutte=20?= =?UTF-8?q?le=20funzionalit=C3=A0)=20-=20in=20Lua=20aggiunta=20creazione?= =?UTF-8?q?=20superficie=20da=20BBox3d=20-=20in=20Lua=20aggiunte=20funzion?= =?UTF-8?q?i=20per=20avere=20BBox3d=20di=20oggetti=20-=20in=20Lua=20aggiun?= =?UTF-8?q?ta=20OutBox=20-=20in=20Lua=20aggiunte=20funzioni=20per=20MachMg?= =?UTF-8?q?r.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API.h | 24 ++- API_GdbCreateCurve.cpp | 31 ++-- API_GdbCreateSurf.cpp | 73 ++++++++- API_GdbModify.cpp | 83 ++++++---- API_GdbModifyCurve.cpp | 86 ++++++---- API_GdbModifySurf.cpp | 11 +- API_GdbObjects.cpp | 131 +++++++++++---- API_GeoBase.cpp | 69 +++++++- API_GeomDB.cpp | 6 + API_MachMgr.cpp | 360 +++++++++++++++++++++++++++++++++++++---- AuxTools.cpp | 81 +++++++++- AuxTools.h | 11 +- EgtInterface.rc | Bin 11718 -> 11718 bytes LUA_GdbCreateCurve.cpp | 6 +- LUA_GdbCreateSurf.cpp | 25 ++- LUA_GdbModify.cpp | 24 ++- LUA_GdbModifyCurve.cpp | 32 ++-- LUA_GdbModifySurf.cpp | 6 +- LUA_GdbObjects.cpp | 114 ++++++++++++- LUA_General.cpp | 27 ++++ LUA_GeoBase.cpp | 71 ++++++++ LUA_MachMgr.cpp | 271 +++++++++++++++++++++++++++++-- 22 files changed, 1335 insertions(+), 207 deletions(-) diff --git a/API.h b/API.h index 93854f3..71e1a52 100644 --- a/API.h +++ b/API.h @@ -51,11 +51,12 @@ int EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt, in int EgtCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPntW, int nRefType) ; int EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) ; int EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, - const Point3d& ptNear, bool bErase, int nRefType) ; + const Point3d& ptNear, bool bErase, int nRefType, int* pnCount) ; int EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) ; int EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefType) ; //--------------------------- GeomDBCreateSurface ---------------------------- +int EgtCreateSurfTmBBox( int nParentId, const BBox3d& b3Box, int nRefType) ; int EgtCreateSurfTmByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) ; int EgtCreateSurfTmByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, double dLinTol, int nRefType) ; @@ -73,6 +74,7 @@ bool EgtChangeTextFont( int nId, const std::string& sNewFont) ; bool EgtInvertCurve( const INTVECTOR& vIds) ; bool EgtModifyCurveExtrusion( const INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) ; bool EgtModifyCurveThickness( const INTVECTOR& vIds, double dThick) ; +bool EgtExplodeCurveCompo( int nId, int& nFirstId, int& nCount) ; //--------------------------- GdbModifySurf ---------------------------------- bool EgtInvertSurface( const INTVECTOR& vIds) ; @@ -80,6 +82,11 @@ bool EgtInvertSurface( const INTVECTOR& vIds) ; //--------------------------- GdbObjects ------------------------------------- int EgtGetFirstNameInGroup( int nGroupId, const std::string& sName) ; int EgtGetNextName( int nId, const std::string& sName) ; +int EgtGetLastNameInGroup( int nGroupId, const std::string& sName) ; +int EgtGetPrevName( int nId, const std::string& sName) ; +bool EgtGetBBox( int nId, int nFlag, BBox3d& b3Box) ; +bool EgtGetBBoxGlob( int nId, int nFlag, BBox3d& b3Box) ; +bool EgtGetBBoxRef( int nId, int nFlag, const Frame3d& frRef, BBox3d& b3Box) ; bool EgtErase( const INTVECTOR& vIds) ; //--------------------------- GdbObjAttribs ---------------------------------- @@ -138,9 +145,20 @@ bool EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, bool EgtUpdateMachMgr( void) ; bool EgtInsertMachMgr( int nInsGrp) ; int EgtAddMachGroup( const std::string& sName, const std::string& sMachineName) ; -bool EgtGetMachGroupName( int nMGroupInd, std::string& sName) ; -bool EgtGetMachGroupInd( const std::string& sName, int& nInd) ; +bool EgtGetMachGroupName( int nId, std::string& sName) ; +int EgtGetMachGroupId( const std::string& sName) ; int EgtAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol) ; +int EgtAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) ; +bool EgtAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) ; +bool EgtModifyRawPartHeight( int nRawId, double dHeight) ; +bool EgtRemoveRawPart( int nRawId) ; +bool EgtTranslateRawPart( int nRawId, const Vector3d& vtMove) ; +bool EgtRotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ; +bool EgtMoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) ; +bool EgtMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) ; +bool EgtRemovePartFromRawPart( int nPartId) ; +bool EgtTranslatePartInRawPart( int nPartId, const Vector3d& vtMove) ; +bool EgtRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ; //--------------------------- Scene ------------------------------------------ bool EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) ; diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index e63d9d5..b01cffe 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -1449,14 +1449,8 @@ EgtCreateCurveCompo( int nParentId, const INTVECTOR& vIds, bool bErase) int nId = MyCreateCurveCompo( nParentId, vIds, bErase) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ToString( vIds[i]) ; - } string sLua = "EgtCurveCompo(" + ToString( nParentId) + ",{" + - sIds + "}," + + IdListToString( vIds) + "}," + ( bErase ? "true" : "false") + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -1475,13 +1469,13 @@ __stdcall EgtCreateCurveCompoByChain( int nParentId, int nNumId, const int nIds[ for ( int i = 0 ; i < nNumId ; ++i) { vIds.push_back( nIds[i]) ; } - return EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE), nRefType) ; + return EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, ( bErase != FALSE), nRefType, nullptr) ; } //------------------------------------------------------------------------------- static int MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, - const Point3d& ptNear, bool bErase, int nRefType) + const Point3d& ptNear, bool bErase, int nRefType, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -1525,6 +1519,7 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, } // recupero i percorsi concatenati int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; Point3d ptNearL = GetPointLocal( pGeomDB, ptNear.v, nRefType, frDest) ; INTVECTOR vId2s ; while ( chainC.GetChainFromNear( ptNearL, false, vId2s)) { @@ -1581,6 +1576,7 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, return GDB_ID_NULL ; if ( nFirstId == GDB_ID_NULL) nFirstId = nNewId ; + ++ nCount ; } // se richiesto e ok, cancello le curve originali if ( bErase && nFirstId != GDB_ID_NULL) { @@ -1594,29 +1590,30 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, } } // restituisco l'identificativo della prima nuova entità + if ( pnCount != nullptr) + *pnCount = nCount ; return nFirstId ; } //------------------------------------------------------------------------------- int EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, - const Point3d& ptNear, bool bErase, int nRefType) + const Point3d& ptNear, bool bErase, int nRefType, int* pnCount) { // eseguo - int nFirstId = MyCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType) ; + int nCount = 0 ; + int nFirstId = MyCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType, &nCount) ; + if ( pnCount != nullptr) + *pnCount = nCount ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; - sIds.pop_back() ; string sLua = "EgtCurveCompoByChain(" + ToString( nParentId) + ",{" + - sIds + "},{" + + IdListToString( vIds) + "},{" + ToString( ptNear) + "}," + ( bErase ? "true" : "false") + "," + RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nFirstId) ; + " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo della prima nuova entità diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index c6a9b9c..87632df 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -29,6 +29,67 @@ using namespace std ; +//------------------------------------------------------------------------------- +int +__stdcall EgtCreateSurfTmBBox( int nParentId, const double ptMin[3], const double ptMax[3], int nRefType) +{ + BBox3d b3Box ; + // per conservare un box vuoto + if ( ptMin[0] < ( ptMax[0] + EPS_SMALL) && + ptMin[1] < ( ptMax[1] + EPS_SMALL) && + ptMin[2] < ( ptMax[2] + EPS_SMALL)) + b3Box.Set( ptMin, ptMax) ; + // eseguo + return EgtCreateSurfTmBBox( nParentId, b3Box, nRefType) ; +} + +//------------------------------------------------------------------------------- +int +EgtCreateSurfTmBBox( int nParentId, const BBox3d& b3Box, int nRefType) +{ + // bounding box orientato come gli assi del riferimento + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // ricavo i punti standard e le dimensioni + Point3d ptIni ; + double dWidth = 0, dLen = 0, dHeight = 0 ; + bOk = bOk && b3Box.GetMinDim( ptIni, dWidth, dLen, dHeight) ; + dWidth = max( dWidth, 10 * EPS_SMALL) ; + dLen = max( dLen, 10 * EPS_SMALL) ; + dHeight = max( dHeight, 10 * EPS_SMALL) ; + Point3d ptCross = ptIni + Vector3d( dWidth, dLen) ; + Point3d ptDir = ptIni + Vector3d( dWidth, 0) ; + // porto in locale i punti + Point3d ptIniL = GetPointLocal( pGeomDB, ptIni.v, nRefType, frLoc) ; + Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross.v, nRefType, frLoc) ; + Point3d ptDirL = GetPointLocal( pGeomDB, ptDir.v, nRefType, frLoc) ; + // ne ricavo un riferimento intrinseco + Frame3d frBox ; + bOk = bOk && frBox.Set( ptIniL, ptDirL, ptCrossL) ; + // creo il box nel suo riferimento intrinseco + PtrOwner pSTM( GetSurfTriMeshBox( dWidth, dLen, dHeight)) ; + bOk = bOk && ! IsNull( pSTM) ; + // porto il box nel riferimento locale + bOk = bOk && pSTM->ToGlob( frBox) ; + // inserisco la superficie nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmBBox(" + ToString( nParentId) + ",{{" + + ToString( b3Box.GetMin()) + "},{" + + ToString( b3Box.GetMax()) + "}}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nNewId ; +} + //------------------------------------------------------------------------------- int __stdcall EgtCreateSurfTmBox( int nParentId, const double ptIni[3], const double ptCross[3], @@ -36,12 +97,10 @@ __stdcall EgtCreateSurfTmBox( int nParentId, const double ptIni[3], const double { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) - return GDB_ID_NULL ; - // porto in locale i punti, i versori e il versore estrusione + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // porto in locale i punti Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ; Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ; @@ -91,7 +150,7 @@ __stdcall EgtCreateSurfTmPyramid( int nParentId, const double ptIni[3], const do Frame3d frLoc ; if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) return GDB_ID_NULL ; - // porto in locale i punti, i versori e il versore estrusione + // porto in locale i punti Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; Point3d ptCrossL = GetPointLocal( pGeomDB, ptCross, nRefType, frLoc) ; Point3d ptDirL = GetPointLocal( pGeomDB, ptDir, nRefType, frLoc) ; @@ -690,7 +749,7 @@ EgtCreateSurfTmByTriangles( int nParentId, const INTVECTOR& vIds, bool bErase) string sLua = "EgtSurfTmByTriangles(" + ToString( nParentId) + ",{" + sIds + "}," + ( bErase ? "true" : "false") + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco il risultato @@ -774,7 +833,7 @@ EgtCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) string sLua = "EgtSurfTmBySewing(" + ToString( nParentId) + ",{" + sIds + "}," + ( bErase ? "true" : "false") + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco il risultato diff --git a/API_GdbModify.cpp b/API_GdbModify.cpp index 4c17fed..180604c 100644 --- a/API_GdbModify.cpp +++ b/API_GdbModify.cpp @@ -68,11 +68,11 @@ EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType) EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtChangeGroupFrame(" + ToString( nId) + ",{" + + string sLua = "EgtChangeGroupFrame(" + ToString( nId) + ",{{" + ToString( frNewRef.Orig()) + "},{" + ToString( frNewRef.VersX()) + "},{" + ToString( frNewRef.VersY()) + "},{" + - ToString( frNewRef.VersZ()) + "}," + + ToString( frNewRef.VersZ()) + "}}," + RefTypeToString( nRefType) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; @@ -182,81 +182,94 @@ __stdcall EgtMirrorText( int nId, BOOL bOnL) } //------------------------------------------------------------------------------- -BOOL -__stdcall EgtExplodeText( int nId) +int +__stdcall EgtExplodeText( int nId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTXT == nullptr) - bOk = false ; + bool bOk = ( pTXT != nullptr) ; // recupero l'outline del testo ICURVEPLIST lstPCRV ; bOk = bOk && pTXT->GetOutline( lstPCRV) ; // inserisco le curve nella stessa posizione del testo - ICURVEPLIST::iterator iIter ; - for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + for ( ICURVEPLIST::iterator iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { // inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, (*iIter)) ; - if ( nCrvId == GDB_ID_NULL) - bOk = false ; + bOk = bOk && ( nCrvId != GDB_ID_NULL) ; // copio gli attributi - if ( ! pGeomDB->CopyAttributes( nId, nCrvId)) - bOk = false ; + bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; + // aggiorno contatori + if ( bOk) { + if ( nFirstId == GDB_ID_NULL) + nFirstId = nCrvId ; + ++ nCount ; + } } + nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; // elimino il testo originale bOk = bOk && pGeomDB->Erase( nId) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtExplodeText(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; + return nFirstId ; } //------------------------------------------------------------------------------- -BOOL -__stdcall EgtSplitText( int nId) +int +__stdcall EgtSplitText( int nId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il testo IExtText* pTXT = GetExtText( pGeomDB->GetGeoObj( nId)) ; - if ( pTXT == nullptr) - bOk = false ; + bool bOk = ( pTXT != nullptr) ; // recupero l'esplosione del testo in linee singole IEXTTEXTPVECTOR vTxt ; bOk = bOk && pTXT->SplitOnLineBreak( vTxt) ; // inserisco i nuovi testi nella stessa posizione del testo - for ( int i = 0 ; bOk && i < int( vTxt.size()) ; ++ i) { + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + for ( int i = 0 ; i < int( vTxt.size()) ; ++ i) { // inserimento - int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, vTxt[i]) ; - // se errore - if ( nCrvId == GDB_ID_NULL) { - delete vTxt[i] ; - bOk = false ; + int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, vTxt[i]) : GDB_ID_NULL) ; + if ( nCrvId != GDB_ID_NULL) { + // copio gli attributi + bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; + // aggiorno contatori + if ( bOk) { + if ( nFirstId == GDB_ID_NULL) + nFirstId = nCrvId ; + ++ nCount ; + } } - // altrimenti copio gli attributi else { - if ( ! pGeomDB->CopyAttributes( nId, nCrvId)) - bOk = false ; + bOk = false ; + delete vTxt[i] ; } } + nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; // elimino il testo originale bOk = bOk && pGeomDB->Erase( nId) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSplitText(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; + return nFirstId ; } diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index 5d88e58..b4f14df 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -530,11 +530,11 @@ __stdcall EgtTrimExtendCurveByLen( int nId, double dLen, const double ptNear[3], } //---------------------------------------------------------------------------- -BOOL +int __stdcall EgtSplitCurve( int nId, int nParts) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero la curva ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pCurve != nullptr) ; @@ -546,33 +546,42 @@ __stdcall EgtSplitCurve( int nId, int nParts) // lunghezza di una parte double dLen = dLenTot / nParts ; // eseguo la divisione + int nFirstId = GDB_ID_NULL ; + int nCurrId = nId ; for ( int i = 1; i < nParts ; ++ i) { // copio la curva - int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_BEFORE) ; + int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ; 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) ; + // tengo la prima parte dell'originale e la seconda parte della copia + bOk = bOk && pCurve->TrimEndAtLen( dLen) ; + bOk = bOk && pCopyCrv->TrimStartAtLen( dLen) ; + // la copia diventa il nuovo corrente + nCurrId = nCopyId ; + pCurve = pCopyCrv ; + // salvo identificativo prima copia + if ( nFirstId == GDB_ID_NULL) + nFirstId = nCopyId ; } + nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSplitCurve(" + ToString( nId) + "," + ToString( nParts) + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id1=" + ToString( nFirstId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return nFirstId ; } //---------------------------------------------------------------------------- -BOOL +int __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero la curva ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; bool bOk = ( pCurve != nullptr) ; @@ -603,26 +612,28 @@ __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType) } } // se il punto di taglio è interno, devo realmente tagliare + int nNewId = GDB_ID_NULL ; if ( bIsInside) { // copio la curva - int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ; - ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ; + nNewId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ; + ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nNewId)) ; bOk = bOk && ( pCopyCrv != nullptr) ; // tengo la prima parte dell'originale e la seconda parte della copia bOk = bOk && pCurve->TrimEndAtParam( dU) ; bOk = bOk && pCopyCrv->TrimStartAtParam( dU) ; } + nNewId = ( bOk ? nNewId : GDB_ID_NULL) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSplitCurveAtPoint(" + ToString( nId) + ",{" + ToString( Point3d( ptOn)) + "}," + RefTypeToString( nRefType) + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return nNewId ; } //------------------------------------------------------------------------------- @@ -738,46 +749,55 @@ __stdcall EgtModifyCurveArc3P( int nId, const double ptMid[3], int nRefType) } //------------------------------------------------------------------------------- -BOOL -__stdcall EgtExplodeCurveCompo( int nId) +int +__stdcall EgtExplodeCurveCompo( int nId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; // recupero la curva composita ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ; if ( pCompo == nullptr) bOk = false ; // estraggo tutte le curve + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; ICurve* pCrv ; while ( bOk && ( pCrv = pCompo->RemoveFirstOrLastCurve( false)) != nullptr) { // inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pCrv) ; - if ( nCrvId == GDB_ID_NULL) - bOk = false ; + bOk = bOk && ( nCrvId != GDB_ID_NULL) ; // copio gli attributi - if ( ! pGeomDB->CopyAttributes( nId, nCrvId)) - bOk = false ; + bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; + // aggiorno contatori + if ( bOk) { + if ( nFirstId == GDB_ID_NULL) + nFirstId = nCrvId ; + ++ nCount ; + } } + nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ; // elimino la curva composita ormai vuota bOk = bOk && pGeomDB->Erase( nId) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtExplodeCurveCompo(" + ToString( nId) + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; + return nFirstId ; } //------------------------------------------------------------------------------- -BOOL +int __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; // recupero la curva di Bezier ICurveBezier* pCBezier = GetCurveBezier( pGeomDB->GetGeoObj( nId)) ; @@ -802,13 +822,11 @@ __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) } else bOk = false ; - // inserisco la curva composita nello spesso posto del GeomDB - int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) ; - if ( nCrvId == GDB_ID_NULL) - bOk = false ; + // inserisco la curva composita nello stesso posto del GeomDB + int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) : GDB_ID_NULL) ; + bOk = bOk && ( nCrvId != GDB_ID_NULL) ; // copio gli attributi - if ( ! pGeomDB->CopyAttributes( nId, nCrvId)) - bOk = false ; + bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ; // elimino la curva di Bezier bOk = bOk && pGeomDB->Erase( nId) ; EgtSetModified() ; @@ -817,9 +835,9 @@ __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) string sLua = "EgtExplodeCurveBezier(" + ToString( nId) + ",'" + ( bArcsVsLines ? "ARCS" : "LINES") + "'," + ToString( dLinTol) + ")" + - " -- Ok=" + ToString( bOk) ; + " -- Id=" + ToString( nCrvId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return nCrvId ; } \ No newline at end of file diff --git a/API_GdbModifySurf.cpp b/API_GdbModifySurf.cpp index 54ca937..dd4f5c8 100644 --- a/API_GdbModifySurf.cpp +++ b/API_GdbModifySurf.cpp @@ -71,7 +71,7 @@ EgtInvertSurface( const INTVECTOR& vIds) //---------------------------------------------------------------------------- int -__stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId) +__stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -89,6 +89,7 @@ __stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId) bOk = bOk && pStm->GetFacetLoops( nFacet, vPL) ; // dalle polilinee creo le curve e le inserisco nel DB int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; for ( size_t i = 0 ; i < vPL.size() ; ++ i) { // creo la curva PtrOwner pCrvCompo( CreateCurveComposite()) ; @@ -100,6 +101,8 @@ __stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId) bOk = bOk && ( nNewId != GDB_ID_NULL) ; if ( bOk && nFirstId == GDB_ID_NULL) nFirstId = nNewId ; + if ( bOk) + ++ nCount ; } EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente @@ -107,9 +110,11 @@ __stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId) string sLua = "EgtExtractSurfTmFacetLoops(" + ToString( nId) + ",{" + ToString( nFacet) + "," + ToString( nDestGrpId) + ")" + - " -- Id=" + ToString( nFirstId) ; + " -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco risultati + if ( pnCount != nullptr) + *pnCount = nCount ; return nFirstId ; } diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index b76275a..30443a5 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -158,12 +158,8 @@ EgtGetFirstNameInGroup( int nGroupId, const string& sName) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il primo oggetto nel gruppo - int nFirstId = pGeomDB->GetFirstInGroup( nGroupId) ; - string sObjName ; - if ( pGeomDB->GetName( nFirstId, sObjName) && sObjName == sName) - return nFirstId ; - return EgtGetNextName( nFirstId, sName) ; + // recupero il primo oggetto con il nome desiderato nel gruppo + return pGeomDB->GetFirstNameInGroup( nGroupId, sName) ; } //----------------------------------------------------------------------------- @@ -173,53 +169,118 @@ EgtGetNextName( int nId, const string& sName) IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il prossimo oggetto nello stesso gruppo con il nome voluto - int nNextId = nId ; - while ( ( nNextId = pGeomDB->GetNext( nNextId)) != GDB_ID_NULL) { - string sObjName ; - if ( pGeomDB->GetName( nNextId, sObjName) && sObjName == sName) - return nNextId ; - } - return GDB_ID_NULL ; + return pGeomDB->GetNextName( nId, sName) ; +} + +//----------------------------------------------------------------------------- +int +EgtGetLastNameInGroup( int nGroupId, const string& sName) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero l'ultimo oggetto con il nome desiderato nel gruppo + return pGeomDB->GetLastNameInGroup( nGroupId, sName) ; +} + +//----------------------------------------------------------------------------- +int +EgtGetPrevName( int nId, const string& sName) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il precedente oggetto nello stesso gruppo con il nome voluto + return pGeomDB->GetPrevName( nId, sName) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtGetBBox( int nId, int nFlag, double ptMin[3], double ptMax[3]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il bounding box locale dell'oggetto - BBox3d b3Loc ; - if ( ! pGeomDB->GetLocalBBox( nId, b3Loc, nFlag)) + // recupero il bounding box dell'oggetto in locale + BBox3d b3Box ; + if ( ! EgtGetBBox( nId, nFlag, b3Box)) return FALSE ; - ptMin[0] = b3Loc.GetMin().x ; - ptMin[1] = b3Loc.GetMin().y ; - ptMin[2] = b3Loc.GetMin().z ; - ptMax[0] = b3Loc.GetMax().x ; - ptMax[1] = b3Loc.GetMax().y ; - ptMax[2] = b3Loc.GetMax().z ; + ptMin[0] = b3Box.GetMin().x ; + ptMin[1] = b3Box.GetMin().y ; + ptMin[2] = b3Box.GetMin().z ; + ptMax[0] = b3Box.GetMax().x ; + ptMax[1] = b3Box.GetMax().y ; + ptMax[2] = b3Box.GetMax().z ; return TRUE ; } +//----------------------------------------------------------------------------- +bool +EgtGetBBox( int nId, int nFlag, BBox3d& b3Box) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il bounding box dell'oggetto in locale + return pGeomDB->GetLocalBBox( nId, b3Box, nFlag) ; +} + //----------------------------------------------------------------------------- BOOL __stdcall EgtGetBBoxGlob( int nId, int nFlag, double ptMin[3], double ptMax[3]) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il bounding box globale dell'oggetto - BBox3d b3Loc ; - if ( ! pGeomDB->GetGlobalBBox( nId, b3Loc, nFlag)) + // recupero il bounding box dell'oggetto in globale + BBox3d b3Box ; + if ( ! EgtGetBBoxGlob( nId, nFlag, b3Box)) return FALSE ; - ptMin[0] = b3Loc.GetMin().x ; - ptMin[1] = b3Loc.GetMin().y ; - ptMin[2] = b3Loc.GetMin().z ; - ptMax[0] = b3Loc.GetMax().x ; - ptMax[1] = b3Loc.GetMax().y ; - ptMax[2] = b3Loc.GetMax().z ; + // converto il risultato + ptMin[0] = b3Box.GetMin().x ; + ptMin[1] = b3Box.GetMin().y ; + ptMin[2] = b3Box.GetMin().z ; + ptMax[0] = b3Box.GetMax().x ; + ptMax[1] = b3Box.GetMax().y ; + ptMax[2] = b3Box.GetMax().z ; return TRUE ; } +//----------------------------------------------------------------------------- +bool +EgtGetBBoxGlob( int nId, int nFlag, BBox3d& b3Box) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il bounding box dell'oggetto in globale + return pGeomDB->GetGlobalBBox( nId, b3Box, nFlag) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetBBoxRef( int nId, int nFlag, const double ptOrig[3], + const double vtX[3], const double vtY[3], const double vtZ[3], + double ptMin[3], double ptMax[3]) +{ + // calcolo il riferimento + Frame3d frRef ; + if ( ! frRef.Set( ptOrig, vtX, vtY, vtZ)) + return FALSE ; + // recupero il bounding box dell'oggetto nel riferimento + BBox3d b3Box ; + if ( ! EgtGetBBoxRef( nId, nFlag, frRef, b3Box)) + return FALSE ; + // converto il risultato + ptMin[0] = b3Box.GetMin().x ; + ptMin[1] = b3Box.GetMin().y ; + ptMin[2] = b3Box.GetMin().z ; + ptMax[0] = b3Box.GetMax().x ; + ptMax[1] = b3Box.GetMax().y ; + ptMax[2] = b3Box.GetMax().z ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +bool +EgtGetBBoxRef( int nId, int nFlag, const Frame3d& frRef, BBox3d& b3Box) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il bounding box dell'oggetto nel riferimento + return pGeomDB->GetRefBBox( nId, frRef, b3Box, nFlag) ; +} + //----------------------------------------------------------------------------- int __stdcall EgtCopy( int nSouId, int nRefId, int nSonBeforeAfter) diff --git a/API_GeoBase.cpp b/API_GeoBase.cpp index 7e31472..dd508ed 100644 --- a/API_GeoBase.cpp +++ b/API_GeoBase.cpp @@ -474,4 +474,71 @@ __stdcall EgtFrameLocToLoc( double ptOrig[3], double vtX[3], double vtY[3], doub VEC_FROM_3D( vtY, frTemp.VersY()) VEC_FROM_3D( vtZ, frTemp.VersZ()) return TRUE ; -} \ No newline at end of file +} + +//----------------------------------------------------------------------------- +// BBox3d +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtBBoxToGlob( double ptMin[3], double ptMax[3], + const double ptO1[3], const double vtX1[3], const double vtY1[3], const double vtZ1[3]) +{ + // costruisco il frame di trasformazione + Frame3d frRef ; + if ( ! frRef.Set( ptO1, vtX1, vtY1, vtZ1)) + return FALSE ; + // eseguo la trasformazione + BBox3d b3Temp ; + b3Temp.Set( ptMin, ptMax) ; + if ( ! b3Temp.ToGlob( frRef)) + return FALSE ; + // aggiorno i parametri del box + VEC_FROM_3D( ptMin, b3Temp.GetMin()) + VEC_FROM_3D( ptMax, b3Temp.GetMax()) + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtBBoxToLoc( double ptMin[3], double ptMax[3], + const double ptO1[3], const double vtX1[3], const double vtY1[3], const double vtZ1[3]) +{ + // costruisco il frame di trasformazione + Frame3d frRef ; + if ( ! frRef.Set( ptO1, vtX1, vtY1, vtZ1)) + return FALSE ; + // eseguo la trasformazione + BBox3d b3Temp ; + b3Temp.Set( ptMin, ptMax) ; + if ( ! b3Temp.ToLoc( frRef)) + return FALSE ; + // aggiorno i parametri del box + VEC_FROM_3D( ptMin, b3Temp.GetMin()) + VEC_FROM_3D( ptMax, b3Temp.GetMax()) + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtBBoxLocToLoc( double ptMin[3], double ptMax[3], + const double ptO1[3], const double vtX1[3], const double vtY1[3], const double vtZ1[3], + const double ptO2[3], const double vtX2[3], const double vtY2[3], const double vtZ2[3]) +{ + // costruisco il frame sorgente + Frame3d frSou ; + if ( ! frSou.Set( ptO1, vtX1, vtY1, vtZ1)) + return FALSE ; + // costruisco il frame destinazione + Frame3d frDest ; + if ( ! frDest.Set( ptO2, vtX2, vtY2, vtZ2)) + return FALSE ; + // eseguo la trasformazione + BBox3d b3Temp ; + b3Temp.Set( ptMin, ptMax) ; + if ( ! b3Temp.LocToLoc( frSou, frDest)) + return FALSE ; + // aggiorno i parametri del box + VEC_FROM_3D( ptMin, b3Temp.GetMin()) + VEC_FROM_3D( ptMax, b3Temp.GetMax()) + return TRUE ; +} diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 42e5e29..21df71c 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -396,8 +396,14 @@ EgtSaveFile( const string& sFilePath, int nFlag) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) + // se ero in CAM, esco + int nCurrMachGroup = EgtGetCurrMachGroup() ; + EgtResetCurrMachGroup() ; // salvo il file bool bOk = pGseCtx->m_pGeomDB->Save( sFilePath, nFlag) ; + // eventuale ripristino precedente CAM + if ( nCurrMachGroup != GDB_ID_NULL) + EgtSetCurrMachGroup( nCurrMachGroup) ; // aggiorno stato file corrente pGseCtx->m_sFilePath = sFilePath ; if ( bOk) diff --git a/API_MachMgr.cpp b/API_MachMgr.cpp index 77cddab..aeeb3b8 100644 --- a/API_MachMgr.cpp +++ b/API_MachMgr.cpp @@ -15,8 +15,10 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "AuxTools.h" #include "DllMachKernel.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -45,7 +47,7 @@ bool EgtUpdateMachMgr( void) { IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, FALSE) + VERIFY_MACHMGR( pMachMgr, false) // aggiornamento gestore lavorazioni return pMachMgr->Update() ; } @@ -55,7 +57,7 @@ bool EgtInsertMachMgr( int nInsGrp) { IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, 0) + VERIFY_MACHMGR( pMachMgr, false) // sposto le macchinate dal gruppo di inserimento alla base macchinate return pMachMgr->Insert( nInsGrp) ; } @@ -70,6 +72,26 @@ __stdcall EgtGetMachGroupNbr( void) return pMachMgr->GetMachGroupNbr() ; } +//----------------------------------------------------------------------------- +int +__stdcall EgtGetFirstMachGroup( void) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) + // recupero la prima macchinata + return pMachMgr->GetFirstMachGroup() ; +} + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetNextMachGroup( int nId) +{ + IMachMgr* pMachMgr = GetCurrMachMgr() ; + VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) + // recupero la successiva macchinata + return pMachMgr->GetNextMachGroup( nId) ; +} + //----------------------------------------------------------------------------- int __stdcall EgtAddMachGroup( const wchar_t* wsName, const wchar_t* wsMachineName) @@ -81,20 +103,39 @@ __stdcall EgtAddMachGroup( const wchar_t* wsName, const wchar_t* wsMachineName) int EgtAddMachGroup( const string& sName, const string& sMachineName) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, 0) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) // aggiungo la macchinata (gruppo di lavorazione) - return pMachMgr->AddMachGroup( sName, sMachineName) ; + int nId = pGseCtx->m_pMachMgr->AddMachGroup( sName, sMachineName) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAddMachGroup('" + sName + "','" + + sMachineName + "')" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nId ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtRemoveMachGroup( int nMGroupInd) +__stdcall EgtRemoveMachGroup( int nMGroupId) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, FALSE) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) // rimuovo la macchinata (gruppo di lavorazione) - return ( pMachMgr->RemoveMachGroup( nMGroupInd) ? TRUE : FALSE) ; + bool bOk = pGseCtx->m_pMachMgr->RemoveMachGroup( nMGroupId) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRemoveMachGroup(" + ToString( nMGroupId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -112,67 +153,324 @@ __stdcall EgtGetMachGroupName( int nMGroupInd, wchar_t*& wsName) //----------------------------------------------------------------------------- bool -EgtGetMachGroupName( int nMGroupInd, string& sName) +EgtGetMachGroupName( int nId, string& sName) { IMachMgr* pMachMgr = GetCurrMachMgr() ; VERIFY_MACHMGR( pMachMgr, false) // recupero il nome della macchinata - return pMachMgr->GetMachGroupName( nMGroupInd, sName) ; + sName = pMachMgr->GetMachGroupName( nId) ; + return ( ! sName.empty()) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtGetMachGroupInd( const wchar_t* wsName, int* pnInd) +__stdcall EgtGetMachGroupId( const wchar_t* wsName) { - return ( EgtGetMachGroupInd( wstrztoA( wsName), *pnInd) ? TRUE : FALSE) ; + return EgtGetMachGroupId( wstrztoA( wsName)) ; } //----------------------------------------------------------------------------- -bool -EgtGetMachGroupInd( const string& sName, int& nInd) +int +EgtGetMachGroupId( const string& sName) { IMachMgr* pMachMgr = GetCurrMachMgr() ; VERIFY_MACHMGR( pMachMgr, false) // recupero l'indice della macchinata - return pMachMgr->GetMachGroupInd( sName, nInd) ; + return pMachMgr->GetMachGroupId( sName) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetCurrMachGroup( int nMGroupInd) +__stdcall EgtSetCurrMachGroup( int nMGroupId) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, FALSE) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, FALSE) // imposto la macchinata corrente - return ( pMachMgr->SetCurrMachGroup( nMGroupInd) ? TRUE : FALSE) ; + bool bOk = pGseCtx->m_pMachMgr->SetCurrMachGroup( nMGroupId) ; + // non cambia lo stato di modificato del progetto + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSetCurrMachGroup(" + ToString( nMGroupId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetCurrMachGroup( void) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, FALSE) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, FALSE) // reset macchinata corrente - return ( pMachMgr->ResetCurrMachGroup() ? TRUE : FALSE) ; + bool bOk = pGseCtx->m_pMachMgr->ResetCurrMachGroup() ; + // non cambia lo stato di modificato del progetto + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtResetCurrMachGroup()" + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return ( bOk ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- -BOOL -__stdcall EgtGetCurrMachGroup( int* pnInd) +int +__stdcall EgtGetCurrMachGroup( void) { IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, FALSE) - // reset macchinata corrente - return ( pMachMgr->GetCurrMachGroup( *pnInd) ? TRUE : FALSE) ; + VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL) + // restituisco identificativo macchinata corrente + return pMachMgr->GetCurrMachGroup() ; } //----------------------------------------------------------------------------- int EgtAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol) { - IMachMgr* pMachMgr = GetCurrMachMgr() ; - VERIFY_MACHMGR( pMachMgr, false) + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) // inserisco grezzo nella macchinata corrente - return pMachMgr->AddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ; + int nId = pGseCtx->m_pMachMgr->AddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAddRawPart({" + ToString( ptOrig) + "}," + + ToString( dWidth) + "," + + ToString( dLength) + "," + + ToString( dHeight) + ",{" + + ToString( cCol) + "})" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nId ; +} + +//----------------------------------------------------------------------------- +int +EgtAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL) + // inserisco grezzo con pezzo nella macchinata corrente + int nId = pGseCtx->m_pMachMgr->AddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAddRawPartWithPart(" + ToString( nPartId) + "," + + ToString( nCrvId) + "," + + ToString( dOverMat) + ",{" + + ToString( cCol) + "})" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nId ; +} + +//----------------------------------------------------------------------------- +bool +EgtAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // inserisco pezzo in un grezzo della macchinata corrente + bool bOk = pGseCtx->m_pMachMgr->AddPartToRawPart( nPartId, ptPos, nRawId) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAddPartToRawPart(" + ToString( nPartId) + ",{" + + ToString( ptPos) + "}," + + ToString( nRawId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtModifyRawPartHeight( int nRawId, double dHeight) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // modifico lo spessore del grezzo + bool bOk = pGseCtx->m_pMachMgr->ModifyRawPartHeight( nRawId, dHeight) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtModifyRawPartHeight(" + ToString( nRawId) + "," + + ToString( dHeight) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtRemoveRawPart( int nRawId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // elimino grezzo dalla macchinata corrente + bool bOk = pGseCtx->m_pMachMgr->RemoveRawPart( nRawId) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRemoveRawPart(" + ToString( nRawId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtTranslateRawPart( int nRawId, const Vector3d& vtMove) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // traslo il grezzo + bool bOk = pGseCtx->m_pMachMgr->TranslateRawPart( nRawId, vtMove) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtMoveRawPart(" + ToString( nRawId) + ",{" + + ToString( vtMove) + "})" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtRotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // ruoto il grezzo + bool bOk = pGseCtx->m_pMachMgr->RotateRawPart( nRawId, vtAx, dAngRotDeg) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRotateRawPart(" + ToString( nRawId) + ",{" + + ToString( vtAx) + "}," + + ToString( dAngRotDeg) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtMoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // mando il grezzo nel corner + bool bOk = pGseCtx->m_pMachMgr->MoveToCornerRawPart( nRawId, ptCorner, nFlag) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtMoveToCornerRawPart(" + ToString( nRawId) + ",{" + + ToString( ptCorner) + "}," + + RawPartCornerPosToString( nFlag) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // mando il grezzo nel corner + bool bOk = pGseCtx->m_pMachMgr->MoveToCenterRawPart( nRawId, ptCenter, nFlag) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtMoveToCenterRawPart(" + ToString( nRawId) + ",{" + + ToString( ptCenter) + "}," + + RawPartCenterPosToString( nFlag) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtRemovePartFromRawPart( int nPartId) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // elimino pezzo da grezzo della macchinata corrente + bool bOk = pGseCtx->m_pMachMgr->RemovePartFromRawPart( nPartId) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRemovePartFromRawPart(" + ToString( nPartId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtTranslatePartInRawPart( int nPartId, const Vector3d& vtMove) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // traslo il pezzo nel grezzo + bool bOk = pGseCtx->m_pMachMgr->TranslatePartInRawPart( nPartId, vtMove) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtMovePartInRawPart(" + ToString( nPartId) + ",{" + + ToString( vtMove) + "})" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + +//----------------------------------------------------------------------------- +bool +EgtRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // ruoto il pezzo nel grezzo + bool bOk = pGseCtx->m_pMachMgr->RotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRotatePartInRawPart(" + ToString( nPartId) + ",{" + + ToString( vtAx) + "}," + + ToString( dAngRotDeg) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; } diff --git a/AuxTools.cpp b/AuxTools.cpp index c2abb2c..b68eb94 100644 --- a/AuxTools.cpp +++ b/AuxTools.cpp @@ -13,12 +13,26 @@ #include "stdafx.h" #include "AuxTools.h" -#include "/EgtDev/Include/EgkExtText.h" +#include "/EgtDev/Include/EGkExtText.h" +#include "/EgtDev/Include/EMkMachMgr.h" #include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EGnStringUtils.h" using namespace std ; +//---------------------------------------------------------------------------- +const string +IdListToString( const INTVECTOR& vIds) +{ + string sIds ; + sIds.reserve( 6 * vIds.size()) ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + if ( ! sIds.empty()) + sIds.pop_back() ; + return sIds ; +} + //---------------------------------------------------------------------------- const char* NgeTypeToString( int nNgeType) @@ -196,3 +210,68 @@ ETxtInsPosToString( const string& sETxtInsPos) // default return ETXT_IPBL ; } + +//---------------------------------------------------------------------------- +const char* +RawPartCornerPosToString( int nFlag) +{ + switch ( nFlag) { + case RPCR_TL : return "'TL'" ; + case RPCR_TR : return "'TR'" ; + default : + case RPCR_BL : return "'BL'" ; + case RPCR_BR : return "'BR'" ; + } +} + +//---------------------------------------------------------------------------- +int +StringToRawPartCornerPos( const string& sFlag) +{ + string sTemp = sFlag ; + ToUpper( sTemp) ; + if ( sTemp == "TL") + return RPCR_TL ; + else if ( sTemp == "TR") + return RPCR_TR ; + else if ( sTemp == "BL") + return RPCR_BL ; + else if ( sTemp == "BR") + return RPCR_BR ; + // default + return RPCR_BL ; +} + +//---------------------------------------------------------------------------- +const char* +RawPartCenterPosToString( int nFlag) +{ + switch ( nFlag) { + case RPCE_TC : return "'TC'" ; + default : + case RPCE_ML : return "'ML'" ; + case RPCE_MR : return "'MR'" ; + case RPCE_BC : return "'BC'" ; + case RPCE_MC : return "'MC'" ; + } +} + +//---------------------------------------------------------------------------- +int +StringToRawPartCenterPos( const string& sFlag) +{ + string sTemp = sFlag ; + ToUpper( sTemp) ; + if ( sTemp == "TC") + return RPCE_TC ; + else if ( sTemp == "ML") + return RPCE_ML ; + else if ( sTemp == "MR") + return RPCE_MR ; + else if ( sTemp == "BC") + return RPCE_BC ; + else if ( sTemp == "MC") + return RPCE_MC ; + // default + return RPCE_ML ; +} diff --git a/AuxTools.h b/AuxTools.h index ec803b9..b54ba2f 100644 --- a/AuxTools.h +++ b/AuxTools.h @@ -11,12 +11,14 @@ // //---------------------------------------------------------------------------- -#include #include "/EgtDev/Include/EgtNumCollection.h" +#include class IGeomDB ; //---------------------------------------------------------------------------- +// Lista di Id completa (parametro per lua) +const std::string IdListToString( const INTVECTOR& vIds) ; // Tipo del file Nge const char* NgeTypeToString( int nNgeType) ; int StringToNgeType( const std::string& sNgeType) ; @@ -34,4 +36,9 @@ int StringToRefId( const std::string& sRefId) ; // Posizione inserimento testo const char* ETxtInsPosToString( int nETxtInsPos) ; int ETxtInsPosToString( const std::string& sETxtInsPos) ; - +// Flag per posizione corner rispetto a grezzo +const char* RawPartCornerPosToString( int nFlag) ; +int StringToRawPartCornerPos( const std::string& sFlag) ; +// Flag per posizione center rispetto a grezzo +const char* RawPartCenterPosToString( int nFlag) ; +int StringToRawPartCenterPos( const std::string& sFlag) ; diff --git a/EgtInterface.rc b/EgtInterface.rc index 234ab4878c741fa689f61890b5dac91397db9b5c..2101d35b2ca6f4c6e33c11f2f2e0b211d138f84d 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/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index 54273ab..45fb779 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -607,13 +607,15 @@ LuaCreateCurveCompoByChain( lua_State* L) LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; // creo la curva composita - int nId = EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType) ; + int nCount = 0 ; + int nId = EgtCreateCurveCompoByChain( nParentId, vIds, ptNear, bErase, nRefType, &nCount) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; - return 1 ; + LuaSetReturn( L, nCount) ; + return 2 ; } //------------------------------------------------------------------------------- diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 5d22f86..05e16f6 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -27,6 +27,28 @@ using namespace std ; //------------------------------------------------------------------------------- static const double LIN_TOL_DEF = 0.05 ; +//------------------------------------------------------------------------------- +static int +LuaCreateSurfTmBBox( lua_State* L) +{ + // 2 o 3 parametri : ParentId, BBox3d [, sRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + BBox3d b3Box ; + LuaCheckParam( L, 2, b3Box) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 3, nRefType) ; + LuaClearStack( L) ; + // creo STM bounding box + int nId = EgtCreateSurfTmBBox( nParentId, b3Box, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateSurfTmBox( lua_State* L) @@ -45,7 +67,7 @@ LuaCreateSurfTmBox( lua_State* L) int nRefType = RTY_DEFAULT ; LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; - // creo STM cilindro + // creo STM parallelepipedo int nId = EgtCreateSurfTmBox( nParentId, ptIni.v, ptCross.v, ptDir.v, dHeight, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) @@ -420,6 +442,7 @@ bool LuaInstallGdbCreateSurf( void) { bool bOk = true ; + bOk = bOk && LuaRegisterFunction( "EgtSurfTmBBox", LuaCreateSurfTmBBox) ; bOk = bOk && LuaRegisterFunction( "EgtSurfTmBox", LuaCreateSurfTmBox) ; bOk = bOk && LuaRegisterFunction( "EgtSurfTmPyramid", LuaCreateSurfTmPyramid) ; bOk = bOk && LuaRegisterFunction( "EgtSurfTmCylinder", LuaCreateSurfTmCylinder) ; diff --git a/LUA_GdbModify.cpp b/LUA_GdbModify.cpp index d92ae9e..dc13df0 100644 --- a/LUA_GdbModify.cpp +++ b/LUA_GdbModify.cpp @@ -135,10 +135,15 @@ LuaExplodeText( lua_State* L) int nId ; LuaCheckParam( L, 1, nId) LuaClearStack( L) ; - // esplosione del testo - bool bOk = ( EgtExplodeText( nId) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; + // esplosione del testo in contorni + int nCount ; + int nFirstId = EgtExplodeText( nId, &nCount) ; + if ( nFirstId != GDB_ID_NULL) + LuaSetReturn( L, nFirstId) ; + else + LuaSetReturn( L) ; + LuaSetReturn( L, nCount) ; + return 2 ; } //------------------------------------------------------------------------------- @@ -150,9 +155,14 @@ LuaSplitText( lua_State* L) LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // esplosione del testo in più testi, uno per riga - bool bOk = ( EgtSplitText( nId) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; + int nCount ; + int nFirstId = EgtSplitText( nId, &nCount) ; + if ( nFirstId != GDB_ID_NULL) + LuaSetReturn( L, nFirstId) ; + else + LuaSetReturn( L) ; + LuaSetReturn( L, nCount) ; + return 2 ; } //------------------------------------------------------------------------------- diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 8d2f117..396a1f5 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -267,8 +267,11 @@ LuaSplitCurve( lua_State* L) LuaCheckParam( L, 2, nParts) LuaClearStack( L) ; // divido la curva nel punto - bool bOk = ( EgtSplitCurve( nId, nParts) != FALSE) ; - LuaSetReturn( L, bOk) ; + int nFirstId = EgtSplitCurve( nId, nParts) ; + if ( nFirstId != GDB_ID_NULL) + LuaSetReturn( L, nFirstId) ; + else + LuaSetReturn( L) ; return 1 ; } @@ -285,8 +288,11 @@ LuaSplitCurveAtPoint( lua_State* L) LuaGetRefType( L, 3, nRefType) ; LuaClearStack( L) ; // divido la curva nel punto - bool bOk = ( EgtSplitCurveAtPoint( nId, ptOn.v, nRefType) != FALSE) ; - LuaSetReturn( L, bOk) ; + int nNewId = EgtSplitCurveAtPoint( nId, ptOn.v, nRefType) ; + if ( nNewId != GDB_ID_NULL) + LuaSetReturn( L, nNewId) ; + else + LuaSetReturn( L) ; return 1 ; } @@ -315,9 +321,14 @@ LuaExplodeCurveCompo( lua_State* L) LuaCheckParam( L, 1, nId) LuaClearStack( L) ; // esplosione della curva composita - bool bOk = ( EgtExplodeCurveCompo( nId) != FALSE) ; - LuaSetReturn( L, bOk) ; - return 1 ; + int nCount ; + int nFirstId = EgtExplodeCurveCompo( nId, &nCount) ; + if ( nFirstId != GDB_ID_NULL) + LuaSetReturn( L, nFirstId) ; + else + LuaSetReturn( L) ; + LuaSetReturn( L, nCount) ; + return 2 ; } //------------------------------------------------------------------------------- @@ -338,8 +349,11 @@ LuaExplodeCurveBezier( lua_State* L) LuaCheckParam( L, 3, dLinTol) LuaClearStack( L) ; // esplosione della curva composita - bool bOk = ( EgtExplodeCurveBezier( nId, bArcsVsLines, dLinTol) != FALSE) ; - LuaSetReturn( L, bOk) ; + int nNewId = EgtExplodeCurveBezier( nId, bArcsVsLines, dLinTol) ; + if ( nNewId != GDB_ID_NULL) + LuaSetReturn( L, nNewId) ; + else + LuaSetReturn( L) ; return 1 ; } diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index 0d05a20..90a5af2 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -52,13 +52,15 @@ LuaExtractSurfTmFacetLoops( lua_State* L) LuaCheckParam( L, 3, nDestGrpId) LuaClearStack( L) ; // eseguo inversione superfici - int nNewId = EgtExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId) ; + int nCount ; + int nNewId = EgtExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, &nCount) ; // restituisco il risultato if ( nNewId != GDB_ID_NULL) LuaSetReturn( L, nNewId) ; else LuaSetReturn( L) ; - return 1 ; + LuaSetReturn( L, nCount) ; + return 2 ; } //------------------------------------------------------------------------------- diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 545bc09..2ad2679 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -136,7 +136,7 @@ LuaGetFirstNameInGroup( lua_State* L) string sName ; LuaCheckParam( L, 2, sName) LuaClearStack( L) ; - // recupero il primo oggetto del gruppo + // recupero il primo oggetto del gruppo con il nome desiderato int nId = EgtGetFirstNameInGroup( nGroupId, sName) ; // restituisco il risultato if ( nId != GDB_ID_NULL) @@ -156,7 +156,7 @@ LuaGetNextName( lua_State* L) string sName ; LuaCheckParam( L, 2, sName) LuaClearStack( L) ; - // recupero il prossimo oggetto nello stesso gruppo + // recupero il prossimo oggetto nello stesso gruppo con il nome desiderato int nNextId = EgtGetNextName( nId, sName) ; // restituisco il risultato if ( nNextId != GDB_ID_NULL) @@ -166,6 +166,111 @@ LuaGetNextName( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetLastNameInGroup( lua_State* L) +{ + // 2 parametri : GroupId, sName + int nGroupId ; + LuaCheckParam( L, 1, nGroupId) + string sName ; + LuaCheckParam( L, 2, sName) + LuaClearStack( L) ; + // recupero l'ultimo oggetto del gruppo con il nome desiderato + int nId = EgtGetLastNameInGroup( nGroupId, sName) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetPrevName( lua_State* L) +{ + // 2 parametri : Id, sName + int nId ; + LuaCheckParam( L, 1, nId) + string sName ; + LuaCheckParam( L, 2, sName) + LuaClearStack( L) ; + // recupero il precedente oggetto nello stesso gruppo con il nome desiderato + int nPrevId = EgtGetPrevName( nId, sName) ; + // restituisco il risultato + if ( nPrevId != GDB_ID_NULL) + LuaSetReturn( L, nPrevId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetBBox( lua_State* L) +{ + // 2 parametri : Id, nFlag + int nId ; + LuaCheckParam( L, 1, nId) + int nFlag ; + LuaCheckParam( L, 2, nFlag) + LuaClearStack( L) ; + // recupero il bounding box dell'oggetto in locale + BBox3d b3Box ; + bool bOk = EgtGetBBox( nId, nFlag, b3Box) ; + // restituisco il risultato + if ( bOk) + LuaSetReturn( L, b3Box) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetBBoxGlob( lua_State* L) +{ + // 2 parametri : Id, nFlag + int nId ; + LuaCheckParam( L, 1, nId) + int nFlag ; + LuaCheckParam( L, 2, nFlag) + LuaClearStack( L) ; + // recupero il bounding box dell'oggetto in globale + BBox3d b3Box ; + bool bOk = EgtGetBBoxGlob( nId, nFlag, b3Box) ; + // restituisco il risultato + if ( bOk) + LuaSetReturn( L, b3Box) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetBBoxRef( lua_State* L) +{ + // 3 parametri : Id, nFlag, Ref + int nId ; + LuaCheckParam( L, 1, nId) + int nFlag ; + LuaCheckParam( L, 2, nFlag) + Frame3d frRef ; + LuaCheckParam( L, 3, frRef) + LuaClearStack( L) ; + // recupero il bounding box dell'oggetto in globale + BBox3d b3Box ; + bool bOk = EgtGetBBoxRef( nId, nFlag, frRef, b3Box) ; + // restituisco il risultato + if ( bOk) + LuaSetReturn( L, b3Box) ; + else + LuaSetReturn( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCopy( lua_State* L) @@ -324,6 +429,11 @@ LuaInstallGdbObjects( void) bOk = bOk && LuaRegisterFunction( "EgtGetPrev", LuaGetPrev) ; bOk = bOk && LuaRegisterFunction( "EgtGetFirstNameInGroup", LuaGetFirstNameInGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetNextName", LuaGetNextName) ; + bOk = bOk && LuaRegisterFunction( "EgtGetLastNameInGroup", LuaGetLastNameInGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetPrevName", LuaGetPrevName) ; + bOk = bOk && LuaRegisterFunction( "EgtGetBBox", LuaGetBBox) ; + bOk = bOk && LuaRegisterFunction( "EgtGetBBoxGlob", LuaGetBBoxGlob) ; + bOk = bOk && LuaRegisterFunction( "EgtGetBBoxRef", LuaGetBBoxRef) ; bOk = bOk && LuaRegisterFunction( "EgtCopy", LuaCopy) ; bOk = bOk && LuaRegisterFunction( "EgtCopyGlob", LuaCopyGlob) ; bOk = bOk && LuaRegisterFunction( "EgtRelocate", LuaRelocate) ; diff --git a/LUA_General.cpp b/LUA_General.cpp index 82b8bdb..b4d39b0 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -18,6 +18,7 @@ #include "LUA_Base.h" #include "LUA_Aux.h" #include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnFileCompare.h" #include "/EgtDev/Include/EgtPerfCounter.h" @@ -171,6 +172,31 @@ LuaOutLog( lua_State* L) return 0 ; } +//------------------------------------------------------------------------------- +static int +LuaOutBox( lua_State* L) +{ + // 3 parametri : stringa, titolo, icona + string sOut ; + LuaCheckParam( L, 1, sOut) + string sTitle ; + LuaCheckParam( L, 2, sTitle) + string sIcon ; + LuaCheckParam( L, 3, sIcon) + int nIcon = MB_ICONINFORMATION ; + ToUpper( sIcon) ; + if ( sIcon == "ERROR") + nIcon = MB_ICONERROR ; + else if ( sIcon == "WARNING") + nIcon = MB_ICONWARNING ; + LuaClearStack( L) ; + // accodo il messaggio nel file di log + int nRes = MessageBox( nullptr, stringtoW( sOut), stringtoW( sTitle), MB_OKCANCEL | nIcon | MB_TASKMODAL) ; + // risultato (Ok->true, Cancel->false) + LuaSetReturn( L, ( nRes == IDOK)) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaEraseFile( lua_State* L) @@ -284,6 +310,7 @@ LuaInstallGeneral( void) bOk = bOk && LuaRegisterFunction( "EgtNumToString", LuaNumToString) ; bOk = bOk && LuaRegisterFunction( "EgtExecTsc", LuaExecTsc) ; bOk = bOk && LuaRegisterFunction( "EgtOutLog", LuaOutLog) ; + bOk = bOk && LuaRegisterFunction( "EgtOutBox", LuaOutBox) ; bOk = bOk && LuaRegisterFunction( "EgtEraseFile", LuaEraseFile) ; bOk = bOk && LuaRegisterFunction( "EgtEmptyDirectory", LuaEmptyDirectory) ; bOk = bOk && LuaRegisterFunction( "EgtTextFileCompare", LuaTextFileCompare) ; diff --git a/LUA_GeoBase.cpp b/LUA_GeoBase.cpp index 1f36915..d590f8e 100644 --- a/LUA_GeoBase.cpp +++ b/LUA_GeoBase.cpp @@ -351,6 +351,74 @@ LuaFrameLocToLoc( lua_State* L) } } +//------------------------------------------------------------------------------- +static int +LuaBBoxToGlob( lua_State* L) +{ + // 2 parametri : bbox, frame di trasformazione + BBox3d b3Box ; + LuaCheckParam( L, 1, b3Box) + Frame3d frTool ; + LuaCheckParam( L, 2, frTool) + LuaClearStack( L) ; + // eseguo la trasformazione + if ( b3Box.ToGlob( frTool)) { + LuaSetReturn( L, true) ; + LuaSetReturn( L, b3Box) ; + return 2 ; + } + else { + LuaSetReturn( L, false) ; + return 1 ; + } +} + +//------------------------------------------------------------------------------- +static int +LuaBBoxToLoc( lua_State* L) +{ + // 2 parametri : bbox, frame di trasformazione + BBox3d b3Box ; + LuaCheckParam( L, 1, b3Box) + Frame3d frTool ; + LuaCheckParam( L, 2, frTool) + LuaClearStack( L) ; + // eseguo la trasformazione + if ( b3Box.ToLoc( frTool)) { + LuaSetReturn( L, true) ; + LuaSetReturn( L, b3Box) ; + return 2 ; + } + else { + LuaSetReturn( L, false) ; + return 1 ; + } +} + +//------------------------------------------------------------------------------- +static int +LuaBBoxLocToLoc( lua_State* L) +{ + // 3 parametri : bbox, frame origine, frame destinazione + BBox3d b3Box ; + LuaCheckParam( L, 1, b3Box) + Frame3d frOri ; + LuaCheckParam( L, 2, frOri) + Frame3d frDest ; + LuaCheckParam( L, 3, frDest) + LuaClearStack( L) ; + // eseguo la trasformazione + if ( b3Box.LocToLoc( frOri, frDest)) { + LuaSetReturn( L, true) ; + LuaSetReturn( L, b3Box) ; + return 2 ; + } + else { + LuaSetReturn( L, false) ; + return 1 ; + } +} + //------------------------------------------------------------------------------- bool LuaInstallGeoBase( void) @@ -370,5 +438,8 @@ LuaInstallGeoBase( void) bOk = bOk && LuaRegisterFunction( "EgtFrameToGlob", LuaFrameToGlob) ; bOk = bOk && LuaRegisterFunction( "EgtFrameToLoc", LuaFrameToLoc) ; bOk = bOk && LuaRegisterFunction( "EgtFrameLocToLoc", LuaFrameLocToLoc) ; + bOk = bOk && LuaRegisterFunction( "EgtBBoxToGlob", LuaBBoxToGlob) ; + bOk = bOk && LuaRegisterFunction( "EgtBBoxToLoc", LuaBBoxToLoc) ; + bOk = bOk && LuaRegisterFunction( "EgtBBoxLocToLoc", LuaBBoxLocToLoc) ; return bOk ; } diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index c8f6ca4..0faca18 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -17,6 +17,7 @@ #include "LUA.h" #include "LUA_Base.h" #include "LUA_Aux.h" +#include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EgnStringUtils.h" @@ -35,6 +36,34 @@ LuaGetMachGroupNbr( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetFirstMachGroup( lua_State* L) +{ + // nessun parametro + LuaClearStack( L) ; + // recupero l'identificativo della prima macchinata + int nId = EgtGetFirstMachGroup() ; + // restituisco il risultato + LuaSetReturn( L, nId) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaGetNextMachGroup( lua_State* L) +{ + // 1 parametro : identificativo di una macchinata + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero l'identificativo della successiva macchinata + int nNextId = EgtGetNextMachGroup( nId) ; + // restituisco il risultato + LuaSetReturn( L, nNextId) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaAddMachGroup( lua_State* L) @@ -56,7 +85,7 @@ LuaAddMachGroup( lua_State* L) static int LuaRemoveMachGroup( lua_State* L) { - // 1 parametro : indice del gruppo + // 1 parametro : identificativo del gruppo int nMGroupInd ; LuaCheckParam( L, 1, nMGroupInd) LuaClearStack( L) ; @@ -71,7 +100,7 @@ LuaRemoveMachGroup( lua_State* L) static int LuaGetMachGroupName( lua_State* L) { - // 1 parametro : indice del gruppo + // 1 parametro : identificativo del gruppo int nMGroupInd ; LuaCheckParam( L, 1, nMGroupInd) LuaClearStack( L) ; @@ -88,18 +117,17 @@ LuaGetMachGroupName( lua_State* L) //------------------------------------------------------------------------------- static int -LuaGetMachGroupInd( lua_State* L) +LuaGetMachGroupId( lua_State* L) { // 1 parametro : nome del gruppo string sGroupName ; LuaCheckParam( L, 1, sGroupName) LuaClearStack( L) ; - // recupero l'indice della macchinata - int nInd ; - bool bOk = EgtGetMachGroupInd( sGroupName, nInd) ; + // recupero l'identificativo della macchinata + int nId = EgtGetMachGroupId( sGroupName) ; // restituisco il risultato - if ( bOk) - LuaSetReturn( L, nInd) ; + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; @@ -109,7 +137,7 @@ LuaGetMachGroupInd( lua_State* L) static int LuaSetCurrMachGroup( lua_State* L) { - // 1 parametro : indice del gruppo + // 1 parametro : identificativo del gruppo int nMGroupInd ; LuaCheckParam( L, 1, nMGroupInd) LuaClearStack( L) ; @@ -139,12 +167,11 @@ LuaGetCurrMachGroup( lua_State* L) { // nessun parametro LuaClearStack( L) ; - // recupero il gruppo corrente - int nInd ; - bool bOk = ( EgtGetCurrMachGroup( &nInd) != FALSE) ; + // recupero l'identificativo del gruppo corrente + int nId = EgtGetCurrMachGroup() ; // restituisco il risultato - if ( bOk) - LuaSetReturn( L, nInd) ; + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; else LuaSetReturn( L) ; return 1 ; @@ -176,19 +203,233 @@ LuaAddRawPart( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaAddRawPartWithPart( lua_State* L) +{ + // 4 parametri : nPartId, nCrvId, dOverMat, Color + int nPartId ; + LuaCheckParam( L, 1, nPartId) + int nCrvId ; + LuaCheckParamDef( L, 2, nCrvId, GDB_ID_NULL) + double dOverMat ; + LuaCheckParam( L, 3, dOverMat) + Color cCol ; + LuaCheckParam( L, 4, cCol) + LuaClearStack( L) ; + // inserisco il grezzo nella macchinata corrente + int nInd = EgtAddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ; + // restituisco il risultato + if ( nInd != GDB_ID_NULL) + LuaSetReturn( L, nInd) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaAddPartToRawPart( lua_State* L) +{ + // 3 parametri : nPartId, ptPos, nRawId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + Point3d ptPos ; + LuaCheckParam( L, 2, ptPos) + int nRawId ; + LuaCheckParam( L, 3, nRawId) + LuaClearStack( L) ; + // inserisco il grezzo nella macchinata corrente + bool bOk = EgtAddPartToRawPart( nPartId, ptPos, nRawId) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaModifyRawPartHeight( lua_State* L) +{ + // 2 parametri : nRawId, dHeight + int nRawId ; + LuaCheckParam( L, 1, nRawId) + double dHeight ; + LuaCheckParam( L, 2, dHeight) + LuaClearStack( L) ; + // modifico lo spessore del grezzo + bool bOk = EgtModifyRawPartHeight( nRawId, dHeight) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaRemoveRawPart( lua_State* L) +{ + // 1 parametro : nRawId + int nRawId ; + LuaCheckParam( L, 1, nRawId) + LuaClearStack( L) ; + // elimino il grezzo dalla macchinata corrente + bool bOk = EgtRemoveRawPart( nRawId) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaTranslateRawPart( lua_State* L) +{ + // 2 parametri : nRawId, vtMove + int nRawId ; + LuaCheckParam( L, 1, nRawId) + Vector3d vtMove ; + LuaCheckParam( L, 2, vtMove) + LuaClearStack( L) ; + // traslo il grezzo + bool bOk = EgtTranslateRawPart( nRawId, vtMove) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaRotateRawPart( lua_State* L) +{ + // 3 parametri : nRawId, vtAx, dAngRotDeg + int nRawId ; + LuaCheckParam( L, 1, nRawId) + Vector3d vtAx ; + LuaCheckParam( L, 2, vtAx) + double dAngRotDeg ; + LuaCheckParam( L, 3, dAngRotDeg) + LuaClearStack( L) ; + // ruoto il grezzo + bool bOk = EgtRotateRawPart( nRawId, vtAx, dAngRotDeg) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaMoveToCornerRawPart( lua_State* L) +{ + // 3 parametri : nRawId, ptCorner, nFlag + int nRawId ; + LuaCheckParam( L, 1, nRawId) + Point3d ptCorner ; + LuaCheckParam( L, 2, ptCorner) + string sFlag ; + LuaCheckParam( L, 3, sFlag) + LuaClearStack( L) ; + // sposto il grezzo nel corner + bool bOk = EgtMoveToCornerRawPart( nRawId, ptCorner, StringToRawPartCornerPos( sFlag)) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaMoveToCenterRawPart( lua_State* L) +{ + // 3 parametri : nRawId, ptCenter, nFlag + int nRawId ; + LuaCheckParam( L, 1, nRawId) + Point3d ptCenter ; + LuaCheckParam( L, 2, ptCenter) + string sFlag ; + LuaCheckParam( L, 3, sFlag) + LuaClearStack( L) ; + // sposto il grezzo nel corner + bool bOk = EgtMoveToCenterRawPart( nRawId, ptCenter, StringToRawPartCenterPos( sFlag)) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaRemovePartFromRawPart( lua_State* L) +{ + // 1 parametro : nPartId + int nPartId ; + LuaCheckParam( L, 1, nPartId) + LuaClearStack( L) ; + // elimino il grezzo dalla macchinata corrente + bool bOk = EgtRemovePartFromRawPart( nPartId) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaTranslatePartInRawPart( lua_State* L) +{ + // 2 parametri : nPartId, vtMove + int nPartId ; + LuaCheckParam( L, 1, nPartId) + Vector3d vtMove ; + LuaCheckParam( L, 2, vtMove) + LuaClearStack( L) ; + // traslo il pezzo nel grezzo + bool bOk = EgtTranslatePartInRawPart( nPartId, vtMove) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +static int +LuaRotatePartInRawPart( lua_State* L) +{ + // 3 parametri : nPartId, vtAx, dAngRotDeg + int nPartId ; + LuaCheckParam( L, 1, nPartId) + Vector3d vtAx ; + LuaCheckParam( L, 2, vtAx) + double dAngRotDeg ; + LuaCheckParam( L, 3, dAngRotDeg) + LuaClearStack( L) ; + // ruoto il pezzo nel grezzo + bool bOk = EgtRotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallMachMgr( void) { bool bOk = true ; bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupNbr", LuaGetMachGroupNbr) ; + bOk = bOk && LuaRegisterFunction( "EgtGetFirstMachGroup", LuaGetFirstMachGroup) ; + bOk = bOk && LuaRegisterFunction( "EgtGetNextMachGroup", LuaGetNextMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtRemoveMachGroup", LuaRemoveMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupName", LuaGetMachGroupName) ; - bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupInd", LuaGetMachGroupInd) ; + bOk = bOk && LuaRegisterFunction( "EgtGetMachGroupId", LuaGetMachGroupId) ; bOk = bOk && LuaRegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ; bOk = bOk && LuaRegisterFunction( "EgtAddRawPart", LuaAddRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtAddRawPartWithPart", LuaAddRawPartWithPart) ; + bOk = bOk && LuaRegisterFunction( "EgtAddPartToRawPart", LuaAddPartToRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtModifyRawPartHeight", LuaModifyRawPartHeight) ; + bOk = bOk && LuaRegisterFunction( "EgtRemoveRawPart", LuaRemoveRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtMoveRawPart", LuaTranslateRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtRotateRawPart", LuaRotateRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtMoveToCornerRawPart", LuaMoveToCornerRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtMoveToCenterRawPart", LuaMoveToCenterRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtRemovePartFromRawPart", LuaRemovePartFromRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtMovePartInRawPart", LuaTranslatePartInRawPart) ; + bOk = bOk && LuaRegisterFunction( "EgtRotatePartInRawPart", LuaRotatePartInRawPart) ; + return bOk ; }