Merge commit 'cdb35b4c38c4b3ca65f90c061aa46d4db1f9506f' into svuotature
This commit is contained in:
+165
-233
@@ -2167,40 +2167,10 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
ISURFFRPOVECTOR vSrfSliced( nStep) ;
|
||||
vector<ICRVCOMPOPOVECTOR> vCrvOEWithFlags( nStep) ;
|
||||
BOOLVECTOR vbChangedPrec( nStep, false) ;
|
||||
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// controllo l'intersezione/proiezione tra la superificie e il grezzo
|
||||
PtrOwner<ICurveComposite> pCrvOPF( CreateCurveComposite()) ;
|
||||
Vector3d vtTrasl = -vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
ICRVCOMPOPOVECTOR vCrvOEF ;
|
||||
bool bChanged = false ;
|
||||
PtrOwner<ISurfFlatRegion> pSrfToAdapt( CloneSurfFlatRegion( pSrfChunk)) ;
|
||||
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, 100.0, vCrvOEF, bChanged)) {
|
||||
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
|
||||
// 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 ;
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// modifico le superifici in base alla geometria del grezzo
|
||||
if ( ! GetParamsAtEachStep( vSrfSliced, vCrvOEWithFlags, vbChangedPrec, pSrfChunk,
|
||||
nStep, vtTool, dElev, dDepth, dStep))
|
||||
return false ;
|
||||
|
||||
// ciclo su tutti gli step
|
||||
for( int j = 1 ; j <= nStep ; ++j) {
|
||||
@@ -3899,8 +3869,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
ISURFFRPOVECTOR vSrfSliced( nStep) ;
|
||||
vector<ICRVCOMPOPOVECTOR> vCrvOEWithFlags( nStep) ;
|
||||
BOOLVECTOR vbChangedPrec( nStep, false) ;
|
||||
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// controllo l'intersezione/proiezione tra la superificie e il grezzo
|
||||
PtrOwner<ICurveComposite> pCrvOPF( CreateCurveComposite()) ;
|
||||
Vector3d vtTrasl = -vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
@@ -3932,6 +3901,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Point3d ptP1 ;
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
|
||||
@@ -4436,43 +4406,10 @@ Pocketing::AddSpiralIn( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool,
|
||||
ISURFFRPOVECTOR vSrfSliced( nStep) ;
|
||||
vector<ICRVCOMPOPOVECTOR> vCrvOEWithFlags( nStep) ;
|
||||
BOOLVECTOR vbChangedPrec( nStep, false) ;
|
||||
double dDepth_Raw = 2.0 * ( dDepth - dElev + dStep) ;
|
||||
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// controllo l'intersezione/proiezione tra la superificie e il grezzo
|
||||
PtrOwner<ICurveComposite> pCrvOPF( CreateCurveComposite()) ;
|
||||
Vector3d vtTrasl = -vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
ICRVCOMPOPOVECTOR vCrvOEF ;
|
||||
bool bChanged = false ;
|
||||
PtrOwner<ISurfFlatRegion> pSrfToAdapt( CloneSurfFlatRegion( pSrfChunk)) ;
|
||||
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, 100.0, vCrvOEF, bChanged)) {
|
||||
|
||||
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
|
||||
// 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 ;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// modifico le superifici in base alla geometria del grezzo
|
||||
if ( ! GetParamsAtEachStep( vSrfSliced, vCrvOEWithFlags, vbChangedPrec, pSrfChunk,
|
||||
nStep, vtTool, dElev, dDepth, dStep))
|
||||
return false ;
|
||||
|
||||
Point3d ptP1 ; // per LeadIn
|
||||
|
||||
@@ -4834,41 +4771,10 @@ Pocketing::AddSpiralOut( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool
|
||||
ISURFFRPOVECTOR vSrfSliced( nStep) ;
|
||||
vector<ICRVCOMPOPOVECTOR> vCrvOEWithFlags( nStep) ;
|
||||
BOOLVECTOR vbChangedPrec( nStep, false) ;
|
||||
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
// controllo l'intersezione/proiezione tra la superificie e il grezzo
|
||||
PtrOwner<ICurveComposite> pCrvOPF( CreateCurveComposite()) ;
|
||||
Vector3d vtTrasl = -vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
ICRVCOMPOPOVECTOR vCrvOEF ;
|
||||
bool bChanged = false ;
|
||||
PtrOwner<ISurfFlatRegion> pSrfToAdapt( CloneSurfFlatRegion( pSrfChunk)) ;
|
||||
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, 100.0, vCrvOEF, bChanged)) {
|
||||
|
||||
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
|
||||
// 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 ;
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// modifico le superifici in base alla geometria del grezzo
|
||||
if ( ! GetParamsAtEachStep( vSrfSliced, vCrvOEWithFlags, vbChangedPrec, pSrfChunk,
|
||||
nStep, vtTool, dElev, dDepth, dStep))
|
||||
return false ;
|
||||
|
||||
Point3d ptP1 ;
|
||||
|
||||
@@ -8839,7 +8745,7 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTO
|
||||
}
|
||||
else {
|
||||
pCompo->AddLine( ptStart) ;
|
||||
pCompo->SetCurveTempProp( pCompo->GetCurveCount() - 1, 1, 0) ; // segmento come curva aperta
|
||||
pCompo->SetCurveTempProp( pCompo->GetCurveCount() - 1, bInVsOut ? 0 : 1, 0) ; // segmento aggiunto
|
||||
}
|
||||
}
|
||||
// se passo da aperto a chiuso
|
||||
@@ -8891,7 +8797,7 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTO
|
||||
}
|
||||
else {
|
||||
pCompo->AddLine( ptStart) ;
|
||||
pCompo->SetCurveTempProp( pCompo->GetCurveCount() - 1, 1, 0) ; // segmento come curva aperta
|
||||
pCompo->SetCurveTempProp( pCompo->GetCurveCount() - 1, bInVsOut ? 0 : 1, 0) ; // segmento come curva aperta
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -9072,8 +8978,8 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
|
||||
PtrOwner<ISurfFlatRegion> pSrfInc_toDraw( CloneSurfFlatRegion( pSfrInc)) ;
|
||||
pSrfInc_toDraw->Translate( vtTrasl) ;
|
||||
int brown1 = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrfInc_toDraw->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( brown1, BROWN) ;
|
||||
//int brown1 = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrfInc_toDraw->Clone()) ; //
|
||||
//m_pGeomDB->SetMaterial( brown1, BROWN) ;
|
||||
|
||||
|
||||
// recupero il Grezzo e sottraggo tutto ciò che sta nella regione
|
||||
@@ -9085,8 +8991,8 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
|
||||
PtrOwner<ISurfFlatRegion> pSrfInc_toDraw1( CloneSurfFlatRegion( pSfrInc)) ;
|
||||
pSrfInc_toDraw1->Translate( vtTrasl) ;
|
||||
int brown = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrfInc_toDraw1->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( brown, YELLOW) ;
|
||||
//int brown = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrfInc_toDraw1->Clone()) ; //
|
||||
//m_pGeomDB->SetMaterial( brown, YELLOW) ;
|
||||
|
||||
// RECUPERO DELLA CURVA DI BORDO ESTERNA DA AGGIUNGERE ALLA SVUOTATURA
|
||||
PtrOwner<ICurveComposite> pCrvNewBorder( GetCurveComposite( pSfrInc->GetLoop( 0, 0))) ;
|
||||
@@ -9351,6 +9257,54 @@ Pocketing::CalcDistanceFromRawSurface( int nPhase, const Point3d& ptP, const Vec
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOVECTOR>& vCrvOEWithFlags,
|
||||
BOOLVECTOR vbChangedPrec, const ISurfFlatRegion* pSrfChunk, const int& nStep, const Vector3d vtTool, const double& dElev,
|
||||
const double& dDepth, const double& dStep)
|
||||
{
|
||||
for ( int j = 1 ; j <= nStep ; ++ j) {
|
||||
|
||||
// vettore traslazione corrente allo step j-esimo
|
||||
Vector3d vtTrasl = - vtTool * ( dDepth - dElev + j * dStep) ;
|
||||
// vettore delle curve con Flag per lati aperti
|
||||
ICRVCOMPOPOVECTOR vCrvOEF ;
|
||||
// flag se la superificie è cambiata
|
||||
bool bChanged = false ;
|
||||
// copia del chunk c-esimo della superificie attuale
|
||||
PtrOwner<ISurfFlatRegion> pSrfToAdapt( CloneSurfFlatRegion( pSrfChunk)) ;
|
||||
if ( IsNull( pSrfToAdapt))
|
||||
return false ;
|
||||
|
||||
// adatto la superficie dello step corrente con la geometria del grezzo
|
||||
if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, 5 * ( dDepth - dElev + dStep) - 50 * EPS_SMALL, vCrvOEF, bChanged)) {
|
||||
|
||||
vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ;
|
||||
// la superificie potrebbe non essere valida ( ad esempio 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 ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, const double& dRawSecLen,
|
||||
@@ -9380,10 +9334,10 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, const doubl
|
||||
return false ;
|
||||
if ( pSrf->GetChunkCount() == 0 || ! pSrf->IsValid())
|
||||
return true ;
|
||||
//PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ;
|
||||
//pSrf_toDraw->Translate( vtTrasl) ;
|
||||
//int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( a, AQUA) ;
|
||||
PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ;
|
||||
pSrf_toDraw->Translate( vtTrasl) ;
|
||||
int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( a, AQUA) ;
|
||||
}
|
||||
// 2) PROIEZIONE CON GREZZO
|
||||
if ( m_bProjectRaw) {
|
||||
@@ -9392,10 +9346,10 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, const doubl
|
||||
return false ;
|
||||
if ( pSrf->GetChunkCount() == 0 || ! pSrf->IsValid())
|
||||
return true ;
|
||||
//PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ;
|
||||
//pSrf_toDraw->Translate( vtTrasl) ;
|
||||
//int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( b, BLUE) ;
|
||||
PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ;
|
||||
pSrf_toDraw->Translate( vtTrasl) ;
|
||||
int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( b, BLUE) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10346,8 +10300,8 @@ Pocketing::GetProjStmBoxOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh*
|
||||
if( IsNull( pSfrProj))
|
||||
return false ;
|
||||
|
||||
int g = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStr_real->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( g, GREEN) ;
|
||||
//int g = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStr_real->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( g, GREEN) ;
|
||||
|
||||
// Proietto ora le curve, delle facce della superificie ottenuta, sul piano della svuotatura
|
||||
for ( int f = 0 ; f < pStr_real->GetFacetCount() ; ++ f) {
|
||||
@@ -10404,6 +10358,10 @@ Pocketing::GetProjStmBoxOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh*
|
||||
// restituisco la FlatRegion della proiezione del grezzo
|
||||
pSfrRawBoxProj->Clear() ;
|
||||
pSfrRawBoxProj->CopyFrom( pSfrProj) ;
|
||||
|
||||
//int g = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrRawBoxProj->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( g, GREEN) ;
|
||||
|
||||
return pSfrRawBoxProj->Invert() && pSfrRawBoxProj->IsValid() && pSfrRawBoxProj->GetChunkCount() > 0 ;
|
||||
|
||||
}
|
||||
@@ -10474,149 +10432,123 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl,
|
||||
Vector3d vtExtr_ ; pSrf->GetLoop( 0, 0)->GetExtrusion( vtExtr_) ;
|
||||
vtExtr_ *= dRawSecLen ;
|
||||
|
||||
// Recupero tutte le curve della Falt Region di proiezione
|
||||
CICURVEPVECTOR vCC ;
|
||||
for ( int c_proj = 0 ; c_proj < pSrfOnPlPlus->GetChunkCount() ; ++ c_proj)
|
||||
for ( int l_proj = 0 ; l_proj < pSrfOnPlPlus->GetLoopCount( c_proj) ; ++ l_proj)
|
||||
vCC.emplace_back( pSrfOnPlPlus->GetLoop( c_proj, l_proj)) ;
|
||||
|
||||
// Estrudo e traslo leggermente la Trimesh per evitare sovrapposizioni tra superifici piane
|
||||
PtrOwner<ISurfTriMesh> pStmExtrusionProj_Chunkcc( GetSurfTriMeshByRegionExtrusion( vCC, 1.5 * vtExtr_)) ;
|
||||
Vector3d vtTr_ = vtExtr_ ; vtTr_.Normalize() ; vtTr_ *= 1500 * EPS_SMALL ;
|
||||
pStmExtrusionProj_Chunkcc->Translate( - vtTr_) ;
|
||||
if ( ! pStmExtrusionProj_Chunkcc->IsValid() || pStmExtrusionProj_Chunkcc->GetTriangleCount() == 0)
|
||||
return true ;
|
||||
|
||||
// Modifico la curva esterna, estendola presso i lati aperti
|
||||
for ( int c = 0 ; c < pSrf_clone->GetChunkCount() ; ++ c) {
|
||||
|
||||
// Controllo se per questo chunk serve proiettare
|
||||
if ( vbSkip[c])
|
||||
continue ;
|
||||
|
||||
// Curva esterna della regione da svuotare
|
||||
PtrOwner<ICurveComposite> pCrvExtPock_Chunk_c( GetCurveComposite( pSrf_clone->GetLoop( c, 0))) ;
|
||||
if ( IsNull( pCrvExtPock_Chunk_c) ||
|
||||
! pCrvExtPock_Chunk_c->IsValid() ||
|
||||
pCrvExtPock_Chunk_c->GetCurveCount() == 0)
|
||||
return false ;
|
||||
pCrvExtPock_Chunk_c->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ;
|
||||
//pCrvExtPock_Chunk_c->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ;
|
||||
//m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCrvExtPock_Chunk_c->Clone()) ;
|
||||
|
||||
// Creo un vettore con eventuali isole
|
||||
ICRVCOMPOPOVECTOR vCrvIsl ;
|
||||
for ( int l = 1 ; l < pSrf_clone->GetLoopCount( c) ; ++ l)
|
||||
vCrvIsl.emplace_back( GetCurveComposite( pSrf_clone->GetLoop( c, l))) ;
|
||||
|
||||
// Ricavo dentro quale chunk della proizione sono
|
||||
int nChunk = -1 ;
|
||||
for ( int cc = 0 ; cc < pSrfOnPlPlus->GetChunkCount() ; ++ cc) {
|
||||
CRVCVECTOR ccClass ;
|
||||
bool bFound = true ;
|
||||
PtrOwner<ISurfFlatRegion> pProjChunk_cc( pSrfOnPlPlus->CloneChunk( cc)) ;
|
||||
if ( IsNull( pProjChunk_cc) || ! pProjChunk_cc->IsValid())
|
||||
// Clono la mia curva esterna originale
|
||||
PtrOwner<ICurveComposite> pCrvExtPock_Chunk_c_clone( CloneCurveComposite( pCrvExtPock_Chunk_c)) ;
|
||||
// Estendo i lati aperti della quantità decisa... ( estensione solo da lati aperti interni alla proeizione)
|
||||
if ( AdjustContourWithOpenEdges( pCrvExtPock_Chunk_c, vCrvIsl, m_dMaxLenRawProj, 0.0, 0.0, V_NULL,
|
||||
pStmExtrusionProj_Chunkcc, true)) {
|
||||
//int y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExtPock_Chunk_c->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( y, YELLOW) ;
|
||||
|
||||
// Creo la Flat region associata a questa curva
|
||||
PtrOwner<ISurfFlatRegion> pSrf_byOE( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_byOE))
|
||||
return false ;
|
||||
pProjChunk_cc->GetCurveClassification( *pCrvExtPock_Chunk_c, EPS_SMALL, ccClass) ;
|
||||
for ( int j = 0 ; j < ( int)ccClass.size() ; ++ j) {
|
||||
if ( ccClass[j].nClass == CRVC_OUT) {
|
||||
bFound = false ;
|
||||
break ;
|
||||
}
|
||||
pSrf_byOE->AddExtLoop( pCrvExtPock_Chunk_c->Clone()) ;
|
||||
// Tengo solo le parti nuove all'interno della proizione originaria
|
||||
|
||||
//int PU = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_byOE->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( PU, PURPLE) ;
|
||||
//int AC = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrfOnPlPlus->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( AC, AQUA) ;
|
||||
|
||||
// controllo che le normali siano parallele
|
||||
if ( AreOppositeVectorApprox( pSrf_byOE->GetNormVersor(), pSrfOnPlPlus->GetNormVersor()))
|
||||
pSrfOnPlPlus->Invert() ;
|
||||
|
||||
pSrf_byOE->Intersect( *pSrfOnPlPlus) ;
|
||||
if ( IsNull( pSrf_byOE) || ! pSrf_byOE->IsValid() || pSrf_byOE->GetChunkCount() == 0) {
|
||||
vbSkip[c] = true ;
|
||||
continue ;
|
||||
}
|
||||
// Se il chunk c-esimo della svuotatura è contenuto nel chunk cc-esimo della superificie da svuotare
|
||||
if ( bFound) {
|
||||
PtrOwner<ICurveComposite> pCrvExtProj_Chunk_cc( GetCurveComposite( pSrfOnPlPlus->GetLoop( cc, 0))) ;
|
||||
if ( IsNull( pCrvExtProj_Chunk_cc) || ! pCrvExtProj_Chunk_cc->IsValid())
|
||||
return false ;
|
||||
CICURVEPVECTOR vCC ;
|
||||
vCC.emplace_back( pCrvExtProj_Chunk_cc) ;
|
||||
// Estrudo e traslo leggermente la Trimesh per evitare sovrapposizioni tra superifici piane
|
||||
PtrOwner<ISurfTriMesh> pStmExtrusionProj_Chunkcc( GetSurfTriMeshByRegionExtrusion( vCC, 1.5 * vtExtr_)) ;
|
||||
Vector3d vtTr_ = vtExtr_ ; vtTr_.Normalize() ; vtTr_ *= 5000 * EPS_SMALL ;
|
||||
pStmExtrusionProj_Chunkcc->Translate( - vtTr_) ;
|
||||
if ( pStmExtrusionProj_Chunkcc->IsValid() && pStmExtrusionProj_Chunkcc->GetTriangleCount() > 0) {
|
||||
PtrOwner<ICurveComposite> pCrvExtPock_Chunk_c_clone( CloneCurveComposite( pCrvExtPock_Chunk_c)) ;
|
||||
// Estendo i lati aperti della quantità decisa...
|
||||
if ( AdjustContourWithOpenEdges( pCrvExtPock_Chunk_c, vCrvIsl, m_dMaxLenRawProj, 0.0, 0.0, V_NULL,
|
||||
pStmExtrusionProj_Chunkcc, true)) {
|
||||
// Recupero la curva di bordo della nuova superificie
|
||||
PtrOwner<ICurveComposite> pCrv_Final_Chunk_cc( GetCurveComposite( pSrf_byOE->GetLoop( 0, 0))) ;
|
||||
if ( IsNull( pCrv_Final_Chunk_cc))
|
||||
return false ;
|
||||
//int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrv_Final_Chunk_cc->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( a, ORANGE) ;
|
||||
// Recupero le temp prop con overlap della curva originaria
|
||||
// nel caso di nuove curve, queste vengono messe aperte ( così posso pulire le proiezioni negli spigoli)
|
||||
int nStat = - 1 ;
|
||||
for ( int u = 0 ; u < pCrv_Final_Chunk_cc->GetCurveCount() ; ++ u)
|
||||
if ( SetTmpPropByOverlap( pCrv_Final_Chunk_cc, u, pCrvExtPock_Chunk_c, nStat, 5 * EPS_SMALL) && ( nStat == 0 || nStat == 2))
|
||||
pCrv_Final_Chunk_cc->SetCurveTempProp( u, 1, 0) ; // --> Aperta se non fa overlap con l'originale
|
||||
|
||||
// Creo la Flat region associata a questa curva
|
||||
PtrOwner<ISurfFlatRegion> pSrf_byOE( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_byOE))
|
||||
return false ;
|
||||
pSrf_byOE->AddExtLoop( pCrvExtPock_Chunk_c_clone->Clone()) ;
|
||||
// Tengo solo le parti nuove all'interno della proizione originaria
|
||||
pSrf_byOE->Intersect( *pSrfOnPlPlus) ;
|
||||
if ( IsNull( pSrf_byOE) || ! pSrf_byOE->IsValid() || pSrf_byOE->GetChunkCount() == 0) {
|
||||
vbSkip[c] = true ;
|
||||
cc = pSrfOnPlPlus->GetChunkCount() ;
|
||||
continue ;
|
||||
}
|
||||
// Recupero la curva di bordo
|
||||
PtrOwner<ICurveComposite> pCrv_Final_Chunk_cc( GetCurveComposite( pSrf_byOE->GetLoop( 0, 0))) ;
|
||||
|
||||
// Se la curva trovata non fa almeno un overlap con il chunk cc-esimo, allora la scarto
|
||||
// ( vuol dire che la superificie non è allargata a sufficienza per comprendere la proiezione, quindi
|
||||
// non la modifico)
|
||||
bool bSkip = true ;
|
||||
for ( int u = 0 ; u < pCrv_Final_Chunk_cc->GetCurveCount() ; ++ u) {
|
||||
const ICurve* pCrv_u = pCrv_Final_Chunk_cc->GetCurve( u) ;
|
||||
int nStat_ = -1 ;
|
||||
if ( CheckSimpleOverlap( pCrv_u, pCrvExtProj_Chunk_cc, nStat_, 5 * EPS_SMALL) && nStat_ == 1) {
|
||||
bSkip = false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// ---> Se non fa overlap, allora passo al chunk della svuotatura successivo
|
||||
if ( bSkip) {
|
||||
vbSkip[c] = true ;
|
||||
cc = pSrfOnPlPlus->GetChunkCount() ;
|
||||
continue ;
|
||||
}
|
||||
// ---> Se fa overlap, controllo che non sia la stessa superificie originaria ( mediante area)
|
||||
// in questo caso la proizione mi ha lasciato invariata la superificie
|
||||
double dArea_Before = 0 ;
|
||||
double dArea_After = 0 ;
|
||||
if ( pCrvExtPock_Chunk_c_clone->GetAreaXY( dArea_Before) &&
|
||||
pCrvExtPock_Chunk_c->GetAreaXY( dArea_After) &&
|
||||
abs( dArea_Before - dArea_After) < dArea_Before * 0.00125) {
|
||||
vbSkip[c] = true ;
|
||||
cc = pSrfOnPlPlus->GetChunkCount() ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
// Recupero le temp prop con overlap della curva precedente
|
||||
// nel caso di nuove curve, queste vengono messe aperte ( così posso pulire le proiezioni negli spigoli)
|
||||
int nStat = - 1 ;
|
||||
for ( int u = 0 ; u < pCrv_Final_Chunk_cc->GetCurveCount() ; ++ u)
|
||||
if ( SetTmpPropByOverlap( pCrv_Final_Chunk_cc, u, pCrvExtPock_Chunk_c, nStat, 5 * EPS_SMALL) &&
|
||||
( nStat == 0 || nStat == 2))
|
||||
pCrv_Final_Chunk_cc->SetCurveTempProp( u, 1, 0) ; // --> Aperta se non fa overlap con l'originale
|
||||
|
||||
pSrfAfterProj.AddCurve( Release( pCrv_Final_Chunk_cc)) ;
|
||||
for ( int is = 0 ; is < ( int)vCrvIsl.size() ; ++ is)
|
||||
pSrfAfterProj.AddCurve( Release( vCrvIsl[is])) ;
|
||||
}
|
||||
else
|
||||
vbSkip[c] = true ;
|
||||
}
|
||||
else
|
||||
vbSkip[c] = true ;
|
||||
break ; // stoppo la ricerca del chunk della superificie, l'ho trovato.
|
||||
}
|
||||
//int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrv_Final_Chunk_cc->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( r, RED) ;
|
||||
pSrfAfterProj.AddCurve( Release( pCrv_Final_Chunk_cc)) ;
|
||||
for ( int is = 0 ; is < ( int)vCrvIsl.size() ; ++ is)
|
||||
pSrfAfterProj.AddCurve( Release( vCrvIsl[is])) ;
|
||||
}
|
||||
else
|
||||
vbSkip[c] = true ;
|
||||
}
|
||||
|
||||
// Superificie finale
|
||||
PtrOwner<ISurfFlatRegion> pSrfF( CreateSurfFlatRegion()) ;
|
||||
pSrfF.Set( pSrfAfterProj.GetSurf()) ;
|
||||
// Superificie formata da tutti i chunk che che NON SONO stati saltati ( vbSkip[c] = F)
|
||||
PtrOwner<ISurfFlatRegion> pSrf_NoSkip( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_NoSkip))
|
||||
return false ;
|
||||
pSrf_NoSkip.Set( pSrfAfterProj.GetSurf()) ;
|
||||
|
||||
PtrOwner<ISurfFlatRegion> pSrf_Union_Skipped( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_Union_Skipped))
|
||||
// Superificie formata da tutti i chunk che SONO stati saltati ( vbSkip[c] = T)
|
||||
PtrOwner<ISurfFlatRegion> pSrf_Skip( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_Skip))
|
||||
return false ;
|
||||
for ( int i = 0 ; i < ( int)vbSkip.size() ; ++ i) {
|
||||
if ( vbSkip[i]) {
|
||||
if ( pSrf_Union_Skipped->GetChunkCount() == 0)
|
||||
pSrf_Union_Skipped.Set( pSrf_clone->CloneChunk( i)) ;
|
||||
if ( pSrf_Skip->GetChunkCount() == 0)
|
||||
pSrf_Skip.Set( pSrf_clone->CloneChunk( i)) ;
|
||||
else
|
||||
pSrf_Union_Skipped->Add( *pSrf_clone->CloneChunk( i)) ;
|
||||
pSrf_Skip->Add( *pSrf_clone->CloneChunk( i)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Superificie finale, data dall'unione di tutti i chunk
|
||||
PtrOwner<ISurfFlatRegion> pSrf_Final( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_Final))
|
||||
return false ;
|
||||
if ( ! IsNull( pSrf_Union_Skipped) && pSrf_Union_Skipped->IsValid() && pSrf_Union_Skipped->GetChunkCount() > 0)
|
||||
pSrf_Final.Set( Release( pSrf_Union_Skipped)) ;
|
||||
if ( ! IsNull( pSrf_Final) && pSrf_Final->IsValid() && pSrf_Final->GetChunkCount() > 0 &&
|
||||
! IsNull( pSrfF) && pSrfF->IsValid() && pSrfF->GetChunkCount() > 0)
|
||||
pSrf_Final->Add( *pSrfF) ;
|
||||
|
||||
if ( ! IsNull( pSrf_NoSkip) && pSrf_NoSkip->IsValid() && pSrf_NoSkip->GetChunkCount() > 0)
|
||||
pSrf_Final.Set( Release( pSrf_NoSkip)) ;
|
||||
|
||||
if ( ! IsNull( pSrf_Skip) && pSrf_Skip->IsValid() && pSrf_Skip->GetChunkCount() > 0) {
|
||||
if ( IsNull( pSrf_Final) || ! pSrf_Final->IsValid() || pSrf_Final->GetChunkCount() == 0)
|
||||
pSrf_Final.Set( Release( pSrf_Skip)) ;
|
||||
else
|
||||
pSrf_Final->Add( *Release( pSrf_Skip)) ;
|
||||
}
|
||||
|
||||
// controllo validità e nel caso esco senza modificare nulla
|
||||
if ( IsNull( pSrf_Final) || ! pSrf_Final->IsValid() || pSrf_Final->GetChunkCount() == 0)
|
||||
|
||||
@@ -92,6 +92,9 @@ class Pocketing : public Machining
|
||||
int nFacet, ISurfFlatRegion* pSfrProj) ;
|
||||
bool GetSurfByAdj( const ISurfTriMesh* pSrfOri, INTVECTOR& vBannedId, int idCurrFace) ;
|
||||
bool GetNewBorderByProjectionOfFaces( ISurfFlatRegion* pSrfpCompo, ICurveComposite* pCrvProj, const Point3d ptStart) ;
|
||||
bool GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, std::vector<ICRVCOMPOPOVECTOR>& vCrvOEWithFlags,
|
||||
BOOLVECTOR vbChangedPrec, const ISurfFlatRegion* pSrfChunk, const int& nStep, const Vector3d vtTool, const double& dElev,
|
||||
const double& dDepth, const double& dStep) ;
|
||||
bool AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, const double& dRawSecLen,
|
||||
ICRVCOMPOPOVECTOR& vCrvOEFlags, bool& bChanged, double dAreaToll = 500 * EPS_SMALL) ;
|
||||
bool GetStmRawPart( int nId, ISurfTriMesh* pSrfTMRaw, Frame3d frPocket = GLOB_FRM) ;
|
||||
|
||||
Reference in New Issue
Block a user