EgtExecutor :

- aggiunta funzione Exe e Lua VolZmapGetEdges.
This commit is contained in:
Dario Sassi
2019-09-12 18:38:36 +00:00
parent f5f45b0794
commit 011ab93d78
3 changed files with 75 additions and 2 deletions
+49
View File
@@ -498,6 +498,55 @@ ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRef
return bOk ;
}
//----------------------------------------------------------------------------
int
ExeVolZmapGetEdges( int nId, int nDestGrpId, int* pnCount)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero lo Zmap
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pVZM != nullptr) ;
// recupero il riferimento del solido
Frame3d frSurf ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ;
// recupero il riferimento di destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
// ne determino gli spigoli
ICURVEPOVECTOR vpCurve ;
bOk = bOk && pVZM->GetEdges( vpCurve) ;
// inserisco gli spigoli come curve nel DB
int nFirstId = GDB_ID_NULL ;
int nCount = 0 ;
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
// lo porto nel riferimento destinazione
bOk = bOk && vpCurve[i]->LocToLoc( frSurf, frDest) ;
// lo inserisco nel DB geometrico
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( vpCurve[i])) : GDB_ID_NULL) ;
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
// copio il materiale
bOk = bOk && pGeomDB->CopyMaterial( nId, nNewId) ;
// aggiorno contatori
if ( bOk && nFirstId == GDB_ID_NULL)
nFirstId = nNewId ;
if ( bOk)
++ nCount ;
}
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtGetSurfTmSilhouette(" + ToString( nId) + ",{" +
ToString( nDestGrpId) + ")" +
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultati
if ( pnCount != nullptr)
*pnCount = nCount ;
return nFirstId ;
}
//----------------------------------------------------------------------------
bool
ExeVolZmapAvoidBox( int nId, const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, int nRefType)
+1 -2
View File
@@ -636,7 +636,7 @@ MyChainCurvesForSurfSurfInters( const BIPNTVECTOR& vBpt, IGeomDB* pGeomDB, int n
! AreSamePointApprox( ptNear, ( bInvert ? vBpt[nInd].first : vBpt[nInd].second)))
return false ;
// aggiorno il prossimo near
ptNear = vBpt[nInd].second ;
ptNear = ( bInvert ? vBpt[nInd].first : vBpt[nInd].second) ;
}
// se lunghezza curva inferiore a 5 volte la tolleranza, la salto
double dCrvLen ;
@@ -647,7 +647,6 @@ MyChainCurvesForSurfSurfInters( const BIPNTVECTOR& vBpt, IGeomDB* pGeomDB, int n
// la salvo
vCrvCompo.emplace_back( Release( pCrvCompo)) ;
}
//return true ;
// Ripeto concatenamento sulle curve appena create (per riempire eventuali mini buchi)
chainC.Init( false, dToler, int( vCrvCompo.size())) ;
for ( int i = 0 ; i < int( vCrvCompo.size()) ; ++ i) {
+25
View File
@@ -355,6 +355,30 @@ LuaVolZmapGetDepth( lua_State* L)
}
return 2 ;
}
//----------------------------------------------------------------------------
static int
LuaVolZmapGetEdges( lua_State* L)
{
// 2 parametri : nId, nDestGrpId
int nId ;
LuaCheckParam( L, 1, nId)
int nDestGrpId ;
LuaCheckParam( L, 2, nDestGrpId)
LuaClearStack( L) ;
// eseguo calcolo profondità dal punto lungo la direzione
int nCount ;
int nFirstId = ExeVolZmapGetEdges( nId, nDestGrpId, &nCount) ;
// restituisco il risultato
if ( nFirstId != GDB_ID_NULL) {
LuaSetParam( L, nFirstId) ;
LuaSetParam( L, nCount) ;
}
else {
LuaSetParam( L) ;
LuaSetParam( L) ;
}
return 2 ;
}
//----------------------------------------------------------------------------
static int
@@ -466,6 +490,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetToolOutline", LuaVolZmapGetToolOutline) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetEdges", LuaVolZmapGetEdges) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidCylinder", LuaVolZmapAvoidCylinder) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidSphere", LuaVolZmapAvoidSphere) ;