EgtExecutor :
- correzione a ExeGetPartClusterCenterGlob.
This commit is contained in:
@@ -2007,7 +2007,7 @@ ExeGetPartClusterCenterGlob( const INTVECTOR& vIds, Point3d& ptCen)
|
||||
return false ;
|
||||
|
||||
// Recupero il centro della regione associata ad ogni oggetto
|
||||
int nCount = 0 ;
|
||||
double dTotArea = 0 ;
|
||||
ptCen = ORIG ;
|
||||
for ( auto nTrueId : vTrueIds) {
|
||||
// recupero regione del pezzo
|
||||
@@ -2015,26 +2015,29 @@ ExeGetPartClusterCenterGlob( const INTVECTOR& vIds, Point3d& ptCen)
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nRegId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
// ne ricavo il centro
|
||||
// ne ricavo il centro e l'area
|
||||
Point3d ptRcen ;
|
||||
if ( ! pSfr->GetCentroid( ptRcen))
|
||||
return false ;
|
||||
double dArea ;
|
||||
if ( ! pSfr->GetArea( dArea))
|
||||
return false ;
|
||||
// lo porto in globale
|
||||
Frame3d frRef ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nRegId, frRef))
|
||||
return false ;
|
||||
ptRcen.ToGlob( frRef) ;
|
||||
// lo sommo al centro complessivo
|
||||
ptCen += ptRcen ;
|
||||
++ nCount ;
|
||||
ptCen += ptRcen * dArea ;
|
||||
dTotArea += dArea ;
|
||||
}
|
||||
|
||||
// Verifico di aver trovato qualcosa
|
||||
if ( nCount == 0)
|
||||
if ( dTotArea < EPS_SMALL * EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// Medio il centro
|
||||
ptCen /= nCount ;
|
||||
ptCen /= dTotArea ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user