From b19dc441e771efeac99d6468001394e8c4d2e8bc Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 27 Jul 2015 13:35:47 +0000 Subject: [PATCH] EgtExecutor 1.6g7 : - aggiunte ExeCreateCurveCompoByApproximation e la corrispondente per LUA_GdbCreateCurve.cpp - corretta ExeCurveDomain --- AuxTools.cpp | 6 ++--- EXE_GdbCreateCurve.cpp | 59 ++++++++++++++++++++++++++++++++++++++--- EXE_GeoSnap.cpp | 2 +- EgtExecutor.rc | Bin 11686 -> 11686 bytes LUA_GdbCreateCurve.cpp | 31 ++++++++++++++++++++++ 5 files changed, 90 insertions(+), 8 deletions(-) diff --git a/AuxTools.cpp b/AuxTools.cpp index 8c18763..bd9e6c2 100644 --- a/AuxTools.cpp +++ b/AuxTools.cpp @@ -143,10 +143,10 @@ const char* InterpTypeToString( int nIntpType) { switch ( nIntpType) { - case ITT_AKIMA : return "GDB_PI.AKIMA" ; + case ITT_ARCS : return "GDB_PI.ARCS" ; default : - case ITT_AKIMA_CORNER : return "GDB_PI.AKIMA_CORNER" ; - case ITT_BESSEL : return "GDB_PI.BESSEL" ; + case ITT_ARCS_CORNER : return "GDB_PI.ARCS_CORNER" ; + case ITT_CUBICS : return "GDB_PI.CUBICS" ; } } diff --git a/EXE_GdbCreateCurve.cpp b/EXE_GdbCreateCurve.cpp index eede9d3..a73ade5 100644 --- a/EXE_GdbCreateCurve.cpp +++ b/EXE_GdbCreateCurve.cpp @@ -37,6 +37,7 @@ #include "/EgtDev/Include/EgkCurveComposite.h" #include "/EgtDev/Include/EgkChainCurves.h" #include "/EgtDev/Include/EGkCurveByInterp.h" +#include "/EgtDev/Include/EGkCurveByApprox.h" #include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkStringUtils3d.h" @@ -1743,23 +1744,21 @@ ExeCreateCurveCompoByInterpolation( int nParentId, const PolyLine& PL, int nType // assegno metodo di interpolazione e tipo del risultato int nMethod = CurveByInterp::AKIMA_CORNER ; int nCrvType = CurveByInterp::BIARCS ; - if ( nType == ITT_AKIMA) { + if ( nType == ITT_ARCS) { nMethod = CurveByInterp::AKIMA ; nCrvType = CurveByInterp::BIARCS ; } - else if ( nType == ITT_BESSEL) { + else if ( nType == ITT_CUBICS) { nMethod = CurveByInterp::BESSEL ; nCrvType = CurveByInterp::CUBIC_BEZIERS ; } // oggetto interpolatore CurveByInterp crvByInterp ; - crvByInterp.Start() ; Point3d ptP ; for ( bool bFound = PL.GetFirstPoint( ptP) ; bFound ; bFound = PL.GetNextPoint( ptP)) crvByInterp.AddPoint( ptP) ; - crvByInterp.End() ; PtrOwner pCrvCompo( crvByInterp.GetCurve( nMethod, nType)) ; bOk = bOk && ! IsNull( pCrvCompo) ; // assegno il versore estrusione @@ -1791,6 +1790,58 @@ ExeCreateCurveCompoByInterpolation( int nParentId, const PolyLine& PL, int nType return nId ; } +//------------------------------------------------------------------------------- +int +ExeCreateCurveCompoByApproximation( int nParentId, const PolyLine& PL, int nType, double dLinTol, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + bool bOk = true ; + // recupero il riferimento del gruppo destinazione + Frame3d frDest ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ; + // eseguo approssimazione + const double ANG_TOL_STD_DEG = 15 ; + const double LIN_FEA_STD = 20 ; + CurveByApprox crvByApprox ; + Point3d ptP ; + for ( bool bFound = PL.GetFirstPoint( ptP) ; + bFound ; + bFound = PL.GetNextPoint( ptP)) + crvByApprox.AddPoint( ptP) ; + PtrOwner pCrvCompo( crvByApprox.GetCurve( nType, dLinTol, ANG_TOL_STD_DEG, LIN_FEA_STD)) ; + bOk = bOk && ! IsNull( pCrvCompo) ; + // assegno il versore estrusione + bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ; + // eventuale trasformazione per riferimento di espressione dei punti + if ( bOk && nRefType == RTY_GLOB) + pCrvCompo->ToLoc( frDest) ; + else if ( bOk && nRefType == RTY_GRID) + pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ; + // inserisco la curva composita nel DB + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sPnt ; + Point3d ptP ; + if ( PL.GetFirstPoint( ptP)) + sPnt += "{" + ToString( ptP) + "}" ; + while ( PL.GetNextPoint( ptP)) + sPnt += ",{" + ToString( ptP) + "}" ; + string sLua = "EgtCurveCompoByApproximation(" + IdToString( nParentId) + ",{" + + sPnt + "}," + + InterpTypeToString( nType) + "," + + ToString( dLinTol) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nId ; +} + //------------------------------------------------------------------------------- int ExeCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) diff --git a/EXE_GeoSnap.cpp b/EXE_GeoSnap.cpp index 5a4896c..700e787 100644 --- a/EXE_GeoSnap.cpp +++ b/EXE_GeoSnap.cpp @@ -613,7 +613,7 @@ ExeCurveDomain( int nId, double* pdStart, double* pdEnd) if ( pCurve == nullptr) return false ; // recupero il dominio - return pCurve->GetDomain( *pdEnd, *pdEnd) ; + return pCurve->GetDomain( *pdStart, *pdEnd) ; } //---------------------------------------------------------------------------- diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 626d098a57b03d2a83aeba4d2acdff397a99db93..086f779f719872db8e6ec0ebc18f1f9c1871bd43 100644 GIT binary patch delta 79 zcmZ1$y)1geFE&Q=&A-`PnSqoe*K!sx?>N)s4T4pS=93+{k~jAW*?>e(i-FY$N+HxV MD8kglDS2=M0ApMljsO4v delta 79 zcmZ1$y)1geFE&QA&A-`PnSqoe*K!sx?>N)s4T4pSW|JMck~jAW*?>e(i-FY$N+HxV MD8kglDS2=M0Adgth5!Hn diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index 7cd248e..f64b050 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -702,6 +702,36 @@ LuaCreateCurveCompoByInterpolation( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateCurveCompoByApproximation( lua_State* L) +{ + // 4 o 5 parametri : ParentId, ptPs, nType, dLinTol [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + PNTVECTOR vPnt ; + LuaCheckParam( L, 2, vPnt) + int nType ; + LuaGetParam( L, 3, nType) ; + double dLinTol ; + LuaGetParam( L, 4, dLinTol) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + PolyLine PL ; + // creo una polilinea a partire dai punti + for ( size_t i = 0 ; i < vPnt.size() ; ++ i) + PL.AddUPoint( 0, vPnt[i]) ; + // creo la curva composita + int nId = ExeCreateCurveCompoByApproximation( nParentId, PL, nType, dLinTol, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCreateCurveCompoFromPoints( lua_State* L) @@ -912,6 +942,7 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompo", LuaCreateCurveCompo) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByChain", LuaCreateCurveCompoByChain) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByInterpolation", LuaCreateCurveCompoByInterpolation) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByApproximation", LuaCreateCurveCompoByApproximation) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRectangle2P", LuaCreateRectangle2P) ;