EgtMachKernel 1.8g1 :
- gestione rototraslazione grezzi sempre come R-T.
This commit is contained in:
+151
-46
@@ -408,14 +408,14 @@ Disposition::Apply( bool bVerifyTab)
|
||||
for ( const auto& vMvrData : m_vMvrData) {
|
||||
switch ( vMvrData.nType) {
|
||||
case MoveRawData::COR :
|
||||
if ( ! MoveToCornerRawPart( vMvrData.nRawId, vMvrData.ptP, vMvrData.nFlag, false)) {
|
||||
if ( ! MoveToCornerRawPart( vMvrData.nRawId, vMvrData.ptP, vMvrData.nFlag, false, false)) {
|
||||
string sOut = "Error in MoveToCornerRawPart " + ToString( vMvrData.nRawId) ;
|
||||
m_pMchMgr->SetLastError( 2003, sOut.c_str()) ;
|
||||
bOk = false ;
|
||||
}
|
||||
break ;
|
||||
case MoveRawData::CEN :
|
||||
if ( ! MoveToCenterRawPart( vMvrData.nRawId, vMvrData.ptP, vMvrData.nFlag, false)) {
|
||||
if ( ! MoveToCenterRawPart( vMvrData.nRawId, vMvrData.ptP, vMvrData.nFlag, false, false)) {
|
||||
string sOut = "Error in MoveToCenterRawPart " + ToString( vMvrData.nRawId) ;
|
||||
m_pMchMgr->SetLastError( 2004, sOut.c_str()) ;
|
||||
bOk = false ;
|
||||
@@ -745,7 +745,7 @@ Disposition::RemoveFixture( int nId)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList)
|
||||
Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList, bool bVerify)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
|
||||
@@ -772,9 +772,9 @@ Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMax().x, b3Raw.GetMin().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
// verifico se il grezzo nella posizione finale sarà nella tavola
|
||||
// se richiesto, verifico se il grezzo nella posizione finale sarà nella tavola
|
||||
b3Raw.Translate( vtMove) ;
|
||||
if ( ! m_b3Area1.EnclosesXY( b3Raw))
|
||||
if ( bVerify && ! m_b3Area1.EnclosesXY( b3Raw))
|
||||
return false ;
|
||||
// recupero eventuale spostamento corrente della tavola
|
||||
Vector3d vtDelta1 ;
|
||||
@@ -786,22 +786,14 @@ Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
|
||||
if ( ! vtTotMove.IsSmall())
|
||||
m_pGeomDB->TranslateGlob( nRawId, vtTotMove) ;
|
||||
// se da aggiungere alla lista
|
||||
if ( bAddToList) {
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::COR, ptP, nFlag) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::COR, ptP, nFlag) ;
|
||||
}
|
||||
if ( bAddToList)
|
||||
InsertMoveInfoInList( nRawId, MoveRawData::COR, ptP, nFlag) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList)
|
||||
Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList, bool bVerify)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
|
||||
@@ -834,9 +826,9 @@ Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( ptCen.x, ptCen.y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
// verifico se il grezzo nella posizione finale sarà nella tavola
|
||||
// se richiesto, verifico se il grezzo nella posizione finale sarà nella tavola
|
||||
b3Raw.Translate( vtMove) ;
|
||||
if ( ! m_b3Area1.EnclosesXY( b3Raw))
|
||||
if ( bVerify && ! m_b3Area1.EnclosesXY( b3Raw))
|
||||
return false ;
|
||||
// recupero eventuale spostamento corrente della tavola
|
||||
Vector3d vtDelta1 ;
|
||||
@@ -848,16 +840,8 @@ Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
|
||||
if ( ! vtTotMove.IsSmall())
|
||||
m_pGeomDB->TranslateGlob( nRawId, vtTotMove) ;
|
||||
// se da aggiungere alla lista
|
||||
if ( bAddToList) {
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::CEN, ptP, nFlag) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::CEN, ptP, nFlag) ;
|
||||
}
|
||||
if ( bAddToList)
|
||||
InsertMoveInfoInList( nRawId, MoveRawData::CEN, ptP, nFlag) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -871,12 +855,13 @@ Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove)
|
||||
// se movimento nullo, non devo fare alcunché
|
||||
if ( vtMove.IsSmall())
|
||||
return true ;
|
||||
// verifico ci sia già un movimento assoluto di questo grezzo
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
// cerco il movimento di traslazione assoluto di questo grezzo (per sicurezza cerco l'ultimo)
|
||||
auto rTras = find_if( m_vMvrData.rbegin(), m_vMvrData.rend(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
// se non c'è non posso fare un movimento incrementale
|
||||
if ( rTras == m_vMvrData.rend())
|
||||
return false ;
|
||||
// recupero il solido
|
||||
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
@@ -896,7 +881,7 @@ Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove)
|
||||
// eseguo traslazione in globale
|
||||
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
// aggiorno comando di movimento
|
||||
iIter->ptP += vtMove ;
|
||||
rTras->ptP += vtMove ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -911,6 +896,12 @@ Disposition::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
||||
Point3d ptAx ;
|
||||
if ( ! m_pMchMgr->GetRawPartCenter( nRawId, ptAx))
|
||||
return false ;
|
||||
// recupero il solido
|
||||
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
// recupero box originale del grezzo (solo il solido ovviamente)
|
||||
BBox3d b3OriRaw ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3OriRaw))
|
||||
return false ;
|
||||
// eseguo rotazione in globale attorno al centro del grezzo
|
||||
if ( ! m_pGeomDB->RotateGlob( nRawId, ptAx, vtAx, dAngRotDeg))
|
||||
return false ;
|
||||
@@ -920,14 +911,77 @@ Disposition::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
||||
// ne calcolo gli angoli di Eulero
|
||||
double dAngCDeg, dAngADeg, dAngC1Deg ;
|
||||
frRaw.GetRotationsCAC1( dAngCDeg, dAngADeg, dAngC1Deg) ;
|
||||
// aggiungo o modifico nella lista
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
// cerco eventuale traslazione di questo grezzo
|
||||
auto iTras = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId && Mrv.nType == MoveRawData::ROT) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
// Se c'è traslazione
|
||||
if ( iTras != m_vMvrData.end()) {
|
||||
// determino il box del grezzo (solo il solido ovviamente)
|
||||
BBox3d b3Raw ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
|
||||
return false ;
|
||||
// determino la traslazione correttiva da apportare
|
||||
Vector3d vtCorr ;
|
||||
if ( iTras->nType == MoveRawData::COR) {
|
||||
switch ( iTras->nFlag) {
|
||||
case MCH_CR_TL :
|
||||
vtCorr = Vector3d( b3Raw.GetMin().x - b3OriRaw.GetMin().x, b3Raw.GetMax().y - b3OriRaw.GetMax().y, b3Raw.GetMin().z - b3OriRaw.GetMin().z) ;
|
||||
break ;
|
||||
case MCH_CR_TR :
|
||||
vtCorr = Vector3d( b3Raw.GetMax().x - b3OriRaw.GetMax().x, b3Raw.GetMax().y - b3OriRaw.GetMax().y, b3Raw.GetMin().z - b3OriRaw.GetMin().z) ;
|
||||
break ;
|
||||
default : // RPCP_BL
|
||||
vtCorr = Vector3d( b3Raw.GetMin().x - b3OriRaw.GetMin().x, b3Raw.GetMin().y - b3OriRaw.GetMin().y, b3Raw.GetMin().z - b3OriRaw.GetMin().z) ;
|
||||
break ;
|
||||
case MCH_CR_BR :
|
||||
vtCorr = Vector3d( b3Raw.GetMax().x - b3OriRaw.GetMax().x, b3Raw.GetMin().y - b3OriRaw.GetMin().y, b3Raw.GetMin().z - b3OriRaw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Point3d ptOriCen ; b3OriRaw.GetCenter( ptOriCen) ;
|
||||
Point3d ptCen ; b3Raw.GetCenter( ptCen) ;
|
||||
switch ( iTras->nFlag) {
|
||||
case MCH_CE_TC :
|
||||
vtCorr = Vector3d( ptCen.x - ptOriCen.x, b3Raw.GetMax().y - b3OriRaw.GetMax().y, ptCen.z - ptOriCen.z) ;
|
||||
break ;
|
||||
default : // RPCE_ML
|
||||
vtCorr = Vector3d( b3Raw.GetMin().x - b3OriRaw.GetMin().x, ptCen.y - ptOriCen.y, ptCen.z - ptOriCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_MR :
|
||||
vtCorr = Vector3d( b3Raw.GetMax().x - b3OriRaw.GetMax().x, ptCen.y - ptOriCen.y, ptCen.z - ptOriCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_BC :
|
||||
vtCorr = Vector3d( ptCen.x - ptOriCen.x, b3Raw.GetMin().y - b3OriRaw.GetMin().y, ptCen.z - ptOriCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_MC :
|
||||
vtCorr = Vector3d( ptCen.x - ptOriCen.x, ptCen.y - ptOriCen.y, b3Raw.GetMin().z - b3OriRaw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
// recupero eventuale spostamento corrente della tavola
|
||||
Vector3d vtDelta1 ;
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMch == nullptr || ! pMch->GetCurrTableDeltaRef1( vtDelta1))
|
||||
return false ;
|
||||
// verifico se il grezzo nella posizione finale sarà nella tavola (espressa in posizione 0)
|
||||
b3Raw.Translate( - vtDelta1) ;
|
||||
if ( ! m_b3Area1.EnclosesXY( b3Raw)) {
|
||||
m_pGeomDB->RotateGlob( nRawId, ptAx, vtAx, - dAngRotDeg) ;
|
||||
return false ;
|
||||
}
|
||||
// modifico valore traslazione che verrà spostata dopo rotazione
|
||||
iTras->ptP += vtCorr ;
|
||||
// aggiungo o modifico nella lista
|
||||
InsertMoveInfoInList( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// aggiungo o modifico nella lista
|
||||
InsertMoveInfoInList( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -955,14 +1009,65 @@ Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADe
|
||||
pfrRaw->Translate( ptCen - ptNewCen) ;
|
||||
// se da aggiungere alla lista
|
||||
if ( bAddToList) {
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
// non ci sono problemi di compensazione della traslazione perchè già processata precedentemente in RotateRawPart
|
||||
InsertMoveInfoInList( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::InsertMoveInfoInList( int nRawId, int nType, const Point3d& ptP, int nFlag)
|
||||
{
|
||||
// verifico il tipo
|
||||
if ( nType != MoveRawData::COR && nType != MoveRawData::CEN && nType != MoveRawData::ROT)
|
||||
return false ;
|
||||
|
||||
// cerco traslazione di questo grezzo
|
||||
auto iTras = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
// cerco rotazione di questo grezzo
|
||||
auto iRot = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
Mrv.nType == MoveRawData::ROT) ; }) ;
|
||||
// entrambi presenti
|
||||
if ( iTras != m_vMvrData.end() && iRot != m_vMvrData.end()) {
|
||||
// se traslazione precede rotazione, li scambio come contenuto e come iteratori
|
||||
if ( iTras < iRot) {
|
||||
swap( *iTras, *iRot) ;
|
||||
swap( iTras, iRot) ;
|
||||
}
|
||||
// se inserimento traslazione
|
||||
if ( nType != MoveRawData::ROT)
|
||||
*iTras = MoveRawData( nRawId, nType, ptP, nFlag) ;
|
||||
// altrimenti
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
*iRot = MoveRawData( nRawId, nType, ptP, nFlag) ;
|
||||
}
|
||||
// presente solo traslazione
|
||||
else if ( iTras != m_vMvrData.end()) {
|
||||
// se inserimento traslazione, la modifico
|
||||
if ( nType != MoveRawData::ROT)
|
||||
*iTras = MoveRawData( nRawId, nType, ptP, nFlag) ;
|
||||
// altrimenti inserisco rotazione subito prima della traslazione
|
||||
m_vMvrData.emplace( iTras, nRawId, nType, ptP, nFlag) ;
|
||||
}
|
||||
// presente solo rotazione
|
||||
else if ( iRot != m_vMvrData.end()) {
|
||||
// se inserimento traslazione, la inserisco subito dopo la rotazione
|
||||
if ( nType != MoveRawData::ROT)
|
||||
m_vMvrData.emplace( iRot + 1, nRawId, nType, ptP, nFlag) ;
|
||||
// altrimenti la modifico
|
||||
else
|
||||
*iRot = MoveRawData( nRawId, nType, ptP, nFlag) ;
|
||||
}
|
||||
// assenti
|
||||
else {
|
||||
// inserisco alla fine
|
||||
m_vMvrData.emplace_back( nRawId, nType, ptP, nFlag) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user