EgtMachKernel :
- semplificazione proiezione grezzo.
This commit is contained in:
+107
-215
@@ -8691,7 +8691,7 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTO
|
||||
Point3d ptS ; pCompo->GetEndPoint( ptS) ;
|
||||
Point3d ptE ; vpCrvs[i+1]->GetStartPoint( ptE) ;
|
||||
PtrOwner<ICurveComposite> pCrvNew( CreateCurveComposite()) ;
|
||||
if ( AdjustPathOutsideRawForOpenEdges( pCompo_clone, vCrvIsl, pHHHH, ptS, ptE, dRad, dDiam,
|
||||
if ( ! bInVsOut && AdjustPathOutsideRawForOpenEdges( pCompo_clone, vCrvIsl, pHHHH, ptS, ptE, dRad, dDiam,
|
||||
pCrvNew, vtTrasl, pStmRaw, bInVsOut)) {
|
||||
vpCrvs[i].Set( Release( pCrvNew)) ;
|
||||
vpCrvs[i]->GetStartPoint( ptStart) ;
|
||||
@@ -8718,8 +8718,8 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, ICRVCOMPOPOVECTO
|
||||
//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) ;
|
||||
@@ -8843,18 +8843,15 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
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) ;
|
||||
@@ -8875,27 +8872,27 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
pCrvOpen_clone->GetParamAtLength( dRad, dUS) ;
|
||||
pCrvOpen_clone->GetParamAtLength( dLen - dRad, dUE) ;
|
||||
pCrvOpen_clone->TrimStartEndAtParam( dUS, dUE) ;
|
||||
int black = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvOpen_clone->Clone()) ; //
|
||||
m_pGeomDB->SetMaterial( black, BLACK) ;
|
||||
bool bOk = true ;
|
||||
// 4) Creo regione squadrata da questa curva
|
||||
PtrOwner<ISurfFlatRegion> pSfrInc( GetSurfFlatRegionFromFatCurve( Release( pCrvOpen_clone), dRad, true, false)) ;
|
||||
if ( IsNull( pSfrInc) || ! pSfrInc->IsValid()) {
|
||||
//return false ;
|
||||
Point3d ptS ; pCrvOpen->GetEndPoint( ptS) ;
|
||||
Point3d ptE ;
|
||||
pCrvOpenOffs->GetEndPoint( ptE) ;
|
||||
PtrOwner<ICurveComposite> pCrv_CompoHelp( CreateCurveComposite()) ;
|
||||
pCrv_CompoHelp->AddCurve( pCrvOpen->Clone()) ;
|
||||
pCrv_CompoHelp->AddLine( ptS) ;
|
||||
pCrv_CompoHelp->AddLine( ptE) ;
|
||||
PtrOwner<ICurveComposite> pCrvOpenOffs_Clone( CloneCurveComposite( pCrvOpenOffs)) ;
|
||||
pCrvOpenOffs_Clone->Invert() ;
|
||||
pCrv_CompoHelp->AddCurve( Release( pCrvOpenOffs_Clone)) ;
|
||||
pCrv_CompoHelp->Close() ;
|
||||
pCrvOpen->GetStartPoint( ptE) ;
|
||||
pCrv_CompoHelp->AddLine( ptE) ;
|
||||
pSfrInc.Set( CreateSurfFlatRegion()) ;
|
||||
pSfrInc->AddExtLoop( Release( pCrv_CompoHelp)) ;
|
||||
if ( IsNull( pSfrInc) || !pSfrInc->IsValid())
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ;
|
||||
bOk = false ;
|
||||
if ( IsNull( pSfrInc) || ! pSfrInc->IsValid())
|
||||
return false ;
|
||||
}
|
||||
//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
|
||||
@@ -8993,21 +8990,32 @@ 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) ;
|
||||
|
||||
if ( ! bOk) {
|
||||
//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
|
||||
if ( pStmRaw != nullptr) {
|
||||
bool bIsChanged ;
|
||||
if ( m_bIntersRaw)
|
||||
IntersSurfWithRaw( pSfrInc, pStmRaw, vtTrasl + Z_AX * 10 * EPS_SMALL, bIsChanged, 1500 * EPS_SMALL, bInVsOut, false) ;
|
||||
IntersSurfWithRaw( pSfrInc, pStmRaw, 1.01 * vtTrasl, bIsChanged, 1500 * EPS_SMALL, bInVsOut, false) ;
|
||||
}
|
||||
|
||||
if ( bInVsOut) {
|
||||
//int P = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRaw->Clone()) ; //
|
||||
//m_pGeomDB->SetMaterial( P, LIME) ;
|
||||
}
|
||||
|
||||
|
||||
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) ;
|
||||
if ( ! bOk) {
|
||||
//int P = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRaw->Clone()) ; //
|
||||
//m_pGeomDB->SetMaterial( P, LIME) ;
|
||||
//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))) ;
|
||||
@@ -9035,7 +9043,7 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
pNewCrv->SetCurveTempProp( u, 1, 0) ;
|
||||
|
||||
//int P = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pNewCrv->Clone()) ; //
|
||||
//m_pGeomDB->SetMaterial( P, PURPLE) ;
|
||||
//m_pGeomDB->SetMaterial( P, LIME) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -9349,10 +9357,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) {
|
||||
@@ -9361,10 +9369,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) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9377,6 +9385,17 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, const doubl
|
||||
if ( ! ModifySurfByOpenEdge( pSrf, vCrvOEFlags, vtTrasl, pStmRaw))
|
||||
return false ;
|
||||
|
||||
for ( int c = 0 ; c < pSrf->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSrf->GetLoopCount( c) ; ++ l) {
|
||||
const ICurveComposite* pCrvCompo( GetCurveComposite( pSrf->GetLoop( c, l))) ;
|
||||
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) {
|
||||
int nProp0 ; pCrvCompo->GetCurveTempProp( u, nProp0, 0) ;
|
||||
int aaa = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvCompo->GetCurve( u)->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( aaa, nProp0 == 0 ? BLUE : RED) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ;
|
||||
//pSrf_toDraw->Translate( vtTrasl) ;
|
||||
//int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
@@ -10328,8 +10347,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) {
|
||||
@@ -10409,8 +10428,8 @@ Pocketing::GetProjStmBoxOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh*
|
||||
pSfr_ff->AddIntLoop( pCrvProjFacef->Clone()) ;
|
||||
|
||||
//if ( IsNull( pSfr_ff) || ! pSfr_ff->IsValid()) {
|
||||
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvProjFacef->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( r, RED) ;
|
||||
//int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvProjFacef->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( r, RED) ;
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -10434,6 +10453,11 @@ Pocketing::GetProjStmBoxOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh*
|
||||
if ( AreOppositeVectorApprox( vtN_check, vtNorm))
|
||||
pSfrProj->Invert() ;
|
||||
|
||||
// estendo la regione iniziale mediante i lati aperti
|
||||
|
||||
// la proiezione che serve è solamente l'intersezione tra la proiezione del grezzo ricavato e la supericie allargata
|
||||
// dai lati aperti
|
||||
|
||||
// restituisco la FlatRegion della proiezione del grezzo
|
||||
pSfrRawBoxProj->Clear() ;
|
||||
pSfrRawBoxProj->CopyFrom( pSfrProj) ;
|
||||
@@ -10441,7 +10465,7 @@ Pocketing::GetProjStmBoxOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh*
|
||||
//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 ;
|
||||
return pSfrRawBoxProj->IsValid() && pSfrRawBoxProj->GetChunkCount() > 0 ;
|
||||
|
||||
}
|
||||
|
||||
@@ -10494,202 +10518,70 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl,
|
||||
// traslo la superificie allo step corrente
|
||||
pSrf_clone->Translate( vtTrasl) ;
|
||||
|
||||
// ricavo la FlatRegion della proiezione di ogni faccia del grezzo tagliato dal
|
||||
// semipiano positivo definito dalla superificie di svuotatura allo step attuale ( vtTrasl)
|
||||
PtrOwner<ISurfFlatRegion> pSrfOnPlPlus( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrfOnPlPlus) || ! GetProjStmBoxOnSfr( pSrf_clone, pStmRaw, pSrfOnPlPlus))
|
||||
return false ;
|
||||
if ( IsNull( pSrfOnPlPlus) || ! pSrfOnPlPlus->IsValid() || pSrfOnPlPlus->GetChunkCount() == 0) {
|
||||
//pSrf->Clear() ; // se non ho grezzo sopra alla superificie, allora non devo svuotare nulla ( non dovrebbe capitare)
|
||||
return true ;
|
||||
}
|
||||
// superificie finale da ottenere
|
||||
SurfFlatRegionByContours pSrf_Help ;
|
||||
|
||||
int r = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pSrfOnPlPlus->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( r, RED) ;
|
||||
|
||||
// Creo la superificie finale da restituire ( come unione di tutti i nuovi chunks)
|
||||
SurfFlatRegionByContours pSrfAfterProj ;
|
||||
|
||||
// Dimensione vettore per estrusione della Trimesh
|
||||
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 ;
|
||||
|
||||
int o = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pStmExtrusionProj_Chunkcc->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( o, ORANGE) ;
|
||||
|
||||
// Modifico la curva esterna, estendola presso i lati aperti
|
||||
// per ogni chunk della superificie originaria da svuotare
|
||||
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) ;
|
||||
//m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCrvExtPock_Chunk_c->Clone()) ;
|
||||
|
||||
// Creo un vettore con eventuali isole
|
||||
// salvo le isole
|
||||
ICRVCOMPOPOVECTOR vCrvIsl ;
|
||||
for ( int l = 1 ; l < pSrf_clone->GetLoopCount( c) ; ++ l)
|
||||
vCrvIsl.emplace_back( GetCurveComposite( pSrf_clone->GetLoop( c, l))) ;
|
||||
|
||||
// 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) ;
|
||||
// prendo il Loop esterno
|
||||
PtrOwner<ICurveComposite> pCrvExt_Loop( GetCurveComposite( pSrf_clone->GetLoop( c, 0))) ;
|
||||
|
||||
// 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()) ;
|
||||
// Tengo solo le parti nuove all'interno della proizione originaria
|
||||
// clono il chunk c-esimo e aggiungo le regioni proiettate
|
||||
PtrOwner<ISurfFlatRegion> pSrf_clone_ChunkC( pSrf_clone->CloneChunk( c)) ;
|
||||
|
||||
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) ;
|
||||
// ricavo la FlatRegion della proiezione di ogni faccia del grezzo tagliato dal
|
||||
// semipiano positivo definito dal chunk c allo step attuale ( vtTrasl)
|
||||
PtrOwner<ISurfFlatRegion> pSrfOnPlPlus( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrfOnPlPlus) || ! GetProjStmBoxOnSfr( pSrf_clone_ChunkC, pStmRaw, pSrfOnPlPlus))
|
||||
return false ;
|
||||
if ( IsNull( pSrfOnPlPlus) || ! pSrfOnPlPlus->IsValid() || pSrfOnPlPlus->GetChunkCount() == 0)
|
||||
continue ;
|
||||
|
||||
// controllo che le normali siano parallele
|
||||
if ( AreOppositeVectorApprox( pSrf_byOE->GetNormVersor(), pSrfOnPlPlus->GetNormVersor()))
|
||||
pSrfOnPlPlus->Invert() ;
|
||||
int aaa = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrfOnPlPlus->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( aaa, RED) ;
|
||||
int aaag = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_clone_ChunkC->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( aaag, GREEN) ;
|
||||
|
||||
pSrf_byOE->Intersect( *pSrfOnPlPlus) ;
|
||||
if ( IsNull( pSrf_byOE) || ! pSrf_byOE->IsValid() || pSrf_byOE->GetChunkCount() == 0) {
|
||||
vbSkip[c] = true ;
|
||||
continue ;
|
||||
}
|
||||
// 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
|
||||
if ( ! pSrf_clone_ChunkC->Add( *Release( pSrfOnPlPlus)))
|
||||
continue ;
|
||||
|
||||
//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])) ;
|
||||
int aaab = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_clone_ChunkC->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( aaab, ORANGE) ;
|
||||
|
||||
// recupero la curva esterna
|
||||
PtrOwner<ICurveComposite> pNewCrvExt( GetCurveComposite( pSrf_clone_ChunkC->GetLoop( 0, 0))) ;
|
||||
int nStat = - 1 ;
|
||||
for ( int u = 0 ; u < pNewCrvExt->GetCurveCount() ; ++ u) {
|
||||
int nStat = -1 ;
|
||||
if ( SetTmpPropByOverlap( pNewCrvExt, u, pCrvExt_Loop, nStat, 5 * EPS_SMALL) &&
|
||||
( nStat == 0 || nStat == 2))
|
||||
pNewCrvExt->SetCurveTempProp( u, 1, 0) ;
|
||||
}
|
||||
else
|
||||
vbSkip[c] = true ;
|
||||
|
||||
// recupero la nuova superificie con la curva esterna modificata e le isole originali
|
||||
pSrf_Help.AddCurve( Release( pNewCrvExt)) ;
|
||||
for ( int i = 0 ; i < ( int)vCrvIsl.size() ; ++ i)
|
||||
pSrf_Help.AddCurve( Release( vCrvIsl[i])) ;
|
||||
}
|
||||
|
||||
// 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()) ;
|
||||
|
||||
// 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_Skip->GetChunkCount() == 0)
|
||||
pSrf_Skip.Set( pSrf_clone->CloneChunk( i)) ;
|
||||
else
|
||||
pSrf_Skip->Add( *pSrf_clone->CloneChunk( i)) ;
|
||||
}
|
||||
PtrOwner<ISurfFlatRegion> pSrf_Final( pSrf_Help.GetSurf()) ;
|
||||
if ( ! IsNull( pSrf_Final) && pSrf_Final->IsValid()) {
|
||||
// Controllo delle aree, se alla fine di tutto sono ancora uguali, allora esco
|
||||
double dArea_orig = 0 ;
|
||||
double dArea_finale = 0 ;
|
||||
if ( pSrf_Final->GetArea( dArea_finale) && pSrf->GetArea( dArea_orig) && abs( dArea_orig - dArea_finale) < dAreaToll)
|
||||
return true ; // Esco, alla fine non ho modificato la superificie originale mediante la proiezione con il grezzo
|
||||
pSrf->Clear() ;
|
||||
pSrf->CopyFrom( Release( pSrf_Final)) ;
|
||||
pSrf->Translate( - vtTrasl) ; // ritraslo la superificie come in origine
|
||||
}
|
||||
|
||||
// Superificie finale, data dall'unione di tutti i chunk
|
||||
PtrOwner<ISurfFlatRegion> pSrf_Final( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrf_Final))
|
||||
return false ;
|
||||
|
||||
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)
|
||||
return true ;
|
||||
|
||||
// reset della superificie clonata
|
||||
pSrf_clone->Clear() ;
|
||||
|
||||
// se la superificie da svuotare viene da una Trimesh, taglio quest'ultima con la Trimesh Originale
|
||||
// ( piccola miglioria)
|
||||
if ( m_pGeomDB->GetGeoType( nId) == SRF_TRIMESH) {
|
||||
|
||||
ICRVCOMPOPOVECTOR vCrvAll ;
|
||||
for ( int c = 0 ; c < ( int)pSrf_Final->GetChunkCount() ; ++ c)
|
||||
vCrvAll.emplace_back( GetCurveComposite( pSrf_Final->GetLoop( c, 0))) ;
|
||||
for ( int c = 0 ; c < ( int)pSrf_Final->GetChunkCount() ; ++ c)
|
||||
for ( int l = 1 ; l < ( int)pSrf_Final->GetLoopCount( c) ; ++ l)
|
||||
vCrvAll.emplace_back( GetCurveComposite( pSrf_Final->GetLoop( c, l))) ;
|
||||
|
||||
PtrOwner<ISurfTriMesh> pStm_orig( CloneSurfTriMesh( m_pGeomDB->GetGeoObj( nId))) ;
|
||||
Frame3d frLoc1 ; m_pGeomDB->GetGlobFrame( nId, frLoc1) ;
|
||||
PtrOwner<ISurfTriMesh> pSrfF_tm( CloneSurfTriMesh( pSrf_Final->GetAuxSurf())) ;
|
||||
|
||||
SurfFlatRegionByContours pSrf_HH ;
|
||||
if ( pSrfF_tm->CutWithOtherSurf( *pStm_orig, false, true)) {
|
||||
if ( pSrfF_tm->GetTriangleCount() != 0) {
|
||||
// Estraggo tutti i loops
|
||||
POLYLINEVECTOR vPl ;
|
||||
pSrfF_tm->GetLoops( vPl) ;
|
||||
for ( int ll = 0 ; ll < ( int)vPl.size() ; ++ ll) {
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
pCrvCompo->FromPolyLine( vPl[ll]) ;
|
||||
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) {
|
||||
for ( int j = 0 ; j < ( int)vCrvAll.size() ; ++ j) {
|
||||
int nStat = -1 ;
|
||||
pCrvCompo->SetCurveTempProp( u, 0, 0) ;
|
||||
if ( SetTmpPropByOverlap( pCrvCompo, u, vCrvAll[j], nStat) && nStat == 1)
|
||||
break ;
|
||||
}
|
||||
}
|
||||
pSrf_HH.AddCurve( Release( pCrvCompo)) ;
|
||||
}
|
||||
pSrf_Final.Set( pSrf_HH.GetSurf()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Controllo delle aree, se alla fine di tutto sono ancora uguali, allora esco
|
||||
double dArea_orig = 0 ;
|
||||
double dArea_finale = 0 ;
|
||||
if ( pSrf_Final->GetArea( dArea_finale) && pSrf->GetArea( dArea_orig) && abs( dArea_orig - dArea_finale) < dAreaToll)
|
||||
return true ; // Esco, alla fine non ho modificato la superificie originale mediante la proiezione con il grezzo
|
||||
|
||||
// altrimenti ...
|
||||
pSrf_Final->Translate( - vtTrasl) ; // ritraslo la superificie come in origine
|
||||
pSrf->CopyFrom( pSrf_Final) ; // copio ed esco
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user