EgtMachKernel :
- prima prova per isole con lati aperti e gestione angoli piccoli.
This commit is contained in:
+275
-28
@@ -1758,8 +1758,8 @@ Pocketing::ProcessPath( int nAuxId, int nPvId, int nClId)
|
||||
// se lo step supera la capacità dell'utensile
|
||||
if ( m_Params.m_dStep > m_TParams.m_dMaxMat + EPS_SMALL) {
|
||||
dOkStep = m_TParams.m_dMaxMat + EPS_SMALL ;
|
||||
string sInfo = "Warning in Pocketing : machining step (" + ToString(m_Params.m_dStep, 1) + ") bigger than MaxMaterial ("
|
||||
+ ToString(m_TParams.m_dMaxMat, 1) + ")" ;
|
||||
string sInfo = "Warning in Pocketing : machining step (" + ToString( m_Params.m_dStep, 1) + ") bigger than MaxMaterial ("
|
||||
+ ToString( m_TParams.m_dMaxMat, 1) + ")" ;
|
||||
m_pMchMgr->SetWarning( 2457, sInfo) ;
|
||||
}
|
||||
// se lavorazione singola
|
||||
@@ -1767,8 +1767,8 @@ Pocketing::ProcessPath( int nAuxId, int nPvId, int nClId)
|
||||
// se l'elevazione supera la capacità dell'utensile
|
||||
if ( dElev > m_TParams.m_dMaxMat + EPS_SMALL ) {
|
||||
string sInfo = "Warning in Pocketing : machining depth (" + ToString(dElev, 1) +
|
||||
") bigger than MaxMaterial (" + ToString(m_TParams.m_dMaxMat, 1) + ")" ;
|
||||
m_pMchMgr->SetWarning(2458, sInfo) ;
|
||||
") bigger than MaxMaterial (" + ToString( m_TParams.m_dMaxMat, 1) + ")" ;
|
||||
m_pMchMgr->SetWarning( 2458, sInfo) ;
|
||||
dDepth -= dElev - m_TParams.m_dMaxMat ;
|
||||
dElev = m_TParams.m_dMaxMat ;
|
||||
}
|
||||
@@ -8651,20 +8651,25 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP
|
||||
return false ;
|
||||
}
|
||||
vpCrvs[i].Set( OffsCrv.GetLongerCurve()) ;
|
||||
// ----------
|
||||
PtrOwner<ICurveComposite> pCrvRange( CreateCurveComposite()) ;
|
||||
pCrvRange->AddCurve( vpCrvs[i]->Clone()) ;
|
||||
|
||||
//int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvRange->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( W, WHITE) ;
|
||||
int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvRange->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( W, WHITE) ;
|
||||
|
||||
for ( int j = 0 ; j < pCrvRange->GetCurveCount() ; ++ j)
|
||||
pCrvRange->SetCurveTempProp( j, 1, 0) ;
|
||||
vpCrvs[i].Set( pCrvRange) ;
|
||||
vpCrvs[i]->SetTempProp( 1) ;
|
||||
// ----------
|
||||
}
|
||||
}
|
||||
|
||||
int green = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( green, GREEN) ;
|
||||
|
||||
// clono la pCompo
|
||||
PtrOwner<ICurveComposite> pCompo_clone( CloneCurveComposite( pCompo)) ;
|
||||
|
||||
// reinserisco le curve, chiudendo eventuali gap
|
||||
pCompo->Clear() ;
|
||||
pCompo->SetExtrusion( vtExtr) ;
|
||||
@@ -8681,25 +8686,37 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP
|
||||
if ( ! AreSamePointEpsilon( ptEnd, ptStart, 10 * EPS_SMALL)) {
|
||||
// se passo da chiuso ad aperto
|
||||
if ( ! bOpenPrev && bOpenCurr) {
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
PtrOwner<ICurveComposite> pHHHH( CreateCurveComposite()) ;
|
||||
pHHHH->AddCurve( vpCrvs[i]->Clone()) ;
|
||||
Point3d ptS ; pCompo->GetEndPoint( ptS) ;
|
||||
Point3d ptE ; vpCrvs[i+1]->GetStartPoint( ptE) ;
|
||||
PtrOwner<ICurveComposite> pCrvNew( CreateCurveComposite()) ;
|
||||
AdjustPathOutsideRawForOpenEdges( pCompo_clone, vCrvIsl, pHHHH, ptS, ptE, dRad, dDiam, pCrvNew) ;
|
||||
vpCrvs[i].Set( Release( pCrvNew)) ;
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
// determino la curva ad amo
|
||||
Vector3d vtTg ; pCompo->GetEndDir( vtTg) ;
|
||||
Vector3d vtOrt = vtTg ; vtOrt.Rotate( vtExtr, 0, 1) ;
|
||||
Point3d ptArc = ptEnd + dDiam * vtOrt ;
|
||||
Point3d ptLine = ptArc - 5 * dDiam * vtTg ;
|
||||
//Point3d ptLine = ptArc - 5 * dDiam * vtTg ;
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return false ;
|
||||
pCrvArc->SetExtrusion( vtExtr) ;
|
||||
pCrvArc->Set2PVN( ptEnd, ptArc, vtTg, vtExtr) ;
|
||||
PtrOwner<ICurveComposite> pJCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pJCrv))
|
||||
return false ;
|
||||
pJCrv->SetExtrusion( vtExtr) ;
|
||||
pJCrv->AddPoint( ptLine) ;
|
||||
pJCrv->AddLine( ptArc, false) ;
|
||||
pJCrv->AddArcTg( ptEnd, false) ;
|
||||
|
||||
//int y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( y, YELLOW) ;
|
||||
pJCrv->AddCurve( Release( pCrvArc)) ;
|
||||
int y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( y, YELLOW) ;
|
||||
|
||||
// assegno alle sue sottocurve la proprietà di curva aperta
|
||||
for ( int u = 0 ; u < pJCrv->GetCurveCount() ; ++ u)
|
||||
pJCrv->SetCurveTempProp( u, 1, 0) ;
|
||||
//for ( int u = 0 ; u < pJCrv->GetCurveCount() ; ++ u)
|
||||
// pJCrv->SetCurveTempProp( u, 1, 0) ;
|
||||
// calcolo l'intersezione nel piano della svuotatura dell'amo con la curva aperta
|
||||
pJCrv->ToLoc( frPocket) ;
|
||||
vpCrvs[i]->ToLoc( frPocket) ;
|
||||
@@ -8730,6 +8747,7 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP
|
||||
}
|
||||
// se passo da aperto a chiuso
|
||||
else if ( bOpenPrev && ! bOpenCurr) {
|
||||
|
||||
// determino la curva ad amo
|
||||
Vector3d vtTg ; vpCrvs[i]->GetStartDir( vtTg) ;
|
||||
Vector3d vtOrt = vtTg ; vtOrt.Rotate( vtExtr, 0, 1) ;
|
||||
@@ -8740,11 +8758,11 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP
|
||||
return false ;
|
||||
pJCrv->SetExtrusion( vtExtr) ;
|
||||
pJCrv->AddPoint( ptLine) ;
|
||||
pJCrv->AddLine( ptArc) ;
|
||||
pJCrv->AddLine( ptArc) ;;
|
||||
pJCrv->AddArcTg( ptStart) ;
|
||||
|
||||
//int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( a, ORANGE) ;
|
||||
int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( a, ORANGE) ;
|
||||
|
||||
// assegno alle sue sottocurve la proprietà di curva aperta
|
||||
for ( int u = 0 ; u < pJCrv->GetCurveCount() ; ++ u)
|
||||
@@ -8790,10 +8808,181 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP
|
||||
}
|
||||
// non dovrebbe esserci un gap, ma meglio prevenire problemi
|
||||
pCompo->Close() ;
|
||||
int LI = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( LI, LIME) ;
|
||||
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsland, ICurveComposite* pCrvOpenOffs,
|
||||
const Point3d& ptCrvOpenS, const Point3d& ptCrvOpenE, const double dRad,
|
||||
const double dDiam, ICurveComposite* pNewCrv)
|
||||
{
|
||||
// controllo la validtà dei parametri
|
||||
if ( pCompo == nullptr || ! pCompo->IsValid() || pCompo->GetCurveCount() == 0 ||
|
||||
pCrvOpenOffs == nullptr || ! pCrvOpenOffs->IsValid() || pCrvOpenOffs->GetCurveCount() == 0)
|
||||
return false ;
|
||||
|
||||
// recupero l'estrusione della curva di bordo
|
||||
Vector3d vtExtr ; pCompo->GetExtrusion( vtExtr) ;
|
||||
|
||||
// -------------- RECUPERO DELLA CURVA ESTERNA PRIMA E DOPO IL LATO APERTO CORRENTE --------------
|
||||
double dUTrimS, dUTrimE ;
|
||||
PtrOwner<ICurveComposite> pCompo_Prec( CloneCurveComposite( pCompo)) ;
|
||||
pCompo_Prec->GetParamAtPoint( ptCrvOpenS, dUTrimS) ;
|
||||
pCompo_Prec->TrimEndAtParam( dUTrimS) ;
|
||||
int B = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCompo_Prec->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( B, BLACK) ; //
|
||||
PtrOwner<ICurveComposite> pCompo_Succ( CloneCurveComposite( pCompo)) ;
|
||||
pCompo_Succ->GetParamAtPoint( ptCrvOpenE, dUTrimE) ;
|
||||
pCompo_Succ->TrimStartAtParam( dUTrimE) ;
|
||||
int Bl = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo_Succ->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( Bl, BLUE) ; //
|
||||
PtrOwner<ICurveComposite> pCrvOpen( CloneCurveComposite( pCompo)) ;
|
||||
pCrvOpen->TrimStartEndAtParam( dUTrimS, dUTrimE) ;
|
||||
PtrOwner<ICurveComposite> pCompo_noOpenCrv( CloneCurveComposite( pCompo_Succ)) ;
|
||||
pCompo_noOpenCrv->AddCurve( pCompo_Prec->Clone()) ;
|
||||
|
||||
// recupero i punti e i vettori tangenti iniziali e finali del lato aperto
|
||||
Point3d ptSTART ; pCrvOpenOffs->GetStartPoint( ptSTART) ;
|
||||
Point3d ptEND ; pCrvOpenOffs->GetEndPoint( ptEND) ;
|
||||
Vector3d vtSTART ; pCrvOpenOffs->GetStartDir( vtSTART) ;
|
||||
Vector3d vtEND ; pCrvOpenOffs->GetEndDir( vtEND) ;
|
||||
|
||||
// -------------- CREAZIONE DELLA REGIONE DI INFLUENZA --------------
|
||||
// 1) Creo una copia della curva
|
||||
PtrOwner<ICurveComposite> pCrvOpen_clone( CloneCurveComposite( pCrvOpen)) ;
|
||||
if ( IsNull( pCrvOpen_clone) || ! pCrvOpen_clone->IsValid())
|
||||
return false ;
|
||||
// 2) Controllo la lunghezza della curva
|
||||
double dLen ;
|
||||
if ( ! pCrvOpen_clone->GetLength( dLen) || dLen < dDiam + EPS_SMALL)
|
||||
return false ;
|
||||
// 3) Accorcio l'inizio e la fine del raggio dell'utensile
|
||||
double dUS, dUE ;
|
||||
pCrvOpen_clone->GetParamAtLength( dRad, dUS) ;
|
||||
pCrvOpen_clone->GetParamAtLength( dLen - dRad, dUE) ;
|
||||
pCrvOpen_clone->TrimStartEndAtParam( dUS, dUE) ;
|
||||
// 4) Creo regione squadrata da questa curva
|
||||
PtrOwner<ISurfFlatRegion> pSfrInc( GetSurfFlatRegionFromFatCurve( Release( pCrvOpen_clone), dRad, true, false)) ;
|
||||
if ( IsNull( pSfrInc) || ! pSfrInc->IsValid())
|
||||
return false ;
|
||||
int arancione = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( arancione, ORANGE) ; //
|
||||
|
||||
// -------------- AGGIORNAMENTO DELLA REGIONE DI INFLUENZA --------------
|
||||
// creo un vettore con la pCompo senza lato aperto e le isole contenute al suo interno
|
||||
ICRVCOMPOPOVECTOR vCrvToCheck ;
|
||||
vCrvToCheck.emplace_back( pCompo_noOpenCrv->Clone()) ; // la curva esterna in prima posizione
|
||||
for ( int i = 0 ; i < ( int)vCrvIsland.size() ; ++ i)
|
||||
vCrvToCheck.emplace_back( vCrvIsland[i]->Clone()) ;
|
||||
|
||||
// scorro il vettore creato...
|
||||
for ( int c = 0 ; c < ( int)vCrvToCheck.size() ; ++ c) {
|
||||
// 1) recupero la curva corrente
|
||||
PtrOwner<ICurveComposite> pCrvCurr( CloneCurveComposite( vCrvToCheck[c])) ;
|
||||
if ( IsNull( pCrvCurr) || ! pCrvCurr->IsValid())
|
||||
return false ;
|
||||
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( pSfrInc->GetCurveClassification( *pCrvCurr, EPS_SMALL, ccClass)) {
|
||||
for ( int i = 0 ; i < ( int)ccClass.size() ; ++ i) {
|
||||
if ( ccClass[i].nClass == CRVC_IN) {
|
||||
// 2) Trovo il tratto di curva interno
|
||||
PtrOwner<ICurveComposite> pCrvCurrPartIn( GetCurveComposite( pCrvCurr->CopyParamRange( ccClass[i].dParS,
|
||||
ccClass[i].dParE))) ;
|
||||
if ( IsNull( pCrvCurrPartIn) || ! pCrvCurrPartIn->IsValid())
|
||||
continue ;
|
||||
|
||||
// 3) ricavo il punto iniziale e il punto finale
|
||||
Point3d ptS1 ; pCrvCurrPartIn->GetStartPoint( ptS1) ;
|
||||
Point3d ptE1 ; pCrvCurrPartIn->GetEndPoint( ptE1) ;
|
||||
|
||||
// 4) effettuo l'Offset della curva del diametro del tool
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pCrvCurrPartIn, - dDiam, ICurve::OFF_FILLET)) {
|
||||
m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// 5) scorro tutte le curve di Offset che si sono formate, prendendo sempre la più lunga tra le rimanenti
|
||||
PtrOwner<ICurve> pOffLongestCrv( OffsCrv.GetLongerCurve()) ;
|
||||
while ( ! IsNull( pOffLongestCrv)) {
|
||||
// 6) escludo le curve che si chiudono su se stesse dopo l'Offset
|
||||
if ( ! pOffLongestCrv->IsClosed()) {
|
||||
// 7) trasformo la curva in composita
|
||||
PtrOwner<ICurveComposite> pCompoPartInOffs( CreateCurveComposite()) ;
|
||||
pCompoPartInOffs->AddCurve( pOffLongestCrv->Clone()) ;
|
||||
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompoPartInOffs->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( r, RED) ;
|
||||
// 8) creo due rette che collegano i punti iniziali e finali della curva originale e di quella con offset
|
||||
PtrOwner<ICurveLine> pLineS( CreateCurveLine()) ;
|
||||
PtrOwner<ICurveLine> pLineE( CreateCurveLine()) ;
|
||||
if ( IsNull( pLineS) || IsNull( pLineE))
|
||||
return false ;
|
||||
Point3d ptS2 ; pCompoPartInOffs->GetStartPoint( ptS2) ;
|
||||
Point3d ptE2 ; pCompoPartInOffs->GetEndPoint( ptE2) ;
|
||||
pLineS->Set( ptS1, ptS2) ;
|
||||
pLineE->Set( ptE2, ptE1) ;
|
||||
// 9) creo il loop esterno della regione da aggiungere
|
||||
PtrOwner<ICurveComposite> pCrvExtBorder( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvExtBorder))
|
||||
return false ;
|
||||
pCrvExtBorder->AddCurve( Release( pLineS)) ; // primo tratto lineare
|
||||
pCrvExtBorder->AddCurve( Release( pCompoPartInOffs)) ; // tratto di offset
|
||||
pCrvExtBorder->AddCurve( Release( pLineE)) ; // secondo tratto lineare
|
||||
pCrvCurrPartIn->Invert() ; // inversione del tratto interno
|
||||
pCrvExtBorder->AddCurve( Release( pCrvCurrPartIn)) ; // aggiunta del tratto interno
|
||||
if ( pCrvExtBorder->IsClosed()) {
|
||||
// 9) Creo la nuova regione da aggiungere a quella di influenza
|
||||
PtrOwner<ISurfFlatRegion> pSfrExpan( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrExpan))
|
||||
return false ;
|
||||
pSfrExpan->AddExtLoop( Release( pCrvExtBorder)) ;
|
||||
int green = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExpan->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( green, GREEN) ; //
|
||||
if ( pSfrExpan->IsValid()) {
|
||||
if ( AreOppositeVectorApprox( pSfrExpan->GetNormVersor(), vtExtr))
|
||||
pSfrExpan->Invert() ;
|
||||
pSfrInc->Add( *pSfrExpan) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
pOffLongestCrv.Set( OffsCrv.GetLongerCurve()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
int brown = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( brown, BROWN) ; //
|
||||
|
||||
// RECUPERO DELLA CURVA DI BORDO ESTERNA DA AGGIUNGERE ALLA SVUOTATURA
|
||||
PtrOwner<ICurveComposite> pCrvNewBorder( GetCurveComposite( pSfrInc->GetLoop( 0, 0))) ;
|
||||
if ( IsNull( pCrvNewBorder))
|
||||
return false ;
|
||||
double dUSTART ; pCrvNewBorder->GetParamAtPoint( ptSTART, dUSTART) ;
|
||||
pCrvNewBorder->ChangeStartPoint( dUSTART) ;
|
||||
double dUEND ; pCrvNewBorder->GetParamAtPoint( ptEND, dUEND) ;
|
||||
pCrvNewBorder->TrimEndAtParam( dUEND) ;
|
||||
|
||||
int bb = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvNewBorder->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( bb, BLUE) ; //
|
||||
pNewCrv->Clear() ;
|
||||
pNewCrv->AddCurve( Release( pCrvNewBorder)) ;
|
||||
for ( int u = 0 ; u < pNewCrv->GetCurveCount() ; ++ u)
|
||||
pNewCrv->SetCurveTempProp( u, 1, 0) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AdjustContourStart( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsl, bool bOrder)
|
||||
@@ -9064,7 +9253,6 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
|
||||
}
|
||||
// aggiusto i bordi nel caso di Tool non cilindrico
|
||||
// ---
|
||||
|
||||
}
|
||||
|
||||
// creo la superifcie da restituire ( aggiornamento)
|
||||
@@ -9073,9 +9261,6 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
|
||||
if ( IsNull( pSrfFinal) || IsNull( pSrf_noOpenEdge))
|
||||
return false ;
|
||||
|
||||
//int v = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( v, PURPLE) ;
|
||||
|
||||
// per ogni Chunck della superificie ottenuta...
|
||||
for ( int c = 0 ; c < pSrf->GetChunkCount() ; ++ c) {
|
||||
|
||||
@@ -9085,7 +9270,7 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
|
||||
return false ;
|
||||
vCrvOEFlags.emplace_back( Release( pCrvEL)) ;
|
||||
|
||||
// 2) creo un vettore con le isole del Chunk
|
||||
// 2) creo un vettore con le isole del Chunk ( e uno con le isole ammissibili)
|
||||
ICRVCOMPOPOVECTOR vCrvIsl ;
|
||||
for ( int l = 1 ; l < pSrf->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<ICurveComposite> pCrvIL( GetCurveComposite( pSrf->GetLoop( c, l))) ;
|
||||
@@ -9093,6 +9278,7 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
|
||||
return false ;
|
||||
vCrvIsl.emplace_back( Release( pCrvIL)) ;
|
||||
}
|
||||
ICRVCOMPOPOVECTOR vCrvModIsland ;
|
||||
|
||||
// 3) Allargo la superificie ( curva esterna ) mediante i lati aperti
|
||||
bool bSomeOpen = false ;
|
||||
@@ -9112,9 +9298,70 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
|
||||
}
|
||||
|
||||
// 4) aggiungo le curve alla nuova superificie
|
||||
// NB Controllo se la curva si Autointerseca... alcuni lati aperti potrebbero mergiarsi
|
||||
SelfIntersCurve SiC( *pCrvExt) ;
|
||||
if ( SiC.GetIntersCount() > 0) {
|
||||
// creo la flatRegion
|
||||
SurfFlatRegionByContours SfrBC ;
|
||||
SfrBC.AddCurve( pCrvExt->Clone()) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrHelp( SfrBC.GetSurf()) ;
|
||||
if ( IsNull( pSfrHelp) || ! pSfrHelp->IsValid())
|
||||
return false ;
|
||||
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrHelp->Clone()) ;
|
||||
pCrvExt.Set( GetCurveComposite( pSfrHelp->GetLoop( 0, 0))) ;
|
||||
for ( int l = 1 ; l < pSfrHelp->GetLoopCount( 0) ; ++ l) {
|
||||
PtrOwner<ICurveComposite> pCrvClosedIsland( GetCurveComposite( pSfrHelp->GetLoop( 0, l))) ;
|
||||
if ( IsNull( pCrvClosedIsland) || ! pCrvClosedIsland->IsValid())
|
||||
return false ;
|
||||
for ( int u = 0 ; u < pCrvClosedIsland->GetCurveCount() ; ++ u)
|
||||
pCrvClosedIsland->SetCurveTempProp( u, 0, 0) ;
|
||||
vCrvIsl.emplace_back( Release( pCrvClosedIsland)) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 5) Controllo i bordi delle isole ottenute e modifico quelli in cui sono presenti lati aperti
|
||||
for ( int i = 0 ; i < ( int)vCrvIsl.size() ; ++ i) {
|
||||
bSomeOpen = false ;
|
||||
nProp0 = -1 ;
|
||||
int nCrvOpen = 0 ;
|
||||
PtrOwner<ICurveComposite> pCrvIsl( GetCurveComposite( vCrvIsl[i]->Clone())) ;
|
||||
for ( int u = 0 ; u < pCrvIsl->GetCurveCount() ; ++ u) {
|
||||
if ( pCrvIsl->GetCurveTempProp( u, nProp0, 0) && nProp0 == 1) {
|
||||
bSomeOpen = true ;
|
||||
++ nCrvOpen ;
|
||||
}
|
||||
}
|
||||
if ( bSomeOpen) { // se trovo dei lati aperti
|
||||
// 5.1) se l'isola è tutta aperta e trascurabile la talgo
|
||||
if ( nCrvOpen == pCrvIsl->GetCurveCount()) {
|
||||
// 5.1.1) Offsetto l'isola e controllo se sparisce
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pCrvIsl, m_dDiam_Prec > 0 ? m_dDiam_Prec + m_dOffsetR_Prec : m_TParams.m_dDiam,
|
||||
ICurve::OFF_FILLET)) {
|
||||
m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// nel caso l'Offset sparisca, allora passo all'isola successiva
|
||||
if ( OffsCrv.GetCurveCount() == 0)
|
||||
continue ;
|
||||
}
|
||||
// 5.2) sistemo la superificie
|
||||
ICRVCOMPOPOVECTOR vCrvNULL ;
|
||||
if ( ! AdjustContourWithOpenEdges( pCrvIsl, vCrvNULL, m_dDiam_Prec > 0 ? m_dDiam_Prec : m_TParams.m_dDiam,
|
||||
m_dDiam_Prec > 0 ? m_dOffsetR_Prec : GetOffsR())) {
|
||||
m_pMchMgr->SetLastError( 2430, "Error in Pocketing : adjust open edges failed") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
vCrvModIsland.emplace_back( pCrvIsl->Clone()) ;
|
||||
}
|
||||
|
||||
// 6) Creo la nuova superificie da svuotare
|
||||
pSrfFinal->AddExtLoop( Release( pCrvExt)) ;
|
||||
for ( int i = 0 ; i < ( int)vCrvIsl.size() ; ++ i)
|
||||
pSrfFinal->AddIntLoop( Release( vCrvIsl[i])) ;
|
||||
for ( int i = 0 ; i < ( int)vCrvModIsland.size() ; ++ i) {
|
||||
pSrfFinal->AddIntLoop( Release( vCrvModIsland[i])) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se superificie già lavorata in precedenza ...
|
||||
|
||||
@@ -115,6 +115,10 @@ class Pocketing : public Machining
|
||||
bool GetParamOnOpenSide( const ICurveComposite* pCompo,const ICRVCOMPOPOVECTOR& vCrvIsl, Point3d& ptMid, Vector3d& vtMidOut) ;
|
||||
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsl,
|
||||
double dDiam, double dOffR) ;
|
||||
bool AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsland,
|
||||
ICurveComposite* pCrvOpenOffs, const Point3d& ptCrvOpenS,
|
||||
const Point3d& ptCrvOpenE, const double dRad, const double dDiam,
|
||||
ICurveComposite* pNewCrv) ;
|
||||
bool AdjustContourStart( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsl, bool bOrder = false) ;
|
||||
bool GetParamForPtStartOnEdge( const ICurve* pCrv, const ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsl,
|
||||
double& dPar) ;
|
||||
|
||||
Reference in New Issue
Block a user