EgtMachKernel :
- migliorie proeiezioni e gesitoni lati aperti.
This commit is contained in:
+285
-175
@@ -9794,6 +9794,7 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
// 1) controllo se ci sono delle facce da proiettare
|
||||
if ( ! ProjectEdgesOfSelectedStm( pSrfChunk_c, pStmORIG, pSfrExtended))
|
||||
return false ;
|
||||
|
||||
// 2) controllo se ci sono degli step extra ( aggiornando il vettore degli step)
|
||||
if ( ! CalcExtraSteps( pSrfChunk_c, pStmORIG, vtTool, dElev, dDepth, nStep, dStep, vVtTrasl))
|
||||
return false ;
|
||||
@@ -9837,12 +9838,31 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
|
||||
// se la geometria iniziale è una TriMesh, allora adatto la FlatRegion della svuotatura...
|
||||
if ( bIsStm) {
|
||||
PtrOwner<ISurfFlatRegion> pSrfNewChunk_c( CreateSurfFlatRegion()) ;
|
||||
if ( ! GetAdaptedSfrByTrimesh( pSfrExtended, pSrfChunk_c, pStmORIG, vtTrasl, pSrfNewChunk_c))
|
||||
return false ;
|
||||
pSrfToPock.Set( Release( pSrfNewChunk_c)) ;
|
||||
if ( ! IsNull( pSfrExtended) && pSfrExtended->IsValid()) {
|
||||
PtrOwner<ISurfFlatRegion> pSrfNewChunk_c( CreateSurfFlatRegion()) ;
|
||||
if ( ! GetAdaptedSfrByTrimesh( pSfrExtended, pSrfChunk_c, pStmORIG, vtTrasl, pSrfNewChunk_c))
|
||||
return false ;
|
||||
pSrfToPock.Set( Release( pSrfNewChunk_c)) ;
|
||||
}
|
||||
}
|
||||
continue ;
|
||||
// 8) DISEGNO =========== TOGLIEREEEEEEEEEEEEEEEEEEEEEEEE ================================
|
||||
// PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pSrfToPock)) ;
|
||||
// pSrf_toDraw->Translate( vtTrasl) ;
|
||||
// int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
// m_pGeomDB->SetMaterial( a, Color( 0.0, 0.0, 1.0, 0.45)) ;
|
||||
// for ( int c = 0 ; c < pSrf_toDraw->GetChunkCount() ; ++ c) {
|
||||
// for ( int l = 0 ; l < pSrf_toDraw->GetLoopCount( c) ; ++ l) {
|
||||
// PtrOwner<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()) ;
|
||||
// m_pGeomDB->SetMaterial( aaa, nProp0 == 0 ? BLUE : RED) ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//// ===================================================================
|
||||
// continue ;
|
||||
|
||||
// adatto la superficie dello step corrente con la geometria del grezzo
|
||||
if ( AdaptSfrWithRaw( pSrfToPock, vtTrasl, pStmRaw, vCrvOEF, bChanged, j, dStep, 500 * EPS_SMALL, m_pStmShape)) {
|
||||
@@ -9871,7 +9891,7 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vector<ICRVCOMPOPOV
|
||||
return false ;
|
||||
}
|
||||
// ======================================================================================
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -10104,9 +10124,10 @@ Pocketing::ProjectEdgesOfSelectedStm( const ISurfFlatRegion* pSrfToPock, const I
|
||||
if ( IsNull( pSfrProj) ||
|
||||
! ProjectStmOnPlane( pStmORIG_noSelFace, plPock, pSfrProj))
|
||||
return false ;
|
||||
if ( ! IsNull( pSfrProj) && pSfrProj->IsValid() && pSfrProj->GetChunkCount() != 0)
|
||||
if ( ! IsNull( pSfrProj) && pSfrProj->IsValid() && pSfrProj->GetChunkCount() != 0) {
|
||||
if ( ! pSrfBorderExt->Add( *pSfrProj))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// d) se valida, restituisco
|
||||
if ( pSrfBorderExt->IsValid())
|
||||
@@ -10120,208 +10141,297 @@ bool
|
||||
Pocketing::GetAdaptedSfrByTrimesh( const ISurfFlatRegion* pSrfExtended, const ISurfFlatRegion* pSfrORIG,
|
||||
const ISurfTriMesh* pStmORIG, const Vector3d& vtTrasl, ISurfFlatRegion* pNewSrfPock)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pSrfExtended == nullptr || ! pSrfExtended->IsValid() || pNewSrfPock == nullptr)
|
||||
// controllo dei parametri
|
||||
if ( pSrfExtended == nullptr || ! pSrfExtended->IsValid() || pNewSrfPock == nullptr)
|
||||
return false ;
|
||||
pNewSrfPock->Clear() ;
|
||||
|
||||
// clono la superficie da svuotare e la porto allo step corrente
|
||||
PtrOwner<ISurfFlatRegion> pSrfExtended_cl( CloneSurfFlatRegion( pSrfExtended)) ;
|
||||
if ( IsNull( pSrfExtended_cl) || ! pSrfExtended_cl->IsValid())
|
||||
return false ;
|
||||
pSrfExtended_cl->Translate( vtTrasl) ;
|
||||
|
||||
// proprietà :
|
||||
PtrOwner<ICurveComposite> pCrvForProps( GetCurveComposite( pSfrORIG->GetLoop( 0, 0))) ;
|
||||
Vector3d vtExtr ; pCrvForProps->GetExtrusion( vtExtr) ;
|
||||
double dThick ; pCrvForProps->GetThickness( dThick) ;
|
||||
int nTmpProp0 = pCrvForProps->GetTempProp( 0) ;
|
||||
int nTmpProp1 = pCrvForProps->GetTempProp( 1) ;
|
||||
|
||||
// 1) Converto la FlatRegion estesa in Trimesh
|
||||
PtrOwner<ISurfTriMesh> pStmExtended( CloneSurfTriMesh( pSrfExtended_cl->GetAuxSurf())) ;
|
||||
if ( IsNull( pStmExtended) || ! pStmExtended->IsValid())
|
||||
return false ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmExtended->Clone()) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmORIG->Clone()) ;
|
||||
|
||||
// 2) Creazione della FlatRegion di proiezione complessiva delle facce della TriMesh sopra al piano di svuotatura
|
||||
// attuale
|
||||
PtrOwner<ISurfFlatRegion> pSfrProjUP( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrProjUP))
|
||||
return false ;
|
||||
|
||||
// 4) Creo il piano di proeizione allo step attuale
|
||||
Point3d ptC ; pSrfExtended_cl->GetCentroid( ptC) ;
|
||||
Vector3d vtN = pSfrORIG->GetNormVersor() ;
|
||||
Plane3d plProj ; plProj.Set( ptC, -vtN) ;
|
||||
if ( ! plProj.IsValid())
|
||||
return false ;
|
||||
|
||||
// 5) taglio la TriMesh originale togliendo tutto ciò che sta sotto al piano di proiezione
|
||||
PtrOwner<ISurfTriMesh> pStmORIG_forCut( CloneSurfTriMesh( pStmORIG)) ;
|
||||
if ( IsNull( pStmORIG_forCut) || ! pStmORIG_forCut->IsValid())
|
||||
return false ;
|
||||
if ( ! pStmORIG_forCut->Cut( plProj, true))
|
||||
return false ;
|
||||
|
||||
if ( pStmORIG_forCut->IsValid()) {
|
||||
// 6) Proietto tutto ciò che sta sopra alla superficie di taglio
|
||||
if ( ! ProjectStmOnPlane( pStmORIG_forCut, plProj, pSfrProjUP))
|
||||
return false ;
|
||||
}
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjUP->Clone()) ;
|
||||
|
||||
// 7) verifico se la superificie è problematica per il taglio
|
||||
PtrOwner<ISurfFlatRegion> pSfrORIGNoSelFaceProj( CreateSurfFlatRegion()) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrExtended( CreateSurfFlatRegion()) ;
|
||||
if ( ! GetSfrByStm( pStmExtended, pSfrExtended, plProj, vtExtr, dThick))
|
||||
return false ;
|
||||
PtrOwner<ISurfTriMesh> pStmORIGNoSelFace( CloneSurfTriMesh( pStmORIG)) ;
|
||||
if ( ! pStmORIGNoSelFace->RemoveFacet( nTmpProp1) ||
|
||||
! ProjectStmOnPlane( pStmORIGNoSelFace, plProj, pSfrORIGNoSelFaceProj))
|
||||
return false ;
|
||||
pNewSrfPock->Clear() ;
|
||||
if ( AreOppositeVectorApprox( vtN, pSfrORIGNoSelFaceProj->GetNormVersor()))
|
||||
pSfrORIGNoSelFaceProj->Invert() ;
|
||||
|
||||
// clono la superficie da svuotare e la porto allo step corrente
|
||||
PtrOwner<ISurfFlatRegion> pSrfExtended_cl( CloneSurfFlatRegion( pSrfExtended)) ;
|
||||
if ( IsNull( pSrfExtended_cl) || ! pSrfExtended_cl->IsValid())
|
||||
return false ;
|
||||
pSrfExtended_cl->Translate( vtTrasl) ;
|
||||
if ( ! IsNull( pSfrORIGNoSelFaceProj) && pSfrORIGNoSelFaceProj->IsValid()) {
|
||||
PNTVECTOR vPt ;
|
||||
BIPNTVECTOR vBpt ;
|
||||
TRIA3DVECTOR vTria ;
|
||||
if ( IntersPlaneSurfTm( plProj, *pStmORIG, vPt, vBpt, vTria) && ( int)vTria.size() == 0) {
|
||||
ChainCurves chainC ;
|
||||
chainC.Init( false, 50 * EPS_SMALL, int( vBpt.size())) ;
|
||||
for ( int i = 0 ; i < int( vBpt.size()) ; ++ i) {
|
||||
Vector3d vtDir = vBpt[i].second - vBpt[i].first ;
|
||||
vtDir.Normalize() ;
|
||||
if ( ! chainC.AddCurve( i + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir))
|
||||
return false ;
|
||||
}
|
||||
// recupero i percorsi concatenati
|
||||
Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ;
|
||||
INTVECTOR vId ;
|
||||
bool bExtraSub = false ;
|
||||
while ( chainC.GetChainFromNear( ptNear, false, vId)) {
|
||||
// creo una curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return false ;
|
||||
// recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita
|
||||
bool bAdded = true ;
|
||||
for ( int i = 0 ; i < int( vId.size()) ; ++ i) {
|
||||
// creo un segmento di retta
|
||||
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
if ( IsNull( pLine))
|
||||
return false ;
|
||||
// recupero gli estremi (non vanno mai invertiti per opzione di concatenamento)
|
||||
int nInd = abs( vId[i]) - 1 ;
|
||||
Point3d ptStart = ( bAdded ? vBpt[nInd].first : ptNear) ;
|
||||
Point3d ptEnd = vBpt[nInd].second ;
|
||||
// provo ad accodarlo alla composita
|
||||
bAdded = ( Dist( ptStart, ptEnd) > 50 * EPS_SMALL / 2 &&
|
||||
pLine->Set( ptStart, ptEnd) &&
|
||||
pCrvCompo->AddCurve( Release( pLine), true, 50 * EPS_SMALL)) ;
|
||||
ptNear = ( bAdded ? ptEnd : ptStart) ;
|
||||
}
|
||||
// le linee chiuse si riesono a tagliare
|
||||
if ( pCrvCompo->IsClosed())
|
||||
continue ;
|
||||
// Test dei punti
|
||||
Point3d ptS, ptE ;
|
||||
pCrvCompo->GetStartPoint( ptS) ;
|
||||
pCrvCompo->GetEndPoint( ptE) ;
|
||||
bool bS = false ;
|
||||
bool bE = false ;
|
||||
for ( int c = 0 ; c < pSfrExtended->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSfrExtended->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<ICurve> pCrvLoopH( pSfrExtended->GetLoop( c, l)) ;
|
||||
if ( pCrvLoopH->IsPointOn( ptS, 50 * EPS_SMALL))
|
||||
bS = true ;
|
||||
if ( pCrvLoopH->IsPointOn( ptE, 50 * EPS_SMALL))
|
||||
bE = true ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvCompo->Clone()) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExtended->Clone()) ;
|
||||
}
|
||||
}
|
||||
bExtraSub = ! ( bS && bE) ;
|
||||
if ( bExtraSub) {
|
||||
// 9.2) conservo le parti in comuune tra quest'ultima FlatRegion e la superificie originale
|
||||
if ( ! pSfrORIGNoSelFaceProj->Intersect( *pSfrORIG))
|
||||
return false ;
|
||||
|
||||
// proprietà :
|
||||
PtrOwner<ICurveComposite> pCrvForProps( GetCurveComposite( pSfrORIG->GetLoop( 0, 0))) ;
|
||||
Vector3d vtExtr ; pCrvForProps->GetExtrusion( vtExtr) ;
|
||||
double dThick ; pCrvForProps->GetThickness( dThick) ;
|
||||
int nTmpProp0 = pCrvForProps->GetTempProp( 0) ;
|
||||
int nTmpProp1 = pCrvForProps->GetTempProp( 1) ;
|
||||
// 7.3) Sottraggo
|
||||
if ( pSfrORIGNoSelFaceProj->IsValid() &&
|
||||
pSfrExtended->Subtract( *pSfrORIGNoSelFaceProj)) {
|
||||
|
||||
// --------- taglio la superificie estesa con la TriMeshOriginale --------------
|
||||
// 1) Converto la FlatRegion estesa in Trimesh
|
||||
PtrOwner<ISurfTriMesh> pStmExtended( CloneSurfTriMesh( pSrfExtended_cl->GetAuxSurf())) ;
|
||||
if ( IsNull( pStmExtended) || ! pStmExtended->IsValid())
|
||||
return false ;
|
||||
if ( IsNull( pSfrExtended) || ! pSfrExtended->IsValid())
|
||||
return false ;
|
||||
|
||||
// 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 ;
|
||||
pStmExtended.Set( pSfrExtended->GetAuxSurf()->Clone()) ;
|
||||
if ( IsNull( pStmExtended) || ! pStmExtended->IsValid())
|
||||
return false ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
// 8) Verifico se riesco a fare il taglio
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmExtended->Clone()) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmORIG->Clone()) ;
|
||||
if ( ! pStmExtended->CutWithOtherSurf( *pStmORIG, false, true))
|
||||
return false ;
|
||||
if ( ! IsNull( pStmExtended) && pStmExtended->GetTriangleCount() == 0)
|
||||
pStmExtended.Set( CloneSurfTriMesh( pSfrORIG->GetAuxSurf())) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmExtended->Clone()) ;
|
||||
|
||||
// 4) Creo il piano di proeizione allo step attuale
|
||||
Point3d ptC ; pSrfExtended_cl->GetCentroid( ptC) ;
|
||||
Vector3d vtN = pSfrORIG->GetNormVersor() ;
|
||||
Plane3d plProj ; plProj.Set( ptC, -vtN) ;
|
||||
if ( ! plProj.IsValid())
|
||||
return false ;
|
||||
// 8) Riconverto in FlatRegion
|
||||
if ( ! GetSfrByStm( pStmExtended, pSfrExtended, plProj, vtExtr, dThick))
|
||||
return false ;
|
||||
|
||||
// 5) taglio la TriMesh originale togliendo tutto ciò che sta sotto al piano di proiezione
|
||||
PtrOwner<ISurfTriMesh> pStmORIG_forCut( CloneSurfTriMesh( pStmORIG)) ;
|
||||
if ( IsNull( pStmORIG_forCut) || ! pStmORIG_forCut->IsValid())
|
||||
return false ;
|
||||
if ( pSfrProjUP->IsValid()) {
|
||||
|
||||
// 4) Taglio
|
||||
if ( pStmExtended->CutWithOtherSurf( *pStmORIG, false, true)) {
|
||||
if ( AreOppositeVectorApprox( vtN, pSfrProjUP->GetNormVersor()))
|
||||
pSfrProjUP->Invert() ;
|
||||
|
||||
// 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)
|
||||
pStmExtended.Set( CloneSurfTriMesh( pSfrORIG->GetAuxSurf())) ;
|
||||
if ( IsNull( pSfrExtended) ||
|
||||
! pSfrExtended->Subtract( *pSfrProjUP))
|
||||
return false ;
|
||||
|
||||
if ( pStmORIG_forCut->Cut( plProj, true)) {
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExtended->Clone()) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjUP->Clone()) ;
|
||||
//m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExtended_Sub->Clone()) ;
|
||||
|
||||
// 7) Proeizione della TriMesh tagliata sul piano di svuotatura
|
||||
if ( ! ProjectStmOnPlane( pStmORIG_forCut, plProj, pSfrProjUP))
|
||||
return false ;
|
||||
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
|
||||
// --------- sottraggo alla FlatRegion estesa la proeizione complessiva ---------------
|
||||
// 1) trasformo la Trimesh estesa ricavata in FlatRegion
|
||||
PtrOwner<ISurfFlatRegion> pSfrExtended( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrExtended))
|
||||
return false ;
|
||||
if ( ! GetSfrByStm( pStmExtended, pSfrExtended, plProj, vtExtr, dThick))
|
||||
return false ;
|
||||
|
||||
// 2) Sottrazione
|
||||
if ( AreOppositeVectorApprox( pSfrExtended->GetNormVersor(), pSfrProjUP->GetNormVersor()))
|
||||
pSfrProjUP->Invert() ;
|
||||
if ( pSfrProjUP->IsValid() &&
|
||||
! pSfrExtended->Subtract( *pSfrProjUP))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// 9) Ricalcolo lati aperti e lati chiusi
|
||||
SurfFlatRegionByContours sfrBC ;
|
||||
// 13.1) scorro tutti i Loops ottenuti e imposto loro le TmpProps
|
||||
for ( int c = 0 ; c < pSfrExtended->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSfrExtended->GetLoopCount( c) ; ++ l) {
|
||||
|
||||
// 2.2) scorro tutti i Loops ottenuti e imposto loro le TmpProps
|
||||
for ( int c = 0 ; c < pSfrExtended->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSfrExtended->GetLoopCount( c) ; ++ l) {
|
||||
// 2.3) recupero della Curva composita
|
||||
PtrOwner<ICurveComposite> pCrvLoop( ConvertCurveToComposite( pSfrExtended->GetLoop( c, l))) ;
|
||||
if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
|
||||
return false ;
|
||||
// 2.4) se Isola allora tutta la curva è chiusa
|
||||
if ( l > 0) {
|
||||
for ( int u = 0 ; u < pCrvLoop->GetCurveCount() ; ++ u)
|
||||
pCrvLoop->SetCurveTempProp( u, 0, 0) ;
|
||||
}
|
||||
// 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 ( ! ManageTmpPropForAdaptingStm( pStmORIG_forCut, pSfrORIG, pSfrProjUP, 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 u = 0 ; u < pCrvLoop->GetCurveCount() ; ++ u) {
|
||||
bool bFound = false ;
|
||||
for ( int i = 0 ; i < ( int)vCrvWithTmpProps.size() && !bFound ; ++ i) {
|
||||
int nStat ;
|
||||
if ( SetTmpPropByOverlap( pCrvLoop, u, vCrvWithTmpProps[i], nStat, 250 * EPS_SMALL) &&
|
||||
nStat == 1)
|
||||
bFound = true ;
|
||||
}
|
||||
if ( ! bFound) {
|
||||
PtrOwner<ICurve> pCrv_u( pCrvLoop->GetCurve( u)->Clone()) ;
|
||||
Point3d ptS, ptM, ptE ;
|
||||
pCrv_u->GetStartPoint( ptS) ;
|
||||
pCrv_u->GetEndPoint( ptE) ;
|
||||
pCrv_u->GetMidPoint( ptM) ;
|
||||
PtrOwner<ISurfTriMesh> pStmNoSelFace( CloneSurfTriMesh( pStmORIG)) ;
|
||||
if ( ! pStmNoSelFace->RemoveFacet( nTmpProp1))
|
||||
return false ;
|
||||
// 13.2) recupero della Curva Composita
|
||||
PtrOwner<ICurveComposite> pCrvLoop( ConvertCurveToComposite( pSfrExtended->GetLoop( c, l))) ;
|
||||
if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
|
||||
return false ;
|
||||
|
||||
DistPointSurfTm dPStm1( ptS, *pStmNoSelFace) ;
|
||||
DistPointSurfTm dPStm2( ptM, *pStmNoSelFace) ;
|
||||
DistPointSurfTm dPStm3( ptE, *pStmNoSelFace) ;
|
||||
double dDist1, dDist2, dDist3 ;
|
||||
pCrvLoop->SetCurveTempProp( u, 0, 0) ;
|
||||
if ( dPStm1.GetDist( dDist1) && dDist1 > 250 * EPS_SMALL)
|
||||
pCrvLoop->SetCurveTempProp( u, 1, 0) ;
|
||||
else if ( dPStm2.GetDist( dDist2) && dDist2 > 250 * EPS_SMALL)
|
||||
pCrvLoop->SetCurveTempProp( u, 1, 0) ;
|
||||
else if ( dPStm3.GetDist( dDist3) && dDist3 > 250 * EPS_SMALL)
|
||||
pCrvLoop->SetCurveTempProp( u, 1, 0) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2.6) riporto le proprietà
|
||||
pCrvLoop->SetTempProp( nTmpProp0, 0) ;
|
||||
pCrvLoop->SetTempProp( nTmpProp1, 1) ;
|
||||
pCrvLoop->SetExtrusion( vtExtr) ;
|
||||
pCrvLoop->SetThickness( dThick) ;
|
||||
// 13.3) se Isola allora tutta la curva è chiusa
|
||||
if ( l > 0) {
|
||||
for ( int u = 0 ; u < pCrvLoop->GetCurveCount() ; ++ u)
|
||||
pCrvLoop->SetCurveTempProp( u, 0, 0) ;
|
||||
}
|
||||
// 13.4) se curva esterna, setto le TmpProp mediante Overlaps
|
||||
else {
|
||||
// 13.5.1) riempio un vettore du curve con TmpProps adeguate
|
||||
ICRVCOMPOPOVECTOR vCrvWithTmpProps ;
|
||||
if ( pSfrORIGNoSelFaceProj->IsValid())
|
||||
pSfrORIGNoSelFaceProj->Intersect( *pSfrORIG) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrORIG_Tr( CloneSurfFlatRegion( pSfrORIG)) ;
|
||||
pSfrORIG_Tr->Translate( vtTrasl) ;
|
||||
if ( ! ManageTmpPropForAdaptingStm( pSfrORIG_Tr, pSfrProjUP, pSfrORIGNoSelFaceProj, vCrvWithTmpProps))
|
||||
return false ;
|
||||
// 13.5.2) assegno la TmpProp ad ogni sottocurva
|
||||
for ( int u = 0 ; u < pCrvLoop->GetCurveCount() ; ++ u) {
|
||||
bool bFound = false ;
|
||||
for ( int i = 0 ; i < ( int)vCrvWithTmpProps.size() && !bFound ; ++ i) {
|
||||
int nStat ;
|
||||
if ( SetTmpPropByOverlap( pCrvLoop, u, vCrvWithTmpProps[i], nStat, 250 * EPS_SMALL) &&
|
||||
nStat == 1)
|
||||
bFound = true ;
|
||||
}
|
||||
// se non vi è Overlap, controllo se sono sulla TriMesh o no
|
||||
if ( ! bFound) {
|
||||
PtrOwner<ICurve> pCrv_u( pCrvLoop->GetCurve( u)->Clone()) ;
|
||||
Point3d ptS, ptM, ptE ;
|
||||
pCrv_u->GetStartPoint( ptS) ;
|
||||
pCrv_u->GetEndPoint( ptE) ;
|
||||
pCrv_u->GetMidPoint( ptM) ;
|
||||
PtrOwner<ISurfTriMesh> pStmNoSelFace( CloneSurfTriMesh( pStmORIG)) ;
|
||||
//if ( ! pStmNoSelFace->RemoveFacet( nTmpProp1))
|
||||
// return false ;
|
||||
|
||||
// 2.8) inserimento della curva
|
||||
sfrBC.AddCurve( Release( pCrvLoop)) ;
|
||||
}
|
||||
}
|
||||
DistPointSurfTm dPStm1( ptS, *pStmNoSelFace) ;
|
||||
DistPointSurfTm dPStm2( ptM, *pStmNoSelFace) ;
|
||||
DistPointSurfTm dPStm3( ptE, *pStmNoSelFace) ;
|
||||
double dDist1, dDist2, dDist3 ;
|
||||
pCrvLoop->SetCurveTempProp( u, 0, 0) ;
|
||||
if ( dPStm1.GetDist( dDist1) && dDist1 > 250 * EPS_SMALL)
|
||||
pCrvLoop->SetCurveTempProp( u, 1, 0) ;
|
||||
else if ( dPStm2.GetDist( dDist2) && dDist2 > 250 * EPS_SMALL)
|
||||
pCrvLoop->SetCurveTempProp( u, 1, 0) ;
|
||||
else if ( dPStm3.GetDist( dDist3) && dDist3 > 250 * EPS_SMALL)
|
||||
pCrvLoop->SetCurveTempProp( u, 1, 0) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2.6) riporto le proprietà
|
||||
pCrvLoop->SetTempProp( nTmpProp0, 0) ;
|
||||
pCrvLoop->SetTempProp( nTmpProp1, 1) ;
|
||||
pCrvLoop->SetExtrusion( vtExtr) ;
|
||||
pCrvLoop->SetThickness( dThick) ;
|
||||
|
||||
// 7) ritorno la superificie ottenuta
|
||||
PtrOwner<ISurfFlatRegion> pSfrFINAL( sfrBC.GetSurf()) ;
|
||||
if ( IsNull( pSfrFINAL) || ! pSfrFINAL->IsValid())
|
||||
return false ;
|
||||
pNewSrfPock->CopyFrom( pSfrFINAL) ;
|
||||
// 2.8) inserimento della curva
|
||||
sfrBC.AddCurve( Release( pCrvLoop)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// 8) DISEGNO =========== TOGLIEREEEEEEEEEEEEEEEEEEEEEEEE ================================
|
||||
PtrOwner<ISurfFlatRegion> pSrf_toDraw( CloneSurfFlatRegion( pNewSrfPock)) ;
|
||||
int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ;
|
||||
m_pGeomDB->SetMaterial( a, Color( 0.0, 0.0, 1.0, 0.45)) ;
|
||||
for ( int c = 0 ; c < pSrf_toDraw->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSrf_toDraw->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<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()) ;
|
||||
m_pGeomDB->SetMaterial( aaa, nProp0 == 0 ? BLUE : RED) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ===================================================================
|
||||
|
||||
pNewSrfPock->Translate( -vtTrasl) ;
|
||||
return pNewSrfPock != nullptr && pNewSrfPock->IsValid() && pNewSrfPock->GetChunkCount() > 0 ;
|
||||
// 7) ritorno la superificie ottenuta
|
||||
PtrOwner<ISurfFlatRegion> pSfrFINAL( sfrBC.GetSurf()) ;
|
||||
if ( IsNull( pSfrFINAL) || ! pSfrFINAL->IsValid())
|
||||
return false ;
|
||||
pNewSrfPock->CopyFrom( pSfrFINAL) ;
|
||||
pNewSrfPock->Translate( -vtTrasl) ;
|
||||
return pNewSrfPock != nullptr && pNewSrfPock->IsValid() && pNewSrfPock->GetChunkCount() > 0 ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::ManageTmpPropForAdaptingStm( const ISurfTriMesh* pStmORIG, const ISurfFlatRegion* pSfrORIG,
|
||||
const ISurfFlatRegion* pSfrProjUP, const ISurfFlatRegion* pSrfExtended,
|
||||
const Vector3d& vtTrasl, ICRVCOMPOPOVECTOR& vCrvWithTmpProps)
|
||||
Pocketing::ManageTmpPropForAdaptingStm( const ISurfFlatRegion* pSfrORIG, const ISurfFlatRegion* pSfrProjUP,
|
||||
const ISurfFlatRegion* pSrfProjToT, ICRVCOMPOPOVECTOR& vCrvWithTmpProps)
|
||||
{
|
||||
|
||||
// controllo dei parametri
|
||||
if ( pSfrORIG == nullptr || ! pSfrORIG->IsValid() || pSfrORIG->GetChunkCount() == 0 )
|
||||
return false ;
|
||||
vCrvWithTmpProps.clear() ;
|
||||
|
||||
// in prima posizione metto il loop esterno
|
||||
for ( int c = 0 ; c < pSfrORIG->GetChunkCount() ; ++ c) {
|
||||
PtrOwner<ICurveComposite> pCrvCompoLoop( ConvertCurveToComposite( pSfrProjUP->GetLoop( c, 0))) ;
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u)
|
||||
pCrvCompoLoop->SetCurveTempProp( u, 0, 0) ;
|
||||
PtrOwner<ICurveComposite> pCrvCompoLoop( ConvertCurveToComposite( pSfrORIG->GetLoop( c, 0))) ;
|
||||
vCrvWithTmpProps.emplace_back( Release( pCrvCompoLoop)) ;
|
||||
}
|
||||
|
||||
// in successione metto tutte le altre curve ricavate dal bordo della ProjectUP
|
||||
if ( pSrfProjToT != nullptr && pSrfProjToT->IsValid()) {
|
||||
for ( int c = 0 ; c < pSrfProjToT->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSrfProjToT->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<ICurveComposite> pCrvCompoLoop( ConvertCurveToComposite( pSrfProjToT->GetLoop( c, l))) ;
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u)
|
||||
pCrvCompoLoop->SetCurveTempProp( u, 0, 0) ; // <-- chiuse
|
||||
vCrvWithTmpProps.emplace_back( Release( pCrvCompoLoop)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// in successione metto tutte le altre curve ricavate dal bordo della ProjectUP
|
||||
if ( pSfrProjUP != nullptr && pSfrProjUP->IsValid()) {
|
||||
for ( int c = 0 ; c < pSfrProjUP->GetChunkCount() ; ++ c) {
|
||||
for ( int l = 0 ; l < pSfrProjUP->GetLoopCount( c) ; ++ l) {
|
||||
PtrOwner<ICurveComposite> pCrvCompoLoop( ConvertCurveToComposite( pSfrProjUP->GetLoop( c, l))) ;
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u)
|
||||
pCrvCompoLoop->SetCurveTempProp( u, 0, 0) ;
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u)
|
||||
pCrvCompoLoop->SetCurveTempProp( u, 0, 0) ; // <-- chiuse
|
||||
vCrvWithTmpProps.emplace_back( Release( pCrvCompoLoop)) ;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -131,9 +131,8 @@ class Pocketing : public Machining
|
||||
double dAreaToll = 500 * EPS_SMALL) ;
|
||||
bool CloseOpenSidesInsideRawForProjection( const ISurfFlatRegion* pSfrAct, const ISurfTriMesh* pStmRaw,
|
||||
ISurfFlatRegion* pSfrMod) ;
|
||||
bool ManageTmpPropForAdaptingStm( const ISurfTriMesh* pStmORIG, const ISurfFlatRegion* pSfrORIG,
|
||||
const ISurfFlatRegion* pSfrProjUP, const ISurfFlatRegion* pSrfExtended,
|
||||
const Vector3d& vtTrasl, ICRVCOMPOPOVECTOR& vCrvWithTmpProps) ;
|
||||
bool ManageTmpPropForAdaptingStm( const ISurfFlatRegion* pSfrORIG, const ISurfFlatRegion* pSfrProjUP,
|
||||
const ISurfFlatRegion* pSrfProjToT, 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