diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index 7c3bc17..5d88e58 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -103,6 +103,46 @@ __stdcall EgtOffsetCurve( int nId, double dDist, int nType) return ( bOk ? TRUE : FALSE) ; } +//---------------------------------------------------------------------------- +BOOL +__stdcall EgtChangeClosedCurveStartPoint( int nId, const double ptP[3], int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, FALSE) + bool bOk = true ; + // recupero la curva + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + bOk = bOk && ( pCurve != nullptr) ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ; + // porto in locale il punto vicino ad iniziale + Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; + // recupero la posizione parametrica della proiezione di questo punto sulla curva + DistPointCurve distPC( ptPL, *pCurve) ; + double dPar ; + int nFlag ; + bOk = bOk && distPC.GetParamAtMinDistPoint( 0, dPar, nFlag) ; + // cambio il punto iniziale + if ( bOk && pCurve->GetType() == CRV_ARC) + bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dPar) ; + else if ( bOk && pCurve->GetType() == CRV_COMPO) + bOk = bOk && dynamic_cast(pCurve)->ChangeStartPoint(dPar) ; + else + bOk = false ; + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtChangeClosedCurveStartPoint(" + ToString( nId) + ",{" + + ToString( Point3d( ptP)) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return ( bOk ? TRUE : FALSE) ; +} + //---------------------------------------------------------------------------- BOOL __stdcall EgtModifyCurveStartPoint( int nId, const double ptP[3], int nRefType) diff --git a/EgtInterface.rc b/EgtInterface.rc index b2f3e2c..c120f4c 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index 4a49cc3..fb9f05e 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -406,11 +406,11 @@ LuaCreateCurveArc2PVNEx( lua_State* L) int nIdE ; LuaCheckParam( L, 5, nIdE) Vector3d vtDirS ; - LuaCheckParam( L, 4, vtDirS) + LuaCheckParam( L, 6, vtDirS) Vector3d vtNorm ; - LuaCheckParam( L, 5, vtNorm) + LuaCheckParam( L, 7, vtNorm) int nRefType = RTY_DEFAULT ; - LuaGetRefType( L, 6, nRefType) ; + LuaGetRefType( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco int nId = EgtCreateCurveArc2PVNEx( nParentId, ptStart.v, ptEnd.v, StringToSep( sSepE), nIdE, diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 2b40afd..3b088c3 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -63,6 +63,24 @@ LuaOffsetCurve( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaChangeClosedCurveStartPoint( lua_State* L) +{ + // 2 o 3 parametri : Id, NewStart [, sRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptStart ; + LuaCheckParam( L, 2, ptStart) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 3, nRefType) ; + LuaClearStack( L) ; + // modifico il punto iniziale + bool bOk = ( EgtChangeClosedCurveStartPoint( nId, ptStart.v, nRefType) != FALSE) ; + LuaSetReturn( L, bOk) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaModifyCurveStartPoint( lua_State* L) @@ -331,6 +349,7 @@ LuaInstallGdbModifyCurve( lua_State* L) try { lua_register( L, "EgtInvertCurve", LuaInvertCurve) ; lua_register( L, "EgtOffsetCurve", LuaOffsetCurve) ; + lua_register( L, "EgtChangeClosedCurveStartPoint", LuaChangeClosedCurveStartPoint) ; lua_register( L, "EgtModifyCurveStartPoint", LuaModifyCurveStartPoint) ; lua_register( L, "EgtModifyCurveEndPoint", LuaModifyCurveEndPoint) ; lua_register( L, "EgtModifyCurveExtrusion", LuaModifyCurveExtrusion) ;