EgtMachKernel 1.6k10 :

- sistemazioni varie in grezzi, lavorazioni, ....
This commit is contained in:
Dario Sassi
2015-12-07 08:03:39 +00:00
parent 5eb5cb387f
commit 42e1a696a1
33 changed files with 1354 additions and 277 deletions
+19 -1
View File
@@ -22,7 +22,7 @@
using namespace std ;
//----------------------------------------------------------------------------
static int CAM_TOTPARAM = 9 ;
static int CAM_TOTPARAM = 10 ;
static std::string CAM_CORR = "Corr" ;
static std::string CAM_TDIR = "TDir" ;
static std::string CAM_CDIR = "CDir" ;
@@ -31,6 +31,7 @@ static std::string CAM_PBAS = "PBas" ;
static std::string CAM_FEED = "Feed" ;
static std::string CAM_FLAG = "Flg" ;
static std::string CAM_AXSTS = "AxS" ;
static std::string CAM_AXMSK = "AxM" ;
static std::string CAM_AXVAL = "AxV" ;
//----------------------------------------------------------------------------
@@ -58,8 +59,12 @@ CamData::Clone( void) const
pCam->m_vtTool = m_vtTool ;
pCam->m_vtCorr = m_vtCorr ;
pCam->m_vtAux = m_vtAux ;
pCam->m_ptBase = m_ptBase ;
pCam->m_dFeed = m_dFeed ;
pCam->m_nFlag = m_nFlag ;
pCam->m_nAxesStatus = m_nAxesStatus ;
pCam->m_nAxesMask = m_nAxesMask ;
pCam->m_vMachAxes = m_vMachAxes ;
}
catch( ...) {
delete pCam ;
@@ -83,6 +88,7 @@ CamData::Dump( string& sOut, bool bMM, const char* szNewLine) const
sOut += CAM_FEED + "=" + ToString( m_dFeed) + szNewLine ;
sOut += CAM_FLAG + "=" + ToString( m_nFlag) + szNewLine ;
sOut += CAM_AXSTS + "=" + ToString( m_nAxesStatus) + szNewLine ;
sOut += CAM_AXMSK + "=" + ToString( m_nAxesMask) + szNewLine ;
sOut += CAM_AXVAL + "=" + ToString( m_vMachAxes) + szNewLine ;
return true ;
@@ -126,6 +132,7 @@ CamData::Save( STRVECTOR& vString) const
vString[++k] = CAM_FEED + "=" + ToString( m_dFeed) ;
vString[++k] = CAM_FLAG + "=" + ToString( m_nFlag) ;
vString[++k] = CAM_AXSTS + "=" + ToString( m_nAxesStatus) ;
vString[++k] = CAM_AXMSK + "=" + ToString( m_nAxesMask) ;
vString[++k] = CAM_AXVAL + "=" + ToString( m_vMachAxes) ;
}
catch( ...) {
@@ -149,6 +156,7 @@ CamData::Load( const STRVECTOR& vString)
! GetVal( vString[++k], CAM_FEED, m_dFeed) ||
! GetVal( vString[++k], CAM_FLAG, m_nFlag) ||
! GetVal( vString[++k], CAM_AXSTS, m_nAxesStatus) ||
! GetVal( vString[++k], CAM_AXMSK, m_nAxesMask) ||
! GetVal( vString[++k], CAM_AXVAL, m_vMachAxes))
return false ;
return true ;
@@ -388,6 +396,7 @@ CamData::CamData( void)
m_dFeed = 0 ;
m_nFlag = 0 ;
m_nAxesStatus = AS_NONE ;
m_nAxesMask = 0x00 ;
m_vMachAxes.reserve( 8) ;
}
@@ -451,6 +460,15 @@ CamData::SetAxes( int nStatus, const DBLVECTOR& vAxVal)
return false ;
m_nAxesStatus = nStatus ;
m_vMachAxes = vAxVal ;
m_nAxesMask = ( 1 << vAxVal.size()) - 1 ;
return true ;
}
//----------------------------------------------------------------------------
bool
CamData::ChangeAxesMask( int nMask)
{
m_nAxesMask = ( nMask & (( 1 << m_vMachAxes.size()) - 1)) ;
return true ;
}
+10 -1
View File
@@ -52,6 +52,7 @@ class CamData : public IUserObj
bool SetFeed( double dFeed) ;
bool SetFlag( int nFlag) ;
bool SetAxes( int nStatus, const DBLVECTOR& vAxVal) ;
bool ChangeAxesMask( int nMask) ;
bool ResetAxes( void)
{ m_nAxesStatus = AS_NONE ; return true ; }
const Vector3d& GetToolDir( void) const
@@ -68,6 +69,8 @@ class CamData : public IUserObj
{ return m_nFlag ; }
int GetAxesStatus( void) const
{ return m_nAxesStatus ; }
int GetAxesMask( void) const
{ return m_nAxesMask ; }
const DBLVECTOR& GetAxisVal( void) const
{ return m_vMachAxes ; }
@@ -77,6 +80,11 @@ class CamData : public IUserObj
AS_OUTSTROKE = 2,
AS_DIR_ERR = 3,
AS_ERR = 4} ;
enum { MSK_L1 = 1,
MSK_L2 = 2,
MSK_L3 = 4,
MSK_R1 = 8,
MSK_R2 = 16} ;
private :
void ResetObjGraphics( void) ;
@@ -91,6 +99,7 @@ class CamData : public IUserObj
Point3d m_ptBase ; // punto base per il disegno dei vettori
double m_dFeed ; // velocità di avanzamento in lavorazione
int m_nFlag ; // flag per usi vari
int m_nAxesStatus ; // stato dei valori assi
int m_nAxesStatus ; // stato dei valori degli assi
int m_nAxesMask ; // mask di emissione degli assi (bit a bit)
DBLVECTOR m_vMachAxes ; // valori degli assi macchina
} ;
+25 -8
View File
@@ -27,6 +27,8 @@ using namespace std ;
//----------------------------------------------------------------------------
static std::string DIS_TABLE = "Tab" ;
static std::string DIS_REF1 = "Ref1" ;
static std::string DIS_AREA1 = "Area1" ;
static std::string DIS_FXD_TOT = "FxT" ;
static std::string DIS_FXD_NAME = "FxN" ;
static std::string DIS_FXD_POS = "FxP" ;
@@ -56,9 +58,9 @@ Disposition::Clone( void) const
Disposition* pDisp = new(nothrow) Disposition ;
// eseguo copia dei dati
if ( pDisp != nullptr) {
try { pDisp->m_nOwnerId = GDB_ID_NULL ;
pDisp->m_pGeomDB = nullptr ;
pDisp->m_sTabName = m_sTabName ;
try { pDisp->m_sTabName = m_sTabName ;
pDisp->m_ptRef1 = m_ptRef1 ;
pDisp->m_b3Area1 = m_b3Area1 ;
pDisp->m_bTabOk = m_bTabOk ;
pDisp->m_vFixData = m_vFixData ;
pDisp->m_vMvrData = m_vMvrData ;
@@ -78,6 +80,8 @@ Disposition::Dump( string& sOut, bool bMM, const char* szNewLine) const
{
sOut += GetClassName() + "[mm]" + szNewLine ;
sOut += "Tab=" + m_sTabName + ( m_bTabOk ? " (ok)" : " (to verify)") + szNewLine ;
sOut += "Ref1=(" + ToString( m_ptRef1, 3) + ")" + szNewLine ;
sOut += "Area1=(" + ToString( m_b3Area1, 3) + ")" + szNewLine ;
for ( const auto& FixData : m_vFixData) {
sOut += "FxD=" + FixData.sName + "," +
ToString( FixData.nId) + ",(" +
@@ -114,10 +118,16 @@ Disposition::Save( STRVECTOR& vString) const
int nFxdLines = 1 + 3 * nFxdTot ;
int nMvdTot = int( m_vMvrData.size()) ;
int nMvdLines = 1 + 4 * nMvdTot ;
vString.insert( vString.begin(), 1 + nFxdLines + nMvdLines, "") ;
vString.insert( vString.begin(), 3 + nFxdLines + nMvdLines, "") ;
// nome
if ( ! SetVal( DIS_TABLE, m_sTabName, vString[++k]))
return false ;
// Primo riferimento
if ( ! SetVal( DIS_REF1, m_ptRef1, vString[++k]))
return false ;
// Prima area
if ( ! SetVal( DIS_AREA1, m_b3Area1, vString[++k]))
return false ;
// dati sottopezzi
if ( ! SetVal( DIS_FXD_TOT, nFxdTot, vString[++k]))
return false ;
@@ -146,18 +156,24 @@ Disposition::Save( STRVECTOR& vString) const
bool
Disposition::Load( const STRVECTOR& vString)
{
if ( vString.size() < 3)
if ( vString.size() < 5)
return false ;
int k = - 1 ;
// nome
if ( ! GetVal( vString[++k], DIS_TABLE, m_sTabName))
return false ;
// primo riferimento
if ( ! GetVal( vString[++k], DIS_REF1, m_ptRef1))
return false ;
// prima area
if ( ! GetVal( vString[++k], DIS_AREA1, m_b3Area1))
return false ;
// dati sottopezzi
int nFxdTot ;
if ( ! GetVal( vString[++k], DIS_FXD_TOT, nFxdTot))
return false ;
int nFxdLines = 1 + 3 * nFxdTot ;
if ( int( vString.size()) < 1 + nFxdLines + 1)
if ( int( vString.size()) < 3 + nFxdLines + 1)
return false ;
m_vFixData.insert( m_vFixData.begin(), nFxdTot, FixtureData()) ;
for ( auto& FixData : m_vFixData) {
@@ -171,7 +187,7 @@ Disposition::Load( const STRVECTOR& vString)
if ( ! GetVal( vString[++k], DIS_MVD_TOT, nMvdTot))
return false ;
int nMvdLines = 1 + 4 * nMvdTot ;
if ( int( vString.size()) < 1 + nFxdLines + nMvdLines)
if ( int( vString.size()) < 3 + nFxdLines + nMvdLines)
return false ;
m_vMvrData.insert( m_vMvrData.begin(), nMvdTot, MoveRawData()) ;
for ( auto& MvrData : m_vMvrData) {
@@ -645,7 +661,8 @@ Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADe
// recupero riferimento del grezzo (coincide con quello globale)
Frame3d* pfrRaw = m_pGeomDB->GetGroupFrame( nRawId) ;
// lo trasformo nel nuovo riferimento
pfrRaw->Set( pfrRaw->Orig(), dAngCDeg, dAngADeg, dAngC1Deg) ;
Point3d ptOrig = pfrRaw->Orig() ; // necessario copiarlo
pfrRaw->Set( ptOrig, dAngCDeg, dAngADeg, dAngC1Deg) ;
return true ;
}
+66 -39
View File
@@ -59,8 +59,6 @@ Drilling::Clone( void) const
// eseguo copia dei dati
if ( pDri != nullptr) {
try {
pDri->m_nOwnerId = GDB_ID_NULL ;
pDri->m_pGeomDB = nullptr ;
pDri->m_Params = m_Params ;
pDri->m_TParams = m_TParams ;
}
@@ -135,8 +133,6 @@ Drilling::Load( const STRVECTOR& vString)
//----------------------------------------------------------------------------
Drilling::Drilling( void)
{
m_nOwnerId = GDB_ID_NULL ;
m_pGeomDB = nullptr ;
m_Params.m_sName = "*" ;
m_Params.m_sToolName = "*" ;
m_TParams.m_sName = "*" ;
@@ -341,7 +337,14 @@ Drilling::Apply( void)
}
// calcolo gli assi macchina
return CalculateAxesValues() ;
if ( ! CalculateAxesValues())
return false ;
// gestione movimenti all'inizio di ogni singolo percorso di lavorazione
if ( ! AdjustStartMovements())
return false ;
return true ;
}
//----------------------------------------------------------------------------
@@ -438,16 +441,40 @@ Drilling::GetHoleData( SelData Id, Hole& hole)
const ICurveArc* pArc = GetCurveArc( m_pGeomDB->GetGeoObj( Id.nId)) ;
if ( pArc == nullptr)
return false ;
// deve avere estrusione e spessore
double dThick ;
Vector3d vtExtr ;
if ( ! pArc->GetThickness( dThick) || ! pArc->GetExtrusion( vtExtr) ||
( dThick * vtExtr).IsSmall ())
return false ;
// ne recupero il riferimento globale
Frame3d frGlob ;
if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob))
return false ;
// deve avere estrusione
Vector3d vtExtr ;
if ( ! pArc->GetExtrusion( vtExtr))
return false ;
// recupero spessore
double dThick = 0 ;
pArc->GetThickness( dThick) ;
// se diretto come asse Z, recupero distanza da fondo dei grezzi interessati dal foro
double dRbDist = 0 ;
Vector3d vtExtrG = vtExtr ;
vtExtrG.ToGlob( frGlob) ;
if ( vtExtrG.IsZplus())
GetDistanceFromRawBottom( Id.nId, EPS_SMALL, dRbDist) ;
// valuto l'espressione dell'affondamento
ExeLuaSetGlobNumVar( "TH", - dThick) ;
ExeLuaSetGlobNumVar( "RB", dRbDist) ;
double dDepth ;
if ( ! ExeLuaEvalNumExpr( m_Params.m_sDepth, &dDepth)) {
LOG_INFO( GetEMkLogger(), "Depth not computable by Drilling") ;
return false ;
}
if ( fabs( dDepth) < EPS_SMALL) {
LOG_INFO( GetEMkLogger(), "Drill with zero depth") ;
return false ;
}
// foro sempre cieco
bool bBlind = true ;
// se verticale e arriva fino al fondo grezzo, allora passante
if ( vtExtrG.IsZplus() && dDepth > dRbDist - EPS_SMALL)
bBlind = false ;
// assegno Id
hole.nOriId = Id.nId ;
// ne recupero il diametro
@@ -456,12 +483,12 @@ Drilling::GetHoleData( SelData Id, Hole& hole)
hole.ptIni = pArc->GetCenter() ;
hole.ptIni.ToGlob( frGlob) ;
// ne recupero versore direzione e lunghezza
hole.vtDir = (( dThick < 0) ? vtExtr : - vtExtr) ;
hole.vtDir = (( dDepth > 0) ? vtExtr : - vtExtr) ;
hole.vtDir.ToGlob( frGlob) ;
hole.vtDir.Normalize() ;
hole.dLen = fabs( dThick) ;
// lo dichiaro cieco (andrà calcolato opportunamente)
hole.bBlind = true ;
hole.dLen = fabs( dDepth) ;
// cieco/passante
hole.bBlind = bBlind ;
return true ;
}
@@ -490,23 +517,23 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
SetPathId( nPathId) ;
SetToolDir( hole.vtDir) ;
// 1 -> punto approccio
double dAppr = GetApproachDist() ;
SetFlag( 1) ;
double dAppr = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
Point3d ptP1 = hole.ptIni + hole.vtDir * ( dAppr + dTExtrLen) ;
if ( AddStart( ptP1) == GDB_ID_NULL)
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
return false ;
SetFlag( 0) ;
// 2 -> punto fuori (se diverso dal precedente)
if ( m_Params.m_dStartPos < dAppr) {
SetFeed( MAX_FEED) ;
SetFlag( 0) ;
Point3d ptP2 = hole.ptIni + hole.vtDir * ( m_Params.m_dStartPos + dTExtrLen) ;
if ( AddLinearMove( ptP2) == GDB_ID_NULL)
if ( AddRapidMove( ptP2) == GDB_ID_NULL)
return false ;
}
// 3 -> punto termine velocità ridotta iniziale (se previsto)
if ( bStartSlow) {
SetFeed( m_TParams.m_dStartFeed) ;
if ( ! bStd && ! bEndSlow)
SetFlag( 1) ; // fondo del foro
SetFlag( 101) ; // fondo del foro
Point3d ptP3 = hole.ptIni - hole.vtDir * dStartSlowLen ;
if ( ! bStd && ! bEndSlow)
ptP3 -= hole.vtDir * dAddLen ;
@@ -517,7 +544,7 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
if ( bStd) {
SetFeed( m_TParams.m_dFeed) ;
if ( ! bEndSlow)
SetFlag( 1) ; // fondo del foro
SetFlag( 101) ; // fondo del foro
Point3d ptP4 = hole.ptIni - hole.vtDir * ( hole.dLen - dEndSlowLen) ;
if ( ! bEndSlow)
ptP4 -= hole.vtDir * dAddLen ;
@@ -527,13 +554,13 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
// 5 -> punto termine velocità finale ridotta (se previsto)
if ( bEndSlow) {
SetFeed( m_TParams.m_dEndFeed) ;
SetFlag( 1) ; // fondo del foro
SetFlag( 101) ; // fondo del foro
Point3d ptP5 = hole.ptIni - hole.vtDir * ( hole.dLen + dAddLen) ;
if ( AddLinearMove( ptP5) == GDB_ID_NULL)
return false ;
}
// 6 -> ritorno all'approccio del foro
SetFeed( MAX_FEED) ;
SetFeed( m_TParams.m_dEndFeed) ;
SetFlag( 0) ;
if ( AddLinearMove( ptP1) == GDB_ID_NULL)
return false ;
@@ -571,16 +598,16 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
SetPathId( nPathId) ;
SetToolDir( hole.vtDir) ;
// 1 -> punto approccio
double dAppr = GetApproachDist() ;
SetFlag( 1) ;
double dAppr = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
Point3d ptP1 = hole.ptIni + hole.vtDir * ( dAppr + dTExtrLen) ;
if ( AddStart( ptP1) == GDB_ID_NULL)
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
return false ;
SetFlag( 0) ;
// 2 -> punto fuori (se diverso dal precedente)
if ( m_Params.m_dStartPos < dAppr) {
SetFeed( MAX_FEED) ;
SetFlag( 0) ;
Point3d ptP2 = hole.ptIni + hole.vtDir * ( m_Params.m_dStartPos + dTExtrLen) ;
if ( AddLinearMove( ptP2) == GDB_ID_NULL)
if ( AddRapidMove( ptP2) == GDB_ID_NULL)
return false ;
}
// ciclo di affondamento a step
@@ -597,13 +624,13 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
// se non è primo step faccio retrazione e riaffondo
if ( i != 1) {
// retrazione
SetFeed( MAX_FEED) ;
SetFlag( 3) ; // punto di scarico truciolo
SetFeed( m_TParams.m_dEndFeed) ;
SetFlag( 103) ; // punto di scarico truciolo
Point3d ptPr = hole.ptIni + hole.vtDir * dReturnPos ;
if ( AddLinearMove( ptPr) == GDB_ID_NULL)
return false ;
// riaffondo
SetFeed( MAX_FEED) ;
SetFeed( m_TParams.m_dEndFeed) ;
SetFlag( 0) ;
Point3d ptPa = hole.ptIni - hole.vtDir * ( dCurrLen - APPR_STEP) ;
if ( AddLinearMove( ptPa) == GDB_ID_NULL)
@@ -622,9 +649,9 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
// assegno parametri
SetFeed( m_TParams.m_dStartFeed) ;
if ( bHoleEnd)
SetFlag( 1) ; // fondo del foro
SetFlag( 101) ; // fondo del foro
else if ( bStepEnd)
SetFlag( 2) ; // fondo dello step
SetFlag( 102) ; // fondo dello step
// movimento
Point3d ptP3 = hole.ptIni - hole.vtDir * dLen ;
if ( bHoleEnd)
@@ -647,9 +674,9 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
// assegno parametri
SetFeed( m_TParams.m_dFeed) ;
if ( bHoleEnd)
SetFlag( 1) ; // fondo del foro
SetFlag( 101) ; // fondo del foro
else if ( bStepEnd)
SetFlag( 2) ; // fondo dello step
SetFlag( 102) ; // fondo dello step
// movimento
Point3d ptP4 = hole.ptIni - hole.vtDir * dLen ;
if ( bHoleEnd)
@@ -671,9 +698,9 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
// assegno parametri
SetFeed( m_TParams.m_dEndFeed) ;
if ( bHoleEnd)
SetFlag( 1) ; // fondo del foro
SetFlag( 101) ; // fondo del foro
else
SetFlag( 2) ; // fondo dello step
SetFlag( 102) ; // fondo dello step
// movimento
Point3d ptP5 = hole.ptIni - hole.vtDir * dLen ;
if ( bHoleEnd)
@@ -686,7 +713,7 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
}
// 6 -> ritorno all'approccio del foro
SetFeed( MAX_FEED) ;
SetFeed( m_TParams.m_dEndFeed) ;
SetFlag( 0) ;
if ( AddLinearMove( ptP1) == GDB_ID_NULL)
return false ;
+26 -2
View File
@@ -24,7 +24,8 @@ using namespace std ;
//----------------------------------------------------------------------------
enum nDrillingKey {
KEY_INV = 0,
KEY_DH = 0,
KEY_INV,
KEY_LAT,
KEY_LSE,
KEY_LSS,
@@ -38,6 +39,7 @@ enum nDrillingKey {
KEY_ZZZ} ; // rappresenta il numero di elementi
static const std::array<std::string,KEY_ZZZ> sDrillingKey = {
"DH",
"INV",
"LAT",
"LSE",
@@ -86,6 +88,7 @@ DrillingData::CopyFrom( const MachiningData* pMdata)
m_ToolUuid = pDdata->m_ToolUuid ;
m_sToolName = pDdata->m_sToolName ;
m_bInvert = pDdata->m_bInvert ;
m_sDepth = pDdata->m_sDepth ;
m_dStartPos = pDdata->m_dStartPos ;
m_dStartSlowLen = pDdata->m_dStartSlowLen ;
m_dEndSlowLen = pDdata->m_dEndSlowLen ;
@@ -112,6 +115,7 @@ DrillingData::SameAs(const MachiningData* pMdata) const
m_ToolUuid == pDdata->m_ToolUuid &&
m_sToolName == pDdata->m_sToolName &&
m_bInvert == pDdata->m_bInvert &&
m_sDepth == pDdata->m_sDepth &&
m_dStartPos == pDdata->m_dStartPos &&
m_dStartSlowLen == pDdata->m_dStartSlowLen &&
m_dEndSlowLen == pDdata->m_dEndSlowLen &&
@@ -156,6 +160,11 @@ DrillingData::FromString( const string& sString, int& nKey)
nKey = FindDrillingKey( ToUpper( sKey)) ;
bool bOk = ( nKey >= 0) ;
switch ( nKey) {
case KEY_DH :
m_sDepth = sVal ;
if ( m_sDepth.empty())
m_sDepth = "TH" ;
break ;
case KEY_INV :
bOk = ::FromString( sVal, m_bInvert) ;
break ;
@@ -202,6 +211,7 @@ string
DrillingData::ToString( int nInd) const
{
switch ( nInd) {
case KEY_DH : return ( sDrillingKey[KEY_DH] + "=" + m_sDepth) ;
case KEY_INV : return ( sDrillingKey[KEY_INV] + "=" + ::ToString( m_bInvert)) ;
case KEY_LAT : return ( sDrillingKey[KEY_LAT] + "=" + ::ToString( m_dThroughAddLen)) ;
case KEY_LSE : return ( sDrillingKey[KEY_LSE] + "=" + ::ToString( m_dEndSlowLen)) ;
@@ -226,7 +236,7 @@ DrillingData::VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, co
pTdata = pToolsMgr->GetTool( sVal) ;
if ( pTdata == nullptr)
return false ;
if ( ( pTdata->m_nType & TF_DRILLBIT) == 0 ||
if ( ( pTdata->m_nType & TF_DRILLBIT) == 0 &&
pTdata->m_nType != TT_MILL_STD)
return false ;
return true ;
@@ -256,6 +266,9 @@ bool
DrillingData::SetParam( int nType, double dVal)
{
switch ( nType) {
case MPA_DEPTH :
m_sDepth = ::ToString( dVal) ;
return true ;
case MPA_STARTPOS :
m_dStartPos = dVal ;
return true ;
@@ -289,6 +302,9 @@ DrillingData::SetParam( int nType, const string& sVal)
case MPA_TOOL :
m_sToolName = sVal ;
return true ;
case MPA_DEPTH_STR :
m_sDepth = sVal ;
return true ;
case MPA_TUUID :
return ::FromString( sVal, m_ToolUuid) ;
case MPA_UUID :
@@ -313,6 +329,11 @@ DrillingData::GetParam( int nType, bool& bVal) const
bool
DrillingData::GetParam( int nType, int& nVal) const
{
switch ( nType) {
case MPA_TYPE :
nVal = MT_DRILLING ;
return true ;
}
return false ;
}
@@ -354,6 +375,9 @@ DrillingData::GetParam( int nType, string& sVal) const
case MPA_TOOL :
sVal = m_sToolName ;
return true ;
case MPA_DEPTH_STR :
sVal = m_sDepth ;
return true ;
case MPA_TUUID :
sVal = ::ToString( m_ToolUuid) ;
return true ;
+1
View File
@@ -21,6 +21,7 @@ struct DrillingData : public MachiningData
EgtUUID m_ToolUuid ; // identificativo universale dell'utensile
std::string m_sToolName ; // nome dell'utensile
bool m_bInvert ; // flag di inversione direzione lavorazione per fori aperti
std::string m_sDepth ; // affondamento (espressione numerica)
double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0)
double m_dStartSlowLen ; // lunghezza rallentamento iniziale
double m_dEndSlowLen ; // lunghezza rallentamento finale
BIN
View File
Binary file not shown.
+5 -8
View File
@@ -34,10 +34,7 @@
<Filter Include="Source Files\Machinings">
<UniqueIdentifier>{9ebd88f4-45ef-477d-b613-d142baef86fb}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Simulation">
<UniqueIdentifier>{fbbebf38-66cd-4db8-863b-bc1a1cbf95d9}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Generation">
<Filter Include="Source Files\Output">
<UniqueIdentifier>{f3ac3061-c243-4c9a-a852-4c9d92f5842d}</UniqueIdentifier>
</Filter>
</ItemGroup>
@@ -135,14 +132,11 @@
<ClCompile Include="CamData.cpp">
<Filter>Source Files\Operations</Filter>
</ClCompile>
<ClCompile Include="Simulator.cpp">
<Filter>Source Files\Simulation</Filter>
</ClCompile>
<ClCompile Include="MachMgrSimulation.cpp">
<Filter>Source Files\MachMgr</Filter>
</ClCompile>
<ClCompile Include="Generator.cpp">
<Filter>Source Files\Generation</Filter>
<Filter>Source Files\Output</Filter>
</ClCompile>
<ClCompile Include="MachMgrGeneration.cpp">
<Filter>Source Files\MachMgr</Filter>
@@ -156,6 +150,9 @@
<ClCompile Include="MachMgrDBTools.cpp">
<Filter>Source Files\MachMgr</Filter>
</ClCompile>
<ClCompile Include="Simulator.cpp">
<Filter>Source Files\Output</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="DllMain.h">
+7 -2
View File
@@ -75,6 +75,7 @@ static const string GVAR_L2T = ".L2t" ; // (num) token del secon
static const string GVAR_L3T = ".L3t" ; // (num) token del terzo asse lineare
static const string GVAR_R1T = ".R1t" ; // (num) token del primo asse rotante
static const string GVAR_R2T = ".R2t" ; // (num) token del secondo asse rotante
static const string GVAR_MASK = ".MASK" ; // (int) mask associato ai movimenti in rapido
static const string GVAR_FLAG = ".FLAG" ; // (int) flag associato ad ogni movimento
static const string TEMP_VAR = "LOC" ; // tavola variabili locali (temporanee)
static const string ON_START = "OnStart" ;
@@ -362,7 +363,7 @@ Generator::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd,
bool bRapid = ( pCamData->GetFeed() < EPS_SMALL) ;
// Emetto movimento
if ( bRapid) {
if ( ! OnRapid( AxesEnd))
if ( ! OnRapid( AxesEnd, pCamData->GetAxesMask(), pCamData->GetFlag()))
return false ;
}
else {
@@ -651,7 +652,7 @@ Generator::OnPathEnd( void)
//----------------------------------------------------------------------------
bool
Generator::OnRapid( const DBLVECTOR& AxesEnd)
Generator::OnRapid( const DBLVECTOR& AxesEnd, int nAxesMask, int nFlag)
{
// definisco tavola variabili locali (temporanee)
bool bOk = m_pMachine->LuaCreateGlobTable( TEMP_VAR) ;
@@ -663,6 +664,10 @@ Generator::OnRapid( const DBLVECTOR& AxesEnd)
else
bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue(i)) ;
}
// assegno la mascheratura degli assi
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MASK, nAxesMask) ;
// assegno il valore del flag
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, nFlag) ;
// chiamo la funzione di movimento in rapido
bOk = bOk && m_pMachine->LuaCallFunction( ON_RAPID) ;
// cancello variabili locali
+1 -1
View File
@@ -51,7 +51,7 @@ class Generator
bool OnMachiningEnd( void) ;
bool OnPathStart( int nClPathId, int nClPathInd) ;
bool OnPathEnd( void) ;
bool OnRapid( const DBLVECTOR& AxesEnd) ;
bool OnRapid( const DBLVECTOR& AxesEnd, int nAxesMask, int nFlag) ;
bool OnLinear( const DBLVECTOR& AxesEnd, double dFeed, int nFlag) ;
std::string GetGlobVarAxisValue( int nAx) ;
std::string GetGlobVarAxisPrev( int nAx) ;
+2
View File
@@ -37,6 +37,8 @@ const std::string MACH_RAW_PART = "RawPart" ;
const std::string MACH_RAW_SOLID = "RawSolid" ;
// Nome del punto che rappresenta il centro del grezzo
const std::string MACH_RAW_CENTER = "RawCenter" ;
// Nome del contorno esterno del grezzo
const std::string MACH_RAW_OUTLINE = "RawOutline" ;
//----------------------------------------------------------------------------
// Nome sottodirettorio delle fixtures
+5 -1
View File
@@ -78,6 +78,7 @@ class MachMgr : public IMachMgr
virtual int GetNextRawPart( int nId) const ;
virtual int AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) ;
virtual int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) ;
virtual bool ModifyRawPart( int nRawId, const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol) ;
virtual bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) ;
virtual bool ModifyRawPartHeight( int nRawId, double dHeight) ;
virtual bool RemoveRawPart( int nRawId) ;
@@ -138,6 +139,8 @@ class MachMgr : public IMachMgr
virtual bool MdbGetCurrMachiningParam( int nType, int& nVal) const ;
virtual bool MdbGetCurrMachiningParam( int nType, double& dVal) const ;
virtual bool MdbGetCurrMachiningParam( int nType, std::string& sVal) const ;
virtual bool MdbSetSafeZ( double dSafeZ) ;
virtual bool MdbGetSafeZ( double& dSafeZ) const ;
virtual bool MdbSave( void) const ;
virtual bool MdbGetMachiningDir( std::string& sMchDir) const ;
// Operations : general
@@ -172,6 +175,8 @@ class MachMgr : public IMachMgr
virtual bool SimStart( void) ;
virtual bool SimMove( int& nStatus) ;
virtual bool SimGetAxisInfoPos( int nI, std::string& sName, double& dVal) ;
virtual bool SimGetToolInfo( std::string& sName, double& dSpeed) ;
virtual bool SimGetMoveInfo( int& nGmove, double& dFeed) ;
virtual bool SimSetStep( double dStep) ;
virtual bool SimStop( void) ;
// Generation
@@ -266,7 +271,6 @@ class MachMgr : public IMachMgr
bool SetRawPartCenter( int nRawId) ;
bool ResetRawPartCenter( int nRawId) ;
// Parts
bool AddPartToRawPart( int nPartId, int nRawId) ;
bool SwapParts( bool bToRawPart) ;
bool SwapRawPartParts( int nRawId, bool bToRawPart) ;
bool ShowRootParts( bool bShow) ;
+25
View File
@@ -222,6 +222,31 @@ MachMgr::MdbGetCurrMachiningParam( int nType, string& sVal) const
return pMsMgr->GetCurrMachiningParam( nType, sVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSetSafeZ( double dSafeZ)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// assegno il parametro
return pMsMgr->SetSafeZ( dSafeZ) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetSafeZ( double& dSafeZ) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// recupero il parametro
dSafeZ = pMsMgr->GetSafeZ() ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSave( void) const
+12 -7
View File
@@ -202,6 +202,9 @@ MachMgr::RemoveOperation( int nId)
// verifico sia una Operazione
if ( GetOperationType( nId) == OPER_NULL)
return false ;
// se lavorazione corrente, resetto
if ( m_nCurrMachiningId == nId)
m_nCurrMachiningId = GDB_ID_NULL ;
// eseguo la rimozione
m_pGeomDB->Erase( nId) ;
return true ;
@@ -302,14 +305,19 @@ MachMgr::GetCurrMachining( void) const
int
MachMgr::AddMachining( const string& sName, const std::string& sMachining)
{
// nessuna lavorazione corrente
m_nCurrMachiningId = GDB_ID_NULL ;
// recupero il gestore delle lavorazioni della macchina corrente
MachiningsMgr* pMMgr = GetCurrMachiningsMgr() ;
if ( pMMgr == nullptr)
return GDB_ID_NULL ;
// recupero il tipo di lavorazione
const MachiningData* pMd = pMMgr->GetMachining( sMachining) ;
if ( pMd == nullptr)
if ( pMd == nullptr) {
string sOut = "AddMachining error : " + sMachining + " not found" ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
return GDB_ID_NULL ;
}
int nMchType = pMd->GetType() ;
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
@@ -332,13 +340,10 @@ MachMgr::AddMachining( const string& sName, const std::string& sMachining)
case MT_SAWING : pMch = new( nothrow) Sawing ; break ;
case MT_MILLING : pMch = new( nothrow) Milling ; break ;
}
if ( pMch == nullptr) {
m_pGeomDB->Erase( nId) ;
return GDB_ID_NULL ;
}
m_pGeomDB->SetUserObj( nId, pMch) ;
pMch->Init( this) ;
if ( ! pMch->Prepare( sMachining)) {
if ( pMch == nullptr || ! pMch->Init( this) || ! pMch->Prepare( sMachining)) {
string sOut = "AddMachining error : " + sMachining + " on " + sName ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
m_pGeomDB->Erase( nId) ;
return GDB_ID_NULL ;
}
-32
View File
@@ -68,36 +68,6 @@ MachMgr::GetNextPartInRawPart( int nId) const
return m_pGeomDB->GetNextGroup( nId) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::AddPartToRawPart( int nPartId, int nRawId)
{
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// verifico che il pezzo non sia già usato nella macchinata corrente
if ( m_pGeomDB->GetParentId( nPartId) != GDB_ID_ROOT)
return false ;
// recupero il riferimento del grezzo
Frame3d frRaw ;
m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ;
// determino il riferimento del pezzo rispetto al grezzo
Frame3d frPart ;
m_pGeomDB->GetGroupGlobFrame( nPartId, frPart) ;
frPart.ToLoc( frRaw) ;
// inserisco il pezzo
int nGroup = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawId, frPart) ;
if ( nGroup == GDB_ID_NULL ||
! m_pGeomDB->GroupSwap( nPartId, nGroup, true, true))
return false ;
// impongo il livello system al gruppo
m_pGeomDB->SetLevel( nGroup, GDB_LV_SYSTEM) ;
// mi assicuro sia visibile il pezzo e nascosto il gruppo
m_pGeomDB->SetStatus( nPartId, GDB_ST_ON) ;
m_pGeomDB->SetStatus( nGroup, GDB_ST_OFF) ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId)
@@ -121,8 +91,6 @@ MachMgr::AddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId)
// muovo riferimento del pezzo per posizionare correttamente nel grezzo
Vector3d vtMove = ptPos - b3Part.GetMin() ;
frPart.Translate( vtMove) ;
// esprimo questo riferimento rispetto al grezzo
frPart.ToLoc( frRaw) ;
// inserisco il pezzo
int nGroup = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawId, frPart) ;
if ( nGroup == GDB_ID_NULL ||
+156 -26
View File
@@ -20,6 +20,8 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EgkCurveAux.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -75,25 +77,19 @@ MachMgr::AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double d
int nRawGroupId = GetCurrRawGroupId() ;
if ( nRawGroupId == GDB_ID_NULL)
return GDB_ID_NULL ;
// creo il solido
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshBox( dLen, dWidth, dHeight)) ;
if ( IsNull( pStm))
return GDB_ID_NULL ;
// se definita una tavola corrente, esprimo il punto rispetto alla sua prima origine
Point3d ptMyOrig = ptOrig ;
Point3d ptRef1 ;
if ( GetTableRef( 1, ptRef1))
ptMyOrig += ptRef1 ;
// inserisco il gruppo del grezzo nei grezzi della macchinata
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, Frame3d( ptOrig)) ;
int nRawId = m_pGeomDB->AddGroup( GDB_ID_NULL, nRawGroupId, Frame3d( ptMyOrig)) ;
if ( nRawId == GDB_ID_NULL)
return GDB_ID_NULL ;
// assegno il nome al gruppo
bool bOk = m_pGeomDB->SetName( nRawId, MACH_RAW_PART) ;
// inserisco il solido nel gruppo
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ;
bOk = bOk && ( nId != GDB_ID_NULL) ;
// assegno il nome al solido
bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ;
// assegno il colore al solido
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
// calcolo il punto centro del solido
bOk = bOk && SetRawPartCenter( nRawId) ;
// creo solido e outline
bOk = bOk && ModifyRawPart( nRawId, ptOrig, dLen, dWidth, dHeight, cCol) ;
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
@@ -103,6 +99,65 @@ MachMgr::AddRawPart( const Point3d& ptOrig, double dLen, double dWidth, double d
return nRawId ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ModifyRawPart( int nRawId, const Point3d& ptOrig, double dLen, double dWidth, double dHeight, Color cCol)
{
// le dimensioni non possono essere nulle
if ( dLen < EPS_SMALL || dWidth < EPS_SMALL || dHeight < EPS_SMALL)
return false ;
// verifica validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// creo il solido
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshBox( dLen, dWidth, dHeight)) ;
if ( IsNull( pStm))
return false ;
// creo il contorno esterno
PolyLine PL ;
PL.AddUPoint( 0, ORIG) ;
PL.AddUPoint( 1, Point3d( dLen, 0, 0)) ;
PL.AddUPoint( 2, Point3d( dLen, dWidth, 0)) ;
PL.AddUPoint( 3, Point3d( 0, dWidth, 0)) ;
PL.AddUPoint( 4, ORIG) ;
// creo la curva
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( PL) || ! pCrvCompo->SetExtrusion( Z_AX))
return false ;
// cancello eventuali vecchi solidi e curve di outline
int nOldRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if ( nOldRawSolId != GDB_ID_NULL)
m_pGeomDB->Erase( nOldRawSolId) ;
int nOldRawOutId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ;
if ( nOldRawOutId != GDB_ID_NULL)
m_pGeomDB->Erase( nOldRawOutId) ;
// se definita una tavola corrente, esprimo il punto rispetto alla sua prima origine
Point3d ptMyOrig = ptOrig ;
Point3d ptRef1 ;
if ( GetTableRef( 1, ptRef1))
ptMyOrig += ptRef1 ;
// aggiorno l'origine del gruppo
m_pGeomDB->GetGroupFrame( nRawId)->ChangeOrig( ptMyOrig) ;
// inserisco il solido nel gruppo
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pStm)) ;
bool bOk = ( nId != GDB_ID_NULL) ;
// assegno il nome al solido
bOk = bOk && m_pGeomDB->SetName( nId, MACH_RAW_SOLID) ;
// assegno il colore al solido
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
// calcolo il punto centro del solido
bOk = bOk && SetRawPartCenter( nRawId) ;
// inserisco la curva composita nel DB
int nCrvId = ( bOk ? m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pCrvCompo)) : GDB_ID_NULL) ;
bOk = bOk && ( nCrvId != GDB_ID_NULL) ;
// assegno il nome al contorno
bOk = bOk && m_pGeomDB->SetName( nCrvId, MACH_RAW_OUTLINE) ;
// assegno il colore al contorno
bOk = bOk && m_pGeomDB->SetMaterial( nCrvId, cCol) ;
return bOk ;
}
//----------------------------------------------------------------------------
int
MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight, Color cCol)
@@ -137,8 +192,7 @@ MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight,
if ( ! pMyCrv->Scale( Frame3d(), 1, 1, 0))
return GDB_ID_NULL ;
// se non è chiusa, la chiudo
if ( ! pMyCrv->IsClosed())
pMyCrv->Close() ;
pMyCrv->Close() ;
// la oriento in senso CCW
double dAreaXY ;
if ( ! pMyCrv->GetAreaXY( dAreaXY))
@@ -146,10 +200,13 @@ MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight,
if ( dAreaXY < 0)
pMyCrv->Invert() ;
// ne eseguo l'offset
if ( ! pMyCrv->SimpleOffset( dOverMat, ICurve::OFF_EXTEND))
OffsetCurve OffsCrv ;
OffsCrv.Make( Get( pMyCrv), dOverMat, ICurve::OFF_EXTEND) ;
PtrOwner<ICurve> pOffsCrv( OffsCrv.GetLongerCurve()) ;
if ( IsNull( pOffsCrv))
return GDB_ID_NULL ;
// creo il solido
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshByExtrusion( Get( pMyCrv), Vector3d(0,0,dHeight), true)) ;
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshByExtrusion( Get( pOffsCrv), Vector3d(0,0,dHeight), true)) ;
if ( IsNull( pStm))
return GDB_ID_NULL ;
// inserisco il gruppo del grezzo nella macchinata
@@ -167,6 +224,13 @@ MachMgr::AddRawPart( int nCrvId, double dOverMat, double dZmin, double dHeight,
bOk = bOk && m_pGeomDB->SetMaterial( nId, cCol) ;
// calcolo il punto centro del solido
bOk = bOk && SetRawPartCenter( nRawId) ;
// inserisco nel DB la curva di offset come contorno del grezzo
int nOutCrvId = ( bOk ? m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pOffsCrv)) : GDB_ID_NULL) ;
bOk = bOk && ( nOutCrvId != GDB_ID_NULL) ;
// assegno il nome al contorno
bOk = bOk && m_pGeomDB->SetName( nOutCrvId, MACH_RAW_OUTLINE) ;
// assegno il colore al contorno
bOk = bOk && m_pGeomDB->SetMaterial( nOutCrvId, cCol) ;
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
@@ -206,6 +270,55 @@ MachMgr::AddRawPart( int nSurfId, Color cCol)
bOk = bOk && m_pGeomDB->SetStatus( nId, GDB_ST_ON) ;
// calcolo il punto centro del solido
bOk = bOk && SetRawPartCenter( nRawId) ;
// calcolo la curva di contorno
if ( bOk) {
// creo la curva
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
return GDB_ID_NULL ;
// recupero la superficie trimesh
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nId)) ;
if ( pStm == nullptr)
return GDB_ID_NULL ;
// recupero l'ingombro della superficie in locale
BBox3d b3Srf ;
pStm->GetLocalBBox( b3Srf) ;
// ne calcolo la silhouette secondo Z+
POLYLINEVECTOR vPL ;
bool bSilh = false ;
if ( pStm->GetSilhouette( Z_AX, vPL) && vPL.size() == 1) {
PtrOwner<ICurveComposite> pCrvSilh( CreateCurveComposite()) ;
if ( pCrvSilh->FromPolyLine( vPL[0]) && pCrvSilh->IsClosed()) {
pCrvSilh->SetExtrusion( Z_AX) ;
Plane3d plProj ;
SetPlane( b3Srf.GetMin(), Z_AX, plProj) ;
pCrvCompo.Set( GetCurveComposite( ProjectCurveOnPlane( *pCrvSilh, plProj))) ;
pCrvCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL) ;
bSilh = ( ! IsNull( pCrvCompo)) ;
}
}
// non riuscita, la calcolo come contorno del box
if ( ! bSilh) {
Point3d ptMin ;
double dDimX, dDimY, dDimZ ;
b3Srf.GetMinDim( ptMin, dDimX, dDimY, dDimZ) ;
PolyLine PL ;
PL.AddUPoint( 0, ptMin) ;
PL.AddUPoint( 1, ptMin + Vector3d( dDimX, 0,0)) ;
PL.AddUPoint( 2, ptMin + Vector3d( dDimX, dDimY,0)) ;
PL.AddUPoint( 3, ptMin + Vector3d( 0, dDimY,0)) ;
PL.AddUPoint( 4, ptMin) ;
if ( ! pCrvCompo->FromPolyLine( PL) && ! pCrvCompo->SetExtrusion( Z_AX))
bOk = false ;
}
// inserisco la curva composita nel DB
int nCrvId = ( bOk ? m_pGeomDB->AddGeoObj( GDB_ID_NULL, nRawId, Release( pCrvCompo)) : GDB_ID_NULL) ;
bOk = bOk && ( nCrvId != GDB_ID_NULL) ;
// assegno il nome alla curva
bOk = bOk && m_pGeomDB->SetName( nCrvId, MACH_RAW_SOLID) ;
// assegno il colore alla curva
bOk = bOk && m_pGeomDB->SetMaterial( nCrvId, cCol) ;
}
// se qualcosa è andato storto, cancello tutto
if ( ! bOk) {
m_pGeomDB->Erase( nRawId) ;
@@ -229,12 +342,16 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color
return GDB_ID_NULL ;
// recupero il tipo di oggetto per definire il grezzo
int nGtype = m_pGeomDB->GetGeoType( nCrvSrfId) ;
// punto di riferimento del pezzo nel grezzo
Point3d ptRef ;
// costruzione del grezzo
int nRawId = GDB_ID_NULL ;
// se grezzo da superficie (per ora senza possibilità di offset)
if ( ( nGtype & GEO_SURF) != 0) {
// inserisco il grezzo
nRawId = AddRawPart( nCrvSrfId, cCol) ;
// annullo il sovra-materiale
dOverMat = 0 ;
}
// se altrimenti grezzo da contorno
else if ( ( nGtype & GEO_CURVE) != 0) {
@@ -256,22 +373,30 @@ MachMgr::AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color
if ( ! m_pGeomDB->GetGlobalBBox( nPartId, b3Part))
return GDB_ID_NULL ;
// deduco i dati del grezzo
Point3d ptMin = b3Part.GetMin() - Vector3d( dOverMat, dOverMat, 0) ;
Point3d ptMax = b3Part.GetMax() + Vector3d( dOverMat, dOverMat, 0) ;
Vector3d vtDiff = ptMax - ptMin ;
Vector3d vtDiff = b3Part.GetMax() - b3Part.GetMin() + 2 * Vector3d( dOverMat, dOverMat, 0) ;
if ( vtDiff.z < RAW_MIN_H)
vtDiff.z = RAW_MIN_H ;
// inserisco il grezzo
nRawId = AddRawPart( ptMin, vtDiff.x, vtDiff.y, vtDiff.z, cCol) ;
nRawId = AddRawPart( ORIG, vtDiff.x, vtDiff.y, vtDiff.z, cCol) ;
// il riferimento deve tenere conto dell'offset
ptRef = Point3d( dOverMat, dOverMat, 0) ;
}
// verifico costruzione grezzo
if ( nRawId == GDB_ID_NULL)
return GDB_ID_NULL ;
// 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()) ;
}
// inserisco il pezzo nel grezzo
if ( ! AddPartToRawPart( nPartId, nRawId)) {
if ( ! AddPartToRawPart( nPartId, ptRef, nRawId)) {
RemoveRawPart( nRawId) ;
return GDB_ID_NULL ;
}
return nRawId ;
}
@@ -289,6 +414,10 @@ MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dH
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if ( nRawSolId == GDB_ID_NULL)
return false ;
// recupero il contorno del grezzo
int nRawOutId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ;
if ( nRawOutId == GDB_ID_NULL)
return false ;
// recupero il box del grezzo
BBox3d b3Raw ;
if ( ! m_pGeomDB->GetLocalBBox( nRawSolId, b3Raw))
@@ -308,8 +437,9 @@ MachMgr::ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dH
if ( dOldH < EPS_SMALL)
return false ;
double dCoeffZ = dHeight / dOldH ;
// eseguo scalatura
bool bOk = m_pGeomDB->Scale( nRawSolId, Frame3d( b3Raw.GetMin()), dCoeffX, dCoeffY, dCoeffZ) ;
// eseguo scalature
bool bOk = m_pGeomDB->Scale( nRawSolId, Frame3d( b3Raw.GetMin()), dCoeffX, dCoeffY, dCoeffZ) &&
m_pGeomDB->Scale( nRawOutId, Frame3d( b3Raw.GetMin()), dCoeffX, dCoeffY, dCoeffZ) ;
// dichiaro centro da ricalcolare
ResetRawPartCenter( nRawId) ;
return bOk ;
@@ -426,7 +556,7 @@ MachMgr::MoveRawPart( int nRawId, const Vector3d& vtMove)
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
return pDisp->MoveRawPart( nRawId,vtMove) ;
return pDisp->MoveRawPart( nRawId, vtMove) ;
}
//----------------------------------------------------------------------------
+22
View File
@@ -61,6 +61,28 @@ MachMgr::SimGetAxisInfoPos( int nI, string& sName, double& dVal)
return m_pSimul->GetAxisInfoPos( nI, sName, dVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimGetToolInfo( string& sName, double& dSpeed)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// recupero quote
return m_pSimul->GetToolInfo( sName, dSpeed) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimGetMoveInfo( int& nGmove, double& dFeed)
{
// verifico simulatore
if ( m_pSimul == nullptr)
return false ;
// recupero quote
return m_pSimul->GetMoveInfo( nGmove, dFeed) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::SimSetStep( double dStep)
+2
View File
@@ -40,6 +40,8 @@ Machine::Machine( void)
m_nCalcToolId = GDB_ID_NULL ;
m_dCalcRot1W = 1 ;
m_nCalcSolCh = MCH_SCC_NONE ;
m_dCalcTLen = 0 ;
m_dCalcTRad = 0 ;
}
//----------------------------------------------------------------------------
+3
View File
@@ -123,15 +123,18 @@ class Machine
typedef std::unordered_map< std::string, int> STRINT_UMAP ;
private :
// generali
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
LuaMgr m_LuaMgr ; // interprete lua della macchina
Writer m_Writer ; // scrittore di file di testo
// dati macchina
std::string m_sName ; // nome della macchina
std::string m_sMachineDir ; // direttorio della macchina
int m_nGroupId ; // Id del gruppo della macchina
int m_nTempGroupId ; // Id del gruppo temporaneo macchina per carico
STRINT_UMAP m_mapGroups ; // dizionario dei gruppi della macchina
// dati di calcolo
int m_nCalcTabId ; // tavola corrente per calcoli
int m_nCalcHeadId ; // testa corrente per calcoli
int m_nCalcExitId ; // uscita corrente per calcoli
+353 -3
View File
@@ -19,6 +19,7 @@
#include "CamData.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EgkIntersCurves.h"
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
@@ -197,6 +198,76 @@ Machining::GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3
return bFound ;
}
//----------------------------------------------------------------------------
bool
Machining::GetDistanceFromRawSide( const Point3d& ptP, const Vector3d& vtDir, double& dDist)
{
// recupero il grezzo in cui è incluso il punto
BBox3d b3Pnt( ptP) ;
b3Pnt.Expand( 10, 10, 0) ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
BBox3d b3Raw ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Pnt.OverlapsXY( b3Raw)) {
break ;
}
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
}
// se il punto non è interno ad alcun grezzo, distanza nulla
if ( nRawId == GDB_ID_NULL) {
dDist = 0 ;
return true ;
}
// recupero il contorno del grezzo
int nOutId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ;
ICurve* pOut = ::GetCurve( m_pGeomDB->GetGeoObj( nOutId)) ;
if ( pOut == nullptr)
return false ;
// recupero il riferimento del contorno e verifico che abbia Z verticale
Frame3d frStm ;
if ( ! m_pGeomDB->GetGlobFrame( nOutId, frStm) ||
( frStm.GetZType() != Frame3d::TOP && frStm.GetZType() != Frame3d::BOTTOM))
return false ;
// interseco il raggio di test (portato nel riferimento del contorno) con il contorno del grezzo
const double RAY_LEN = 10000 ;
PtrOwner<ICurveLine> pRay( CreateCurveLine()) ;
if ( IsNull( pRay) || ! pRay->SetPVL( ptP, vtDir, RAY_LEN))
return false ;
pRay->ToLoc( frStm) ;
IntersCurveCurve intCC( *Get( pRay), *pOut) ;
IntCrvCrvInfo aInfo ;
if ( intCC.GetIntCrvCrvInfo( 0, aInfo))
dDist = aInfo.IciA[0].dU * RAY_LEN ;
else
dDist = 0 ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machining::GetDistanceFromRawBottom( int nPathId, double dToler, double& dRbDist)
{
// recupero distanza da fondo dei grezzi interessati dal percorso
dRbDist = 0 ;
BBox3d b3Compo ;
if ( ! m_pGeomDB->GetGlobalBBox( nPathId, b3Compo))
return false ;
b3Compo.Expand( dToler, dToler, 0) ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
BBox3d b3Raw ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Compo.OverlapsXY( b3Raw)) {
double dDist = b3Compo.GetMax().z - b3Raw.GetMin().z ;
if ( dDist > dRbDist)
dRbDist = dDist ;
}
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
}
return true ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
@@ -248,7 +319,7 @@ Machining::SetFlag( int nFlag)
//----------------------------------------------------------------------------
int
Machining::AddStart( const Point3d& ptP)
Machining::AddRapidStart( const Point3d& ptP)
{
// verifico di essere in uno stato valido per inizio
if ( m_vtTool.IsSmall())
@@ -272,6 +343,8 @@ Machining::AddStart( const Point3d& ptP)
pCam->SetCorrDir( m_vtCorr) ;
pCam->SetAuxDir( m_vtAux) ;
pCam->SetBasePoint( ptP) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( m_nFlag) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
// salvo la posizione corrente
@@ -280,6 +353,42 @@ Machining::AddStart( const Point3d& ptP)
return nId ;
}
//----------------------------------------------------------------------------
int
Machining::AddRapidMove( const Point3d& ptP)
{
// verifico di essere in uno stato valido per un movimento in rapido
if ( ! m_bCurr || m_vtTool.IsSmall())
return GDB_ID_NULL ;
// creo oggetto linea per DB geometrico
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
if ( IsNull( pLine))
return GDB_ID_NULL ;
// assegno le coordinate degli estremi
if ( ! pLine->Set( m_ptCurr, ptP))
return GDB_ID_NULL ;
// inserisco l'oggetto nel DB geometrico
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pLine)) ;
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
// creo oggetto dati Cam
PtrOwner<CamData> pCam( new( nothrow) CamData) ;
if ( IsNull( pCam))
return GDB_ID_NULL ;
// assegno valori
pCam->SetToolDir( m_vtTool) ;
pCam->SetCorrDir( m_vtCorr) ;
pCam->SetAuxDir( m_vtAux) ;
pCam->SetBasePoint( ptP) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( m_nFlag) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
// salvo la posizione corrente
m_ptCurr = ptP ;
return nId ;
}
//----------------------------------------------------------------------------
int
Machining::AddLinearMove( const Point3d& ptP)
@@ -331,16 +440,53 @@ Machining::ResetMoveData( void)
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
Machining::GetInitialAxesValues( DBLVECTOR& vAxVal)
{
// recupero gruppo per geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
if ( nClId == GDB_ID_NULL)
return false ;
// recupero il primo percorso CL
int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
// restituisco i valori iniziali degli assi di questo percorso di lavorazione
return GetClPathInitialAxesValues( nClPathId, vAxVal) ;
}
//----------------------------------------------------------------------------
bool
Machining::GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal)
{
// recupero la prima entità di questo percorso
int nEntId = m_pGeomDB->GetFirstInGroup( nClPathId) ;
// recupero i dati Cam dell'entità
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
return false ;
// assegno i valori degli assi
vAxVal = pCamData->GetAxisVal() ;
return ( vAxVal.size() > 0) ;
}
//----------------------------------------------------------------------------
bool
Machining::GetFinalAxesValues( DBLVECTOR& vAxVal)
{
// recupero gruppo per geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
if ( nClId == GDB_ID_NULL)
return false ;
// recupero l'ultimo percorso CL
int nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ;
// restituisco i valori finali degli assi di questo percorso di lavorazione
return GetClPathFinalAxesValues( nClPathId, vAxVal) ;
}
//----------------------------------------------------------------------------
bool
Machining::GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal)
{
// recupero l'ultima entità di questo percorso
int nEntId = m_pGeomDB->GetLastInGroup( nClPathId) ;
// recupero i dati Cam dell'entità
@@ -397,7 +543,7 @@ Machining::CalculateAxesValues( void)
double dRot1W = m_pMchMgr->GetCalcRot1W() ;
// recupero gruppo della geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
if ( nClId == GDB_ID_NULL)
return false ;
@@ -497,3 +643,207 @@ Machining::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machining::AdjustStartMovements(void)
{
// recupero gruppo della geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
if ( nClId == GDB_ID_NULL)
return false ;
// recupero la lavorazione precedente
int nPrevOpId = m_pMchMgr->GetPrevOperation( m_nOwnerId) ;
Machining* pPrevMch = dynamic_cast<Machining*>( m_pGeomDB->GetUserObj( nPrevOpId)) ;
// recupero l'utensile precedente e i dati della sua testa
string sPrevTool ;
if ( pPrevMch != nullptr)
pPrevMch->GetParam( MPA_TOOL, sPrevTool) ;
// imposto l'utensile per i calcoli macchina
if ( ! m_pMchMgr->SetCalcTool( GetToolData().m_sName, GetToolData().m_sHead, GetToolData().m_nExit))
return false ;
// determino posizione precedente assi
DBLVECTOR vAxVal ;
// se primo utensile, uso la posizione home
if ( sPrevTool.empty()) {
if ( ! m_pMchMgr->GetAllCalcAxesHomePos( vAxVal))
return false ;
}
// se utensile non cambiato o su diversa uscita della stessa testa, uso posizione finale della lavorazione precedente
else if ( ! ToolChangeNeeded( pPrevMch->GetToolData(), GetToolData())) {
pPrevMch->RemoveRise() ;
DBLVECTOR vAxIni ;
if ( ! pPrevMch->GetFinalAxesValues( vAxVal) || ! GetInitialAxesValues( vAxIni))
return false ;
if ( vAxVal.size() >= 5 && vAxIni.size() >= 5 &&
fabs( vAxVal[4] - vAxIni[4]) > 15) {
double dDelta = max( vAxVal[2], vAxIni[2]) - vAxVal[2] + 200 ;
if ( ! pPrevMch->AddRise( vAxVal, dDelta))
return false ;
}
}
// altrimenti aggiungo uscita per cambio utensile alla lavorazione precedente e parto da questa
else {
pPrevMch->RemoveRise() ;
if ( ! pPrevMch->AddRise( vAxVal))
return false ;
}
// aggiusto l'inizio di ogni percorso di lavoro
bool bOk = true ;
int nClPathId = m_pGeomDB->GetFirstGroupInGroup( nClId) ;
while ( bOk && nClPathId != GDB_ID_NULL) {
// sistemo inizio
if ( ! AdjustOneStartMovement( nClPathId, vAxVal))
bOk = false ;
// recupero nuovi finali
if ( ! GetClPathFinalAxesValues( nClPathId, vAxVal))
bOk = false ;
// passo al successivo
nClPathId = m_pGeomDB->GetNextGroup( nClPathId) ;
}
// aggiungo risalita finale
AddRise( vAxVal) ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
Machining::AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev)
{
// recupero la prima entità di questo percorso
int nEntId = m_pGeomDB->GetFirstInGroup( nClPathId) ;
// recupero i dati Cam dell'entità
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
return false ;
// recupero i valori degli assi
DBLVECTOR vAxCurr ;
vAxCurr = pCamData->GetAxisVal() ;
// se Z pressochè uguali non devo fare alcunché
if ( fabs( vAxCurr[2] - vAxPrev[2]) < 10 * EPS_SMALL)
return true ;
// se Z corrente maggiore della precedente
else if ( vAxCurr[2] > vAxPrev[2]) {
// copio l'entità
if ( m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_AFTER) == GDB_ID_NULL)
return false ;
// modifico quella originale (è la prima del percorso)
DBLVECTOR vAxNew = vAxPrev ;
vAxNew[2] = vAxCurr[2] ;
pCamData->SetAxes( CamData::AS_OK, vAxNew) ;
pCamData->ChangeAxesMask( CamData::MSK_L3) ;
pCamData->SetFlag( 0) ;
}
// altrimenti Z corrente minore della precedente
else {
// copio l'entità
if ( m_pGeomDB->Copy( nEntId, GDB_ID_NULL, nEntId, GDB_AFTER) == GDB_ID_NULL)
return false ;
// modifico quella originale (è la prima del percorso)
DBLVECTOR vAxNew = vAxCurr ;
vAxNew[2] = vAxPrev[2] ;
pCamData->SetAxes( CamData::AS_OK, vAxNew) ;
pCamData->ChangeAxesMask( CamData::MSK_L1 | CamData::MSK_L2 | CamData::MSK_R1 | CamData::MSK_R2) ;
pCamData->SetFlag( 2) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Machining::ToolChangeNeeded( const ToolData& T1, const ToolData& T2)
{
// se non cambia l'utensile, non cambia la testa fisica
if ( EqualNoCase( T1.m_sName, T2.m_sName))
return false ;
// se non hanno TcPos e stanno sulla stessa testa con uscita diversa, non cambia la testa fisica
if ( T1.m_sTcPos.empty() && T2.m_sTcPos.empty() &&
EqualNoCase( T1.m_sHead, T2.m_sHead) && T1.m_nExit != T2.m_nExit)
return false ;
// se hanno lo stesso TcPos e stanno sulla stessa testa con uscita diversa, non cambia la testa fisica
if ( EqualNoCase( T1.m_sTcPos, T2.m_sTcPos) &&
EqualNoCase( T1.m_sHead, T2.m_sHead) && T1.m_nExit != T2.m_nExit)
return false ;
// altrimenti necessario un cambio
return true ;
}
//----------------------------------------------------------------------------
bool
Machining::AddRise( DBLVECTOR& vAxVal, double dDelta)
{
// recupero gruppo per geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
if ( nClId == GDB_ID_NULL)
return false ;
// recupero l'ultimo percorso
int nLastPxClId = m_pGeomDB->GetLastGroupInGroup( nClId) ;
// recupero l'ultima entità del percorso
int nEntId = m_pGeomDB->GetLastInGroup( nLastPxClId) ;
if ( nEntId == GDB_ID_NULL)
return false ;
// ne recupero i dati Cam
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( nEntId)) ;
if ( pCamData == nullptr)
return false ;
// creo oggetto punto per DB geometrico
PtrOwner<IGeoPoint3d> pGP( CreateGeoPoint3d()) ;
if ( IsNull( pGP))
return false ;
// assegno le coordinate del punto
pGP->Set( pCamData->GetBasePoint()) ;
// inserisco l'oggetto nel DB geometrico
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nLastPxClId, Release( pGP)) ;
if ( nId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nId, MCH_RISE) ;
// creo oggetto dati Cam
PtrOwner<CamData> pCam( pCamData->Clone()) ;
if ( IsNull( pCam))
return false ;
// recupero i valori degli assi
vAxVal = pCam->GetAxisVal() ;
// se delta positivo lo uso come incremeto di Z
if ( dDelta > 0)
vAxVal[2] += dDelta ;
// altrimenti uso la Z home
else {
DBLVECTOR vAxHome ;
m_pMchMgr->GetAllCalcAxesHomePos( vAxHome) ;
vAxVal[2] = vAxHome[2] ;
}
pCam->SetAxes( CamData::AS_OK, vAxVal) ;
pCam->SetFeed( 0) ;
pCam->SetFlag( 3) ;
// associo questo oggetto a quello geometrico
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machining::RemoveRise( void)
{
// recupero gruppo per geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ;
if ( nClId == GDB_ID_NULL)
return false ;
// recupero l'ultimo percorso CL
int nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ;
// elimino tutte le entità RISE alla fine del percorso
int nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_RISE) ;
while ( nId != GDB_ID_NULL) {
m_pGeomDB->Erase( nId) ;
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_RISE) ;
}
return true ;
}
+12 -2
View File
@@ -51,13 +51,22 @@ class Machining : public IUserObj
Machining( void) ;
protected :
double GetApproachDist( void) { return 60.0 ; }
bool GetElevation( const Point3d& ptP, const Vector3d& vtDir, double& dElev) ;
bool GetElevation( const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtDir, double& dElev) ;
bool GetDistanceFromRawSide( const Point3d& ptP, const Vector3d& vtDir, double& dDist) ;
bool GetDistanceFromRawBottom( int nPathId, double dToler, double& dRbDist) ;
bool GetInitialAxesValues( DBLVECTOR& vAxVal) ;
bool GetClPathInitialAxesValues( int nClPathId, DBLVECTOR& vAxVal) ;
bool GetFinalAxesValues( DBLVECTOR& vAxVal) ;
bool GetClPathFinalAxesValues( int nClPathId, DBLVECTOR& vAxVal) ;
bool CalculateAxesValues( void) ;
bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
double& dAngAprec, double& dAngBprec) ;
bool AdjustStartMovements( void) ;
bool AdjustOneStartMovement( int nClPathId, const DBLVECTOR& vAxPrev) ;
bool ToolChangeNeeded( const ToolData& T1, const ToolData& T2) ;
bool AddRise( DBLVECTOR& vAxVal, double dDelta = - 1) ;
bool RemoveRise( void) ;
protected :
bool SetPathId( int nPathId) ;
@@ -66,7 +75,8 @@ class Machining : public IUserObj
bool SetAuxDir( const Vector3d& vtDir) ;
bool SetFeed( double dFeed) ;
bool SetFlag( int nFlag) ;
int AddStart( const Point3d& ptP) ;
int AddRapidStart( const Point3d& ptP) ;
int AddRapidMove( const Point3d& ptP) ;
int AddLinearMove( const Point3d& ptP) ;
bool ResetMoveData( void) ;
+2
View File
@@ -22,6 +22,8 @@ static std::string KEY_IDS = "IDS" ;
static std::string MCH_AUX = "AUX" ;
static std::string MCH_CL = "CL" ;
static std::string MCH_PATH = "P" ;
// Nomi di entitŕ speciali
static std::string MCH_RISE = "RISE" ;
//----------------------------------------------------------------------------
// Feed equivalente a massima
+137 -20
View File
@@ -16,7 +16,8 @@
#include "MachiningsMgr.h"
#include "MachiningDataFactory.h"
#include "DllMain.h"
#include "/EgtDEv/Include/EmkMachiningConst.h"
#include "/EgtDEv/Include/EGkGeoConst.h"
#include "/EgtDEv/Include/EMkMachiningConst.h"
#include "/EgtDEv/Include/EGnStringKeyVal.h"
#include "/EgtDEv/Include/EGnStringUtils.h"
#include "/EgtDEv/Include/EGnFileUtils.h"
@@ -33,7 +34,14 @@ const string MF_HEADER = "[HEADER]" ;
const string MF_VERSION = "VERSION" ;
const string MF_TOTAL = "TOTAL" ;
const string MF_SIZE = "SIZE" ;
const int MF_CURR_VER = 1001 ;
const int MF_CURR_VER = 1002 ;
const string MF_GENERAL = "[GENERAL]" ;
const string MF_SAFEZ = "SAFEZ" ;
const double MF_CURR_SAFEZ = 100 ;
const string MF_3AXCOMP = "3AXCOMP" ;
const bool MF_CURR_3AXCOMP = false ;
const string MF_5AXCOMP = "5AXCOMP" ;
const bool MF_CURR_5AXCOMP = false ;
//----------------------------------------------------------------------------
@@ -43,6 +51,9 @@ MachiningsMgr::MachiningsMgr( void)
m_suCIter = m_suData.cend() ;
m_pCurrMach = nullptr ;
m_bModified = false ;
m_dSafeZ = MF_CURR_SAFEZ ;
m_b3AxComp = MF_CURR_3AXCOMP ;
m_b5AxComp = MF_CURR_5AXCOMP ;
}
//----------------------------------------------------------------------------
@@ -79,22 +90,22 @@ MachiningsMgr::Clear( void)
bool
MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr)
{
// pulisco
// Pulisco
Clear() ;
// salvo la path del file con i dati
// Salvo la path del file con i dati
m_sMachsFile = sMachsFile ;
{ string sOut = "MachiningsMgr Init : " + m_sMachsFile ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) }
// verifico il gestore degli utensili
// Verifico il gestore degli utensili
if ( pTsMgr == nullptr) {
LOG_ERROR( GetEMkLogger(), "LoadMachinings : Error on ToolsMgr")
return false ;
}
m_pTsMgr = pTsMgr ;
// inizializzo lo scanner
// Inizializzo lo scanner
Scanner TheScanner ;
if ( ! TheScanner.Init( m_sMachsFile, ";")) {
LOG_ERROR( GetEMkLogger(), "LoadMachinings : Error on Init")
@@ -105,7 +116,7 @@ MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr)
bool bOk = true ;
bool bEnd = false ;
// leggo l'intestazione
// Leggo l'intestazione
int nVersion = 0 ;
int nTotal = 0 ;
if ( ! LoadHeader( TheScanner, nVersion, nTotal, bEnd)) {
@@ -118,11 +129,18 @@ MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr)
LOG_INFO( GetEMkLogger(), sOut.c_str())
}
// dimensiono map
// Leggo i dati generali (da versione 1002)
if ( nVersion >= 1002 && ! LoadGeneral( TheScanner, bEnd)) {
bOk = false ;
string sOut = "LoadMachinings : Error on General" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
}
// Dimensiono map
const int MIN_BUCKETS = 163 ;
m_umData.rehash( MIN_BUCKETS) ;
// ciclo di lettura delle lavorazioni
// Ciclo di lettura delle lavorazioni
do {
if ( ! LoadOneMachining( TheScanner, bEnd)) {
bOk = false ;
@@ -131,7 +149,7 @@ MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr)
}
} while ( bOk && ! bEnd) ;
// termino lo scanner
// Termino lo scanner
TheScanner.Terminate() ;
return bOk ;
@@ -157,7 +175,7 @@ MachiningsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool
nVersion = 1000 ;
nTotal = 0 ;
while ( bOk && TheScanner.GetLine( sLine)) {
// se utensile successivo
// se sezione successiva
if ( sLine.front() == '[' && sLine.back() == ']') {
TheScanner.UngetLine( sLine) ;
bEnd = false ;
@@ -177,6 +195,46 @@ MachiningsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::LoadGeneral( Scanner& TheScanner, bool& bEnd)
{
// leggo la prossima linea
string sLine ;
if ( ! TheScanner.GetLine( sLine)) {
// fine file
bEnd = true ;
return true ;
}
// deve essere dati generali
if ( sLine != MF_GENERAL)
return false ;
bool bOk = true ;
// leggo le linee successive
bEnd = true ;
while ( bOk && TheScanner.GetLine( sLine)) {
// se sezione successiva
if ( sLine.front() == '[' && sLine.back() == ']') {
TheScanner.UngetLine( sLine) ;
bEnd = false ;
break ;
}
// separo chiave da valore
string sKey, sVal ;
SplitFirst( sLine, "=", sKey, sVal) ;
// riconosco la chiave
if ( ToUpper( sKey) == MF_SAFEZ)
bOk = FromString( sVal, m_dSafeZ) ;
else if ( ToUpper( sKey) == MF_3AXCOMP)
bOk = FromString( sVal, m_b3AxComp) ;
else if ( ToUpper( sKey) == MF_5AXCOMP)
bOk = FromString( sVal, m_b5AxComp) ;
else
bOk = false ;
}
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd)
@@ -245,34 +303,40 @@ MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd)
bool
MachiningsMgr::Save( bool bCompressed) const
{
// se non ci sono state modifiche, esco subito
// Se non ci sono state modifiche, esco subito
if ( ! m_bModified)
return true ;
// faccio copia di backup del file originale
// Faccio copia di backup del file originale
CopyFileEgt( m_sMachsFile, m_sMachsFile + ".bak") ;
// inizializzo il writer
// Inizializzo il writer
Writer TheWriter ;
if ( ! TheWriter.Init( m_sMachsFile, bCompressed)) {
LOG_ERROR( GetEMkLogger(), "SaveMachinings : Error on Init")
return false ;
}
// scrivo linea di inizio file
// Scrivo linea di inizio file
string sOut = "; --- " + m_sMachsFile + " " + CurrDateTime() + " ---" ;
if ( ! TheWriter.OutText( sOut)) {
LOG_ERROR( GetEMkLogger(), "SaveMachinings : Error on Start")
return false ;
}
// scrivo l'intestazione
// Scrivo l'intestazione
if ( ! SaveHeader( TheWriter)) {
LOG_ERROR( GetEMkLogger(), "SaveMachinings : Error on Header")
return false ;
}
// Scrivo i dati generali
if ( ! SaveGeneral( TheWriter)) {
LOG_ERROR( GetEMkLogger(), "SaveMachinings : Error on General")
return false ;
}
// ciclo su tutti i nomi delle lavorazioni
// Ciclo su tutti i nomi delle lavorazioni
int nCounter = 0 ;
for ( auto iIter = m_suData.cbegin() ; iIter != m_suData.cend() ; ++ iIter) {
// salvo l'utensile
@@ -283,16 +347,16 @@ MachiningsMgr::Save( bool bCompressed) const
}
}
// scrivo linea di fine file
// Scrivo linea di fine file
if ( ! TheWriter.OutText( "; --- End ---")) {
LOG_ERROR( GetEMkLogger(), "SaveMachinings : Error on End")
return false ;
}
// chiudo la scrittura
// Chiudo la scrittura
TheWriter.Close() ;
// dichiaro non più modificato rispetto al file
// Dichiaro non più modificato rispetto al file
m_bModified = false ;
return true ;
@@ -314,6 +378,24 @@ MachiningsMgr::SaveHeader( Writer& TheWriter) const
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SaveGeneral( Writer& TheWriter) const
{
// scrivo l'intestazione
bool bOk = true ;
string sOut ;
sOut = MF_GENERAL ;
bOk = bOk && TheWriter.OutText( sOut) ;
sOut = MF_SAFEZ + "=" + ToString( m_dSafeZ) ;
bOk = bOk && TheWriter.OutText( sOut) ;
sOut = MF_3AXCOMP + "=" + ToString( m_b3AxComp) ;
bOk = bOk && TheWriter.OutText( sOut) ;
sOut = MF_5AXCOMP + "=" + ToString( m_b5AxComp) ;
bOk = bOk && TheWriter.OutText( sOut) ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const
@@ -656,3 +738,38 @@ MachiningsMgr::GetCurrMachiningParam( int nType, std::string& sVal) const
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->GetParam( nType, sVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetSafeZ( double dSafeZ)
{
// deve essere un valore positivo o nullo
if ( dSafeZ < - EPS_SMALL)
return false ;
// se cambiato, salvo e setto modifica
if ( fabs( dSafeZ - m_dSafeZ) > EPS_SMALL) {
m_dSafeZ = dSafeZ ;
m_bModified = true ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::Set3AxComp( bool b3AxComp)
{
// salvo e setto modifica
m_b3AxComp = b3AxComp ;
m_bModified = true ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::Set5AxComp( bool b5AxComp)
{
// salvo e setto modifica
m_b5AxComp = b5AxComp ;
m_bModified = true ;
return true ;
}
+23 -3
View File
@@ -47,12 +47,23 @@ class MachiningsMgr
bool GetCurrMachiningParam( int nType, int& nVal) const ;
bool GetCurrMachiningParam( int nType, double& dVal) const ;
bool GetCurrMachiningParam( int nType, std::string& sVal) const ;
bool SetSafeZ( double dSafeZ) ;
double GetSafeZ( void) const
{ return m_dSafeZ ; }
bool Set3AxComp( bool b3AxComp) ;
bool Get3AxComp( void) const
{ return m_b3AxComp ; }
bool Set5AxComp( bool b5AxComp) ;
bool Get5AxComp( void) const
{ return m_b5AxComp ; }
private :
bool Clear( void) ;
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) ;
bool LoadGeneral( Scanner& TheScanner, bool& bEnd) ;
bool LoadOneMachining( Scanner& TheScanner, bool& bEnd) ;
bool SaveHeader( Writer& TheWriter) const ;
bool SaveGeneral( Writer& TheWriter) const ;
bool SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
bool VerifyCurrMachining( int nType, std::string& sName) const ;
@@ -62,12 +73,21 @@ class MachiningsMgr
typedef STRUUID_MAP::const_iterator STRUUID_CITER ;
private :
// path file lavorazioni
std::string m_sMachsFile ;
const ToolsMgr* m_pTsMgr ;
// flag di dati modificati
mutable bool m_bModified ;
// database lavorazioni
UUIDPMDATA_UMAP m_umData ;
STRUUID_MAP m_suData ;
// iteratore corrente per First/Next
mutable STRUUID_CITER m_suCIter ;
// lavorazione corrente
MachiningData* m_pCurrMach ;
mutable bool m_bModified ;
// gestore utensili
const ToolsMgr* m_pTsMgr ;
// dati generali
double m_dSafeZ ;
bool m_b3AxComp ;
bool m_b5AxComp ;
} ;
+3 -4
View File
@@ -45,8 +45,6 @@ Milling::Clone( void) const
// eseguo copia dei dati
if ( pMill != nullptr) {
try {
pMill->m_nOwnerId = GDB_ID_NULL ;
pMill->m_pGeomDB = nullptr ;
pMill->m_Params = m_Params ;
pMill->m_TParams = m_TParams ;
}
@@ -121,8 +119,6 @@ Milling::Load( const STRVECTOR& vString)
//----------------------------------------------------------------------------
Milling::Milling( void)
{
m_nOwnerId = GDB_ID_NULL ;
m_pGeomDB = nullptr ;
m_Params.m_sName = "*" ;
m_Params.m_sToolName = "*" ;
m_TParams.m_sName = "*" ;
@@ -240,6 +236,9 @@ Milling::GetParam( int nType, double& dVal) const
case MPA_TOOLOFFSL :
dVal = m_TParams.m_dOffsL ;
return true ;
case MPA_STARTPOS :
dVal = m_Params.m_dStartPos ;
return true ;
case MPA_SIDEANGLE :
dVal = m_Params.m_dSideAngle ;
return true ;
+18 -1
View File
@@ -40,6 +40,7 @@ enum nMillingKey {
KEY_LT,
KEY_NAME,
KEY_OL,
KEY_PS,
KEY_SA,
KEY_ST,
KEY_STY,
@@ -69,6 +70,7 @@ static const std::array<std::string,KEY_ZZZ> sMillingKey = {
"LT",
"NAME",
"OL",
"PS",
"SA",
"ST",
"STY",
@@ -119,6 +121,7 @@ MillingData::CopyFrom( const MachiningData* pMdata)
m_bInvert = pSdata->m_bInvert ;
m_nWorkSide = pSdata->m_nWorkSide ;
m_sDepth = pSdata->m_sDepth ;
m_dStartPos = pSdata->m_dStartPos ;
m_dOverlap = pSdata->m_dOverlap ;
m_dStep = pSdata->m_dStep ;
m_nStepType = pSdata->m_nStepType ;
@@ -160,6 +163,7 @@ MillingData::SameAs(const MachiningData* pMdata) const
m_bInvert == pSdata->m_bInvert &&
m_nWorkSide == pSdata->m_nWorkSide &&
m_sDepth == pSdata->m_sDepth &&
m_dStartPos == pSdata->m_dStartPos &&
m_dOverlap == pSdata->m_dOverlap &&
m_dStep == pSdata->m_dStep &&
m_nStepType == pSdata->m_nStepType &&
@@ -265,6 +269,9 @@ MillingData::FromString( const string& sString, int& nKey)
case KEY_OL :
bOk = ::FromString( sVal, m_dOverlap) ;
break ;
case KEY_PS :
bOk = ::FromString( sVal, m_dStartPos) ;
break ;
case KEY_SA :
bOk = ::FromString( sVal, m_dSideAngle) ;
break ;
@@ -325,6 +332,7 @@ MillingData::ToString( int nInd) const
case KEY_LT : return ( sMillingKey[KEY_LT] + "=" + ::ToString( m_bLeaveTab)) ;
case KEY_NAME : return ( sMillingKey[KEY_NAME] + "=" + m_sName) ;
case KEY_OL : return ( sMillingKey[KEY_OL] + "=" + ::ToString( m_dOverlap)) ;
case KEY_PS : return ( sMillingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ;
case KEY_SA : return ( sMillingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ;
case KEY_ST : return ( sMillingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ;
case KEY_STY : return ( sMillingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ;
@@ -351,7 +359,7 @@ MillingData::VerifyWorkSide( int nVal) const
bool
MillingData::VerifyStepType( int nVal) const
{
return ( nVal == MILL_ST_STEP || nVal == MILL_ST_ONEWAY || nVal == MILL_ST_SPIRAL) ;
return ( nVal == MILL_ST_ZIGZAG || nVal == MILL_ST_ONEWAY || nVal == MILL_ST_SPIRAL) ;
}
//----------------------------------------------------------------------------
@@ -446,6 +454,9 @@ MillingData::SetParam( int nType, double dVal)
case MPA_OVERLAP :
m_dOverlap = dVal ;
return true ;
case MPA_STARTPOS :
m_dStartPos = dVal ;
return true ;
case MPA_STEP :
m_dStep = dVal ;
return true ;
@@ -536,6 +547,9 @@ bool
MillingData::GetParam( int nType, int& nVal) const
{
switch ( nType) {
case MPA_TYPE :
nVal = MT_MILLING ;
return true ;
case MPA_WORKSIDE :
nVal = m_nWorkSide ;
return true ;
@@ -560,6 +574,9 @@ MillingData::GetParam( int nType, double& dVal) const
case MPA_OVERLAP :
dVal = m_dOverlap ;
return true ;
case MPA_STARTPOS :
dVal = m_dStartPos ;
return true ;
case MPA_STEP :
dVal = m_dStep ;
return true ;
+2 -1
View File
@@ -23,6 +23,7 @@ struct MillingData : public MachiningData
bool m_bInvert ; // flag di inversione direzione lavorazione
int m_nWorkSide ; // lato di lavoro (destra, sinistra, centro)
std::string m_sDepth ; // affondamento (espressione numerica)
double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0)
double m_dOverlap ; // lunghezza di sovrapposizione se percorso chiuso
double m_dStep ; // passo di affondamento (0=nessun passo)
int m_nStepType ; // tipo di lavorazione a step (a gradini, una via, a spirale)
@@ -44,7 +45,7 @@ struct MillingData : public MachiningData
double m_dLoCompLen ; // lunghezza del tratto di disinserimento correttore raggio utensile
MillingData( void)
: m_bInvert( false), m_nWorkSide( 0),
m_dOverlap( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0),
m_dStartPos(0), m_dOverlap( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0),
m_bLeaveTab( false), m_dTabLen( 0), m_dTabDist( 0), m_dTabHeight( 0), m_dTabAngle( 0),
m_nLeadInType( 0), m_dLiTang( 0), m_dLiPerp( 0), m_dLiElev( 0), m_dLiCompLen( 0),
m_nLeadOutType( 0), m_dLoTang( 0), m_dLoPerp( 0), m_dLoElev( 0), m_dLoCompLen( 0) {}
+308 -95
View File
@@ -49,8 +49,6 @@ Sawing::Clone( void) const
// eseguo copia dei dati
if ( pSaw != nullptr) {
try {
pSaw->m_nOwnerId = GDB_ID_NULL ;
pSaw->m_pGeomDB = nullptr ;
pSaw->m_Params = m_Params ;
pSaw->m_TParams = m_TParams ;
}
@@ -125,8 +123,6 @@ Sawing::Load( const STRVECTOR& vString)
//----------------------------------------------------------------------------
Sawing::Sawing( void)
{
m_nOwnerId = GDB_ID_NULL ;
m_pGeomDB = nullptr ;
m_Params.m_sName = "*" ;
m_Params.m_sToolName = "*" ;
m_TParams.m_sName = "*" ;
@@ -170,9 +166,6 @@ Sawing::SetParam( int nType, bool bVal)
case MPA_INVERT :
m_Params.m_bInvert = bVal ;
return true ;
case MPA_TOANDFROM :
m_Params.m_bToAndFrom = bVal ;
return true ;
}
return false ;
}
@@ -192,6 +185,11 @@ Sawing::SetParam( int nType, int nVal)
return false ;
m_Params.m_nHeadSide = nVal ;
return true ;
case MPA_STEPTYPE :
if ( ! m_Params.VerifyStepType( nVal))
return false ;
m_Params.m_nStepType = nVal ;
return true ;
case MPA_LEADINTYPE :
if ( ! m_Params.VerifyLeadInType( nVal))
return false ;
@@ -247,6 +245,12 @@ Sawing::SetParam( int nType, double dVal)
case MPA_DEPTH :
m_Params.m_sDepth = ToString( dVal) ;
return true ;
case MPA_STARTPOS :
m_Params.m_dStartPos = dVal ;
return true ;
case MPA_STEP :
m_Params.m_dStep = dVal ;
return true ;
case MPA_SIDEANGLE :
if ( ! m_Params.VerifySideAngle( dVal))
return false ;
@@ -359,7 +363,14 @@ Sawing::Apply( void)
}
// calcolo gli assi macchina
return CalculateAxesValues() ;
if ( ! CalculateAxesValues())
return false ;
// gestione movimenti all'inizio di ogni singolo percorso di lavorazione
if ( ! AdjustStartMovements())
return false ;
return true ;
}
//----------------------------------------------------------------------------
@@ -370,9 +381,6 @@ Sawing::GetParam( int nType, bool& bVal) const
case MPA_INVERT :
bVal = m_Params.m_bInvert ;
return true ;
case MPA_TOANDFROM :
bVal = m_Params.m_bToAndFrom ;
return true ;
}
return false ;
}
@@ -382,12 +390,18 @@ bool
Sawing::GetParam( int nType, int& nVal) const
{
switch ( nType) {
case MPA_TYPE :
nVal = MT_SAWING ;
return true ;
case MPA_WORKSIDE :
nVal = m_Params.m_nWorkSide ;
return true ;
case MPA_HEADSIDE :
nVal = m_Params.m_nHeadSide ;
return true ;
case MPA_STEPTYPE :
nVal = m_Params.m_nStepType ;
return true ;
case MPA_LEADINTYPE :
nVal = m_Params.m_nLeadInType ;
return true ;
@@ -430,6 +444,12 @@ Sawing::GetParam( int nType, double& dVal) const
case MPA_TOOLOFFSL :
dVal = m_TParams.m_dOffsL ;
return true ;
case MPA_STARTPOS :
dVal = m_Params.m_dStartPos ;
return true ;
case MPA_STEP :
dVal = m_Params.m_dStep ;
return true ;
case MPA_SIDEANGLE :
dVal = m_Params.m_dSideAngle ;
return true ;
@@ -472,6 +492,16 @@ Sawing::GetToolData( void) const
return m_TParams ;
}
//----------------------------------------------------------------------------
bool
Sawing::AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP)
{
// compenso il raggio dell'utensile
ptP += pCamData->GetCorrDir() * ( m_TParams.m_dDiam / 2) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::VerifyGeometry( SelData Id, int& nSubs)
@@ -776,21 +806,24 @@ Sawing::PathApply( int nPathId, int nClId)
ExeLuaSetGlobNumVar( "RB", dRbDist) ;
double dDepth ;
if ( ! ExeLuaEvalNumExpr( m_Params.m_sDepth, &dDepth)) {
string sOut = "Depth not computable by Sawing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
LOG_INFO( GetEMkLogger(), "Error in Sawing : Depth not computable") ;
return false ;
}
// determino l'eccesso di taglio
double dExtraCut = max( 0., dDepth - dRbDist) ;
// correzione per angolo di fianco
if ( fabs( m_Params.m_dSideAngle) > EPS_ANG_SMALL) {
// generale
dDepth /= cos( m_Params.m_dSideAngle * DEGTORAD) ;
double dCoeff = 1 / cos( m_Params.m_dSideAngle * DEGTORAD) ;
dDepth *= dCoeff ;
dExtraCut *= dCoeff ;
// se sottosquadra (controllo il lato opposto della lama, quindi ...)
if ( m_Params.m_dSideAngle < 0)
dDepth += m_TParams.m_dThick * tan( abs( m_Params.m_dSideAngle) * DEGTORAD) ;
}
// verifico di non superare il massimo materiale
if ( dDepth > m_TParams.m_dMaxMat) {
string sOut = "Depth bigger than MaxMaterial" ;
string sOut = "Error in Sawing : Depth bigger than MaxMaterial" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
@@ -813,7 +846,7 @@ Sawing::PathApply( int nPathId, int nClId)
const ICurve* pCrvN = pCompo->GetCurve( k) ;
// elaborazioni sulla curva corrente
string sName = sPathName + "_" + ToString( i) ;
if ( ! EntityApply( pCrvP, pCrvC, pCrvN, dDepth, i == 0, i == nMaxInd, sName, nClId))
if ( ! EntityApply( pCrvP, pCrvC, pCrvN, dDepth, dExtraCut, i == 0, i == nMaxInd, sName, nClId))
return false ;
}
@@ -823,7 +856,8 @@ Sawing::PathApply( int nPathId, int nClId)
//----------------------------------------------------------------------------
bool
Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN,
double dDepth, bool bIsFirst, bool bIsLast, const string& sName, int nClId)
double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast,
const string& sName, int nClId)
{
// se non è una linea, la salto
if ( pCrvC->GetType() != CRV_LINE)
@@ -839,14 +873,12 @@ Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCr
// calcolo i versori fresa e correzione
Vector3d vtTool, vtCorr ;
if ( ! CalculateToolAndCorrVersors( Get( pLine), vtTool, vtCorr)) {
string sOut = "Entity not versorable by Sawing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
LOG_INFO( GetEMkLogger(), "Error in Sawing : Entity CalculateToolAndCorrVersors") ;
return false ;
}
// correzioni per lato lama, lato mandrino
if ( ! AdjustForSide( Get( pLine))) {
string sOut = "Entity not offsetable by Sawing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
LOG_INFO( GetEMkLogger(), "Error in Sawing : Entity AdjustForSide") ;
return false ;
}
// aggiungo affondamento
@@ -856,8 +888,7 @@ Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCr
Vector3d vtThick = vtTool * m_TParams.m_dThick ;
if ( ! GetElevation( pLine->GetStart(), pLine->GetEnd(), vtCorr, dElev) ||
! GetElevation( pLine->GetStart() + vtThick, pLine->GetEnd() + vtThick, vtCorr, dElev2) ) {
string sOut = "Entity not elevation-enabled by Sawing" ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
LOG_INFO( GetEMkLogger(), "Error in Sawing : Entity GetElevation") ;
return false ;
}
dElev = max( dElev, dElev2) ;
@@ -887,35 +918,184 @@ Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCr
bExtAngCN = false ;
}
// aggiusto per tipo estremi
AdjustForEdges( Get( pLine), dElev, bIsFirst, bIsLast, bExtAngPC, bExtAngCN) ;
// recupero distanza di approccio
double dAppr = GetApproachDist() ;
// correzione per angolo di fianco
if ( fabs( m_Params.m_dSideAngle) > EPS_ANG_SMALL)
dAppr /= cos( m_Params.m_dSideAngle * DEGTORAD) ;
// imposto dati comuni
bool bToSkip = false ;
if ( ! AdjustForEdges( Get( pLine), dElev, vtThick, bIsFirst, bIsLast, bExtAngPC, bExtAngCN, bToSkip)) {
LOG_INFO( GetEMkLogger(), "Error in Sawing : Entity AdjustForEdges") ;
return false ;
}
if ( bToSkip) {
LOG_INFO( GetEMkLogger(), "Warning in Sawing : skipped Entity too small") ;
return true ;
}
// Imposto dati comuni
SetPathId( nPxId) ;
SetToolDir( vtTool) ;
SetCorrDir( vtCorr) ;
// 1 -> punto sopra inizio
Point3d ptP1 = pLine->GetStart() + vtCorr * ( dElev + dAppr) ;
if ( AddStart( ptP1) == GDB_ID_NULL)
return false ;
// 2 -> movimento al punto iniziale
SetFeed( m_TParams.m_dTipFeed) ;
Point3d ptP2 = pLine->GetStart() ;
if ( AddLinearMove( ptP2) == GDB_ID_NULL)
return false ;
// 3 -> movimento al punto finale
SetFeed( m_TParams.m_dFeed) ;
Point3d ptP3 = pLine->GetEnd() ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// 4 -> movimento di risalita sopra il punto finale
SetFeed( m_TParams.m_dFeed) ;
Point3d ptP4 = pLine->GetEnd() + vtCorr * ( dElev + dAppr) ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
// recupero distanza di sicurezza
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
// lunghezza di approccio/retrazione
double dAppr = m_Params.m_dStartPos ;
if ( fabs( m_Params.m_dSideAngle) > EPS_ANG_SMALL)
dAppr /= cos( m_Params.m_dSideAngle * DEGTORAD) ;
// Se una sola passata
if ( m_Params.m_dStep < EPS_SMALL) {
// 1 -> approccio
if ( ! AddApproach( pLine->GetStart(), vtCorr, dSafeZ, dElev, dAppr))
return false ;
// 2 -> movimento in affondo al punto iniziale
SetFlag( 0) ;
SetFeed( m_TParams.m_dTipFeed) ;
Point3d ptP2 = pLine->GetStart() ;
if ( AddLinearMove( ptP2) == GDB_ID_NULL)
return false ;
// 3 -> movimento di lato al punto finale
SetFeed( m_TParams.m_dFeed) ;
Point3d ptP3 = pLine->GetEnd() ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// 4 -> retrazione
if ( ! AddRetract( pLine->GetEnd(), vtCorr, dSafeZ, dElev, dAppr))
return false ;
}
// Se step a Zig-Zag o ToAndFrom
else if ( m_Params.m_nStepType == SAW_ST_ZIGZAG || m_Params.m_nStepType == SAW_ST_TOANDFROM) {
// 1 -> approccio
if ( ! AddApproach( pLine->GetStart(), vtCorr, dSafeZ, dElev, dAppr))
return false ;
// 2-3 -> lavorazione (sempre numero pari di passate)
// calcolo numero e valore degli step
double dCutH = dElev - dExtraCut ;
int nStep = 2 ;
if ( m_Params.m_nStepType == SAW_ST_ZIGZAG) {
nStep = static_cast<int>( ceil( dCutH / m_Params.m_dStep)) ;
if ( ( nStep % 2) == 1)
nStep += 1 ;
}
double dStep = dCutH / nStep ;
// esecuzione degli step
for ( int i = nStep - 1 ; i >= 0 ; -- i) {
// distanza dal fondo
double dDelta = ( ( i != 0) ? dExtraCut + i * dStep : 0) ;
// estremi del movimento (dispari vanno, pari tornano)
Point3d ptP2 = pLine->GetStart() + vtCorr * dDelta ;
Point3d ptP3 = pLine->GetEnd() + vtCorr * dDelta ;
if ( ( i % 2) == 0)
swap( ptP2, ptP3) ;
// movimento in affondo
SetFlag( 0) ;
SetFeed( m_TParams.m_dTipFeed) ;
if ( AddLinearMove( ptP2) == GDB_ID_NULL)
return false ;
// movimento di lato
SetFeed( m_TParams.m_dFeed) ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
}
// 4 -> retrazione
if ( ! AddRetract( pLine->GetStart(), vtCorr, dSafeZ, dElev, dAppr))
return false ;
}
// Altrimenti step a una via
else {
// 1 -> approccio
if ( ! AddApproach( pLine->GetStart(), vtCorr, dSafeZ, dElev, dAppr))
return false ;
// 2-3 -> lavorazione
// calcolo numero e valore degli step
double dCutH = dElev - dExtraCut ;
int nStep = static_cast<int>( ceil( dCutH / m_Params.m_dStep)) ;
double dStep = dCutH / nStep ;
// esecuzione degli step
for ( int i = nStep - 1 ; i >= 0 ; -- i) {
// distanza dal fondo
double dDelta = ( ( i != 0) ? dExtraCut + i * dStep : 0) ;
// movimento in affondo al punto iniziale
SetFlag( 0) ;
SetFeed( m_TParams.m_dTipFeed) ;
Point3d ptP2 = pLine->GetStart() + vtCorr * dDelta ;
if ( AddLinearMove( ptP2) == GDB_ID_NULL)
return false ;
// movimento di lato al punto finale
SetFeed( m_TParams.m_dFeed) ;
Point3d ptP3 = pLine->GetEnd() + vtCorr * dDelta ;
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
return false ;
// se non è ultimo passo
if ( i != 0) {
// movimento di risalita sopra il punto finale
SetFeed( m_TParams.m_dEndFeed) ;
Point3d ptP4 = pLine->GetEnd() + vtCorr * ( dElev + dAppr) ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
// movimento di ritorno spora il punto iniziale
SetFeed( m_TParams.m_dEndFeed) ;
Point3d ptP5 = pLine->GetStart() + vtCorr * ( dElev + dAppr) ;
if ( AddLinearMove( ptP5) == GDB_ID_NULL)
return false ;
}
}
// 4 -> retrazione
if ( ! AddRetract( pLine->GetEnd(), vtCorr, dSafeZ, dElev, dAppr))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::AddApproach( const Point3d& ptP, const Vector3d& vtCorr, double dSafeZ, double dElev, double dAppr)
{
// se distanza di sicurezza minore di distanza di inizio
if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) {
// 1 -> punto sopra inizio
SetFlag( 1) ;
Point3d ptP1 = ptP + vtCorr * ( dElev + dAppr) ;
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
return false ;
}
else {
// 1a -> punto sopra inizio
SetFlag( 1) ;
Point3d ptP1b = ptP + vtCorr * ( dElev + dAppr) ;
Point3d ptP1a = ptP1b + Z_AX * ( dSafeZ - m_Params.m_dStartPos) ;
if ( AddRapidStart( ptP1a) == GDB_ID_NULL)
return false ;
// 1b -> punto appena sopra inizio
SetFlag( 0) ;
if ( AddRapidMove( ptP1b) == GDB_ID_NULL)
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::AddRetract( const Point3d& ptP, const Vector3d& vtCorr, double dSafeZ, double dElev, double dAppr)
{
if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) {
// 4 -> movimento di risalita sopra il punto finale
SetFeed( m_TParams.m_dEndFeed) ;
Point3d ptP4 = ptP + vtCorr * ( dElev + dAppr) ;
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
return false ;
}
else {
// 4a -> movimento di risalita appena sopra il punto finale
SetFeed( m_TParams.m_dEndFeed) ;
Point3d ptP4a = ptP + vtCorr * ( dElev + dAppr) ;
if ( AddLinearMove( ptP4a) == GDB_ID_NULL)
return false ;
// 4b -> movimento di risalita sopra il punto finale
Point3d ptP4b = ptP4a + Z_AX * ( dSafeZ - m_Params.m_dStartPos) ;
if ( AddRapidMove( ptP4b) == GDB_ID_NULL)
return false ;
}
return true ;
}
@@ -983,7 +1163,8 @@ Sawing::AdjustForSide( ICurve* pCurve)
//----------------------------------------------------------------------------
bool
Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN)
Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick,
bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN, bool& bToSkip)
{
// distanza XY tra centro e bordo taglio
double dDeltaT = (( dElev < 0.5 * m_TParams.m_dDiam) ? sqrt( dElev * m_TParams.m_dDiam - dElev * dElev) : 0) ;
@@ -993,18 +1174,58 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIs
dDeltaI = - dDeltaT ;
else if ( bIsFirst) {
if ( m_Params.m_nLeadInType == SAW_LI_STRICT)
// all'interno
dDeltaI = - dDeltaT ;
else if ( m_Params.m_nLeadInType == SAW_LI_OUT)
// all'esterno
dDeltaI = dDeltaT ;
else if ( m_Params.m_nLeadInType == SAW_LI_EXT_CENT)
; // estendere al bordo del grezzo
else if ( m_Params.m_nLeadInType == SAW_LI_EXT_OUT)
; // estendere al bordo del grezzo e aggiungere dDeltaT
else if ( m_Params.m_nLeadInType == SAW_LI_EXT_CENT) {
// porto il centro lama sul bordo del grezzo
// calcolo punto di inizio e direzione (sono in globale)
Point3d ptP ;
pLine->GetStartPoint( ptP) ;
Vector3d vtDir ;
pLine->GetStartDir( vtDir) ;
// determino la distanza dal bordo del grezzo
double dDist = 0, dDist2 = 0 ;
if ( ! GetDistanceFromRawSide( ptP, - vtDir, dDist) &&
! GetDistanceFromRawSide( ptP + vtThick, - vtDir, dDist2))
return false ;
dDeltaI = max( dDist, dDist2) ;
}
else if ( m_Params.m_nLeadInType == SAW_LI_EXT_OUT) {
// estendo all'esterno del bordo del grezzo
// calcolo punto di inizio e direzione (sono in globale)
Point3d ptP ;
pLine->GetStartPoint( ptP) ;
Vector3d vtDir ;
pLine->GetStartDir( vtDir) ;
// determino la distanza dal bordo del grezzo
double dDist = 0, dDist2 = 0 ;
if ( ! GetDistanceFromRawSide( ptP, - vtDir, dDist) ||
! GetDistanceFromRawSide( ptP + vtThick, - vtDir, dDist2))
return false ;
dDeltaI = max( dDist, dDist2) + dDeltaT ;
}
}
else {
if ( m_Params.m_nExtLinkType == SAW_EL_EXT_NEXT ||
m_Params.m_nExtLinkType == SAW_EL_EXT_BOTH) {
; // estendere al bordo del grezzo se LeadIn EXT_OUT aggiungere dDeltaT
// estendere al bordo del grezzo
// calcolo punto di inizio e direzione (sono in globale)
Point3d ptP ;
pLine->GetStartPoint( ptP) ;
Vector3d vtDir ;
pLine->GetStartDir( vtDir) ;
// determino la distanza dal bordo del grezzo
double dDist = 0, dDist2 = 0 ;
if ( ! GetDistanceFromRawSide( ptP, - vtDir, dDist) ||
! GetDistanceFromRawSide( ptP + vtThick, - vtDir, dDist2))
return false ;
dDeltaI = max( dDist, dDist2) ;
// se LeadIn EXT_OUT vado all'esterno
if ( m_Params.m_nLeadInType == SAW_LI_EXT_OUT)
dDeltaI += dDeltaT ;
}
}
// verifiche e aggiustamenti sulla fine
@@ -1012,22 +1233,48 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIs
if ( ! bExtAngCN)
dDeltaF = - dDeltaT ;
else if ( bIsLast) {
if ( m_Params.m_nLeadOutType == SAW_LI_STRICT)
if ( m_Params.m_nLeadOutType == SAW_LO_STRICT)
dDeltaF = - dDeltaT ;
else if ( m_Params.m_nLeadInType == SAW_LO_EXT)
; // estendere al bordo del grezzo
else if ( m_Params.m_nLeadInType == SAW_LO_EXT) {
// estendo al bordo del grezzo
// calcolo punto di fine e direzione (sono in globale)
Point3d ptP ;
pLine->GetEndPoint( ptP) ;
Vector3d vtDir ;
pLine->GetEndDir( vtDir) ;
// determino la distanza dal bordo del grezzo
double dDist = 0, dDist2 = 0 ;
if ( ! GetDistanceFromRawSide( ptP, vtDir, dDist) ||
! GetDistanceFromRawSide( ptP + vtThick, vtDir, dDist2))
return false ;
dDeltaF = max( dDist, dDist2) ;
}
}
else {
if ( m_Params.m_nExtLinkType == SAW_EL_EXT_PREV ||
m_Params.m_nExtLinkType == SAW_EL_EXT_BOTH) {
; // estendere al bordo del grezzo
// estendo al bordo del grezzo
// calcolo punto di fine e direzione (sono in globale)
Point3d ptP ;
pLine->GetEndPoint( ptP) ;
Vector3d vtDir ;
pLine->GetEndDir( vtDir) ;
// determino la distanza dal bordo del grezzo
double dDist = 0, dDist2 = 0 ;
if ( ! GetDistanceFromRawSide( ptP, vtDir, dDist) ||
! GetDistanceFromRawSide( ptP + vtThick, vtDir, dDist2))
return false ;
dDeltaF = max( dDist, dDist2) ;
}
}
// controllo se lunghezza entità accettabile
const double MIN_LEN = 10 ;
double dLenXY = DistXY( pLine->GetStart(), pLine->GetEnd()) ;
if ( dDeltaI + dLenXY + dDeltaF < MIN_LEN)
return false ;
if ( dDeltaI + dLenXY + dDeltaF < MIN_LEN) {
bToSkip = true ;
return true ;
}
bToSkip = false ;
// modifico gli estremi
if ( dDeltaF > EPS_SMALL)
pLine->ExtendEndByLen( dDeltaF) ;
@@ -1040,37 +1287,3 @@ Sawing::AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIs
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::AdjustPositionForAxesCalc( const CamData* pCamData, Point3d& ptP)
{
// compenso il raggio dell'utensile
ptP += pCamData->GetCorrDir() * ( m_TParams.m_dDiam / 2) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::GetDistanceFromRawBottom( int nPathId, double dToler, double & dRbDist)
{
// recupero distanza da fondo dei grezzi interessati dal percorso
dRbDist = 0 ;
BBox3d b3Compo ;
if ( ! m_pGeomDB->GetGlobalBBox( nPathId, b3Compo))
return false ;
b3Compo.Expand( dToler, dToler, 0) ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
BBox3d b3Raw ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Compo.OverlapsXY( b3Raw)) {
double dDist = b3Compo.GetMax().z - b3Raw.GetMin().z ;
if ( dDist > dRbDist)
dRbDist = dDist ;
}
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
}
return true ;
}
+6 -3
View File
@@ -56,11 +56,14 @@ class Sawing : public Machining
bool Chain( int nGrpDestId) ;
bool PathApply( int nPathId, int nClId) ;
bool EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN,
double dDepth, bool bIsFirst, bool bIsLast, const std::string& sName, int nClId) ;
double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast,
const std::string& sName, int nClId) ;
bool CalculateToolAndCorrVersors( const ICurve* pCurve, Vector3d& vtTool, Vector3d& vtCorr) ;
bool AdjustForSide( ICurve* pCurve) ;
bool AdjustForEdges( ICurveLine* pLine, double dElev, bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN) ;
bool GetDistanceFromRawBottom( int nPathId, double dToler, double& dRbDist) ;
bool AdjustForEdges( ICurveLine* pLine, double dElev, const Vector3d& vtThick,
bool bIsFirst, bool bIsLast, bool bExtAngPC, bool bExtAngCN, bool& ToSkip) ;
bool AddApproach( const Point3d& ptP, const Vector3d& vtCorr, double dSafeZ, double dElev, double dAppr) ;
bool AddRetract( const Point3d& ptP, const Vector3d& vtCorr, double dSafeZ, double dElev, double dAppr) ;
private :
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
+53 -13
View File
@@ -34,8 +34,10 @@ enum nSawingKey {
KEY_LITY,
KEY_LOTY,
KEY_NAME,
KEY_PS,
KEY_SA,
KEY_TAF,
KEY_ST,
KEY_STY,
KEY_TNAME,
KEY_TUUID,
KEY_UUID,
@@ -52,8 +54,10 @@ static const std::array<std::string,KEY_ZZZ> sSawingKey = {
"LITY",
"LOTY",
"NAME",
"PS",
"SA",
"TAF",
"ST",
"STY",
"TN",
"TU",
"UUID",
@@ -97,8 +101,10 @@ SawingData::CopyFrom( const MachiningData* pMdata)
m_bInvert = pSdata->m_bInvert ;
m_nWorkSide = pSdata->m_nWorkSide ;
m_nHeadSide = pSdata->m_nHeadSide ;
m_bToAndFrom = pSdata->m_bToAndFrom ;
m_sDepth = pSdata->m_sDepth ;
m_dStartPos = pSdata->m_dStartPos ;
m_dStep = pSdata->m_dStep ;
m_nStepType = pSdata->m_nStepType ;
m_dSideAngle = pSdata->m_dSideAngle ;
m_nLeadInType = pSdata->m_nLeadInType ;
m_nExtLinkType = pSdata->m_nExtLinkType ;
@@ -127,8 +133,10 @@ SawingData::SameAs(const MachiningData* pMdata) const
m_bInvert == pSdata->m_bInvert &&
m_nWorkSide == pSdata->m_nWorkSide &&
m_nHeadSide == pSdata->m_nHeadSide &&
m_bToAndFrom == pSdata->m_bToAndFrom &&
m_sDepth == pSdata->m_sDepth &&
m_dStartPos == pSdata->m_dStartPos &&
m_dStep == pSdata->m_dStep &&
m_nStepType == pSdata->m_nStepType &&
m_dSideAngle == pSdata->m_dSideAngle &&
m_nLeadInType == pSdata->m_nLeadInType &&
m_nExtLinkType == pSdata->m_nExtLinkType &&
@@ -203,11 +211,17 @@ SawingData::FromString( const string& sString, int& nKey)
m_sName = sVal ;
bOk = ! m_sName.empty() ;
break ;
case KEY_PS :
bOk = ::FromString( sVal, m_dStartPos) ;
break ;
case KEY_SA :
bOk = ::FromString( sVal, m_dSideAngle) ;
break ;
case KEY_TAF :
bOk = ::FromString( sVal, m_bToAndFrom) ;
case KEY_ST :
bOk = ::FromString( sVal, m_dStep) ;
break ;
case KEY_STY :
bOk = ::FromString( sVal, m_nStepType) ;
break ;
case KEY_TNAME :
m_sToolName = sVal ;
@@ -242,8 +256,10 @@ SawingData::ToString( int nInd) const
case KEY_LITY : return ( sSawingKey[KEY_LITY] + "=" + ::ToString( m_nLeadInType)) ;
case KEY_LOTY : return ( sSawingKey[KEY_LOTY] + "=" + ::ToString( m_nLeadOutType)) ;
case KEY_NAME : return ( sSawingKey[KEY_NAME] + "=" + m_sName) ;
case KEY_PS : return ( sSawingKey[KEY_PS] + "=" + ::ToString( m_dStartPos)) ;
case KEY_SA : return ( sSawingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ;
case KEY_TAF : return ( sSawingKey[KEY_TAF] + "=" + ::ToString( m_bToAndFrom)) ;
case KEY_ST : return ( sSawingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ;
case KEY_STY : return ( sSawingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ;
case KEY_TNAME : return ( sSawingKey[KEY_TNAME] + "=" + m_sToolName) ;
case KEY_TUUID : return ( sSawingKey[KEY_TUUID] + "=" + ::ToString( m_ToolUuid)) ;
case KEY_UUID : return ( sSawingKey[KEY_UUID] + "=" + ::ToString( m_Uuid)) ;
@@ -266,6 +282,13 @@ SawingData::VerifyHeadSide( int nVal) const
return ( nVal == SAW_HS_LEFT || nVal == SAW_HS_RIGHT) ;
}
//----------------------------------------------------------------------------
bool
SawingData::VerifyStepType( int nVal) const
{
return ( nVal == SAW_ST_ZIGZAG || nVal == SAW_ST_ONEWAY || nVal == SAW_ST_TOANDFROM) ;
}
//----------------------------------------------------------------------------
bool
SawingData::VerifyLeadInType( int nVal) const
@@ -327,9 +350,6 @@ SawingData::SetParam( int nType, bool bVal)
case MPA_INVERT :
m_bInvert = bVal ;
return true ;
case MPA_TOANDFROM :
m_bToAndFrom = bVal ;
return true ;
}
return false ;
}
@@ -349,6 +369,11 @@ SawingData::SetParam( int nType, int nVal)
return false ;
m_nHeadSide = nVal ;
return true ;
case MPA_STEPTYPE :
if ( ! VerifyStepType( nVal))
return false ;
m_nStepType = nVal ;
return true ;
case MPA_LEADINTYPE :
if ( ! VerifyLeadInType( nVal))
return false ;
@@ -381,6 +406,12 @@ SawingData::SetParam( int nType, double dVal)
case MPA_DEPTH :
m_sDepth = ::ToString( dVal) ;
return true ;
case MPA_STARTPOS :
m_dStartPos = dVal ;
return true ;
case MPA_STEP :
m_dStep = dVal ;
return true ;
case MPA_SIDEANGLE :
if ( ! VerifySideAngle( dVal))
return false ;
@@ -423,9 +454,6 @@ SawingData::GetParam( int nType, bool& bVal) const
case MPA_INVERT :
bVal = m_bInvert ;
return true ;
case MPA_TOANDFROM :
bVal = m_bToAndFrom ;
return true ;
}
return false ;
}
@@ -435,12 +463,18 @@ bool
SawingData::GetParam( int nType, int& nVal) const
{
switch ( nType) {
case MPA_TYPE :
nVal = MT_SAWING ;
return true ;
case MPA_WORKSIDE :
nVal = m_nWorkSide ;
return true ;
case MPA_HEADSIDE :
nVal = m_nHeadSide ;
return true ;
case MPA_STEPTYPE :
nVal = m_nStepType ;
return true ;
case MPA_LEADINTYPE :
nVal = m_nLeadInType ;
return true ;
@@ -462,6 +496,12 @@ bool
SawingData::GetParam( int nType, double& dVal) const
{
switch ( nType) {
case MPA_STARTPOS :
dVal = m_dStartPos ;
return true ;
case MPA_STEP :
dVal = m_dStep ;
return true ;
case MPA_SIDEANGLE :
dVal = m_dSideAngle ;
return true ;
+6 -2
View File
@@ -23,8 +23,10 @@ struct SawingData : public MachiningData
bool m_bInvert ; // flag di inversione direzione lavorazione
int m_nWorkSide ; // lato di lavoro (destra, sinistra, centro)
int m_nHeadSide ; // lato di posizionamento del mandrino ( destra o sinistra)
bool m_bToAndFrom ; // taglio avanti-indietro
std::string m_sDepth ; // affondamento (espressione numerica)
double m_dStartPos ; // quota di inizio lavorazione (sempre >= 0)
double m_dStep ; // passo di affondamento (0=nessun passo)
int m_nStepType ; // tipo di lavorazione a step (a gradini, una via, va e vieni)
double m_dSideAngle ; // angolo di sbandamento (0..+60deg, 99=auto)
int m_nLeadInType ; // tipo di attacco (interno, centro, fuori, esteso, esteso fuori)
int m_nExtLinkType ; // tipo di collegamento su ang esterno ( centro, esteso prec, esteso succ, esteso minore)
@@ -33,7 +35,8 @@ struct SawingData : public MachiningData
double m_dApprox ; // valore di approssimazione per curve
SawingData( void)
: m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_bToAndFrom( false), m_dSideAngle( 0),
: m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0),
m_dStartPos( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0),
m_nLeadInType( 0), m_nExtLinkType( 0), m_nLeadOutType( 0), m_nCurveUse( 0), m_dApprox( 0) {}
virtual SawingData* Clone( void) const ;
virtual bool CopyFrom( const MachiningData* pMdata) ;
@@ -54,6 +57,7 @@ struct SawingData : public MachiningData
virtual bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const ;
bool VerifyWorkSide( int nVal) const ;
bool VerifyHeadSide( int nVal) const ;
bool VerifyStepType( int nVal) const ;
bool VerifyLeadInType( int nVal) const ;
bool VerifyExtLinkType( int nVal) const ;
bool VerifyLeadOutType( int nVal) const ;
+42 -2
View File
@@ -108,13 +108,16 @@ Simulator::Move( int& nStatus)
m_dCoeff = 0 ;
}
// Se arrivato alla fine di un percorso di lavoro, recupero un nuovo CLpath
if ( m_nEntId == GDB_ID_NULL) {
while ( m_nEntId == GDB_ID_NULL) {
m_nCLPathId = m_pGeomDB->GetNextGroup( m_nCLPathId) ;
// se non ce ne sono altri, devo passare a una nuova lavorazione
if ( m_nCLPathId == GDB_ID_NULL)
break ;
m_nEntId = m_pGeomDB->GetFirstInGroup( m_nCLPathId) ;
m_dCoeff = 0 ;
}
// Se arrivato alla fine di una lavorazione, recupero la successiva
if ( m_nCLPathId == GDB_ID_NULL) {
while ( m_nCLPathId == GDB_ID_NULL) {
m_nOpId = m_pMchMgr->GetNextOperation( m_nOpId) ;
// se non ce ne sono altre, sono alla fine
if ( m_nOpId == GDB_ID_NULL) {
@@ -191,6 +194,43 @@ Simulator::GetAxisInfoPos( int nI, string& sName, double& dVal)
return m_pMchMgr->GetAxisPos( sName, dVal) ;
}
//----------------------------------------------------------------------------
bool
Simulator::GetToolInfo( string& sName, double& dSpeed)
{
// Verifiche
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// Assegno il nome dell'utensile
if ( m_sTool.empty())
return false ;
sName = m_sTool ;
// Recupero speed
Machining* pMch = dynamic_cast<Machining*>( m_pGeomDB->GetUserObj( m_nOpId)) ;
return ( pMch != nullptr && pMch->GetParam( MPA_TOOLSPEED, dSpeed)) ;
}
//----------------------------------------------------------------------------
bool
Simulator::GetMoveInfo( int& nGmove, double& dFeed)
{
// Verifiche
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// Recupero il movimento corrente
CamData* pCamData = dynamic_cast<CamData*>( m_pGeomDB->GetUserObj( m_nEntId)) ;
if ( pCamData == nullptr)
return false ;
// Assegno feed
dFeed = pCamData->GetFeed() ;
// Assegno tipo di movimento
if ( dFeed < EPS_SMALL)
nGmove = 0 ;
else
nGmove = 1 ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::SetStep( double dStep)
+2
View File
@@ -29,6 +29,8 @@ class Simulator
bool Start( void) ;
bool Move( int& nStatus) ;
bool GetAxisInfoPos( int nI, std::string& sName, double& dVal) ;
bool GetToolInfo( std::string& sName, double& dSpeed) ;
bool GetMoveInfo( int& nGmove, double& dFeed) ;
bool SetStep( double dStep) ;
bool Stop( void) ;