diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index 42a114a..d284866 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -452,9 +452,9 @@ ExeTrimExtendCurveByLen( int nId, double dLen, const Point3d& ptNear, int nRefTy // porto in locale il punto Point3d ptNearL = GetPointLocal( pGeomDB, ptNear, nRefType, frLoc) ; // cerco l'estremo pių vicino al punto passato - Point3d ptStart, ptEnd ; - if ( bOk && pCurve->GetStartPoint( ptStart) && pCurve->GetEndPoint( ptEnd)) { - if ( SqDist( ptStart, ptNearL) < SqDist( ptEnd, ptNearL)) { + bool bStart ; + if ( bOk && pCurve->GetNearestExtremityToPoint( ptNearL, bStart)) { + if ( bStart) { if ( dLen < - EPS_SMALL) bOk = pCurve->TrimStartAtLen( - dLen) ; else if ( dLen > EPS_SMALL) @@ -469,6 +469,23 @@ ExeTrimExtendCurveByLen( int nId, double dLen, const Point3d& ptNear, int nRefTy bOk = pCurve->ExtendEndByLen( dLen) ; } } + //Point3d ptStart, ptEnd ; + //if ( bOk && pCurve->GetStartPoint( ptStart) && pCurve->GetEndPoint( ptEnd)) { + // if ( SqDist( ptStart, ptNearL) < SqDist( ptEnd, ptNearL)) { + // if ( dLen < - EPS_SMALL) + // bOk = pCurve->TrimStartAtLen( - dLen) ; + // else if ( dLen > EPS_SMALL) + // bOk = pCurve->ExtendStartByLen( dLen) ; + // } + // else { + // if ( dLen < - EPS_SMALL) { + // double dCrvLen ; + // bOk = pCurve->GetLength( dCrvLen) && pCurve->TrimEndAtLen( dCrvLen + dLen) ; + // } + // else if ( dLen > EPS_SMALL) + // bOk = pCurve->ExtendEndByLen( dLen) ; + // } + //} else bOk = false ; ExeSetModified() ; diff --git a/EXE_GeoSnap.cpp b/EXE_GeoSnap.cpp index 2e77377..1c032a8 100644 --- a/EXE_GeoSnap.cpp +++ b/EXE_GeoSnap.cpp @@ -573,6 +573,23 @@ ExeFrame( int nId, int nRefId, Frame3d& frFrame) return false ; } +//---------------------------------------------------------------------------- +bool +ExeCurveDomain( int nId, double* pdStart, double* pdEnd) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // verifico i parametri + if ( pdStart == nullptr || pdEnd == nullptr) + return false ; + // recupero la curva + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + if ( pCurve == nullptr) + return false ; + // recupero il dominio + return pCurve->GetDomain( *pdEnd, *pdEnd) ; +} + //---------------------------------------------------------------------------- bool ExeCurveLength( int nId, double* pdLen) @@ -634,6 +651,18 @@ ExeCurveLengthAtPoint( int nId, const Point3d& ptOn, double dExtend, double* pdL return false ; } +//---------------------------------------------------------------------------- +bool +ExeCurveNearestExtremityToPoint( int nId, const Point3d& ptP, bool& bStart) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la curva + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + // recupero quale estremo č pių vicino al punto + return ( pCurve != nullptr && pCurve->GetNearestExtremityToPoint( ptP, bStart)) ; +} + //---------------------------------------------------------------------------- bool ExeCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) @@ -666,11 +695,11 @@ ExeCurveThickness( int nId, double* pdThick) //---------------------------------------------------------------------------- bool -ExeGetMinDistPointCurve( const Point3d& ptP, int nId, double* pdDist) +ExeGetMinDistPointCurve( const Point3d& ptP, int nId, double* pdDist, double* pdU) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - // verifico i parametri + // verifico il primo parametro di ritorno obbligatorio if ( pdDist == nullptr) return false ; // recupero la curva @@ -678,8 +707,13 @@ ExeGetMinDistPointCurve( const Point3d& ptP, int nId, double* pdDist) if ( pCurve == nullptr) return false ; // calcolo la minima distanza + int nFlag ; DistPointCurve distPC( ptP, *pCurve) ; - return distPC.GetDist( *pdDist) ; + if ( ! distPC.GetDist( *pdDist)) + return false ; + if ( pdU != nullptr && ! distPC.GetParamAtMinDistPoint( 0, *pdU, nFlag)) + return false ; + return true ; } //---------------------------------------------------------------------------- diff --git a/EXE_Messages.cpp b/EXE_Messages.cpp index 2762587..3b8f41c 100644 --- a/EXE_Messages.cpp +++ b/EXE_Messages.cpp @@ -15,7 +15,7 @@ #include "stdafx.h" #include "EXE.h" #include "/EgtDev/Include/EXeExecutor.h" -#include "/EgtDEv/Include/EGnScan.h" +#include "/EgtDEv/Include/EGnScanner.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtLogger.h" diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 5562df6..1f48023 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index 2f50144..fc6b04d 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -279,6 +279,27 @@ LuaFrame( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaCurveDomain( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il dominio della curva + double dStart, dEnd ; + if ( ExeCurveDomain( nId, &dStart, &dEnd) != FALSE) { + LuaSetReturn( L, dStart) ; + LuaSetReturn( L, dEnd) ; + return 2 ; + } + else { + LuaSetReturn( L) ; + return 1 ; + } +} + //---------------------------------------------------------------------------- static int LuaCurveLength( lua_State* L) @@ -566,6 +587,7 @@ LuaInstallGeoSnap( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtUV", LuaAtParamVector) ; bOk = bOk && luaMgr.RegisterFunction( "EgtFR", LuaFrame) ; bOk = bOk && luaMgr.RegisterFunction( "EgtET", LuaExtrusionByThickness) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCurveDomain", LuaCurveDomain) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveLength", LuaCurveLength) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveExtrusion", LuaCurveExtrusion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCurveThickness", LuaCurveThickness) ;