EgtMachKernel :

- semplificazione curve con archi.
This commit is contained in:
Riccardo Elitropi
2024-02-01 13:23:43 +01:00
parent 84fc7b0dc3
commit 443fac5f0f
2 changed files with 202 additions and 88 deletions
+201 -88
View File
@@ -2538,13 +2538,16 @@ Pocketing::SliceVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_Pa
m_pMchMgr->SetLastError( 2439, "Error in Pocketing : Detecting open edges failed") ;
return false ;
}
// dato che la FlatRegion è ricavata a partire da una Trimesh, semplifico i suoi loops
if ( ! SimplifySfrLoops( pSfrCurr))
return false ;
// salvo le curve originali per casi ottimizzati
if ( ! GetCurvesForOptimizedPocketing( pSfrCurr, vCrvOEWithFlags[j-1]))
return false ;
// modifico la supericie in base alle proprietà di lato aperto/chiuso
PtrOwner<ISurfFlatRegion> pSfrNoExtension( CloneSurfFlatRegion( pSfrCurr)) ;
if ( IsNull( pSfrNoExtension) ||
! ModifySurfByOpenEdges( pSfrCurr, pSfrLimit)) { // pizza
! ModifySurfByOpenEdges( pSfrCurr, pSfrLimit)) {
m_pMchMgr->SetLastError( 2430, "Error in Pocketing : adjust open edges failed") ;
return false ;
}
@@ -2566,6 +2569,96 @@ Pocketing::SliceVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_Pa
return true ;
}
//----------------------------------------------------------------------------
bool
Pocketing::SimplifySfrLoops( ISurfFlatRegion* pSfr)
{
// controllo dei parametri
if ( pSfr == nullptr || ! pSfr->IsValid())
return false ;
// superficie semplificata
PtrOwner<ISurfFlatRegion> pSfrSimple( CreateSurfFlatRegion()) ;
if ( IsNull( pSfrSimple))
return false ;
// scorro tutti i loop della superficie da semplificare
for ( int c = 0 ; c < pSfr->GetChunkCount() ; ++ c) {
for ( int l = 0 ; l < pSfr->GetLoopCount( c) ; ++ l) {
PtrOwner<ICurveComposite> pCrvLoop( ConvertCurveToComposite( pSfr->GetLoop( c, l))) ;
if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
return false ;
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvLoop->Clone()) ;
m_pGeomDB->SetMaterial( r, RED) ;
// ricavo i tratti con proprità omogenee, quindi aperti e chiusi
ICRVCOMPOPOVECTOR vCrvSameProps ;
if ( ! GetHomogeneousParts( pCrvLoop, vCrvSameProps))
return false ;
// curva semplificata che restituirà il loop
PtrOwner<ICurveComposite> pCrvSimpleLoop( CreateCurveComposite()) ;
if ( IsNull( pCrvSimpleLoop))
return false ;
// per ogni tratto omogeneo trovato, cerco di semplificare
for ( int t = 0 ; t < int( vCrvSameProps.size()) ; ++ t) {
PtrOwner<ICurveComposite> pCrv_part( CloneCurveComposite( vCrvSameProps[t])) ;
if ( IsNull( pCrv_part) || ! pCrv_part->IsValid())
return false ;
// tmp prop ( Aperto/Chiuso)
int nTmpProp = pCrv_part->GetCurve( 0)->GetTempProp( 0) ;
// estremi
Point3d ptS ; pCrv_part->GetStartPoint( ptS) ;
Point3d ptE ; pCrv_part->GetEndPoint( ptE) ;
PolyArc PA ; Point3d ptS_c, ptE_c ;
// 1) Mergiamo per uniformità
if ( pCrv_part->MergeCurves( 200 * EPS_SMALL, 200 * EPS_ANG_SMALL) &&
// 2) Rimozione Spikes o Curve a Z
pCrv_part->RemoveSmallDefects( 150 * EPS_SMALL, 2 * ANG_TOL_STD_DEG, true) &&
// 3) Interpoliamo mediante Linee ed Archi
pCrv_part->ApproxWithArcsEx( 150 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) &&
pCrv_part->Clear() &&
pCrv_part->FromPolyArc( PA) &&
// 4) Controllo che i punti inziali e finali siano gli stessi...( per estrema sicurezza)
pCrv_part->GetStartPoint( ptS_c) &&
pCrv_part->GetEndPoint( ptE_c) &&
( pCrv_part->IsClosed() || ( AreSamePointApprox( ptS, ptS_c) &&
AreSamePointApprox( ptE, ptE_c)))) {
// assegno la temp prop a tutte le sue sottocurve
for ( int u = 0 ; u < pCrv_part->GetCurveCount() ; ++ u)
pCrv_part->SetCurveTempProp( u, nTmpProp, 0) ;
}
// inserisco il tratto di curva semplificata nel loop semplificato
if ( ! pCrvSimpleLoop->AddCurve( Release( pCrv_part)))
return false ;
}
int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvSimpleLoop->Clone()) ;
m_pGeomDB->SetMaterial( b, BLUE) ;
// ora che ho il loop semplificato lo inserisco nella flatRegion semplificata
if ( l == 0) {
if ( ! pSfrSimple->AddExtLoop( Release( pCrvSimpleLoop)))
return false ;
}
else
if ( ! pSfrSimple->AddIntLoop( Release( pCrvSimpleLoop)))
return false ;
}
}
// sostituisco la superficie semplificata ricavata
if ( pSfrSimple->IsValid()) {
pSfr->Clear() ;
pSfr->CopyFrom( pSfrSimple) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Pocketing::GetRaw( ISurfTriMesh* pStmRaw)
@@ -3282,7 +3375,14 @@ Pocketing::ProjectVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_
return false ;
// plFar
Point3d ptFar = ORIG + ( vtTrasl1.IsValid() ? vtTrasl1 : 5000 * Z_AX) ;
Vector3d vtMaxTrasl = 5000 * Z_AX ;
if ( ! vtTrasl1.IsValid()) {
BBox3d BBox ;
if ( ! pStmVol->GetLocalBBox( BBox))
return false ;
vtMaxTrasl = vtN * ( BBox.GetDimZ() - 10 * EPS_SMALL) ;
}
Point3d ptFar = ORIG + ( vtTrasl1.IsValid() ? vtTrasl1 : vtMaxTrasl) ;
Plane3d plFar ; plFar.Set( ptFar, vtN) ;
if ( ! plFar.IsValid())
return false ;
@@ -3314,9 +3414,9 @@ Pocketing::ProjectVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_
// per la superficie tra i due piani ricavo gli indici dei triangoli delle facce C ( tutti questi triangoli andranno
// rimossi lasciando quindi solo le facce A)
// NB. sul piano Far la TriMesh non presenta facce, bisogna riaggiungerle
if ( ! SewingMissingFacesOnPlanes( pStmBetween_Planes, plFar) ||
! SewingMissingFacesOnPlanes( pStmBetween_Planes, plNear))
return false ;
//if ( ! SewingMissingFacesOnPlanes( pStmBetween_Planes, plFar) ||
// ! SewingMissingFacesOnPlanes( pStmBetween_Planes, plNear))
// return false ;
INTVECTOR vAllTria_C_between ;
for ( int f = 0 ; f < pStmBetween_Planes->GetFacetCount() ; ++ f) {
@@ -3967,17 +4067,19 @@ Pocketing::AddZigZag( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
VCT3DVECTOR vVtMidOut(( int)vCrvIslMergeBorders.size()) ;
BOOLVECTOR vbMidOut(( int)vCrvIslMergeBorders.size()) ;
PNTVECTOR vPtStart(( int)vCrvIslMergeBorders.size()) ;
// se la superficie è cambiata, allora ricalcolo i parametri
// se le isole si sono mergiate, ricavolo il nuovo punto iniziale
for ( int x = 0 ; x < int( vCrvIslMergeBorders.size()) ; ++ x) {
// se richisto, inverto
if ( m_Params.m_bInvert)
vCrvIslMergeBorders[x]->Invert() ;
// setto la Feed per la curva di contorno
//AssignFeedForEdgeCleaning( vCrvIslMergeBorders[x], vCrvOEWithFlags[j-1], nInd) ;
// cambio il punto inziale alla curva di bordo
if ( vCrvIslMergeBorders[x]->IsClosed()) {
bool bOutTmp = false ;
//if ( ! SetBetterPtStartForSubChunks( vCrvIslMergeBorders[x], pSrfChunk,
// vPtStart[x], vVtMidOut[x], bOutTmp))
Point3d ptEnd_prec = P_INVALID ;
if ( ! SetBetterPtStartForSubChunks( vCrvIslMergeBorders[x], pSrfChunk, ptEnd_prec,
frPocket, vPtStart[x], vVtMidOut[x], bOutTmp))
return false ;
vbMidOut[x] = bOutTmp ; // vector<bool>::reference da Bit a Bool
}
@@ -4073,25 +4175,25 @@ Pocketing::AddZigZag( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
BOOLVECTOR vbMidOut( pSrfForCrv->GetLoopCount( cfc)) ;
PNTVECTOR vPtStart( pSrfForCrv->GetLoopCount( cfc)) ;
for ( int l = 0 ; l < pSrfForCrv->GetLoopCount( cfc) ; ++ l) {
// ricavo il loop
PtrOwner<ICurveComposite> pCrvLoop( ConvertCurveToComposite( pSrfForCrv->GetLoop( cfc, l))) ;
if ( IsNull( pCrvLoop))
return false ;
// assegno il punto di inizio
bool bOutTmp = false ;
Point3d ptEndPrec = P_INVALID ;
if ( ! SetBetterPtStartForSubChunks( pCrvLoop, pSrfChunk, ptEndPrec, frPocket,
vPtStart[l], vVtMidOut[l], bOutTmp))
return false ;
vbMidOut[l] = bOutTmp ; // vector<bool>::reference da Bit a Bool
//if ( ! SetBetterPtStartForSubChunks( pCrvLoop, pSrfChunk, vPtStart[l], vVtMidOut[l], bOutTmp))
// return false ;
vbMidOut[l] = bOutTmp ; // vector<bool>::reference da Bit a Bool
// se richiesto, la inverto
if ( m_Params.m_bInvert)
pCrvLoop->Invert() ;
// se richiesto, la inverto
if ( m_Params.m_bInvert)
pCrvLoop->Invert() ;
// setto la Feed per la curva di contorno
//AssignFeedForEdgeCleaning( pCrvLoop, vCrvOEWithFlags[j-1], nInd) ;
// inserisco la curva nel vettore
vAllCrv.emplace_back( Release( pCrvLoop)) ;
// inserisco la curva nel vettore
vAllCrv.emplace_back( Release( pCrvLoop)) ;
}
// guardo il punto finale in cui si trova la fresa dopo al percorso a ZigZag
// e le riordino le curve ( e i relativi vettori ) in base alla vicinanza
@@ -4293,17 +4395,13 @@ Pocketing::AddZigZag( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
}
// aggiungo attacco
SetFeed( GetStartFeed()) ;
//if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert,
// bSplitArcs, bOutRawLeadIn || m_bOpenOutRaw)) {
// m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
// return false ;
//}
if ( ! AddLeadIn( pCrvCurr, ptP1, ptStart, vtStart, V_INVALID, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert,
bSplitArcs, bOutRawLeadIn || m_bOpenOutRaw)) {
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
return false ;
}
}
// elaborazioni sulla curva corrente
//double dMinFeed = GetFeed() * GetSideStep() / m_TParams.m_dDiam ;
//double dFeed = pCurve->GetTempProp( 0) / FEED_DIVISOR < dMinFeed - 50 * EPS_SMALL ?
// GetFeed() : pCurve->GetTempProp( 0) / FEED_DIVISOR ;
//SetFeed( dFeed) ;
if ( pCurve->GetType() == CRV_LINE) {
ICurveLine* pLine = GetCurveLine( pCurve) ;
Point3d ptP3 = pLine->GetEnd() ;
@@ -4418,6 +4516,10 @@ Pocketing::AddZigZag( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
GetLeadInType() == POCKET_LI_GLIDE) {
ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ;
dStElev = -LIO_ELEV_TOL ;
if ( j > 1) {
ptP1.Translate( - vtTool * ( vVtTrasl[j-1] - vVtTrasl[j-2]).Len()) ;
dStElev += ( vVtTrasl[j-1] - vVtTrasl[j-2]).Len() ;
}
}
// approccio al punto iniziale
if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr,
@@ -4427,18 +4529,14 @@ Pocketing::AddZigZag( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
}
// aggiungo attacco
SetFeed( GetStartFeed()) ;
//if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert,
// bSplitArcs, vCrvInfo[u].bMidOut || bForcedOutStart)) {
// m_pMchMgr->SetLastError(2415, "Error in Pocketing : LeadIn not computable");
// return false;
//}
if ( ! AddLeadIn( pCrvCurr, ptP1, ptStart, vtStart, V_INVALID, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert,
bSplitArcs, vCrvInfo[u].bMidOut || bForcedOutStart)) {
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable");
return false;
}
}
// elaborazioni sulla curva corrente
//double dMinFeed = GetFeed() * GetSideStep() / m_TParams.m_dDiam ;
//double dFeed = pCurve->GetTempProp( 0) / FEED_DIVISOR < dMinFeed - 50 * EPS_SMALL ?
// GetFeed() : pCurve->GetTempProp( 0) / FEED_DIVISOR ;
//SetFeed( dFeed) ;
if ( pCurve->GetType() == CRV_LINE) {
ICurveLine* pLine( GetCurveLine( pCurve)) ;
Point3d ptP3 = pLine->GetEnd() ;
@@ -5783,22 +5881,19 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
if ( IsNull( pSrfCurrChunk))
return false ;
// imposto un punto valido per l'entrata
//if ( ! SetBetterPtStartForSubChunks( vAllCrv[u], pSrfCurrChunk,
// vPtStart[u], vVtMidOut[u], bOutTmp))
// return false ;
if ( ! SetBetterPtStartForSubChunks( vAllCrv[u], pSrfCurrChunk, P_INVALID, frLocI,
vPtStart[u], vVtMidOut[u], bOutTmp))
return false ;
vbMidOut[u] = bOutTmp ; // vector<bool>::reference da Bit a Bool
// riporto i valori nel sistema di riferimento corretto
vPtStart[u].ToGlob( frLocI) ;
vVtMidOut[u].ToGlob( frLocI) ;
vAllCrv[u]->ToGlob( frLocI) ;
// riporto i valori nel sistema di riferimento corretto
vPtStart[u].ToGlob( frLocI) ;
vVtMidOut[u].ToGlob( frLocI) ;
vAllCrv[u]->ToGlob( frLocI) ;
// se richiesto, la inverto
if ( m_Params.m_bInvert)
vAllCrv[u]->Invert() ;
// setto la Feed per la curva di contorno
//AssignFeedForEdgeCleaning( vAllCrv[u], vCrvOEWithFlags[j-1]) ;
// se richiesto, la inverto
if ( m_Params.m_bInvert)
vAllCrv[u]->Invert() ;
// se la curva è valida per entrata da fuori, aggiungo un piccolo tratto lineare
if ( vbMidOut[u]) {
@@ -5880,6 +5975,10 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
GetLeadInType() == POCKET_LI_GLIDE) {
ptP1 += vtExtr * ( dStElev + LIO_ELEV_TOL) ;
dStElev = -LIO_ELEV_TOL ;
if ( j > 1) {
ptP1.Translate( - vtTool * ( vVtTrasl[j-1] - vVtTrasl[j-2]).Len()) ;
dStElev += ( vVtTrasl[j-1] - vVtTrasl[j-2]).Len() ;
}
}
// approccio al punto iniziale
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, vbMidOut[u] || vbForcedOutStart[u])) {
@@ -5888,17 +5987,12 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
}
// aggiungo attacco
SetFeed( GetStartFeed()) ;
//if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert, bSplitArcs, vbMidOut[u] || vbForcedOutStart[u])) {
// m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
// return false ;
//}
if ( ! AddLeadIn( pOffs, ptP1, ptStart, vtStart, V_INVALID, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert, bSplitArcs, vbMidOut[u] || vbForcedOutStart[u])) {
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
return false ;
}
}
// elaborazioni sulla curva corrente
//double dMinFeed = GetFeed() * GetSideStep() / m_TParams.m_dDiam ;
//double dFeed = pCurve->GetTempProp( 0) / FEED_DIVISOR < dMinFeed - 50 * EPS_SMALL ?
// GetFeed() : pCurve->GetTempProp( 0) / FEED_DIVISOR ;
//DrawColoredCrvForFeedTest( pCurve, dFeed) ;
//SetFeed( dFeed) ;
if ( pCurve->GetType() == CRV_LINE) {
ICurveLine* pLine = GetCurveLine( pCurve) ;
Point3d ptP3 = pLine->GetEnd() ;
@@ -6003,8 +6097,6 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
pCrvCompo->Clear() ;
pCrvCompo->AddCurve( pCrvSeg->Clone()) ;
vAddedLines.emplace_back( pCrvCompo->Clone()) ;
//if ( ! AssignFeedZigZagOneWay( pCrvCompo, false, vLineAbove, vLineUnder, vCrvLink))
// return false ;
// INIZIO
ptS.ToGlob( frLocI) ;
@@ -6022,10 +6114,10 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
}
// aggiungo attacco (forzato ad essere lineare)
SetFeed( GetStartFeed()) ;
//if ( ! AddLeadIn( ptP, ptS, frLocI.VersX(), vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert, bSplitArcs, true)) {
// m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
// return false ;
//}
if ( ! AddLeadIn( pCrvCompo, ptP, ptS, frLocI.VersX(), V_INVALID, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert, bSplitArcs, true)) {
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
return false ;
}
// punto finale
Point3d ptE ;
@@ -6038,11 +6130,6 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vector<ICRVCOMPOPOVECTOR
ptE.ToGlob( frLocI) ;
// movimento al punto finale
// elaborazioni sulla curva corrente
//double dMinFeed = GetFeed() * GetSideStep() / m_TParams.m_dDiam ;
//double dFeed = pCurve->GetTempProp( 0) / FEED_DIVISOR < dMinFeed - 50 * EPS_SMALL ?
// GetFeed() : pCurve->GetTempProp( 0) / FEED_DIVISOR ;
//SetFeed( dFeed) ;
SetFeed( GetFeed()) ;
if ( AddLinearMove( ptE) == GDB_ID_NULL)
return false ;
@@ -6844,30 +6931,31 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl
vCrvBisectors.empty())
return false ;
/*
*/
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrSafe->Clone()) ;
ICURVEPOVECTOR VRONI ;
pSfrSafe->CalcVoronoiDiagram( VRONI) ;
// porto i bisettori nel riferimento
// porto i bisettori nel riferimento e rimuovo quelli con un parametro a zero
ICURVEPOVECTOR vCrvBisectors_tmp ;
for ( int i = 0 ; i < ( int)vCrvBisectors.size() ; ++ i) {
//vCrvBisectors[i]->ToLoc( frCurr) ;
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vCrvBisectors[i]->Clone()) ;
m_pGeomDB->SetMaterial( r, RED) ;
// tolgo tutti i Bisettori che presentano un parametro nullo
if ( vCrvBisectors[i]->GetTempParam( 0) > EPS_SMALL &&
vCrvBisectors[i]->GetTempParam( 1) > EPS_SMALL) {
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, 158, vCrvBisectors[i]->Clone()) ;
m_pGeomDB->SetMaterial( r, RED) ;
vCrvBisectors[i]->ToLoc( frCurr) ;
vCrvBisectors_tmp.emplace_back( Release( vCrvBisectors[i])) ;
}
}
swap( vCrvBisectors, vCrvBisectors_tmp) ;
vCrvBisectors_tmp.clear() ;
// porto i bisettori nel riferimento
for ( int i = 0 ; i < ( int)VRONI.size() ; ++ i) {
//vCrvBisectors[i]->ToLoc( frCurr) ;
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, VRONI[i]->Clone()) ;
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, 159, VRONI[i]->Clone()) ;
m_pGeomDB->SetMaterial( r, BLUE) ;
}
return false ;
// trasformo in composite concatenando le curve ( bloccandomi alle biforcazioni)
ICRVCOMPOPOVECTOR vCompoBisChain ;
if ( ! ChainBisectors( vCrvBisectors, vCompoBisChain))
@@ -6879,10 +6967,8 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl
if ( IsNull( pCrvPath))
return false ;
ChooseBestBisectorPath( vCompoBisChain, ORIG, ptEProj, pCrvPath) ;
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvPath->Clone()) ;
double dMAxElev = 0. ;
// controllo che la curva si effettivamente valida e distante dal percorso, altrimenti scarico
bool bSkip = ! pCrvPath->IsValid() || pCrvPath->GetCurveCount() == 0 ;
if ( ! bSkip) {
@@ -6931,8 +7017,10 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl
// approssimo il percorso
PtrOwner<ICurveComposite> pCrvRes( CreateCurveComposite()) ;
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvPath->Clone()) ;
if ( ! IsNull( pCrvRes) && GetApproxCurveDP( pCrvPath, dMinPar, pCrvRes))
pCrvPath.Set( Release( pCrvRes)) ;
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvPath->Clone()) ;
// smusso mediante parametro di VRONI
ModifyCurveToSmoothed( pCrvPath, dMinPar, dMinPar, false) ;
@@ -10540,12 +10628,33 @@ Pocketing::AddLeadIn( const ICurveComposite* pCrvCompo, const Point3d& ptP1, con
}
// semplifico le curve
PolyArc PA ;
pCrvA_ZigZag->MergeCurves( 500 * EPS_SMALL, 500 * EPS_ANG_SMALL) ;
pCrvA_ZigZag->ApproxWithArcsEx( 500 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) ;
pCrvA_ZigZag->Clear() ;
pCrvA_ZigZag->FromPolyArc( PA) ;
PA.Clear() ;
pCrvA_ZigZag_I->MergeCurves( 500 * EPS_SMALL, 500 * EPS_ANG_SMALL) ;
pCrvA_ZigZag_I->Invert() ; // altrimenti la curva salirebbe lungo vtN
pCrvA_ZigZag_I->ApproxWithArcsEx( 500 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) ;
pCrvA_ZigZag_I->Clear() ;
pCrvA_ZigZag_I->FromPolyArc( PA) ;
PA.Clear() ;
pCrvB_ZigZag->MergeCurves( 500 * EPS_SMALL, 500 * EPS_ANG_SMALL) ;
pCrvB_ZigZag->ApproxWithArcsEx( 500 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) ;
pCrvB_ZigZag->Clear() ;
pCrvB_ZigZag->FromPolyArc( PA) ;
PA.Clear() ;
pCrvB_ZigZag_I->MergeCurves( 500 * EPS_SMALL, 500 * EPS_ANG_SMALL) ;
pCrvB_ZigZag_I->Invert() ; // altrimenti la curva salirebbe lungo vtN
pCrvB_ZigZag_I->ApproxWithArcsEx( 500 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) ;
pCrvB_ZigZag_I->Clear() ;
pCrvB_ZigZag_I->FromPolyArc( PA) ;
// per ogni step copio le curve
for ( int i = 1 ; i <= nStep ; ++ i) {
@@ -11805,7 +11914,8 @@ Pocketing::GetCoeffLinArc( const ICurveArc* pArc, double dDiam, double& dSubArc)
//----------------------------------------------------------------------------
bool
Pocketing::SetBetterPtStartForSubChunks( ICurveComposite* pCrvOffsAct, const ISurfFlatRegion* pSrfToWork,
const Point3d& ptEndPrec, const Frame3d& frPocket, Point3d& ptStart, Vector3d& vtMidOut, bool& bMidOut)
const Point3d& ptEndPrec, const Frame3d& frPocket, Point3d& ptStart,
Vector3d& vtMidOut, bool& bMidOut)
{
// ============================= INFO ==============================================================
// pCrvOffsAct -> Curva di Offset su cui cercare ptStart, vtMidOut, bMidOpen
@@ -12352,6 +12462,7 @@ Pocketing::GetTrapezoidFromShape( const ICurveComposite* pCrvCompo, ICurveCompos
nBase = 0 ;
nSecondBase = 2 ;
}
break ;
// 1 LATO CHIUSO ( LINEARE)
case 1 : {
int nType = -1 ;
@@ -12368,6 +12479,7 @@ Pocketing::GetTrapezoidFromShape( const ICurveComposite* pCrvCompo, ICurveCompos
nSecondBase = 2 ;
}
}
break ;
// 2 LATI CHIUSI ( LINEARI, CONSECUTIVI O PARALLELI)
case 2 : {
// controllo se entrambi sono lineari
@@ -12505,6 +12617,7 @@ Pocketing::GetTrapezoidFromShape( const ICurveComposite* pCrvCompo, ICurveCompos
}
}
}
break ;
// 3 LATI CHIUSI ( LINEARI e CONSECUTIVI)
case 3 : {
// prendo i 3 lati chiusi
+1
View File
@@ -116,6 +116,7 @@ class Pocketing : public Machining
const Vector3d& vtTraslPrec, const ISurfFlatRegion* pSfrOpenProjPrec, ISurfFlatRegion* pSfr,
const bool bOneStep, double& dExtraLenInOut) ;
bool ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm, const bool bOnIsClosed = false) ;
bool SimplifySfrLoops( ISurfFlatRegion* pSfr) ;
bool GetCurvesForOptimizedPocketing( ISurfFlatRegion* pSfr, ICRVCOMPOPOVECTOR& vCrvOEWithFlags) ;
bool ModifySurfByOpenEdges( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrLimit) ;
bool AdjustContourWithOpenEdges( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vCrvIsl, const double dDiam,