EgtExecutor 1.6p3 :

- aggiunta estensione MPF riconosciuta come tipo file CNC
- aggiunta ExeExistsTable.
This commit is contained in:
Dario Sassi
2016-04-19 15:56:35 +00:00
parent 4ec6568db1
commit 411df42814
5 changed files with 165 additions and 97 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ ExeGetFileType( const string& sFilePath)
return FT_DXF ;
else if ( sFileExt == "STL")
return FT_STL ;
else if ( sFileExt == "CNC" || sFileExt == "XPI")
else if ( sFileExt == "CNC" || sFileExt == "XPI" || sFileExt == "MPF")
return FT_CNC ;
else if ( sFileExt == "HED" || sFileExt == "ENT" || sFileExt == "ENS")
return FT_CSF ;
+115 -95
View File
@@ -139,6 +139,99 @@ ExeOffsetCurveAdv( int nId, double dDist, int nType, int* pnCount)
return nFirstId ;
}
//-------------------------------------------------------------------------------
bool
ExeApproxCurve( int nId, int nApprType, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// eseguo l'approssimazione
const double ANG_TOL_MAX_DEG = 90 ;
const double ANG_TOL_STD_DEG = 15 ;
const double LIN_FEA_LEN_STD = 20 ;
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
bOk = bOk && ! IsNull( pCC) ;
if ( nApprType == APP_LINES ||
nApprType == APP_LEFT_LINES || nApprType == APP_LEFT_CONVEX_LINES ||
nApprType == APP_RIGHT_LINES || nApprType == APP_RIGHT_CONVEX_LINES) {
PolyLine PL ;
bOk = bOk && pCurve->ApproxWithLines( dLinTol, ANG_TOL_MAX_DEG, nApprType, PL) && pCC->FromPolyLine( PL) ;
}
else { // con bi-archi
PolyArc PA ;
bOk = bOk && pCurve->ApproxWithArcsEx( dLinTol, ANG_TOL_STD_DEG, LIN_FEA_LEN_STD, PA) && pCC->FromPolyArc( PA) ;
// merge di archi identici di biarchi
bOk = bOk && pCC->MergeCurves( 0.5 * dLinTol, ANG_TOL_STD_DEG) ;
}
// copio estrusione e spessore
Vector3d vtExtr ;
if ( bOk && pCurve->GetExtrusion( vtExtr))
pCC->SetExtrusion( vtExtr) ;
double dThick ;
if ( bOk && pCurve->GetThickness( dThick))
pCC->SetThickness(dThick) ;
// sostituisco la vecchia curva con la nuova
bOk = bOk && pGeomDB->ReplaceGeoObj( nId, Release( pCC)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtApproxCurve(" + ToString( nId) + "," +
ApproxTypeToString( nApprType) + "," +
ToString( dLinTol) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//-------------------------------------------------------------------------------
bool
ExeProjectCurveOnPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il punto e la normale del piano
Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ;
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
// calcolo il piano di proiezione
Plane3d plPlane ;
bOk = bOk && SetPlane( ptOnL, vtNL, plPlane) ;
// eseguo la proiezione
PtrOwner<ICurve> pProCrv( bOk ? ProjectCurveOnPlane( *pCurve, plPlane) : nullptr) ;
bOk = bOk && ! IsNull( pProCrv) ;
// copio estrusione e spessore
Vector3d vtExtr ;
if ( bOk && pCurve->GetExtrusion( vtExtr))
pProCrv->SetExtrusion( vtExtr) ;
double dThick ;
if ( bOk && pCurve->GetThickness( dThick))
pProCrv->SetThickness(dThick) ;
// sostituisco la vecchia curva con la nuova
bOk = bOk && pGeomDB->ReplaceGeoObj( nId, Release( pProCrv)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtProjectCurveOnPlane(" + ToString( nId) + ",{" +
ToString( ptOn) + "},{" +
ToString( vtN) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//----------------------------------------------------------------------------
bool
ExeChangeClosedCurveStartPoint( int nId, const Point3d& ptP, int nRefType)
@@ -1364,99 +1457,6 @@ ExeRemoveCurveCompoUndercutOnY( int nId, double dLinTol)
return bOk ;
}
//-------------------------------------------------------------------------------
bool
ExeApproxCurve( int nId, int nApprType, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// eseguo l'approssimazione
const double ANG_TOL_MAX_DEG = 90 ;
const double ANG_TOL_STD_DEG = 15 ;
const double LIN_FEA_LEN_STD = 20 ;
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
bOk = bOk && ! IsNull( pCC) ;
if ( nApprType == APP_LINES ||
nApprType == APP_LEFT_LINES || nApprType == APP_LEFT_CONVEX_LINES ||
nApprType == APP_RIGHT_LINES || nApprType == APP_RIGHT_CONVEX_LINES) {
PolyLine PL ;
bOk = bOk && pCurve->ApproxWithLines( dLinTol, ANG_TOL_MAX_DEG, nApprType, PL) && pCC->FromPolyLine( PL) ;
}
else { // con bi-archi
PolyArc PA ;
bOk = bOk && pCurve->ApproxWithArcsEx( dLinTol, ANG_TOL_STD_DEG, LIN_FEA_LEN_STD, PA) && pCC->FromPolyArc( PA) ;
// merge di archi identici di biarchi
bOk = bOk && pCC->MergeCurves( 0.5 * dLinTol, ANG_TOL_STD_DEG) ;
}
// copio estrusione e spessore
Vector3d vtExtr ;
if ( bOk && pCurve->GetExtrusion( vtExtr))
pCC->SetExtrusion( vtExtr) ;
double dThick ;
if ( bOk && pCurve->GetThickness( dThick))
pCC->SetThickness(dThick) ;
// sostituisco la vecchia curva con la nuova
bOk = bOk && pGeomDB->ReplaceGeoObj( nId, Release( pCC)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtApproxCurve(" + ToString( nId) + "," +
ApproxTypeToString( nApprType) + "," +
ToString( dLinTol) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//-------------------------------------------------------------------------------
bool
ExeProjectCurveOnPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
// porto in locale il punto e la normale del piano
Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ;
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ;
// calcolo il piano di proiezione
Plane3d plPlane ;
bOk = bOk && SetPlane( ptOnL, vtNL, plPlane) ;
// eseguo la proiezione
PtrOwner<ICurve> pProCrv( bOk ? ProjectCurveOnPlane( *pCurve, plPlane) : nullptr) ;
bOk = bOk && ! IsNull( pProCrv) ;
// copio estrusione e spessore
Vector3d vtExtr ;
if ( bOk && pCurve->GetExtrusion( vtExtr))
pProCrv->SetExtrusion( vtExtr) ;
double dThick ;
if ( bOk && pCurve->GetThickness( dThick))
pProCrv->SetThickness(dThick) ;
// sostituisco la vecchia curva con la nuova
bOk = bOk && pGeomDB->ReplaceGeoObj( nId, Release( pProCrv)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtProjectCurveOnPlane(" + ToString( nId) + ",{" +
ToString( ptOn) + "},{" +
ToString( vtN) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return bOk ;
}
//-------------------------------------------------------------------------------
static bool
MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, int nRefType)
@@ -1516,12 +1516,32 @@ MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, in
bool
ExeChainCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType)
{
return MyChainCurvesInGroup(nGroupId, ptNear, true, nRefType) ;
bool bOk = MyChainCurvesInGroup(nGroupId, ptNear, true, nRefType) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtChainCurvesInGroup(" + ToString( nGroupId) + "," +
ToString( ptNear) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
//-------------------------------------------------------------------------------
bool
ExeReorderCurvesInGroup( int nGroupId, const Point3d& ptNear, int nRefType)
{
return MyChainCurvesInGroup(nGroupId, ptNear, false, nRefType) ;
bool bOk = MyChainCurvesInGroup(nGroupId, ptNear, false, nRefType) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtReorderCurvesInGroup(" + ToString( nGroupId) + "," +
ToString( ptNear) + "}," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
+11 -1
View File
@@ -712,7 +712,17 @@ ExeRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg)
// Table & Fixtures
//-----------------------------------------------------------------------------
bool
ExeSetTable( const std::string& sTable)
ExeExistsTable( const string& sTable)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifico esistenza della tavola indicata nella macchina della macchinata corrente
return pGseCtx->m_pMachMgr->ExistsTable( sTable) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetTable( const string& sTable)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
BIN
View File
Binary file not shown.
+38
View File
@@ -651,6 +651,42 @@ LuaRemoveCurveCompoUndercutOnY( lua_State* L)
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaChainCurvesInGroup( lua_State* L)
{
// 2 o 3 parametri : nGroupId, ptNear [, nRefType]
int nGroupId ;
LuaCheckParam( L, 1, nGroupId)
Point3d ptNear ;
LuaCheckParam( L, 2, ptNear)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// concateno le curve nel gruppo (senza fonderle in una curva composita)
bool bOk = ExeChainCurvesInGroup( nGroupId, ptNear, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaReorderCurvesInGroup( lua_State* L)
{
// 2 o 3 parametri : nGroupId, ptNear [, nRefType]
int nGroupId ;
LuaCheckParam( L, 1, nGroupId)
Point3d ptNear ;
LuaCheckParam( L, 2, ptNear)
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// riordino le curve nel gruppo (senza fonderle in una curva composita)
bool bOk = ExeReorderCurvesInGroup( nGroupId, ptNear, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
@@ -691,5 +727,7 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeCurveCompo", LuaExplodeCurveCompo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtMergeCurvesInCurveCompo", LuaMergeCurvesInCurveCompo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveCurveCompoUndercutOnY", LuaRemoveCurveCompoUndercutOnY) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtChainCurvesInGroup", LuaChainCurvesInGroup) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtReorderCurvesInGroup", LuaReorderCurvesInGroup) ;
return bOk ;
}