diff --git a/API.h b/API.h index aa99f58..766f05f 100644 --- a/API.h +++ b/API.h @@ -28,7 +28,7 @@ bool __stdcall EgtGetVersionInfo( std::string& sVer, const char* szNewLine) ; //--------------------------- GeomDB ----------------------------------------- bool __stdcall EgtSetGridFrame( const Frame3d& frFrame) ; -bool __stdcall EgtGetGridFrame( Frame3d& frFrame) ; +bool __stdcall EgtGetGridFrame( int nRefId, Frame3d& frFrame) ; bool __stdcall EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) ; bool __stdcall EgtOpenFile( const std::string& sFilePath) ; bool __stdcall EgtImportFile( const std::string& sFilePath) ; @@ -36,12 +36,12 @@ bool __stdcall EgtSaveFile( const std::string& sFilePath, int nFlag) ; //--------------------------- GeomDBCreate ----------------------------------- int __stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, - const std::string& sText, double dH) ; + const std::string& sText, double dH, int nRefType) ; int __stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, - const std::string& sText, const std::string& sFont, bool bItalic, double dH) ; + const std::string& sText, const std::string& sFont, bool bItalic, double dH, int nRefType) ; int __stdcall EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, const std::string& sText, const std::string& sFont, - int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos) ; + int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType) ; //--------------------------- GeomDBCreateCurve ------------------------------ int __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt) ; @@ -94,11 +94,12 @@ bool __stdcall EgtVectorToIdGlob( Vector3d& vtV, int nId) ; bool __stdcall EgtVectorToIdLoc( Vector3d& vtV, int nId) ; //--------------------------- Scene ------------------------------------------ -BOOL __stdcall EgtSetBackground( Color TopCol, Color BottomCol, BOOL bRedraw) ; -BOOL __stdcall EgtSetMarkAttribs( Color MarkCol) ; -BOOL __stdcall EgtSetSelSurfAttribs( Color SelSurfCol) ; -BOOL __stdcall EgtSetGeoLineAttribs( Color GlCol) ; -BOOL __stdcall EgtSetWinRectAttribs( BOOL bOutline, Color WrCol) ; +bool __stdcall EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) ; +bool __stdcall EgtSetMarkAttribs( Color MarkCol) ; +bool __stdcall EgtSetSelSurfAttribs( Color SelSurfCol) ; +bool __stdcall EgtSetGeoLineAttribs( Color GlCol) ; +bool __stdcall EgtSetGeoTriaAttribs( Color GtCol) ; +bool __stdcall EgtSetWinRectAttribs( bool bOutline, Color WrCol) ; //--------------------------- Exchange --------------------------------------- int __stdcall EgtGetFileType( const std::string& sFilePath) ; diff --git a/API_GdbCreate.cpp b/API_GdbCreate.cpp index a7cede5..d08434f 100644 --- a/API_GdbCreate.cpp +++ b/API_GdbCreate.cpp @@ -17,6 +17,7 @@ #include "API_Macro.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" #include "/EgtDev/Include/EgkGeoVector3d.h" #include "/EgtDev/Include/EgkExtText.h" @@ -29,16 +30,37 @@ using namespace std ; //------------------------------------------------------------------------------- int __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3], - const double vX[3], const double vY[3], const double vZ[3]) + const double vX[3], const double vY[3], const double vZ[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale l'origine e i versori + Point3d ptOrigL( ptOrig) ; + Vector3d vtXL( vX) ; + Vector3d vtYL( vY) ; + Vector3d vtZL( vZ) ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptOrigL.ToLoc( frLoc) ; + vtXL.ToLoc( frLoc) ; + vtYL.ToLoc( frLoc) ; + vtZL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptOrigL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtXL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtYL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtZL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // costruisco il riferimento Frame3d frFrame ; - if ( ! frFrame.Set( ptOrig, vX, vY, vZ)) - return GDB_ID_NULL ; + bOk = bOk && frFrame.Set( ptOrigL, vtXL, vtYL, vtZL) ; // creo il gruppo - int nId = pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrame) ; + int nId = ( bOk ? pGeomDB->AddGroup( GDB_ID_NULL, nParentId, frFrame) : GDB_ID_NULL) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; @@ -50,7 +72,8 @@ __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3], ToString( Point3d( ptOrig)) + "},{" + ToString( Vector3d( vX)) + "},{" + ToString( Vector3d( vY)) + "},{" + - ToString( Vector3d( vZ)) + "}})" + + ToString( Vector3d( vZ)) + "}}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -60,23 +83,35 @@ __stdcall EgtCreateGroup( int nParentId, const double ptOrig[3], //------------------------------------------------------------------------------- int -__stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3]) +__stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale il punto + Point3d ptPL( ptP) ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptPL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // creo il punto PtrOwner pGeoPnt( CreateGeoPoint3d()) ; - if ( IsNull( pGeoPnt)) - return GDB_ID_NULL ; + bOk = bOk && ! IsNull( pGeoPnt) ; // setto il punto - if ( ! pGeoPnt->Set( ptP)) - return GDB_ID_NULL ; + bOk = bOk && pGeoPnt->Set( ptPL) ; // inserisco il punto nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoPnt)) : GDB_ID_NULL) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtPoint(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptP)) + "})" + + ToString( Point3d( ptP)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -86,30 +121,46 @@ __stdcall EgtCreateGeoPoint( int nParentId, const double ptP[3]) //------------------------------------------------------------------------------- int -__stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double ptB[3]) +__stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double ptB[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale il vettore e il punto + Vector3d vtVL( vtV) ; + Point3d ptBL( ptB) ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + vtVL.ToLoc( frLoc) ; + ptBL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + vtVL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptBL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // creo il vettore PtrOwner pGeoVct( CreateGeoVector3d()) ; - if ( IsNull( pGeoVct)) - return GDB_ID_NULL ; + bOk = bOk && ! IsNull( pGeoVct) ; // setto il vettore (con il punto base) - if ( ! pGeoVct->Set( vtV, ptB)) - return GDB_ID_NULL ; + bOk = bOk && pGeoVct->Set( vtVL, ptBL) ; // inserisco il vettore nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoVct)) : GDB_ID_NULL) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua ; if ( Point3d( ptB).IsSmall()) sLua = "EgtVector(" + ToString( nParentId) + ",{" + - ToString( Vector3d( vtV)) + "})" + + ToString( Vector3d( vtV)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; else sLua = "EgtVector(" + ToString( nParentId) + ",{" + ToString( Vector3d( vtV)) + "},{" + - ToString( Point3d( ptB)) + "})" + + ToString( Point3d( ptB)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -120,26 +171,46 @@ __stdcall EgtCreateGeoVector( int nParentId, const double vtV[3], const double p //------------------------------------------------------------------------------- int __stdcall EgtCreateGeoFrame( int nParentId, const double ptOrig[3], - const double vX[3], const double vY[3], const double vZ[3]) + const double vX[3], const double vY[3], const double vZ[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo il riferimento + bool bOk = true ; + // porto in locale l'origine e i versori + Point3d ptOrigL( ptOrig) ; + Vector3d vtXL( vX) ; + Vector3d vtYL( vY) ; + Vector3d vtZL( vZ) ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptOrigL.ToLoc( frLoc) ; + vtXL.ToLoc( frLoc) ; + vtYL.ToLoc( frLoc) ; + vtZL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptOrigL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtXL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtYL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtZL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } + // creo e setto il riferimento PtrOwner pGeoFrm( CreateGeoFrame3d()) ; - if ( IsNull( pGeoFrm)) - return GDB_ID_NULL ; - // setto il riferimento - if ( ! pGeoFrm->Set( ptOrig, vX, vY, vZ)) - return GDB_ID_NULL ; + bOk = bOk & ! IsNull( pGeoFrm) ; + bOk = bOk & pGeoFrm->Set( ptOrigL, vtXL, vtYL, vtZL) ; // inserisco il riferimento nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pGeoFrm)) : GDB_ID_NULL) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtFrame(" + ToString( nParentId) + ",{{" + ToString( Point3d( ptOrig)) + "},{" + ToString( Vector3d( vX)) + "},{" + ToString( Vector3d( vY)) + "},{" + - ToString( Vector3d( vZ)) + "}})" + + ToString( Vector3d( vZ)) + "}}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -150,21 +221,41 @@ __stdcall EgtCreateGeoFrame( int nParentId, const double ptOrig[3], //------------------------------------------------------------------------------- int __stdcall EgtCreateText( int nParentId, const double ptP[3], double dAngRotDeg, - const wchar_t* wsText, double dH) + const wchar_t* wsText, double dH, int nRefType) { - return EgtCreateText( nParentId, ptP, dAngRotDeg, wstrztoA( wsText), dH) ; + return EgtCreateText( nParentId, ptP, dAngRotDeg, wstrztoA( wsText), dH, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, - const string& sText, double dH) + const string& sText, double dH, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale l'origine e i versori + Point3d ptPL( ptP) ; + Vector3d vtNL = Z_AX ; + Vector3d vtDL = X_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptPL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtDL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtDL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // creo il testo e lo riempio PtrOwner pTXT( CreateExtText()) ; - bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, dAngRotDeg, sText, dH)) ; + 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) ; // se richiesto, salvo il comando Lua equivalente @@ -173,7 +264,8 @@ __stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, ToString( ptP) + "}," + ToString( dAngRotDeg) + ",'" + sText + "','" + - ToString( dH) + ")" + + ToString( dH) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -184,23 +276,42 @@ __stdcall EgtCreateText( int nParentId, const Point3d& ptP, double dAngRotDeg, //------------------------------------------------------------------------------- int __stdcall EgtCreateTextEx( int nParentId, const double ptP[3], const double vtN[3], const double vtD[3], - const wchar_t* wsText, const wchar_t* wsFont, BOOL bItalic, double dH) + const wchar_t* wsText, const wchar_t* wsFont, BOOL bItalic, double dH, int nRefType) { return EgtCreateTextEx( nParentId, ptP, vtN, vtD, - wstrztoA( wsText), wstrztoA( wsFont), (bItalic != FALSE), dH) ; + wstrztoA( wsText), wstrztoA( wsFont), (bItalic != FALSE), dH, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, - const string& sText, const string& sFont, bool bItalic, double dH) + const string& sText, const string& sFont, bool bItalic, double dH, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale l'origine e i versori + Point3d ptPL( ptP) ; + Vector3d vtNL( vtN) ; + Vector3d vtDL( vtD) ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptPL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtDL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtDL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // creo il testo e lo riempio PtrOwner pTXT( CreateExtText()) ; - //bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, dAngRotDeg, sText, dH)) ; - bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, vtN, vtD, sText, sFont, bItalic, dH)) ; + 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) ; // se richiesto, salvo il comando Lua equivalente @@ -212,7 +323,8 @@ __stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vt sText + "','" + sFont + "'," + ( bItalic ? "'I'" : "'S'") + "," + - ToString( dH) + ")" + + ToString( dH) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -224,24 +336,44 @@ __stdcall EgtCreateTextEx( int nParentId, const Point3d& ptP, const Vector3d& vt int __stdcall EgtCreateTextAdv( int nParentId, const double ptP[3], const double vtN[3], const double vtD[3], const wchar_t* wsText, const wchar_t* wsFont, - int nW, BOOL bItalic, double dH, double dRat, double dAddAdv, int nInsPos) + int nW, BOOL bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType) { return EgtCreateTextAdv( nParentId, ptP, vtN, vtD, wstrztoA( wsText), wstrztoA( wsFont), - nW, ( bItalic != FALSE), dH, dRat, dAddAdv, nInsPos) ; + nW, ( bItalic != FALSE), dH, dRat, dAddAdv, nInsPos, nRefType) ; } //------------------------------------------------------------------------------- int __stdcall EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD, const string& sText, const string& sFont, - int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos) + int nW, bool bItalic, double dH, double dRat, double dAddAdv, int nInsPos, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale l'origine e i versori + Point3d ptPL( ptP) ; + Vector3d vtNL( vtN) ; + Vector3d vtDL( vtD) ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptPL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtDL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptPL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtDL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // creo il testo e lo imposto PtrOwner pTXT( CreateExtText()) ; - bool bOk = ( ! IsNull( pTXT) && pTXT->Set( ptP, vtN, vtD, sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos)) ; + 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) ; // se richiesto, salvo il comando Lua equivalente @@ -257,7 +389,8 @@ __stdcall EgtCreateTextAdv( int nParentId, const Point3d& ptP, const Vector3d& v ToString( dH) + "," + ToString( dRat) + "," + ToString( dAddAdv) + "," + - ETxtInsPosToString( nInsPos) + ")" + + ETxtInsPosToString( nInsPos) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index 789d795..34274a4 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -53,7 +53,7 @@ static bool __stdcall SetExtrusionFromGridVersZ( IGeomDB* pGeomDB, int nParentId //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double ptFin[3]) +__stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double ptFin[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -61,19 +61,38 @@ __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double PtrOwner pCrvLine( CreateCurveLine()) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; + // porto in locale i punti e il versore estrusione + Point3d ptIniL( ptIni) ; + Point3d ptFinL( ptFin) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptIniL.ToLoc( frLoc) ; + ptFinL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptFinL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // setto la linea - if ( ! pCrvLine->Set( ptIni, ptFin)) + if ( ! pCrvLine->Set( ptIniL, ptFinL)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine))) - return GDB_ID_NULL ; + pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtLine(" + ToString( nParentId) + ",{" + ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptFin)) + "})" + + ToString( Point3d( ptFin)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -84,83 +103,102 @@ __stdcall EgtCreateCurveLine( int nParentId, const double ptIni[3], const double //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, int nIdI, - const double ptFin[3], int nSepF, int nIdF) + const double ptFin[3], int nSepF, int nIdF, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // puntatore alla linea PtrOwner pCrvLine ; + // porto in locale i punti e il versore estrusione + Point3d ptIniL( ptIni) ; + Point3d ptFinL( ptFin) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptIniL.ToLoc( frLoc) ; + ptFinL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptFinL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // 1 - se punti entrambi definiti if ( nSepI == SEP_STD && nSepF == SEP_STD) { pCrvLine.Set( CreateCurveLine()) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; - if ( ! pCrvLine->Set( ptIni, ptFin)) + if ( ! pCrvLine->Set( ptIniL, ptFinL)) return GDB_ID_NULL ; } // 2 - se primo punto definito e secondo a minima distanza else if ( nSepI == SEP_STD && nSepF == SEP_MINDIST) { - pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptIni, ptFin, nIdF)) ; + pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; } // 3 - se primo punto a minima distanza e secondo definito else if ( nSepI == SEP_MINDIST && nSepF == SEP_STD) { - pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptFin, ptIni, nIdI)) ; + pCrvLine.Set( CreateLinePointMinDistCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; pCrvLine->Invert() ; } // 4 - se primo punto definito e secondo tangente else if ( nSepI == SEP_STD && nSepF == SEP_TG) { - pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptIni, ptFin, nIdF)) ; + pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; } // 5 - se primo punto tangente e secondo definito else if ( nSepI == SEP_TG && nSepF == SEP_STD) { // costruisco la curva al contrario e poi la inverto - pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptFin, ptIni, nIdI)) ; + pCrvLine.Set( CreateLinePointTgCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; pCrvLine->Invert() ; } // 6 - se entrambi i punti tangenti else if ( nSepI == SEP_TG && nSepF == SEP_TG) { - pCrvLine.Set( CreateLineTgTwoCurves( pGeomDB, nParentId, ptIni, nIdI, ptFin, nIdF)) ; + pCrvLine.Set( CreateLineTgTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; } // 7 - se primo punto definito e secondo perpendicolare else if ( nSepI == SEP_STD && nSepF == SEP_PERP) { - pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptIni, ptFin, nIdF)) ; + pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptIniL, ptFinL, nIdF)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; } // 8 - se primo punto perpendicolare e secondo definito else if ( nSepI == SEP_PERP && nSepF == SEP_STD) { // costruisco la curva al contrario e poi la inverto - pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptFin, ptIni, nIdI)) ; + pCrvLine.Set( CreateLinePointPerpCurve( pGeomDB, nParentId, ptFinL, ptIniL, nIdI)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; pCrvLine->Invert() ; } // 9 - se entrambi i punti perpendicolari else if ( nSepI == SEP_PERP && nSepF == SEP_PERP) { - pCrvLine.Set( CreateLinePerpTwoCurves( pGeomDB, nParentId, ptIni, nIdI, ptFin, nIdF)) ; + pCrvLine.Set( CreateLinePerpTwoCurves( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; } // 10 - se primo punto tangente e secondo perpendicolare else if ( nSepI == SEP_TG && nSepF == SEP_PERP) { - pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptIni, nIdI, ptFin, nIdF)) ; + pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptIniL, nIdI, ptFinL, nIdF)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; } // 11 - se primo punto perpendicolare e secondo tangente else if ( nSepI == SEP_PERP && nSepF == SEP_TG) { // costruisco la curva al contrario e poi la inverto - pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptFin, nIdF, ptIni, nIdI)) ; + pCrvLine.Set( CreateLineTgCurvePerpCurve( pGeomDB, nParentId, ptFinL, nIdF, ptIniL, nIdI)) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; pCrvLine->Invert() ; @@ -170,8 +208,7 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, return GDB_ID_NULL ; } // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine))) - return GDB_ID_NULL ; + pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; // se richiesto, salvo il comando Lua equivalente @@ -180,7 +217,8 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, if ( nSepI == SEP_STD && nSepF == SEP_STD) sLua = "EgtLine(" + ToString( nParentId) + ",{" + ToString( Point3d( ptIni)) + "},{" + - ToString( Point3d( ptFin)) + "})" + + ToString( Point3d( ptFin)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; else sLua = "EgtLineEx(" + ToString( nParentId) + ",{" + @@ -189,7 +227,8 @@ __stdcall EgtCreateCurveLineEx( int nParentId, const double ptIni[3], int nSepI, ToString( nIdI) + ",{" + ToString( Point3d( ptFin)) + "}," + SepToString( nSepF) + "," + - ToString( nIdF) + ")" + + ToString( nIdF) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -460,20 +499,39 @@ __stdcall CreateLineTgCurvePerpCurve( IGeomDB* pGeomDB, int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const double vtDir[3], double dLen) +__stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], + const double vtDir[3], double dLen, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // porto in locale i punti e il versore estrusione + Point3d ptIniL( ptIni) ; + Vector3d vtDirL( vtDir) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptIniL.ToLoc( frLoc) ; + vtDirL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtDirL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // creo la linea PtrOwner pCrvLine( CreateCurveLine()) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; // setto la linea - if ( ! pCrvLine->SetPVL( ptIni, vtDir, dLen)) + if ( ! pCrvLine->SetPVL( ptIniL, vtDirL, dLen)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine))) - return GDB_ID_NULL ; + pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; // se richiesto, salvo il comando Lua equivalente @@ -481,7 +539,8 @@ __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const dou string sLua = "EgtLinePVL(" + ToString( nParentId) + ",{" + ToString( Point3d( ptIni)) + "},{" + ToString( Vector3d( vtDir)) + "}," + - ToString( dLen) + ")" + + ToString( dLen) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -492,14 +551,25 @@ __stdcall EgtCreateCurveLinePVL( int nParentId, const double ptIni[3], const dou //------------------------------------------------------------------------------- int __stdcall EgtCreateCurveLineMinPointCurve( int nParentId, - const double ptStart[3], int nCrvId, double dNearPar) + const double ptStart[3], int nCrvId, double dNearPar, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il riferimento del gruppo destinazione - Frame3d frPoint ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frPoint)) + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) return GDB_ID_NULL ; + // porto in locale il punto e il versore estrusione + Point3d ptStartL( ptStart) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType == RTY_GLOB) { + ptStartL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else if ( nRefType == RTY_GRID) { + ptStartL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } // recupero il riferimento della curva Frame3d frCurve ; if ( ! pGeomDB->GetGlobFrame( nCrvId, frCurve)) @@ -509,26 +579,25 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId, if ( pCurve == nullptr) return GDB_ID_NULL ; // porto il punto nel riferimento della curva - Point3d ptSloc = ptStart ; - ptSloc.LocToLoc( frPoint, frCurve) ; + Point3d ptStartC = ptStart ; + ptStartC.LocToLoc( frLoc, frCurve) ; // calcolo il punto a minima distanza int nFlag ; - Point3d ptEnd ; - DistPointCurve dstPtCurve( ptSloc, *pCurve) ; - if ( ! dstPtCurve.GetMinDistPoint( dNearPar, ptEnd, nFlag)) + Point3d ptEndL ; + DistPointCurve dstPtCurve( ptStartC, *pCurve) ; + if ( ! dstPtCurve.GetMinDistPoint( dNearPar, ptEndL, nFlag)) return GDB_ID_NULL ; // porto il punto finale nel riferimento di creazione - ptEnd.LocToLoc( frCurve, frPoint) ; + ptEndL.LocToLoc( frCurve, frLoc) ; // creo la linea PtrOwner pCrvLine( CreateCurveLine()) ; if ( IsNull( pCrvLine)) return GDB_ID_NULL ; // setto la linea - if ( ! pCrvLine->Set( ptStart, ptEnd)) + if ( ! pCrvLine->Set( ptStartL, ptEndL)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvLine))) - return GDB_ID_NULL ; + pCrvLine->SetExtrusion( vtExtrL) ; // inserisco la linea nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; // se richiesto, salvo il comando Lua equivalente @@ -536,7 +605,8 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId, string sLua = "EgtLineMinPointCurve(" + ToString( nParentId) + ",{" + ToString( Point3d( ptStart)) + "}," + ToString( nCrvId) + "," + - ToString( dNearPar) + ")" + + ToString( dNearPar) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -546,8 +616,8 @@ __stdcall EgtCreateCurveLineMinPointCurve( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveCircle( int nParentId, - const double ptCen[3], const double vtN[3], double dRad) +__stdcall EgtCreateCurveCircle( int nParentId, const double ptCen[3], + const double vtN[3], double dRad, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -555,27 +625,39 @@ __stdcall EgtCreateCurveCircle( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; + // porto in locale il centro, la normale e il versore estrusione + Point3d ptCenL( ptCen) ; + Vector3d vtNL( vtN) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptCenL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // setto la circonferenza - if ( ! pCrvArc->Set( ptCen, vtN, dRad)) + if ( ! pCrvArc->Set( ptCenL, vtNL, dRad)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua ; - if ( Vector3d( vtN).IsZplus()) - sLua = "EgtCircleXY(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "}," + - ToString( dRad) + ")" + - " -- Id=" + ToString( nId) ; - else - sLua = "EgtCircle(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "},{" + - ToString( Vector3d( vtN)) + "}," + - ToString( dRad) + ")" + + string sLua = "EgtCircle(" + ToString( nParentId) + ",{" + + ToString( Point3d( ptCen)) + "},{" + + ToString( Vector3d( vtN)) + "}," + + ToString( dRad) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -585,8 +667,8 @@ __stdcall EgtCreateCurveCircle( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveCircleXY( int nParentId, - const double ptCen[3], double dRad) +__stdcall EgtCreateCurveCircleCPN( int nParentId, const double ptCen[3], + const double ptOn[3], const double vtN[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -594,45 +676,35 @@ __stdcall EgtCreateCurveCircleXY( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; - // setto la circonferenza - if ( ! pCrvArc->SetXY( ptCen, dRad)) - return GDB_ID_NULL ; - // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; - // inserisco l'arco nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtCircleXY(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "}," + - ToString( dRad) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + // porto in locale i punti, i versori e il versore estrusione + Point3d ptCenL( ptCen) ; + Point3d ptOnL( ptOn) ; + Vector3d vtNL( vtN) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptCenL.ToLoc( frLoc) ; + ptOnL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptOnL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } } - // restituisco l'identificativo della nuova entità - return nId ; -} - -//------------------------------------------------------------------------------- -int -__stdcall EgtCreateCurveCircleCPN( int nParentId, - const double ptCen[3], const double ptOn[3], const double vtN[3]) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - if ( IsNull( pCrvArc)) - return GDB_ID_NULL ; // calcolo il raggio - double dRad = (( Point3d( ptOn) - Point3d( ptCen)) ^ Vector3d( vtN)).Len() ; + double dRad = (( ptOnL - ptCenL) ^ vtNL).Len() ; // setto la circonferenza - if ( ! pCrvArc->Set( ptCen, vtN, dRad)) + if ( ! pCrvArc->Set( ptCenL, vtNL, dRad)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; // se richiesto, salvo il comando Lua equivalente @@ -640,7 +712,8 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId, string sLua = "EgtCircleCPN(" + ToString( nParentId) + ",{" + ToString( Point3d( ptCen)) + "},{" + ToString( Point3d( ptOn)) + "},{" + - ToString( Vector3d( vtN)) + "})" + + ToString( Vector3d( vtN)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -650,8 +723,8 @@ __stdcall EgtCreateCurveCircleCPN( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveCircle3P( int nParentId, - const double ptP1[3], const double ptP2[3], const double ptP3[3]) +__stdcall EgtCreateCurveCircle3P( int nParentId, const double ptP1[3], + const double ptP2[3], const double ptP3[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -659,12 +732,33 @@ __stdcall EgtCreateCurveCircle3P( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; + // porto in locale i punti e il versore estrusione + Point3d ptP1L( ptP1) ; + Point3d ptP2L( ptP2) ; + Point3d ptP3L( ptP3) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptP1L.ToLoc( frLoc) ; + ptP2L.ToLoc( frLoc) ; + ptP3L.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptP1L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptP2L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptP3L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // setto l'arco - if ( ! pCrvArc->Set3P( ptP1, ptP2, ptP3, true)) + if ( ! pCrvArc->Set3P( ptP1L, ptP2L, ptP3L, true)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; // se richiesto, salvo il comando Lua equivalente @@ -672,7 +766,8 @@ __stdcall EgtCreateCurveCircle3P( int nParentId, string sLua = "EgtCircle3P(" + ToString( nParentId) + ",{" + ToString( Point3d( ptP1)) + "},{" + ToString( Point3d( ptP2)) + "},{" + - ToString( Point3d( ptP3)) + "})" + + ToString( Point3d( ptP3)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -684,7 +779,7 @@ __stdcall EgtCreateCurveCircle3P( int nParentId, int __stdcall EgtCreateCurveArc( int nParentId, const double ptCen[3], const double vtN[3], double dRad, - const double vtS[3], double dAngCenDeg, double dDeltaN) + const double vtS[3], double dAngCenDeg, double dDeltaN, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -692,12 +787,33 @@ __stdcall EgtCreateCurveArc( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; + // porto in locale i punti, i versori e il versore estrusione + Point3d ptCenL( ptCen) ; + Vector3d vtNL( vtN) ; + Vector3d vtSL( vtS) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptCenL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtSL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtSL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } // setto l'arco - if ( ! pCrvArc->Set( ptCen, vtN, dRad, vtS, dAngCenDeg, dDeltaN)) + if ( ! pCrvArc->Set( ptCenL, vtNL, dRad, vtSL, dAngCenDeg, dDeltaN)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; // se richiesto, salvo il comando Lua equivalente @@ -708,7 +824,8 @@ __stdcall EgtCreateCurveArc( int nParentId, ToString( dRad) + ",{" + ToString( Vector3d( vtS)) + "}," + ToString( dAngCenDeg) + "," + - ToString( dDeltaN) + ")" + + ToString( dDeltaN) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -718,9 +835,8 @@ __stdcall EgtCreateCurveArc( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveArcXY( int nParentId, - const double ptCen[3], double dRad, - double dAngStartDeg, double dAngCenDeg, double dDeltaZ) +__stdcall EgtCreateCurveArcC2PN( int nParentId, const double ptCen[3], const double ptStart[3], + const double ptNearEnd[3], const double vtNorm[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -728,46 +844,36 @@ __stdcall EgtCreateCurveArcXY( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; - // setto l'arco - if ( ! pCrvArc->SetXY( ptCen, dRad, dAngStartDeg, dAngCenDeg, dDeltaZ)) - return GDB_ID_NULL ; - // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; - // inserisco l'arco nel DB - int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtArc(" + ToString( nParentId) + ",{" + - ToString( Point3d( ptCen)) + "}," + - ToString( dRad) + "," + - ToString( dAngStartDeg) + "," + - ToString( dAngCenDeg) + "," + - ToString( dDeltaZ) + ")" + - " -- Id=" + ToString( nId) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + // porto in locale i punti, i versori e il versore estrusione + Point3d ptCenL( ptCen) ; + Point3d ptStartL( ptStart) ; + Point3d ptNearEndL( ptNearEnd) ; + Vector3d vtNormL( vtNorm) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptCenL.ToLoc( frLoc) ; + ptStartL.ToLoc( frLoc) ; + ptNearEndL.ToLoc( frLoc) ; + vtNormL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptCenL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptStartL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptNearEndL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNormL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } } - // restituisco l'identificativo della nuova entità - return nId ; -} - -//------------------------------------------------------------------------------- -int -__stdcall EgtCreateCurveArcC2PN( int nParentId, - const double ptCen[3], const double ptStart[3], const double ptNearEnd[3], const double vtNorm[3]) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // creo l'arco - PtrOwner pCrvArc( CreateCurveArc()) ; - if ( IsNull( pCrvArc)) - return GDB_ID_NULL ; // setto l'arco - if ( ! pCrvArc->SetC2PN( ptCen, ptStart, ptNearEnd, vtNorm)) + if ( ! pCrvArc->SetC2PN( ptCenL, ptStartL, ptNearEndL, vtNormL)) return GDB_ID_NULL ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; // se richiesto, salvo il comando Lua equivalente @@ -776,7 +882,8 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId, ToString( Point3d( ptCen)) + "},{" + ToString( Point3d( ptStart)) + "},{" + ToString( Point3d( ptNearEnd)) + "},{" + - ToString( Vector3d( vtNorm)) + "})" + + ToString( Vector3d( vtNorm)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -786,8 +893,8 @@ __stdcall EgtCreateCurveArcC2PN( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveArc3P( int nParentId, - const double ptP1[3], const double ptP2[3], const double ptP3[3]) +__stdcall EgtCreateCurveArc3P( int nParentId, const double ptP1[3], + const double ptP2[3], const double ptP3[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -795,29 +902,54 @@ __stdcall EgtCreateCurveArc3P( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; + // porto in locale i punti e il versore estrusione + Point3d ptP1L( ptP1) ; + Point3d ptP2L( ptP2) ; + Point3d ptP3L( ptP3) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptP1L.ToLoc( frLoc) ; + ptP2L.ToLoc( frLoc) ; + ptP3L.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptP1L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptP2L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptP3L.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } int nId = GDB_ID_NULL ; // setto l'arco - if ( pCrvArc->Set3P( ptP1, ptP2, ptP3, false)) { + if ( pCrvArc->Set3P( ptP1L, ptP2L, ptP3L, false)) { // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; } // se risulta essere una retta - else if ( ( Point3d( ptP2) - Point3d( ptP1)) * ( Point3d( ptP3) - Point3d( ptP2)) > EPS_ZERO) { - bool bOldCmdLog = IsCmdLog() ; - EgtDisableCommandLogger() ; - nId = EgtCreateCurveLine( nParentId, ptP1, ptP3) ; - if ( bOldCmdLog) - EgtEnableCommandLogger() ; + else if ( ( ptP2L - ptP1L) * ( ptP3L - ptP2L) > EPS_ZERO) { + // creo e setto la retta + PtrOwner pCrvLine( CreateCurveLine()) ; + if ( ! IsNull( pCrvLine) && pCrvLine->Set( ptP1L, ptP3L)) { + // assegno il versore estrusione + pCrvLine->SetExtrusion( vtExtrL) ; + // inserisco la retta nel DB + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; + } } // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtArc3P(" + ToString( nParentId) + ",{" + ToString( Point3d( ptP1)) + "},{" + ToString( Point3d( ptP2)) + "},{" + - ToString( Point3d( ptP3)) + "})" + + ToString( Point3d( ptP3)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -827,8 +959,8 @@ __stdcall EgtCreateCurveArc3P( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateCurveArc2PVN( int nParentId, - const double ptStart[3], const double ptEnd[3], const double vtDirS[3], const double vtNorm[3]) +__stdcall EgtCreateCurveArc2PVN( int nParentId, const double ptStart[3], const double ptEnd[3], + const double vtDirS[3], const double vtNorm[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -836,22 +968,49 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId, PtrOwner pCrvArc( CreateCurveArc()) ; if ( IsNull( pCrvArc)) return GDB_ID_NULL ; + // porto in locale i punti, i versori e il versore estrusione + Point3d ptStartL( ptStart) ; + Point3d ptEndL( ptEnd) ; + Vector3d vtDirSL( vtDirS) ; + Vector3d vtNormL( vtNorm) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc)) + return GDB_ID_NULL ; + if ( nRefType == RTY_GLOB) { + ptStartL.ToLoc( frLoc) ; + ptEndL.ToLoc( frLoc) ; + vtDirSL.ToLoc( frLoc) ; + vtNormL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptStartL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptEndL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtDirSL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNormL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } int nId = GDB_ID_NULL ; // setto l'arco - if ( pCrvArc->Set2PVN( ptStart, ptEnd, vtDirS, vtNorm)) { + if ( pCrvArc->Set2PVN( ptStartL, ptEndL, vtDirSL, vtNormL)) { // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvArc))) - return GDB_ID_NULL ; + pCrvArc->SetExtrusion( vtExtrL) ; // inserisco l'arco nel DB nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ; } // se risulta essere una retta - else if ( ( Point3d( ptEnd) - Point3d( ptStart)) * Vector3d( vtDirS) > EPS_ZERO) { - bool bOldCmdLog = IsCmdLog() ; - EgtDisableCommandLogger() ; - nId = EgtCreateCurveLine( nParentId, ptStart, ptEnd) ; - if ( bOldCmdLog) - EgtEnableCommandLogger() ; + else if ( ( ptEndL - ptStartL) * vtDirSL > EPS_ZERO) { + // creo e setto la retta + PtrOwner pCrvLine( CreateCurveLine()) ; + if ( ! IsNull( pCrvLine) && pCrvLine->Set( ptStartL, ptEndL)) { + // assegno il versore estrusione + pCrvLine->SetExtrusion( vtExtrL) ; + // inserisco la retta nel DB + nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvLine)) ; + } } // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { @@ -859,7 +1018,8 @@ __stdcall EgtCreateCurveArc2PVN( int nParentId, ToString( Point3d( ptStart)) + "},{" + ToString( Point3d( ptEnd)) + "},{" + ToString( Vector3d( vtDirS)) + "},{" + - ToString( Vector3d( vtNorm)) + "})" + + ToString( Vector3d( vtNorm)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -1304,38 +1464,62 @@ __stdcall EgtCreateCurveCompoByApprox( int nParentId, int nSouId, BOOL bArcsVsLi //------------------------------------------------------------------------------- int -__stdcall EgtCreateRectangle3P( int nParentId, - const double ptIni[3], const double ptCross[3], const double ptDir[3]) +__stdcall EgtCreateRectangle3P( int nParentId, const double ptIni[3], + const double ptCross[3], const double ptDir[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // recupero il riferimento di inserimento - Frame3d frEnt ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frEnt)) - bOk = false ; + // porto in locale i punti, i versori e il versore estrusione + Point3d ptIniL( ptIni) ; + Point3d ptCrossL( ptCross) ; + Point3d ptDirL( ptDir) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( bOk) { + if ( nRefType == RTY_GLOB) { + ptIniL.ToLoc( frLoc) ; + ptCrossL.ToLoc( frLoc) ; + ptDirL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptCrossL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptDirL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } + } // calcolo il lato X - Vector3d vtDirX = Point3d( ptDir) - Point3d( ptIni) ; - bOk = vtDirX.Normalize() ; - Vector3d vtLatoX = bOk ? (( Point3d( ptCross) - Point3d( ptIni)) * vtDirX) * vtDirX : V_NULL ; + Vector3d vtDirX = ptDirL - ptIniL ; + bOk = bOk && vtDirX.Normalize() ; + Vector3d vtLatoX = bOk ? (( ptCrossL - ptIniL) * vtDirX) * vtDirX : V_NULL ; // creo la polilinea con i punti int nId = GDB_ID_NULL ; if ( bOk) { PolyLine PL ; - PL.AddUPoint( 0, ptIni) ; - PL.AddUPoint( 1, Point3d( ptIni) + vtLatoX) ; - PL.AddUPoint( 2, ptCross) ; - PL.AddUPoint( 3, Point3d( ptCross) - vtLatoX) ; - PL.AddUPoint( 4, ptIni) ; + PL.AddUPoint( 0, ptIniL) ; + PL.AddUPoint( 1, Point3d( ptIniL) + vtLatoX) ; + PL.AddUPoint( 2, ptCrossL) ; + PL.AddUPoint( 3, Point3d( ptCrossL) - vtLatoX) ; + PL.AddUPoint( 4, ptIniL) ; // creo la curva e la inserisco nel GDB nId = EgtCreateCurveCompoFromPoints( nParentId, PL) ; + // ne sistemo il vettore estrusione + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; + if ( pCurve != nullptr) + pCurve->SetExtrusion( vtExtrL) ; } // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtRectangle3P(" + ToString( nParentId) + ",{" + ToString( Point3d( ptIni)) + "},{" + ToString( Point3d( ptCross)) + "},{" + - ToString( Point3d( ptDir)) + "})" + + ToString( Point3d( ptDir)) + "}," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -1345,23 +1529,57 @@ __stdcall EgtCreateRectangle3P( int nParentId, //------------------------------------------------------------------------------- int -__stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides, - const double ptIni[3], const double ptFin[3]) +__stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides, const double ptIni[3], + const double ptFin[3], const double vtN[3], int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + bool bOk = true ; + // porto in locale i punti, la normale e il versore estrusione + Point3d ptIniL( ptIni) ; + Point3d ptFinL( ptFin) ; + Vector3d vtNL( vtN) ; + Vector3d vtExtrL = Z_AX ; + if ( nRefType != RTY_LOC) { + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( bOk) { + if ( nRefType == RTY_GLOB) { + ptIniL.ToLoc( frLoc) ; + ptFinL.ToLoc( frLoc) ; + vtNL.ToLoc( frLoc) ; + vtExtrL.ToLoc( frLoc) ; + } + else /* RTY_GRID */ { + ptIniL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + ptFinL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtNL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } + } + } // creo la curva composita PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo)) - return GDB_ID_NULL ; + bOk = bOk && ! IsNull( pCrvCompo) ; // setto la curva - if ( ! pCrvCompo->PolygonSide( nNumSides, ptIni, ptFin)) - return GDB_ID_NULL ; + bOk = bOk && pCrvCompo->PolygonSide( nNumSides, ptIniL, ptFinL, vtNL) ; // assegno il versore estrusione - if ( ! SetExtrusionFromGridVersZ( pGeomDB, nParentId, Get( pCrvCompo))) - return GDB_ID_NULL ; + bOk = bOk && pCrvCompo->SetExtrusion( vtExtrL) ; // inserisco la curva nel DB - return pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) ; + int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtPolygonFromSide(" + ToString( nParentId) + "," + + ToString( nNumSides) + ",{" + + ToString( Point3d( ptIni)) + "},{" + + ToString( Point3d( ptFin)) + "},{" + + ToString( Vector3d( vtN)) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nId ; } //------------------------------------------------------------------------------- diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index d821efa..70df127 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -15,7 +15,9 @@ #include "stdafx.h" #include "API.h" #include "API_Macro.h" +#include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EgkCurve.h" #include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EgkStringUtils3d.h" @@ -58,23 +60,29 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const double vtExtr[3], double dLinTol) +__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const double vtExtr[3], + double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - bOk = false ; + // porto in locale il vettore estrusione + Vector3d vtExtrL( vtExtr) ; + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + vtExtrL.ToLoc( frLoc) ; + } + else if ( nRefType == RTY_GRID) { + vtExtrL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } // calcolo la polilinea che approssima la curva PolyLine PL ; - if ( ! GetPolyLineFromCurve( nCrvId, frDest, dLinTol, PL)) - bOk = false ; + bOk = bOk && GetPolyLineFromCurve( nCrvId, frLoc, dLinTol, PL) ; // creo e setto la superficie trimesh PtrOwner pSTM( CreateSurfTriMesh()) ; - if ( IsNull( pSTM) || ! pSTM->CreateByExtrusion( PL, vtExtr)) - bOk = false ; + bOk = bOk && ! IsNull( pSTM) ; + bOk = bOk && pSTM->CreateByExtrusion( PL, vtExtrL) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; // se richiesto, salvo il comando Lua equivalente @@ -82,7 +90,8 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + "," + ToString( nCrvId) + ",{" + ToString( Vector3d( vtExtr)) + "}," + - ToString( dLinTol) + ")" + + ToString( dLinTol) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } @@ -94,22 +103,30 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub int __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, const double ptAx[3], const double vtAx[3], - double dAngRotDeg, double dMove, double dLinTol) + double dAngRotDeg, double dMove, double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) bool bOk = true ; - // recupero il riferimento del gruppo destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frDest)) - bOk = false ; + // porto in locale punto e vettore asse + Point3d ptAxL( ptAx) ; + Vector3d vtAxL( vtAx) ; + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + if ( nRefType == RTY_GLOB) { + ptAxL.ToLoc( frLoc) ; + vtAxL.ToLoc( frLoc) ; + } + else if ( nRefType == RTY_GRID) { + ptAxL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + vtAxL.LocToLoc( pGeomDB->GetGridFrame(), frLoc) ; + } // calcolo la polilinea che approssima la curva PolyLine PL ; - if ( ! GetPolyLineFromCurve( nCrvId, frDest, dLinTol, PL)) - bOk = false ; + bOk = bOk && GetPolyLineFromCurve( nCrvId, frLoc, dLinTol, PL) ; // calcolo lo step di rotazione double dMaxRad = 0 ; - PL.GetMaxDistanceFromLine( dMaxRad, ptAx, vtAx, 1, false) ; + bOk = bOk && PL.GetMaxDistanceFromLine( dMaxRad, ptAx, vtAx, 1, false) ; if ( dMaxRad < EPS_SMALL) { bOk = false ; dMaxRad = EPS_SMALL ; @@ -117,8 +134,8 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, double dStepRotDeg = sqrt( 8 * dLinTol / dMaxRad) * RADTODEG ; // creo e setto la superficie trimesh PtrOwner pSTM( CreateSurfTriMesh()) ; - if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, dAngRotDeg, dStepRotDeg, dMove)) - bOk = false ; + bOk = bOk && ! IsNull( pSTM) ; + bOk = bOk && pSTM->CreateByScrewing( PL, ptAxL, vtAxL, dAngRotDeg, dStepRotDeg, dMove) ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSTM)) : GDB_ID_NULL) ; // se richiesto, salvo il comando Lua equivalente @@ -129,7 +146,8 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, ToString( Vector3d( vtAx)) + "}," + ToString( dAngRotDeg) + "," + ToString( dMove) + "," + - ToString( dLinTol) + ")" + + ToString( dLinTol) + "," + + RefTypeToString( nRefType) + ")" + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index 0f6571a..3cb62d1 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -323,6 +323,24 @@ __stdcall EgtRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) return ( bOk ? TRUE : FALSE) ; } +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtChangeId( int nId, int nNewId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // eseguo cambio di Id + bool bOk = pGeomDB->ChangeId( nId, nNewId) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtChangeId(" + ToString( nId) + "," + + ToString( nNewId) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + return ( bOk ? TRUE : FALSE) ; +} + //----------------------------------------------------------------------------- BOOL __stdcall EgtErase( int nId) diff --git a/API_GeoSnap.cpp b/API_GeoSnap.cpp index 92a7bb3..a97c908 100644 --- a/API_GeoSnap.cpp +++ b/API_GeoSnap.cpp @@ -864,6 +864,9 @@ __stdcall EgtPointToIdGlob( Point3d& ptP, int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + // se griglia + if ( nId == GDB_ID_GRID) + return ptP.ToGlob( pGeomDB->GetGridFrame()) ; // recupero il riferimento // se gruppo -> il suo proprio espresso in globale // se oggetto -> quello del gruppo cui appartiene in globale @@ -872,8 +875,7 @@ __stdcall EgtPointToIdGlob( Point3d& ptP, int nId) ! pGeomDB->GetGlobFrame( nId, frRef)) return false ; // eseguo la trasformazione - ptP.ToGlob( frRef) ; - return true ; + return ptP.ToGlob( frRef) ; } //------------------------------------------------------------------------------- @@ -895,6 +897,9 @@ __stdcall EgtPointToIdLoc( Point3d& ptP, int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + // se griglia + if ( nId == GDB_ID_GRID) + return ptP.ToLoc( pGeomDB->GetGridFrame()) ; // recupero il riferimento // se gruppo -> il suo proprio espresso in globale // se oggetto -> quello del gruppo cui appartiene in globale @@ -903,8 +908,7 @@ __stdcall EgtPointToIdLoc( Point3d& ptP, int nId) ! pGeomDB->GetGlobFrame( nId, frRef)) return false ; // eseguo la trasformazione - ptP.ToLoc( frRef) ; - return true ; + return ptP.ToLoc( frRef) ; } //------------------------------------------------------------------------------- @@ -926,6 +930,9 @@ __stdcall EgtVectorToIdGlob( Vector3d& vtV, int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + // se griglia + if ( nId == GDB_ID_GRID) + return vtV.ToGlob( pGeomDB->GetGridFrame()) ; // recupero il riferimento // se gruppo -> il suo proprio espresso in globale // se oggetto -> quello del gruppo cui appartiene in globale @@ -934,8 +941,7 @@ __stdcall EgtVectorToIdGlob( Vector3d& vtV, int nId) ! pGeomDB->GetGlobFrame( nId, frRef)) return false ; // eseguo la trasformazione - vtV.ToGlob( frRef) ; - return true ; + return vtV.ToGlob( frRef) ; } //------------------------------------------------------------------------------- @@ -957,6 +963,9 @@ __stdcall EgtVectorToIdLoc( Vector3d& vtV, int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) + // se griglia + if ( nId == GDB_ID_GRID) + return vtV.ToLoc( pGeomDB->GetGridFrame()) ; // recupero il riferimento // se gruppo -> il suo proprio espresso in globale // se oggetto -> quello del gruppo cui appartiene in globale @@ -965,6 +974,5 @@ __stdcall EgtVectorToIdLoc( Vector3d& vtV, int nId) ! pGeomDB->GetGlobFrame( nId, frRef)) return false ; // eseguo la trasformazione - vtV.ToLoc( frRef) ; - return true ; + return vtV.ToLoc( frRef) ; } diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 29bae7f..224d02c 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -121,7 +121,7 @@ __stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double { // recupero il riferimento della griglia Frame3d frGrid ; - if ( EgtGetGridFrame( frGrid)) { + if ( EgtGetGridFrame( GDB_ID_ROOT, frGrid)) { // assegno i valori di ritorno VEC_FROM_3D( ptOrig, frGrid.Orig()) VEC_FROM_3D( vX, frGrid.VersX()) @@ -135,13 +135,22 @@ __stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double //----------------------------------------------------------------------------- bool -__stdcall EgtGetGridFrame( Frame3d& frFrame) +__stdcall EgtGetGridFrame( int nRefId, Frame3d& frFrame) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) // recupero il riferimento della griglia frFrame = pGeomDB->GetGridFrame() ; - return true ; + // se richiesto nel riferimento globale, esco subito + if ( nRefId == GDB_ID_ROOT) + return true ; + // recupero il riferimento destinazione (nRefId può essere un gruppo o una entità) + Frame3d frDest ; + if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && + ! pGeomDB->GetGlobFrame( nRefId, frDest)) + return false ; + // eseguo la trasformazione + return frFrame.ToLoc( frDest) ; } //----------------------------------------------------------------------------- diff --git a/API_Lua.cpp b/API_Lua.cpp index 013c21a..968fdd6 100644 --- a/API_Lua.cpp +++ b/API_Lua.cpp @@ -52,9 +52,15 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal) BOOL __stdcall EgtLuaExecLine( const wchar_t* wsLine) { + // disabilito il log dei comandi + bool bPrevCmdLog = IsCmdLog() ; + EgtDisableCommandLogger() ; // eseguo il comando string sLine = wstrztoA( wsLine) ; bool bOk = LuaExecLine( sLine) ; + // ripristino lo stato originale del log dei comandi + if ( bPrevCmdLog) + EgtEnableCommandLogger() ; // se richiesto, salvo il comando Lua if ( IsCmdLog()) { string sLua = sLine + diff --git a/API_Scene.cpp b/API_Scene.cpp index 71db037..71af88f 100644 --- a/API_Scene.cpp +++ b/API_Scene.cpp @@ -75,88 +75,105 @@ __stdcall EgtGetSceneInfo( wchar_t*& wsInfo) BOOL __stdcall EgtSetBackground( const int TopCol[4], const int BottomCol[4], BOOL bRedraw) { - return EgtSetBackground( Color( TopCol), Color( BottomCol), bRedraw) ; + return ( EgtSetBackground( Color( TopCol), Color( BottomCol), ( bRedraw != FALSE)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- -BOOL -__stdcall EgtSetBackground( Color TopCol, Color BottomCol, BOOL bRedraw) +bool +__stdcall EgtSetBackground( Color TopCol, Color BottomCol, bool bRedraw) { GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) + VERIFY_CTX_SCENE( pGseCtx, false) // imposto lo sfondo pGseCtx->m_pScene->SetBackground( TopCol, BottomCol) ; if ( bRedraw) pGseCtx->m_pScene->RedrawWindow() ; - return TRUE ; + return true ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetMarkAttribs( const int MarkCol[4]) { - return EgtSetMarkAttribs( Color( MarkCol)) ; + return ( EgtSetMarkAttribs( Color( MarkCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- -BOOL +bool __stdcall EgtSetMarkAttribs( Color MarkCol) { GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) + VERIFY_CTX_SCENE( pGseCtx, false) // imposto il colore del Mark - return ( pGseCtx->m_pScene->SetMark( MarkCol) ? TRUE : FALSE) ; + return pGseCtx->m_pScene->SetMark( MarkCol) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetSelSurfAttribs( const int SelSurfCol[4]) { - return EgtSetSelSurfAttribs( Color( SelSurfCol)) ; + return ( EgtSetSelSurfAttribs( Color( SelSurfCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- -BOOL +bool __stdcall EgtSetSelSurfAttribs( Color SelSurfCol) { GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) + VERIFY_CTX_SCENE( pGseCtx, false) // imposto il colore del Mark - return ( pGseCtx->m_pScene->SetSelSurf( SelSurfCol) ? TRUE : FALSE) ; + return pGseCtx->m_pScene->SetSelSurf( SelSurfCol) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetGeoLineAttribs( const int GlCol[4]) { - return EgtSetGeoLineAttribs( Color( GlCol)) ; + return ( EgtSetGeoLineAttribs( Color( GlCol)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +__stdcall EgtSetGeoLineAttribs( Color GlCol) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, false) + // imposto il colore della linea geometrica gestita direttamente dalla scena + return pGseCtx->m_pScene->SetGeoLineAttribs( GlCol) ; } //----------------------------------------------------------------------------- BOOL -__stdcall EgtSetGeoLineAttribs( Color GlCol) +__stdcall EgtSetGeoTriaAttribs( const int GtCol[4]) +{ + return ( EgtSetGeoTriaAttribs( Color( GtCol)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +__stdcall EgtSetGeoTriaAttribs( Color GtCol) { GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) - // imposto il colore della linea geometrica gestita direttamente dalla scena - return ( pGseCtx->m_pScene->SetGeoLineAttribs( GlCol) ? TRUE : FALSE) ; + VERIFY_CTX_SCENE( pGseCtx, false) + // imposto il colore del triangolo immediato + return pGseCtx->m_pScene->SetGeoTriaAttribs( GtCol) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetWinRectAttribs( BOOL bOutline, const int WrCol[4]) { - return EgtSetWinRectAttribs( bOutline, Color( WrCol)) ; + return ( EgtSetWinRectAttribs( ( bOutline != FALSE), Color( WrCol)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- -BOOL -__stdcall EgtSetWinRectAttribs( BOOL bOutline, Color WrCol) +bool +__stdcall EgtSetWinRectAttribs( bool bOutline, Color WrCol) { GseContext* pGseCtx = GetCurrGseContext() ; - VERIFY_CTX_SCENE( pGseCtx, FALSE) + VERIFY_CTX_SCENE( pGseCtx, false) // imposto il colore della linea geometrica gestita direttamente dalla scena - return ( pGseCtx->m_pScene->SetWinRectAttribs( ( bOutline != FALSE), WrCol) ? TRUE : FALSE) ; + return pGseCtx->m_pScene->SetWinRectAttribs( bOutline, WrCol) ; } //----------------------------------------------------------------------------- @@ -479,6 +496,32 @@ __stdcall EgtResetGeoLine( BOOL bRedraw) return TRUE ; } +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetGeoTria( const double ptP1[3], const double ptP2[3], const double ptP3[3], BOOL bRedraw) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // disegno triangolo immediato + pGseCtx->m_pScene->SetGeoTria( ptP1, ptP2, ptP3) ; + if ( bRedraw) + pGseCtx->m_pScene->RedrawWindow() ; + return TRUE ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtResetGeoTria( BOOL bRedraw) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_SCENE( pGseCtx, FALSE) + // cancello triangolo immediato + pGseCtx->m_pScene->ResetGeoTria() ; + if ( bRedraw) + pGseCtx->m_pScene->RedrawWindow() ; + return TRUE ; +} + //----------------------------------------------------------------------------- BOOL __stdcall EgtSetWinRect( int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) diff --git a/AuxTools.cpp b/AuxTools.cpp index f53dd6f..31e6866 100644 --- a/AuxTools.cpp +++ b/AuxTools.cpp @@ -24,7 +24,8 @@ const char* __stdcall SepToString( int nSep) { switch ( nSep) { - default : return "'ST'" ; + default : + case SEP_STD : return "'ST'" ; case SEP_TG : return "'TG'" ; case SEP_PERP : return "'PR'" ; case SEP_MINDIST : return "'MD'" ; @@ -37,14 +38,44 @@ __stdcall StringToSep( const string& sSep) { string sTmp = sSep ; ToUpper( sTmp) ; - if ( sTmp == "TG") + if ( sTmp == "ST") + return SEP_STD ; + else if ( sTmp == "TG") return SEP_TG ; else if ( sTmp == "PR") return SEP_PERP ; else if ( sTmp == "MD") return SEP_MINDIST ; - else - return SEP_STD ; + // default + return SEP_STD ; +} + +//---------------------------------------------------------------------------- +const char* +__stdcall RefTypeToString( int nRefType) +{ + switch ( nRefType) { + case RTY_GLOB : return "'GLOB'" ; + default : + case RTY_LOC : return "'LOC'" ; + case RTY_GRID : return "'GRID'" ; + } +} + +//---------------------------------------------------------------------------- +int +__stdcall StringToRefType( const string& sRefType) +{ + string sTmp = sRefType ; + ToUpper( sTmp) ; + if ( sTmp == "GLOB") + return RTY_GLOB ; + else if ( sTmp == "LOC") + return RTY_LOC ; + else if ( sTmp == "GRID") + return RTY_GRID ; + // default + return RTY_LOC ; } //---------------------------------------------------------------------------- diff --git a/AuxTools.h b/AuxTools.h index 950e759..c7ecf2a 100644 --- a/AuxTools.h +++ b/AuxTools.h @@ -17,6 +17,9 @@ // Tipo punto per creazione rette e archi const char* __stdcall SepToString( int nSep) ; int __stdcall StringToSep( const std::string& sSep) ; +// Tipo riferimento in cui sono espressi i dati geometrici +const char* __stdcall RefTypeToString( int nRefType) ; +int __stdcall StringToRefType( const std::string& sRefType) ; // Posizione inserimento testo const char* __stdcall ETxtInsPosToString( int nETxtInsPos) ; int __stdcall ETxtInsPosToString( const std::string& sETxtInsPos) ; diff --git a/EgtInterface.rc b/EgtInterface.rc index d6a7ff5..1f8376d 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/LUA.h b/LUA.h index af916c2..cd12fbe 100644 --- a/LUA.h +++ b/LUA.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2015 //---------------------------------------------------------------------------- -// File : LUA.h Data : 08.01.15 Versione : 1.6a1 +// File : LUA.h Data : 16.01.15 Versione : 1.6a3 // Contenuto : Dichiarazioni locali per moduli LUA. // // @@ -48,6 +48,7 @@ bool LuaGetParam( lua_State* L, int nInd, Color& colPar) ; bool LuaGetParam( lua_State* L, int nInd, INTVECTOR& vPar) ; bool LuaGetParam( lua_State* L, int nInd, PNTVECTOR& vPar) ; bool LuaGetParam( lua_State* L, int nInd, PNTUVECTOR& vParW) ; +bool LuaGetRefType( lua_State* L, int nInd, int& nRefType) ; bool LuaClearStack( lua_State* L) ; // bool LuaSetReturn( lua_State* L /*, nil */) ; diff --git a/LUA_Aux.cpp b/LUA_Aux.cpp index 1f38b95..5136c3b 100644 --- a/LUA_Aux.cpp +++ b/LUA_Aux.cpp @@ -14,8 +14,11 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "LUA.h" -#include "/EgtDev/Include/EgkFrame3d.h" -#include "/EgtDev/Include/EgkColor.h" +#include "AuxTools.h" +#include "/EgtDev/Include/EGkFrame3d.h" +#include "/EgtDev/Include/EGkColor.h" +#include "/EgtDev/Include/EInConst.h" +#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Extern/Lua/Include/lua.hpp" using namespace std ; @@ -271,6 +274,19 @@ LuaGetParam( lua_State* L, int nInd, PNTUVECTOR& vParW) return false ; } +//---------------------------------------------------------------------------- +bool +LuaGetRefType( lua_State* L, int nInd, int& nRefType) +{ + // se non c'è il tipo cercato, ritorno + string sRefType ; + if ( ! LuaGetParam( L, nInd, sRefType)) + return false ; + // interpreto il parametro + nRefType = StringToRefType( sRefType) ; + return true ; +} + //---------------------------------------------------------------------------- bool LuaClearStack( lua_State* L) diff --git a/LUA_GdbCreate.cpp b/LUA_GdbCreate.cpp index 8d0ffb5..ebda20c 100644 --- a/LUA_GdbCreate.cpp +++ b/LUA_GdbCreate.cpp @@ -17,6 +17,7 @@ #include "API.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Extern/Lua/Include/lua.hpp" @@ -28,16 +29,19 @@ using namespace std ; static int LuaCreateGroup( lua_State* L) { - // 1 o 2 parametri : ParentId [, Frame] + // 1 o 2 o 3 parametri : ParentId [, Frame] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Frame3d frFrame ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, frFrame) ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 2, frFrame)) + LuaGetRefType( L, 3, nRefType) ; + else + LuaGetRefType( L, 2, nRefType) ; LuaClearStack( L) ; // creo il gruppo int nId = EgtCreateGroup( nParentId, frFrame.Orig().v, - frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v) ; + frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -50,14 +54,16 @@ LuaCreateGroup( lua_State* L) static int LuaCreateGeoPoint( lua_State* L) { - // 2 parametri : ParentId, PtP + // 2 o 3 parametri : ParentId, PtP [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; LuaCheckParam( L, 2, ptP) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 3, nRefType) ; LuaClearStack( L) ; // creo il punto - int nId = EgtCreateGeoPoint( nParentId, ptP.v) ; + int nId = EgtCreateGeoPoint( nParentId, ptP.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -70,17 +76,20 @@ LuaCreateGeoPoint( lua_State* L) static int LuaCreateGeoVector( lua_State* L) { - // 2 o 3 parametri : ParentId, VtV [, PtB] + // 2 o 3 o 4 parametri : ParentId, VtV [, PtB] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Vector3d vtV ; LuaCheckParam( L, 2, vtV) Point3d ptB ; - if ( lua_gettop( L) >= 3) - LuaCheckParam( L, 3, ptB) ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 3, ptB)) + LuaGetRefType( L, 4, nRefType) ; + else + LuaGetRefType( L, 3, nRefType) ; LuaClearStack( L) ; // creo il vettore - int nId = EgtCreateGeoVector( nParentId, vtV.v, ptB.v) ; + int nId = EgtCreateGeoVector( nParentId, vtV.v, ptB.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -93,15 +102,17 @@ LuaCreateGeoVector( lua_State* L) static int LuaCreateGeoFrame( lua_State* L) { - // 2 parametri : ParentId, Frame + // 2 o 3 parametri : ParentId, Frame [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Frame3d frFrame ; LuaCheckParam( L, 2, frFrame) ; + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 3, nRefType) ; LuaClearStack( L) ; // creo il gruppo int nId = EgtCreateGeoFrame( nParentId, frFrame.Orig().v, - frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v) ; + frFrame.VersX().v, frFrame.VersY().v, frFrame.VersZ().v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -114,7 +125,7 @@ LuaCreateGeoFrame( lua_State* L) static int LuaCreateText( lua_State* L) { - // 5 parametri : ParentId, ptP, AngRotDeg, Text, H + // 5 o 6 parametri : ParentId, ptP, AngRotDeg, Text, H [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; @@ -125,9 +136,11 @@ LuaCreateText( lua_State* L) LuaCheckParam( L, 4, sText) double dH ; LuaCheckParam( L, 5, dH) ; + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; // creo il testo - int nId = EgtCreateText( nParentId, ptP, dAngRotDeg, sText, dH) ; + int nId = EgtCreateText( nParentId, ptP, dAngRotDeg, sText, dH, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -140,7 +153,7 @@ LuaCreateText( lua_State* L) static int LuaCreateTextEx( lua_State* L) { - // 8 parametri : ParentId, ptP, vtN, vtD, Text, Font, bItalic, H + // 8 o 9 parametri : ParentId, ptP, vtN, vtD, Text, Font, bItalic, H [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; @@ -159,9 +172,11 @@ LuaCreateTextEx( lua_State* L) bool bItalic = ( sItalic == "I") ; double dH ; LuaCheckParam( L, 8, dH) ; + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 9, nRefType) ; LuaClearStack( L) ; // creo il testo in modo esteso - int nId = EgtCreateTextEx( nParentId, ptP, vtN, vtD, sText, sFont, bItalic, dH) ; + int nId = EgtCreateTextEx( nParentId, ptP, vtN, vtD, sText, sFont, bItalic, dH, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -174,7 +189,7 @@ LuaCreateTextEx( lua_State* L) static int LuaCreateTextAdv( lua_State* L) { - // 12 parametri : ParentId, ptP, vtN, vtD, Text, Font, W, sItalic, H, Rat, AddAdv, InsPos + // 12 o 13 parametri : ParentId, ptP, vtN, vtD, Text, Font, W, sItalic, H, Rat, AddAdv, InsPos [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP ; @@ -202,10 +217,12 @@ LuaCreateTextAdv( lua_State* L) string sInsPos ; LuaCheckParam( L, 12, sInsPos) ; int nInsPos = ETxtInsPosToString( sInsPos) ; + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 13, nRefType) ; LuaClearStack( L) ; // creo il testo in modo avanzato int nId = EgtCreateTextAdv( nParentId, ptP, vtN, vtD, - sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos) ; + sText, sFont, nW, bItalic, dH, dRat, dAddAdv, nInsPos, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index 4049120..5851c31 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -17,6 +17,7 @@ #include "API.h" #include "AuxTools.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EgkPolyLine.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Extern/Lua/Include/lua.hpp" @@ -27,16 +28,18 @@ using namespace std ; static int LuaCreateCurveLine( lua_State* L) { - // 3 parametri : ParentId, PtIni, PtFin + // 3 o 4 parametri : ParentId, PtIni, PtFin [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; LuaCheckParam( L, 2, ptIni) Point3d ptFin ; LuaCheckParam( L, 3, ptFin) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta - int nId = EgtCreateCurveLine( nParentId, ptIni.v, ptFin.v) ; + int nId = EgtCreateCurveLine( nParentId, ptIni.v, ptFin.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -49,7 +52,7 @@ LuaCreateCurveLine( lua_State* L) static int LuaCreateCurveLineEx( lua_State* L) { - // 7 parametri : ParentId, PtIni, sSepI, nIdI, PtFin, sSEpF, nIdF + // 7 o 8 parametri : ParentId, PtIni, sSepI, nIdI, PtFin, sSEpF, nIdF [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -64,9 +67,13 @@ LuaCreateCurveLineEx( lua_State* L) LuaCheckParam( L, 6, sSepF) int nIdF ; LuaCheckParam( L, 7, nIdF) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 8, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta - int nId = EgtCreateCurveLineEx( nParentId, ptIni.v, StringToSep( sSepI), nIdI, ptFin.v, StringToSep( sSepF), nIdF) ; + int nId = EgtCreateCurveLineEx( nParentId, + ptIni.v, StringToSep( sSepI), nIdI, + ptFin.v, StringToSep( sSepF), nIdF, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -79,7 +86,7 @@ LuaCreateCurveLineEx( lua_State* L) static int LuaCreateCurveLinePVL( lua_State* L) { - // 4 parametri : ParentId, PtIni, VtDir, dLen + // 4 o 5 parametri : ParentId, PtIni, VtDir, dLen [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -88,9 +95,11 @@ LuaCreateCurveLinePVL( lua_State* L) LuaCheckParam( L, 3, vtDir) double dLen ; LuaCheckParam( L, 4, dLen) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta - int nId = EgtCreateCurveLinePVL( nParentId, ptIni.v, vtDir.v, dLen) ; + int nId = EgtCreateCurveLinePVL( nParentId, ptIni.v, vtDir.v, dLen, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -103,7 +112,7 @@ LuaCreateCurveLinePVL( lua_State* L) static int LuaCreateCurveLineMinPointCurve( lua_State* L) { - // 3 o 4 parametri : ParentId, PtIni, CrvId [, NearPar] + // 3 o 4 o 5 parametri : ParentId, PtIni, CrvId [, NearPar] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -111,11 +120,14 @@ LuaCreateCurveLineMinPointCurve( lua_State* L) int nCrvId ; LuaCheckParam( L, 3, nCrvId) double dNearPar = 0 ; - if ( lua_gettop( L) >= 4) - LuaCheckParam( L, 4, dNearPar) ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 4, dNearPar)) + LuaGetRefType( L, 5, nRefType) ; + else + LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; // creo il segmento di retta - int nId = EgtCreateCurveLineMinPointCurve( nParentId, ptIni.v, nCrvId, dNearPar) ; + int nId = EgtCreateCurveLineMinPointCurve( nParentId, ptIni.v, nCrvId, dNearPar, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -128,7 +140,7 @@ LuaCreateCurveLineMinPointCurve( lua_State* L) static int LuaCreateCurveCircle( lua_State* L) { - // 4 parametri : ParentId, PtCen, VtN, Rad + // 4 o 5 parametri : ParentId, PtCen, VtN, Rad [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -137,31 +149,11 @@ LuaCreateCurveCircle( lua_State* L) LuaCheckParam( L, 3, vtN) double dRad ; LuaCheckParam( L, 4, dRad) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveCircle( nParentId, ptCen.v, vtN.v, dRad) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveCircleXY( lua_State* L) -{ - // 3 parametri : ParentId, PtCen, Rad - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptCen ; - LuaCheckParam( L, 2, ptCen) - double dRad ; - LuaCheckParam( L, 3, dRad) - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveCircleXY( nParentId, ptCen.v, dRad) ; + int nId = EgtCreateCurveCircle( nParentId, ptCen.v, vtN.v, dRad, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -174,7 +166,7 @@ LuaCreateCurveCircleXY( lua_State* L) static int LuaCreateCurveCircleCPN( lua_State* L) { - // 4 parametri : ParentId, PtCen, PtOn, VtN + // 4 o 5 parametri : ParentId, PtCen, PtOn, VtN [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -183,9 +175,11 @@ LuaCreateCurveCircleCPN( lua_State* L) LuaCheckParam( L, 3, ptOn) Vector3d vtN ; LuaCheckParam( L, 4, vtN) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveCircleCPN( nParentId, ptCen.v, ptOn.v, vtN.v) ; + int nId = EgtCreateCurveCircleCPN( nParentId, ptCen.v, ptOn.v, vtN.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -198,7 +192,7 @@ LuaCreateCurveCircleCPN( lua_State* L) static int LuaCreateCurveCircle3P( lua_State* L) { - // 4 parametri : ParentId, PtP1, PtP2, PtP3 + // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; @@ -207,9 +201,11 @@ LuaCreateCurveCircle3P( lua_State* L) LuaCheckParam( L, 3, ptP2) Point3d ptP3 ; LuaCheckParam( L, 4, ptP3) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveCircle3P( nParentId, ptP1.v, ptP2.v, ptP3.v) ; + int nId = EgtCreateCurveCircle3P( nParentId, ptP1.v, ptP2.v, ptP3.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -222,7 +218,7 @@ LuaCreateCurveCircle3P( lua_State* L) static int LuaCreateCurveArc( lua_State* L) { - // 7 parametri : ParentId, PtCen, VtN, Rad, VtS, AngCenDeg, DeltaN + // 7 o 8 parametri : ParentId, PtCen, VtN, Rad, VtS, AngCenDeg, DeltaN [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -237,37 +233,11 @@ LuaCreateCurveArc( lua_State* L) LuaCheckParam( L, 6, dAngCenDeg) double dDeltaN ; LuaCheckParam( L, 7, dDeltaN) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 8, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveArc( nParentId, ptCen.v, vtN.v, dRad, vtS.v, dAngCenDeg, dDeltaN) ; - // restituisco il risultato - if ( nId != GDB_ID_NULL) - LuaSetReturn( L, nId) ; - else - LuaSetReturn( L) ; - return 1 ; -} - -//------------------------------------------------------------------------------- -static int -LuaCreateCurveArcXY( lua_State* L) -{ - // 6 parametri : ParentId, PtCen, Rad, AngStartDeg, AngCenDeg, DeltaN - int nParentId ; - LuaCheckParam( L, 1, nParentId) - Point3d ptCen ; - LuaCheckParam( L, 2, ptCen) - double dRad ; - LuaCheckParam( L, 3, dRad) - double dAngStartDeg ; - LuaCheckParam( L, 4, dAngStartDeg) - double dAngCenDeg ; - LuaCheckParam( L, 5, dAngCenDeg) - double dDeltaZ ; - LuaCheckParam( L, 6, dDeltaZ) - LuaClearStack( L) ; - // creo l'arco - int nId = EgtCreateCurveArcXY( nParentId, ptCen.v, dRad, dAngStartDeg, dAngCenDeg, dDeltaZ) ; + int nId = EgtCreateCurveArc( nParentId, ptCen.v, vtN.v, dRad, vtS.v, dAngCenDeg, dDeltaN, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -280,7 +250,7 @@ LuaCreateCurveArcXY( lua_State* L) static int LuaCreateCurveArcC2PN( lua_State* L) { - // 5 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm + // 5 o 6 parametri : ParentId, PtCen, PtStart, PtNearEnd, VtNorm [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptCen ; @@ -291,9 +261,11 @@ LuaCreateCurveArcC2PN( lua_State* L) LuaCheckParam( L, 4, ptNearEnd) Vector3d vtNorm ; LuaCheckParam( L, 5, vtNorm) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveArcC2PN( nParentId, ptCen.v, ptStart.v, ptNearEnd.v, vtNorm.v) ; + int nId = EgtCreateCurveArcC2PN( nParentId, ptCen.v, ptStart.v, ptNearEnd.v, vtNorm.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -306,7 +278,7 @@ LuaCreateCurveArcC2PN( lua_State* L) static int LuaCreateCurveArc3P( lua_State* L) { - // 4 parametri : ParentId, PtP1, PtP2, PtP3 + // 4 o 5 parametri : ParentId, PtP1, PtP2, PtP3 [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptP1 ; @@ -315,9 +287,11 @@ LuaCreateCurveArc3P( lua_State* L) LuaCheckParam( L, 3, ptP2) Point3d ptP3 ; LuaCheckParam( L, 4, ptP3) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveArc3P( nParentId, ptP1.v, ptP2.v, ptP3.v) ; + int nId = EgtCreateCurveArc3P( nParentId, ptP1.v, ptP2.v, ptP3.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -330,7 +304,7 @@ LuaCreateCurveArc3P( lua_State* L) static int LuaCreateCurveArc2PVN( lua_State* L) { - // 5 parametri : ParentId, PtStart, PtEnd, VtDirS, VtNorm + // 5 o 6 parametri : ParentId, PtStart, PtEnd, VtDirS, VtNorm [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptStart ; @@ -341,9 +315,11 @@ LuaCreateCurveArc2PVN( lua_State* L) LuaCheckParam( L, 4, vtDirS) Vector3d vtNorm ; LuaCheckParam( L, 5, vtNorm) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; // creo l'arco - int nId = EgtCreateCurveArc2PVN( nParentId, ptStart.v, ptEnd.v, vtDirS.v, vtNorm.v) ; + int nId = EgtCreateCurveArc2PVN( nParentId, ptStart.v, ptEnd.v, vtDirS.v, vtNorm.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -551,7 +527,7 @@ LuaCreateCurveCompoByApprox( lua_State* L) static int LuaCreateRectangle3P( lua_State* L) { - // 4 parametri : ParentId, PtIni, PtCross, PtDir + // 4 o 5 parametri : ParentId, PtIni, PtCross, PtDir [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) Point3d ptIni ; @@ -560,9 +536,11 @@ LuaCreateRectangle3P( lua_State* L) LuaCheckParam( L, 3, ptCross) Point3d ptDir ; LuaCheckParam( L, 4, ptDir) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 5, nRefType) ; LuaClearStack( L) ; // creo il poligono - int nId = EgtCreateRectangle3P( nParentId, ptIni.v, ptCross.v, ptDir.v) ; + int nId = EgtCreateRectangle3P( nParentId, ptIni.v, ptCross.v, ptDir.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -575,7 +553,7 @@ LuaCreateRectangle3P( lua_State* L) static int LuaCreatePolygonFromSide( lua_State* L) { - // 4 parametri : ParentId, nNumSides, PtIni, PtFin + // 5 o 6 parametri : ParentId, nNumSides, PtIni, PtFin, VtN [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nNumSides ; @@ -584,9 +562,13 @@ LuaCreatePolygonFromSide( lua_State* L) LuaCheckParam( L, 3, ptIni) Point3d ptFin ; LuaCheckParam( L, 4, ptFin) + Vector3d vtN ; + LuaCheckParam( L, 5, vtN) + int nRefType = RTY_DEFAULT ; + LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; // creo il poligono - int nId = EgtCreatePolygonFromSide( nParentId, nNumSides, ptIni.v, ptFin.v) ; + int nId = EgtCreatePolygonFromSide( nParentId, nNumSides, ptIni.v, ptFin.v, vtN.v, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -605,11 +587,9 @@ LuaInstallGdbCreateCurve( lua_State* L) lua_register( L, "EgtLinePVL", LuaCreateCurveLinePVL) ; lua_register( L, "EgtLineMinPointCurve", LuaCreateCurveLineMinPointCurve) ; lua_register( L, "EgtCircle", LuaCreateCurveCircle) ; - lua_register( L, "EgtCircleXY", LuaCreateCurveCircleXY) ; lua_register( L, "EgtCircleCPN", LuaCreateCurveCircleCPN) ; lua_register( L, "EgtCircle3P", LuaCreateCurveCircle3P) ; lua_register( L, "EgtArc", LuaCreateCurveArc) ; - lua_register( L, "EgtArcXY", LuaCreateCurveArcXY) ; lua_register( L, "EgtArcC2PN", LuaCreateCurveArcC2PN) ; lua_register( L, "EgtArc3P", LuaCreateCurveArc3P) ; lua_register( L, "EgtArc2PVN", LuaCreateCurveArc2PVN) ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 3d6fe05..e6bb1bb 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -16,6 +16,7 @@ #include "LUA.h" #include "API.h" #include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EgkPolyLine.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Extern/Lua/Include/lua.hpp" @@ -49,7 +50,7 @@ LuaCreateSurfTriMeshByContour( lua_State* L) static int LuaCreateSurfTriMeshByExtrusion( lua_State* L) { - // 3 o 4 parametri : ParentId, CrvId, vtExtr [, dTol] + // 3 o 4 o 5 parametri : ParentId, CrvId, vtExtr [, dTol] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; @@ -57,11 +58,14 @@ LuaCreateSurfTriMeshByExtrusion( lua_State* L) Vector3d vtExtr ; LuaCheckParam( L, 3, vtExtr) double dLinTol = 0.1 ; - if ( lua_gettop( L) >= 4) - LuaCheckParam( L, 4, dLinTol) ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 4, dLinTol)) + LuaGetRefType( L, 5, nRefType) ; + else + LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, nCrvId, vtExtr.v, dLinTol) ; + int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, nCrvId, vtExtr.v, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -74,7 +78,7 @@ LuaCreateSurfTriMeshByExtrusion( lua_State* L) static int LuaCreateSurfTriMeshByScrewing( lua_State* L) { - // 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] + // 6 o 7 o 8 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] [, sRefType] int nParentId ; LuaCheckParam( L, 1, nParentId) int nCrvId ; @@ -88,11 +92,14 @@ LuaCreateSurfTriMeshByScrewing( lua_State* L) double dMove ; LuaCheckParam( L, 6, dMove) double dLinTol = 0.1 ; - if ( lua_gettop( L) >= 7) - LuaCheckParam( L, 7, dLinTol) ; + int nRefType = RTY_DEFAULT ; + if ( LuaGetParam( L, 7, dLinTol)) + LuaGetRefType( L, 8, nRefType) ; + else + LuaGetRefType( L, 7, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByScrewing( nParentId, nCrvId, ptAx.v, vtAx.v, dAngRotDeg, dMove, dLinTol) ; + int nId = EgtCreateSurfTriMeshByScrewing( nParentId, nCrvId, ptAx.v, vtAx.v, dAngRotDeg, dMove, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 5f982d5..40b45b4 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -278,6 +278,23 @@ LuaRelocateGlob( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaChangeId( lua_State* L) +{ + // 2 parametri : Id, nNewId + int nId ; + LuaCheckParam( L, 1, nId) + int nNewId ; + LuaCheckParam( L, 2, nNewId) + LuaClearStack( L) ; + // eseguo il cambio di identificativo + bool bOk = ( EgtChangeId( nId, nNewId) != FALSE) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaErase( lua_State* L) @@ -314,6 +331,7 @@ LuaInstallGdbObjects( lua_State* L) lua_register( L, "EgtCopyGlob", LuaCopyGlob) ; lua_register( L, "EgtRelocate", LuaRelocate) ; lua_register( L, "EgtRelocateGlob", LuaRelocateGlob) ; + lua_register( L, "EgtChangeId", LuaChangeId) ; lua_register( L, "EgtErase", LuaErase) ; } catch ( ...) { diff --git a/LUA_GeomDB.cpp b/LUA_GeomDB.cpp index 8d13f82..39037ae 100644 --- a/LUA_GeomDB.cpp +++ b/LUA_GeomDB.cpp @@ -59,11 +59,14 @@ LuaSetGridFrame( lua_State* L) static int LuaGetGridFrame( lua_State* L) { - // nessun parametro + // 1 o nessun parametro : [nRefId] + int nRefId = GDB_ID_ROOT ; + if ( lua_gettop( L) >= 1) + LuaCheckParam( L, 1, nRefId) LuaClearStack( L) ; // recupero il riferimento della griglia Frame3d frFrame ; - EgtGetGridFrame( frFrame) ; + EgtGetGridFrame( nRefId, frFrame) ; // restituisco il risultato LuaSetReturn( L, frFrame) ; return 1 ;