EgtMachKernel :
- aggiunta funzione KeepFixture - estesa funzione KeepRawPart.
This commit is contained in:
+16
-3
@@ -396,7 +396,7 @@ Disposition::Apply( bool bVerifyTab)
|
||||
}
|
||||
break ;
|
||||
case MoveRawData::ROT :
|
||||
if ( ! ApplyRotationToRawPart( vMvrData.nRawId, vMvrData.ptP.x, vMvrData.ptP.y, vMvrData.ptP.z)) {
|
||||
if ( ! ApplyRotationToRawPart( vMvrData.nRawId, vMvrData.ptP.x, vMvrData.ptP.y, vMvrData.ptP.z, false)) {
|
||||
string sOut = "Error in ApplyRotationToRawPart " + ToString( vMvrData.nRawId) ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
}
|
||||
@@ -860,7 +860,7 @@ Disposition::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg)
|
||||
Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg, bool bAddToList)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( m_pMchMgr == nullptr || ! m_pMchMgr->VerifyRawPart( nRawId, false))
|
||||
@@ -880,6 +880,17 @@ Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADe
|
||||
return false ;
|
||||
// eseguo spostamento per riportare il centro nella posizione originale
|
||||
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) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -905,7 +916,8 @@ Disposition::RemoveRawPart( int nRawId)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::GetFixtureData( int nInd, string& sName, int& nId, Point3d& ptPos, double& dAngDeg) const
|
||||
Disposition::GetFixtureData( int nInd, string& sName, int& nId, Point3d& ptPos,
|
||||
double& dAngDeg, double& dMov) const
|
||||
{
|
||||
// verifico MachMgr e GeomDB
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
||||
@@ -918,6 +930,7 @@ Disposition::GetFixtureData( int nInd, string& sName, int& nId, Point3d& ptPos,
|
||||
nId = m_vFixData[nInd].nId ;
|
||||
ptPos = m_vFixData[nInd].ptPos ;
|
||||
dAngDeg = m_vFixData[nInd].dAng ;
|
||||
dMov = m_vFixData[nInd].dMov ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -96,9 +96,10 @@ class Disposition : public Operation
|
||||
bool MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList = true) ;
|
||||
bool MoveRawPart( int nRawId, const Vector3d& vtMove) ;
|
||||
bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ;
|
||||
bool ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg) ;
|
||||
bool ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg, bool bAddToList = true) ;
|
||||
bool RemoveRawPart( int nRawId) ;
|
||||
bool GetFixtureData( int nInd, std::string& sName, int& nId, Point3d& ptPos, double& dAngDeg) const ;
|
||||
bool GetFixtureData( int nInd, std::string& sName, int& nId, Point3d& ptPos,
|
||||
double& dAngDeg, double& dMov) const ;
|
||||
bool GetMoveRawData( int nInd, int& nRawId, int& nType, Point3d& ptPos, int& nFlag) const ;
|
||||
bool SpecialApply( bool bRecalc) ;
|
||||
bool GetToolData( string& sName, string& sHead, int& nExit) const ;
|
||||
|
||||
+6
-3
@@ -182,8 +182,9 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
|
||||
int nId ;
|
||||
Point3d ptPos ;
|
||||
double dAngDeg ;
|
||||
if ( pDisp->GetFixtureData( i, sName, nId, ptPos, dAngDeg)) {
|
||||
if ( ! OnFixtureData( nId, i + 1, sName, ptPos, dAngDeg))
|
||||
double dMov ;
|
||||
if ( pDisp->GetFixtureData( i, sName, nId, ptPos, dAngDeg, dMov)) {
|
||||
if ( ! OnFixtureData( nId, i + 1, sName, ptPos, dAngDeg, dMov))
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
@@ -617,7 +618,8 @@ Generator::OnTableData( const string& sName, const Point3d& ptOri1)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Generator::OnFixtureData( int nFixId, int nFixInd, const string& sName, const Point3d& ptPos, double dAngDeg)
|
||||
Generator::OnFixtureData( int nFixId, int nFixInd, const string& sName, const Point3d& ptPos,
|
||||
double dAngDeg, double dMov)
|
||||
{
|
||||
// assegno dati bloccaggio
|
||||
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXID, nFixId) ;
|
||||
@@ -625,6 +627,7 @@ Generator::OnFixtureData( int nFixId, int nFixInd, const string& sName, const Po
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXNAME, sName) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXPOS, ptPos) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXANG, dAngDeg) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIXMOB, dMov) ;
|
||||
// chiamo la funzione di gestione dati bloccaggio
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_FIXTURE_DATA) ;
|
||||
return bOk ;
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ class Generator
|
||||
bool OnDispositionEnd( void) ;
|
||||
bool OnTableData( const std::string& sName, const Point3d& ptOri1) ;
|
||||
bool OnFixtureData( int nFixId, int nFixInd, const std::string& sName,
|
||||
const Point3d& ptPos, double dAngDeg) ;
|
||||
const Point3d& ptPos, double dAngDeg, double dMov) ;
|
||||
bool OnRawMoveData( int nRawId, int RawMoveInd, int nType, const Point3d& ptPos, int nFlag) ;
|
||||
bool OnMachiningStart( int nOpId, int nOpInd, double dSpeed) ;
|
||||
bool OnMachiningEnd( void) ;
|
||||
|
||||
@@ -99,7 +99,7 @@ class MachMgr : public IMachMgr
|
||||
bool ModifyRawPart( int nRawId, int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol) override ;
|
||||
bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) override ;
|
||||
bool ModifyRawPartHeight( int nRawId, double dHeight) override ;
|
||||
bool KeepRawPart( int nRawId) override ;
|
||||
bool KeepRawPart( int nRawId, int nSouPhase) override ;
|
||||
bool VerifyRawPartPhase( int nRawId, int nPhase) const override ;
|
||||
bool RemoveRawPartFromCurrPhase( int nRawId) override ;
|
||||
bool RemoveRawPart( int nRawId) override ;
|
||||
@@ -124,6 +124,7 @@ class MachMgr : public IMachMgr
|
||||
bool GetTableArea( int nInd, BBox3d& b3Area) override ;
|
||||
bool ShowOnlyTable( bool bVal) override ;
|
||||
int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg, double dMov) override ;
|
||||
bool KeepFixture( int nFxtId, int nSouPhase) override ;
|
||||
bool RemoveFixture( int nFxtId) override ;
|
||||
int GetFirstFixture( void) override ;
|
||||
int GetNextFixture( int nFxtId) override ;
|
||||
|
||||
@@ -162,6 +162,39 @@ MachMgr::AddFixture( const string& sName, const Point3d& ptPos, double dAngRotDe
|
||||
return pDisp->AddFixture( sName, ptPos, dAngRotDeg, dMov) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::KeepFixture( int nFxtId, int nSouPhase)
|
||||
{
|
||||
// verifico validità e recupero fasi in cui è presente
|
||||
INTVECTOR vPhase ;
|
||||
if ( ! GetFixturePhases( nFxtId, vPhase))
|
||||
return false ;
|
||||
// se fase corrente già presente, non devo fare alcunché
|
||||
if ( find( vPhase.begin(), vPhase.end(), m_nCurrPhase) != vPhase.end())
|
||||
return true ;
|
||||
// se fase di origine non definita, esco con successo
|
||||
if ( nSouPhase == 0)
|
||||
return true ;
|
||||
// copio il posizionamento
|
||||
Disposition* pSouDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( nSouPhase))) ;
|
||||
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( m_nCurrPhase))) ;
|
||||
if ( pSouDisp == nullptr || pDisp == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; ; ++ i) {
|
||||
string sName ; int nId ; Point3d ptPos ; double dAngDeg ; double dMov ;
|
||||
if ( pSouDisp->GetFixtureData( i, sName, nId, ptPos, dAngDeg, dMov)) {
|
||||
if ( nId == nFxtId) {
|
||||
pDisp->AddFixture( sName, ptPos, dAngDeg, dMov) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::RemoveFixture( int nFxtId)
|
||||
|
||||
+50
-5
@@ -185,6 +185,18 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color
|
||||
nRawId = AddRawPart( nCrvSrfId, cCol) ;
|
||||
// annullo il sovra-materiale
|
||||
dOverMat = 0 ;
|
||||
// calcolo il punto di inserimento nel grezzo
|
||||
// determino l'ingombro del pezzo
|
||||
BBox3d b3Part ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il box del solido del grezzo in globale
|
||||
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
BBox3d b3RawSolid ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolidId, b3RawSolid))
|
||||
return false ;
|
||||
// calcolo il punto di inserimento (come differenza tra i punti minimi)
|
||||
ptRef = b3Part.GetMin() + ( ORIG - b3RawSolid.GetMin()) ;
|
||||
}
|
||||
// se altrimenti grezzo da contorno
|
||||
else if ( ( nGtype & GEO_CURVE) != 0) {
|
||||
@@ -229,9 +241,12 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color
|
||||
// se definita tavola, aggiusto posizione del grezzo
|
||||
Point3d ptTabRef ;
|
||||
if ( GetTableRef( 1, ptTabRef)) {
|
||||
BBox3d b3Raw ;
|
||||
m_pGeomDB->GetGlobalBBox( nRawId, b3Raw) ;
|
||||
m_pGeomDB->TranslateGlob( nRawId, ptTabRef - b3Raw.GetMin()) ;
|
||||
// recupero box del solido
|
||||
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
BBox3d b3RawSolid ;
|
||||
// lo porto nell'angolo in basso a sinistra della tavola
|
||||
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3RawSolid))
|
||||
m_pGeomDB->TranslateGlob( nRawId, ptTabRef - b3RawSolid.GetMin()) ;
|
||||
}
|
||||
// inserisco il pezzo nel grezzo
|
||||
if ( ! AddPartToRawPart( nPartId, ptRef, nRawId)) {
|
||||
@@ -534,7 +549,7 @@ MachMgr::GetRawPartPhases( int nRawId, INTVECTOR& vPhase) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::KeepRawPart( int nRawId)
|
||||
MachMgr::KeepRawPart( int nRawId, int nSouPhase)
|
||||
{
|
||||
// verifico validità e recupero fasi in cui è presente
|
||||
INTVECTOR vPhase ;
|
||||
@@ -550,7 +565,37 @@ MachMgr::KeepRawPart( int nRawId)
|
||||
// visualizzo il grezzo e ne attivo i pezzi
|
||||
if ( ! m_pGeomDB->SetStatus( nRawId, GDB_ST_ON))
|
||||
return false ;
|
||||
return SwapRawPartParts( nRawId, true) ;
|
||||
if ( ! SwapRawPartParts( nRawId, true))
|
||||
return false ;
|
||||
// se fase di origine non definita, esco con successo
|
||||
if ( nSouPhase == 0)
|
||||
return true ;
|
||||
// copio il posizionamento
|
||||
Disposition* pSouDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( nSouPhase))) ;
|
||||
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( GetPhaseDisposition( m_nCurrPhase))) ;
|
||||
if ( pSouDisp == nullptr || pDisp == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; ; ++ i) {
|
||||
int nId ; int nType ; Point3d ptPos ; int nFlag ;
|
||||
if ( pSouDisp->GetMoveRawData( i, nId, nType, ptPos, nFlag)) {
|
||||
if ( nId == nRawId) {
|
||||
switch ( nType) {
|
||||
case MoveRawData::COR :
|
||||
pDisp->MoveToCornerRawPart( nRawId, ptPos, nFlag) ;
|
||||
break ;
|
||||
case MoveRawData::CEN :
|
||||
pDisp->MoveToCenterRawPart( nRawId, ptPos, nFlag) ;
|
||||
break ;
|
||||
case MoveRawData::ROT :
|
||||
pDisp->ApplyRotationToRawPart( nRawId, ptPos.x, ptPos.y, ptPos.z) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -44,6 +44,7 @@ static const std::string GVAR_FIXIND = ".FIXIND" ; // (int) indice blo
|
||||
static const std::string GVAR_FIXNAME = ".FIXNAME" ; // (string) nome bloccaggio
|
||||
static const std::string GVAR_FIXPOS = ".FIXPOS" ; // (Point3d) posizione bloccaggio
|
||||
static const std::string GVAR_FIXANG = ".FIXANG" ; // (num) angolo di rotazione bloccaggio
|
||||
static const std::string GVAR_FIXMOB = ".FIXMOB" ; // (num) movimento eventuale parte mobile del bloccaggio
|
||||
static const std::string GVAR_RAWID = ".RAWID" ; // (int) identificativo grezzo
|
||||
static const std::string GVAR_RAWIND = ".RAWIND" ; // (int) indice movimento del grezzo
|
||||
static const std::string GVAR_RAWTYPE = ".RAWTYPE" ; // (int) tipo di movimento del grezzo
|
||||
|
||||
Reference in New Issue
Block a user