EgtMachKernel 1.8b5 :

- correzioni a lavorazioni di superfici con fresa per risalite in Z
- aggiunta a lvorazioni di superfici con presa possibilità di accorciare inizio e fine.
This commit is contained in:
Dario Sassi
2017-02-21 19:54:09 +00:00
parent 2d0ea787fa
commit b251726fbe
12 changed files with 294 additions and 37 deletions
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -36,8 +36,8 @@ struct MillingData : public MachiningData
double m_dStep ; // passo di affondamento (0=nessun passo)
int m_nStepType ; // tipo di lavorazione a step (a gradini, una via, a spirale)
double m_dSideAngle ; // angolo di sbandamento (0-60deg)
double m_dStartAddLen ; // lunghezza da aggiungere/togliere all'inizio se percorso aperto
double m_dEndAddLen ; // lunghezza da aggiungere/togliere alla fine se percorso aperto
double m_dStartAddLen ; // lunghezza da aggiungere/togliere all'inizio
double m_dEndAddLen ; // lunghezza da aggiungere/togliere alla fine
bool m_bLeaveTab ; // lasciare i tab
double m_dTabLen ; // lunghezza dei tab lasciati per tenere il pezzo
double m_dTabDist ; // distanza tra due tab consecutivi
+13
View File
@@ -431,6 +431,19 @@ Operation::GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw)
BBox3d b3Compo ;
if ( ! m_pGeomDB->GetGlobalBBox( nPathId, b3Compo))
return false ;
return GetRawGlobBox( nPhase, b3Compo, dToler, b3Raw) ;
}
//----------------------------------------------------------------------------
bool
Operation::GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw)
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// inizializzo box
b3Raw.Reset() ;
// allargo box di test
BBox3d b3Compo = b3Test ;
b3Compo.Expand( dToler, dToler, 0) ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
+1
View File
@@ -68,6 +68,7 @@ class Operation : public IUserObj
bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double& dDist, Vector3d& vtDir) ;
bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) ;
bool GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) ;
bool GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) ;
bool ApproxWithArcsIfUseful( ICurveComposite* pCompo) ;
bool ApproxWithLines( ICurveComposite* pCompo) ;
+117 -21
View File
@@ -42,6 +42,8 @@ using namespace std ;
// 2705 = "Error in SawFinishing : ApproxWithLines"
// 2706 = "Error in SawFinishing : Guide Line not along X or Y"
// 2707 = "Error in SawFinishing : GetElevation"
// 2708 = "Error in SawFinishing : CalculateAlongToolPath failed"
// 2709 = "Error in SawFinishing : CalculateAcrossToolPath failed"
//----------------------------------------------------------------------------
typedef PtrOwner<ICurve> POWNCURVE ;
@@ -325,6 +327,12 @@ SawFinishing::SetParam( int nType, double dVal)
case MPA_APPROX :
m_Params.m_dApprox = dVal ;
return true ;
case MPA_STARTADDLEN :
m_Params.m_dStartAddLen = dVal ;
return true ;
case MPA_ENDADDLEN :
m_Params.m_dEndAddLen = dVal ;
return true ;
}
return false ;
}
@@ -439,12 +447,16 @@ SawFinishing::Apply( bool bRecalc)
// calcolo le passate
if ( m_Params.m_nSubType == SAWFIN_SUB_ALONG) {
if ( ! CalculateAlongToolPath( nAuxId, nClId))
return false ;
if ( ! CalculateAlongToolPath( nAuxId, nClId)) {
m_pMchMgr->SetLastError( 2708, "Error in SawFinishing : CalculateAlongToolPath failed") ;
return false ;
}
}
else if ( m_Params.m_nSubType == SAWFIN_SUB_ACROSS) {
if ( ! CalculateAcrossToolPath( nAuxId, nClId))
if ( ! CalculateAcrossToolPath( nAuxId, nClId)) {
m_pMchMgr->SetLastError( 2709, "Error in SawFinishing : CalculateAcrossToolPath failed") ;
return false ;
}
}
// se lavorazione vuota, esco
@@ -546,6 +558,12 @@ SawFinishing::GetParam( int nType, double& dVal) const
case MPA_APPROX :
dVal = m_Params.m_dApprox ;
return true ;
case MPA_STARTADDLEN :
dVal = m_Params.m_dStartAddLen ;
return true ;
case MPA_ENDADDLEN :
dVal = m_Params.m_dEndAddLen ;
return true ;
}
dVal = 0 ;
return false ;
@@ -788,25 +806,33 @@ SawFinishing::CalculateAlongToolPath( int nAuxId, int nClId)
if ( ! CalculateSection( nSectGrpId, pSect))
return false ;
PtrOwner<ICurve> pCrv( pSect) ;
// recupero il riferimento globale delle sezioni
Frame3d frSect ;
m_pGeomDB->GetGroupGlobFrame( nSectGrpId, frSect) ;
// recupero il box globale delle sezioni
BBox3d b3Sect ;
m_pGeomDB->GetGlobalBBox( nSectGrpId, b3Sect) ;
// Recupero ed elaboro la linea guida
Point3d ptGdStart, ptGdEnd ;
Vector3d vtGdDir ;
int nGuideId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nAuxId, MCH_GUIDE)) ;
if ( ! CalculateGuideLine( nGuideId, ptGdStart, ptGdEnd, vtGdDir))
if ( ! CalculateGuideLine( nGuideId, b3Sect, ptGdStart, ptGdEnd, vtGdDir))
return false ;
if ( m_Params.m_bInvert) {
swap( ptGdStart, ptGdEnd) ;
vtGdDir.Invert() ;
}
// recupero il box globale della linea guida
BBox3d b3Guide ;
m_pGeomDB->GetGlobalBBox( nGuideId, b3Guide) ;
// recupero il box del grezzo in globale
BBox3d b3Test ;
b3Test.Add( b3Sect) ;
b3Test.Add( b3Guide) ;
BBox3d b3Raw ;
if ( ! GetRawGlobBox( m_nPhase, nGuideId, 2 * m_TParams.m_dThick, b3Raw) || b3Raw.IsEmpty()) {
if ( ! GetRawGlobBox( m_nPhase, b3Test, 10 * EPS_SMALL, b3Raw) || b3Raw.IsEmpty()) {
m_pMchMgr->SetLastError( 2702, "Error in SawFinishing : Empty RawBox") ;
return false ;
}
@@ -861,7 +887,7 @@ SawFinishing::CalculateAlongToolPath( int nAuxId, int nClId)
// eseguo la passata
if ( ! CalcAlongVerticalCuts( pCrv, nUmin, nUmax, frSect,
ptGdStart, ptGdEnd, vtGdDir,
dDepth, vtTool, vtCorr))
dDepth, b3Raw.GetMax().z, vtTool, vtCorr))
return false ;
nUmin = - 1 ;
}
@@ -900,7 +926,7 @@ SawFinishing::CalculateAlongToolPath( int nAuxId, int nClId)
if ( ! CalcAlongStdCuts( pCrv, nUmin, nUmax,
bSkipMin, bSkipMax, bInvert, frSect,
ptGdStart, ptGdEnd, vtGdDir,
dDepth, vtTool, vtCorr))
dDepth, b3Raw.GetMax().z, vtTool, vtCorr))
return false ;
// aggiorno stato
if ( vnClass[i] == CCL_VERT)
@@ -921,7 +947,7 @@ SawFinishing::CalculateAlongToolPath( int nAuxId, int nClId)
if ( ! CalcAlongStdCuts( pCrv, nUmin, nUmax,
bSkipMin, bSkipMax, bInvert, frSect,
ptGdStart, ptGdEnd, vtGdDir,
dDepth, vtTool, vtCorr))
dDepth, b3Raw.GetMax().z, vtTool, vtCorr))
return false ;
}
return true ;
@@ -937,25 +963,33 @@ SawFinishing::CalculateAcrossToolPath( int nAuxId, int nClId)
if ( ! CalculateSection( nSectGrpId, pSect))
return false ;
PtrOwner<ICurve> pCrv( pSect) ;
// recupero il riferimento globale delle sezioni
Frame3d frSect ;
m_pGeomDB->GetGroupGlobFrame( nSectGrpId, frSect) ;
// recupero il box globale delle sezioni
BBox3d b3Sect ;
m_pGeomDB->GetGlobalBBox( nSectGrpId, b3Sect) ;
// Recupero ed elaboro la linea guida
Point3d ptGdStart, ptGdEnd ;
Vector3d vtGdDir ;
int nGuideId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nAuxId, MCH_GUIDE)) ;
if ( ! CalculateGuideLine( nGuideId, ptGdStart, ptGdEnd, vtGdDir))
if ( ! CalculateGuideLine( nGuideId, b3Sect, ptGdStart, ptGdEnd, vtGdDir))
return false ;
if ( m_Params.m_bInvert) {
swap( ptGdStart, ptGdEnd) ;
vtGdDir.Invert() ;
}
// recupero il box globale della linea guida
BBox3d b3Guide ;
m_pGeomDB->GetGlobalBBox( nGuideId, b3Guide) ;
// recupero il box del grezzo in globale
BBox3d b3Test ;
b3Test.Add( b3Sect) ;
b3Test.Add( b3Guide) ;
BBox3d b3Raw ;
if ( ! GetRawGlobBox( m_nPhase, nGuideId, 2 * m_TParams.m_dThick, b3Raw) || b3Raw.IsEmpty()) {
if ( ! GetRawGlobBox( m_nPhase, b3Test, 10 * EPS_SMALL, b3Raw) || b3Raw.IsEmpty()) {
m_pMchMgr->SetLastError( 2702, "Error in SawFinishing : Empty RawBox") ;
return false ;
}
@@ -1065,7 +1099,6 @@ SawFinishing::CalculateAcrossToolPath( int nAuxId, int nClId)
return true ;
}
//----------------------------------------------------------------------------
bool
SawFinishing::CalculateSection( int nSectGrpId, ICurve*& pSect)
@@ -1141,9 +1174,13 @@ SawFinishing::CalculateSection( int nSectGrpId, ICurve*& pSect)
OffsCrvX.Make( pOvrCrv, dOffsX) ;
pCrv.Set( OffsCrvX.GetLongerCurve()) ;
//int nCrvId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ::Release( pCrv)) ;
//m_pGeomDB->Save( nCrvId, "C:\\EgtData\\Varie\\Test\\aaa.nge", GDB_SV_TXT) ;
//pCrv.Set( ::GetCurveComposite( m_pGeomDB->RemoveGeoObjAndErase( nCrvId))) ;
// eseguo trim (se richiesto)
if ( ! TrimSection( pCrv))
return false ;
int nCrvId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ::Release( pCrv)) ;
m_pGeomDB->Save( nCrvId, "C:\\EgtData\\Varie\\Test\\aaa.nge", GDB_SV_TXT) ;
pCrv.Set( ::GetCurveComposite( m_pGeomDB->RemoveGeoObjAndErase( nCrvId))) ;
pSect = Release( pCrv) ;
@@ -1152,7 +1189,53 @@ SawFinishing::CalculateSection( int nSectGrpId, ICurve*& pSect)
//----------------------------------------------------------------------------
bool
SawFinishing::CalculateGuideLine( int nGuideId, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir)
SawFinishing::TrimSection( ICurve* pCrv)
{
// se parametri di accorciamento iniziale e finale sono nulli, non faccio alcunché
if ( m_Params.m_dStartAddLen > - EPS_SMALL && m_Params.m_dEndAddLen > -EPS_SMALL)
return true ;
// box della sezione in locale
BBox3d b3Crv ;
pCrv->GetBBox( Frame3d(), b3Crv) ;
// riduco gli estremi in X
Point3d ptMin = b3Crv.GetMin() ;
Point3d ptMax = b3Crv.GetMax() ;
ptMin.x -= m_Params.m_dStartAddLen ;
ptMax.x += m_Params.m_dEndAddLen ;
double dDimX = ptMax.x - ptMin.x ;
double dDimY = ptMax.y - ptMin.y + 100 * EPS_SMALL ;
// regione del box nel piano XY
PtrOwner<ISurfFlatRegion> pSfr( GetSurfFlatRegionRectangle( dDimX, dDimY)) ;
if ( IsNull( pSfr))
return false ;
pSfr->Translate( Vector3d( ptMin.x, ptMin.y - 50 * EPS_SMALL, ptMin.z)) ;
// calcolo la classificazione della curva rispetto alla regione
CRVCVECTOR ccClass ;
if ( ! pSfr->GetCurveClassification( *pCrv, ccClass))
return false ;
// determino l'intervallo di curva da conservare
Intervals inOk ;
for ( auto& ccOne : ccClass) {
if ( ccOne.nClass == CRVC_IN || ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)
inOk.Add( ccOne.dParS, ccOne.dParE) ;
}
// eseguo trim
double dUmin, dUmax ;
if ( ! inOk.GetMinMax( dUmin, dUmax))
return false ;
return ( pCrv->TrimEndAtParam( dUmax) && pCrv->TrimStartAtParam( dUmin)) ;
}
//----------------------------------------------------------------------------
bool
SawFinishing::CalculateGuideLine( int nGuideId, const BBox3d& b3Sect,
Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir)
{
// recupero la linea guida
ICurve* pGuide = ::GetCurve( m_pGeomDB->GetGeoObj( nGuideId)) ;
@@ -1174,10 +1257,16 @@ SawFinishing::CalculateGuideLine( int nGuideId, Point3d& ptGdStart, Point3d& ptG
m_pMchMgr->SetLastError( 2706, "Error in SawFinishing : Guide Line not along X or Y") ;
return false ;
}
// recupero il box globale della linea guida
BBox3d b3Guide ;
m_pGeomDB->GetGlobalBBox( nGuideId, b3Guide) ;
// recupero il box del grezzo in globale
BBox3d b3Test ;
b3Test.Add( b3Sect) ;
b3Test.Add( b3Guide) ;
BBox3d b3Raw ;
if ( ! GetRawGlobBox( m_nPhase, nGuideId, 2 * m_TParams.m_dThick, b3Raw) || b3Raw.IsEmpty()) {
if ( ! GetRawGlobBox( m_nPhase, b3Test, 10 * EPS_SMALL, b3Raw) || b3Raw.IsEmpty()) {
m_pMchMgr->SetLastError( 2702, "Error in SawFinishing : Empty RawBox") ;
return false ;
}
@@ -1252,7 +1341,7 @@ SawFinishing::ClassifySection( ICurve* pCrv, INTVECTOR& vnClass)
bool
SawFinishing::CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const Frame3d& frSect,
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
double dDepth, const Vector3d& vtTool, const Vector3d& vtCorr)
double dDepth, double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr)
{
// Ingombro del taglio
BBox3d b3Cut ;
@@ -1291,6 +1380,8 @@ SawFinishing::CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const
return false ;
}
dElev = max( dElev, dElev2) ;
if ( dElev < EPS_SMALL)
dElev = max( dRawMaxZ - ptStart.z, dRawMaxZ - ptEnd.z) ;
// la confronto con il massimo affondamento e con la massima lavorazione della lama
double dMaxDepth = min( dDepth, m_TParams.m_dMaxMat) ;
if ( dElev > dMaxDepth) {
@@ -1334,7 +1425,7 @@ bool
SawFinishing::CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
bool bSkipMin, bool bSkipMax, bool bInvert, const Frame3d& frSect,
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
double dDepth, const Vector3d& vtTool, const Vector3d& vtCorr)
double dDepth, double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr)
{
// Calcolo dello step tra le passate
double dStep = max( m_Params.m_dSideStep, 10 * EPS_SMALL) ;
@@ -1353,6 +1444,8 @@ SawFinishing::CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
bool bSkipFin = ( bInvert ? bSkipMin : bSkipMax) ;
int nIni = ( bSkipIni ? 1 : 0) ;
int nFin = ( bSkipFin ? nStep - 1 : nStep) ;
if ( nFin < nIni)
return true ;
for ( int i = nIni ; i <= nFin ; ++ i) {
// calcolo del parametro
double dLcurr = ( bInvert ? dLmax - i * dStep : dLmin + i * dStep) ;
@@ -1374,6 +1467,8 @@ SawFinishing::CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
return false ;
}
dElev = max( dElev, dElev2) ;
if ( dElev < EPS_SMALL)
dElev = max( dRawMaxZ - ptStart.z, dRawMaxZ - ptEnd.z) ;
// la confronto con il massimo affondamento e con la massima lavorazione della lama
double dMaxDepth = min( dDepth, m_TParams.m_dMaxMat) ;
if ( dElev > dMaxDepth) {
@@ -1731,7 +1826,8 @@ SawFinishing::AddApproach( const Point3d& ptP, const Vector3d& vtCorr,
//----------------------------------------------------------------------------
bool
SawFinishing::AddRetract( const Point3d& ptP, const Vector3d& vtCorr, double dSafeZ, double dElev, double dAppr)
SawFinishing::AddRetract( const Point3d& ptP, const Vector3d& vtCorr,
double dSafeZ, double dElev, double dAppr)
{
if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) {
// 4 -> movimento di risalita sopra il punto finale
+5 -3
View File
@@ -71,15 +71,17 @@ class SawFinishing : public Machining
bool CalculateAlongToolPath( int nAuxId, int nClId) ;
bool CalculateAcrossToolPath( int nAuxId, int nClId) ;
bool CalculateSection( int nSectGrpId, ICurve*& pSect) ;
bool CalculateGuideLine( int nGuideId, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir) ;
bool TrimSection( ICurve* pCrv) ;
bool CalculateGuideLine( int nGuideId, const BBox3d& b3Sect,
Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir) ;
bool ClassifySection( ICurve* pCrv, INTVECTOR& vnClass) ;
bool CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const Frame3d& frSect,
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
double dDepth, const Vector3d& vtTool, const Vector3d& vtCorr) ;
double dDepth, double dRaxMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr) ;
bool CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
bool bSkipMin, bool bSkipMax, bool bInvert, const Frame3d& frSect,
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
double dDepth, const Vector3d& vtTool, const Vector3d& vtCorr) ;
double dDepth, double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr) ;
bool CalcAlongOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bVert) ;
bool CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
+29 -1
View File
@@ -28,6 +28,7 @@ using namespace std ;
enum nSawFinishingKey {
KEY_APPR = 0,
KEY_DH,
KEY_EAL,
KEY_F,
KEY_FE,
KEY_FS,
@@ -42,6 +43,7 @@ enum nSawFinishingKey {
KEY_OR,
KEY_PS,
KEY_S,
KEY_SAL,
KEY_SCC,
KEY_SS,
KEY_ST,
@@ -55,6 +57,7 @@ enum nSawFinishingKey {
static const std::array<std::string,KEY_ZZZ> sSawFinishingKey = {
"APPR",
"DH",
"EAL",
"F",
"FE",
"FS",
@@ -69,6 +72,7 @@ static const std::array<std::string,KEY_ZZZ> sSawFinishingKey = {
"OR",
"PS",
"S",
"SAL",
"SCC",
"SS",
"ST",
@@ -131,6 +135,8 @@ SawFinishingData::CopyFrom( const MachiningData* pMdata)
m_nStepType = pSdata->m_nStepType ;
m_nLeadLinkType = pSdata->m_nLeadLinkType ;
m_dApprox = pSdata->m_dApprox ;
m_dStartAddLen = pSdata->m_dStartAddLen ;
m_dEndAddLen = pSdata->m_dEndAddLen ;
m_sSysNotes = pSdata->m_sSysNotes ;
m_sUserNotes = pSdata->m_sUserNotes ;
return true ;
@@ -170,6 +176,8 @@ SawFinishingData::SameAs(const MachiningData* pMdata) const
m_nStepType == pSdata->m_nStepType &&
m_nLeadLinkType == pSdata->m_nLeadLinkType &&
abs( m_dApprox - pSdata->m_dApprox) < EPS_MACH_LEN_PAR &&
abs( m_dStartAddLen - pSdata->m_dStartAddLen) < EPS_MACH_LEN_PAR &&
abs( m_dEndAddLen - pSdata->m_dEndAddLen) < EPS_MACH_LEN_PAR &&
m_sSysNotes == pSdata->m_sSysNotes &&
m_sUserNotes == pSdata->m_sUserNotes) ;
}
@@ -218,6 +226,9 @@ SawFinishingData::FromString( const string& sString, int& nKey)
if ( m_sDepth.empty())
m_sDepth = "0" ;
break ;
case KEY_EAL :
bOk = ::FromString( sVal, m_dEndAddLen) ;
break ;
case KEY_F :
bOk = ::FromString( sVal, m_dFeed) ;
break ;
@@ -261,6 +272,9 @@ SawFinishingData::FromString( const string& sString, int& nKey)
case KEY_S :
bOk = ::FromString( sVal, m_dSpeed) ;
break ;
case KEY_SAL :
bOk = ::FromString( sVal, m_dStartAddLen) ;
break ;
case KEY_SCC :
bOk = ::FromString( sVal, m_nSolCh) ;
break ;
@@ -299,6 +313,7 @@ SawFinishingData::ToString( int nInd) const
switch ( nInd) {
case KEY_APPR : return ( sSawFinishingKey[KEY_APPR] + "=" + ::ToString( m_dApprox)) ;
case KEY_DH : return ( sSawFinishingKey[KEY_DH] + "=" + m_sDepth) ;
case KEY_EAL : return ( sSawFinishingKey[KEY_EAL] + "=" + ::ToString( m_dEndAddLen)) ;
case KEY_F : return ( sSawFinishingKey[KEY_F] + "=" + ::ToString( m_dFeed)) ;
case KEY_FE : return ( sSawFinishingKey[KEY_FE] + "=" + ::ToString( m_dEndFeed)) ;
case KEY_FS : return ( sSawFinishingKey[KEY_FS] + "=" + ::ToString( m_dStartFeed)) ;
@@ -313,6 +328,7 @@ SawFinishingData::ToString( int nInd) const
case KEY_OR : return ( sSawFinishingKey[KEY_OR] + "=" + ::ToString( m_dOffsR)) ;
case KEY_PS : return ( sSawFinishingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ;
case KEY_S : return ( sSawFinishingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ;
case KEY_SAL : return ( sSawFinishingKey[KEY_SAL] + "=" + ::ToString( m_dStartAddLen)) ;
case KEY_SCC : return ( sSawFinishingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ;
case KEY_SS : return ( sSawFinishingKey[KEY_SS] + "=" + ::ToString( m_dSideStep)) ;
case KEY_ST : return ( sSawFinishingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ;
@@ -330,7 +346,7 @@ bool
SawFinishingData::IsOptional( int nKey) const
{
return ( nKey == KEY_FV || nKey == KEY_ST || nKey == KEY_SCC || nKey == KEY_SUBTYPE ||
nKey == KEY_INV) ;
nKey == KEY_INV || nKey == KEY_EAL || nKey == KEY_SAL) ;
}
//----------------------------------------------------------------------------
@@ -479,6 +495,12 @@ SawFinishingData::SetParam( int nType, double dVal)
case MPA_APPROX :
m_dApprox = dVal ;
return true ;
case MPA_STARTADDLEN :
m_dStartAddLen = dVal ;
return true ;
case MPA_ENDADDLEN :
m_dEndAddLen = dVal ;
return true ;
}
return false ;
}
@@ -599,6 +621,12 @@ SawFinishingData::GetParam( int nType, double& dVal) const
case MPA_APPROX :
dVal = m_dApprox ;
return true ;
case MPA_STARTADDLEN :
dVal = m_dStartAddLen ;
return true ;
case MPA_ENDADDLEN :
dVal = m_dEndAddLen ;
return true ;
}
dVal = 0 ;
return false ;
+4 -1
View File
@@ -38,6 +38,8 @@ struct SawFinishingData : public MachiningData
int m_nStepType ; // tipo di lavorazione a step (una via, va e vieni)
int m_nLeadLinkType ; // tipo di attacco/uscita/collegamento ( centro, fuori)
double m_dApprox ; // valore di approssimazione per superfici
double m_dStartAddLen ; // lunghezza da aggiungere/togliere all'inizio
double m_dEndAddLen ; // lunghezza da aggiungere/togliere alla fine
std::string m_sSysNotes ; // note interne
std::string m_sUserNotes ; // note dell'utente
@@ -45,7 +47,8 @@ struct SawFinishingData : public MachiningData
: m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0), m_dVertFeed(0),
m_dOffsR( UNKNOWN_PAR),
m_bInvert( false), m_nHeadSide( 0), m_dStartPos( 0), m_dSideStep( 0), m_dStep( 0),
m_nSubType( 0), m_nStepType( 0), m_nLeadLinkType( 0), m_dApprox( 0) {}
m_nSubType( 0), m_nStepType( 0), m_nLeadLinkType( 0), m_dApprox( 0),
m_dStartAddLen( 0), m_dEndAddLen( 0) {}
SawFinishingData* Clone( void) const override ;
bool CopyFrom( const MachiningData* pMdata) override ;
bool SameAs(const MachiningData* pMdata) const override ;
+89 -7
View File
@@ -25,6 +25,7 @@
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EgkOffsetCurveOnX.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include "/EgtDev/Include/EGkIntervals.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -42,6 +43,7 @@ using namespace std ;
// 2606 = "Error in SawRoughing : Depth not computable"
// 2607 = "Error in SawRoughing : CalculateToolAndCorrVersors"
// 2608 = "Error in SawRoughing : GetElevation"
// 2609 = "Error in SawRoughing : TrimSection failed"
//----------------------------------------------------------------------------
typedef PtrOwner<ICurve> POWNCURVE ;
@@ -310,6 +312,12 @@ SawRoughing::SetParam( int nType, double dVal)
case MPA_APPROX :
m_Params.m_dApprox = dVal ;
return true ;
case MPA_STARTADDLEN :
m_Params.m_dStartAddLen = dVal ;
return true ;
case MPA_ENDADDLEN :
m_Params.m_dEndAddLen = dVal ;
return true ;
}
return false ;
}
@@ -354,7 +362,7 @@ SawRoughing::SetGeometry( const SELVECTOR& vIds)
// test sull'entità
int nSubs ;
if ( ! VerifyGeometry( Id, nSubs)) {
string sOut = "Entity " + ToString( Id) + " skipped by Sawing" ;
string sOut = "Entity " + ToString( Id) + " skipped by SawRoughing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
continue ;
}
@@ -520,6 +528,12 @@ SawRoughing::GetParam( int nType, double& dVal) const
case MPA_APPROX :
dVal = m_Params.m_dApprox ;
return true ;
case MPA_STARTADDLEN :
dVal = m_Params.m_dStartAddLen ;
return true ;
case MPA_ENDADDLEN :
dVal = m_Params.m_dEndAddLen ;
return true ;
}
dVal = 0 ;
return false ;
@@ -771,6 +785,9 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId)
// recupero il riferimento globale delle sezioni
Frame3d frSect ;
m_pGeomDB->GetGroupGlobFrame( nSectGrpId, frSect) ;
// recupero il box globale delle sezioni
BBox3d b3Sect ;
m_pGeomDB->GetGlobalBBox( nSectGrpId, b3Sect) ;
// recupero la linea guida
int nGuideId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nAuxId, MCH_GUIDE)) ;
@@ -790,10 +807,16 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId)
m_pMchMgr->SetLastError( 2602, "Error in SawRoughing : Guide Line not along X or Y") ;
return false ;
}
// recupero il box globale della linea guida
BBox3d b3Guide ;
m_pGeomDB->GetGlobalBBox( nGuideId, b3Guide) ;
// recupero il box del grezzo in globale e nel riferimento locale delle sezioni
BBox3d b3Test ;
b3Test.Add( b3Sect) ;
b3Test.Add( b3Guide) ;
BBox3d b3Raw ;
if ( ! GetRawGlobBox( m_nPhase, nGuideId, 2 * m_TParams.m_dThick, b3Raw) || b3Raw.IsEmpty()) {
if ( ! GetRawGlobBox( m_nPhase, b3Test, 10 * EPS_SMALL, b3Raw) || b3Raw.IsEmpty()) {
m_pMchMgr->SetLastError( 2603, "Error in SawRoughing : Empty RawBox") ;
return false ;
}
@@ -884,13 +907,21 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId)
m_pMchMgr->SetLastError( 2605, "Error in SawRoughing : OffsetCurveOnX") ;
return false ;
}
// determino l'ingombro della curva risultante in locale
BBox3d b3Crv ;
pCrv->GetLocalBBox( b3Crv) ;
// determino l'intervallo di curva da conservare
if ( ! TrimSection( pCrv)) {
m_pMchMgr->SetLastError( 2609, "Error in SawRoughing : TrimSection failed") ;
return false ;
}
//int nBBBId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ::Release( pCrv)) ;
//m_pGeomDB->Save( nBBBId, "C:\\EgtData\\Varie\\Test\\bbb.nge", GDB_SV_TXT) ;
//pCrv.Set( ::GetCurve( m_pGeomDB->RemoveGeoObjAndErase( nBBBId))) ;
// determino l'ingombro della curva risultante in locale
BBox3d b3Crv ;
pCrv->GetLocalBBox( b3Crv) ;
// valuto l'espressione dell'affondamento
ExeLuaSetGlobNumVar( "TH", 0) ;
ExeLuaSetGlobNumVar( "RB", b3Raw.GetMax().z - b3Raw.GetMin().z) ;
@@ -921,6 +952,7 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId)
// Determino eventuali pareti verticali (sono in senso decrescente di X)
DBLVECTOR vdVr ;
double dPrevX = INFINITO ;
const ICurveComposite* pCompo = GetCurveComposite( pCrv) ;
if ( pCompo != nullptr) {
const ICurve* pSimpCrv = pCompo->GetFirstCurve() ;
@@ -928,8 +960,13 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId)
Point3d ptStart, ptEnd ;
pSimpCrv->GetStartPoint( ptStart) ;
pSimpCrv->GetEndPoint( ptEnd) ;
if ( abs( ptEnd.x - ptStart.x) < EPS_SMALL)
vdVr.push_back( ( ptEnd.x + ptStart.x) / 2) ;
if ( abs( ptEnd.x - ptStart.x) < EPS_SMALL) {
double dX = ( ptEnd.x + ptStart.x) / 2 ;
if ( dX < dPrevX - EPS_SMALL) {
vdVr.push_back( dX) ;
dPrevX = dX ;
}
}
pSimpCrv = pCompo->GetNextCurve() ;
}
}
@@ -1027,6 +1064,51 @@ SawRoughing::CalculateToolPath( int nAuxId, int nClId)
return true ;
}
//----------------------------------------------------------------------------
bool
SawRoughing::TrimSection( ICurve* pCrv)
{
// se parametri di accorciamento iniziale e finale sono nulli, non faccio alcunché
if ( m_Params.m_dStartAddLen > - EPS_SMALL && m_Params.m_dEndAddLen > -EPS_SMALL)
return true ;
// box della sezione in locale
BBox3d b3Crv ;
pCrv->GetBBox( Frame3d(), b3Crv) ;
// riduco gli estremi in X
Point3d ptMin = b3Crv.GetMin() ;
Point3d ptMax = b3Crv.GetMax() ;
ptMin.x -= m_Params.m_dStartAddLen ;
ptMax.x += m_Params.m_dEndAddLen ;
double dDimX = ptMax.x - ptMin.x ;
double dDimY = ptMax.y - ptMin.y + 100 * EPS_SMALL ;
// regione del box nel piano XY
PtrOwner<ISurfFlatRegion> pSfr( GetSurfFlatRegionRectangle( dDimX, dDimY)) ;
if ( IsNull( pSfr))
return false ;
pSfr->Translate( Vector3d( ptMin.x, ptMin.y - 50 * EPS_SMALL, ptMin.z)) ;
// calcolo la classificazione della curva rispetto alla regione
CRVCVECTOR ccClass ;
if ( ! pSfr->GetCurveClassification( *pCrv, ccClass))
return false ;
// determino l'intervallo di curva da conservare
Intervals inOk ;
for ( auto& ccOne : ccClass) {
if ( ccOne.nClass == CRVC_IN || ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)
inOk.Add( ccOne.dParS, ccOne.dParE) ;
}
// eseguo trim
double dUmin, dUmax ;
if ( ! inOk.GetMinMax( dUmin, dUmax))
return false ;
return ( pCrv->TrimEndAtParam( dUmax) && pCrv->TrimStartAtParam( dUmin)) ;
}
//----------------------------------------------------------------------------
bool
SawRoughing::CalculateOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
+1
View File
@@ -69,6 +69,7 @@ class SawRoughing : public Machining
ICurve* GetCurve( SelData Id) ;
bool AdjustGeometry( int nAuxId) ;
bool CalculateToolPath( int nAuxId, int nClId) ;
bool TrimSection( ICurve* pCrv) ;
bool CalculateOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bFirst, bool bLast) ;
bool CalculateZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
+29 -1
View File
@@ -28,6 +28,7 @@ using namespace std ;
enum nSawRoughingKey {
KEY_APPR = 0,
KEY_DH,
KEY_EAL,
KEY_F,
KEY_FE,
KEY_FS,
@@ -41,6 +42,7 @@ enum nSawRoughingKey {
KEY_OR,
KEY_PS,
KEY_S,
KEY_SAL,
KEY_SCC,
KEY_SS,
KEY_ST,
@@ -53,6 +55,7 @@ enum nSawRoughingKey {
static const std::array<std::string,KEY_ZZZ> sSawRoughingKey = {
"APPR",
"DH",
"EAL",
"F",
"FE",
"FS",
@@ -66,6 +69,7 @@ static const std::array<std::string,KEY_ZZZ> sSawRoughingKey = {
"OR",
"PS",
"S",
"SAL",
"SCC",
"SS",
"ST",
@@ -125,6 +129,8 @@ SawRoughingData::CopyFrom( const MachiningData* pMdata)
m_nStepType = pSdata->m_nStepType ;
m_nLeadLinkType = pSdata->m_nLeadLinkType ;
m_dApprox = pSdata->m_dApprox ;
m_dStartAddLen = pSdata->m_dStartAddLen ;
m_dEndAddLen = pSdata->m_dEndAddLen ;
m_sSysNotes = pSdata->m_sSysNotes ;
m_sUserNotes = pSdata->m_sUserNotes ;
return true ;
@@ -162,6 +168,8 @@ SawRoughingData::SameAs(const MachiningData* pMdata) const
m_nStepType == pSdata->m_nStepType &&
m_nLeadLinkType == pSdata->m_nLeadLinkType &&
abs( m_dApprox - pSdata->m_dApprox) < EPS_MACH_LEN_PAR &&
abs( m_dStartAddLen - pSdata->m_dStartAddLen) < EPS_MACH_LEN_PAR &&
abs( m_dEndAddLen - pSdata->m_dEndAddLen) < EPS_MACH_LEN_PAR &&
m_sSysNotes == pSdata->m_sSysNotes &&
m_sUserNotes == pSdata->m_sUserNotes) ;
}
@@ -210,6 +218,9 @@ SawRoughingData::FromString( const string& sString, int& nKey)
if ( m_sDepth.empty())
m_sDepth = "0" ;
break ;
case KEY_EAL :
bOk = ::FromString( sVal, m_dEndAddLen) ;
break ;
case KEY_F :
bOk = ::FromString( sVal, m_dFeed) ;
break ;
@@ -250,6 +261,9 @@ SawRoughingData::FromString( const string& sString, int& nKey)
case KEY_S :
bOk = ::FromString( sVal, m_dSpeed) ;
break ;
case KEY_SAL :
bOk = ::FromString( sVal, m_dStartAddLen) ;
break ;
case KEY_SCC :
bOk = ::FromString( sVal, m_nSolCh) ;
break ;
@@ -285,6 +299,7 @@ SawRoughingData::ToString( int nInd) const
switch ( nInd) {
case KEY_APPR : return ( sSawRoughingKey[KEY_APPR] + "=" + ::ToString( m_dApprox)) ;
case KEY_DH : return ( sSawRoughingKey[KEY_DH] + "=" + m_sDepth) ;
case KEY_EAL : return ( sSawRoughingKey[KEY_EAL] + "=" + ::ToString( m_dEndAddLen)) ;
case KEY_F : return ( sSawRoughingKey[KEY_F] + "=" + ::ToString( m_dFeed)) ;
case KEY_FE : return ( sSawRoughingKey[KEY_FE] + "=" + ::ToString( m_dEndFeed)) ;
case KEY_FS : return ( sSawRoughingKey[KEY_FS] + "=" + ::ToString( m_dStartFeed)) ;
@@ -298,6 +313,7 @@ SawRoughingData::ToString( int nInd) const
case KEY_OR : return ( sSawRoughingKey[KEY_OR] + "=" + ::ToString( m_dOffsR)) ;
case KEY_PS : return ( sSawRoughingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ;
case KEY_S : return ( sSawRoughingKey[KEY_S] + "=" + ::ToString( m_dSpeed)) ;
case KEY_SAL : return ( sSawRoughingKey[KEY_SAL] + "=" + ::ToString( m_dStartAddLen)) ;
case KEY_SCC : return ( sSawRoughingKey[KEY_SCC] + "=" + ::ToString( m_nSolCh)) ;
case KEY_SS : return ( sSawRoughingKey[KEY_SS] + "=" + ::ToString( m_dSideStep)) ;
case KEY_ST : return ( sSawRoughingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ;
@@ -313,7 +329,7 @@ SawRoughingData::ToString( int nInd) const
bool
SawRoughingData::IsOptional( int nKey) const
{
return ( nKey == KEY_SCC) ;
return ( nKey == KEY_SCC || nKey == KEY_EAL || nKey == KEY_SAL) ;
}
//----------------------------------------------------------------------------
@@ -447,6 +463,12 @@ SawRoughingData::SetParam( int nType, double dVal)
case MPA_APPROX :
m_dApprox = dVal ;
return true ;
case MPA_STARTADDLEN :
m_dStartAddLen = dVal ;
return true ;
case MPA_ENDADDLEN :
m_dEndAddLen = dVal ;
return true ;
}
return false ;
}
@@ -561,6 +583,12 @@ SawRoughingData::GetParam( int nType, double& dVal) const
case MPA_APPROX :
dVal = m_dApprox ;
return true ;
case MPA_STARTADDLEN :
dVal = m_dStartAddLen ;
return true ;
case MPA_ENDADDLEN :
dVal = m_dEndAddLen ;
return true ;
}
dVal = 0 ;
return false ;
+4 -1
View File
@@ -36,6 +36,8 @@ struct SawRoughingData : public MachiningData
int m_nStepType ; // tipo di lavorazione a step (una via, va e vieni)
int m_nLeadLinkType ; // tipo di attacco/uscita/collegamento ( centro, fuori)
double m_dApprox ; // valore di approssimazione per superfici
double m_dStartAddLen ; // lunghezza da aggiungere/togliere all'inizio
double m_dEndAddLen ; // lunghezza da aggiungere/togliere alla fine
std::string m_sSysNotes ; // note interne
std::string m_sUserNotes ; // note dell'utente
@@ -43,7 +45,8 @@ struct SawRoughingData : public MachiningData
: m_ToolUuid(), m_nSolCh( 0), m_dSpeed( 0), m_dFeed( 0), m_dStartFeed( 0), m_dEndFeed( 0), m_dTipFeed( 0),
m_dOffsR( UNKNOWN_PAR), m_dOffsL( UNKNOWN_PAR),
m_nHeadSide(0), m_dStartPos( 0), m_dSideStep( 0), m_dStep( 0),
m_nStepType( 0), m_nLeadLinkType( 0), m_dApprox( 0) {}
m_nStepType( 0), m_nLeadLinkType( 0), m_dApprox( 0),
m_dStartAddLen( 0), m_dEndAddLen( 0) {}
SawRoughingData* Clone( void) const override ;
bool CopyFrom( const MachiningData* pMdata) override ;
bool SameAs(const MachiningData* pMdata) const override ;