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:
+108
-14
@@ -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 ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -2868,6 +2868,26 @@ ExeGetMachiningEndPoint( Point3d& ptEnd)
|
||||
return pMachMgr->GetMachiningEndPoint( ptEnd) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetMachiningStartAxes( bool bSkipClimb, DBLVECTOR& vAxVal)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// restituisco quanto cercato
|
||||
return pMachMgr->GetMachiningStartAxes( bSkipClimb, vAxVal) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetMachiningEndAxes( bool bSkipRise, DBLVECTOR& vAxVal)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// restituisco quanto cercato
|
||||
return pMachMgr->GetMachiningEndAxes( bSkipRise, vAxVal) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeApplyAllMachinings( bool bRecalc, bool bStopOnFirstErr, string& sErrList)
|
||||
|
||||
+24
-1
@@ -1004,6 +1004,28 @@ LuaReorderCurvesInGroup( lua_State* L)
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaProjectCurveOnSurf( lua_State* L)
|
||||
{
|
||||
// 3, 4 o 5 parametri : nCurveId, vSurfId, nDestGrpId [, dLinTol [, dMaxSegmLen]]
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
INTVECTOR vSurfId ;
|
||||
LuaCheckParam( L, 2, vSurfId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
double dLinTol = 0.01 ;
|
||||
double dMaxSegmLen = INFINITO ;
|
||||
if ( LuaGetParam( L, 4, dLinTol))
|
||||
LuaGetParam( L, 5, dMaxSegmLen) ;
|
||||
LuaClearStack( L) ;
|
||||
// proietto la curva su una o più superfici a minima distanza
|
||||
bool bOk = ExeProjectCurveOnSurf( nCurveId, vSurfId, nDestGrpId, dLinTol, dMaxSegmLen) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaProjectCurveOnSurfDir( lua_State* L)
|
||||
{
|
||||
// 4, 5, 6, 7 o 8 parametri : nCurveId, vSurfId, vtDir, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromProj] [, nRefType]]
|
||||
int nCurveId ;
|
||||
@@ -1024,7 +1046,7 @@ LuaProjectCurveOnSurf( lua_State* L)
|
||||
LuaGetParam( L, 8, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// proietto la curva su una o più superfici secondo la direzione data
|
||||
bool bOk = ExeProjectCurveOnSurf( nCurveId, vSurfId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ;
|
||||
bool bOk = ExeProjectCurveOnSurfDir( nCurveId, vSurfId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromProj, nRefType) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
@@ -1254,6 +1276,7 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtChainCurvesInGroup", LuaChainCurvesInGroup) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtReorderCurvesInGroup", LuaReorderCurvesInGroup) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurf", LuaProjectCurveOnSurf) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfDir", LuaProjectCurveOnSurfDir) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfExt", LuaProjectCurveOnSurfExt) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetVoronoi", LuaCurveGetVoronoi) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxisAdv", LuaCurveMedialAxisAdv) ;
|
||||
|
||||
@@ -3082,6 +3082,44 @@ LuaGetMachiningEndPoint( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetMachiningStartAxes( lua_State* L)
|
||||
{
|
||||
// 0 o 1 parametro : [bSkipClimb]
|
||||
bool bSkipClimb = true ;
|
||||
LuaGetParam( L, 1, bSkipClimb) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il valore iniziale degli assi del primo percorso della lavorazione corrente
|
||||
DBLVECTOR vAxVal ;
|
||||
bool bOk = ExeGetMachiningStartAxes( bSkipClimb, vAxVal) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vAxVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetMachiningEndAxes( lua_State* L)
|
||||
{
|
||||
// 0 o 1 parametro : [bSkipRise]
|
||||
bool bSkipRise = true ;
|
||||
LuaGetParam( L, 1, bSkipRise) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il valore finale degli assi dell'ultimo percorso della lavorazione corrente
|
||||
DBLVECTOR vAxVal ;
|
||||
bool bOk = ExeGetMachiningEndAxes( bSkipRise, vAxVal) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vAxVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaApplyAllMachinings( lua_State* L)
|
||||
@@ -4531,6 +4569,8 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtIsMachiningEmpty", LuaIsMachiningEmpty) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachiningStartPoint", LuaGetMachiningStartPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachiningEndPoint", LuaGetMachiningEndPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachiningStartAxes", LuaGetMachiningStartAxes) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachiningEndAxes", LuaGetMachiningEndAxes) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtApplyAllMachinings", LuaApplyAllMachinings) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateAllMachinings", LuaUpdateAllMachinings) ;
|
||||
// CL Entities Interrogations
|
||||
|
||||
Reference in New Issue
Block a user