diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index fa47142..d63b894 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -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) diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp index 517d74e..5a348fd 100644 --- a/EXE_GeoInters.cpp +++ b/EXE_GeoInters.cpp @@ -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) { diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index f516bb3..9ae74ff 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -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) ;