04bb4165c9
- modifiche a UpdateToolData per impostare lavorazione da riverificare se sono cambiati i dati dell'utensile.
248 lines
18 KiB
C++
248 lines
18 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2019-2019
|
|
//----------------------------------------------------------------------------
|
|
// File : SurfFinishing.h Data : 28.05.19 Versione : 2.1e5
|
|
// Contenuto : Dichiarazione della classe SurfFinishing.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 28.05.19 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "set"
|
|
#include "Machining.h"
|
|
#include "SurfFinishingData.h"
|
|
#include "ToolData.h"
|
|
#include "MachiningConst.h"
|
|
#include "GeoConst.h"
|
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
|
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
|
#include "/EgtDev/Include/EGkSurfLocal.h"
|
|
|
|
class ICAvToolSurfTm ;
|
|
class ISurfFlatRegion ;
|
|
class ISurfTriMesh ;
|
|
class ICAvParSilhouettesSurfTm ;
|
|
class StmFromTriangleSoup ;
|
|
|
|
// struttura percorsi da calcolare per finiture ottimizzate
|
|
struct PATH {
|
|
PtrOwner<ICurveComposite> pCrvPath ;
|
|
int nType ;
|
|
} ;
|
|
// vettore associato
|
|
typedef std::vector<PATH> VECTORPATHS ;
|
|
|
|
// struttura per collisioni per finiture ottimizzate
|
|
struct CollisionSfr {
|
|
PNTUVVECT CollisionInfo ;
|
|
bool bInSpiral ;
|
|
bool bInZConst ;
|
|
bool bOnBorder ;
|
|
} ;
|
|
// vettore associato
|
|
typedef std::vector<CollisionSfr> VECTORCOLLISIONSFR ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
class SurfFinishing : public Machining
|
|
{
|
|
public : // IUserObj
|
|
SurfFinishing* 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_SAWFINISHING ; }
|
|
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 :
|
|
SurfFinishing( 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 GetSurfacesByIds( SURFLOCALVECTOR& vSrfLoc, SURFLOCALVECTOR& vSrfSuppLoc, Frame3d& frSurf) ;
|
|
bool CalcRegionElevation( const ISurfFlatRegion* pSfr, const Vector3d& vtTool, double dRad, double dLen, double& dElev) const ; ;
|
|
bool SetCAvTlStmForSurfaces( ICAvToolSurfTm* pCAvTlStm, const ISurfFlatRegion* pSfrCnt, double dDepth,
|
|
double dToolLen, double dToolDiam, double dToolCornRad,
|
|
double dToolSideAng, double dToolMaxMat, double dMachOffsR,
|
|
const SURFLOCALVECTOR& vSurfLoc, const SURFLOCALVECTOR& vSurfSuppLoc) ;
|
|
bool EraseMaxDownSurf( const SURFLOCALVECTOR& vSurfLoc, const Frame3d& frSurf, const Vector3d& vtTool,
|
|
double dDepth, ISurfFlatRegion* pSfrCnt) ;
|
|
bool ProcessCrvCompo( int nPathId, int nPvId, int nClId) ;
|
|
bool ProcessSfr( int nPathId, int nPvId, int nClId) ;
|
|
bool SimplifyCurve( ICurveComposite* pCompo,
|
|
double dMergeLinTol = 200. * EPS_SMALL, double dMergeAndTolDeg = 200. * EPS_ANG_SMALL,
|
|
double dSmallDefLinTol = 150. * EPS_SMALL, double dSmallDefAngTolDeg = 2. * ANG_TOL_STD_DEG,
|
|
double dArcApproxLinTol = 50. * EPS_SMALL, double dArcApproxAngTolDeg = ANG_TOL_STD_DEG) const ;
|
|
bool CalcZConstProjectedLink( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frPocket,
|
|
const Frame3d& frSurf, const Vector3d& vtTool, double dDepth,
|
|
const Point3d ptStart_forced, const Point3d ptEnd_forced,
|
|
ICurveComposite* pCrv) const ;
|
|
// lavorazioni per superfici
|
|
bool AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ISurfFlatRegion* pSfrCnt,
|
|
const Vector3d& vtTool, double dDepth, double dElev, bool bSplitArcs) ;
|
|
bool AddOneWay( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ISurfFlatRegion* pSfrCnt,
|
|
const Vector3d& vtTool, double dDepth, double dElev, bool bSplitArcs) ;
|
|
bool AddSpiral( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ISurfFlatRegion* pSfrCnt,
|
|
const Vector3d& vtTool, double dDepth, double dElev, bool bSplitArcs, bool bInVsOut) ;
|
|
bool AddZConst( ICAvToolSurfTm* pCAvTlStm, const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf,
|
|
const ISurfFlatRegion* pSfrCnt, const Vector3d& vtTool, double dDepth, double dElev, bool bSplitArcs) ;
|
|
bool AddOptimal( ICAvToolSurfTm* pCAvTlStm, const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf,
|
|
const ISurfFlatRegion* pSfrCntZigZag, const ISurfFlatRegion* pSfrCntZConst, const Vector3d& vtTool,
|
|
double dDepth, double dElev, bool bSplitArcs) ;
|
|
bool AddPencil( ICAvToolSurfTm* pCAvTlStm, const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf,
|
|
const ISurfFlatRegion* pSfrCnt, const Vector3d& vtTool, double dDepth, double dElev, bool bSplitArcs) ;
|
|
// lavorazioni per curve
|
|
bool AddProjection( ICAvToolSurfTm* pCAvTlStm, const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf, const ICurveComposite* pCompo,
|
|
const Vector3d& vtTool, double dDepth, double dElev, bool bSplitArcs) ;
|
|
// creazione del percorso finale di lavorazione
|
|
bool AddFinishing( const ISurfFlatRegion* pSfrCnt, ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const ICRVCOMPOPOVECTOR& vCrvCompo,
|
|
const Vector3d& vtTool, double dElev, double dDepth, bool bSplitArcs) ;
|
|
// collisione con i percorsi di lavorazione
|
|
bool CorrectPathByCollision( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const Vector3d& vtTool,
|
|
double dDepth, ICRVCOMPOPOVECTOR& vpCrvs) ;
|
|
|
|
bool WorkPencilCurves( const ICRVCOMPOPOVECTOR& vCrvCompo, const ISurfFlatRegion* pSfrCnt, int nPencilType, double dOffs, int nOffs,
|
|
double dDepth, double dElev, double dLinTol, const Vector3d& vtTool, const SURFLOCALVECTOR& vSrfLoc,
|
|
const Frame3d& frSurf, ICAvToolSurfTm* pCAvTlStm, bool bSplitArcs) ;
|
|
bool OrderAndConnectPencilCurves( ICRVCOMPOPOVECTOR& vCrvCompo, double dLinkTol) const ;
|
|
bool GetOffsetCurvesFromPencilProjection( const ICRVCOMPOPOVECTOR& vCrvCompo, const ISurfFlatRegion* pSfrClass,
|
|
double dOffs, int nPencilType, ICRVCOMPOPOVECTOR& vCrvCompoRes) const ;
|
|
bool ProjectExposedPencilCurvesOnPlane( ICAvToolSurfTm* pCAvTlStm, const ICRVCOMPOPOVECTOR& vCrvCompo,
|
|
const Plane3d& plProj, const Vector3d& vtAxL, const Vector3d& vtMoveL,
|
|
double dOffs, double dDepth, ICRVCOMPOPOVECTOR& vCrvCompoProj) const ;
|
|
bool ChainPencilCurves( ICRVCOMPOPOVECTOR& vCrvCompo, double dLinTol, bool bAllowInvert = true) const ;
|
|
bool GetSurfTriMeshFromOffset( const SURFLOCALVECTOR& vSrfLoc, double dOffs, double dLinTol, ISurfTriMesh* pStmOffs) const ;
|
|
bool GetCurvesFromSurfTriMeshesOffset( const ISurfTriMesh * pStmOffs, double dBiTanAng, double dLinTol,
|
|
int nOffs, const ISurfFlatRegion* pSfrCnt, ICRVCOMPOPOVECTOR& vCrvCompo ) ;
|
|
bool ChooseFinishingForOptimal( const ISurfFlatRegion* pSfr, int nChunk, bool& bSpiral, double& dSideAng) ;
|
|
bool OrderOptimalPathsByZLoc( const ISurfFlatRegion* pSfrCntZConst, const ISurfFlatRegion* pSfrCntZigZag, VECTORPATHS& vCrvPaths) const ;
|
|
bool GetSfrBySilhouette( ICAvParSilhouettesSurfTm* pCavParSilh, double dDepth, double dSilTolSamp,
|
|
double dSilTolLin, double dSilTolAng, ISurfFlatRegion* pSfrSil) ;
|
|
bool ApproxSilhouetteClosedPLForOptimal( PolyLine& PL, double dSampleTol, double dMaxLinTol, double dAngTol, double dLinFeaTol, ICurveComposite* pCompoPL) ;
|
|
bool SplitStmTrianglesByClippingAngle( const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf, const ISurfFlatRegion* pSfrCnt,
|
|
const Vector3d& vtTool, double dDepth, double dClippingAngle, double dTolerAngle,
|
|
ISURFTMPOVECTOR& vpStm1, ISURFTMPOVECTOR& vpStm2, double& dMaxFrontTriaRad) const ;
|
|
bool GetZConstQuotesInsideSfrParallelToTool( const SURFLOCALVECTOR&, const Frame3d& frSurf, const ISurfFlatRegion* pSfr,
|
|
const Vector3d& vtTool, std::set<double>& setZAmbiguos) const ;
|
|
ISurfFlatRegion* GetSfrSilhouette( const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frLvl0, double dDepth) const ;
|
|
ISurfFlatRegion* GetSfrProjectedStmLoops( const ISURFTMPOVECTOR& vStm, const ISurfFlatRegion* pSfrContour,
|
|
const DBLVECTOR& vdLinFeaTol, const DBLVECTOR& vdAngTol, const DBLVECTOR& vdMaxLinTol) const ;
|
|
ISurfTriMesh* SplitStmTriaUnderClippingAngle( const SurfLocal SrfLoc, const Vector3d& vtTest, double dClippingAngle,
|
|
double dFrontTriaTolerAng, double& dMaxFrontTriaRad) const ;
|
|
bool CalcOptimalZConstCurves( const ISurfFlatRegion* pSfrLoc, const SURFLOCALVECTOR& vSrfLoc,
|
|
const Frame3d& frSurf, const Vector3d& vtTool, double dAngDegSplit,
|
|
double dAngDegTol, double dDepth, ICAvToolSurfTm* pCAvTlStm, VECTORPATHS& vPaths, ISurfFlatRegion* pSfrProj) const ;
|
|
bool CalcOptimalZigZagCurves( const ISurfFlatRegion* pSfrLoc, const Frame3d& frSurf,
|
|
const Vector3d& vtTool, double dDepth, ICAvToolSurfTm* pCAvTlStm, VECTORPATHS& vPaths) const ;
|
|
bool GetOptimalSfr( ICAvToolSurfTm* pCAvTlStm, const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf, const ISurfFlatRegion* pSfrLoc, const Vector3d& vtTool,
|
|
double dDepth, double dElev, ISurfFlatRegion* pSfrSpiral, ISurfFlatRegion* pSfrZConst) const ;
|
|
bool CalcZConstSilCrv( ICAvParSilhouettesSurfTm* pCavParSilh, const SURFLOCALVECTOR& vSrfLoc, const Frame3d& frSurf,
|
|
const ISurfFlatRegion* pSfrClass, const Vector3d& vtTool, double dDepth, std::vector<ICRVCOMPOPOVECTOR>& vCrvCompo) const ;
|
|
bool CreateZConstPaths( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, std::vector<ICRVCOMPOPOVECTOR>& vCrvCompo, const Vector3d& vtTool,
|
|
const ISurfFlatRegion* pSfr, double dDepth, ICRVCOMPOPOVECTOR& vCrvPath) const ;
|
|
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
|
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
|
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& vtStart, const Vector3d& vtTool, const Vector3d& vtNorm, Point3d& ptP1) const ;
|
|
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, bool bSplitArcs) ;
|
|
bool CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtTool, const Vector3d& vtNorm, Point3d& ptP1) const ;
|
|
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Point3d& ptP1, const Vector3d& vtTool, bool bSplitArcs) ;
|
|
bool GetLastGoodPoint( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, const Point3d& ptStart,
|
|
const Point3d& ptEnd, const Vector3d& vtInit, const Vector3d& vtTool,
|
|
bool bLeadInVsOut, Point3d& ptP1) const ;
|
|
bool GetLinkFromPaths( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtTool, const ISurfFlatRegion* pSfrCnt,
|
|
double dDepth, double dSafeZ, ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, ICurveComposite* pCrvLink) const ;
|
|
bool GetSurfaceNormalAtPoint( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf,
|
|
const Point3d& ptTool, const Vector3d& vtTool, Vector3d& vtNorm) const ;
|
|
bool GetActiveSurfaces( INTVECTOR& vSurfId, INTVECTOR& vSurfSuppId) const ;
|
|
int ProcessSquare( int nFlag, double dLevel, double dQPt0, double dQpt1, double dQpt2, double dQpt3,
|
|
int& nI1s, int& nI1e, int& nI2s, int& nI2e) const ;
|
|
Point3d CalcShapedPoint( const PNTUVVECT& myInfoStart, const PNTUVVECT& myInfoEnd, int nType, const Vector3d& vtAxL,
|
|
const Vector3d& vtMoveL, double dCosSplitAngle, double dLimInfCosSplitAng,
|
|
double dLimSupCosSplitAng, ICAvToolSurfTm* pCAvTlStm, int _nInd_debug) const ;
|
|
bool TestSubEdges( std::unordered_map<int, Point3d>& umEdgePnt, const INTVECTOR& vEdgeInd, int nType, int nFirst, int nLast,
|
|
const VECTORCOLLISIONSFR& vPntM, int nStepX, const Vector3d vtAxL, const Vector3d& vtMoveL,
|
|
double dCosSplitAng, double dLimInfCosSplitAng, double dLimSupCosSplitAng, ICAvToolSurfTm* pCAvTlStm, int _nInd_debug) const ;
|
|
bool MarchingSquares( const VECTORCOLLISIONSFR& vPntM, int nType, double dOffsTol, int nStepX, int nStepY, double dClippingAngle,
|
|
double dLimInfClippingAng, double dLimSupClippingAng, const Vector3d& vtAxL, const Vector3d& vtMoveL, ICAvToolSurfTm* pCAvTlStm,
|
|
ICRVCOMPOPOVECTOR& vCrvCompo) const ;
|
|
double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ;
|
|
double GetRadiusForStartEndElevation( void) 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 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
|
|
{ return ( IsUnknownValue( m_Params.m_dOffsR) ? m_TParams.m_dOffsR : m_Params.m_dOffsR) ; }
|
|
double GetSideStep( void) const
|
|
{ return Clamp( m_Params.m_dSideStep, 0.1, m_TParams.m_dTDiam) ; }
|
|
int GetLeadInType( void) const ;
|
|
int GetLeadOutType( void) const ;
|
|
|
|
private :
|
|
SELVECTOR m_vId ; // identificativi entit� geometriche da lavorare
|
|
SurfFinishingData 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
|
|
bool m_bRunning ; // flag di calcoli in corso
|
|
} ;
|