EgtMachKernel :
- in fresatura aggiunta a gestione Tabs la sincronizzazione tra parti adiacenti di lavorazioni diverse.
This commit is contained in:
+121
-6
@@ -19,6 +19,7 @@
|
||||
#include "Milling.h"
|
||||
#include "GeoConst.h"
|
||||
#include "OperationConst.h"
|
||||
#include "/EgtDev/Include/EXeCmdLogOff.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
@@ -2124,7 +2126,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
TabData tdTabs ;
|
||||
AdjustTabsParams( pCompo, bPathTabsEnable, tdTabs) ;
|
||||
DBLVECTOR vdTabs ;
|
||||
CalcTabsPositions( pCompo, bPathTabsEnable, tdTabs, vdTabs) ;
|
||||
CalcTabsPositions( pCompo, dDepth, bPathTabsEnable, tdTabs, vdTabs) ;
|
||||
|
||||
// in caso di oscillazione ne aggiusto i parametri secondo il percorso
|
||||
double dOscRampLen, dOscFlatLen ;
|
||||
@@ -4199,7 +4201,7 @@ Milling::AdjustTabsParams( const ICurve* pCrv, bool& bPathTabsEnable, TabData& t
|
||||
}
|
||||
else {
|
||||
// calcolo numero di tabs e distanza
|
||||
int nTabs = max( static_cast<int>( dLen / ( 2 * tdTabs.m_dRampLen + tdTabs.m_dBottomLen + tdTabs.m_dTopLen)), 1) ;
|
||||
int nTabs = max( static_cast<int>( dLen / ( 2 * tdTabs.m_dRampLen + tdTabs.m_dBottomLen + tdTabs.m_dTopLen)), 0) ;
|
||||
nTabs = min( nTabs, m_Params.m_nTabMax) ;
|
||||
if ( nTabs < m_Params.m_nTabMin) {
|
||||
if ( dLen > ( 2 * tdTabs.m_dRampLen + 2 * tdTabs.m_dTopLen) * m_Params.m_nTabMin)
|
||||
@@ -4207,7 +4209,8 @@ Milling::AdjustTabsParams( const ICurve* pCrv, bool& bPathTabsEnable, TabData& t
|
||||
else
|
||||
m_pMchMgr->SetWarning( 2364, "Warning in Milling : tabs number less than minimum") ;
|
||||
}
|
||||
tdTabs.m_dBottomLen = ( dLen - nTabs * ( 2 * tdTabs.m_dRampLen + tdTabs.m_dTopLen)) / nTabs ;
|
||||
if ( nTabs > 0)
|
||||
tdTabs.m_dBottomLen = ( dLen - nTabs * ( 2 * tdTabs.m_dRampLen + tdTabs.m_dTopLen)) / nTabs ;
|
||||
}
|
||||
}
|
||||
// verifico che le lughezze non siano inferiori al minimo
|
||||
@@ -4235,14 +4238,33 @@ PeriodicIntervalsSubract( Intervals& ivItv, double dPeriod, double dMin, double
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::CalcTabsPositions( const ICurveComposite* pCompo, bool bPathTabsEnable, const TabData& tdTabs, DBLVECTOR& vdTabs)
|
||||
Milling::CalcTabsPositions( const ICurveComposite* pCompo, double dDepth, bool bPathTabsEnable, const TabData& tdTabs, DBLVECTOR& vdTabs)
|
||||
{
|
||||
// reset posizioni Tabs
|
||||
vdTabs.clear() ;
|
||||
|
||||
// se Tabs non abilitati, esco
|
||||
if ( ! bPathTabsEnable)
|
||||
// recupero gruppo ausiliario per Tabs
|
||||
int nTabsId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_TABS) ;
|
||||
|
||||
// se Tabs non abilitati, cancello gruppo ausiliario relativo ed esco
|
||||
if ( ! bPathTabsEnable) {
|
||||
m_pGeomDB->Erase( nTabsId) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// disabilito eventuale registrazione comandi EXE (riabilitazione automatica)
|
||||
CmdLogOff cmdLogOff ;
|
||||
|
||||
// creo o svuoto gruppo ausiliario tabs
|
||||
if ( nTabsId == GDB_ID_NULL) {
|
||||
nTabsId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
|
||||
if ( nTabsId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nTabsId, MCH_TABS) ;
|
||||
}
|
||||
// altrimenti, lo svuoto
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nTabsId) ;
|
||||
|
||||
// lunghezza di un Tab
|
||||
double dTabLen = tdTabs.m_dRampLen + tdTabs.m_dTopLen + tdTabs.m_dRampLen ;
|
||||
@@ -4335,6 +4357,99 @@ Milling::CalcTabsPositions( const ICurveComposite* pCompo, bool bPathTabsEnable,
|
||||
dCurrLen += dNextTab + dTabLen ;
|
||||
dNextTab = tdTabs.m_dBottomLen ;
|
||||
}
|
||||
|
||||
// recupero posizioni tabs adiacenti di precedenti lavorazioni, se accettabili
|
||||
DBLVECTOR vdAdj ;
|
||||
double dMaxDist = m_TParams.m_dDiam + 10. ;
|
||||
BBox3d b3Mill ;
|
||||
m_pGeomDB->GetGlobalBBox( m_nOwnerId, b3Mill) ;
|
||||
b3Mill.Expand( dMaxDist) ;
|
||||
int nOpeId = m_pMchMgr->GetNextActiveOperation( m_pMchMgr->GetPhaseDisposition( m_nPhase)) ;
|
||||
while ( nOpeId != GDB_ID_NULL && m_pMchMgr->GetOperationPhase( nOpeId) == m_nPhase) {
|
||||
if ( nOpeId != m_nOwnerId) {
|
||||
int nTabId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nOpeId, MCH_TABS)) ;
|
||||
while ( nTabId != GDB_ID_NULL) {
|
||||
Point3d ptCen ;
|
||||
if ( ExeCenterPoint( nTabId, GDB_ID_ROOT, ptCen) && b3Mill.EnclosesXY( ptCen)) {
|
||||
double dDist ; double dPar, dAdjLen ; int nFlag ;
|
||||
DistPointCurve distPC( ptCen, *pCompo) ;
|
||||
if ( distPC.GetDist( dDist) && dDist < dMaxDist &&
|
||||
distPC.GetParamAtMinDistPoint( 0, dPar, nFlag) &&
|
||||
pCompo->GetLengthAtParam( dPar, dAdjLen)) {
|
||||
double dPos = dAdjLen - dTabLen / 2 ;
|
||||
if ( dPos < 0)
|
||||
dPos += dLen ;
|
||||
double dPrev, dNext ;
|
||||
if ( ivTabs.IsInside( dPos))
|
||||
vdAdj.emplace_back( dPos) ;
|
||||
else if ( ivTabs.GetPrevNearest( dPos, dPrev) && abs( dPos - dPrev) <= dTabLen / 2)
|
||||
vdAdj.emplace_back( dPrev) ;
|
||||
else if ( ivTabs.GetNextNearest( dPos, dNext) && abs( dNext - dPos) <= dTabLen / 2)
|
||||
vdAdj.emplace_back( dNext) ;
|
||||
}
|
||||
}
|
||||
nTabId = m_pGeomDB->GetNext( nTabId) ;
|
||||
}
|
||||
}
|
||||
nOpeId = m_pMchMgr->GetNextActiveOperation( nOpeId) ;
|
||||
}
|
||||
|
||||
// correggo posizione tabs per eventuali adiacenti
|
||||
if ( ! vdAdj.empty()) {
|
||||
// ordino le posizioni adiacenti in senso crescente lungo la lavorazione
|
||||
sort( vdAdj.begin(), vdAdj.end()) ;
|
||||
// se non sono presenti tabs
|
||||
if ( vdTabs.empty()) {
|
||||
for ( int i = 0 ; i < int( vdAdj.size()) && i < m_Params.m_nTabMax ; ++ i) {
|
||||
vdTabs.emplace_back( vdAdj[i]) ;
|
||||
}
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// per ogni posizione adiacente
|
||||
for ( int i = 0 ; i < int( vdAdj.size()) ; ++ i) {
|
||||
double dPos = vdAdj[i] ;
|
||||
// cerco quale posizione già definita sostituire
|
||||
for ( int j = 0 ; j < int( vdTabs.size()) ; ++ j) {
|
||||
if ( abs( dPos - vdTabs[j]) < EPS_SMALL)
|
||||
;
|
||||
else if ( dPos < vdTabs[j]) {
|
||||
if ( j == 0)
|
||||
vdTabs[j] = dPos ;
|
||||
else {
|
||||
if ( abs( dPos - vdTabs[j-1]) < abs( vdTabs[j] - dPos))
|
||||
vdTabs[j-1] = dPos ;
|
||||
else
|
||||
vdTabs[j] = dPos ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
else if ( j == int( vdTabs.size()) - 1) {
|
||||
vdTabs[j] = dPos ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// inserisco geometria ausiliaria per i tabs
|
||||
for ( auto& dPos : vdTabs) {
|
||||
// recupero la posizione
|
||||
double dU ;
|
||||
Point3d ptCen ;
|
||||
if ( pCompo->GetParamAtLength( dPos + dTabLen / 2, dU) &&
|
||||
pCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptCen)) {
|
||||
ptCen -= vtExtr * dDepth ;
|
||||
PtrOwner<ICurveArc> pCircle( CreateCurveArc()) ;
|
||||
if ( ! IsNull( pCircle) && pCircle->Set( ptCen, vtExtr, m_TParams.m_dDiam / 2)) {
|
||||
int nCircId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nTabsId, Release( pCircle)) ;
|
||||
m_pGeomDB->SetMaterial( nCircId, AQUA) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aggiungo la posizione tappo
|
||||
vdTabs.emplace_back( dLen + m_dAddedOverlap + 100.) ;
|
||||
|
||||
return true ;
|
||||
|
||||
@@ -110,7 +110,7 @@ class Milling : public Machining
|
||||
bool AddOscillLine( const ICurveLine* pLine, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
|
||||
bool AddOscillArc( const ICurveArc* pArc, const Vector3d& vtTool, double dRampLen, double dFlatLen) ;
|
||||
bool AdjustTabsParams( const ICurve* pCrv, bool& bPathTabsEnable, TabData& tdTabs) ;
|
||||
bool CalcTabsPositions( const ICurveComposite* pCompo, bool bPathTabsEnable, const TabData& tdTabs, DBLVECTOR& vdTabs) ;
|
||||
bool CalcTabsPositions( const ICurveComposite* pCompo, double dDepth, bool bPathTabsEnable, const TabData& tdTabs, DBLVECTOR& vdTabs) ;
|
||||
bool AddTabsLine( const ICurveLine* pLine, const Vector3d& vtTool, const DBLVECTOR& vdTabs, const TabData& tdTabs) ;
|
||||
bool AddTabsArc( const ICurveArc* pArc, const Vector3d& vtTool, const DBLVECTOR& vdTabs, const TabData& tdTabs) ;
|
||||
double GetRadiusForStartEndElevation( void) const ;
|
||||
|
||||
Reference in New Issue
Block a user