Merge remote-tracking branch 'origin/HEAD' into Bezier_trim&mesh

This commit is contained in:
Daniele Bariletti
2023-06-21 09:36:55 +02:00
9 changed files with 169 additions and 15 deletions
+8 -1
View File
@@ -45,8 +45,15 @@ HMODULE s_hENs = nullptr ;
//-----------------------------------------------------------------------------
bool
LoadNestingDll( ILogger* pLogger, const string& sKey, const string& sKey2)
LoadNestingDll( ILogger* pLogger, const string& sKey, const string& sKey2, bool bNetHwKey)
{
// non ammessa con chiave di rete
if ( bNetHwKey) {
std::string sErr = "Warning on Key (ENS/NET)" ;
LOG_ERROR( pLogger, sErr.c_str()) ;
FreeNestingDll() ;
return false ;
}
// verifico la chiave
if ( ! TestKeyForENs( sKey, 0, pLogger)) {
FreeNestingDll() ;
+1 -1
View File
@@ -19,7 +19,7 @@ class ILogger ;
class IAutoNester ;
//----------------------------------------------------------------------------
bool LoadNestingDll( ILogger* pLogger, const std::string& sKey, const std::string& sKey2) ;
bool LoadNestingDll( ILogger* pLogger, const std::string& sKey, const std::string& sKey2, bool bNetHwKey) ;
bool FreeNestingDll( void) ;
bool IsLoadedNestingDll( void) ;
void MySetENsLogger( ILogger* pLogger) ;
+1
View File
@@ -25,6 +25,7 @@ const std::string& ExeGetIniFile( void) ;
//----------------------------------------------------------------------------
const std::string& ExeGetKey( void) ;
const std::string& ExeGetNestKey( void) ;
const std::string& ExeGetLockId( void) ;
//----------------------------------------------------------------------------
ILogger* GetLogger( void) ;
+75 -5
View File
@@ -25,7 +25,9 @@
#include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
#include "/EgtDev/Include/EGkVolZmap.h"
#include "/EgtDev/Include/EGkSurfLocal.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
using namespace std ;
@@ -67,7 +69,7 @@ MyCDeBoxVolZmap( const Frame3d& frBox, const Vector3d& vtDiag, int nZmapId, doub
// porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento)
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -138,7 +140,7 @@ MyCDeRectPrismoidVolZmap( const Frame3d& frPrismoid, double dBaseLenX, double dB
// porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento)
Frame3d frPrismoidL = GetFrameLocal( pGeomDB, frPrismoid, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -211,7 +213,7 @@ MyCDeCylVolZmap( const Frame3d& frCyl, double dR, double dH, int nZmapId, double
// porto in locale il riferimento
Frame3d frCylL = GetFrameLocal( pGeomDB, frCyl, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -279,7 +281,7 @@ MyCDeConeVolZmap( const Frame3d& frCone, double dR1, double dR2, double dH, int
// porto in locale il riferimento
Frame3d frConeL = GetFrameLocal( pGeomDB, frCone, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -348,7 +350,7 @@ MyCDeSpheVolZmap( const Point3d& ptCen, double dRad, int nZmapId, double dSafeDi
// porto in locale il centro della sfera
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -374,3 +376,71 @@ ExeCDeSpheSolid( const Point3d& ptCen, double dR, int nSolidId, double dSafeDist
// restituisco risultato
return nRes ;
}
//----------------------------------------------------------------------------
static int
MyCDeClosedSurfTmClosedSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, -1)
// recupero il riferimento della seconda superficie
Frame3d frSurf2 ;
if ( ! pGeomDB->GetGlobFrame( nSurfTm2Id, frSurf2))
return -1 ;
// recupero la prima superficie in locale alla seconda
SurfLocal Surf1Loc( pGeomDB, nSurfTm1Id, frSurf2) ;
const ISurfTriMesh* pStm1 = GetSurfTriMesh( Surf1Loc) ;
if ( pStm1 == nullptr)
return -1 ;
// recupero la seconda superficie TriMesh
const ISurfTriMesh* pStm2 = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTm2Id)) ;
if ( pStm2 == nullptr)
return -1 ;
// verifico la collisione
return ( CDeClosedSurfTmClosedSurfTm( *pStm1, *pStm2, dSafeDist) ? 1 : 0) ;
}
//----------------------------------------------------------------------------
static int
MyCDeClosedSurfTmVolZmap( int nSurfTmId, int nZmapId, double dSafeDist)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, -1)
// recupero il riferimento dello Zmap
Frame3d frZmap ;
if ( ! pGeomDB->GetGlobFrame( nZmapId, frZmap))
return -1 ;
// recupero la superficie in locale allo Zmap
SurfLocal SurfLoc( pGeomDB, nSurfTmId, frZmap) ;
const ISurfTriMesh* pStm = GetSurfTriMesh( SurfLoc) ;
if ( pStm == nullptr)
return -1 ;
// recupero lo Zmap
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nZmapId)) ;
if ( pVZM == nullptr)
return -1 ;
// verifico la collisione
return ( pVZM->AvoidSurfTm( *pStm, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
int
ExeCDeSolidSolid( int nSolid1Id, int nSolid2Id, double dSafeDist)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
int nRes = -1 ;
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == SRF_TRIMESH)
nRes = MyCDeClosedSurfTmClosedSurfTm( nSolid1Id, nSolid2Id, dSafeDist) ;
else if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == VOL_ZMAP)
nRes = MyCDeClosedSurfTmVolZmap( nSolid1Id, nSolid2Id, dSafeDist) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCDeSolidSolid({" + IdToString( nSolid1Id) + "," +
IdToString( nSolid2Id) + "," +
ToString( dSafeDist) + ")" +
" -- Res=" + ToString( nRes) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return nRes ;
}
+2 -1
View File
@@ -413,7 +413,8 @@ ExeAdvancedImport( const string& sFilePath, double dToler)
sExec = "EgtConverterR32.exe" ;
#endif
string sCmdLine = "\"" + sExec + "\" \"" + sFilePath + "\" \"" + sFileOut + "\" \"" +
ToString( dToler, 3) + "\" \"" + ToString( ExeGetDebugLevel()) +"\" \"" + ExeGetKey() + "\"" ;
ToString( dToler, 3) + "\" \"" + ToString( ExeGetDebugLevel()) + "\" \"" +
ExeGetKey() + "\" \"" + ExeGetLockId() + "\"" ;
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
ZeroMemory( &si, sizeof( si)) ;
+54 -4
View File
@@ -29,6 +29,7 @@
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EGnGetModuleVer.h"
#include "/EgtDev/Include/EGnPcInfo.h"
#include "/EgtDev/Include/EGnGetKeyData.h"
#include "/EgtDev/Include/EgtIniFile.h"
#include "/EgtDev/Include/EgtLogger.h"
#include "/EgtDev/Include/EgtStringConverter.h"
@@ -51,6 +52,7 @@ static bool s_bNetHwKey = false ;
static int s_nKeyExpDays = 0 ;
static int s_nKeyOptExpDays = 0 ;
static string s_sNestKey ;
static string s_sLockId ;
static string s_sIniFile ;
static bool s_bEnableUI = true ;
static pfProcEvents s_pFunProcEvents = nullptr ;
@@ -115,7 +117,7 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg)
LOG_INFO( s_pGenLog, MyGetEMkVersion())
// carico libreria nesting opzionale (non può usare la chiave di rete)
if ( LoadNestingDll( s_pGenLog, s_sKey, s_sNestKey))
if ( LoadNestingDll( s_pGenLog, s_sKey, s_sNestKey, s_bNetHwKey))
LOG_INFO( s_pGenLog, MyGetENsVersion())
// Info sulla protezione e sul sistema
@@ -188,6 +190,10 @@ ExeExit( void)
s_pGenLog = nullptr ;
}
// libero eventuale chiave di rete
if ( s_bNetHwKey)
CloseNetHwKey() ;
return true ;
}
@@ -218,6 +224,7 @@ bool
ExeSetKey( const string& sKey)
{
s_sKey = sKey ;
SetEGnKey( s_sKey) ;
return true ;
}
@@ -248,15 +255,56 @@ bool
ExeSetLockType( int nType)
{
s_nKeyType = nType ;
SetEGnKeyType( s_nKeyType) ;
return SetLockType( nType) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetNetHwKey( bool bNetHwKey)
ExeSetLockId( const string& sLockId)
{
int nKeyType ;
bool bNetKey ;
int nUserId ;
GetLockIdStringInfo( sLockId, nKeyType, bNetKey, nUserId) ;
bool bOk ;
switch ( nKeyType) {
default :
ExeSetNetHwKey( false) ;
bOk = false ;
break ;
case KEY_LOCK_TYPE_SW :
ExeSetNetHwKey( false) ;
bOk = ( s_nKeyType != KEY_LOCK_TYPE_HW) ;
break ;
case KEY_LOCK_TYPE_HW :
ExeSetNetHwKey( bNetKey, nUserId) ;
bOk = true ;
break ;
}
if ( bOk)
s_sLockId = sLockId ;
else
s_sLockId = "" ;
return bOk ;
}
//-----------------------------------------------------------------------------
const string&
ExeGetLockId( void)
{
if ( s_sLockId.empty())
GetLockId( s_sLockId) ;
return s_sLockId ;
}
//-----------------------------------------------------------------------------
bool
ExeSetNetHwKey( bool bNetHwKey, int nUserId)
{
s_bNetHwKey = bNetHwKey ;
return SetNetHwKey( bNetHwKey) ;
SetEGnNetHwKey( s_bNetHwKey) ;
return SetNetHwKey( s_bNetHwKey, nUserId) ;
}
//-----------------------------------------------------------------------------
@@ -411,7 +459,7 @@ ExeGetKeyInfo( string& sKey)
sLockId = sLockId.substr( 7, 6) ;
if ( sLockId.empty())
return false ;
int nLockSN ;
int nLockSN = 0 ;
if ( GetLockSN( nLockSN))
sLockId += " (" + ToString( nLockSN) + ")" ;
}
@@ -431,6 +479,7 @@ ExeGetKeyLevel( int nProd, int nVer, int nLev, int& nKLev)
{
// verifico la chiave e il livello
int nRet = GetKeyLevel( s_sKey, nProd, nVer, nLev, nKLev, s_nKeyExpDays) ;
SetEGnKeyLevel( nRet, nKLev, s_nKeyExpDays) ;
if ( nRet != KEY_OK) {
string sErr = "Error on Key (EGKL/" + ToString( nRet) + ")" ;
LOG_ERROR( s_pGenLog, sErr.c_str()) ;
@@ -448,6 +497,7 @@ ExeGetKeyOptions( int nProd, int nVer, int nLev, unsigned int& nOpt2)
// verifico la chiave e le opzioni
unsigned int nOpt1 ;
int nRet = GetKeyOptions( s_sKey, nProd, nVer, nLev, nOpt1, nOpt2, s_nKeyOptExpDays) ;
SetEGnKeyOptions( nRet, nOpt1, nOpt2, s_nKeyOptExpDays) ;
if ( nRet != KEY_OK) {
nOpt2 = 0 ;
string sErr = "Error on Key (EGKO/" + ToString( nRet) + ")" ;
+5 -3
View File
@@ -212,11 +212,13 @@ ExeResize( int nW, int nH)
bool
ExeDraw( void)
{
// se interfaccia disabilitata, esco subito
if ( ! ExeGetEnableUI())
return true ;
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_SCENE( pGseCtx, false)
// se abilitato, eseguo disegno
if ( ExeGetEnableUI())
pGseCtx->m_pScene->Draw() ;
// eseguo disegno
pGseCtx->m_pScene->Draw() ;
// valido la finestra disegnata
ValidateRgn( pGseCtx->m_hWnd, NULL) ;
return true ;
BIN
View File
Binary file not shown.
+23
View File
@@ -165,6 +165,28 @@ LuaCDeSpheSolid( lua_State* L)
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCDeSolidSolid( lua_State* L)
{
// 3 parametri : nSolid1Id, nSolid2Id, dSafeDist
int nSolid1Id ;
LuaCheckParam( L, 1, nSolid1Id)
int nSolid2Id ;
LuaCheckParam( L, 2, nSolid2Id)
double dSafeDist ;
LuaCheckParam( L, 3, dSafeDist)
LuaClearStack( L) ;
// eseguo verifica di collisione
int nRes = ExeCDeSolidSolid( nSolid1Id, nSolid2Id, dSafeDist) ;
// restituisco il risultato
if ( nRes >= 0)
LuaSetParam( L, ( nRes != 0)) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallCDeObjSolid( LuaMgr& luaMgr)
@@ -175,5 +197,6 @@ LuaInstallCDeObjSolid( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeCylSolid", LuaCDeCylSolid) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeConeSolid", LuaCDeConeSolid) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSpheSolid", LuaCDeSpheSolid) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSolidSolid", LuaCDeSolidSolid) ;
return bOk ;
}