diff --git a/EXE_GdbCreateVol.cpp b/EXE_GdbCreateVol.cpp index 6ca6247..f60437f 100644 --- a/EXE_GdbCreateVol.cpp +++ b/EXE_GdbCreateVol.cpp @@ -1,4 +1,4 @@ -//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- // EgalTech 2016-2016 //---------------------------------------------------------------------------- // File : EXE_GdbCreateVol.cpp Data : 27.10.16 Versione : 1.6v7 @@ -64,7 +64,50 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità + return nNewId ; +} + +//------------------------------------------------------------------------------- +int ExeCreateVolZmapEmpty( int nParentId, const Point3d& ptIni, double dDimX, double dDimY, double dDimZ, + double dPrec, bool bTriDex, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + nParentId = AdjustId( nParentId) ; + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // porto in locale i punti + Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ; + Point3d ptOnXL = GetPointLocal( pGeomDB, ptIni + X_AX, nRefType, frLoc) ; + Point3d ptOnYL = GetPointLocal( pGeomDB, ptIni + Y_AX, nRefType, frLoc) ; + // ne ricavo un riferimento intrinseco + Frame3d frBox ; + bOk = bOk && frBox.Set( ptIniL, ptOnXL, ptOnYL) ; + // creo lo Zmap nel suo riferimento intrinseco + PtrOwner pVZM( CreateVolZmap()) ; + bOk = bOk && ! IsNull( pVZM) ; + bOk = bOk && pVZM->CreateEmptyMap( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ; + // lo porto nel riferimento locale + bOk = bOk && pVZM->ToGlob( frBox) ; + // inserisco lo Zmap nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapEmpty(" + IdToString( nParentId) + ",{" + + ToString( ptIni) + "}," + + ToString( dDimX) + "," + + ToString( dDimY) + "," + + ToString( dDimZ) + "," + + ToString( dPrec) + "," + + ( bTriDex ? "true" : "false") + "," + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -103,7 +146,7 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } @@ -141,6 +184,6 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } - // restituisco l'identificativo della nuova entità + // restituisco l'identificativo della nuova entità return nNewId ; } diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 1cce74a..3f57943 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -337,6 +337,34 @@ ExeVolZmapSetChiselTool( const INTVECTOR& vIds, const string& sToolName, return bOk ; } +//---------------------------------------------------------------------------- +bool +ExeVolZmapSetAdditiveTool( const INTVECTOR& vIds, const string& sToolName, + double dLen, double dDiam, double dCornR, int nFlag, bool bFirst) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero gli Zmap e assegno i dati dell'utensile + bool bOk = true ; + for ( int i = 0 ; i < int( vIds.size()) ; ++ i) { + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( vIds[i])) ; + bOk = ( bOk && pVZM != nullptr && pVZM->SetAdditiveTool( sToolName, dLen, dDiam / 2, dCornR, nFlag, bFirst)) ; + } + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapSetAdditiveTool({" + IdListToString( vIds) + "}," + + sToolName + "," + + ToString( dLen) + "," + + ToString( dDiam) + "," + + ToString( dCornR) + "," + + ToString( nFlag) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //---------------------------------------------------------------------------- bool ExeVolZmapResetTools( const INTVECTOR& vIds) diff --git a/LUA_GdbCreateVol.cpp b/LUA_GdbCreateVol.cpp index 2e2e1fc..f5ec104 100644 --- a/LUA_GdbCreateVol.cpp +++ b/LUA_GdbCreateVol.cpp @@ -54,6 +54,42 @@ LuaCreateVolZmapBox( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCreateVolZmapEmpty( lua_State* L) +{ + // 6 o 7 o 8 parametri : ParentId, PtIni, dDimX, dDimY, dDimZ, dPrec [, bTriDex] [, nRefType] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + Point3d ptIni ; + LuaCheckParam( L, 2, ptIni) + double dDimX ; + LuaCheckParam( L, 3, dDimX) + double dDimY ; + LuaCheckParam( L, 4, dDimY) + double dDimZ ; + LuaCheckParam( L, 5, dDimZ) + double dPrec ; + LuaCheckParam( L, 6, dPrec) + bool bTriDex = true ; + int nRefType = RTY_DEFAULT ; + if ( ! LuaGetParam( L, 7, bTriDex)) + LuaGetParam( L, 7, nRefType) ; + else + LuaGetParam( L, 8, nRefType) ; + LuaClearStack( L) ; + // creo VZM parallelepipedo + int nId = ExeCreateVolZmapEmpty( nParentId, ptIni, dDimX, dDimY, dDimZ, dPrec, bTriDex, nRefType) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetParam( L, nId) ; + else + LuaSetParam( L) ; + return 1 ; +} + + + //------------------------------------------------------------------------------- static int LuaCreateVolZmapByRegionExtrusion( lua_State* L) @@ -110,6 +146,7 @@ LuaInstallGdbCreateVol( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEmpty", LuaCreateVolZmapEmpty) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ; return bOk ; diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index b0c8e28..f749bd9 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -250,6 +250,32 @@ LuaVolZmapSetChiselTool( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaVolZmapSetAdditiveTool( lua_State* L) +{ + // 5 o 6 parametri : vIds, sToolName, dLen, dWidth, dThick, nFlag + INTVECTOR vIds ; + LuaCheckParam( L, 1, vIds) + string sToolName ; + LuaCheckParam( L, 2, sToolName) + double dLen ; + LuaCheckParam( L, 3, dLen) + double dDiam ; + LuaCheckParam( L, 4, dDiam) + double dCornR ; + LuaCheckParam( L, 5, dCornR) + int nFlag = 1 ; + LuaGetParam( L, 6, nFlag) ; + LuaClearStack( L) ; + // imposto scalpello a Zmap indicati + bool bOk = ExeVolZmapSetAdditiveTool( vIds, sToolName, dLen, dDiam, dCornR, nFlag, true) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + + //---------------------------------------------------------------------------- static int LuaVolZmapResetTool( lua_State* L) @@ -375,6 +401,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetGenTool", LuaVolZmapSetGenTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetMortiserTool", LuaVolZmapSetMortiserTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetChiselTool", LuaVolZmapSetChiselTool) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdditiveTool", LuaVolZmapSetAdditiveTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapResetTool", LuaVolZmapResetTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetToolOutline", LuaVolZmapGetToolOutline) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ;