EgtExecutor :

- migliorie a nesting (allineamento e rotazione).
This commit is contained in:
Dario Sassi
2016-01-12 18:31:23 +00:00
parent f937996c27
commit 80631d875e
+72 -17
View File
@@ -581,24 +581,26 @@ MyMovePartCluster( const INTVECTOR& vIds, bool bReducedCut, Vector3d& vtMove,
return false ;
// Log provvisorio
if ( false && s_scInfo.nType != SCI_NONE) {
string sOut = "Id1=" + ToString( s_scInfo.nIdM) + " Id2=" + ToString( s_scInfo.nIdF) + " Info type=" ;
switch ( s_scInfo.nType) {
case SCI_NONE : sOut += "NONE" ; break ;
case SCI_PNT_PNT : sOut += "PNT_PNT" ; break ;
case SCI_PNT_LINE : sOut += "PNT_LINE" ; break ;
case SCI_LINE_PNT : sOut += "LINE_PNT" ; break ;
case SCI_LINE_LINE : sOut += "LINE_LINE" ; break ;
if ( false) {
if ( s_scInfo.nType != SCI_NONE) {
string sOut = "Id1=" + ToString( s_scInfo.nIdM) + " Id2=" + ToString( s_scInfo.nIdF) + " Info type=" ;
switch ( s_scInfo.nType) {
case SCI_NONE : sOut += "NONE" ; break ;
case SCI_PNT_PNT : sOut += "PNT_PNT" ; break ;
case SCI_PNT_LINE : sOut += "PNT_LINE" ; break ;
case SCI_LINE_PNT : sOut += "LINE_PNT" ; break ;
case SCI_LINE_LINE : sOut += "LINE_LINE" ; break ;
}
sOut += " Crv1=" + ToString( s_scInfo.nCrvM) + " Crv2=" + ToString( s_scInfo.nCrvF) ;
sOut += " ptA=(" + ToString( s_scInfo.ptP1) + ")" ;
if ( s_scInfo.nType == SCI_LINE_LINE)
sOut += " ptB=(" + ToString( s_scInfo.ptP2) + ")" ;
if ( s_scInfo.nType == SCI_LINE_PNT || s_scInfo.nType == SCI_LINE_LINE)
sOut += " Dir1=(" + ToString( s_scInfo.vtDirM) + ")" ;
if ( s_scInfo.nType == SCI_PNT_LINE || s_scInfo.nType == SCI_LINE_LINE)
sOut += " Dir2=(" + ToString( s_scInfo.vtDirF) + ")" ;
LOG_INFO( GetLogger(), sOut.c_str()) ;
}
sOut += " Crv1=" + ToString( s_scInfo.nCrvM) + " Crv2=" + ToString( s_scInfo.nCrvF) ;
sOut += " ptA=(" + ToString( s_scInfo.ptP1) + ")" ;
if ( s_scInfo.nType == SCI_LINE_LINE)
sOut += " ptB=(" + ToString( s_scInfo.ptP2) + ")" ;
if ( s_scInfo.nType == SCI_LINE_PNT || s_scInfo.nType == SCI_LINE_LINE)
sOut += " Dir1=(" + ToString( s_scInfo.vtDirM) + ")" ;
if ( s_scInfo.nType == SCI_PNT_LINE || s_scInfo.nType == SCI_LINE_LINE)
sOut += " Dir2=(" + ToString( s_scInfo.vtDirF) + ")" ;
LOG_INFO( GetLogger(), sOut.c_str()) ;
}
// Se movimento risultante nullo, non faccio alcunché
@@ -810,6 +812,59 @@ ExeRotatePartCluster( const INTVECTOR& vIds, bool bReducedCut, const Point3d& pt
return true ;
}
//----------------------------------------------------------------------------
bool
ExeAlignPartClusterOnCollision( const INTVECTOR& vIds, bool bReducedCut,
double dXmin, double dYmin, double dXmax, double dYmax)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// verifico sia collisione punto->linea
if ( s_scInfo.nType != SCI_PNT_LINE)
return false ;
// recupero la regione mobile interessata dalla collision
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( s_scInfo.nIdM)) ;
if ( pSfr == nullptr)
return false ;
// recupero il suo sistema di riferimento
Frame3d frSfr ;
if ( ! pGeomDB->GetGlobFrame( s_scInfo.nIdM, frSfr))
return false ;
// porto il punto di contatto nel riferimento della superficie
Point3d ptCntL = s_scInfo.ptP1 ;
ptCntL.ToLoc( frSfr) ;
// cerco le direzioni tangenti prima e dopo il punto di contatto sulle parti mobili
PtrOwner<ICurve> pCrv( pSfr->GetLoop( s_scInfo.nChunkM, 0)) ;
if ( IsNull( pCrv))
return false ;
double dU ;
if ( ! pCrv->GetParamAtPoint( ptCntL, dU, 10 * EPS_SMALL))
return false ;
Point3d ptPp ;
Vector3d vtTp ;
if ( ! pCrv->GetPointTang( dU, ICurve::FROM_MINUS, ptPp, vtTp))
return false ;
Point3d ptPn ;
Vector3d vtTn ;
if ( ! pCrv->GetPointTang( dU, ICurve::FROM_PLUS, ptPn, vtTn))
return false ;
// verifico che le tangenti siano diverse
if ( AreSameVectorApprox( vtTp, vtTn))
return false ;
// porto le tangenti nel riferimento globale e le confronto con la tangente dell'ostacolo
vtTp.ToGlob( frSfr) ;
vtTn.ToGlob( frSfr) ;
if ( false) {
string sOut = "vtTp=(" + ToString( vtTp) + ") vtTn=(" + ToString( vtTn) + ")" ;
LOG_INFO( GetLogger(), sOut.c_str()) ;
}
// ruoto dalla parte dell'angolo più piccolo (componente più grande)
double dRotAngDeg = ( abs( vtTp * s_scInfo.vtDirF) > abs( vtTn * s_scInfo.vtDirF)) ? 90 : - 90 ;
// provo a ruotare sul punto di collisione in senso orario
Point3d ptCen = s_scInfo.ptP1 ;
return ExeRotatePartCluster( vIds, bReducedCut, ptCen, dRotAngDeg, dXmin, dYmin, dXmax, dYmax) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetPartClusterCenterGlob( const INTVECTOR& vIds, Point3d& ptCen)