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
+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 ;
}