EgtMachKernel 2.2h3 :

- migliorato calcolo elevazione di svuotature
- corretti errori in svuotature piccole con lati aperti
- corretta gestione appiattimento contorni di svuotature.
This commit is contained in:
Dario Sassi
2020-08-30 11:29:51 +00:00
parent 8c9b760f94
commit e7d3a7d7af
3 changed files with 122 additions and 52 deletions
BIN
View File
Binary file not shown.
+121 -51
View File
@@ -1403,7 +1403,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
}
// verifico sia piana e se necessario la appiattisco
PtrOwner<ICurve> pFlatCrv( FlattenCurve( *pCompo, 50 * EPS_SMALL, 50 * EPS_ANG_SMALL)) ;
PtrOwner<ICurve> pFlatCrv( FlattenCurve( *pCompo, 50 * EPS_SMALL, 50 * EPS_ANG_SMALL, FLTCRV_USE_EXTR)) ;
if ( IsNull( pFlatCrv)) {
Plane3d plPlane ;
if ( ! pCompo->IsFlat( plPlane, true, 50 * EPS_SMALL))
@@ -1443,8 +1443,9 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
// sposto l'inizio a metà del tratto più lungo ( o aperto più lungo)
if ( bMidOpen) {
const double LEN_OUT = 5 ;
double dPar ; int nFlag ;
bMidOpen = ( DistPointCurve( ptMidOpen, *pCompo).GetParamAtMinDistPoint( 0, dPar, nFlag) && pCompo->ChangeStartPoint( dPar)) ;
bMidOpen = ( DistPointCurve( ptMidOpen + LEN_OUT * vtMidOut, *pCompo).GetParamAtMinDistPoint( 0, dPar, nFlag) && pCompo->ChangeStartPoint( dPar)) ;
}
if ( ! bMidOpen)
AdjustContourStart( pCompo) ;
@@ -1490,7 +1491,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
// calcolo l'elevazione massima
double dElev ;
if ( CalcPathElevation( pCompo, vtTool, dDepth, 0.5 * m_TParams.m_dDiam, dElev)) {
if ( CalcRegionElevation( pCompo, vtTool, dDepth, 0.5 * m_TParams.m_dDiam, dElev)) {
if ( dElev < EPS_SMALL && AreSameVectorApprox( vtExtr, Z_AX)) {
BBox3d b3Crv ;
pCompo->GetLocalBBox( b3Crv) ;
@@ -1635,35 +1636,24 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
//----------------------------------------------------------------------------
bool
Pocketing::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad,
double& dElev) const
Pocketing::CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad,
double& dElev) const
{
// inizializzo l'elevazione
dElev = 0 ;
// affondamento come vettore
Vector3d vtDepth = vtTool * dDepth ;
// Campiono il contorno
int nMaxInd = pCompo->GetCurveCount() - 1 ;
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
// curva corrente
const ICurve* pCrvC = pCompo->GetCurve( i) ;
// calcolo elevazione
Point3d ptStart ; pCrvC->GetStartPoint( ptStart) ;
Point3d ptMid ; pCrvC->GetMidPoint( ptMid) ;
Point3d ptEnd ; pCrvC->GetEndPoint( ptEnd) ;
// elevazione della curva
double dCurrElev ;
Point3d ptStart, ptMid, ptEnd ;
pCrvC->GetStartPoint( ptStart) ;
pCrvC->GetMidPoint( ptMid) ;
pCrvC->GetEndPoint( ptEnd) ;
Vector3d vtStartPerp, vtMidPerp, vtEndPerp, vtTg ;
pCrvC->GetStartDir( vtTg) ;
vtStartPerp = vtTg ^ vtTool ;
vtStartPerp.Normalize() ;
vtStartPerp *= dRad ;
pCrvC->GetMidDir( vtTg) ;
vtMidPerp = vtTg ^ vtTool ;
vtMidPerp.Normalize() ;
vtMidPerp *= dRad ;
pCrvC->GetEndDir( vtTg) ;
vtEndPerp = vtTg ^ vtTool ;
vtEndPerp.Normalize() ;
vtEndPerp *= dRad ;
Vector3d vtDepth = vtTool * dDepth ;
// linea centro utensile
if ( GetElevation( m_nPhase, ptStart - vtDepth, ptMid - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
if ( dCurrElev > dElev)
dElev = dCurrElev ;
@@ -1672,27 +1662,87 @@ Pocketing::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtT
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
return false ;
}
// da una parte
if ( GetElevation( m_nPhase, ptStart + vtStartPerp - vtDepth, ptMid + vtMidPerp - vtDepth,
ptEnd + vtEndPerp - vtDepth, vtTool, dCurrElev)) {
if ( dCurrElev > dElev)
dElev = dCurrElev ;
}
else {
}
// Campiono l'interno con una griglia (uso linee parallele a X)
// determino il riferimento di base
Frame3d frPocket ;
Point3d ptCen ; pCompo->GetCentroid( ptCen) ;
frPocket.Set( ptCen, vtTool) ;
// copio il contorno e lo porto nel riferimento
PtrOwner<ICurveComposite> pCompoL( pCompo->Clone()) ;
if ( IsNull( pCompoL) || ! pCompoL->ToLoc( frPocket)) {
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
return false ;
}
// ingombro del contorno in locale
BBox3d b3Pocket ;
pCompoL->GetLocalBBox( b3Pocket) ;
Point3d ptMin ; double dDimX, dDimY, dDimZ ;
b3Pocket.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ;
// passi in Y
const double STEP = 50 ;
int nYStep = max( int( ceil( ( dDimY - 20 * EPS_SMALL) / STEP)), 2) ;
double dYStep = ( nYStep > 0 ? ( dDimY - 20 * EPS_SMALL) / nYStep : 0) ;
// calcolo le linee di svuotatura
int nCount = 0 ;
for ( int i = 1 ; i < nYStep ; ++ i) {
// definisco la linea
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
const double EXP_LEN = 1.0 ;
Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + 10 * EPS_SMALL + i * dYStep, ptMin.z + dDimZ) ;
if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN)) {
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
return false ;
}
// dall'altra parte
if ( GetElevation( m_nPhase, ptStart - vtStartPerp - vtDepth, ptMid - vtMidPerp - vtDepth,
ptEnd - vtEndPerp - vtDepth, vtTool, dCurrElev)) {
if ( dCurrElev > dElev)
dElev = dCurrElev ;
// calcolo la classificazione della curva rispetto al contorno
IntersCurveCurve intCC( *pLine, *pCompoL) ;
CRVCVECTOR ccClass ;
if ( intCC.GetCurveClassification( 0, ccClass)) {
// determino gli intervalli di curva interni
Intervals inOk ;
for ( auto& ccOne : ccClass) {
if ( ccOne.nClass == CRVC_IN) {
Point3d ptStart ;
pLine->GetPointD1D2( ccOne.dParS, ICurve::FROM_PLUS, ptStart) ;
ptStart.ToGlob( frPocket) ;
Point3d ptEnd ;
pLine->GetPointD1D2( ccOne.dParE, ICurve::FROM_MINUS, ptEnd) ;
ptEnd.ToGlob( frPocket) ;
// elevazione della curva
double dCurrElev ;
if ( GetElevation( m_nPhase, ptStart - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
if ( dCurrElev > dElev)
dElev = dCurrElev ;
}
else {
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
return false ;
}
}
}
}
// altrimenti uso tutta la curva
else {
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
return false ;
Point3d ptStart ;
pLine->GetStartPoint( ptStart) ;
ptStart.ToGlob( frPocket) ;
Point3d ptEnd ;
pLine->GetEndPoint( ptEnd) ;
ptEnd.ToGlob( frPocket) ;
// elevazione della curva
double dCurrElev ;
if ( GetElevation( m_nPhase, ptStart - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
if ( dCurrElev > dElev)
dElev = dCurrElev ;
}
else {
m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
return false ;
}
}
}
return true ;
}
@@ -3057,7 +3107,8 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
while ( nIter < MAX_ITER) {
// calcolo
OffsetCurve OffsCrv ;
if ( ! OffsCrv.Make( ( nIter == 0 ? (ICurve*) pCompo : pOffs), - dOffs, ICurve::OFF_FILLET)) {
if ( ! OffsCrv.Make( ( nIter == 0 ? (ICurve*) pCompo : pOffs), - dOffs, ICurve::OFF_FILLET) ||
( nIter == 0 && nReg == 0 && OffsCrv.GetCurveCount() == 0)) {
m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ;
return false ;
}
@@ -3102,6 +3153,13 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
pOffs.Set( Release( pNextOffs)) ;
// nuovo valore pari allo step
dOffs = GetSideStep() ;
// se raggio della curva offsetta è inferiore al raggio fresa
if ( dRad < dTRad + EPS_ZERO) {
// inserisco l'offset nel vettore
vOffs.emplace_back( Release( pOffs)) ;
// esco
break ;
}
}
// se altrimenti riducibile, provo con offset ridotto al raggio utensile
else if ( ! bSmallRad) {
@@ -3740,8 +3798,18 @@ Pocketing::GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMi
// recupero il vettore estrusione
Vector3d vtExtr = Z_AX ;
pCompo->GetExtrusion( vtExtr) ;
// verifico se tutti i lati sono aperti
bool bAllOpen = true ;
const ICurve* pMyCrv = pCompo->GetFirstCurve() ;
while ( pMyCrv != nullptr) {
if ( pMyCrv->GetTempProp() != 1) {
bAllOpen = false ;
break ;
}
pMyCrv = pCompo->GetNextCurve() ;
}
// richiedo lunghezza superiore a diametro utensile più doppio offset radiale
double dMaxLen = m_TParams.m_dDiam + 2 * GetOffsR() - EPS_SMALL ;
double dMaxLen = ( bAllOpen ? 0 : m_TParams.m_dDiam + 2 * GetOffsR() - EPS_SMALL) ;
// ciclo sulle singole curve
bool bFound = false ;
const ICurve* pPrevCrv = pCompo->GetLastCurve() ;
@@ -3760,17 +3828,19 @@ Pocketing::GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMi
pNextCrv->GetLength( dLenNext) ;
// verifico la curva corrente
if ( pCrv->GetTempProp() == 1) {
// contributo dalle entità adiacenti
// contributo dalle entità adiacenti (se non tutte aperte)
double dLenAgg = 0 ;
if ( pPrevCrv != nullptr && pPrevCrv->GetTempProp() == 1) {
Vector3d vtPrevEnd ; pPrevCrv->GetEndDir( vtPrevEnd) ;
Vector3d vtStart ; pCrv->GetStartDir( vtStart) ;
dLenAgg += max( 0., vtPrevEnd * vtStart * dLenPrev) ;
}
if ( pNextCrv != nullptr && pNextCrv->GetTempProp() == 1) {
Vector3d vtEnd ; pCrv->GetEndDir( vtEnd) ;
Vector3d vtNextStart ; pNextCrv->GetStartDir( vtNextStart) ;
dLenAgg += max( 0., vtEnd * vtNextStart * dLenNext) ;
if ( ! bAllOpen) {
if ( pPrevCrv != nullptr && pPrevCrv->GetTempProp() == 1) {
Vector3d vtPrevEnd ; pPrevCrv->GetEndDir( vtPrevEnd) ;
Vector3d vtStart ; pCrv->GetStartDir( vtStart) ;
dLenAgg += max( 0., vtPrevEnd * vtStart * dLenPrev) ;
}
if ( pNextCrv != nullptr && pNextCrv->GetTempProp() == 1) {
Vector3d vtEnd ; pCrv->GetEndDir( vtEnd) ;
Vector3d vtNextStart ; pNextCrv->GetStartDir( vtNextStart) ;
dLenAgg += max( 0., vtEnd * vtNextStart * dLenNext) ;
}
}
// entità corrente
double dLen = 0 ;
+1 -1
View File
@@ -71,7 +71,7 @@ class Pocketing : public Machining
bool ResetCurveAllTempProp( ICurve* pCurve) ;
bool Chain( int nGrpDestId) ;
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
bool GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo) ;
bool AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,