Merge remote-tracking branch 'origin/master' into Sara

This commit is contained in:
SaraP
2021-08-11 15:06:56 +02:00
21 changed files with 260 additions and 162 deletions
+10 -10
View File
@@ -895,11 +895,11 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC)
// ammessi : curve, testi, facce di trimesh o regioni
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
if ( pGObj == nullptr)
return nullptr ;
return false ;
// ne recupero il riferimento globale
Frame3d frGlob ;
if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob))
return nullptr ;
return false ;
// se curva
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
PtrOwner<ICurve> pCurve ;
@@ -935,7 +935,7 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC)
}
}
if ( IsNull( pCurve))
return nullptr ;
return false ;
// la porto in globale
pCurve->ToGlob( frGlob) ;
// la restituisco
@@ -962,23 +962,23 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC)
// recupero la trimesh
const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ;
if ( pSurf == nullptr)
return nullptr ;
return false ;
// recupero l'indice della faccia
int nFacet = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ;
// recupero i contorni della faccia
POLYLINEVECTOR vPL ;
pSurf->GetFacetLoops( nFacet, vPL) ;
if ( vPL.empty())
return nullptr ;
return false ;
// recupero la normale esterna della faccia
Vector3d vtN ;
if ( ! pSurf->GetFacetNormal( nFacet, vtN))
return nullptr ;
return false ;
// creo la curva a partire da quello esterno
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
pCrvCompo->FromPolyLine( vPL[0]) ;
if ( ! pCrvCompo->IsValid())
return nullptr ;
return false ;
// assegno l'estrusione dalla normale alla faccia
pCrvCompo->SetExtrusion( vtN) ;
// unisco le eventuali parti allineate
@@ -1031,7 +1031,7 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC)
}
// altrimenti errore
else
return nullptr ;
return false ;
}
//----------------------------------------------------------------------------
@@ -1313,8 +1313,8 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId)
const double SIN_ANG_LIM = sin( ( ANG_RIGHT - 100 * EPS_ANG_SMALL) * DEGTORAD) ;
if ( dPrevLen > 0.5 * m_TParams.m_dDiam - EPS_SMALL &&
dCurrLen > 0.5 * m_TParams.m_dDiam - EPS_SMALL &&
( dProVett > SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_LEFT) ||
( dProVett < - SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_RIGHT)) {
(( dProVett > SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_LEFT) ||
( dProVett < - SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_RIGHT))) {
Vector3d vtMid = Media( - vtPrevDir, vtCurrDir, 0.5) ;
Point3d ptIni ; pPrevCrv->GetEndPoint( ptIni) ;
ptIni += vtMid * m_TParams.m_dDiam + vtTool * ( dElev - dDepth) ;
BIN
View File
Binary file not shown.
+4 -2
View File
@@ -33,7 +33,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>ClangCL</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@@ -46,7 +46,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>ClangCL</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -131,6 +131,7 @@ copy $(TargetPath) \EgtProg\DllD32</Command>
<OpenMPSupport>true</OpenMPSupport>
<PrecompiledHeader>Use</PrecompiledHeader>
<CompileAs>CompileAsCpp</CompileAs>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -198,6 +199,7 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<WholeProgramOptimization>false</WholeProgramOptimization>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>
+1 -1
View File
@@ -51,7 +51,7 @@ Generator::Run( const string& sCncFile, const string& sInfo)
int nOptExpDays ;
int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
nOpt1, nOpt2, nOptExpDays) ;
if ( ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) {
if ( nRet == KEY_OK && ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) {
// emetto info di log
{ string sOut = "Generator Run : " + sCncFile ;
+2 -2
View File
@@ -204,7 +204,7 @@ class MachMgr : public IMachMgr
bool EraseCurrSetup( void) override ;
// Machinings DataBase
bool MdbGetMachiningNewName( std::string& sName) const override ;
bool MdbAddMachining( const std::string& sName, int nType) ;
bool MdbAddMachining( const std::string& sName, int nType) override ;
bool MdbCopyMachining( const std::string& sSource, const std::string& sName) override ;
bool MdbRemoveMachining( const std::string& sName) override ;
bool MdbGetFirstMachining( int nType, std::string& sName) const override ;
@@ -321,7 +321,7 @@ class MachMgr : public IMachMgr
bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const override ;
bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ;
int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const override ;
bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB,
int& nStat, double& dX, double& dY, double& dZ) const override ;
bool GetCalcPositions( const Point3d& ptP, const DBLVECTOR& vAng,
+2 -2
View File
@@ -445,7 +445,7 @@ MachMgr::TdbReload( void)
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
if ( pTsMgr == nullptr)
return nullptr ;
return false ;
// ricarico il db utensili
return pTsMgr->Reload() ;
}
@@ -782,7 +782,7 @@ MachMgr::GetToolHolderPath( const string& sHeadName, int nExit, int nType) const
// Verifico esista macchina corrente
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
return "" ;
// Recupero il direttorio dei portautensili
string sToolHolderDir ;
if ( ! TdbGetToolHolderDir( sToolHolderDir))
+3 -2
View File
@@ -1031,8 +1031,9 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
int nSide ;
double dDist ;
DistPointCurve distPC( ptTest, *pCurve) ;
if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL ||
(distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT))
if ( distPC.GetDist( dDist) &&
( dDist < 100 * EPS_SMALL ||
( distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)))
break ;
}
}
+1 -1
View File
@@ -107,7 +107,7 @@ MachMgr::VerifyCurrSetup( STRVECTOR& vsErrors)
}
// altrimenti, verifico se uscita coincide con quella indicata nel DB utensili
else {
int nTdbExit ;
int nTdbExit = 0 ;
if ( ! TdbSetCurrTool( sTool) ||
! TdbGetCurrToolParam( TPA_EXIT, nTdbExit) ||
nExit != nTdbExit) {
+3 -3
View File
@@ -589,7 +589,7 @@ Machine::LuaEmtStdHead( lua_State* L)
double dRot1W = 1 ;
LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ;
// lettura eventuale campo 'Rot2Stroke' dalla tabella
STROKE Rot2Stroke = { - INFINITO, INFINITO} ;
STROKE Rot2Stroke{ -INFINITO, INFINITO} ;
LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ;
// lettura eventuale campo 'SolCh' dalla tabella
int nSolCh = MCH_SCC_NONE ;
@@ -667,7 +667,7 @@ Machine::LuaEmtMultiHead( lua_State* L)
double dRot1W = 1 ;
LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ;
// lettura eventuale campo 'Rot2Stroke' dalla tabella
STROKE Rot2Stroke = { - INFINITO, INFINITO} ;
STROKE Rot2Stroke{ -INFINITO, INFINITO} ;
LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ;
// lettura eventuale campo 'SolCh' dalla tabella
int nSolCh = MCH_SCC_NONE ;
@@ -734,7 +734,7 @@ Machine::LuaEmtSpecialHead( lua_State* L)
double dRot1W = 1 ;
LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ;
// lettura eventuale campo 'Rot2Stroke' dalla tabella
STROKE Rot2Stroke = { - INFINITO, INFINITO} ;
STROKE Rot2Stroke{ -INFINITO, INFINITO} ;
LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ;
// lettura eventuale campo 'SolCh' dalla tabella
int nSolCh = MCH_SCC_NONE ;
+2 -2
View File
@@ -24,11 +24,11 @@ CreateMachining( int nMchType)
{
// verifico sia richiesto un oggetto utente di tipo lavorazione
if ( ! IsValidMachiningType( nMchType))
return false ;
return nullptr ;
// creo l'oggetto
IUserObj* pUsrObj = USEROBJ_CREATE( GetOperationClass( nMchType)) ;
if ( pUsrObj == nullptr)
return false ;
return nullptr ;
// lo converto a lavorazione
Machining* pMch = GetMachining( pUsrObj) ;
if ( pMch == nullptr)
+18 -11
View File
@@ -3399,14 +3399,16 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
double dElev, double dAppr, bool bOutStart, bool bAboveStart)
{
SetFlag( 1) ;
// se con aggregato da sotto
// se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi)
bool bBottomStart = false ;
if ( m_bAggrBottom) {
// aggiuntivo in Z
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
// distanza dal bordo del pezzo
// distanza dal bordo del pezzo (se negativa il punto è fuori dal grezzo)
double dDistBottom ;
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom))
dDistBottom = 0 ;
bBottomStart = ( dDistBottom < - 10 * EPS_SMALL) ;
// aggiuntivo in Z
double dAggZ = ( bBottomStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ;
// pre-approccio
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
@@ -3439,7 +3441,7 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
// se non sono già sopra il pezzo e sopra attacco c'è spazio per sicurezza o approccio
double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
double dElevZ = vtAppr.z * dElev ;
if ( ! bAboveStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
if ( ! bAboveStart && ! bBottomStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
// se distanza di sicurezza minore di distanza di inizio
if ( dSafeDist < dAppr + 10 * EPS_SMALL) {
// 1 -> punto sopra inizio
@@ -3538,10 +3540,19 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
vtAppr.z = 0 ;
vtAppr.Normalize() ;
}
// se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi)
bool bBottomOutStart = false ;
double dDistBottom ;
if ( m_bAggrBottom) {
// distanza dal bordo del pezzo (se negativa il punto è fuori dal grezzo)
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom))
dDistBottom = 0 ;
bBottomOutStart = ( dDistBottom < - 10 * EPS_SMALL) ;
}
// se non sono già sopra il pezzo e sopra uscita c'è spazio per sicurezza o approccio
double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
double dElevZ = vtAppr.z * dElev ;
if ( ! bAboveEnd && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
if ( ! bAboveEnd && ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
if ( dSafeDist < dAppr + 10 * EPS_SMALL) {
// 4 -> movimento di risalita sopra il punto finale
SetFeed( GetEndFeed()) ;
@@ -3589,11 +3600,7 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
// se con aggregato da sotto
if ( m_bAggrBottom) {
// aggiuntivo in Z
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
// distanza dal bordo del pezzo
double dDistBottom ;
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom))
dDistBottom = 0 ;
double dAggZ = ( bBottomOutStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ;
// post-retract
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
+33 -20
View File
@@ -407,38 +407,49 @@ Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// recupero il grezzo in cui è incluso il punto
// recupero il grezzo più vicino al punto (entro 100 mm)
const double EXPAND_LEN = 100 ;
BBox3d b3Pnt( ptP) ;
b3Pnt.Expand( 10, 10, 0) ;
int nRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
b3Pnt.Expand( EXPAND_LEN, EXPAND_LEN, 0) ;
double dMinDist = INFINITO ;
int nRawId = GDB_ID_NULL ;
int nCurrRawId = m_pMchMgr->GetFirstRawPart() ;
while ( nCurrRawId != GDB_ID_NULL) {
// verifico che il grezzo compaia nella fase
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) {
if ( m_pMchMgr->VerifyRawPartPhase( nCurrRawId, nPhase)) {
// pre-filtro con il box
BBox3d b3Raw ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nCurrRawId, MACH_RAW_SOLID) ;
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Pnt.OverlapsXY( b3Raw)) {
// porto il punto nel riferimento del grezzo (a Z=0 perchè ivi è il contorno)
Frame3d frRaw ;
m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ;
m_pGeomDB->GetGroupGlobFrame( nCurrRawId, frRaw) ;
Point3d ptPL = ptP ;
ptPL.ToLoc( frRaw) ;
ptPL.z = 0 ;
// verifica con il contorno
int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ;
int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nCurrRawId, MACH_RAW_OUTLINE) ;
const ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ;
if ( pCurve != nullptr) {
int nSide ;
double dDist ;
DistPointCurve distPC( ptPL, *pCurve) ;
if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL ||
(distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT))
break ;
if ( distPC.GetDist( dDist)) {
if ( dDist < 100 * EPS_SMALL ||
(distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) {
nRawId = nCurrRawId ;
break ;
}
else if ( dDist < dMinDist) {
dMinDist = dDist ;
nRawId = nCurrRawId ;
}
}
}
}
}
// passo al grezzo successivo
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
nCurrRawId = m_pMchMgr->GetNextRawPart( nCurrRawId) ;
}
// se il punto non è interno ad alcun grezzo, distanza nulla
if ( nRawId == GDB_ID_NULL) {
@@ -457,14 +468,16 @@ Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3
return false ;
// interseco il raggio di test (portato nel riferimento del contorno) con il contorno del grezzo
const double RAY_LEN = 10000 ;
const double EXTRA_LEN = EXPAND_LEN ;
PtrOwner<ICurveLine> pRay( CreateCurveLine()) ;
if ( IsNull( pRay) || ! pRay->SetPVL( ptP, vtDir, RAY_LEN))
if ( IsNull( pRay) || ! pRay->SetPVL( ptP - vtDir * EXTRA_LEN, vtDir, RAY_LEN))
return false ;
pRay->ToLoc( frStm) ;
IntersCurveCurve intCC( *pRay, *pOut) ;
int nInters = intCC.GetIntersCount() ;
IntCrvCrvInfo aInfo ;
if ( intCC.GetIntCrvCrvInfo( 0, aInfo))
dDist = aInfo.IciA[0].dU * RAY_LEN ;
if ( nInters > 0 && intCC.GetIntCrvCrvInfo( nInters - 1, aInfo))
dDist = aInfo.IciA[0].dU * RAY_LEN - EXTRA_LEN ;
else
dDist = 0 ;
return true ;
@@ -741,11 +754,11 @@ Operation::AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nF
else
break ;
}
// elimino le curve estreme molto corte ( 0.1 mm)
// elimino le curve estreme molto corte ( 0.5 mm)
const double REF_LEN = 10.0 ;
double dLen ;
if ( pCrvCompo->GetLength( dLen) && dLen > REF_LEN) {
const double MIN_LEN = 0.1 ;
const double MIN_LEN = 0.5 ;
double dCrvLen ;
pCrv = pCrvCompo->GetFirstCurve() ;
if ( pCrv != nullptr && pCrv->GetLength( dCrvLen) && dCrvLen < MIN_LEN)
@@ -2036,11 +2049,11 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation*
if ( nPrevClPathId == GDB_ID_NULL) {
if ( pPrevOp == nullptr ||
! pPrevOp->RemoveRise() ||
! pPrevOp->AddRise( vAxNew1, dSafeZ - vAxPrev[2]), GDB_ID_NULL, bZHomeDown)
! pPrevOp->AddRise( vAxNew1, dSafeZ - vAxPrev[2], GDB_ID_NULL, bZHomeDown))
return false ;
}
else {
if ( ! AddRise( vAxNew1, dSafeZ - vAxPrev[2], nPrevClPathId), bZHomeDown)
if ( ! AddRise( vAxNew1, dSafeZ - vAxPrev[2], nPrevClPathId, bZHomeDown))
return false ;
}
// aggiungo posizione elevata prima dell'inizio del percorso corrente
@@ -2471,7 +2484,7 @@ Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR
for ( int i = 0 ; i <= nStep ; ++ i) {
vAng[0] = dR1Start + i * dR1Step ;
vAng[1] = dR2Start + i * dR2Step ;
vAng[2] = dR3Start + i * dR2Step ;
vAng[2] = dR3Start + i * dR3Step ;
Point3d ptTip ;
if ( ! m_pMchMgr->GetCalcTipFromPositions( dL1, dL2, dL3, vAng, true, true, ptTip))
return false ;
+66 -56
View File
@@ -1837,8 +1837,9 @@ Pocketing::GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo)
if ( IsNull( pCrv))
return false ;
// calcolo la regione
PtrOwner<ISurfFlatRegion> pSfr ;
pSfr.Set( GetSurfFlatRegionFromFatCurve( Release( pCrv), 0.5 * m_TParams.m_dDiam, false, false)) ;
SurfFlatRegionByContours SfrCntrRr ;
SfrCntrRr.AddCurve( Release( pCrv)) ;
PtrOwner<ISurfFlatRegion> pSfr( SfrCntrRr.GetSurf()) ;
if ( IsNull( pSfr))
return false ;
// ne recupero il contorno
@@ -1852,7 +1853,7 @@ Pocketing::GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo)
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC2Id, MCH_PV_CUT) ;
m_pGeomDB->SetMaterial( nC2Id, LIME) ;
m_pGeomDB->SetMaterial( nC2Id, RED) ;
// eventuali altri contorni ( interni di contornatura chiusa)
const int MAX_INT_LOOP = 1000 ;
for ( int i = 1 ; i <= MAX_INT_LOOP ; ++i) {
@@ -1866,14 +1867,14 @@ Pocketing::GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo)
return false ;
// assegno nome e colore
m_pGeomDB->SetName( nC3Id, MCH_PV_CUT) ;
m_pGeomDB->SetMaterial( nC3Id, LIME) ;
m_pGeomDB->SetMaterial( nC3Id, RED) ;
}
// inserisco la regione nel DB
int nRId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pSfr)) ;
if ( nRId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nRId, MCH_PV_RCUT) ;
m_pGeomDB->SetMaterial( nRId, INVISIBLE) ;
m_pGeomDB->SetMaterial( nRId, Color( 255, 0, 0, 60)) ;
// la copio anche come regione ridotta
int nRrId = m_pGeomDB->Copy( nRId, GDB_ID_NULL, nPathId) ;
if ( nRrId == GDB_ID_NULL)
@@ -1911,8 +1912,10 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con
// se utensile che non lavora di testa poichè ingresso non fuori dal pezzo, errore
if ( m_TParams.m_nType == TT_MILL_NOTIP) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
if ( ! LeadInIsOk()) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
}
}
// determino numero e affondamento degli step
@@ -2016,11 +2019,10 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con
// determino elevazione su inizio attacco
double dStElev ;
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
bool bUnderStart = m_bAboveHead && GetPointUnderRaw( ptP1, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderStart)
dStElev = max( dStElev, dElev) ;
dStElev = j * dStep ;
bool bUnderRaw = GetPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderRaw == m_bAboveHead)
dStElev = max( dStElev, j * dStep) ;
dStElev -= ( ptP1 - ptStart) * vtExtr ;
// se inizio, approccio globale al punto iniziale
if ( bStart) {
@@ -2156,11 +2158,10 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con
// determino elevazione su inizio attacco
double dStElev ;
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
bool bUnderStart = m_bAboveHead && GetPointUnderRaw( ptP1, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderStart)
dStElev = max( dStElev, dElev) ;
dStElev = dStep ;
bool bUnderRaw = GetPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderRaw == m_bAboveHead)
dStElev = max( dStElev, dStep) ;
dStElev -= ( ptP1 - ptStart) * vtExtr ;
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
@@ -2456,8 +2457,10 @@ Pocketing::AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, con
// se utensile che non lavora di testa poichè ingresso non fuori dal pezzo, errore
if ( m_TParams.m_nType == TT_MILL_NOTIP) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
if ( ! LeadInIsOk()) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
}
}
// determino numero e affondamento degli step
@@ -2523,11 +2526,10 @@ Pocketing::AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, con
// determino elevazione su inizio attacco
double dStElev ;
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
bool bUnderStart = m_bAboveHead && GetPointUnderRaw( ptP1, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderStart)
dStElev = max( dStElev, dElev) ;
dStElev = dStep ;
bool bUnderRaw = GetPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderRaw == m_bAboveHead)
dStElev = max( dStElev, dStep) ;
dStElev -= ( ptP1 - ptStart) * vtExtr ;
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
@@ -2677,11 +2679,10 @@ Pocketing::AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, con
// determino elevazione su inizio attacco
double dStElev ;
if ( ! GetElevation( m_nPhase, ptS - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
bool bUnderStart = m_bAboveHead && GetPointUnderRaw( ptP, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderStart)
dStElev = max( dStElev, dElev) ;
dStElev = j * dStep ;
bool bUnderRaw = GetPointUnderRaw( ptP, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderRaw == m_bAboveHead)
dStElev = max( dStElev, j * dStep) ;
dStElev -= ( ptP - ptS) * vtExtr ;
// sempre approccio di collegamento
if ( ! AddLinkApproach( ptP, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr)) {
@@ -2782,8 +2783,10 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
// se utensile che non lavora di testa e ingresso non fuori dal pezzo, errore
if ( m_TParams.m_nType == TT_MILL_NOTIP && ! bOutStart) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
if ( ! LeadInIsOk()) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
}
}
// determino numero e affondamento degli step
@@ -2819,14 +2822,13 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
// determino inizio attacco
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, pRCrv, ptP1))
return false ;
// determino elevazione su inizio attacco
// determino elevazione su inizio attacco (se non trovata, elevazione è step)
double dStElev ;
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
bool bUnderStart = m_bAboveHead && GetPointUnderRaw( ptP1, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderStart)
dStElev = max( dStElev, dElev) ;
dStElev = dStep ;
bool bUnderRaw = GetPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderRaw == m_bAboveHead)
dStElev = max( dStElev, dStep) ;
dStElev -= ( ptP1 - ptStart) * vtExtr ;
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
@@ -2943,8 +2945,10 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
// se utensile che non lavora di testa poichè ingresso non fuori dal pezzo, errore
if ( m_TParams.m_nType == TT_MILL_NOTIP) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
if ( ! LeadInIsOk()) {
m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ;
return false ;
}
}
// ciclo sulle regioni
@@ -3007,11 +3011,10 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
// determino elevazione su inizio attacco
double dStElev ;
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev))
dStElev = dElev ;
bool bUnderStart = m_bAboveHead && GetPointUnderRaw( ptP1, vtTool, 0,
GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderStart)
dStElev = max( dStElev, dElev) ;
dStElev = dStep ;
bool bUnderRaw = GetPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), m_TParams.m_dLen, false, dSafeZ, dStElev) ;
if ( bUnderRaw == m_bAboveHead)
dStElev = max( dStElev, dStep) ;
dStElev -= ( ptP1 - ptStart) * vtExtr ;
// se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco
if ( GetLeadInType() == POCKET_LI_ZIGZAG ||
@@ -3507,14 +3510,16 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe
double dElev, double dAppr, bool bOutStart)
{
SetFlag( 1) ;
// se con aggregato da sotto
// se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi)
bool bBottomOutStart = false ;
if ( m_bAggrBottom) {
// aggiuntivo in Z
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
// distanza dal bordo del pezzo
// distanza dal bordo del pezzo (se negativa il punto è fuori dal grezzo)
double dDistBottom ;
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom))
dDistBottom = 0 ;
bBottomOutStart = ( dDistBottom < - 10 * EPS_SMALL) ;
// aggiuntivo in Z
double dAggZ = ( bBottomOutStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ;
// pre-approccio
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
@@ -3540,7 +3545,7 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe
}
// se sopra attacco c'è spazio per sicurezza o approccio
double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
if ( dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
// se distanza di sicurezza minore di distanza di inizio
if ( dSafeDist < dAppr + 10 * EPS_SMALL) {
// 1 -> punto sopra inizio
@@ -3629,9 +3634,18 @@ bool
Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
double dElev, double dAppr)
{
// se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi)
bool bBottomOutStart = false ;
double dDistBottom ;
if ( m_bAggrBottom) {
// distanza dal bordo del pezzo
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom))
dDistBottom = 0 ;
bBottomOutStart = ( dDistBottom < - 10 * EPS_SMALL) ;
}
// se sopra uscita c'è spazio per sicurezza o approccio
double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
if ( dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) {
if ( dSafeDist < dAppr + 10 * EPS_SMALL) {
// 4 -> movimento di risalita sopra il punto finale
SetFeed( GetEndFeed()) ;
@@ -3653,14 +3667,10 @@ Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ
return false ;
}
}
// se con aggregato da sotto
// se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi)
if ( m_bAggrBottom) {
// aggiuntivo in Z
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
// distanza dal bordo del pezzo
double dDistBottom ;
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom))
dDistBottom = 0 ;
double dAggZ = ( bBottomOutStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ;
// post-retract
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
+4
View File
@@ -142,6 +142,10 @@ class Pocketing : public Machining
if ( m_Params.m_nLeadInType != POCKET_LI_GLIDE && m_Params.m_dLiElev < 10 * EPS_SMALL)
return POCKET_LI_NONE ;
return m_Params.m_nLeadInType ; }
int LeadInIsOk( void) const
{ if ( m_TParams.m_nType != TT_MILL_NOTIP)
return true ;
return ( GetLeadInType() == POCKET_LI_HELIX && m_Params.m_dLiTang >= 0.49 * m_TParams.m_dDiam && m_Params.m_dLiElev <= 2) ; }
int GetLeadOutType( void) const
{ if ( m_Params.m_dLoTang < std::min( 0.1 * m_TParams.m_dDiam, 1.0))
return POCKET_LO_NONE ;
+2 -2
View File
@@ -847,7 +847,7 @@ SawFinishing::VerifyGeometry( SelData Id, int& nSubs)
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
// se direttamente la curva
if ( Id.nSub == SEL_SUB_ALL) {
pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
pCurve = ::GetCurve( pGObj) ;
if ( pCurve != nullptr) {
if ( pCurve->GetType() == CRV_COMPO)
nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
@@ -857,7 +857,7 @@ SawFinishing::VerifyGeometry( SelData Id, int& nSubs)
}
// altrimenti sottocurva di composita
else {
const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
if ( pCompo != nullptr)
pCurve = pCompo->GetCurve( Id.nSub) ;
nSubs = 0 ;
+2 -2
View File
@@ -805,7 +805,7 @@ SawRoughing::VerifyGeometry( SelData Id, int& nSubs)
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
// se direttamente la curva
if ( Id.nSub == SEL_SUB_ALL) {
pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
pCurve = ::GetCurve( pGObj) ;
if ( pCurve != nullptr) {
if ( pCurve->GetType() == CRV_COMPO)
nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
@@ -815,7 +815,7 @@ SawRoughing::VerifyGeometry( SelData Id, int& nSubs)
}
// altrimenti sottocurva di composita
else {
const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
if ( pCompo != nullptr)
pCurve = pCompo->GetCurve( Id.nSub) ;
nSubs = 0 ;
+9 -5
View File
@@ -1081,7 +1081,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType)
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
// se direttamente la curva
if ( Id.nSub == SEL_SUB_ALL) {
pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
pCurve = ::GetCurve( pGObj) ;
if ( pCurve != nullptr) {
if ( pCurve->GetType() == CRV_COMPO)
nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
@@ -1091,7 +1091,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType)
}
// altrimenti sottocurva di composita
else {
const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
if ( pCompo != nullptr)
pCurve = pCompo->GetCurve( Id.nSub) ;
nSubs = 0 ;
@@ -1241,6 +1241,8 @@ Sawing::GetCurve( SelData Id)
m_Params.m_dSideAngle = ANG_RIGHT - dSideAng ;
m_Params.m_nHeadSide = ( m_Params.m_nWorkSide == SAW_WS_RIGHT ? SAW_HS_LEFT : SAW_HS_RIGHT) ;
}
// assegno estrusione Z+
pCrvCompo->SetExtrusion( Z_AX) ;
// la restituisco
return Release( pCrvCompo) ;
}
@@ -1249,17 +1251,17 @@ Sawing::GetCurve( SelData Id)
// recupero la regione
const ISurfFlatRegion* pReg = ::GetSurfFlatRegion( pGObj) ;
if ( pReg == nullptr)
return false ;
return nullptr ;
// recupero l'indice del chunk
int nChunk = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ;
// recupero il contorno esterno del chunk
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nChunk, 0)))
return false ;
return nullptr ;
// recupero la normale della regione
Vector3d vtN = pReg->GetNormVersor() ;
if ( vtN.IsSmall())
return false ;
return nullptr ;
// assegno l'estrusione dalla normale alla faccia
pCrvCompo->SetExtrusion( vtN) ;
// unisco le eventuali parti allineate
@@ -1288,6 +1290,8 @@ Sawing::GetCurve( SelData Id)
m_Params.m_dSideAngle = ANG_RIGHT - dSideAng ;
m_Params.m_nHeadSide = ( m_Params.m_nWorkSide == SAW_WS_RIGHT ? SAW_HS_LEFT : SAW_HS_RIGHT) ;
}
// assegno estrusione Z+
pCrvCompo->SetExtrusion( Z_AX) ;
// la restituisco
return Release( pCrvCompo) ;
}
+91 -34
View File
@@ -149,6 +149,7 @@ Simulator::Start( bool bFirst)
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INCHES, ! ExeUiUnitsAreMM()) ;
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMSTEP, m_dStep) ;
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_VER, GetEMkVer()) ;
m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MACHNAME, m_pMachine->GetMachineName()) ;
// Richiamo funzione su avvio simulazione
if ( ! OnStart( bFirst))
@@ -415,8 +416,10 @@ Simulator::GoHome( void)
//----------------------------------------------------------------------------
bool
Simulator::UpdateTool( bool bFirst)
Simulator::UpdateTool( bool bFirst, int& nErr)
{
// reset stato di errore da script
nErr = 0 ;
// Recupero l'utensile della lavorazione corrente
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
if ( pMch != nullptr) {
@@ -440,8 +443,12 @@ Simulator::UpdateTool( bool bFirst)
// se cambierà ed esiste il corrente, lo scarico
if ( bDiffTool && ! m_sTool.empty()) {
// eventuale lancio script per scarico utensile
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos))
return false ;
int nCurrErr ;
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
return false ;
}
}
// se prima volta, pulisco la testa
if ( bFirst)
@@ -480,10 +487,14 @@ Simulator::UpdateTool( bool bFirst)
}
// se cambiato oppure prima volta, lancio lo script di selezione
if ( bDiffTool || bFirst) {
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst))
return false ;
int nCurrErr ;
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
return false ;
}
}
return true ;
return ( nErr == 0) ;
}
// Provo con una disposizione
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nOpId)) ;
@@ -494,8 +505,12 @@ Simulator::UpdateTool( bool bFirst)
// se esiste utensile corrente e cambierà, lo scarico
if ( ! m_sTool.empty() && sTool != m_sTool) {
// eventuale lancio script per scarico utensile
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos))
return false ;
int nCurrErr ;
if ( ! OnToolDeselect( sTool, sHead, nExit, sTcPos, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
return false ;
}
}
// carico l'utensile
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
@@ -508,9 +523,13 @@ Simulator::UpdateTool( bool bFirst)
if ( ! UpdateAxes())
return false ;
// eventuale lancio script
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst))
return false ;
return true ;
int nCurrErr ;
if ( ! OnToolSelect( m_sTool, sHead, nExit, sTcPos, bFirst, nCurrErr)) {
nErr = ( nErr != 0 ? nErr : nCurrErr) ;
if ( nCurrErr != 11)
return false ;
}
return ( nErr == 0) ;
}
return false ;
}
@@ -611,8 +630,11 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( m_nOpId)) ;
if ( pMch != nullptr && ! pMch->IsEmpty()) {
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool( bFirst)) {
nStatus = CalcStatusOnError( 0) ;
int nErr ;
if ( ! UpdateTool( bFirst, nErr)) {
string sOut = "Err=" + ToString( nErr) ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
nStatus = CalcStatusOnError( nErr) ;
return false ;
}
++ m_nOpInd ;
@@ -659,8 +681,9 @@ Simulator::FindAndManageOperationStart( bool bStart, bool bFirst, int& nStatus)
// cambio fase
m_pMchMgr->SetCurrPhase( nPhase, ( nPhase == 1)) ;
// aggiorno utensile e assi conseguenti
if ( ! UpdateTool( bFirst)) {
nStatus = CalcStatusOnError( 0) ;
int nErr ;
if ( ! UpdateTool( bFirst, nErr)) {
nStatus = CalcStatusOnError( nErr) ;
return false ;
}
++ m_nOpInd ;
@@ -948,6 +971,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
int nCdInd, nObjInd ;
bool bCollCheck = true ;
// Eseguo movimento assi principali ed eventuali ausiliari
if ( m_bEnabAxes) {
// Calcolo distanza di movimento
double dSqDist = 0 ;
@@ -960,7 +984,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
double dDist = sqrt( dSqDist) ;
if ( dDist > EPS_SMALL) {
double dStep = min( ( nMoveType == 0 ? 2 : 1) * m_dStep, MAX_STEP) ;
int nStep = int( max( dDist / dStep, 1.)) ;
int nStep = max( int( dDist / dStep), 1) ;
m_dCoeff += 1. / nStep ;
if ( m_dCoeff > 1)
m_dCoeff = 1 ;
@@ -981,8 +1005,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
// se attivo CollisionCheck approssimo movimento con più step
int nStep = 1 ;
if ( NeedCollisionCheck()) {
const double LEN_STEP = 20. ;
nStep = max( int( dDist / LEN_STEP), 1) ;
const double LEN_COLL_STEP = 10. ;
nStep = max( int( dMove / LEN_COLL_STEP), 1) ;
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
@@ -1067,6 +1091,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
}
}
// altrimenti eseguo movimento soli eventuali assi ausiliari
else {
// Calcolo distanza di movimento
double dSqDist = 0 ;
@@ -1078,7 +1104,8 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
double dPrevCoeff = m_dCoeff ;
double dDist = sqrt( dSqDist) ;
if ( dDist > EPS_SMALL) {
int nStep = int( max( dDist / ( ( nMoveType == 0 ? 4 : 1) * m_dStep), 1.)) ;
double dStep = min( ( nMoveType == 0 ? 2 : 1) * m_dStep, MAX_STEP) ;
int nStep = max( int( dDist / dStep), 1) ;
m_dCoeff += 1. / nStep ;
if ( m_dCoeff > 1)
m_dCoeff = 1 ;
@@ -1086,13 +1113,22 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
else
m_dCoeff = 1 ;
dMove = ( m_dCoeff - dPrevCoeff) * dDist ;
// Muovo eventuali assi ausiliari
for ( int i = 0 ; i < int( m_AuxAxesName.size()) ; ++ i) {
double dVal = m_AuxAxesVal[i] * ( 1 - m_dCoeff) + m_AuxAxesEnd[i] * m_dCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[i], dVal) ;
// se attivo CollisionCheck approssimo movimento con più step
int nStep = 1 ;
if ( NeedCollisionCheck()) {
const double LEN_COLL_STEP = 10. ;
nStep = max( int( dMove / LEN_COLL_STEP), 1) ;
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
// muovo eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale collision check
bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
}
// eseguo eventuale collision check
bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
}
// Se riscontrata collisione
@@ -1118,8 +1154,9 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
nStatus = MCH_SIM_END_STEP ;
// richiamo gestione evento fine entità
if ( ! OnMoveEnd()) {
nStatus = CalcStatusOnError( 0) ;
int nErr ;
if ( ! OnMoveEnd( nErr)) {
nStatus = CalcStatusOnError( nErr) ;
return false ;
}
}
@@ -1380,8 +1417,10 @@ Simulator::OnDispositionEnd( void)
//----------------------------------------------------------------------------
bool
Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos,
bool bFirst)
bool bFirst, int& nErr)
{
// reset stato di errore da script
nErr = 0 ;
// reset oggetti per verifica collisione con grezzo
m_CollObj.clear() ;
// assegno il nome dell'utensile, la testa e l'uscita
@@ -1407,6 +1446,9 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
// assegno il flag di chiamata di utensile iniziale
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FIRST, bFirst))
return false ;
// reset errore
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr))
return false ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_SELECT))
return true ;
@@ -1416,11 +1458,13 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
UpdateAxesPos() ;
// recupero distanza di sicurezza per verifica collisione
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_SAFEDIST, m_dSafeDist) ;
// verifico codice di errore
bOk = bOk && m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
// recupero i dati di ritorno per assi ausiliari
ResetAuxAxes() ;
int nNumAuxAxes = 0 ;
if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_AUXAXES, nNumAuxAxes) || nNumAuxAxes == 0)
return true ;
return ( bOk && nErr == 0) ;
m_AuxAxesName.reserve( nNumAuxAxes) ;
m_AuxAxesToken.reserve( nNumAuxAxes) ;
m_AuxAxesInvert.reserve( nNumAuxAxes) ;
@@ -1449,13 +1493,15 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
bOk = false ;
}
return bOk ;
return ( bOk && nErr == 0) ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnToolDeselect( const string& sNextTool, const string& sNextHead, int nNextExit, const string& sNextTcPos)
Simulator::OnToolDeselect( const string& sNextTool, const string& sNextHead, int nNextExit, const string& sNextTcPos, int& nErr)
{
// reset stato di errore da script
nErr = 0 ;
// assegno il prossimo utensile
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTTOOL, sNextTool) ;
// assegno la prossima testa
@@ -1464,6 +1510,8 @@ Simulator::OnToolDeselect( const string& sNextTool, const string& sNextHead, int
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTEXIT, nNextExit) ;
// assegno l'eventuale prossima posizione nel TC
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_NEXTTCPOS, sNextTcPos) ;
// reset errore
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_TOOL_DESELECT))
return bOk ;
@@ -1471,7 +1519,9 @@ Simulator::OnToolDeselect( const string& sNextTool, const string& sNextHead, int
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_TOOL_DESELECT) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
// verifico codice di errore
bOk = bOk && m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
return ( bOk && nErr == 0) ;
}
//----------------------------------------------------------------------------
@@ -1716,16 +1766,23 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
//----------------------------------------------------------------------------
bool
Simulator::OnMoveEnd( void)
Simulator::OnMoveEnd( int& nErr)
{
// reset stato di errore da script
nErr = 0 ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_END))
return true ;
// reset errore
if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ERR, nErr))
return false ;
// chiamo la funzione
bool bOk = m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_END) ;
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
return bOk ;
// verifico codice di errore
m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_ERR, nErr) ;
return ( bOk && nErr == 0) ;
}
//----------------------------------------------------------------------------
+4 -4
View File
@@ -42,7 +42,7 @@ class Simulator
bool OnCollision( int nCdInd, int nObjInd, int& nErr) ;
private :
bool UpdateTool( bool bFirst = false) ;
bool UpdateTool( bool bFirst, int& nErr) ;
bool UpdateAxes( void) ;
bool UpdateAxesPos( void) ;
bool ResetInterpolation( void) ;
@@ -74,8 +74,8 @@ class Simulator
bool OnDispositionStart( int nOpId, int nOpInd, int nPhase,
const std::string& sTable, const Point3d& ptOri1, bool bEmpty, bool bSomeByHand) ;
bool OnDispositionEnd( void) ;
bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, bool bFirst) ;
bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos) ;
bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos, bool bFirst, int& nErr) ;
bool OnToolDeselect( const std::string& sNextTool, const std::string& sNextHead, int nNextExit, const std::string& sNextTcPos, int& nErr) ;
bool OnMachiningStart( int nOpId, int nOpInd, const Point3d& ptMin, const Point3d& ptMax,
const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax) ;
bool OnMachiningEnd( void) ;
@@ -86,7 +86,7 @@ class Simulator
const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev) ;
bool OnPathEnd( int nAE) ;
bool OnMoveStart( const CamData* pCamData, int& nErr) ;
bool OnMoveEnd( void) ;
bool OnMoveEnd( int& nErr) ;
bool OnResetMachine( void) ;
private :
+2 -2
View File
@@ -846,7 +846,7 @@ SurfFinishing::VerifyGeometry( SelData Id, int& nSubs)
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
// se direttamente la curva
if ( Id.nSub == SEL_SUB_ALL) {
pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ;
pCurve = ::GetCurve( pGObj) ;
if ( pCurve != nullptr) {
if ( pCurve->GetType() == CRV_COMPO)
nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ;
@@ -856,7 +856,7 @@ SurfFinishing::VerifyGeometry( SelData Id, int& nSubs)
}
// altrimenti sottocurva di composita
else {
const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ;
const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
if ( pCompo != nullptr)
pCurve = pCompo->GetCurve( Id.nSub) ;
nSubs = 0 ;
+1 -1
View File
@@ -1879,7 +1879,7 @@ WaterJetting::AddLeadOutPreview( const ICurveComposite* pCompo, ISurfFlatRegion*
vtPerp.Rotate( vtN, 0, ( bCcwRot ? 1 : - 1)) ;
Point3d ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
if ( IsNull( pLine) || ! pLine->Set( ptEnd, ptP1))
return nullptr ;
return false ;
pCrv.Set( Release( pLine)) ;
} break ;
case WJET_LO_TANGENT :