EgtMachKernel :
- Ottimizzazioni numero Offset per spirali.
This commit is contained in:
+101
-23
@@ -4997,8 +4997,8 @@ Pocketing::CalcSpiral( const ISurfFlatRegion* pSrfPock, int& nReg, Point3d& ptSt
|
||||
while ( nIter < MAX_ITER) {
|
||||
// salvo la regione
|
||||
pSrfPrec.Set( pSrfAct->Clone()) ;
|
||||
if ( ! pSrfAct->Offset( - dOffs, ICurve::OFF_FILLET))
|
||||
return false ;
|
||||
if ( ! pSrfAct->Offset( - dOffs, ICurve::OFF_FILLET))
|
||||
return false ;
|
||||
|
||||
// estraggo il contorno della FlatRegion (ciclo i Chunks e prendo i rispettivi Loops)
|
||||
if ( nIter == 0) {
|
||||
@@ -5021,26 +5021,8 @@ Pocketing::CalcSpiral( const ISurfFlatRegion* pSrfPock, int& nReg, Point3d& ptSt
|
||||
ptoCCBorder->Invert() ;
|
||||
// controllo quali regioni di Offset possono essere sostituite
|
||||
bool bInsert = true ;
|
||||
|
||||
PtrOwner<ICurveArc> pCrvToolShape( CreateCurveArc()) ; // superifice di ingombro del tool
|
||||
if ( IsNull( pCrvToolShape))
|
||||
if( ! CheckIfOffsetIsNecessary( ptoCCBorder, dOffs, ( int)vOffs.size(), nIter, vtExtr, bInsert))
|
||||
return false ;
|
||||
|
||||
// prendo il centroide dell'Offset
|
||||
Point3d ptC ;
|
||||
ptoCCBorder->GetCentroid( ptC) ;
|
||||
|
||||
// creo la curva che rappresenta il mio Tool centrata nel centroide dell'Offset
|
||||
pCrvToolShape->SetXY( ptC, m_TParams.m_dDiam / 2 + 5 * EPS_SMALL) ;
|
||||
|
||||
// guardo se l'Offset è contenuto nella curva del Tool
|
||||
CRVCVECTOR ccClass ;
|
||||
IntersCurveCurve intCC( *ptoCCBorder, *pCrvToolShape) ;
|
||||
intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ;
|
||||
|
||||
if (( int)ccClass.size() == 1 && ccClass[0].nClass == CRVC_IN && ( int)vOffs.size() > 0)
|
||||
bInsert = false ;
|
||||
|
||||
if ( bInsert)
|
||||
vOffs.emplace_back( Release( ptoCCBorder)) ;
|
||||
|
||||
@@ -5863,8 +5845,8 @@ Pocketing::CutOffsetToClosestPoint( ICRVCOMPOPOVECTOR& vCurves, const Point3d& p
|
||||
nIndex = -1 ;
|
||||
Point3d ptCL ;
|
||||
|
||||
// scorro tutti gli offset ad eccezione del primo
|
||||
for ( int j = 1 ; j < int( vCurves.size()) ; ++ j) {
|
||||
// scorro tutti gli offset ad eccezione del primo ( a meno di averne uno solo )
|
||||
for ( int j = ( int)vCurves.size() == 1 ? 0 : 1 ; j < int( vCurves.size()) ; ++ j) {
|
||||
|
||||
// non ho offset nulli, però controllo...
|
||||
if( IsNull( vCurves[j]))
|
||||
@@ -10322,3 +10304,99 @@ Pocketing::SetTmpPropByOverlap( ICurveComposite* pCrv_, int nInd, const ICurveCo
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CheckIfOffsetIsNecessary( const ICurveComposite* pCrvOffs, const double dOffs, const int nOffsCount,
|
||||
const int nIter, const Vector3d& vtN, bool& bInsert)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pCrvOffs == nullptr || ! pCrvOffs->IsValid() || pCrvOffs->GetCurveCount() == 0 || dOffs <= 0)
|
||||
return false ;
|
||||
bInsert = true ; // di base inserisco
|
||||
bool bDoTheSame = false ;
|
||||
|
||||
if ( nIter != 0) { // controllo se sono almeno al secondo offset...
|
||||
|
||||
// per ogni curva controllo se il controOffset + 5 * EPS_SMALL genera una regione ...
|
||||
OffsetCurve OffsCrv ; // considero anche i casi in cui ho bSmallRad
|
||||
if ( OffsCrv.Make( pCrvOffs, - m_TParams.m_dDiam / 2 + dOffs - 5 * EPS_SMALL , ICurve::OFF_FILLET)) {
|
||||
// se questa curva sparisce -> non serve inserirla come offset, non svuota parti aggiuntive
|
||||
if ( OffsCrv.GetCurveCount() == 0) {
|
||||
bInsert = false ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
|
||||
if ( ! OffsCrv.Make( pCrvOffs, abs( m_TParams.m_dDiam / 2 - dOffs) < 5 * EPS_SMALL ?
|
||||
5 * EPS_SMALL : abs( - m_TParams.m_dDiam / 2 + dOffs) + 5 * EPS_SMALL , ICurve::OFF_FILLET))
|
||||
return true ;
|
||||
|
||||
PtrOwner<ICurve> pCrvOffLonger( OffsCrv.GetLongerCurve()) ;
|
||||
if( IsNull( pCrvOffLonger) || ! pCrvOffLonger->IsValid())
|
||||
return true ;
|
||||
|
||||
// Immagine del tool con centro nel centroide della zona da svuotare
|
||||
Point3d ptC ; pCrvOffLonger->GetCentroid( ptC) ;
|
||||
PtrOwner<ICurveArc> pCrvTool( CreateCurveArc()) ;
|
||||
if( IsNull( pCrvTool))
|
||||
return false ;
|
||||
pCrvTool->SetXY( ptC, m_TParams.m_dDiam / 2 - 5 * EPS_SMALL) ;
|
||||
|
||||
CRVCVECTOR ccClass ;
|
||||
IntersCurveCurve intCC( *pCrvOffLonger, *pCrvTool) ;
|
||||
intCC.GetCurveClassification( 1, EPS_SMALL, ccClass) ;
|
||||
if (( int)ccClass.size() == 1 && ccClass[0].nClass == CRVC_OUT && nOffsCount > 0) {
|
||||
// CENTROIDE
|
||||
bInsert = false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
ICRVCOMPOPOVECTOR vCrvInside ;
|
||||
for ( int p = 0 ; p < ( int)ccClass.size() ; ++ p) {
|
||||
if ( ccClass[p].nClass == CRVC_OUT) {
|
||||
pCrvTool->ChangeStartPoint( 0.5 * ( ccClass[p].dParS + ccClass[p].dParE)) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
IntersCurveCurve intCC1( *pCrvOffLonger, *pCrvTool) ;
|
||||
intCC1.GetCurveClassification( 1, EPS_SMALL, ccClass) ;
|
||||
bool bFirst = true ;
|
||||
Point3d ptA, ptB ;
|
||||
if (( int)ccClass.size() == 5 && nOffsCount > 0) {
|
||||
// CENTROIDE
|
||||
for ( int u = 0 ; u < ( int)ccClass.size() ; ++ u) {
|
||||
if ( ccClass[u].nClass == CRVC_IN) {
|
||||
if ( bFirst) {
|
||||
pCrvTool->GetPointD1D2( 0.5 * ( ccClass[u].dParS + ccClass[u].dParE), ICurve::FROM_MINUS, ptA) ;
|
||||
bFirst = false ;
|
||||
}
|
||||
else
|
||||
pCrvTool->GetPointD1D2( 0.5 * ( ccClass[u].dParS + ccClass[u].dParE), ICurve::FROM_MINUS, ptB) ;
|
||||
}
|
||||
}
|
||||
|
||||
Frame3d frLoc ; frLoc.Set( ptC, vtN, ptA - ptB) ;
|
||||
if( ! frLoc.IsValid())
|
||||
return true ;
|
||||
BBox3d bBox ;
|
||||
pCrvOffLonger->GetBBox( frLoc, bBox) ;
|
||||
double dDimX = bBox.GetDimX() ;
|
||||
double dDimY = bBox.GetDimY() ;
|
||||
if( dDimX < m_TParams.m_dDiam - 100 * EPS_SMALL ||
|
||||
dDimY < m_TParams.m_dDiam - 100 * EPS_SMALL) {
|
||||
bInsert = false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -156,6 +156,8 @@ class Pocketing : public Machining
|
||||
bool CalcSpiral( const ISurfFlatRegion* pSrfPock, int& nReg, Point3d& ptStart, Vector3d& vtMidOut , bool& bMidOut,
|
||||
bool bSplitArcs,ICurveComposite* pMCrv, ICurveComposite* pRCrv, ICurveComposite* pCrvOEWithFlags,
|
||||
bool& bOptimizedTrap) ;
|
||||
bool CheckIfOffsetIsNecessary( const ICurveComposite* pCrvOffs, const double dOffs, const int nIter,
|
||||
const int nOffsCount, const Vector3d& vtN, bool& bInsert) ;
|
||||
bool GetUnclearedRegion( ICRVCOMPOPOVECTOR& vFirstOffs, ICRVCOMPOPOVECTOR& vCrvs, ICURVEPOVECTOR& vLinks,
|
||||
ISurfFlatRegion* pSrfToCut) ;
|
||||
bool RemoveFirstLoopFromSfr( ISurfFlatRegion* pSrfOrig ) ;
|
||||
|
||||
Reference in New Issue
Block a user