Files
EgtMachKernel/Operation.h
T
Dario Sassi c3729befbb EgtMachKernel :
- modifiche e correzioni per flag di fine passata (301) in fresatura con lama a ZigZag e OneWay.
2024-02-27 10:36:52 +01:00

235 lines
14 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2016-2019
//----------------------------------------------------------------------------
// File : Operation.h Data : 17.06.19 Versione : 2.1f2
// Contenuto : Dichiarazione della classe Operation da cui derivano
// Disposition e Machining.
//
//
//
// Modifiche : 29.04.16 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "MachConst.h"
#include "MachineStruConst.h"
#include "/EgtDev/Include/EGkPoint3d.h"
#include "/EgtDev/Include/EGkUserObj.h"
#include "/EgtDev/Include/EGkSelection.h"
#include "/EgtDev/Include/EgtNumCollection.h"
class MachMgr ;
class CamData ;
class ICurve ;
class ICurveComposite ;
//----------------------------------------------------------------------------
class Operation : public IUserObj
{
public : // IUserObj
bool SetOwner( int nId, IGeomDB* pGDB) override ;
int GetOwner( void) const override ;
IGeomDB* GetGeomDB( void) const override ;
bool Removing( int nParentId, int nNextId) override ;
bool Relocate( int nOrigParentId, int nOrigNextId, int nRefId, int nSonBeforeAfter, bool bGlob) override ;
public :
virtual bool Init( MachMgr* pMchMgr) ;
virtual bool SetPhase( int nPhase)
{ m_nPhase = nPhase ; return true ; }
virtual int GetPhase( void) const
{ return m_nPhase ; }
virtual bool RemoveHome( void) ;
std::string GetName( void) const ;
public :
virtual int GetType( void) const = 0 ;
virtual bool IsEmpty( void) const = 0 ;
virtual bool UpdateStatus( int nModif) = 0 ;
protected :
virtual const std::string& GetToolName( void) const = 0 ;
virtual const std::string& GetHeadName( void) const = 0 ;
virtual int GetExitNbr( void) const = 0 ;
virtual int GetSolCh( void) const = 0 ;
virtual const std::string& GetToolTcPos( void) const = 0 ;
virtual bool NeedPrevHome( void) const = 0 ;
virtual bool AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) const
{ return true ; }
virtual bool AdjustArcCenterForAxesCalc( const CamData* pCamData, Point3d& ptCen) const
{ return true ; }
protected :
Operation( void) ;
protected :
bool UpdateFollowingOperationsStatus( int nModif) ;
bool GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev, Vector3d& vtNorm) const ;
bool GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev, INTVECTOR& vRawStmId) const ;
bool GetElevation( int nPhase, const Point3d& ptP,
const Vector3d& vtDir, double& dElev, Vector3d& vtNorm, INTVECTOR& vRawStmId) const ;
bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad, double dLen,
const Vector3d& vtDir, double& dElev) const ;
bool GetElevation( int nPhase, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtTool, double dRad, double dLen,
const Vector3d& vtDir, double& dElev) const ;
bool GetAhPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
double dToolLen, bool bIsSaw, double dSafeZ, const Vector3d& vtDir, double& dElev) const ;
bool GetUhPointAboveRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
double dToolLen, bool bIsSaw, double dSafeZ, const Vector3d& vtDir, double& dElev) const ;
bool GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3d& vtDir, double& dDist) const ;
bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand,
double& dDist, Vector3d& vtDir) const ;
bool GetMinDistanceFromRawSide( int nPhase, const Point3d& ptP, double dExpand,
const Vector3d& vtMainDir, double dCosMaxDelta,
double& dDist, Vector3d& vtDir) const ;
bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist) const
{ double dDummy ;
return GetDistanceFromRawBottom( nPhase, nPathId, dToler, dRbDist, dDummy) ; }
bool GetDistanceFromRawBottom( int nPhase, int nPathId, double dToler, double& dRbDist, double& dAllRbDist) const ;
bool GetRawGlobBox( int nPhase, int nPathId, double dToler, BBox3d& b3Raw) const ;
bool GetRawGlobBox( int nPhase, const BBox3d& b3Test, double dToler, BBox3d& b3Raw) const ;
bool GetCurrRawsGlobBox( BBox3d& b3Raw) const ;
bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo, int nToolDir, int nFaceUse, double dToolThick, int nGrade = 3) ;
bool ApproxWithArcsIfUseful( ICurveComposite* pCompo, bool bCareTempProp = false) const ;
bool ApproxWithLines( ICurveComposite* pCompo, double dMaxLen = 0) const ;
bool VerifyArcs( ICurveComposite* pCompo, double dMaxAngCen = MAX_ANG_CEN) const ;
bool CalcAndSetBBox( int nClId) ;
bool CalcAndSetAxesBBox( void) ;
bool CalcMirrorByDouble( int nClId, const std::string& sUserNotes) ;
bool GetInitialAxesValues( bool bSkipClimb, DBLVECTOR& vAxVal) const ;
bool GetClPathInitialAxesValues( int nClPathId, bool bSkipClimb, DBLVECTOR& vAxVal) const ;
bool GetFinalAxesValues( bool bSkipRise, DBLVECTOR& vAxVal) const ;
bool GetClPathFinalAxesValues( int nClPathId, bool bSkipRise, DBLVECTOR& vAxVal) const ;
bool GetInitialToolDir( bool bSkipClimb, Vector3d& vtTool) const ;
bool GetClPathInitialToolDir( int nClPathId, bool bSkipClimb, Vector3d& vtTool) const ;
bool GetFinalToolDir( bool bSkipRise, Vector3d& vtTool) const ;
bool GetClPathFinalToolDir( int nClPathId, bool bSkipRise, Vector3d& vtTool) const ;
const CamData* GetInitialCamData( bool bSkipClimb) const ;
const CamData* GetClPathInitialCamData( int nClPathId, bool bSkipClimb) const ;
const CamData* GetFinalCamData( bool bSkipRise) const ;
const CamData* GetClPathFinalCamData( int nClPathId, bool bSkipRise) const ;
std::string ExtractInfo( const std::string& sNotes, const std::string& sKey) const ;
std::string ExtractHint( const std::string& sNotes) const ;
bool SetBlockedRotAxis( const std::string& sBlockedAxis) const ;
bool CalculateAxesValues( const std::string& sHint, bool bRotContOnNext = true, bool bSolChExact = false) ;
bool CalculateClPathCenterAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
bool bMaxDeltaR2OnFirst, bool bRotContOnNext, double dAngDeltaMinForHome,
const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec) ;
bool CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
bool bMaxDeltaR2OnFirst, bool bRotContOnNext, double dAngDeltaMinForHome,
const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec, int& nOutStrC) ;
bool CalculateClPathRobotAxesValues( int nClPathId, int nLinAxes, int nRotAxes, double dRot1W,
bool bMaxDeltaR2OnFirst, bool bRotContOnNext, double dAngDeltaMinForHome,
const DBLVECTOR& vAxRotHome, DBLVECTOR& vAxRotPrec) ;
bool AdjustStartEndMovements( bool bVerifyPreviousLink = true) ;
bool AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation* pPrevOp, const DBLVECTOR& vAxPrev, bool bMaxZ) ;
bool ToolChangeNeeded( const Operation& Op1, const Operation& Op2) const ;
bool RemoveClimb( int nClPathId) ;
bool AddRise( DBLVECTOR& vAxVal, double dDelta = - 1, int nClPathId = GDB_ID_NULL, bool bZHomeDown = false) ;
bool AddSpecialRise( const DBLVECTOR& vAxVal, bool bOk = true, int nClPathId = GDB_ID_NULL, int nFlag = 0) ;
bool RemoveRise( int nClPathId = GDB_ID_NULL) ;
bool AddHome( void) ;
bool RemoveClimbRiseHome( void) ;
bool AddRobotClimb( int nEntId, double dDeltaZ) ;
bool CalcRobotAxesAbovePos( const Point3d& ptP, const Vector3d& vtT, const Vector3d& vtA, double dDeltaZ,
DBLVECTOR& vAx, double* pdNewDeltaZ = nullptr) const ;
bool CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) const ;
bool GetExtraZ( const DBLVECTOR& vAx1, const Vector3d& vtTool1,
const DBLVECTOR& vAx2, const Vector3d& vtTool2,
double dHomeZ, double& dExtraZ) const ;
bool SpecialGetMaxZ( const DBLVECTOR& vAx1, const Vector3d& vtTool1,
const DBLVECTOR& vAx2, const Vector3d& vtTool2,
double& dMaxZ) const ;
bool GetRotationAtZmax( void) const ;
bool ForcedZmax( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, const BBox3d& b3Raws) const ;
int GetUserNotesZmax( void) const ;
bool GetZHomeDown( void) const ;
bool TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ;
int SpecialTestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) const ;
bool SpecialMoveZup( DBLVECTOR& vAx, Vector3d& vtTool, int& nFlag, int& nFlag2, bool& bModif) ;
bool SpecialMoveRapid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, DBLVECTOR& vAxNew, bool& bModif) ;
bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) const ;
bool IsAggrBottom( const std::string& sHead) const ;
protected :
int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
int m_nPhase ; // indice della fase di appartenenza (da 1 in su)
protected :
bool SetPathId( int nPathId) ;
bool SetToolDir( const Vector3d& vtDir) ;
bool SetCorrDir( const Vector3d& vtDir) ;
bool SetAuxDir( const Vector3d& vtDir) ;
bool SetCorrAuxDir( const Vector3d& vtDir) ;
bool SetFeed( double dFeed) ;
bool SetFlag( int nFlag) ;
bool SetFlagOnLastMove( int nFlag) ;
bool SetFlag2( int nFlag2) ;
bool SetIndex( int nIndex) ;
bool GetCurrPos( Point3d& ptCurr) const
{ if ( ! m_bCurr) return false ; ptCurr = m_ptCurr ; return true ; }
bool SameAsCurrPos( const Point3d& ptP) const
{ if ( ! m_bCurr) return false ; return AreSamePointEpsilon( ptP, m_ptCurr, 10 * EPS_SMALL) ; }
bool GetCurrCorr( Vector3d& vtCCurr) const
{ if ( ! m_bCurr) return false ; vtCCurr = m_vtCorr ; return true ; }
bool GetCurrAux( Vector3d& vtACurr) const
{ if ( ! m_bCurr) return false ; vtACurr = m_vtAux ; return true ; }
int AddRapidStart( const Point3d& ptP) ;
int AddRapidStart( const Point3d& ptP, const std::string& sName) ;
int AddRapidMove( const Point3d& ptP) ;
int AddRapidMove( const Point3d& ptP, const std::string& sName) ;
int AddLinearMove( const Point3d& ptP) ;
int AddLinearMove( const Point3d& ptP, const std::string& sName) ;
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN) ;
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, const std::string& sName) ;
int AddCurveMove( const ICurve* pCrv, bool bOnlySimple = false) ;
int AddCurveMove( const ICurve* pCrv, const std::string& sName, bool bOnlySimple = false) ;
bool ResetMoveData( void) ;
protected :
int m_nPathId ; // identificativo del gruppo corrente di inserimento dati
bool m_bCurr ; // punto corrente valido
Point3d m_ptCurr ; // posizione corrente
Vector3d m_vtTool ; // direzione fresa corrente
Vector3d m_vtCorr ; // direzione correzione corrente
Vector3d m_vtAux ; // direzione ausiliaria corrente
double m_dFeed ; // feed corrente
int m_nFlag ; // flag corrente
int m_nFlag2 ; // secondo flag corrente
int m_nIndex ; // indice corrente
} ;
//----------------------------------------------------------------------------
inline const Operation* GetOperation( const IUserObj* pUserObj)
{ return dynamic_cast<const Operation*>( pUserObj) ; }
inline Operation* GetOperation( IUserObj* pUserObj)
{ return dynamic_cast< Operation*>( pUserObj) ; }
//----------------------------------------------------------------------------
// tipo posizione utensile
enum { TOOL_PARAL = 1, TOOL_ORTHO = 2, TOOL_ORTUP = 3, TOOL_PAR_SLANT= 4} ;
// tipo di utilizzo contorno faccia
enum { FACE_DOWN = 1, FACE_TOP = 2, FACE_FRONT = 3, FACE_BACK = 4, FACE_LEFT = 5, FACE_RIGHT = 6, FACE_CONT = 7} ;
// risultato di SpecialTestCollisionAvoid
enum { SCAV_ERROR = -1, SCAV_COLLIDE = 0, SCAV_AVOID = 1, SCAV_TOTEST = 2};