96c96383c3
- in Sgrossature aggiunti i controlli sulle Feed per gli ingressi.
293 lines
17 KiB
C++
293 lines
17 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2024-2024
|
|
//----------------------------------------------------------------------------
|
|
// File : SurfRoughing.h Data : 24.05.24 Versione : 2.6e5
|
|
// Contenuto : Dichiarazione della classe SurfRoughing.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 24.05.24 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "Machining.h"
|
|
#include "SurfRoughingData.h"
|
|
#include "ToolData.h"
|
|
#include "MachiningConst.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
|
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
|
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
|
#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h"
|
|
|
|
class ICAvParSilhouettesSurfTm ;
|
|
|
|
// struttura informazioni sui singoli percorsi
|
|
struct PathInfoSR {
|
|
bool bOutStart ; // flag per entrata 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 bIsZigZagOneWayBorder ; // curve di bordo dei lati chiusi ( per ZigZag e OneWay)
|
|
PtrOwner<ICurveComposite> pCrvPath ; // percorso del centro utensile
|
|
PtrOwner<ICurveComposite> pCvrRet ; // curva di ritorno per LeadIn/Out a guida
|
|
} ;
|
|
// tipo percorso
|
|
typedef std::vector<PathInfoSR> PATHINFOSRVECTOR ;
|
|
|
|
// struttura informazioni per Step/SubSteps durante la loro creazione [quindi temporanei]
|
|
struct StepInfoSRTmp {
|
|
StepInfoSRTmp( void)
|
|
: nIndRef( -1), dDepth( 0), bSubStep( false), bPlaneZStep( false), dPercFeed( 0.),
|
|
pSfrRemoved( nullptr), pSfrPlaneZ( nullptr) {}
|
|
StepInfoSRTmp( int nIR, double dD, bool bSS, bool bPZ, double dPF, ISurfFlatRegion* pSR, ISurfFlatRegion* pSPZ)
|
|
: nIndRef( nIR), dDepth( dD), bSubStep( bSS), bPlaneZStep( bPZ), dPercFeed( dPF),
|
|
pSfrRemoved( pSR), pSfrPlaneZ( pSPZ) {}
|
|
~StepInfoSRTmp() {
|
|
delete( pSfrRemoved) ;
|
|
delete( pSfrPlaneZ) ;
|
|
}
|
|
int nIndRef ; // ( usato solo per step intermedi ) posizione step precedente
|
|
double dDepth ; // profondità posizione piano di svuotatura ( in negativo)
|
|
bool bSubStep ; // flag per indicare se lo Step è un SubStep
|
|
bool bPlaneZStep ; // flag per indicare se lo Step è un planeZ
|
|
double dPercFeed ; // percentuale degli extra steps relativa agli step base ( per Feed ZLoc)
|
|
ISurfFlatRegion* pSfrRemoved ; // regione PROGRESSIVA rimossa attuale
|
|
ISurfFlatRegion* pSfrPlaneZ ; // regione individuata da PlaneZDetection
|
|
} ;
|
|
// vettore associato
|
|
typedef std::vector<StepInfoSRTmp> STEPINFOTMPSRVECTOR ;
|
|
|
|
// struttura per salvataggio Sfr con parametri nel GeomDB
|
|
struct SfrGeoDBInfo {
|
|
SfrGeoDBInfo( ISurfFlatRegion* pMySfr, ISurfFlatRegion* pMySfrLimit, ISurfFlatRegion* pMySfrRemoved,
|
|
bool bMySubSubStep, double dMyDepth, double dMyRelativeDepth, double dMyZLocCoefFeed)
|
|
: bSubStep( bMySubSubStep), dDepth( dMyDepth), dRelativeDepth( dMyRelativeDepth), dZLocCoefFeed( dMyZLocCoefFeed) {
|
|
pSfr.Set( pMySfr) ;
|
|
pSfrLimit.Set( pMySfrLimit) ;
|
|
pSfrRemoved.Set( pMySfrRemoved) ;
|
|
}
|
|
SfrGeoDBInfo()
|
|
: bSubStep( true), dDepth( 0.), dRelativeDepth( 0.), dZLocCoefFeed( 1.) {
|
|
pSfr.Set( nullptr) ;
|
|
pSfrLimit.Set( nullptr) ;
|
|
pSfrRemoved.Set( nullptr) ;
|
|
}
|
|
PtrOwner<ISurfFlatRegion> pSfr ; // superficie di Sgrossatura ( allo step corrente)
|
|
PtrOwner<ISurfFlatRegion> pSfrLimit ; // superficie Limite ( allo step corrente)
|
|
PtrOwner<ISurfFlatRegion> pSfrRemoved ; // supericie Rimossa ( allo step corrente)
|
|
bool bSubStep ; // flag per indicare se Step semplice o meno ( Extra/PlaneZ)
|
|
double dDepth ; // profondità
|
|
double dRelativeDepth ; // profondità relativa
|
|
double dZLocCoefFeed ; // coefficiente di riduzione della Feed complessivo
|
|
} ;
|
|
// vettore associato
|
|
typedef std::vector<SfrGeoDBInfo> SFRGEODBINFOVECTOR ;
|
|
|
|
// struttura informazioni per Step/SubSteps complessivi
|
|
struct StepInfoSR {
|
|
double dDepth ; // profondità dello step attuale
|
|
double dRelativeDepth ; // profondità relativa allo step al di sopra
|
|
double dZlocCoeffFeed ; // coefficiente riduzione Feed lungo Zloc
|
|
int nSubType ; // tipo di lavorazione dello Step corrente
|
|
bool bIsExtraStep ; // flag per SubStep o PlaneZStep
|
|
bool bInverted ; // se percorsi invertiti
|
|
PtrOwner<ISurfFlatRegion> pSfrPock ; // regione piana di sgrossatura
|
|
PtrOwner<ISurfFlatRegion> pSfrLimit ; // regione piana da non rovinare
|
|
PATHINFOSRVECTOR vPaths ; // percorsi di Pocketing
|
|
} ;
|
|
// vettore associato
|
|
typedef std::vector<StepInfoSR> STEPINFOSRVECTOR ;
|
|
// planeZ detection <SfrFace, dDepth>
|
|
typedef std::pair<PtrOwner<ISurfFlatRegion>, double> PLANEZFACE ;
|
|
typedef std::vector<PLANEZFACE> PLANEZFACEVECTOR ;
|
|
// posizione reciproca tra Step/SubStep/PlaneZ
|
|
enum { DOWN = 0, PLANAR = 1, ABOVE = 2} ;
|
|
|
|
// struttura per ordinamento mediante ZChunk
|
|
struct StepData {
|
|
PtrOwner<ISurfFlatRegion> pSfrChunk ; // regione piana di sgrossatura
|
|
PtrOwner<ISurfFlatRegion> pSfrLimit ; // regione piana da non rovinare
|
|
PtrOwner<ISurfFlatRegion> pSfrRemoved ; // regione piana rimossa alla Depth corrente
|
|
bool bIsSubStep ; // Flag per Step base o Extra ( SubStep/PlaneZ)
|
|
double dDepth ; // profondità
|
|
double dRelativeDepth ; // profondità relativa
|
|
double dZLocCoeffFeed ; // coefficiente di riduzione della Feed
|
|
} ;
|
|
// vettore di StepData
|
|
typedef std::vector<StepData> STEPDATAVECTOR ;
|
|
// Matrice di StepData
|
|
typedef std::vector<STEPDATAVECTOR> STEPDATAMATRIX ;
|
|
// ordine <Ind, ZMin, ZMax>
|
|
typedef std::pair<int, std::pair<double, double>> INTDBLDBL ;
|
|
// vettore associato
|
|
typedef std::vector<INTDBLDBL> INTDBLDBLVECTOR ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class SurfRoughing : public Machining
|
|
{
|
|
public : // IUserObj
|
|
SurfRoughing* 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_SURFROUGHING ; }
|
|
bool IsEmpty( int nEmptyType = NEED_GEOM) const override
|
|
{ if ( m_nPaths == 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 ; }
|
|
bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) const override ;
|
|
|
|
public : // Machining
|
|
bool Prepare( const std::string& sSawName) 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 :
|
|
SurfRoughing( void) ;
|
|
|
|
private :
|
|
bool MyApply( bool bRecalc, bool bPostApply) ;
|
|
bool VerifyGeometry( SelData Id, int& nSubs) ;
|
|
bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ;
|
|
bool Chain( int nGrpDestId) ;
|
|
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
|
|
bool DetectPlaneZ( const CISURFTMPVECTOR& vpStm, const Frame3d& frCompo, const Vector3d& vtTool, PLANEZFACEVECTOR& vPlaneZ,
|
|
double dMinDepth, double dMaxDepth) const ;
|
|
bool CalcPaths( const INTINTVECTOR& vPocket, STEPINFOSRVECTOR& vStepInfo) const ;
|
|
bool OrderByZChunk( SFRGEODBINFOVECTOR& vInfoSfrGeomDB, int nTempInd, const ISurfFlatRegion* pSfrSgro) const ;
|
|
bool OrderZChunkSteps( STEPDATAMATRIX& vvDataSteps, STEPDATAMATRIX& vIndepChunkGroup,
|
|
INTDBLDBLVECTOR& vMapGrpZLoc) const ;
|
|
bool GetLinkFromPaths( STEPINFOSRVECTOR& vStepInfo, int i, int j, const Point3d& ptStart,
|
|
const Vector3d& vtTool, double dSafeZ, double dExtraElev, double& dEndElev,
|
|
ICurveComposite* pCrvLink) const ;
|
|
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dLen, double& dElev) const ;
|
|
bool AddRoughing( const INTINTVECTOR& vPocket, const Vector3d& vtTool, double dElev, double dStep,
|
|
double dSubStep, bool bSplitArcs) ;
|
|
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr, bool bOutStart, bool bAbsFirst) ;
|
|
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr, bool bOutMove) ;
|
|
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
|
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
|
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtTool, const ICurveComposite* pCrvPath, Point3d& ptP1) const ;
|
|
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 ICurveComposite* pRCrv, bool bSplitArcs, bool bNoneForced, Point3d& ptP1) ;
|
|
ISurfTriMesh* GetRaw( void) const ;
|
|
ISurfTriMesh* GetStmOutSideSfr( const ISurfFlatRegion* pSfr, double dDepth, const ISurfTriMesh* pStmRaw, const Vector3d& vtExtr) const ;
|
|
ISurfFlatRegion* GetSfrByStmIntersection( const IntersParPlanesSurfTm& IPPStm, double dDist, double dSmallOffs = 0) const ;
|
|
ISurfFlatRegion* GetSfrSilhouette( ICAvParSilhouettesSurfTm* pCavParSilh, double dDepth, double Sil_tol, bool& bOk) const ;
|
|
ISurfFlatRegion* GetSfrCornerColl( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrLimit,
|
|
const ISurfFlatRegion* pSfrColl, const ISurfFlatRegion* pSfrSearchCorners) const ;
|
|
bool GetToolCollisionRegion( const ISurfFlatRegion* pSfrSgro, double& dDepth, ISurfFlatRegion* pSfrColl,
|
|
ISurfFlatRegion* pSfrSearchCorners) const ;
|
|
bool GetActiveSurfaces( INTVECTOR& vSurfId, INTVECTOR& vSurfSuppId) const ;
|
|
double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ;
|
|
double GetRightStartFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ;
|
|
double GetRadiusForStartEndElevation( void) const ;
|
|
bool ResetCurveAllTempProp( ICurve* pCurve) const ;
|
|
bool RemoveChunksUnderTolerance( ISurfFlatRegion* pSfr, double dTol, ISurfFlatRegion* pSfrLimit,
|
|
ISurfFlatRegion* pSfrToUpdate = nullptr) const ;
|
|
bool CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler) ;
|
|
bool ModifySurfForOpenCloseEdges( ISurfFlatRegion* pSfr, const Vector3d& vtTool, const ICurveComposite* pCrvCompo) const ;
|
|
bool ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrRef) const ;
|
|
bool SimplifyCurve( ICurveComposite* pCompo, const ICRVCOMPOPOVECTOR& vCrvCheck, const Frame3d& frLocXY) const ;
|
|
bool SimplyfySfr( ISurfFlatRegion* pSfr) const ;
|
|
bool CheckSafetyLinearLink( const Point3d& ptCurr, const Point3d& ptDest, const ISurfFlatRegion* pSfrCheck, const Vector3d& vtTool,
|
|
bool& bSafe) const ;
|
|
bool GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const ;
|
|
bool VerifyLeadInHelix( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptCen, double dHelixRad) const ;
|
|
bool VerifyLeadInZigZag( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptPa, const Point3d& ptPb) const ;
|
|
|
|
private :
|
|
double GetSpeed() const
|
|
{ return ( IsNullAngValue( m_Params.m_dSpeed) ? m_TParams.m_dSpeed : m_Params.m_dSpeed) ; }
|
|
double GetFeed() const
|
|
{ return ( IsNullLenValue( m_Params.m_dFeed) ? m_TParams.m_dFeed : m_Params.m_dFeed) ; }
|
|
double GetAdaptedCoeffFeed( bool bExtraStep, double dDepth, double dStep) const
|
|
{ if ( ! bExtraStep || dStep < 10 * EPS_SMALL)
|
|
return 1. ;
|
|
return ( 1. + ( - dDepth / dStep) - std::floor( - dDepth / dStep)) ; } ;
|
|
double GetStartFeed() const
|
|
{ return ( IsNullLenValue( m_Params.m_dStartFeed) ? m_TParams.m_dStartFeed : m_Params.m_dStartFeed) ; }
|
|
double GetEndFeed() const
|
|
{ return ( IsNullLenValue( m_Params.m_dEndFeed) ? m_TParams.m_dEndFeed : m_Params.m_dEndFeed) ; }
|
|
double GetTipFeed() const
|
|
{ return ( IsNullLenValue( m_Params.m_dTipFeed) ? m_TParams.m_dTipFeed : m_Params.m_dTipFeed) ; }
|
|
double GetOffsR() const
|
|
{ double dCurrOffsR = IsUnknownValue( m_Params.m_dOffsR) ? m_TParams.m_dOffsR : m_Params.m_dOffsR ;
|
|
return std::max( 0.1, dCurrOffsR) ; }
|
|
double GetOffsL() const
|
|
{ return ( IsUnknownValue( m_Params.m_dOffsL) ? m_TParams.m_dOffsL : m_Params.m_dOffsL) ; }
|
|
double GetSideStep( void) const
|
|
{ return Clamp( m_Params.m_dSideStep, 0.1, m_TParams.m_dTDiam) ; }
|
|
int GetLeadInType( void) const
|
|
{ if ( m_Params.m_dLiTang < std::min( 0.1 * m_TParams.m_dDiam, 1.0))
|
|
return SURFROU_LI_NONE ;
|
|
if ( m_Params.m_nLeadInType != SURFROU_LI_GLIDE && m_Params.m_dLiElev < 10 * EPS_SMALL)
|
|
return SURFROU_LI_NONE ;
|
|
return m_Params.m_nLeadInType ; }
|
|
bool LeadInRawIsOk( void) const
|
|
{ if ( m_TParams.m_nType != TT_MILL_NOTIP)
|
|
return true ;
|
|
return (( GetLeadInType() == SURFROU_LI_ZIGZAG || GetLeadInType() == SURFROU_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 SURFROU_LO_NONE ;
|
|
return m_Params.m_nLeadOutType ; }
|
|
|
|
/* debug functions */
|
|
void DrawLoopsSurf( const ISurfFlatRegion* pSfr, bool bWithSurf, Color Col, bool bAlphaCoverage, std::string sName) const ;
|
|
void DrawFeed( const ICurve* pCrv, double dFeed, int nLay) const ;
|
|
void DrawNormalShaderSurfTm( const ISurfTriMesh* pStm, std::string sName) const ;
|
|
/* end debug functions */
|
|
|
|
private :
|
|
SELVECTOR m_vId ; // identificativi entità geometriche da lavorare
|
|
SurfRoughingData 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
|
|
int m_nStatus ; // stato di aggiornamento della lavorazione
|
|
int m_nPaths ; // numero di percorsi di lavoro generati
|
|
double m_dMaxHelixRad ; // raggio massimo attacco ad elica nel caso di cerchi
|
|
double m_dStepToler ; // tolleranza di rimozione chunk per Steps
|
|
double m_dSubStepToler ; // tolleranza di rimozione chunk per SubSteps
|
|
bool m_bDetectPlaneZ ; // flag per calcolo piani in Zloc di Pocketing
|
|
bool m_bOrderZ ; // flag per ordinamento Chunks secondo vtTool
|
|
bool m_bRunning ; // flag di calcoli in corso
|
|
} ; |