EgtExecutor :

- aggiunte funzioni exe e lua per valori iniziali e finali degli assi in una lavorazione GetMachiningStartAxes e GetMachiningEndAxes
- aggiunta funzione di proiezione a minima distanza di curva su superficie ProjectCurveOnSurf
- rinominata funzione di proiezione lungo direzione di curva su superficie in ProjectCurveOnSurfDir.
This commit is contained in:
Dario Sassi
2025-12-09 08:17:51 +01:00
parent f698451c4c
commit 50d92d366d
4 changed files with 192 additions and 15 deletions
+108 -14
View File
@@ -2441,8 +2441,104 @@ ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType)
//-------------------------------------------------------------------------------
static bool
MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId,
double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType)
MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId,
double dLinTol, double dMaxSegmLen)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// recupero la curva e il suo riferimento
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ;
if ( pCrv == nullptr)
return false ;
Frame3d frCrv ;
if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv))
return false ;
// deve esserci almeno una superficie
if ( vnSurfId.empty())
return false ;
// recupero il riferimento della prima superficie
Frame3d frSurf ;
if ( ! pGeomDB->GetGlobFrame( vnSurfId[0], frSurf))
return false ;
// recupero le superfici e le porto tutte in locale alla prima
SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vnSurfId.size()) ;
CISURFPVECTOR vpSurf ; vpSurf.reserve( vnSurfId.size()) ;
for ( int i = 0 ; i < int( vnSurfId.size()) ; ++ i) {
vSurfL.emplace_back( pGeomDB, vnSurfId[i], frSurf) ;
if ( vSurfL[i].Get() == nullptr)
return false ;
vpSurf.emplace_back( vSurfL[i].Get()) ;
}
// recupero il riferimento del gruppo di destinazione
nDestGrpId = AdjustId( nDestGrpId) ;
Frame3d frDest ;
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
return false ;
// porto la curva e il vettore nel riferimento della superficie
CurveLocal CrvLoc( pCrv, frCrv, frSurf) ;
if ( CrvLoc.Get() == nullptr)
return false ;
// eseguo la proiezione
PNT5AXVECTOR vPt5ax ;
if ( ! ProjectCurveOnSurf( *CrvLoc.Get(), vpSurf, dLinTol, dMaxSegmLen, true, vPt5ax))
return false ;
// inserisco la composita nel gruppo destinazione
PtrOwner<ICurveComposite> pCompo ;
for ( const auto& Pt5ax : vPt5ax) {
if ( IsNull( pCompo)) {
pCompo.Set( CreateCurveComposite()) ;
if ( IsNull( pCompo))
return false ;
pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ;
}
else
pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ;
}
int nCompoId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCompo)) ;
if ( nCompoId == GDB_ID_NULL)
return false ;
// aggiungo i versori nel gruppo destinazione
int nInd = 0 ;
for ( const auto& Pt5ax : vPt5ax) {
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
if ( IsNull( pGeoVct))
return false ;
pGeoVct->Set( 10 * GetLocToLoc( Pt5ax.vtDir1, frSurf, frDest), GetLocToLoc( Pt5ax.ptP, frSurf, frDest)) ;
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoVct)) ;
if ( nNewId == GDB_ID_NULL)
return false ;
pGeomDB->SetInfo( nNewId, "Ind", nInd ++) ;
pGeomDB->SetInfo( nNewId, "Par", Pt5ax.dPar) ;
pGeomDB->SetInfo( nNewId, "Flag", Pt5ax.nFlag) ;
}
return true ;
}
//-------------------------------------------------------------------------------
bool
ExeProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, int nDestGrpId,
double dLinTol, double dMaxSegmLen)
{
bool bOk = MyProjectCurveOnSurf( nCurveId, vnSurfId, nDestGrpId, dLinTol, dMaxSegmLen) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtProjectCurveOnSurf(" + ToString( nCurveId) + ",{" +
ToString( vnSurfId) + "},{" +
ToString( nDestGrpId) + "," +
ToString( dLinTol) + "," +
ToString( dMaxSegmLen) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
//-------------------------------------------------------------------------------
static bool
MyProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId,
double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -2522,26 +2618,25 @@ MyProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& v
//-------------------------------------------------------------------------------
bool
ExeProjectCurveOnSurf( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId,
ExeProjectCurveOnSurfDir( int nCurveId, const INTVECTOR& vnSurfId, const Vector3d& vtProj, int nDestGrpId,
double dLinTol, double dMaxSegmLen, bool bDirFromProj, int nRefType)
{
bool bOk = MyProjectCurveOnSurf( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ;
bool bOk = MyProjectCurveOnSurfDir( nCurveId, vnSurfId, vtProj, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtProjectCurveOnSurf(" + ToString( nCurveId) + ",{" +
ToString( vnSurfId) + "},{" +
ToString( vtProj) + "}," +
ToString( nDestGrpId) + "," +
ToString( dLinTol) + "," +
ToString( dMaxSegmLen) + "," +
( bDirFromProj ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
string sLua = "EgtProjectCurveOnSurfDir(" + ToString( nCurveId) + ",{" +
ToString( vnSurfId) + "},{" +
ToString( vtProj) + "}," +
ToString( nDestGrpId) + "," +
ToString( dLinTol) + "," +
ToString( dMaxSegmLen) + "," +
( bDirFromProj ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
//-------------------------------------------------------------------------------
@@ -2680,7 +2775,6 @@ ExeProjectCurveOnSurfExt( int nCurveId, const INTVECTOR& vnSurfId, int nGuideId,
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
//----------------------------------------------------------------------------