EgtMachKernel :
- migliorie gestioni lati aperti in adattamento a TriMesh - inizio risoluzione problemi per lati aperti dentro al grezzo.
This commit is contained in:
+254
-108
@@ -2319,7 +2319,6 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
}
|
||||
|
||||
// ---------------------------- Disegno le curve a ZigZag (vpCrv) -------------------------
|
||||
double dCurrAffondamento = dDepth - dElev - vVtTrasl[j-1].Len() ;
|
||||
bool bStart = true ;
|
||||
// ciclo sui percorsi
|
||||
int nPath = int( vpCrvs.size());
|
||||
@@ -2349,7 +2348,7 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
|
||||
dStElev = dCurrAffondamento /*j * dStep*/ ;
|
||||
dStElev = j * dStep ;
|
||||
bool bAhUnderRaw = m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab &&
|
||||
GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
@@ -2357,7 +2356,7 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
if ( bAhUnderRaw || bUhAboveRaw)
|
||||
dStElev = max( dStElev, dCurrAffondamento) ;
|
||||
dStElev = max( dStElev, j * dStep) ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se ottimizzata e attacco nel grezzo
|
||||
if ( bOptimizedZigZag && !( bOutRawLeadIn || m_bOpenOutRaw)) {
|
||||
@@ -2394,7 +2393,7 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
}
|
||||
|
||||
}
|
||||
dStElev = max( dStElev, dCurrAffondamento) ;
|
||||
dStElev = max( dStElev, j * dStep) ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
//GetCurrPos( ptP1) ; // <----- ????
|
||||
@@ -2447,8 +2446,8 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c
|
||||
// aggiungo uscita
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev))
|
||||
dEndElev = dCurrAffondamento ;
|
||||
dEndElev = max( dEndElev, dCurrAffondamento) ;
|
||||
dEndElev = j * dStep ;
|
||||
dEndElev = max( dEndElev, j * dStep) ;
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, nullptr, bSplitArcs, true, ptP1, dEndElev, false)) {
|
||||
@@ -4996,8 +4995,6 @@ Pocketing::AddSpiralOut( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool
|
||||
int nMaxInd = pMCrv->GetCurveCount() - 1 ;
|
||||
int nMaxRInd = pRCrv->GetCurveCount() - 1 ;
|
||||
|
||||
double dCurrAffondamento = dDepth - dElev - vVtTrasl[j-1].Len() ;
|
||||
|
||||
// ciclo sugli step
|
||||
if ( bOptimizedTrap && nOutsideRaw != 1 && j > 1)
|
||||
pMCrv->Invert() ;
|
||||
@@ -5036,7 +5033,7 @@ Pocketing::AddSpiralOut( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool
|
||||
GetUhPointAboveRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(),
|
||||
m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ;
|
||||
//if ( bAhUnderRaw || bUhAboveRaw || ( bOutStart && !m_bAboveHead))
|
||||
dStElev = max( dStElev, dCurrAffondamento) ;
|
||||
dStElev = max( dStElev, j * dStep) ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
|
||||
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
|
||||
@@ -5129,7 +5126,7 @@ Pocketing::AddSpiralOut( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptQ ;
|
||||
double dEndElev = dCurrAffondamento ;
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, pRCrv, bSplitArcs, false, ptQ, dEndElev, false)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ;
|
||||
@@ -9392,8 +9389,12 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
bool bIsChanged ;
|
||||
if ( m_bIntersRaw) {
|
||||
PtrOwner<ISurfFlatRegion> pSrfInc_Copy( CloneSurfFlatRegion( pSfrInc)) ;
|
||||
IntersSurfWithRaw( pSfrInc, pStmRaw, 1.01 * vtTrasl, bIsChanged, 1500 * EPS_SMALL, bInVsOut, false, false) ;
|
||||
if ( IsNull( pSfrInc) || ! pSfrInc->IsValid() || pSfrInc->GetChunkCount() == 0)
|
||||
int nChunkBef = pSfrInc->GetChunkCount() ;
|
||||
if ( ! IntersSurfWithRaw( pSfrInc, pStmRaw, 1.01 * vtTrasl, bIsChanged, 1500 * EPS_SMALL,
|
||||
bInVsOut, false, false))
|
||||
return false ;
|
||||
if ( IsNull( pSfrInc) || ! pSfrInc->IsValid() || pSfrInc->GetChunkCount() == 0 ||
|
||||
( nChunkBef < pSfrInc->GetChunkCount()))
|
||||
pSfrInc.Set( pSrfInc_Copy) ;
|
||||
}
|
||||
}
|
||||
@@ -9428,9 +9429,6 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons
|
||||
for ( int u = 0 ; u < pNewCrv->GetCurveCount() ; ++ u)
|
||||
pNewCrv->SetCurveTempProp( u, 1, 0) ;
|
||||
|
||||
int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( r, RED) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -9661,13 +9659,11 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
if ( IsNull( pCrvBorder) || ! pCrvBorder->IsValid())
|
||||
return false ;
|
||||
|
||||
// recupero la superificie Trimesh ( se selezionata) ed eventualmente la FlatRegion con le proiezioni delle facce
|
||||
// recupero la superificie Trimesh ( se selezionata) ed eventualmente la FlatRegion
|
||||
bool bIsStm = false ;
|
||||
PtrOwner<ISurfTriMesh> pStmORIG( CreateSurfTriMesh()) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrProjDanger( CreateSurfFlatRegion()) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrExtended( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pStmORIG) ||
|
||||
IsNull( pSfrProjDanger) ||
|
||||
IsNull( pSfrExtended) ||
|
||||
! pStmORIG->AdjustTopology() ||
|
||||
! GetSelectedStm( pCrvBorder, GLOB_FRM, bIsStm, pStmORIG))
|
||||
@@ -9710,7 +9706,7 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
// ED ESTENSIONE PRESSO LATI APERTI
|
||||
for ( int j = 1 ; j <= int( vVtTrasl.size()) ; ++ j) {
|
||||
|
||||
//if ( j != 9)
|
||||
//if ( j != 7)
|
||||
// continue ;
|
||||
|
||||
// vettore traslazione corrente
|
||||
@@ -9760,7 +9756,7 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
return false ;
|
||||
}
|
||||
// ======================================================================================
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -10048,17 +10044,14 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
if ( IsNull( pStmExtended) || ! pStmExtended->IsValid())
|
||||
return false ;
|
||||
|
||||
/*int A = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmExtended->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( A, ORANGE) ;
|
||||
int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmORIG->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( p, PURPLE) ;*/
|
||||
|
||||
// 2) Creazione della FlatRegion di proiezione complessiva delle facce dela TriMesh sopra al piano di svuotatura attuale
|
||||
// 2) Creazione della FlatRegion di proiezione complessiva delle facce dela TriMesh sopra al piano di svuotatura
|
||||
// attuale
|
||||
PtrOwner<ISurfFlatRegion> pSfrProjUP( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrProjUP))
|
||||
return false ;
|
||||
|
||||
// 3) Creazione di un vettore di curve contenente tutte le curve proiettate derivante dalle facce ( serve per le TmpProps)
|
||||
// 3) Creazione di un vettore di curve contenente tutte le curve proiettate derivante dalle facce
|
||||
// ( serve per le TmpProps)
|
||||
ICRVCOMPOPOVECTOR vAllCrv ;
|
||||
pCrvForProps->Translate( vtTrasl) ;
|
||||
vAllCrv.emplace_back( pCrvForProps->Clone()) ; // in posizione 0 ( la più importante)
|
||||
@@ -10073,8 +10066,6 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
// 4) Taglio
|
||||
if ( pStmExtended->CutWithOtherSurf( *pStmORIG, false, true)) {
|
||||
|
||||
//int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmExtended->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( b, BLACK) ;
|
||||
// NB. Se pStmExtended è vuota, allora la TriMesh non arriva fino al bordo del grezzo, quindi non cambio
|
||||
// la geometria di intersezione
|
||||
if ( ! IsNull( pStmExtended) && pStmExtended->GetTriangleCount() == 0)
|
||||
@@ -10087,9 +10078,6 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
|
||||
if ( pStmORIG_forCut->Cut( plProj, true)) {
|
||||
|
||||
//int g = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmORIG_forCut->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( g, GRAY) ;
|
||||
|
||||
// 6) Proeizione della TriMesh tagliata sul piano di svuotatura
|
||||
if ( ! ProjectStmOnPlane( pStmORIG_forCut, plProj, pSfrProjUP))
|
||||
return false ;
|
||||
@@ -10101,9 +10089,6 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
else
|
||||
return false ;
|
||||
|
||||
//int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjUP->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( r, RED) ;
|
||||
|
||||
// --------- sottraggo alla FlatRegion estesa la proeizione complessiva ---------------
|
||||
// 1) trasformo la Trimesh estesa ricavata in FlatRegion
|
||||
PtrOwner<ISurfFlatRegion> pSfrExtended( CreateSurfFlatRegion()) ;
|
||||
@@ -10112,13 +10097,6 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
if ( ! GetSfrByStm( pStmExtended, pSfrExtended, plProj, vtExtr, dThick))
|
||||
return false ;
|
||||
|
||||
//int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjUP->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( b, BLACK) ;
|
||||
//int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExtended->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( p, PURPLE) ;
|
||||
|
||||
// controllo se la FlatRegion estesa fino alla Trimesh non sia più piccola della parte proiettata
|
||||
|
||||
// 2) Sottrazione
|
||||
if ( pSfrProjUP->IsValid() &&
|
||||
! pSfrExtended->Subtract( *pSfrProjUP))
|
||||
@@ -10140,23 +10118,35 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
}
|
||||
// 2.5) se curva esterna, setto le TmpProp mediante Overlaps
|
||||
else {
|
||||
// 2.5.1) apro i lati che fanno overlap con la superficie di pSfrProjUp \ pSfrORIG
|
||||
ICRVCOMPOPOVECTOR vCrvWithTmpProps ;
|
||||
if ( vtTrasl.IsSmall())
|
||||
int a = 9 ;
|
||||
if ( ! ManageTmpPropForAdaptingStm( pSfrProjUP, pSfrORIG, pSrfExtended_cl, vtTrasl, vCrvWithTmpProps))
|
||||
return false ;
|
||||
Vector3d vtN = pSrfExtended_cl->GetNormVersor() ;
|
||||
// 2.5.2) uso il Loop esterno della superficie originale come riferimento
|
||||
if ( ! SetTmpPropWithRawProjectedFaces( pCrvLoop, vAllCrv, vtN))
|
||||
return false ;
|
||||
for ( int i = 0 ; i < ( int)vAllCrv.size() ; ++ i)
|
||||
vCrvWithTmpProps.emplace_back( vAllCrv[i]->Clone()) ;
|
||||
for ( int i = 0 ; i < ( int)vCrvWithTmpProps.size() && ! vtTrasl.IsSmall() ; ++ i) {
|
||||
for ( int u = 0 ; u < pCrvLoop->GetCurveCount() ; ++ u) {
|
||||
int nStat ;
|
||||
if ( ! SetTmpPropByOverlap( pCrvLoop, u, vCrvWithTmpProps[i], nStat, 250 * EPS_SMALL))
|
||||
return false ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// 2.6) inserimento del loop nella regione finale da restituire
|
||||
//for ( int u = 0 ; u < pCrvLoop->GetCurveCount() ; ++ u) {
|
||||
//int nProp0 ; pCrvLoop->GetCurveTempProp( u, nProp0, 0) ;
|
||||
//int aaa = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvLoop->GetCurve( u)->Clone()) ;
|
||||
//m_pGeomDB->SetMaterial( aaa, nProp0 == 0 ? BLUE : RED) ;
|
||||
//}
|
||||
// 2.7) riporto le proprietà
|
||||
// 2.6) riporto le proprietà
|
||||
pCrvLoop->SetTempProp( nTmpProp0, 0) ;
|
||||
pCrvLoop->SetTempProp( nTmpProp1, 1) ;
|
||||
pCrvLoop->SetExtrusion( vtExtr) ;
|
||||
pCrvLoop->SetThickness( dThick) ;
|
||||
|
||||
// 2.8 ) inserimento della curva
|
||||
// 2.8) inserimento della curva
|
||||
sfrBC.AddCurve( Release( pCrvLoop)) ;
|
||||
}
|
||||
}
|
||||
@@ -10166,11 +10156,89 @@ Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const IS
|
||||
if ( IsNull( pSfrFINAL) || ! pSfrFINAL->IsValid())
|
||||
return false ;
|
||||
pNewSrfPock->CopyFrom( pSfrFINAL) ;
|
||||
|
||||
PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pNewSrfPock)) ;
|
||||
int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( a, AQUA) ;
|
||||
for ( int c = 0 ; c < pSrf_toDraw->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSrf_toDraw->GetLoopCount( c) ; ++ l) {
|
||||
const ICurveComposite* pCrvCompo( GetCurveComposite( pSrf_toDraw->GetLoop( c, l))) ;
|
||||
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) {
|
||||
int nProp0 ; pCrvCompo->GetCurveTempProp( u, nProp0, 0) ;
|
||||
int nProp1 ; pCrvCompo->GetCurveTempProp( u, nProp1, 1) ;
|
||||
int aaa = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvCompo->GetCurve( u)->Clone()) ;
|
||||
if ( nProp1 != -99)
|
||||
m_pGeomDB->SetMaterial( aaa, nProp0 == 0 ? BLUE : RED) ;
|
||||
else
|
||||
m_pGeomDB->SetMaterial( aaa, Color( 1.0, 0.5, 0.0)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pNewSrfPock->Translate( -vtTrasl) ;
|
||||
return pNewSrfPock != nullptr && pNewSrfPock->IsValid() && pNewSrfPock->GetChunkCount() > 0 ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::ManageTmpPropForAdaptingStm( const ISurfFlatRegion* pSfrProjUP, const ISurfFlatRegion* pSfrORIG,
|
||||
const ISurfFlatRegion* pSrfExtended, const Vector3d& vtTrasl, ICRVCOMPOPOVECTOR& vCrvWithTmpProps)
|
||||
{
|
||||
|
||||
ICRVCOMPOPOVECTOR vCrvLoops ;
|
||||
PtrOwner<ISurfFlatRegion> pSrfCheck( CloneSurfFlatRegion( pSrfExtended)) ;
|
||||
if ( ! IsNull( pSrfCheck) && pSrfCheck->IsValid())
|
||||
if ( pSrfCheck->Subtract( *pSfrORIG) && ! IsNull( pSrfCheck) && pSrfCheck->IsValid())
|
||||
for ( int c = 0 ; c < pSrfCheck->GetChunkCount() ; ++ c)
|
||||
for ( int l = 0 ; l < pSrfCheck->GetLoopCount( c) ; ++ l)
|
||||
vCrvLoops.emplace_back( ConvertCurveToComposite( pSrfCheck->GetLoop( c, l))) ;
|
||||
|
||||
for ( int i = 0 ; i < vCrvLoops.size() ; ++ i)
|
||||
m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vCrvLoops[i]->Clone()) ;
|
||||
|
||||
PtrOwner<ISurfFlatRegion> pSfrForMyCrv( CloneSurfFlatRegion( pSrfExtended)) ;
|
||||
if ( ! IsNull( pSfrForMyCrv) && pSfrForMyCrv->IsValid()) {
|
||||
if ( pSfrForMyCrv->Subtract( *pSfrORIG) && ! IsNull( pSfrForMyCrv) && pSfrForMyCrv->IsValid()) {
|
||||
if ( pSfrForMyCrv->IsValid()) {
|
||||
for ( int cc = 0 ; cc < pSfrForMyCrv->GetChunkCount() ; ++ cc) {
|
||||
for ( int ll = 0 ; ll < pSfrForMyCrv->GetLoopCount( cc) ; ++ ll) {
|
||||
PtrOwner<ICurveComposite> pMyCrv( ConvertCurveToComposite( pSfrForMyCrv->GetLoop( cc, ll))) ;
|
||||
if ( IsNull( pMyCrv) || ! pMyCrv->IsValid())
|
||||
return false ;
|
||||
|
||||
for ( int u = 0 ; u < pMyCrv->GetCurveCount() ; ++ u) {
|
||||
PtrOwner<ICurve> pCrv( pMyCrv->GetCurve( u)->Clone()) ;
|
||||
if ( IsNull( pCrv) || ! pCrv->IsValid())
|
||||
return false ;
|
||||
bool bIsOpen = false ;
|
||||
for ( int i = 0 ; i < ( int)vCrvLoops.size() && ! bIsOpen ; ++ i) {
|
||||
int nStat = 0 ;
|
||||
if ( CheckSimpleOverlap( pCrv, vCrvLoops[i], nStat, 250 * EPS_SMALL) && nStat == 1)
|
||||
bIsOpen = true ;
|
||||
}
|
||||
pMyCrv->SetCurveTempProp( u, bIsOpen ? 1 : 0, 0) ;
|
||||
}
|
||||
|
||||
for ( int u = 0 ; u < pMyCrv->GetCurveCount() ; ++ u) {
|
||||
int TP = 0 ; pMyCrv->GetCurveTempProp( u, TP, 0) ;
|
||||
int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pMyCrv->GetCurve( u)->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( a, TP == 0 ? BLACK : WHITE) ;
|
||||
}
|
||||
vCrvWithTmpProps.emplace_back( Release( pMyCrv)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::ProjectStmOnPlane( const ISurfTriMesh* pStmAbove, const Plane3d plPock, ISurfFlatRegion* pSfrProj)
|
||||
@@ -10397,6 +10465,7 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMes
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
// 3) ADATTAMENTO A GEOMETRIA FINALE
|
||||
if ( m_bHasShape && ( pStmShape != nullptr && pStmShape->IsValid() && pStmShape->GetTriangleCount() > 0)) {
|
||||
if ( ! SubtractFinalShape( pSrf, vtTrasl, pStmShape))
|
||||
@@ -11130,7 +11199,7 @@ Pocketing::IntersSurfWithRaw( ISurfFlatRegion* pSfrPock, const ISurfTriMesh* pSt
|
||||
pStm.Set( pStmCopy) ;
|
||||
// nel caso il taglio non sia riuscito, allungo leggermente il vettore di traslazione e riprovo
|
||||
if ( ! pStm->Translate(( 1 + 20 * EPS_SMALL) * vtTrasl) ||
|
||||
! pStm->CutWithOtherSurf( *pStmRaw, bInVsOut, true))
|
||||
! pStm->CutWithOtherSurf( *pStmRaw, bInVsOut, true))
|
||||
return true ; // nel caso non riesca ancora, lascio la superificie da svuotare inviariata...
|
||||
}
|
||||
|
||||
@@ -11180,7 +11249,7 @@ Pocketing::IntersSurfWithRaw( ISurfFlatRegion* pSfrPock, const ISurfTriMesh* pSt
|
||||
if ( ! frPock.IsValid())
|
||||
return false ;
|
||||
pCrv->ToLoc( frPock) ;
|
||||
pCrv->ApproxWithArcsEx( 0.5 , ANG_TOL_STD_DEG, LIN_FEA_STD, PA) ; // 5 EPS_SMALL
|
||||
pCrv->ApproxWithArcsEx( 500 * EPS_SMALL , ANG_TOL_STD_DEG, LIN_FEA_STD, PA) ; // 5 EPS_SMALL
|
||||
pCrv->Clear() ;
|
||||
pCrv->FromPolyArc( PA) ;
|
||||
pCrv->ToGlob( frPock) ;
|
||||
@@ -11194,6 +11263,7 @@ Pocketing::IntersSurfWithRaw( ISurfFlatRegion* pSfrPock, const ISurfTriMesh* pSt
|
||||
if ( IsNull( pCrv_c) || ! pCrv_c->IsValid())
|
||||
return false ;
|
||||
PtrOwner<ICurve> pCrv_proj( ProjectCurveOnPlane( *pCrv_c, plPock)) ;
|
||||
|
||||
SrfChunkDef.AddCurve( Release( pCrv_proj)) ; // aggiungo le curve proiettate
|
||||
}
|
||||
|
||||
@@ -11854,50 +11924,6 @@ Pocketing::GetProjStmOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh* pSt
|
||||
pStmRaw == nullptr || ! pStmRaw->IsValid() || pStmRaw->GetTriangleCount() == 0)
|
||||
return false ;
|
||||
|
||||
// ---------- CREAZIONE DI UN VETTORE CONTENENTI TUTTI I TRATTI APERTI --------------------
|
||||
ICRVCOMPOPOVECTOR vCrvOpen ;
|
||||
ICRVCOMPOPOVECTOR vCrvNULL ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo( GetCurveComposite( pSfr->GetLoop( 0, 0))) ;
|
||||
// controllo se la curva ha tutti i lati aperti
|
||||
bool bIsAllOpen = true ;
|
||||
int nCurrTempProp_ ;
|
||||
for ( int u = 0 ; u < pCrvCompo->GetCurveCount() && bIsAllOpen ; ++ u) {
|
||||
pCrvCompo->GetCurveTempProp( u, nCurrTempProp_, 0) ;
|
||||
bIsAllOpen = nCurrTempProp_ == 1 ;
|
||||
}
|
||||
if ( bIsAllOpen)
|
||||
// se tutti lati aperti...
|
||||
vCrvOpen.emplace_back( pCrvCompo->Clone()) ;
|
||||
else {
|
||||
// ... altrimenti sposto l'inizio a metà del tratto più lungo
|
||||
AdjustContourStart( pCrvCompo, vCrvNULL) ;
|
||||
// estraggo parti con proprietà uniforme in un vettore
|
||||
int nCurrTempProp ;
|
||||
int nParStart = 0 ;
|
||||
for ( int i = 0 ; i < pCrvCompo->GetCurveCount() ; ++ i) {
|
||||
int nTempProp ;
|
||||
pCrvCompo->GetCurveTempProp( i, nTempProp) ;
|
||||
if ( i == 0) {
|
||||
nCurrTempProp = nTempProp ;
|
||||
nParStart = i ;
|
||||
}
|
||||
else if ( nCurrTempProp != nTempProp) {
|
||||
PtrOwner<ICurve> pCrv( pCrvCompo->CopyParamRange( nParStart, i)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
pCrv->SetTempProp( nCurrTempProp) ;
|
||||
PtrOwner<ICurveComposite> pCrvSameTmpProp( CreateCurveComposite()) ;
|
||||
pCrvSameTmpProp->AddCurve( Release( pCrv)) ;
|
||||
if ( nCurrTempProp == 1) {
|
||||
pCrvSameTmpProp->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL) ;
|
||||
vCrvOpen.emplace_back( Release( pCrvSameTmpProp)) ; // se aperta
|
||||
}
|
||||
nCurrTempProp = nTempProp ;
|
||||
nParStart = i ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copio la superficie in globale
|
||||
PtrOwner<ISurfFlatRegion> pSfrPock( CloneSurfFlatRegion( pSfr)) ;
|
||||
if ( IsNull( pSfrPock))
|
||||
@@ -12035,7 +12061,6 @@ Pocketing::GetProjStmOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh* pSt
|
||||
if ( IsNull( pSrf_Proj_Ext))
|
||||
return false ;
|
||||
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStr_real->Clone()) ;
|
||||
if ( ! ProjectStmOnPlane( pStr_real, plProj, pSrf_Proj_Ext))
|
||||
return false ;
|
||||
|
||||
@@ -12059,7 +12084,6 @@ Pocketing::GetProjStmOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh* pSt
|
||||
if ( IsNull( pSrf_Proj) || ! pSrf_Proj->IsValid())
|
||||
return false ;
|
||||
pSrf_Proj->Add( *pSfr) ;
|
||||
//pSrf_Proj->Add( *pSfr) ;
|
||||
|
||||
// controllo i loop della superificie creata ------------------------
|
||||
SurfFlatRegionByContours SrfByC ;
|
||||
@@ -12132,7 +12156,7 @@ Pocketing::GetProjStmOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh* pSt
|
||||
// Imposto le temp prop
|
||||
if ( pCrvCompo_NewExt->IsValid()) {
|
||||
if ( ! SetTmpPropWithRawProjectedFaces( pCrvCompo_NewExt, vCrvExtProj, pSfr->GetNormVersor()) ||
|
||||
! CheckSmallPartsForOpenEdge( pCrvCompo))
|
||||
! CheckSmallPartsForOpenEdge( pCrvCompo_NewExt))
|
||||
return false ;
|
||||
// creo la superificie finale
|
||||
PtrOwner<ISurfFlatRegion> pSrfProj_Final( CreateSurfFlatRegion()) ;
|
||||
@@ -12153,9 +12177,6 @@ Pocketing::GetProjStmOnSfr( const ISurfFlatRegion* pSfr, const ISurfTriMesh* pSt
|
||||
}
|
||||
}
|
||||
|
||||
if ( nStep == 2)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
@@ -12322,12 +12343,19 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl,
|
||||
for ( int l = 1 ; l < pSrf_clone->GetLoopCount( c) ; ++ l)
|
||||
vCrvIsl.emplace_back( ConvertCurveToComposite( pSrf_clone->GetLoop( c, l))) ;
|
||||
|
||||
// prendo il Loop esterno
|
||||
PtrOwner<ICurveComposite> pCrvExt_Loop( GetCurveComposite( pSrf_clone->GetLoop( c, 0))) ;
|
||||
|
||||
// clono il chunk c-esimo e aggiungo le regioni proiettate
|
||||
// clono il chunk c-esimo
|
||||
PtrOwner<ISurfFlatRegion> pSrf_clone_ChunkC( pSrf_clone->CloneChunk( c)) ;
|
||||
|
||||
// NB. Nella Travi ci possono essere dei lati aperti dovuti all'allineamento di più TriMesh per una
|
||||
// svuotatura lunga in una direzione, questi li considero chiusi per la proeizione...
|
||||
//PtrOwner<ISurfFlatRegion> pSfr_Act( CreateSurfFlatRegion()) ;
|
||||
//if ( IsNull( pSfr_Act))
|
||||
//return false ;
|
||||
//ICRVCOMPOPOVECTOR vCrvOpenToClose ;
|
||||
//if ( ! CloseOpenSidesInsideRawForProjection( pSrf_clone_ChunkC, pStmRaw, pSfr_Act, vCrvOpenToClose))
|
||||
// return false ;
|
||||
//pSrf_clone_ChunkC.Set( Release( pSfr_Act)) ;
|
||||
|
||||
// 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()) ;
|
||||
@@ -12337,7 +12365,7 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl,
|
||||
if ( IsNull( pSrfOnPlPlus) || ! pSrfOnPlPlus->IsValid() || pSrfOnPlPlus->GetChunkCount() == 0)
|
||||
pSrfOnPlPlus.Set( pSrf_clone_ChunkC) ;
|
||||
|
||||
// inseirsco nel vettore
|
||||
// inserisco nel vettore
|
||||
vSfr_gained.emplace_back( pSrfOnPlPlus->Clone()) ;
|
||||
|
||||
// sommo il nuovo chunk ottenuto alla regione finale di proiezione
|
||||
@@ -12437,6 +12465,123 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl,
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CloseOpenSidesInsideRawForProjection( const ISurfFlatRegion* pSfrAct, const ISurfTriMesh* pStmRaw,
|
||||
ISurfFlatRegion* pSfrMod, ICRVCOMPOPOVECTOR& vCrvMod)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pSfrAct == nullptr || ! pSfrAct->IsValid() || pSfrAct->GetChunkCount() == 0)
|
||||
return false ;
|
||||
if ( pStmRaw == nullptr)
|
||||
return true ;
|
||||
else if ( ! pStmRaw->IsValid() || pStmRaw->GetTriangleCount() == 0)
|
||||
return false ;
|
||||
pSfrMod->CopyFrom( pSfrAct) ;
|
||||
|
||||
// ricavo il piano della svuotatura
|
||||
Vector3d vtN = pSfrAct->GetNormVersor() ;
|
||||
Point3d ptC ;
|
||||
if ( ! pSfrAct->GetCentroid( ptC)) {
|
||||
PtrOwner<ICurveComposite> pCrvCompo( ConvertCurveToComposite( pSfrAct->GetLoop( 0, 0))) ;
|
||||
if ( IsNull( pCrvCompo) ||
|
||||
! pCrvCompo->IsValid() ||
|
||||
! pCrvCompo->GetStartPoint( ptC))
|
||||
return false ;
|
||||
}
|
||||
Plane3d plPock ; plPock.Set( ptC, vtN) ;
|
||||
if ( ! plPock.IsValid())
|
||||
return false ;
|
||||
|
||||
// taglio il grezzo e ricavo il controno libero
|
||||
PtrOwner<ISurfTriMesh> pStmRaw_Clone( CloneSurfTriMesh( pStmRaw)) ;
|
||||
if ( IsNull( pStmRaw_Clone) || ! pStmRaw_Clone->IsValid())
|
||||
return false ;
|
||||
if ( ! pStmRaw_Clone->Cut( plPock, true))
|
||||
return false ;
|
||||
if ( IsNull( pStmRaw_Clone) || ! pStmRaw_Clone->IsValid())
|
||||
return true ;
|
||||
|
||||
// creazione FlatRegion
|
||||
PtrOwner<ISurfFlatRegion> pSfrRawCheck( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrRawCheck))
|
||||
return false ;
|
||||
SurfFlatRegionByContours SrfBC ;
|
||||
|
||||
// estraggo i Loop del grezzo tagliato
|
||||
POLYLINEVECTOR vPL ;
|
||||
pStmRaw_Clone->GetLoops( vPL) ;
|
||||
for ( int i = 0 ; i < ( int)vPL.size() ; ++ i) {
|
||||
PtrOwner<ICurveComposite> pCrvLoop( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvLoop))
|
||||
return false ;
|
||||
pCrvLoop->FromPolyLine( vPL[i]) ;
|
||||
if ( pCrvLoop->IsValid())
|
||||
SrfBC.AddCurve( Release( pCrvLoop)) ;
|
||||
}
|
||||
|
||||
// ricavo la FlatRegion per il controllo delle curve
|
||||
pSfrRawCheck.Set( SrfBC.GetSurf()) ;
|
||||
if ( IsNull( pSfrRawCheck) || ! pSfrRawCheck->IsValid())
|
||||
return true ;
|
||||
|
||||
// FlatRegion finale da restituire
|
||||
SurfFlatRegionByContours SfrBC_Final ;
|
||||
|
||||
// per ogni Chunk-c
|
||||
for ( int c = 0 ; c < pSfrAct->GetChunkCount() ; ++ c) {
|
||||
// estraggo il bordo esterno ( controllo solo quello )
|
||||
PtrOwner<ICurveComposite> pCrvExt( ConvertCurveToComposite( pSfrAct->GetLoop( c, 0))) ;
|
||||
if ( IsNull( pCrvExt) || ! pCrvExt->IsValid())
|
||||
return false ;
|
||||
|
||||
// scorro tutte le curve
|
||||
for ( int u = 0 ; u < pCrvExt->GetCurveCount() ; ++ u) {
|
||||
// ricavo la curva u-esima
|
||||
PtrOwner<ICurve> pCrv_u( pCrvExt->GetCurve( u)->Clone()) ;
|
||||
if ( IsNull( pCrv_u) || ! pCrv_u->IsValid())
|
||||
return false ;
|
||||
|
||||
// continuo solo se è aperta
|
||||
if ( pCrv_u->GetTempProp( 0) == 0)
|
||||
continue ;
|
||||
|
||||
// classifico la curva con la FlatRegion ricavata dal grezzo
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( pSfrRawCheck->GetCurveClassification( *pCrv_u, 1500 * EPS_SMALL, ccClass)) {
|
||||
if (( int)ccClass.size() == 1 && ccClass[0].nClass == CRVC_IN) {
|
||||
// se interna, la chiudo e salvo tale curva nel vettore
|
||||
pCrvExt->SetCurveTempProp( u, 0, 0) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompo_u( ConvertCurveToComposite( pCrv_u->Clone())) ;
|
||||
if ( IsNull( pCrvCompo_u) || ! pCrvCompo_u->IsValid())
|
||||
return false ;
|
||||
vCrvMod.emplace_back( Release( pCrvCompo_u)) ; // salvata con TmpProp0 = 1 ( aperta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aggiungo il loopEsterno modificato
|
||||
SfrBC_Final.AddCurve( Release( pCrvExt)) ;
|
||||
|
||||
// aggiungo eventuali isole
|
||||
for ( int l = 1 ; l < pSfrAct->GetLoopCount( c) ; ++ l)
|
||||
SfrBC_Final.AddCurve( pSfrAct->GetLoop( c, l)) ;
|
||||
}
|
||||
|
||||
// se nulla è stato modificato, allora esco
|
||||
if (( int)vCrvMod.size() == 0)
|
||||
return true ;
|
||||
|
||||
// altrimenti, ritorno la superificie con i lati aperti interno al grezzo modificati a chiusi
|
||||
PtrOwner<ISurfFlatRegion> pSfrFinal( SfrBC_Final.GetSurf()) ;
|
||||
if ( ! IsNull( pSfrFinal) && pSfrFinal->IsValid()) {
|
||||
pSfrMod->Clear() ;
|
||||
pSfrMod->CopyFrom( pSfrFinal) ;
|
||||
}
|
||||
|
||||
return pSfrMod != nullptr && pSfrMod->IsValid() && pSfrMod->GetChunkCount() != 0 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::AjustCurveForProjRawOnFace( const ICurveLine* pL1, ICurveLine* pL2, const ICurveComposite* pCrvBorder,
|
||||
@@ -12916,7 +13061,8 @@ Pocketing::CheckSimpleOverlap( const ICurve* pCrv, const ICurveComposite* pCrvOr
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::SetTmpPropByOverlap( ICurveComposite* pCrv_, int nInd, const ICurveComposite* pCrvOri, int& nStat, double dToll)
|
||||
Pocketing::SetTmpPropByOverlap( ICurveComposite* pCrv_, int nInd, const ICurveComposite* pCrvOri, int& nStat,
|
||||
double dToll)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if (( pCrv_ == nullptr || pCrvOri == nullptr || nInd < 0 || nInd > pCrv_->GetCurveCount() || dToll < EPS_SMALL))
|
||||
|
||||
@@ -128,6 +128,11 @@ class Pocketing : public Machining
|
||||
bool ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrals, const ISurfTriMesh* pSrfProjRaw, int nId,
|
||||
const ISurfFlatRegion* pSrfOrig, int nStep, double dStep,
|
||||
double dAreaToll = 500 * EPS_SMALL) ;
|
||||
bool CloseOpenSidesInsideRawForProjection( const ISurfFlatRegion* pSfrAct, const ISurfTriMesh* pStmRaw,
|
||||
ISurfFlatRegion* pSfrMod, ICRVCOMPOPOVECTOR& vCrvMod) ;
|
||||
bool ManageTmpPropForAdaptingStm( const ISurfFlatRegion* pSfrprojUp, const ISurfFlatRegion* pSfrORIG,
|
||||
const ISurfFlatRegion* pSrfExtended, const Vector3d& vtTrasl,
|
||||
ICRVCOMPOPOVECTOR& vCrvWithTmpProps) ;
|
||||
bool SubtractFinalShape( ISurfFlatRegion* pSfrCurr, const Vector3d& vtTrasl, const ISurfTriMesh* pStmShape) ;
|
||||
bool AdjustAngleForProjectedFace( const ISurfFlatRegion* pSrfFaceT, ICurveComposite* pCrvEdgeBorder, double dAngle) ;
|
||||
bool SetOpenOrCloseEdge( ISurfFlatRegion* pSrfTP, const ISurfFlatRegion* pSrfForCrvs, const ISurfFlatRegion* pSrfOrig,
|
||||
|
||||
Reference in New Issue
Block a user