From dd5c8ebdd1f0fb5539f66e6768c31874c851396a Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Fri, 31 Mar 2023 14:55:45 +0200 Subject: [PATCH] EgtExecutor : - aggiunte funzioni Exe e Lua per quotature angolari, radiali e diametrali. --- EXE_GdbCreate.cpp | 799 +++++++++++++++++++++++++++++++++++++++------- LUA_GdbCreate.cpp | 165 ++++++++++ 2 files changed, 854 insertions(+), 110 deletions(-) diff --git a/EXE_GdbCreate.cpp b/EXE_GdbCreate.cpp index 61a4f7b..78baf0c 100644 --- a/EXE_GdbCreate.cpp +++ b/EXE_GdbCreate.cpp @@ -26,6 +26,11 @@ #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" +#include "/EgtDev/Include/EGkIntersCurves.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveArc.h" +#include "/EgtDev/Include/EGkDistPointCurve.h" +#include "/EgtDev/Include/EGkCurveComposite.h" using namespace std ; @@ -35,11 +40,11 @@ ExeCreateGroup( int nParentId, const Frame3d& frFrame, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; - // recupero il riferimento locale + // recupero il riferimento locale Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc ) ; // porto in locale l'origine e i versori Point3d ptOrigL = GetPointLocal( pGeomDB, frFrame.Orig(), nRefType, frLoc) ; Vector3d vtXL = GetVectorLocal( pGeomDB, frFrame.VersX(), nRefType, frLoc) ; @@ -57,23 +62,23 @@ ExeCreateGroup( int nParentId, const Frame3d& frFrame, int nRefType) if ( AreSameFrame( frFrame, GLOB_FRM)) { if ( nRefType == RTY_LOC) sLua = "EgtGroup(" + IdToString( nParentId) + ")" + - " -- Id=" + ToString( nId) ; + " -- Id=" + ToString( nId) ; else sLua = "EgtGroup(" + IdToString( nParentId) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; } else sLua = "EgtGroup(" + IdToString( nParentId) + ",{{" + - ToString( frFrame.Orig()) + "},{" + - ToString( frFrame.VersX()) + "},{" + - ToString( frFrame.VersY()) + "},{" + - ToString( frFrame.VersZ()) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( frFrame.Orig()) + "},{" + + ToString( frFrame.VersX()) + "},{" + + ToString( frFrame.VersY()) + "},{" + + ToString( frFrame.VersZ()) + "}}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo del nuovo gruppo + // restituisco l'identificativo del nuovo gruppo return nId ; } @@ -83,7 +88,7 @@ ExeCreateGeoPoint( int nParentId, const Point3d& ptP, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -92,21 +97,21 @@ ExeCreateGeoPoint( int nParentId, const Point3d& ptP, int nRefType) Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; // creo il punto PtrOwner pGeoPnt( CreateGeoPoint3d()) ; - bOk = bOk && ! IsNull( pGeoPnt) ; + bOk = bOk && !IsNull( pGeoPnt) ; // setto il punto - bOk = bOk && pGeoPnt->Set( ptPL) ; + bOk = bOk && pGeoPnt->Set( ptPL) ; // inserisco il punto nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtPoint(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entit� return nId ; } @@ -116,7 +121,7 @@ ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -126,9 +131,9 @@ ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int Point3d ptBL = GetPointLocal( pGeomDB, ptB, nRefType, frLoc) ; // creo il vettore PtrOwner pGeoVct( CreateGeoVector3d()) ; - bOk = bOk && ! IsNull( pGeoVct) ; + bOk = bOk && !IsNull( pGeoVct) ; // setto il vettore (con il punto base) - bOk = bOk && pGeoVct->Set( vtVL, ptBL) ; + bOk = bOk && pGeoVct->Set( vtVL, ptBL) ; // inserisco il vettore nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ; ExeSetModified() ; @@ -137,18 +142,18 @@ ExeCreateGeoVector( int nParentId, const Vector3d& vtV, const Point3d& ptB, int string sLua ; if ( ptB.IsSmall()) sLua = "EgtVector(" + IdToString( nParentId) + ",{" + - ToString( vtV) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( vtV) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; else sLua = "EgtVector(" + IdToString( nParentId) + ",{" + - ToString( vtV) + "},{" + - ToString( ptB) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( vtV) + "},{" + + ToString( ptB) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entit� return nId ; } @@ -158,11 +163,11 @@ ExeCreateGeoFrame( int nParentId, const Frame3d& frFrame, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; - bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc ) ; // porto in locale l'origine e i versori Point3d ptOrigL = GetPointLocal( pGeomDB, frFrame.Orig(), nRefType, frLoc) ; Vector3d vtXL = GetVectorLocal( pGeomDB, frFrame.VersX(), nRefType, frLoc) ; @@ -170,20 +175,20 @@ ExeCreateGeoFrame( int nParentId, const Frame3d& frFrame, int nRefType) Vector3d vtZL = GetVectorLocal( pGeomDB, frFrame.VersZ(), nRefType, frLoc) ; // creo e setto il riferimento PtrOwner pGeoFrm( CreateGeoFrame3d()) ; - bOk = bOk && ! IsNull( pGeoFrm) ; - bOk = bOk && pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ; + bOk = bOk && !IsNull( pGeoFrm) ; + bOk = bOk && pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ; // inserisco il riferimento nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ; ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtFrame(" + IdToString( nParentId) + ",{{" + - ToString( frFrame.Orig()) + "},{" + - ToString( frFrame.VersX()) + "},{" + - ToString( frFrame.VersY()) + "},{" + - ToString( frFrame.VersZ()) + "}}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( frFrame.Orig()) + "},{" + + ToString( frFrame.VersX()) + "},{" + + ToString( frFrame.VersY()) + "},{" + + ToString( frFrame.VersZ()) + "}}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del nuovo gruppo @@ -197,7 +202,7 @@ ExeCreateText( int nParentId, const Point3d& ptP, { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -208,7 +213,7 @@ ExeCreateText( int nParentId, const Point3d& ptP, Vector3d vtDL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ; // creo il testo e lo riempio PtrOwner pTXT( CreateExtText()) ; - bOk = bOk && ! IsNull( pTXT) ; + bOk = bOk && !IsNull( pTXT) ; bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, "", false, dH) ; // inserisco il testo nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; @@ -216,11 +221,11 @@ ExeCreateText( int nParentId, const Point3d& ptP, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtText(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "},'" + - StringToLuaString( sText) + "'," + - ToString( dH) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "},'" + + StringToLuaString( sText) + "'," + + ToString( dH) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -234,7 +239,7 @@ ExeCreateTextEx( int nParentId, const Point3d& ptP, double dAngRotDeg, { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -242,10 +247,10 @@ ExeCreateTextEx( int nParentId, const Point3d& ptP, double dAngRotDeg, // porto in locale l'origine e i versori Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - Vector3d vtDL = GetVectorLocal( pGeomDB, FromPolar(1, dAngRotDeg), nRefType, frLoc) ; + Vector3d vtDL = GetVectorLocal( pGeomDB, FromPolar( 1, dAngRotDeg), nRefType, frLoc) ; // creo il testo e lo riempio PtrOwner pTXT( CreateExtText()) ; - bOk = bOk && ! IsNull( pTXT) ; + bOk = bOk && !IsNull( pTXT) ; bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, bItalic, dH) ; // inserisco il testo nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; @@ -253,17 +258,17 @@ ExeCreateTextEx( int nParentId, const Point3d& ptP, double dAngRotDeg, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTextEx(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "}," + - ToString( dAngRotDeg) + ",'" + - StringToLuaString( sText) + "','" + - StringToLuaString( sFont) + "'," + - ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "}," + + ToString( dAngRotDeg) + ",'" + + StringToLuaString( sText) + "','" + + StringToLuaString( sFont) + "'," + + ( bItalic ? "'I'" : "'S'") + "," + + ToString( dH) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo del oggetto + // restituisco l'identificativo del oggetto return nId ; } @@ -275,7 +280,7 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg, { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; bool bOk = true ; // recupero il riferimento locale Frame3d frLoc ; @@ -283,10 +288,10 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg, // porto in locale l'origine e i versori Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ; Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; - Vector3d vtDL = GetVectorLocal( pGeomDB, FromPolar(1, dAngRotDeg), nRefType, frLoc) ; + Vector3d vtDL = GetVectorLocal( pGeomDB, FromPolar( 1, dAngRotDeg), nRefType, frLoc) ; // creo il testo e lo imposto PtrOwner pTXT( CreateExtText()) ; - bOk = bOk && ! IsNull( pTXT) ; + bOk = bOk && !IsNull( pTXT) ; bOk = bOk && pTXT->Set( ptPL, vtNL, vtDL, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ; // inserisco il testo nel DB int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pTXT)) : GDB_ID_NULL) ; @@ -294,18 +299,18 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtTextAdv(" + IdToString( nParentId) + ",{" + - ToString( ptP) + "}," + - ToString( dAngRotDeg) + ",'" + - StringToLuaString( sText) + "','" + - StringToLuaString( sFont) + "'," + - ToString( nW) + "," + - ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + "," + - ToString( dRat) + "," + - ToString( dAddAdv) + "," + - ETxtInsPosToString( nInsPos) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP) + "}," + + ToString( dAngRotDeg) + ",'" + + StringToLuaString( sText) + "','" + + StringToLuaString( sFont) + "'," + + ToString( nW) + "," + + ( bItalic ? "'I'" : "'S'") + "," + + ToString( dH) + "," + + ToString( dRat) + "," + + ToString( dAddAdv) + "," + + ETxtInsPosToString( nInsPos) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -315,12 +320,12 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg, //------------------------------------------------------------------------------- bool ExeSetCurrDimensionStyle( double dExtLineLen, double dArrowLen, double dTextDist, - int nLenIsMM, int nDecDigit, const string& sFont, double dTextHeight) + int nLenIsMM, int nDecDigit, const string& sFont, double dTextHeight) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, false) - // aggiorno lo stile di quotatura corrente - pGseCtx->m_dsCurr.Set( dExtLineLen, dArrowLen, dTextDist, nLenIsMM, nDecDigit, sFont, dTextHeight) ; + // aggiorno lo stile di quotatura corrente + pGseCtx->m_dsCurr.Set( dExtLineLen, dArrowLen, dTextDist, nLenIsMM, nDecDigit, sFont, dTextHeight) ; return true ; } @@ -330,8 +335,8 @@ ExeResetCurrDimensionStyle( void) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, false) - // aggiorno lo stile di quotatura corrente - pGseCtx->m_dsCurr.Reset() ; + // aggiorno lo stile di quotatura corrente + pGseCtx->m_dsCurr.Reset() ; return true ; } @@ -341,16 +346,16 @@ MySetDimensionStyle( IExtDimension* pDim) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, false) - // verifico validità quotatura - if ( pDim == nullptr) - return false ; + // verifico validit� quotatura + if ( pDim == nullptr) + return false ; // recupero lo stile di quotatura const DimensionStyle& DimSt = pGseCtx->m_dsCurr ; - // recupero l'unità di misura lineare per la quotatura - bool bLenIsMM = ( DimSt.nLenIsMM == 2 ? ExeUiUnitsAreMM() : ( DimSt.nLenIsMM != 0)) ; + // recupero l'unit� di misura lineare per la quotatura + bool bLenIsMM = ( DimSt.nLenIsMM == 2 ? ExeUiUnitsAreMM() : ( DimSt.nLenIsMM != 0 )) ; // imposto lo stile return pDim->SetStyle( DimSt.dExtLineLen, DimSt.dArrowLen, DimSt.dTextDist, - bLenIsMM, DimSt.nDecDigit, DimSt.sFont, DimSt.dTextHeight) ; + bLenIsMM, DimSt.nDecDigit, DimSt.sFont, DimSt.dTextHeight) ; } //------------------------------------------------------------------------------- @@ -360,10 +365,10 @@ MyCreateLinearDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2 { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - nParentId = AdjustId( nParentId) ; + nParentId = AdjustId( nParentId) ; // recupero il riferimento locale Frame3d frLoc ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc )) return GDB_ID_NULL ; // porto in locale i punti e assegno i versori Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ; @@ -373,9 +378,9 @@ MyCreateLinearDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP2 Vector3d vtDL = GetVectorLocal( pGeomDB, vtDir, nRefType, frLoc) ; // creo la quota PtrOwner pDim( CreateExtDimension()) ; - if ( IsNull( pDim) || - ! MySetDimensionStyle( pDim) || - ! pDim->SetLinear( ptP1L, ptP2L, ptDimL, vtNL, vtDL, sText)) + if ( IsNull( pDim ) || + ! MySetDimensionStyle( pDim ) || + ! pDim->SetLinear( ptP1L, ptP2L, ptDimL, vtNL, vtDL, sText )) return GDB_ID_NULL ; // inserisco la quota nel DB return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; @@ -392,12 +397,12 @@ ExeCreateHorizontalDimension( int nParentId, const Point3d& ptP1, const Point3d& // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtHorizontalDimension(" + IdToString( nParentId) + ",{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -414,13 +419,13 @@ ExeCreateVerticalDimension( int nParentId, const Point3d& ptP1, const Point3d& p ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtVerticalDimension(" + IdToString( nParentId) + ",{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + string sLua = "EgtVerticalDimension(" + IdToString( nParentId ) + ",{" + + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto @@ -438,14 +443,588 @@ ExeCreateAlignedDimension( int nParentId, const Point3d& ptP1, const Point3d& pt // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtAlignedDimension(" + IdToString( nParentId) + ",{" + - ToString( ptP1) + "},{" + - ToString( ptP2) + "},{" + - ToString( ptDim) + "},'" + - StringToLuaString( sText) + "'," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nId) ; + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco l'identificativo del oggetto return nId ; } + +//------------------------------------------------------------------------------- +static int +MyCreateAngularDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP0, const Point3d& ptP2, + const Point3d& ptDim, const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + // porto in locale i punti e assegno i versori + Point3d ptP0L = GetPointLocal( pGeomDB, ptP0, nRefType, frLoc) ; + Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ; + Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ; + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim) || + ! MySetDimensionStyle( pDim ) || + ! pDim->SetAngular( ptP1L, ptP0L, ptP2L, ptDimL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateAngularDimension( int nParentId, const Point3d& ptP1, const Point3d& ptP0, const Point3d& ptP2, + const Point3d& ptDim, const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateAngularDimension( nParentId, ptP1, ptP0, ptP2, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAngularDimension(" + IdToString( nParentId) + ",{" + + ToString( ptP0) + "},{" + + ToString( ptP1) + "},{" + + ToString( ptP2) + "},{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateAngularDimensionFromLines( int nParentId, INTVECTOR vLineIds, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + + //recupero le linee + ICurveLine* pCrv1 = GetCurveLine( pGeomDB->GetGeoObj( vLineIds[0])) ; + ICurveLine* pCrv2 = GetCurveLine( pGeomDB->GetGeoObj( vLineIds[1])) ; + if ( pCrv1 == nullptr || pCrv2 == nullptr) + return GDB_ID_NULL ; + PtrOwner pL1( pCrv1->Clone()) ; + PtrOwner pL2( pCrv2->Clone()) ; + if ( IsNull( pL1 ) || ! pL1->IsValid() || IsNull( pL2) || ! pL2->IsValid()) + return GDB_ID_NULL ; + + //porto tutto nel frLoc + Frame3d frL1, frL2 ; + if ( ! pGeomDB->GetGlobFrame( vLineIds[0], frL1) || ! pGeomDB->GetGlobFrame( vLineIds[1], frL2)) + return GDB_ID_NULL ; + pL1->LocToLoc( frL1, frLoc) ; + pL2->LocToLoc( frL2, frLoc) ; + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + + //recupero i punti e le direzioni + Point3d ptP1L, ptP2L, ptP3L, ptP4L ; + Vector3d vtL1, vtL2 ; + pL1->GetStartPoint( ptP1L) ; + pL1->GetEndPoint( ptP2L) ; + pL2->GetStartPoint( ptP3L) ; + pL2->GetEndPoint( ptP4L) ; + pL1->GetStartDir( vtL1) ; + pL2->GetStartDir( vtL2) ; + + // controllo se le rette sono coincidenti o parallele + if ( AreSameOrOppositeVectorApprox( vtL1, vtL2)) + return GDB_ID_NULL ; + + // verifico se le rette si intersecano già + Point3d ptP0L ; + IntersCurveCurve pInters( *pL1, *pL2) ; + IntCrvCrvInfo Info ; + int nNumeroInters = pInters.GetIntersCount() ; + // se non ho intersezioni estendo + if ( nNumeroInters == 0) { + double dLen = pow( 10, 5) ; + pL1->ExtendStartByLen( dLen) ; + pL2->ExtendStartByLen( dLen) ; + pL1->ExtendEndByLen( dLen) ; + pL2->ExtendEndByLen( dLen) ; + + //faccio intersezione + IntersCurveCurve pIntersExt( *pL1, *pL2) ; + nNumeroInters = pIntersExt.GetIntersCount() ; + + // le linee estese non si intersecano, quindi vuol dire che sono quasi parallele e lontanissime + if ( nNumeroInters == 0 ) + return GDB_ID_NULL ; + else { + pIntersExt.GetIntCrvCrvInfo( 0, Info) ; + // controllo che non siano coincidenti + if ( Info.bOverlap) + return false ; + else + ptP0L = Info.IciA->ptI ; + } + // seleziono i punti necessari + // se ptDimL è più vicino a ptP0L rispetto agli estremi esterni delle linee, allora tengo gli estremi interni + double dP1P0 = ( ptP1L - ptP0L ).Len() ; + double dP2P0 = ( ptP2L - ptP0L ).Len() ; + double dDimP0 = ( ptDimL - ptP0L ).Len() ; + if ( ( dDimP0 < dP1P0 || dDimP0 < dP2P0)) + // se uno dei due punti è più vicino a ptP0L rispetto a ptDimL, allora tengo il punto più vicino a ptDimL + ptP1L = ( ( ptDimL - ptP1L ).Len() < ( ptDimL - ptP2L ).Len() ? ptP1L : ptP2L) ; + else + ptP1L = ( dP1P0 < dP2P0 ? ptP2L : ptP1L ) ; + // rifaccio anche per l'altro lato + double dP3P0 = ( ptP3L - ptP0L).Len() ; + double dP4P0 = ( ptP4L - ptP0L).Len() ; + if ( dDimP0 < dP3P0 || dDimP0 < dP4P0 ) + ptP3L = ( ( ptDimL - ptP3L).Len() < ( ptDimL - ptP4L).Len() ? ptP3L : ptP4L ) ; + else + ptP3L = ( dP3P0 < dP4P0 ? ptP4L : ptP3L) ; + } + // se ho già intesezioni devo capire in quale quadrante si trova ptDim + else { + // recupero l'intersezione + pInters.GetIntCrvCrvInfo( 0, Info) ; + // controllo che non siano coincidenti + if ( Info.bOverlap) + return false ; + else + ptP0L = Info.IciA->ptI ; // se non coincidono restituisco l'intersezione + + // se le due linee hanno un estremo in comune, estendo le linee quel lato + if ( ( AreSamePointApprox( ptP0L, ptP1L) || AreSamePointApprox( ptP0L, ptP2L)) && + ( AreSamePointApprox( ptP0L, ptP3L) || AreSamePointApprox( ptP0L, ptP4L))) { + if ( AreSamePointApprox( ptP0L, ptP1L)) { + pL1->ExtendStartByLen(Dist( ptP1L, ptP2L) / 2) ; + pL1->GetStartPoint( ptP1L) ; + } + else { + pL1->ExtendEndByLen(Dist( ptP1L, ptP2L) / 2) ; + pL1->GetEndPoint( ptP2L) ; + } + if ( AreSamePointApprox( ptP0L, ptP3L) ) { + pL2->ExtendStartByLen(Dist( ptP3L, ptP4L) / 2); + pL2->GetStartPoint( ptP3L) ; + } + else { + pL2->ExtendEndByLen(Dist( ptP3L, ptP4L) / 2); + pL2->GetEndPoint( ptP4L) ; + } + } + + // seleziono i punti necessari + // proietto pdDim su vtLine1 e su vtLine2 + Point3d ptDim1, ptDim2 ; + DistPointCurve distPL1( ptDimL, *pL1, true) ; + DistPointCurve distPL2( ptDimL, *pL2, true) ; + int nFlag1, nFlag2 ; + if ( ! distPL1.GetMinDistPoint( 0, ptDim1, nFlag1) || ! distPL2.GetMinDistPoint( 0, ptDim2, nFlag2) ) + return false ; + if ( abs(( ptDim1 - ptP1L).Len() + ( ptP0L - ptDim1).Len() - ( ptP0L - ptP1L).Len()) < EPS_SMALL || + abs(( ptDim1 - ptP1L).Len() + ( ptP0L - ptP1L ).Len() - ( ptDim1 - ptP0L).Len()) < EPS_SMALL) + // ptDim è dal lato di ptP1L + ptP1L = ptP1L ; + else + // ptDim è dal lato di ptP2L + ptP1L = ptP2L ; + if ( abs(( ptDim2 - ptP3L).Len() + ( ptP0L - ptDim2).Len() - ( ptP0L - ptP3L).Len()) < EPS_SMALL || + abs(( ptDim2 - ptP3L).Len() + ( ptP0L - ptP3L).Len() - ( ptDim2 - ptP0L).Len()) < EPS_SMALL) + // ptDim è dal lato di ptP1L + ptP3L = ptP3L ; + else + // ptDim è dal lato di ptP2L + ptP3L = ptP4L ; + } + + + + + + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim ) || + ! MySetDimensionStyle( pDim ) || + ! pDim->SetAngular( ptP1L, ptP0L, ptP3L, ptDimL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateAngularDimensionFromLines( int nParentId, const INTVECTOR vLineIds, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateAngularDimensionFromLines( nParentId, vLineIds, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAngularDimensionFromLines(" + IdToString( nParentId) + "," + + ToString( vLineIds[0]) + "," + + ToString( vLineIds[1]) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateAngularDimensionFromArc( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + + //recupero l'arco e il suo frame + ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCurve == nullptr) + return GDB_ID_NULL ; + Frame3d frArc; + if ( ! pGeomDB->GetGlobFrame( nCrvId, frArc)) + return GDB_ID_NULL ; + + PtrOwner pCrv( pCurve->Clone()) ; + if ( IsNull( pCrv ) || ! pCrv->IsValid()) + return GDB_ID_NULL ; + + // porto tutto nel frLoc + pCrv->LocToLoc( frArc, frLoc ) ; + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + + //recupero i punti e i versori + Point3d ptP0L, ptP1L, ptP2L ; + pCrv->GetStartPoint( ptP1L) ; + pCrv->GetEndPoint( ptP2L) ; + pCrv->GetCenterPoint( ptP0L) ; + + // porto ptDimL nell'area di influenza dell'arco + Point3d ptDimNew ; + double dDist = ( ptDimL - ptP0L).Len() ; + Point3d ptMid ; + pCrv->GetMidPoint( ptMid) ; + Vector3d vtDir = ( ptMid - ptP0L) ; + vtDir.Normalize() ; + ptDimNew = ptP0L + dDist * vtDir ; + // proietto il punto sul piano XY della griglia + Frame3d frGrid = pGeomDB->GetGridFrame() ; + if ( ! frGrid.IsValid()) + return GDB_ID_NULL ; + Point3d ptOrig = frGrid.Orig() ; + ptDimNew -= ( ptDimNew - ptOrig) * vtNL * vtNL; + + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim ) || + ! MySetDimensionStyle( pDim) || + ! pDim->SetAngular( ptP1L, ptP0L, ptP2L, ptDimNew, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateAngularDimensionFromArc( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateAngularDimensionFromArc( nParentId, nCrvId, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAngularDimensionFromArc(" + IdToString( nParentId) + "," + + IdToString( nCrvId) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateAngularDimensionFromCircle( int nParentId, int nCrvId, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId ) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + + //recupero il cerchio e il suo frame + ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCurve == nullptr) + return GDB_ID_NULL ; + Frame3d frCrv; + if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) + return GDB_ID_NULL ; + + PtrOwner pCrv( pCurve->Clone()) ; + if ( IsNull( pCrv ) || ! pCrv->IsValid()) + return GDB_ID_NULL ; + + // porto tutto nel frLoc + pCrv->LocToLoc( frCrv, frLoc ) ; + Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ; + Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ; + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + + //recupero il centro + Point3d ptP0L ; + pCrv->GetCenterPoint( ptP0L) ; + + // verifico che i punti P1 e P2 siano sul cerchio, sennò prendo i più vicini + if ( ! pCrv->IsPointOn(ptP1L)) { + DistPointCurve distPC( ptP1L, *pCrv) ; + int nFlag ; + distPC.GetMinDistPoint(0,ptP1L,nFlag); + } + if ( ! pCrv->IsPointOn(ptP2L)) { + DistPointCurve distPC(ptP2L, *pCrv) ; + int nFlag ; + distPC.GetMinDistPoint(0, ptP2L, nFlag); + } + + // proietto il punto sul piano XY della griglia + Frame3d frGrid = pGeomDB->GetGridFrame() ; + if ( ! frGrid.IsValid()) + return GDB_ID_NULL ; + Point3d ptOrig = frGrid.Orig() ; + ptDimL -= ( ptDimL - ptOrig) * vtNL * vtNL; + + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim) || + ! MySetDimensionStyle( pDim) || + ! pDim->SetAngular( ptP1L, ptP0L, ptP2L, ptDimL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateAngularDimensionFromCircle( int nParentId, int nCrvId, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateAngularDimensionFromCircle( nParentId, nCrvId, ptP1, ptP2, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtAngularDimensionFromCircle(" + IdToString( nParentId) + "," + + IdToString( nCrvId) + ",{" + + ToString( ptP1) + "},'" + + ToString( ptP2) + "},'" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + + //recupero il cerchio e il suo frame + ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCurve == nullptr) + return GDB_ID_NULL ; + Frame3d frCrv; + if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) + return GDB_ID_NULL ; + + PtrOwner pCrv( pCurve->Clone()) ; + if ( IsNull( pCrv ) || ! pCrv->IsValid()) + return GDB_ID_NULL ; + + // porto tutto nel frLoc + pCrv->LocToLoc( frCrv, frLoc ) ; + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + Vector3d vtXL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ; + + //recupero il centro e il raggio + Point3d ptP0L ; + double dRad = pCrv->GetRadius() ; + pCrv->GetCenterPoint( ptP0L) ; + + // porto ptDimL sul cerchio + Point3d ptDimNew ; + Vector3d vtDir = ptDimL - ptP0L ; + vtDir.Normalize() ; + ptDimNew = ptP0L + dRad * vtDir ; + + // proietto il punto sul piano XY della griglia + Frame3d frGrid = pGeomDB->GetGridFrame() ; + if ( ! frGrid.IsValid()) + return GDB_ID_NULL ; + Point3d ptOrig = frGrid.Orig() ; + ptDimNew -= ( ptDimNew - ptOrig) * vtNL * vtNL; + + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim) || + ! MySetDimensionStyle( pDim) || + ! pDim->SetRadial( ptP0L, ptDimNew, vtXL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateRadialDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtRadialDimension(" + IdToString( nParentId) + "," + + IdToString( nCrvId) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} + +//------------------------------------------------------------------------------- +static int +MyCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + + //recupero il cerchio e il suo frame + ICurveArc* pCurve = GetCurveArc( pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCurve == nullptr) + return GDB_ID_NULL ; + Frame3d frCrv; + if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv)) + return GDB_ID_NULL ; + + PtrOwner pCrv( pCurve->Clone()) ; + if ( IsNull( pCrv ) || ! pCrv->IsValid()) + return GDB_ID_NULL ; + + // porto tutto nel frLoc + pCrv->LocToLoc( frCrv, frLoc ) ; + Point3d ptDimL = GetPointLocal( pGeomDB, ptDim, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ; + Vector3d vtXL = GetVectorLocal( pGeomDB, X_AX, nRefType, frLoc) ; + + //recupero il centro e il raggio + Point3d ptP0L ; + double dRad = pCrv->GetRadius() ; + pCrv->GetCenterPoint( ptP0L) ; + + // porto ptDimL sul cerchio se non lo è già + Point3d ptDimNew ; + if ( pCrv->IsPointOn(ptDim)) + ptDimNew = ptDim ; + else { + Vector3d vtDir = ptDimL - ptP0L ; + vtDir.Normalize() ; + ptDimNew = ptP0L + dRad * vtDir ; + } + + // proietto il punto sul piano XY della griglia + Frame3d frGrid = pGeomDB->GetGridFrame() ; + if ( ! frGrid.IsValid()) + return GDB_ID_NULL ; + Point3d ptOrig = frGrid.Orig() ; + ptDimNew -= ( ptDimNew - ptOrig) * vtNL * vtNL; + + // creo la quota + PtrOwner pDim( CreateExtDimension()) ; + if ( IsNull( pDim) || + ! MySetDimensionStyle( pDim) || + ! pDim->SetDiametral( ptP0L, ptDimNew, vtXL, vtNL, sText)) + return GDB_ID_NULL ; + // inserisco la quota nel DB + return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pDim)) ; +} + +//------------------------------------------------------------------------------- +int +ExeCreateDiametralDimension( int nParentId, int nCrvId, const Point3d& ptDim, + const string& sText, int nRefType) +{ + // eseguo + int nId = MyCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtDiametralDimension(" + IdToString( nParentId) + "," + + IdToString( nCrvId) + ",{" + + ToString( ptDim) + "},'" + + StringToLuaString( sText) + "'," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo del oggetto + return nId ; +} \ No newline at end of file diff --git a/LUA_GdbCreate.cpp b/LUA_GdbCreate.cpp index 32e8c25..b27e058 100644 --- a/LUA_GdbCreate.cpp +++ b/LUA_GdbCreate.cpp @@ -344,6 +344,165 @@ LuaCreateAlignedDimension( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateAngularDimension(lua_State* L) +{ + // 6 o 7 parametri : ParentId, ptP1, ptP0, ptP2, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d ptP1 ; + LuaCheckParam( L, 2, ptP1) ; + Point3d ptP0 ; + LuaCheckParam( L, 3, ptP0) ; + Point3d ptP2 ; + LuaCheckParam( L, 4, ptP2) ; + Point3d ptDim ; + LuaCheckParam( L, 5, ptDim) ; + string sText ; + LuaCheckParam( L, 6, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 7, nRefType) ; + LuaClearStack( L) ; + // creo la quota angolare + int nId = ExeCreateAngularDimension( nParentId, ptP1, ptP0, ptP2, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +static int +LuaCreateAngularDimensionFromLines( lua_State* L) +{ + // 4 o 5 parametri : nParentId, vLineIds, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vLineIds ; + LuaCheckParam( L, 2, vLineIds) ; + Point3d ptDim ; + LuaCheckParam( L, 3, ptDim) ; + string sText ; + LuaCheckParam( L, 4, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L ) ; + // creo la quota allineata + int nId = ExeCreateAngularDimensionFromLines( nParentId, vLineIds, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L ) ; + return 1 ; +} + +static int +LuaCreateAngularDimensionFromArc( lua_State* L) +{ + // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nCrvId ; + LuaCheckParam( L, 2, nCrvId) ; + Point3d ptDim ; + LuaCheckParam( L, 3, ptDim) ; + string sText ; + LuaCheckParam( L, 4, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // creo la quota allineata + int nId = ExeCreateAngularDimensionFromArc( nParentId, nCrvId, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +static int +LuaCreateAngularDimensionFromCircle( lua_State* L) +{ + // 6 o 7 parametri : nParentId, nCrvId, ptP1, ptP2, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nCrvId ; + LuaCheckParam( L, 2, nCrvId) ; + Point3d ptP1 ; + LuaCheckParam( L, 3, ptP1) ; + Point3d ptP2 ; + LuaCheckParam( L, 4, ptP2) ; + Point3d ptDim ; + LuaCheckParam( L, 5, ptDim) ; + string sText ; + LuaCheckParam( L, 6, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 7, nRefType) ; + LuaClearStack( L) ; + // creo la quota allineata + int nId = ExeCreateAngularDimensionFromCircle( nParentId, nCrvId, ptP1, ptP2, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +static int +LuaCreateRadialDimension( lua_State* L) +{ + // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nCrvId ; + LuaCheckParam( L, 2, nCrvId) ; + Point3d ptDim ; + LuaCheckParam( L, 3, ptDim) ; + string sText ; + LuaCheckParam( L, 4, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L ) ; + // creo la quota allineata + int nId = ExeCreateRadialDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + +static int +LuaCreateDiametralDimension( lua_State* L ) +{ + // 4 o 5 parametri : nParentId, nCrvId, ptDim, Text [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + int nCrvId ; + LuaCheckParam( L, 2, nCrvId) ; + Point3d ptDim ; + LuaCheckParam( L, 3, ptDim) ; + string sText ; + LuaCheckParam( L, 4, sText) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // creo la quota allineata + int nId = ExeCreateDiametralDimension( nParentId, nCrvId, ptDim, sText, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- bool LuaInstallGdbCreate( LuaMgr& luaMgr) @@ -361,5 +520,11 @@ LuaInstallGdbCreate( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtHorizontalDimension", LuaCreateHorizontalDimension) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVerticalDimension", LuaCreateVerticalDimension) ; bOk = bOk && luaMgr.RegisterFunction( "EgtAlignedDimension", LuaCreateAlignedDimension) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimension", LuaCreateAngularDimension); + bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimensionFromLines", LuaCreateAngularDimensionFromLines) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimensionFromArc", LuaCreateAngularDimensionFromArc) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAngularDimensionFromCircle", LuaCreateAngularDimensionFromCircle) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtRadialDimension", LuaCreateRadialDimension) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtDiametralDimension", LuaCreateDiametralDimension) ; return bOk ; }