6e359a5740
- In PocketingNT migliorati gli ingressi.
239 lines
15 KiB
C++
239 lines
15 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2017-2017
|
|
//----------------------------------------------------------------------------
|
|
// File :Pocketing.h Data : 04.02.17 Versione : 1.8b1
|
|
// Contenuto : Dichiarazione della classe Pocketing.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 04.02.17 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "Machining.h"
|
|
#include "PocketingData.h"
|
|
#include "ToolData.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
|
#include "/EgtDev/Include/EGkCurveLine.h"
|
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
|
#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h"
|
|
|
|
// struttura informazioni sui singoli percorsi
|
|
struct PathInfoPO {
|
|
bool bOutStart ; // flag per entrata da fuori
|
|
bool bOutEnd ; // flag per uscita da fuori
|
|
bool bSingleCrv ; // se percorso formato da una curva singola ( in generale per SubSteps)
|
|
bool bOptTrap ; // flag per casi ottimizzati a trapezio ( per Spiral)
|
|
bool bOptCirle ; // flag per casi ottimizzati a Spirale ( per Spiral)
|
|
bool bIsZigZagOneWayBorder ; // curve di bordo dei lati chiusi ( per ZigZag e OneWay)
|
|
PtrOwner<ICurveComposite> pCrvPath ; // percorso del centro utensile
|
|
PtrOwner<ICurveComposite> pCrvGlideIn ; // curva per LeadIn a guida
|
|
PtrOwner<ICurveComposite> pCrvGlideOut ; // curva per LeadOut a guida
|
|
PtrOwner<ICurveComposite> pCrvRet ; // curva di ritorno ( per ora solo caso fori)
|
|
} ;
|
|
// tipo percorso
|
|
typedef std::vector<PathInfoPO> PATHINFOPOVECTOR ;
|
|
|
|
// struttura informazioni per Step/SubSteps complessivi
|
|
struct StepInfoPO {
|
|
double dDepth ; // profondità dello step attuale
|
|
double dRelativeDepth ; // profondità relativa allo step al di sopra
|
|
PtrOwner<ISurfFlatRegion> pSfrPock ; // regione piana di svuotatura
|
|
PtrOwner<ISurfFlatRegion> pSfrLimit ; // regione piana da non svuotare
|
|
PATHINFOPOVECTOR vPaths ; // percorsi di Pocketing
|
|
} ;
|
|
// tipo step
|
|
typedef std::vector<StepInfoPO> STEPINFOPOVECTOR ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class PocketingNT : public Machining
|
|
{
|
|
public : // IUserObj
|
|
PocketingNT* Clone( void) const override ;
|
|
const std::string& GetClassName( void) const override ;
|
|
bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ;
|
|
bool ToSave( void) const override
|
|
{ return true ; }
|
|
bool Save( int nBaseId, STRVECTOR& vString) const override ;
|
|
bool Load( const STRVECTOR& vString, int nBaseGdbId) override ;
|
|
|
|
public : // Operation
|
|
int GetType( void) const override
|
|
{ return OPER_POCKETING ; }
|
|
bool IsEmpty( int nEmptyType = NEED_GEOM) const override
|
|
{ if ( m_nPockets == 0)
|
|
return true ;
|
|
if ( nEmptyType == NEED_ONE_TP_OK)
|
|
return ( ! IsAtLeastOnePathOk()) ;
|
|
if ( nEmptyType == NEED_ALL_TP_OK)
|
|
return ( ! AreAllPathsOk()) ;
|
|
return false ; }
|
|
bool UpdateStatus( int nModif) override
|
|
{ m_nStatus |= nModif ; return true ; }
|
|
|
|
protected : // Operation
|
|
int GetSolCh( void) const override
|
|
{ return m_Params.m_nSolCh ; }
|
|
|
|
public : // Machining
|
|
bool Prepare( const std::string& sMillName) override ;
|
|
bool SetParam( int nType, bool bVal) override ;
|
|
bool SetParam( int nType, int nVal) override ;
|
|
bool SetParam( int nType, double dVal) override ;
|
|
bool SetParam( int nType, const std::string& sVal) override ;
|
|
bool SetGeometry( const SELVECTOR& vIds) override ;
|
|
bool Preview( bool bRecalc) override ;
|
|
bool Apply( bool bRecalc, bool bPostApply) override ;
|
|
bool Update( bool bPostApply) override ;
|
|
bool GetParam( int nType, bool& bVal) const override ;
|
|
bool GetParam( int nType, int& nVal) const override ;
|
|
bool GetParam( int nType, double& dVal) const override ;
|
|
bool GetParam( int nType, std::string& sVal) const override ;
|
|
bool UpdateToolData( void) override ;
|
|
const ToolData& GetToolData( void) const override ;
|
|
bool GetGeometry( SELVECTOR& vIds) const override ;
|
|
|
|
public :
|
|
PocketingNT( void) ;
|
|
|
|
private :
|
|
bool MyApply( bool bRecalc, bool bPostApply) ;
|
|
bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ;
|
|
bool AdjustCurvesByStmTopology( const ISurfTriMesh* pSurf, const Frame3d& frGlob, const ISurfTriMesh* pStmTrim, ICURVEPLIST& lstPC) ;
|
|
bool GetCurves( const SelData& Id, const ISurfTriMesh* pStmRaw, const ISurfTriMesh* pStmTrim, ICURVEPLIST& lstPC) ;
|
|
bool SetCurveAllTempProp( int nCrvId, bool bForcedClose, ICurve* pCurve, bool* pbSomeOpen = nullptr) ;
|
|
bool SetSfrLoopsAllTempProp( int nSfrId, ISurfFlatRegion* pSfr) ;
|
|
bool ResetCurveAllTempProp( ICurve* pCurve) ;
|
|
bool Chain( int nGrpDestId) ;
|
|
ISurfTriMesh* GetRaw( void) ;
|
|
ISurfTriMesh* GetStmTrim( void) ;
|
|
ISurfTriMesh* GetExtrusionStm( const ISurfFlatRegion* pSfr, const Vector3d& vtExtr) ;
|
|
ISurfFlatRegion* GetSfrByStmIntersection( const IntersParPlanesSurfTm& IPPStm, double dDist, double dSmallOffs = 0) ;
|
|
ISurfFlatRegion* GetSfrRawProjection( const ISurfTriMesh* pStmRaw, const ISurfFlatRegion* pSfr, const Vector3d& vtTool) ;
|
|
Point3d GetStartPointsByHead( const STEPINFOPOVECTOR& vStepInfo) const ;
|
|
Point3d GetStartPointsFromSteps( const STEPINFOPOVECTOR& vStepInfo, int nCrvType) const ;
|
|
bool ChooseRawPart( const ISurfFlatRegion* pSfrChunk, ISurfTriMesh* pStm) const ;
|
|
bool ManageOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStmPart) ;
|
|
bool GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const ;
|
|
bool ExtendOpenEdges( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStm) ;
|
|
bool ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfTriMesh* pStmExtrusion) ;
|
|
bool CheckMaxDepth( const ISurfFlatRegion* pSfr, double dDepth, const Vector3d& vtTool,
|
|
const ISurfTriMesh* pStmRaw, const ISurfTriMesh* pStmExtrusion,
|
|
const IntersParPlanesSurfTm& IPPStm, bool& bSkipMaxDepth) ;
|
|
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
|
|
bool CalcRegionElevation( const ISurfFlatRegion* pSfr, const Vector3d& vtTool, double dDepth,
|
|
double dRad, double dLen, double& dElev) ;
|
|
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
|
|
bool GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo) ;
|
|
bool CalcLimitRegion( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrRaw, ISurfFlatRegion* pSfrLimit) ;
|
|
bool CalcPaths( STEPINFOPOVECTOR& vStepInfo) ;
|
|
bool CalcRetCurve( PathInfoPO& PathInfo, const StepInfoPO& StepInfo, const ICurveComposite* pCrvPath,
|
|
const Vector3d& vtTool, bool bHolePocketing, bool bInVsOut, ICurveComposite* pCrvGlide) ;
|
|
bool AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, double dElev, double dStep, bool bSplitArcs) ;
|
|
double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) ;
|
|
bool CutCurveWithLine( ICurveComposite* pCrvA, const ICurveLine* pCrvB) ;
|
|
bool ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool bSplitArcs) ;
|
|
bool AddEpicycles( ICurveComposite * pCompo, ICurveComposite * pCrv, ICurveComposite * pCrvBound = nullptr) ;
|
|
bool CalcBoundedLinkWithBiArcs( const Point3d& ptStart, const Vector3d& vtStart, const Point3d& ptEnd, const Vector3d& vtEnd,
|
|
const ICurve* pCrvBound, ICurveComposite* pCrvLink) ;
|
|
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
|
double dElev, double dAppr, bool bSplitArcs, bool bOutStart) ;
|
|
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
|
double dElev, double dAppr, bool bSplitArcs, bool bOutStart = false) ;
|
|
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
|
double dElev, double dAppr, bool bSplitArcs) ;
|
|
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
|
double dElev, double dAppr, bool bSplitArcs) ;
|
|
bool CalcFirstElevation( const Point3d& ptStart, const Point3d& ptP1, const Vector3d& vtTool,
|
|
const StepInfoPO& currStep, double dSafeZ, double dStep, double& dCurrElev,
|
|
double& dEscapeElev, Vector3d& vtEscape) const ;
|
|
bool CalcLastElevation( const Point3d& ptStart, const Point3d& ptP1, const Vector3d& vtTool,
|
|
const StepInfoPO& currStep, double dSafeZ, double dStep, double& dCurrElev,
|
|
double& dEscapeElev, Vector3d& vtEscape) const ;
|
|
bool CalcLeadInStart( Point3d& ptStart, const Vector3d& vtTool, const ICurveComposite* pCrvPath, Point3d& ptP1) ;
|
|
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
|
const ISurfFlatRegion* pSfr, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs,
|
|
bool bNoneForced, bool bSkipControl) ;
|
|
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, const ISurfFlatRegion* pSfr,
|
|
const ICurveComposite* pRCrv, bool bSplitArcs, bool bNoneForced, Point3d& ptP1) ;
|
|
double GetRadiusForStartEndElevation( void) const ;
|
|
bool GetForcedClosed( void) ;
|
|
bool GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMid, Vector3d& vtMidOut) ;
|
|
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ;
|
|
bool AdjustContourStart( ICurveComposite* pCompo) ;
|
|
bool ManageSmoothLink( const PathInfoPO& currPath, const PathInfoPO& nextPath, bool bSamePlane,
|
|
bool& bSmoothEnd, bool& bForceLinear) ;
|
|
bool CheckSafetyLink( const Point3d& ptCurr, const Vector3d& vtCurr,
|
|
const Point3d& ptDest, const Vector3d& vtDest,
|
|
const ISurfFlatRegion* pSfrLimit, const Vector3d& vtTool,
|
|
bool bSmoothEnd, bool& bSafeLimit, ICurveComposite* pCrvSafeLink) ;
|
|
bool VerifyLeadInHelix( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptCen, double dHelixRad) ;
|
|
bool VerifyLeadInZigZag( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptPa, const Point3d& ptPb) ;
|
|
bool VerifyLeadInOutGlide( const ISurfFlatRegion* pSfr, ICurveComposite* pCrvGlide) ;
|
|
bool CalcDistanceFromRawSurface( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist, Vector3d& vtNorm) ;
|
|
// debug
|
|
void DebugDrawSfr( const ISurfFlatRegion* pSfr, bool bUniform, int nlayer = GDB_ID_ROOT) ;
|
|
void DebugDrawLoop( const ICurveComposite* pCrvCompo, int nLayer, bool bUniform) ;
|
|
void DebugDrawBox( const BBox3d& BBox, const Frame3d& FrBox, int nlayer) ;
|
|
void DebugDrawOpenEdgesInRaw( const ICRVCOMPOPOVECTOR& vpCrvsm, int nlayer) ;
|
|
void DebugDrawFeed( const ICurve* pCrv, double dFeed, int nlayer) ;
|
|
|
|
private :
|
|
double GetSpeed( void) const
|
|
{ return ( IsNullAngValue( m_Params.m_dSpeed) ? m_TParams.m_dSpeed : m_Params.m_dSpeed) ; }
|
|
double GetFeed( void) const
|
|
{ return ( IsNullLenValue( m_Params.m_dFeed) ? m_TParams.m_dFeed : m_Params.m_dFeed) ; }
|
|
double GetStartFeed( void) const
|
|
{ return ( IsNullLenValue( m_Params.m_dStartFeed) ? m_TParams.m_dStartFeed : m_Params.m_dStartFeed) ; }
|
|
double GetEndFeed( void) const
|
|
{ return ( IsNullLenValue( m_Params.m_dEndFeed) ? m_TParams.m_dEndFeed : m_Params.m_dEndFeed) ; }
|
|
double GetTipFeed( void) const
|
|
{ return ( IsNullLenValue( m_Params.m_dTipFeed) ? m_TParams.m_dTipFeed : m_Params.m_dTipFeed) ; }
|
|
double GetOffsL( void) const
|
|
{ return ( IsUnknownValue( m_Params.m_dOffsL) ? m_TParams.m_dOffsL : m_Params.m_dOffsL) ; }
|
|
double GetOffsR( void) const
|
|
{ return ( IsUnknownValue( m_Params.m_dOffsR) ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; }
|
|
double GetSideStep( void) const
|
|
{ return Clamp( m_Params.m_dSideStep, std::min( 0.1 * m_TParams.m_dDiam, 1.0), m_TParams.m_dDiam) ; }
|
|
int GetLeadInType( void) const
|
|
{ if ( m_Params.m_dLiTang < std::min( 0.1 * m_TParams.m_dDiam, 1.0))
|
|
return POCKET_LI_NONE ;
|
|
if ( m_Params.m_nLeadInType != POCKET_LI_GLIDE && m_Params.m_dLiElev < 10 * EPS_SMALL)
|
|
return POCKET_LI_NONE ;
|
|
return m_Params.m_nLeadInType ; }
|
|
bool LeadInRawIsOk( void) const
|
|
{ if ( m_TParams.m_nType != TT_MILL_NOTIP)
|
|
return true ;
|
|
return (( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX) &&
|
|
m_Params.m_dLiTang >= 0.9 * 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 ;
|
|
return m_Params.m_nLeadOutType ; }
|
|
|
|
private :
|
|
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
|
|
PocketingData m_Params ; // parametri lavorazione
|
|
ToolData m_TParams ; // parametri utensile
|
|
double m_dTHoldBase ; // posizione base del porta-utensile
|
|
double m_dTHoldLen ; // lunghezza del porta-utensile
|
|
double m_dTHoldDiam ; // diametro del porta-utensile
|
|
double m_dMaxHelixRad ; // raggio massimo attacco ad elica nel caso di cerchi
|
|
int m_nStatus ; // stato di aggiornamento della lavorazione
|
|
int m_nPockets ; // numero di percorsi di svuotatura generati
|
|
bool m_bTiltingTab ; // flag utilizzo tavola basculante
|
|
Vector3d m_vtTiltingAx ; // versore direzione eventuale asse basculante
|
|
bool m_bAboveHead ; // flag utilizzo testa da sopra
|
|
bool m_bAggrBottom ; // flag di utilizzo dell'aggregato da sotto
|
|
Vector3d m_vtAggrBottom ; // vettore direzione ausiliaria aggregato da sotto
|
|
AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto
|
|
bool m_bOpenOutRaw ; // flag forzatura lati aperti sempre fuori dal grezzo
|
|
double m_dOpenMinSafe ; // minima distanza di sicurezza di attacco su lato aperto
|
|
double m_dOpenInRawExtension ; // estensione dei tratti aperti dentro al grezzo
|
|
bool m_bAllClose ; // flag per forzare i lati come tutti chiusi
|
|
bool m_bRunning ; // flag di calcoli in corso
|
|
} ; |