EgtMachkernel :
- in SurfRoughing piccola correzione per le Fixture.
This commit is contained in:
+76
-61
@@ -2459,71 +2459,83 @@ SurfRoughing::GetToolCollisionRegion( const ISurfFlatRegion* pSfrSgro, double& d
|
||||
// recupero il Box della ventosa
|
||||
BBox3d bFxtBox ;
|
||||
if ( m_pGeomDB->GetGlobalBBox( nFxtId, bFxtBox) && ! bFxtBox.IsEmpty()) {
|
||||
// espando il Box per evitare la collisione con l'utensile
|
||||
bFxtBox.Expand( SAFE_TOL) ;
|
||||
#if ENABLE_DEBUG_SFR_COLLISION
|
||||
ICurveComposite* _pCompoFxt = CreateCurveComposite() ;
|
||||
_pCompoFxt->AddPoint( bFxtBox.GetMin()) ;
|
||||
_pCompoFxt->AddLine( bFxtBox.GetMin() + X_AX * bFxtBox.GetDimX()) ;
|
||||
_pCompoFxt->AddLine( bFxtBox.GetMax() - Z_AX * bFxtBox.GetDimZ()) ;
|
||||
_pCompoFxt->AddLine( bFxtBox.GetMin() + Y_AX * bFxtBox.GetDimY()) ;
|
||||
_pCompoFxt->Close() ;
|
||||
_pCompoFxt->SetExtrusion( Z_AX) ;
|
||||
_pCompoFxt->SetThickness( bFxtBox.GetDimZ()) ;
|
||||
int nFxtId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, _pCompoFxt) ;
|
||||
m_pGeomDB->SetMaterial( nFxtId, YELLOW) ;
|
||||
#endif
|
||||
// recupero la TriMesh del Box
|
||||
PtrOwner<ICurveComposite> pCompoFxt( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompoFxt))
|
||||
return false ;
|
||||
pCompoFxt->AddPoint( bFxtBox.GetMin()) ;
|
||||
pCompoFxt->AddLine( bFxtBox.GetMin() + X_AX * bFxtBox.GetDimX()) ;
|
||||
pCompoFxt->AddLine( bFxtBox.GetMax() - Z_AX * bFxtBox.GetDimZ()) ;
|
||||
pCompoFxt->AddLine( bFxtBox.GetMin() + Y_AX * bFxtBox.GetDimY()) ;
|
||||
pCompoFxt->Close() ;
|
||||
CICURVEPVECTOR vpCrvs ;
|
||||
vpCrvs.emplace_back( pCompoFxt) ;
|
||||
PtrOwner<ISurfTriMesh> pStmCollFxt( GetSurfTriMeshByRegionExtrusion( vpCrvs, Z_AX * bFxtBox.GetDimZ())) ;
|
||||
if ( IsNull( pStmCollFxt) || ! pStmCollFxt->IsValid() || pStmCollFxt->GetTriangleCount() == 0)
|
||||
return false ;
|
||||
// recupero la sua proiezione nel piano di sgrossatura come regione piana
|
||||
Plane3d plProj ;
|
||||
if ( ! plProj.Set( frLoc.Orig() - dDepth * frLoc.VersZ(), frLoc.VersZ()))
|
||||
return false ;
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pStmCollFxt->GetSilhouette( plProj, EPS_SMALL, vPL)) // proiezione di 6 triangoli, veloce
|
||||
return false ;
|
||||
// se completamente dietro al piano, non influenza la sgrossatura attuale
|
||||
if ( vPL.empty())
|
||||
continue ;
|
||||
SurfFlatRegionByContours SfrByC ;
|
||||
for ( const PolyLine& PL : vPL) {
|
||||
PtrOwner<ICurveComposite> pCompoLoop( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompoLoop) || ! pCompoLoop->FromPolyLine( PL) ||
|
||||
! SfrByC.AddCurve( Release( pCompoLoop)))
|
||||
return false ;
|
||||
}
|
||||
PtrOwner<ISurfFlatRegion> pSfrFxtColl( SfrByC.GetSurf()) ;
|
||||
if ( IsNull( pSfrFxtColl) || ! pSfrFxtColl->IsValid())
|
||||
return false ;
|
||||
if ( AreOppositeVectorApprox( pSfrFxtColl->GetNormVersor(), frLoc.VersZ()))
|
||||
pSfrFxtColl->Invert() ;
|
||||
// aggiorno la regione di collissione per l'utensile
|
||||
if ( ! pSfrColl->IsValid()) {
|
||||
if ( ! pSfrColl->CopyFrom( pSfrFxtColl))
|
||||
return false ;
|
||||
// se sgrossatura orientata come come Z_AX
|
||||
if ( AreSameVectorApprox( pSfrSgro->GetNormVersor(), Z_AX)) {
|
||||
// controllo se limitare la Depth della tavola
|
||||
double dTabDist = abs( ( ptCen - bFxtBox.GetMax()) * pSfrSgro->GetNormVersor()) ;
|
||||
if ( dDepth > dTabDist - DIST_TABLE) {
|
||||
dDepth = dTabDist - DIST_TABLE ;
|
||||
string sWarn = "Warning in SurfRoughing : Depth reduced at " + ToString( dDepth, 3) ;
|
||||
m_pMchMgr->SetWarning( 3057, sWarn) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( ! pSfrColl->Add( *pSfrFxtColl))
|
||||
// espando il Box per evitare la collisione con l'utensile
|
||||
bFxtBox.Expand( SAFE_TOL) ;
|
||||
#if ENABLE_DEBUG_SFR_COLLISION
|
||||
ICurveComposite* _pCompoFxt = CreateCurveComposite() ;
|
||||
_pCompoFxt->AddPoint( bFxtBox.GetMin()) ;
|
||||
_pCompoFxt->AddLine( bFxtBox.GetMin() + X_AX * bFxtBox.GetDimX()) ;
|
||||
_pCompoFxt->AddLine( bFxtBox.GetMax() - Z_AX * bFxtBox.GetDimZ()) ;
|
||||
_pCompoFxt->AddLine( bFxtBox.GetMin() + Y_AX * bFxtBox.GetDimY()) ;
|
||||
_pCompoFxt->Close() ;
|
||||
_pCompoFxt->SetExtrusion( Z_AX) ;
|
||||
_pCompoFxt->SetThickness( bFxtBox.GetDimZ()) ;
|
||||
int nFxtId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, _pCompoFxt) ;
|
||||
m_pGeomDB->SetMaterial( nFxtId, YELLOW) ;
|
||||
#endif
|
||||
// recupero la TriMesh del Box
|
||||
PtrOwner<ICurveComposite> pCompoFxt( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompoFxt))
|
||||
return false ;
|
||||
pCompoFxt->AddPoint( bFxtBox.GetMin()) ;
|
||||
pCompoFxt->AddLine( bFxtBox.GetMin() + X_AX * bFxtBox.GetDimX()) ;
|
||||
pCompoFxt->AddLine( bFxtBox.GetMax() - Z_AX * bFxtBox.GetDimZ()) ;
|
||||
pCompoFxt->AddLine( bFxtBox.GetMin() + Y_AX * bFxtBox.GetDimY()) ;
|
||||
pCompoFxt->Close() ;
|
||||
CICURVEPVECTOR vpCrvs ;
|
||||
vpCrvs.emplace_back( pCompoFxt) ;
|
||||
PtrOwner<ISurfTriMesh> pStmCollFxt( GetSurfTriMeshByRegionExtrusion( vpCrvs, Z_AX * bFxtBox.GetDimZ())) ;
|
||||
if ( IsNull( pStmCollFxt) || ! pStmCollFxt->IsValid() || pStmCollFxt->GetTriangleCount() == 0)
|
||||
return false ;
|
||||
// recupero la sua proiezione nel piano di sgrossatura come regione piana
|
||||
Plane3d plProj ;
|
||||
if ( ! plProj.Set( frLoc.Orig() - dDepth * frLoc.VersZ(), frLoc.VersZ()))
|
||||
return false ;
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pStmCollFxt->GetSilhouette( plProj, EPS_SMALL, vPL)) // proiezione di 6 triangoli, veloce
|
||||
return false ;
|
||||
// se completamente dietro al piano, non influenza la sgrossatura attuale
|
||||
if ( vPL.empty())
|
||||
continue ;
|
||||
SurfFlatRegionByContours SfrByC ;
|
||||
for ( const PolyLine& PL : vPL) {
|
||||
PtrOwner<ICurveComposite> pCompoLoop( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompoLoop) || ! pCompoLoop->FromPolyLine( PL) ||
|
||||
! SfrByC.AddCurve( Release( pCompoLoop)))
|
||||
return false ;
|
||||
}
|
||||
PtrOwner<ISurfFlatRegion> pSfrFxtColl( SfrByC.GetSurf()) ;
|
||||
if ( IsNull( pSfrFxtColl) || ! pSfrFxtColl->IsValid())
|
||||
return false ;
|
||||
if ( AreOppositeVectorApprox( pSfrFxtColl->GetNormVersor(), frLoc.VersZ()))
|
||||
pSfrFxtColl->Invert() ;
|
||||
// aggiorno la regione di collissione per l'utensile
|
||||
if ( ! pSfrColl->IsValid()) {
|
||||
if ( ! pSfrColl->CopyFrom( pSfrFxtColl))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! pSfrColl->Add( *pSfrFxtColl))
|
||||
return false ;
|
||||
}
|
||||
#if ENABLE_DEBUG_SFR_COLLISION
|
||||
ISurfFlatRegion* _pSfrFxt = CreateSurfFlatRegion() ;
|
||||
_pSfrFxt->CopyFrom( pSfrFxtColl) ;
|
||||
int _nSfrFxtId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, _pSfrFxt) ;
|
||||
m_pGeomDB->SetMaterial( _nSfrFxtId, Color( 255, 255, 0, 50)) ;
|
||||
#endif
|
||||
}
|
||||
#if ENABLE_DEBUG_SFR_COLLISION
|
||||
ISurfFlatRegion* _pSfrFxt = CreateSurfFlatRegion() ;
|
||||
_pSfrFxt->CopyFrom( pSfrFxtColl) ;
|
||||
int _nSfrFxtId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, _pSfrFxt) ;
|
||||
m_pGeomDB->SetMaterial( _nSfrFxtId, Color( 255, 255, 0, 50)) ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2595,6 +2607,9 @@ SurfRoughing::GetToolCollisionRegion( const ISurfFlatRegion* pSfrSgro, double& d
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non ho una superficie di Blocco, allora non devo fare nulla
|
||||
if ( IsNull( pSfrBlock) || ! pSfrBlock->IsValid())
|
||||
return true ;
|
||||
|
||||
// determino la superficie di collisione
|
||||
pSfrColl->Clear() ;
|
||||
|
||||
Reference in New Issue
Block a user