Merge commit 'b7eee50e55973024da5fc7d80020ee7daacf64d2' into Svuotature_LeadIn/Out
This commit is contained in:
+114
-131
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2022
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Pocketing.cpp Data : 24.08.22 Versione : 2.4h2
|
||||
// File : Pocketing.cpp Data : 17.12.23 Versione : 2.5l3
|
||||
// Contenuto : Implementazione gestione svuotature.
|
||||
//
|
||||
//
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkPolygonElevation.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
@@ -2051,7 +2052,6 @@ Pocketing::AdjustPocketingSideForVolumePart( ISurfTriMesh* pStmVolPart, const Ve
|
||||
bool
|
||||
Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
{
|
||||
|
||||
// recupero gruppo per geometria temporanea ( Gruppo Temp)
|
||||
const string GRP_TEMP = "Temp" ;
|
||||
int nTempId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, GRP_TEMP) ;
|
||||
@@ -2104,7 +2104,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
if ( ! AdjustPocketingSideForVolumePart( pStm_PartVolume, vtTool))
|
||||
return false ;
|
||||
|
||||
// devo calcolare l'Elevazione...
|
||||
// devo calcolare l'Elevazione... ( devo tenere conto del grezzo, non solo della parte)
|
||||
Frame3d frElevation ;
|
||||
frElevation.Set( ptC, vtTool) ;
|
||||
if ( ! frElevation.IsValid())
|
||||
@@ -2112,11 +2112,39 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
pStm_PartVolume->ToLoc( frElevation) ;
|
||||
// ricavo quindi il Box
|
||||
BBox3d BBox ; pStm_PartVolume->GetLocalBBox( BBox) ;
|
||||
// il su cui iniziare a svuotare è quello che si trova a Z minima
|
||||
// il piano su cui iniziare a svuotare è quello che si trova a Z minima
|
||||
double dZ_min = BBox.GetMin().z ;
|
||||
// riporto in globale
|
||||
pStm_PartVolume->ToGlob( frElevation) ;
|
||||
// calcolo l'elevazione massima ( è la lunghezza Z del Box con asse Z uguale a vtTool)
|
||||
double dElev = BBox.GetDimZ() ;
|
||||
// calcolo l'elevazione massima su ogni faccia del volume con normale circa - vtTool ( il volume è interno)
|
||||
double dElev = 0. ;
|
||||
pStm_PartVolume->Invert() ; // ho curve e normali orientate correttamente
|
||||
for ( int i = 0 ; i < pStm_PartVolume->GetFacetCount() ; ++ i) {
|
||||
Vector3d vtN_f ;
|
||||
if ( ! pStm_PartVolume->GetFacetNormal( i, vtN_f))
|
||||
return false ;
|
||||
if ( ! AreSameVectorEpsilon( vtTool, vtN_f, 5 * EPS_SMALL))
|
||||
continue ;
|
||||
// ricavo le polyLine di bordo
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pStm_PartVolume->GetFacetLoops( i, vPL) ||
|
||||
vPL.empty())
|
||||
return false ;
|
||||
// ricavo le curve Composite associate e calcolo l'elevazione
|
||||
for ( int j = 0 ; j < int( vPL.size()) ; ++ j) {
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
double dCurrElev = 0. ;
|
||||
if ( IsNull( pCompo) ||
|
||||
! pCompo->FromPolyLine( vPL[j]) ||
|
||||
! pCompo->IsValid() ||
|
||||
! CalcRegionElevation( pCompo, vtTool, 0.,
|
||||
0.5 * ( m_dDiam_Prec > 0 ? m_dDiam_Prec : m_TParams.m_dDiam),
|
||||
m_dLen_Prec > 0 ? m_dLen_Prec : m_TParams.m_dLen, dCurrElev))
|
||||
return false ;
|
||||
dElev = max( dElev, dCurrElev) ;
|
||||
}
|
||||
}
|
||||
pStm_PartVolume->Invert() ; // riporto come in orginale
|
||||
// eventuale imposizione massima elevazione da note utente
|
||||
double dMaxElev ;
|
||||
if ( FromString( ExtractInfo( m_Params.m_sUserNotes, "MaxElev="), dMaxElev) && dElev > dMaxElev)
|
||||
@@ -3267,132 +3295,86 @@ Pocketing::ModifySurfByOpenEdges( ISurfFlatRegion* pSfr, const ISurfFlatRegion*
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Pocketing::CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad,
|
||||
Pocketing::CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dLen,
|
||||
double& dElev) const
|
||||
{
|
||||
// inizializzo l'elevazione
|
||||
dElev = 0 ;
|
||||
|
||||
// DA ADATTARE !
|
||||
// approssimo la curva con una polilinea che uso per creare il poligono equivalente
|
||||
PolyLine PL ;
|
||||
if ( ! pCompo->ApproxWithLines( LIN_TOL_RAW, ANG_TOL_MAX_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return false ;
|
||||
Polygon3d pgFacet ;
|
||||
if ( ! pgFacet.FromPolyLine( PL))
|
||||
return false ;
|
||||
// aggiungo l'affondamento
|
||||
pgFacet.Translate( -dDepth * vtTool) ;
|
||||
|
||||
//// inizializzo l'elevazione
|
||||
// dElev = 0 ;
|
||||
//// affondamento come vettore
|
||||
// Vector3d vtDepth = vtTool * dDepth ;
|
||||
|
||||
//// Offsetto la curva della quantità stabvilità per la ricerca di proiezioni
|
||||
// OffsetCurve OffsCrv ;
|
||||
// if ( ! OffsCrv.Make( pCompo, m_dMaxLenRawProj, ICurve::OFF_FILLET)) {
|
||||
// m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ;
|
||||
// return false ;
|
||||
// }
|
||||
// PtrOwner<ICurveComposite> pCompoExtended( ConvertCurveToComposite( OffsCrv.GetLongerCurve())) ;
|
||||
// if ( IsNull( pCompoExtended) || ! pCompoExtended->IsValid())
|
||||
// return false ;
|
||||
|
||||
//// Campiono il contorno
|
||||
// int nMaxInd = pCompoExtended->GetCurveCount() - 1 ;
|
||||
// for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// // curva corrente
|
||||
// const ICurve* pCrvC = pCompoExtended->GetCurve( i) ;
|
||||
// Point3d ptStart ; pCrvC->GetStartPoint( ptStart) ;
|
||||
// Point3d ptMid ; pCrvC->GetMidPoint( ptMid) ;
|
||||
// Point3d ptEnd ; pCrvC->GetEndPoint( ptEnd) ;
|
||||
// // elevazione della curva
|
||||
// double dCurrElev ;
|
||||
// if ( GetElevation( m_nPhase, ptStart - vtDepth, ptMid - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
|
||||
// if ( dCurrElev > dElev)
|
||||
// dElev = dCurrElev ;
|
||||
// }
|
||||
// else {
|
||||
// m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
// return false ;
|
||||
// }
|
||||
// }
|
||||
|
||||
//// Campiono l'interno con una griglia (uso linee parallele a X)
|
||||
//// determino il riferimento di base
|
||||
// Frame3d frPocket ;
|
||||
// Point3d ptCen ; pCompoExtended->GetCentroid( ptCen) ;
|
||||
// frPocket.Set( ptCen, vtTool) ;
|
||||
//// copio il contorno e lo porto nel riferimento
|
||||
// PtrOwner<ICurveComposite> pCompoL( pCompoExtended->Clone()) ;
|
||||
// if ( IsNull( pCompoL) || ! pCompoL->ToLoc( frPocket)) {
|
||||
// m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
// return false ;
|
||||
// }
|
||||
//// ingombro del contorno in locale
|
||||
// BBox3d b3Pocket ;
|
||||
// pCompoL->GetLocalBBox( b3Pocket) ;
|
||||
// Point3d ptMin ; double dDimX, dDimY, dDimZ ;
|
||||
// b3Pocket.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ;
|
||||
|
||||
//// passi in Y
|
||||
// const double STEP = m_TParams.m_dDiam ;
|
||||
// int nYStep = max( int( ceil( ( dDimY - 20 * EPS_SMALL) / STEP)), 2) ;
|
||||
// double dYStep = ( nYStep > 0 ? ( dDimY - 20 * EPS_SMALL) / nYStep : 0) ;
|
||||
//// calcolo le linee di svuotatura
|
||||
// for ( int i = 1 ; i < nYStep ; ++ i) {
|
||||
// // definisco la linea
|
||||
// PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
||||
// const double EXP_LEN = 1.0 ;
|
||||
// Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + 10 * EPS_SMALL + i * dYStep, ptMin.z + dDimZ) ;
|
||||
// if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN)) {
|
||||
// m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
// return false ;
|
||||
// }
|
||||
|
||||
// // calcolo la classificazione della curva rispetto al contorno
|
||||
// IntersCurveCurve intCC( *pLine, *pCompoL) ;
|
||||
// CRVCVECTOR ccClass ;
|
||||
// if ( intCC.GetCurveClassification( 0, EPS_SMALL, ccClass)) {
|
||||
// // determino gli intervalli di curva interni
|
||||
// Intervals inOk ;
|
||||
// for ( auto& ccOne : ccClass) {
|
||||
// if ( ccOne.nClass == CRVC_IN) {
|
||||
// // ricavo punto iniziale e finale
|
||||
// Point3d ptStart ;
|
||||
// pLine->GetPointD1D2( ccOne.dParS, ICurve::FROM_PLUS, ptStart) ;
|
||||
// Point3d ptEnd ;
|
||||
// pLine->GetPointD1D2( ccOne.dParE, ICurve::FROM_MINUS, ptEnd) ;
|
||||
// // calcolo la distanza tra questi due punti
|
||||
// double dDist = Dist( ptStart, ptEnd) ;
|
||||
// // il tratto interno lo campiono rispetto ad X
|
||||
// for ( int j = 0 ; j <= int( dDist / STEP) + 1 ; ++ j) {
|
||||
// Point3d ptCurr ;
|
||||
// pLine->GetPointD1D2( ccOne.dParS + j * ( ccOne.dParE - ccOne.dParS) / ( dDist / STEP + 1), ICurve::FROM_PLUS, ptCurr) ;
|
||||
// ptCurr.ToGlob( frPocket) ;
|
||||
// double dCurrElev ;
|
||||
// if ( GetElevation( m_nPhase, ptCurr - vtDepth, vtTool, dCurrElev)) {
|
||||
// if ( dCurrElev > dElev)
|
||||
// dElev = dCurrElev ;
|
||||
// }
|
||||
// else {
|
||||
// m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
// return false ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // altrimenti uso tutta la curva
|
||||
// else {
|
||||
// Point3d ptStart ;
|
||||
// pLine->GetStartPoint( ptStart) ;
|
||||
// ptStart.ToGlob( frPocket) ;
|
||||
// Point3d ptEnd ;
|
||||
// pLine->GetEndPoint( ptEnd) ;
|
||||
// ptEnd.ToGlob( frPocket) ;
|
||||
// // elevazione della curva
|
||||
// double dCurrElev ;
|
||||
// if ( GetElevation( m_nPhase, ptStart - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
|
||||
// if ( dCurrElev > dElev)
|
||||
// dElev = dCurrElev ;
|
||||
// }
|
||||
// else {
|
||||
// m_pMchMgr->SetLastError( 2408, "Error in Pocketing : Entity GetElevation") ;
|
||||
// return false ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// inizializzo elevazioni per ogni grezzo
|
||||
INTDBLVECTOR vRawElev ;
|
||||
// ciclo sui grezzi della fase
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
while ( nRawId != GDB_ID_NULL) {
|
||||
// verifico che il grezzo compaia nella fase
|
||||
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, m_nPhase)) {
|
||||
// recupero la trimesh del grezzo
|
||||
int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ;
|
||||
if ( pStm != nullptr) {
|
||||
// recupero il riferimento della trimesh
|
||||
Frame3d frStm ;
|
||||
m_pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||
// porto il poligono in questo riferimento
|
||||
Polygon3d pgFacetL = pgFacet ;
|
||||
pgFacetL.ToLoc( frStm) ;
|
||||
// calcolo l'elevazione
|
||||
double dCurrElev ;
|
||||
if ( ! PolygonElevationInClosedSurfTm( pgFacetL, *pStm, true, dCurrElev))
|
||||
return false ;
|
||||
if ( dCurrElev > EPS_SMALL)
|
||||
vRawElev.emplace_back( nStmId, dCurrElev) ;
|
||||
}
|
||||
}
|
||||
// passo al grezzo successivo
|
||||
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
|
||||
}
|
||||
// se trovate elevazioni
|
||||
if ( ! vRawElev.empty()) {
|
||||
// ordino il vettore secondo l'elevazione crescente
|
||||
sort( vRawElev.begin(), vRawElev.end(), []( const INTDBL& a, const INTDBL& b)
|
||||
{ return a.second < b.second ; }) ;
|
||||
// box dell'insieme delle posizioni utensile all'inizio
|
||||
const double MAX_DIST_RAW = 200.0 ;
|
||||
BBox3d b3Tool ;
|
||||
pgFacet.GetLocalBBox( b3Tool) ;
|
||||
b3Tool.Add( b3Tool.GetMin() + dLen * vtTool) ;
|
||||
b3Tool.Add( b3Tool.GetMax() + dLen * vtTool) ;
|
||||
if ( vtTool.IsX())
|
||||
b3Tool.Expand( 0, dRad, dRad) ;
|
||||
else if ( vtTool.IsY())
|
||||
b3Tool.Expand( dRad, 0, dRad) ;
|
||||
else if ( vtTool.IsZ())
|
||||
b3Tool.Expand( dRad, dRad, 0) ;
|
||||
else {
|
||||
double dExpandX = dRad * sqrt( 1 - vtTool.x * vtTool.x) ;
|
||||
double dExpandY = dRad * sqrt( 1 - vtTool.y * vtTool.y) ;
|
||||
double dExpandZ = dRad * sqrt( 1 - vtTool.z * vtTool.z) ;
|
||||
b3Tool.Expand( dExpandX, dExpandY, dExpandZ) ;
|
||||
}
|
||||
b3Tool.Expand( MAX_DIST_RAW) ;
|
||||
// verifico la reale interferenza dell'utensile con i diversi grezzi
|
||||
for ( int i = 0 ; i < int( vRawElev.size()) ; ++ i) {
|
||||
// box del grezzo
|
||||
BBox3d b3Raw ;
|
||||
m_pGeomDB->GetGlobalBBox( vRawElev[i].first, b3Raw) ;
|
||||
// confronto con il box dell'utensile nella posizione precedente
|
||||
BBox3d b3CurrTool = b3Tool ;
|
||||
b3CurrTool.Translate( dElev * vtTool) ;
|
||||
if ( b3Raw.Overlaps( b3CurrTool))
|
||||
dElev = vRawElev[i].second ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -9508,8 +9490,9 @@ Pocketing::AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVE
|
||||
// L'algoritmo di allargamento presso i lati aperti è Euristico; io mi estendo a seconda della geometria del
|
||||
// lato aperto al di fuori del volume di svuotatura... Devo controllare di non rovinare delle zone al di fuori di
|
||||
// esso !
|
||||
if ( ! pSfrInc->Subtract( *pSfrLimit))
|
||||
return false ;
|
||||
if ( pSfrLimit->IsValid())
|
||||
if ( ! pSfrInc->Subtract( *pSfrLimit))
|
||||
return false ;
|
||||
|
||||
// controllo se la curva è un'isola
|
||||
bool bIsIsland = false ;
|
||||
|
||||
Reference in New Issue
Block a user