EgtMachKernel :

- migliorie archi lati aperti.
This commit is contained in:
Riccardo Elitropi
2023-06-22 13:14:35 +02:00
parent ca74fa6794
commit ec1ee961be
2 changed files with 167 additions and 108 deletions
+162 -103
View File
@@ -2175,20 +2175,25 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
bool bChanged = false ;
PtrOwner<ISurfFlatRegion> pSrfToAdapt( CloneSurfFlatRegion( pSrfChunk)) ;
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, vCrvOEF, bChanged)) {
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++ h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
// la superificie potrebbe non essere valida, se già svuotata tutta con un Tool in precedenza...
if ( ! IsNull( vSrfSliced[j-1])) {
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++ h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
if ( ! IsNull( vSrfSliced[j-2])) {
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
}
else
vbChangedPrec[j-1] = true ;
}
}
}
else {
return false ;
@@ -2199,9 +2204,15 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
// ciclo su tutti gli step
for( int j = 1 ; j <= nStep ; ++j) {
// se superificie non valida, salto allo step successivo
if ( IsNull( vSrfSliced[ j-1]) || vSrfSliced[j-1]->GetChunkCount() == 0) {
vSrfSliced[j-1].Set( pSrfChunk->Clone()) ;
continue ;
}
// la superificie che lavoro è quella ottenuta in precedenza allo step j-esimo
PtrOwner<ISurfFlatRegion> pSrfFinal( CloneSurfFlatRegion( vSrfSliced[j - 1])) ;
if( IsNull( pSrfFinal))
if ( IsNull( pSrfFinal))
return false ;
// ciclo su tutti i chunk della superificie per lo step j-esimo
@@ -3881,8 +3892,6 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
vector<ICRVCOMPOPOVECTOR> vCrvOEWithFlags( nStep) ;
BOOLVECTOR vbChangedPrec( nStep, false) ;
m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pSrfIdeal->Clone()) ;
for ( int j = 1 ; j <= nStep ; ++ j) {
// controllo l'intersezione/proiezione tra la superificie e il grezzo
PtrOwner<ICurveComposite> pCrvOPF( CreateCurveComposite()) ;
@@ -3892,18 +3901,23 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
PtrOwner<ISurfFlatRegion> pSrfToAdapt( CloneSurfFlatRegion( pSrfIdeal)) ;
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, vCrvOEF, bChanged)) {
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
if ( ! IsNull( vSrfSliced[j-1])) {
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
if ( ! IsNull( vSrfSliced[j-2])) {
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
}
else
vbChangedPrec[j-1] = true ;
}
}
}
else {
return false ;
@@ -3911,14 +3925,19 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
}
Point3d ptP1 ;
for( int j = 1 ; j <= nStep ; ++ j) {
for ( int j = 1 ; j <= nStep ; ++ j) {
// se superificie non valida, salto allo step successivo
if ( IsNull( vSrfSliced[ j-1]) || vSrfSliced[j-1]->GetChunkCount() == 0) {
vSrfSliced[j-1].Set( vSrfFlat[nIs]->Clone()) ;
continue ;
}
// per entrate ed uscite
PtrOwner<ISurfFlatRegion> pSrfLeanInOut( CloneSurfFlatRegion( vSrfSliced[j-1])) ;
if ( IsNull( pSrfLeanInOut) || pSrfLeanInOut->GetChunkCount() == 0)
return false ;
// === PRIMO OFFSET ===
// NB. Effettuando il primo Offset, il numero di chunk qui potrebbe cambiare...
PtrOwner<ISurfFlatRegion> pSrfFirstOffs( CloneSurfFlatRegion( vSrfSliced[j-1])) ;
@@ -4421,18 +4440,24 @@ Pocketing::AddSpiralIn( const ISurfFlatRegion* pSrfPock, /*PNTVECTOR vPtStart,*/
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, vCrvOEF, bChanged)) {
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// la superificie potrebbe non essere valida, se già svuotata tutta con un Tool in precedenza...
if ( ! IsNull( vSrfSliced[j-1])) {
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
if ( ! IsNull( vSrfSliced[j-2])) {
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
}
else
vbChangedPrec[j-1] = true ;
}
}
}
else {
return false ;
@@ -4445,6 +4470,12 @@ Pocketing::AddSpiralIn( const ISurfFlatRegion* pSrfPock, /*PNTVECTOR vPtStart,*/
// ciclo su tutti gli step
for ( int j = 1 ; j <= nStep ; ++ j) {
// se superificie non valida, salto allo step successivo
if ( IsNull( vSrfSliced[ j-1]) || vSrfSliced[j-1]->GetChunkCount() == 0) {
vSrfSliced[j-1].Set( pSrfChunk->Clone()) ;
continue ;
}
// la superificie che lavoro è quella ottenuta in precedenza allo step j-esimo
PtrOwner<ISurfFlatRegion> pSrfFinal( CloneSurfFlatRegion( vSrfSliced[j - 1])) ;
if ( IsNull( pSrfFinal))
@@ -4805,18 +4836,24 @@ Pocketing::AddSpiralOut( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, vCrvOEF, bChanged)) {
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// la superificie potrebbe non essere valida, se già svuotata tutta con un Tool in precedenza...
if ( ! IsNull( vSrfSliced[j-1])) {
for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h)
vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
// controllo se la superificie attuale e precedente sono diverse tra loro
if ( j > 1) {
double dAreaPrec = 0 ; double dAreaAct = 0 ;
if ( ! IsNull( vSrfSliced[j-2])) {
vSrfSliced[j-2]->GetArea( dAreaPrec) ;
vSrfSliced[j-1]->GetArea( dAreaAct) ;
if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL)
vbChangedPrec[j-1] = true ;
}
else
vbChangedPrec[j-1] = true ;
}
}
}
else {
return false ;
@@ -4829,6 +4866,12 @@ Pocketing::AddSpiralOut( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool
// ciclo su tutti gli step
for ( int j = 1 ; j <= nStep ; ++ j) {
// se superificie non valida, salto allo step successivo
if ( IsNull( vSrfSliced[ j-1]) || vSrfSliced[j-1]->GetChunkCount() == 0) {
vSrfSliced[j-1].Set( pSrfChunk->Clone()) ;
continue ;
}
// la superificie che lavoro è quella ottenuta in precedenza allo step j-esimo
PtrOwner<ISurfFlatRegion> pSrfFinal( CloneSurfFlatRegion( vSrfSliced[j - 1])) ;
if( IsNull( pSrfFinal))
@@ -8613,7 +8656,7 @@ Pocketing::GetParamOnOpenSide( const ICurveComposite* pCompo, const ICRVCOMPOPOV
//----------------------------------------------------------------------------
bool
Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTOR& vCrvIsl,
double dTool_Diam, double dOffR, ISurfTriMesh* pStmRaw)
double dTool_Diam, double dOffR, const Vector3d& vtTrasl, ISurfTriMesh* pStmRaw)
{
// vettore estrusione
@@ -8720,9 +8763,10 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTO
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, pStmRaw) ;
vpCrvs[i].Set( Release( pCrvNew)) ;
vpCrvs[i]->GetStartPoint( ptStart) ;
if ( AdjustPathOutsideRawForOpenEdges( pCompo_clone, vCrvIsl, pHHHH, ptS, ptE, dRad, dDiam, pCrvNew, vtTrasl, pStmRaw)) {
vpCrvs[i].Set( Release( pCrvNew)) ;
vpCrvs[i]->GetStartPoint( ptStart) ;
}
//int BRO = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vpCrvs[i]->Clone()) ;
//m_pGeomDB->SetMaterial( BRO, BROWN) ;
// -----------------------------------------------------------------------------------
@@ -8853,7 +8897,8 @@ 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, ISurfTriMesh* pStmRaw)
const double dDiam, ICurveComposite* pNewCrv, const Vector3d& vtTrasl,
ISurfTriMesh* pStmRaw)
{
// controllo la validtà dei parametri
if ( pCompo == nullptr || ! pCompo->IsValid() || pCompo->GetCurveCount() == 0 ||
@@ -8904,8 +8949,8 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
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) ; //
int black = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; //
m_pGeomDB->SetMaterial( black, BLACK) ; //
// -------------- AGGIORNAMENTO DELLA REGIONE DI INFLUENZA --------------
// creo un vettore con la pCompo senza lato aperto e le isole contenute al suo interno
@@ -8914,7 +8959,7 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
for ( int i = 0 ; i < ( int)vCrvIsland.size() ; ++ i)
vCrvToCheck.emplace_back( vCrvIsland[i]->Clone()) ;
// scorro il vettore creato...
// scorro il vettore creato...
for ( int c = 0 ; c < ( int)vCrvToCheck.size() ; ++ c) {
// 1) recupero la curva corrente
PtrOwner<ICurveComposite> pCrvCurr( CloneCurveComposite( vCrvToCheck[c])) ;
@@ -8930,10 +8975,13 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
ccClass[i].dParE))) ;
if ( IsNull( pCrvCurrPartIn) || ! pCrvCurrPartIn->IsValid())
continue ;
pCrvCurrPartIn->SetExtrusion( vtExtr) ;
// 3) ricavo il punto iniziale e il punto finale
// 3) ricavo il punto iniziale e il punto finale, assieme ai vettori tangenti
Point3d ptS1 ; pCrvCurrPartIn->GetStartPoint( ptS1) ;
Point3d ptE1 ; pCrvCurrPartIn->GetEndPoint( ptE1) ;
Vector3d vtS1 ; pCrvCurrPartIn->GetStartDir( vtS1) ;
Vector3d vtE1 ; pCrvCurrPartIn->GetEndDir( vtE1) ;
// 4) effettuo l'Offset della curva del diametro del tool
OffsetCurve OffsCrv ;
@@ -8951,21 +8999,23 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
PtrOwner<ICurveComposite> pCompoPartInOffs( CreateCurveComposite()) ;
pCompoPartInOffs->AddCurve( pOffLongestCrv->Clone()) ;
// 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))
PtrOwner<ICurveArc> pArcS( CreateCurveArc()) ;
PtrOwner<ICurveArc> pArcE( CreateCurveArc()) ;
if ( IsNull( pArcS) || IsNull( pArcE))
return false ;
Point3d ptS2 ; pCompoPartInOffs->GetStartPoint( ptS2) ;
Point3d ptE2 ; pCompoPartInOffs->GetEndPoint( ptE2) ;
pLineS->Set( ptS1, ptS2) ;
pLineE->Set( ptE2, ptE1) ;
Vector3d vtS2 ; pCompoPartInOffs->GetStartDir( vtS2) ;
Vector3d vtE2 ; pCompoPartInOffs->GetEndDir( vtE2) ;
pArcS->Set2PVN( ptS1, ptS2, vtS1, vtExtr) ;
pArcE->Set2PVN( ptE2, ptE1, vtE2, vtExtr) ;
// 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( pArcS)) ; // primo tratto lineare
pCrvExtBorder->AddCurve( Release( pCompoPartInOffs)) ; // tratto di offset
pCrvExtBorder->AddCurve( Release( pLineE)) ; // secondo tratto lineare
pCrvExtBorder->AddCurve( Release( pArcE)) ; // secondo tratto lineare
pCrvCurrPartIn->Invert() ; // inversione del tratto interno
pCrvExtBorder->AddCurve( Release( pCrvCurrPartIn)) ; // aggiunta del tratto interno
@@ -9004,7 +9054,7 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
if ( pStmRaw != nullptr) {
bool bIsChanged ;
if ( m_bIntersRaw)
IntersSurfWithRaw( pSfrInc, pStmRaw, Z_AX * 10 * EPS_SMALL, bIsChanged, 1500 * EPS_SMALL, false, false) ;
IntersSurfWithRaw( pSfrInc, pStmRaw, vtTrasl + Z_AX * 10 * EPS_SMALL, bIsChanged, 1500 * EPS_SMALL, false, false) ;
}
int brown = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; //
@@ -9015,9 +9065,19 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
if ( IsNull( pCrvNewBorder))
return false ;
double dUSTART ; pCrvNewBorder->GetParamAtPoint( ptSTART, dUSTART, 5000 * EPS_SMALL) ;
double dUSTART ;
if ( ! pCrvNewBorder->GetParamAtPoint( ptSTART, dUSTART, 5000 * EPS_SMALL)) {
int nFlag ;
if ( ! DistPointCurve( ptSTART, *pCrvNewBorder).GetParamAtMinDistPoint( 0, dUSTART, nFlag))
return false ;
}
pCrvNewBorder->ChangeStartPoint( dUSTART) ;
double dUEND ; pCrvNewBorder->GetParamAtPoint( ptEND, dUEND, 5000 * EPS_SMALL) ;
double dUEND ;
if ( ! pCrvNewBorder->GetParamAtPoint( ptEND, dUEND, 5000 * EPS_SMALL)) {
int nFlag ;
if ( ! DistPointCurve( ptEND, *pCrvNewBorder).GetParamAtMinDistPoint( 0, dUEND, nFlag))
return false ;
}
pCrvNewBorder->TrimEndAtParam( dUEND) ;
pNewCrv->Clear() ;
@@ -9025,6 +9085,9 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
for ( int u = 0 ; u < pNewCrv->GetCurveCount() ; ++ u)
pNewCrv->SetCurveTempProp( u, 1, 0) ;
int P = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pNewCrv->Clone()) ; //
m_pGeomDB->SetMaterial( P, PURPLE) ;
return true ;
}
@@ -9285,10 +9348,10 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
if ( pStmRaw->IsValid() || pStmRaw->GetTriangleCount() > 0) {
// 1) INTERSEZIONE CON GREZZO
if ( m_bIntersRaw) {
if ( ! IntersSurfWithRaw( pSrf, pStmRaw, vtTrasl, bChanged, 500 * EPS_SMALL, true, true))
if ( ! IntersSurfWithRaw( pSrf, pStmRaw, vtTrasl, bChanged, 500 * EPS_SMALL, true, m_dDiam_Prec < EPS_SMALL))
return false ;
int g = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf->Clone()) ;
m_pGeomDB->SetMaterial( g, GREEN) ;
int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf->Clone()) ;
m_pGeomDB->SetMaterial( b, BROWN) ;
}
// 2) PROIEZIONE CON GREZZO
if ( m_bProjectRaw) {
@@ -9305,24 +9368,23 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO
return false ;
// 3) ESTENSIONE PER I LATI APERTI
if ( ! ModifySurfByOpenEdge( pSrf, vCrvOEFlags, pStmRaw))
if ( ! ModifySurfByOpenEdge( pSrf, vCrvOEFlags, vtTrasl, pStmRaw))
return false ;
int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf->Clone()) ;
m_pGeomDB->SetMaterial( p, PURPLE) ;
// 4) SE SUPERIFICIE PRECEDENTEMENTE GIA' LAVORATA...
if ( m_dDiam_Prec > 0) {
if ( ! GetNewSrfByAnotherPocketing( pSrf, pSrf_noOpenEdge))
return false ;
}
if ( m_dDiam_Prec > 0)
return GetNewSrfByAnotherPocketing( pSrf, pSrf_noOpenEdge, vtTrasl) ;
return pSrf->IsValid() && pSrf->GetChunkCount() != 0 ;
}
//----------------------------------------------------------------------------
bool
Pocketing::ModifySurfByOpenEdge( ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vCrvOEFlags, ISurfTriMesh* pStmRaw)
Pocketing::ModifySurfByOpenEdge( ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vCrvOEFlags, const Vector3d& vtTrasl,
ISurfTriMesh* pStmRaw)
{
// controllo dei parametri
if ( pSrf == nullptr || ! pSrf->IsValid() || pSrf->GetChunkCount() == 0)
@@ -9363,7 +9425,8 @@ Pocketing::ModifySurfByOpenEdge( ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vCrvO
if ( bSomeOpen) { // se trovo dei lati aperti
// 3.1) sistemo la superificie
if ( ! AdjustContourWithOpenEdges( pCrvExt, vCrvIsl, m_dDiam_Prec > 0 ? m_dDiam_Prec : m_TParams.m_dDiam,
m_dDiam_Prec > 0 ? m_dOffsetR_Prec : GetOffsR(), pStmRaw)) {
m_dDiam_Prec > 0 ? m_dOffsetR_Prec : GetOffsR(), vtTrasl,
pStmRaw)) {
m_pMchMgr->SetLastError( 2430, "Error in Pocketing : adjust open edges failed") ;
return false ;
}
@@ -9418,7 +9481,7 @@ Pocketing::ModifySurfByOpenEdge( ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vCrvO
// 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(), pStmRaw)) {
m_dDiam_Prec > 0 ? m_dOffsetR_Prec : GetOffsR(), vtTrasl, pStmRaw)) {
m_pMchMgr->SetLastError( 2430, "Error in Pocketing : adjust open edges failed") ;
return false ;
}
@@ -9469,7 +9532,7 @@ Pocketing::IntersSurfWithRaw( ISurfFlatRegion* pSfrPock, const ISurfTriMesh* pSt
return false ;
// traslo la superificie da svuotare a seconda dello step e la taglio con il grezzo
if ( ! pStm->Translate( vtTrasl) ||
//! m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStm->Clone()) || ! m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRaw->Clone()) ||
! m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStm->Clone()) || ! m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRaw->Clone()) ||
! pStm->CutWithOtherSurf( *pStmRaw, bInVsOut, true) ||
pStm->GetTriangleCount() == 0) {
pStm.Set( pStmCopy) ;
@@ -11918,13 +11981,13 @@ Pocketing::DrawColoredCrvForFeedTest( ICurve* pCurve, double dFeed)
//----------------------------------------------------------------------------
bool
Pocketing::GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion* pSrf_noOpenEdge)
Pocketing::GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion* pSrf_noOpenEdge, const Vector3d& vtTrasl)
{
// controllo dei parametri
if ( pSrf == nullptr || ! pSrf->IsValid() || pSrf->GetChunkCount() == 0 || m_dDiam_Prec < 0)
return false ;
// se e i parametri ed il tool permettono la nuova lavoazione...
// se e i parametri ed il tool permettono la nuova lavorazione...
if ( m_TParams.m_dDiam / 2 + GetOffsR() < m_dDiam_Prec / 2 + m_dOffsetR_Prec) {
// clono la superificie ricavata in precedenza ( senza estensione con lati aperti)
PtrOwner<ISurfFlatRegion> pSrf_Sub( CloneSurfFlatRegion( pSrf)) ;
@@ -11932,37 +11995,42 @@ Pocketing::GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion*
return false ;
// effettuo un Offset verso l'interno ( curve esterne che percorre il centro del Tool)
if ( pSrf_Sub->Offset( - m_dDiam_Prec / 2 - m_dOffsetR_Prec - 5 * EPS_SMALL, ICurve::OFF_FILLET)) {
// effettuo un Offset del raggio del tool precedente per ricavare la regione svuotata in precedenza
if ( pSrf_Sub->Offset( m_dDiam_Prec / 2 + 20 * EPS_SMALL, ICurve::OFF_FILLET)) {
//int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_Sub->Clone()) ;
//m_pGeomDB->SetMaterial( r, RED) ;
}
if ( ! pSrf_Sub->Offset( m_dDiam_Prec / 2 + 20 * EPS_SMALL, ICurve::OFF_FILLET))
return false ;
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_Sub->Clone()) ;
m_pGeomDB->SetMaterial( r, RED) ;
int v = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_noOpenEdge->Clone()) ;
m_pGeomDB->SetMaterial( v, GREEN) ;
PtrOwner<ISurfFlatRegion> pSrf_clone( CloneSurfFlatRegion( pSrf_noOpenEdge)) ;
if ( pSrf_clone->Subtract( *pSrf_Sub)) {
//int v = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_clone->Clone()) ;
//m_pGeomDB->SetMaterial( v, GREEN) ;
if ( ! pSrf_clone->IsValid() || pSrf_clone->GetChunkCount() == 0) {
pSrf->Clear() ;
return true ;
}
int l = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_clone->Clone()) ;
m_pGeomDB->SetMaterial( l, LIME) ;
// ricavo la curva esterna originale
PtrOwner<ICurveComposite> pCrvExt_orig( GetCurveComposite( pSrf->GetLoop( 0, 0))) ;
//int y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExt_orig->Clone()) ;
//m_pGeomDB->SetMaterial( y, YELLOW) ;
// superificie finale da restituire ...
PtrOwner<ISurfFlatRegion> pSrf_Final( CreateSurfFlatRegion()) ;
if ( IsNull( pSrf_Final))
return false ;
// tolgo dalla superificie le parti al di fuori del grezzo
bool bIsChanged ;
// per ogni chunk della superificie ricavata....
for ( int c = 0 ; c < pSrf_clone->GetChunkCount() ; ++ c) {
// singolo chunk della superificie modificato per i lati aperti...
PtrOwner<ISurfFlatRegion> pChunk_WithOpenEdges( CreateSurfFlatRegion()) ;
if ( IsNull( pChunk_WithOpenEdges))
return false ;
int nStat = 0 ;
PtrOwner<ICurveComposite> pCrvExt( GetCurveComposite( pSrf_clone->GetLoop( c, 0))) ;
// setto tutte le sottocurve aperte
@@ -11986,9 +12054,6 @@ Pocketing::GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion*
}
}
//int R = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExt->Clone()) ;
//m_pGeomDB->SetMaterial( R, RED) ;
bool bSomeOpen = false ;
int nProp0 = -1 ;
for ( int u = 0 ; u < pCrvExt->GetCurveCount() && !bSomeOpen ; ++ u) {
@@ -11999,7 +12064,7 @@ Pocketing::GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion*
for ( int l = 1 ; l < pSrf_clone->GetLoopCount( c) ; ++ l)
vCrvIsl.emplace_back( GetCurveComposite( pSrf_clone->GetLoop( c, l))) ;
if ( bSomeOpen) { // se trovo dei lati aperti
if ( ! AdjustContourWithOpenEdges( pCrvExt, vCrvIsl, m_TParams.m_dDiam, GetOffsR())) {
if ( ! AdjustContourWithOpenEdges( pCrvExt, vCrvIsl, m_TParams.m_dDiam, GetOffsR(), vtTrasl)) {
m_pMchMgr->SetLastError( 2430, "Error in Pocketing : adjust open edges failed") ;
return false ;
}
@@ -12010,17 +12075,11 @@ Pocketing::GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion*
for ( int i = 1 ; i < int( vCrvIsl.size()) ; ++ i)
pChunk_WithOpenEdges->AddIntLoop( Release( vCrvIsl[i])) ; // aggiungo le eventuali isole
//int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pChunk_WithOpenEdges->Clone()) ;
//m_pGeomDB->SetMaterial( W, WHITE) ;
// aggiungo questo Chunk alla superificie finale ( potrebbero essere sovrapposti per alcune parti...)
if ( pSrf_Final->GetChunkCount() == 0)
pSrf_Final.Set( pChunk_WithOpenEdges) ;
else
pSrf_Final->Add( *pChunk_WithOpenEdges) ;
}
pSrf->Clear() ;
+5 -5
View File
@@ -115,16 +115,16 @@ class Pocketing : public Machining
bool GetCoeffLinArc( const ICurveArc* pArc, double dDiam, double& dSubArc) ;
bool GetParamOnOpenSide( const ICurveComposite* pCompo,const ICRVCOMPOPOVECTOR& vCrvIsl, Point3d& ptMid, Vector3d& vtMidOut) ;
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTOR& vCrvIsl,
double dDiam, double dOffR, ISurfTriMesh* pStmRaw = nullptr) ;
double dDiam, double dOffR, const Vector3d& vtTrasl, ISurfTriMesh* pStmRaw = nullptr) ;
bool AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsland,
ICurveComposite* pCrvOpenOffs, const Point3d& ptCrvOpenS,
const Point3d& ptCrvOpenE, const double dRad, const double dDiam,
ICurveComposite* pNewCrv, ISurfTriMesh* pStmRaw = nullptr) ;
ICurveComposite* pNewCrv, const Vector3d& vtTrasl, ISurfTriMesh* pStmRaw = nullptr) ;
bool AdjustContourStart( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsl, bool bOrder = false) ;
bool GetParamForPtStartOnEdge( const ICurve* pCrv, const ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvIsl,
double& dPar) ;
bool ModifySurfByOpenEdge( ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vCrvOEFlags, ISurfTriMesh* pStmRaw = nullptr) ;
bool GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion* pSrf_noOpenEdge) ;
bool ModifySurfByOpenEdge( ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vCrvOEFlags, const Vector3d& vtTrasl, ISurfTriMesh* pStmRaw = nullptr) ;
bool GetNewSrfByAnotherPocketing( ISurfFlatRegion* pSrf, ISurfFlatRegion* pSrf_noOpenEdge, const Vector3d& vtTrasl) ;
// ===================================================================
// ============================ ZigZag ===============================
@@ -317,7 +317,7 @@ class Pocketing : public Machining
bool m_bOptOffset = true ; // flag per ottimizzazione numero di Offset necessari
bool m_bOptOffsetCM = false ; // flag per ottimizzazione numero di Offset necessari con centroidi e medial Axis
bool m_bAssignFeed = true ; // flag per controllo della Feed
double m_dDiam_Prec = 0.0 ; // diametro utensile per precedente svuotatura
double m_dDiam_Prec = 70.0 ; // diametro utensile per precedente svuotatura
double m_dOffsetR_Prec = 0.0 ; // Offset radiale della svuotatura precedente
} ;