diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index ee24c05..0f42c8b 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -2319,7 +2319,7 @@ ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType) //------------------------------------------------------------------------------- static bool -MyProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int nDestGrpId, +MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId, double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -2331,29 +2331,38 @@ MyProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int n Frame3d frCrv ; if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv)) return false ; - // recupero la superficie e il suo riferimento - const ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nSurfTmId)) ; - if ( pSurf == nullptr) + // deve esserci almeno una superficie + if ( vnSurfId.empty()) return false ; - Frame3d frStm ; - if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frStm)) + // recupero il riferimento della prima superficie + Frame3d frSurf ; + if ( ! pGeomDB->GetGlobFrame( vnSurfId[0], frSurf)) return false ; + // recupero le superfici e le porto tutte in locale alla prima + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vnSurfId.size()) ; + CISURFPVECTOR vpSurf ; vpSurf.reserve( vnSurfId.size()) ; + for ( int i = 0 ; i < int( vnSurfId.size()) ; ++ i) { + vSurfL.emplace_back( pGeomDB, vnSurfId[i], frSurf) ; + if ( vSurfL[i].Get() == nullptr) + return false ; + vpSurf.emplace_back( vSurfL[i].Get()) ; + } // recupero il riferimento del gruppo di destinazione nDestGrpId = AdjustId( nDestGrpId) ; Frame3d frDest ; if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) return false ; // porto la curva e il vettore nel riferimento della superficie - CurveLocal CrvLoc( pCrv, frCrv, frStm) ; + CurveLocal CrvLoc( pCrv, frCrv, frSurf) ; if ( CrvLoc.Get() == nullptr) return false ; Vector3d vtProjL = GetVectorLocal( pGeomDB, vtProj, nRefType, frCrv) ; - vtProjL.LocToLoc( frCrv, frStm) ; + vtProjL.LocToLoc( frCrv, frSurf) ; // vanno affilati gli spigoli solo se direzione non da proiezione bool bSharpEdges = ( ! bDirFromProj) ; // eseguo la proiezione PNT5AXVECTOR vPt5ax ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), *pSurf, vtProjL, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, vtProjL, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) return false ; // inserisco la composita nel gruppo destinazione PtrOwner pCompo ; @@ -2362,10 +2371,10 @@ MyProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int n pCompo.Set( CreateCurveComposite()) ; if ( IsNull( pCompo)) return false ; - pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ; } else - pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ; } int nCompoId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCompo)) ; if ( nCompoId == GDB_ID_NULL) @@ -2377,7 +2386,7 @@ MyProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int n if ( IsNull( pGeoVct)) return false ; Vector3d vtDir = ( bDirFromProj ? Pt5ax.vtDir2 : Pt5ax.vtDir1) ; - pGeoVct->Set( 10 * GetLocToLoc( vtDir, frStm, frDest), GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + pGeoVct->Set( 10 * GetLocToLoc( vtDir, frSurf, frDest), GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ; int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoVct)) ; if ( nNewId == GDB_ID_NULL) return false ; @@ -2391,15 +2400,15 @@ MyProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int n //------------------------------------------------------------------------------- bool -ExeProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int nDestGrpId, +ExeProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId, double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType) { - bool bOk = MyProjectCurveOnSurf( nCurveId, nSurfTmId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ; + bool bOk = MyProjectCurveOnSurf( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtProjectCurveOnSurf(" + ToString( nCurveId) + "," + - ToString( nSurfTmId) + ",{" + + string sLua = "EgtProjectCurveOnSurf(" + ToString( nCurveId) + ",{" + + ToString( vnSurfId) + "},{" + ToString( vtProj) + "}," + ToString( nDestGrpId) + "," + ToString( dLinTol) + "," + @@ -2415,7 +2424,7 @@ ExeProjectCurveOnSurf( int nCurveId, int nSurfTmId, const Vector3d& vtProj, int //------------------------------------------------------------------------------- static bool -MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrpId, +MyProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, int nDestGrpId, double dLinTol, double dMaxSegmLen, bool bDirFromGuide) { IGeomDB* pGeomDB = GetCurrGeomDB() ; @@ -2427,13 +2436,22 @@ MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrp Frame3d frCrv ; if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv)) return false ; - // recupero la superficie e il suo riferimento - const ISurf* pStm = GetSurf( pGeomDB->GetGeoObj( nSurfTmId)) ; - if ( pStm == nullptr) + // deve esserci almeno una superficie + if ( vnSurfId.empty()) return false ; - Frame3d frStm ; - if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frStm)) + // recupero il riferimento della prima superficie + Frame3d frSurf ; + if ( ! pGeomDB->GetGlobFrame( vnSurfId[0], frSurf)) return false ; + // recupero le superfici e le porto tutte in locale alla prima + SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vnSurfId.size()) ; + CISURFPVECTOR vpSurf ; vpSurf.reserve( vnSurfId.size()) ; + for ( int i = 0 ; i < int( vnSurfId.size()) ; ++ i) { + vSurfL.emplace_back( pGeomDB, vnSurfId[i], frSurf) ; + if ( vSurfL[i].Get() == nullptr) + return false ; + vpSurf.emplace_back( vSurfL[i].Get()) ; + } // recupero l'entità guida (punto, curva o superficie) e il suo riferimento const IGeoPoint3d* pGdePnt = nullptr ; const ICurve* pGdeCrv = nullptr ; @@ -2456,7 +2474,7 @@ MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrp if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) return false ; // porto la curva nel riferimento della superficie - CurveLocal CrvLoc( pCrv, frCrv, frStm) ; + CurveLocal CrvLoc( pCrv, frCrv, frSurf) ; if ( CrvLoc.Get() == nullptr) return false ; // vanno affilati gli spigoli solo se direzione non da guida @@ -2467,23 +2485,23 @@ MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrp PtrOwner pGdeLoc( pGdePnt->Clone()) ; if ( pGdeLoc == nullptr) return false ; - pGdeLoc->LocToLoc( frGde, frStm) ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), *pStm, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + pGdeLoc->LocToLoc( frGde, frSurf) ; + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) return false ; } else if ( pGdeCrv != nullptr) { - CurveLocal GdeLoc( pGdeCrv, frGde, frStm) ; + CurveLocal GdeLoc( pGdeCrv, frGde, frSurf) ; if ( GdeLoc.Get() == nullptr) return false ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), *pStm, *GdeLoc.Get(), dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *GdeLoc.Get(), dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) return false ; } else { // pGdeStm != nullptr - SurfLocal GdeLoc( pGdeStm, frGde, frStm) ; + SurfLocal GdeLoc( pGdeStm, frGde, frSurf) ; const ISurf* pGdeLoc = GetSurf( GdeLoc.Get()) ; if ( pGdeLoc == nullptr) return false ; - if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), *pStm, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) + if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, *pGdeLoc, dLinTol, dMaxSegmLen, bSharpEdges, vPt5ax)) return false ; } // inserisco la composita nel gruppo destinazione @@ -2493,10 +2511,10 @@ MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrp pCompo.Set( CreateCurveComposite()) ; if ( IsNull( pCompo)) return false ; - pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ; } else - pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ; } int nCompoId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCompo)) ; if ( nCompoId == GDB_ID_NULL) @@ -2508,7 +2526,7 @@ MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrp if ( IsNull( pGeoVct)) return false ; Vector3d vtDir = ( bDirFromGuide ? Pt5ax.vtDir2 : Pt5ax.vtDir1) ; - pGeoVct->Set( 10 * GetLocToLoc( vtDir, frStm, frDest), GetLocToLoc( Pt5ax.ptP, frStm, frDest)) ; + pGeoVct->Set( 10 * GetLocToLoc( vtDir, frSurf, frDest), GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ; int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoVct)) ; if ( nNewId == GDB_ID_NULL) return false ; @@ -2522,16 +2540,16 @@ MyProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrp //------------------------------------------------------------------------------- bool -ExeProjectCurveOnSurfExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestGrpId, - double dLinTol, double dMaxSegmLen, bool bDirFromGuide) +ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId, int nDestGrpId, + double dLinTol, double dMaxSegmLen, bool bDirFromGuide) { - bool bOk = MyProjectCurveOnSurfExt( nCurveId, nSurfTmId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ; + bool bOk = MyProjectCurveOnSurfExt( nCurveId, vnSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtProjectCurveOnSurfExt(" + ToString( nCurveId) + "," + - ToString( nSurfTmId) + ",{" + - ToString( nGuideId) + "}," + + string sLua = "EgtProjectCurveOnSurfExt(" + ToString( nCurveId) + ",{" + + ToString( vnSurfId) + "}," + + ToString( nGuideId) + "," + ToString( nDestGrpId) + "," + ToString( dLinTol) + "," + ToString( dMaxSegmLen) + "," + @@ -2606,8 +2624,8 @@ ExeCurveGetVoronoi( const INTVECTOR& vIds, int nDestGrpId, int nBound, int* pnCo ExeSetModified() ; if ( IsCmdLog()) { - string sLua = "EgtCurveGetVoronoi(" + ToString( vIds[0]) + "," + - ToString( nDestGrpId) + ")" + + string sLua = "EgtCurveGetVoronoi({" + ToString( vIds) + "}," + + ToString( nDestGrpId) + ")" + " FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index ecabdb5..fc903c8 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -989,11 +989,11 @@ LuaReorderCurvesInGroup( lua_State* L) static int LuaProjectCurveOnSurf( lua_State* L) { - // 4, 5, 6, 7 o 8 parametri : nCurveId, nSurfTmId, vtDir, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromProj] [, nRefType]] + // 4, 5, 6, 7 o 8 parametri : nCurveId, vSurfId, vtDir, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromProj] [, nRefType]] int nCurveId ; LuaCheckParam( L, 1, nCurveId) - int nSurfTmId ; - LuaCheckParam( L, 2, nSurfTmId) + INTVECTOR vSurfId ; + LuaCheckParam( L, 2, vSurfId) Vector3d vtDir ; LuaCheckParam( L, 3, vtDir) int nDestGrpId ; @@ -1007,8 +1007,8 @@ LuaProjectCurveOnSurf( lua_State* L) LuaGetParam( L, 7, bDirFromProj)) LuaGetParam( L, 8, nRefType) ; LuaClearStack( L) ; - // proietto la curva su una superficie secondo la direzione data - bool bOk = ExeProjectCurveOnSurf( nCurveId, nSurfTmId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ; + // proietto la curva su una o più superfici secondo la direzione data + bool bOk = ExeProjectCurveOnSurf( nCurveId, vSurfId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ; LuaSetParam( L, bOk) ; return 1 ; } @@ -1017,11 +1017,11 @@ LuaProjectCurveOnSurf( lua_State* L) static int LuaProjectCurveOnSurfExt( lua_State* L) { - // 4, 5, 6 o 7 parametri : nCurveId, nSurfTmId, nGuideId, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromGuide]] + // 4, 5, 6 o 7 parametri : nCurveId, vSurfId, nGuideId, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromGuide]] int nCurveId ; LuaCheckParam( L, 1, nCurveId) - int nSurfTmId ; - LuaCheckParam( L, 2, nSurfTmId) + INTVECTOR vSurfId ; + LuaCheckParam( L, 2, vSurfId) int nGuideId ; LuaCheckParam( L, 3, nGuideId) int nDestGrpId ; @@ -1033,8 +1033,8 @@ LuaProjectCurveOnSurfExt( lua_State* L) LuaGetParam( L, 6, dMaxSegmLen)) LuaGetParam( L, 7, bDirFromGuide) ; LuaClearStack( L) ; - // proietto la curva su una superficie secondo la direzione verso la guida - bool bOk = ExeProjectCurveOnSurfExt( nCurveId, nSurfTmId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ; + // proietto la curva su una o più superfici secondo la direzione verso la guida + bool bOk = ExeProjectCurveOnSurfExt( nCurveId, vSurfId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ; LuaSetParam( L, bOk) ; return 1 ; } diff --git a/LUA_MachOpt.cpp b/LUA_MachOpt.cpp index ce6bdf9..39b047a 100644 --- a/LUA_MachOpt.cpp +++ b/LUA_MachOpt.cpp @@ -50,28 +50,25 @@ LuaOptMachTerminate( lua_State* L) static int LuaOptMachAddTool( lua_State* L) { - // Definizione 15 parametri - int nId = 0 ; + // Definizione 9 parametri (3 obbligatori) + int nId ; LuaCheckParam( L, 1, nId) ; - double dTC_X = 0. ; double dTC_Y = 0. ; double dTC_Z = 0. ; - LuaCheckParam( L, 2, dTC_X) ; - LuaCheckParam( L, 3, dTC_Y) ; - LuaCheckParam( L, 4, dTC_Z) ; - double dTC_A = 0. ; double dTC_B = 0. ; double dTC_C = 0. ; - LuaCheckParam( L, 5, dTC_A) ; - LuaCheckParam( L, 6, dTC_B) ; - LuaCheckParam( L, 7, dTC_C) ; - bool bTC_X = false ; bool bTC_Y = false ; bool bTC_Z = false ; - LuaCheckParam( L, 8, bTC_X) ; - LuaCheckParam( L, 9, bTC_Y) ; - LuaCheckParam( L, 10, bTC_Z) ; - bool bTC_A = false ; bool bTC_B = false ; bool bTC_C = false ; - LuaCheckParam( L, 11, bTC_A) ; - LuaCheckParam( L, 12, bTC_B) ; - LuaCheckParam( L, 13, bTC_C) ; - double dTLoad = 0. ; double dTUnload = 0. ; - LuaCheckParam( L, 14, dTLoad) ; - LuaCheckParam( L, 15, dTUnload) ; + double dTLoad ; + LuaCheckParam( L, 2, dTLoad) ; + double dTUnload ; + LuaCheckParam( L, 3, dTUnload) ; + double dTC_X = 0. ; + bool bTC_X = LuaGetParam( L, 4, dTC_X) ; + double dTC_Y = 0. ; + bool bTC_Y = LuaGetParam( L, 5, dTC_Y) ; + double dTC_Z = 0. ; + bool bTC_Z = LuaGetParam( L, 6, dTC_Z) ; + double dTC_A = 0. ; + bool bTC_A = LuaGetParam( L, 7, dTC_A) ; + double dTC_B = 0. ; + bool bTC_B = LuaGetParam( L, 8, dTC_B) ; + double dTC_C = 0. ; + bool bTC_C = LuaGetParam( L, 9, dTC_C) ; LuaClearStack( L) ; // Aggiungo la Lavorazione bool bOk = ExeOptMachAddTool( nId, dTC_X, dTC_Y, dTC_Z, dTC_A, dTC_B, dTC_C, @@ -86,32 +83,27 @@ LuaOptMachAddTool( lua_State* L) static int LuaOptMachAddMachining( lua_State* L) { - // Definizione 15 parametri - int nId = 0 ; int nToolId = 0 ; int nGroup = 0 ; + // Definizione 5 parametri + int nId ; LuaCheckParam( L, 1, nId) ; + int nToolId ; LuaCheckParam( L, 2, nToolId) ; + int nGroup ; LuaCheckParam( L, 3, nGroup) ; - double dX_Start = 0. ; double dY_Start = 0. ; double dZ_Start = 0. ; - double dA_Start = 0. ; double dB_Start = 0. ; double dC_Start = 0. ; - LuaCheckParam( L, 4, dX_Start) ; - LuaCheckParam( L, 5, dY_Start) ; - LuaCheckParam( L, 6, dZ_Start) ; - LuaCheckParam( L, 7, dA_Start) ; - LuaCheckParam( L, 8, dB_Start) ; - LuaCheckParam( L, 9, dC_Start) ; - double dX_End = 0. ; double dY_End = 0. ; double dZ_End = 0. ; - double dA_End = 0. ; double dB_End = 0. ; double dC_End = 0. ; - LuaCheckParam( L, 10, dX_End) ; - LuaCheckParam( L, 11, dY_End) ; - LuaCheckParam( L, 12, dZ_End) ; - LuaCheckParam( L, 13, dA_End) ; - LuaCheckParam( L, 14, dB_End) ; - LuaCheckParam( L, 15, dC_End) ; + DBLVECTOR vAxStart ; + LuaCheckParam( L, 4, vAxStart) ; + DBLVECTOR vAxEnd ; + LuaCheckParam( L, 5, vAxEnd) ; LuaClearStack( L) ; + // Completamento valori assi + while ( vAxStart.size() < 6) + vAxStart.push_back( 0) ; + while ( vAxEnd.size() < 6) + vAxEnd.push_back( 0) ; // Aggiungo la Lavorazione bool bOk = ExeOptMachAddMachining( nId, nToolId, nGroup, - dX_Start, dY_Start, dZ_Start, dA_Start, dB_Start, dC_Start, - dX_End, dY_End, dZ_End, dA_End, dB_End, dC_End) ; + vAxStart[0], vAxStart[1], vAxStart[2], vAxStart[3], vAxStart[4], vAxStart[5], + vAxEnd[0], vAxEnd[1], vAxEnd[2], vAxEnd[3], vAxEnd[4], vAxEnd[5]) ; // Rstituisco il risultato LuaSetParam( L, bOk) ; return 1 ; @@ -147,6 +139,7 @@ LuaOptMachSetLastMachining( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------ static int LuaOptMachSetFeeds( lua_State* L) {