e62a6036a4
- aggiunta funzione IsGlobFrame.
179 lines
7.0 KiB
C++
179 lines
7.0 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2013-2023
|
|
//----------------------------------------------------------------------------
|
|
// File : EGkFrame3d.h Data : 20.07.23 Versione : 2.5g2
|
|
// Contenuto : Dichiarazione della classe Reference Frame 3d.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 04.01.13 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
#pragma once
|
|
|
|
#include "/EgtDev/Include/EGkPoint3d.h"
|
|
|
|
//----------------------- Macro per import/export ----------------------------
|
|
#undef EGK_EXPORT
|
|
#if defined( I_AM_EGK) // da definirsi solo nella DLL
|
|
#define EGK_EXPORT __declspec( dllexport)
|
|
#else
|
|
#define EGK_EXPORT __declspec( dllimport)
|
|
#endif
|
|
|
|
//----------------------------------------------------------------------------
|
|
class EGK_EXPORT Frame3d
|
|
{
|
|
public :
|
|
enum Type { ERR = 0, TOP = 1, BOTTOM = 2, FRONT = 3,
|
|
BACK = 4, LEFT = 5, RIGHT = 6, GEN = 7} ;
|
|
public :
|
|
Frame3d( bool bGlob = true)
|
|
: m_nType( bGlob ? TOP : ERR), m_nZType( bGlob ? TOP : ERR), m_ptOrig( ORIG),
|
|
m_vtVersX( X_AX), m_vtVersY( Y_AX), m_vtVersZ( Z_AX) {}
|
|
Frame3d( const Point3d& ptOrig)
|
|
: m_nType( TOP), m_nZType( TOP), m_ptOrig( ptOrig),
|
|
m_vtVersX( X_AX), m_vtVersY( Y_AX), m_vtVersZ( Z_AX) {}
|
|
bool Set( const Point3d& ptOrig, const Vector3d& vtDirX,
|
|
const Vector3d& vtDirY, const Vector3d& vtDirZ) ;
|
|
bool Set( const Point3d& ptOrig, const Point3d& ptOnX, const Point3d& ptNearY) ;
|
|
bool Set( const Point3d& ptOrig, const Vector3d& vtDirZ) ;
|
|
bool Set( const Point3d& ptOrig, const Vector3d& vtDirZ, const Vector3d& vtNearDirX) ;
|
|
bool Set( const Point3d& ptOrig, Type nType) ;
|
|
bool Set( const Point3d& ptOrig, double dAngCDeg, double dAngADeg, double dAngC1Deg) ;
|
|
bool Reset( bool bGlob = true) ;
|
|
bool ChangeOrig( const Point3d& ptOrig) ;
|
|
bool Translate( const Vector3d& vtMove) ;
|
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) ;
|
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
|
bool PseudoScale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
|
bool PseudoMirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
|
bool PseudoShear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
|
bool Invert( void) ;
|
|
bool ToGlob( const Frame3d& frRef) ;
|
|
bool ToLoc( const Frame3d& frRef) ;
|
|
bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
|
Frame3d& operator*=( const Frame3d& frRef)
|
|
{ ToGlob( frRef) ; return *this ; }
|
|
Frame3d& operator/=( const Frame3d& frRef)
|
|
{ ToLoc( frRef) ; return *this ; }
|
|
bool IsValid( void) const
|
|
{ return ( m_nType != ERR) ; }
|
|
int GetType( void) const
|
|
{ return m_nType ; }
|
|
int GetZType( void) const
|
|
{ return m_nZType ; }
|
|
const Point3d& Orig( void) const
|
|
{ return m_ptOrig ; }
|
|
const Vector3d& VersX( void) const
|
|
{ return m_vtVersX ; }
|
|
const Vector3d& VersY( void) const
|
|
{ return m_vtVersY ; }
|
|
const Vector3d& VersZ( void) const
|
|
{ return m_vtVersZ ; }
|
|
bool GetRotationsCAC1( double& dAngC, double& dAngA, double& dAngC1) const ;
|
|
bool GetFixedAxesRotationsABC( double& dAngADeg, double& dAngBDeg, double& dAngCDeg) const ;
|
|
|
|
private :
|
|
bool Verify( void) ;
|
|
void CalculateType( void) ;
|
|
|
|
private :
|
|
Type m_nType ;
|
|
Type m_nZType ;
|
|
Point3d m_ptOrig ;
|
|
Vector3d m_vtVersX ;
|
|
Vector3d m_vtVersY ;
|
|
Vector3d m_vtVersZ ;
|
|
} ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Riferimenti notevoli
|
|
//----------------------------------------------------------------------------
|
|
const Frame3d GLOB_FRM ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Prodotto di due frame (porta il primo dal secondo nel globale)
|
|
//----------------------------------------------------------------------------
|
|
inline const Frame3d
|
|
operator*( const Frame3d& frRef, const Frame3d& frOri)
|
|
{
|
|
Frame3d frNew = frRef ;
|
|
frNew.ToGlob( frOri) ;
|
|
return frNew ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Divisione di due frame (porta il primo dal globale nel secondo)
|
|
//----------------------------------------------------------------------------
|
|
inline const Frame3d
|
|
operator/( const Frame3d& frRef, const Frame3d& frDest)
|
|
{
|
|
Frame3d frNew = frRef ;
|
|
frNew.ToLoc( frDest) ;
|
|
return frNew ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
//! Restituisce una copia in locale del frame passato
|
|
//----------------------------------------------------------------------------
|
|
inline const Frame3d
|
|
GetToLoc ( const Frame3d& frRef, const Frame3d& frDest)
|
|
{
|
|
Frame3d frNew = frRef ;
|
|
frNew.ToLoc( frDest) ;
|
|
return frNew ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
//! Restituisce una copia in globale del frame passato
|
|
//----------------------------------------------------------------------------
|
|
inline const Frame3d
|
|
GetToGlob( const Frame3d& frRef, const Frame3d& frOri)
|
|
{
|
|
Frame3d frNew = frRef ;
|
|
frNew.ToGlob( frOri) ;
|
|
return frNew ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
//! Restituisce una copia dal primo al secondo riferimento del frame passato
|
|
//----------------------------------------------------------------------------
|
|
inline const Frame3d
|
|
GetLocToLoc( const Frame3d& frRef, const Frame3d& frOri, const Frame3d& frDest)
|
|
{
|
|
Frame3d frNew = frRef ;
|
|
frNew.LocToLoc( frOri, frDest) ;
|
|
return frNew ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Verifica che due riferimenti sono coincidenti
|
|
//----------------------------------------------------------------------------
|
|
inline bool
|
|
AreSameFrame( const Frame3d& frRef1, const Frame3d& frRef2)
|
|
{
|
|
if ( frRef1.GetType() == Frame3d::ERR || frRef2.GetType() == Frame3d::ERR)
|
|
return false ;
|
|
if ( ! AreSamePointApprox( frRef1.Orig(), frRef2.Orig()))
|
|
return false ;
|
|
if ( ! AreSameVectorExact( frRef1.VersX(), frRef2.VersX()))
|
|
return false ;
|
|
if ( ! AreSameVectorExact( frRef1.VersY(), frRef2.VersY()))
|
|
return false ;
|
|
if ( ! AreSameVectorExact( frRef1.VersZ(), frRef2.VersZ()))
|
|
return false ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Verifica se il riferimento coincide con quello globale (o identità)
|
|
//----------------------------------------------------------------------------
|
|
inline bool
|
|
IsGlobFrame( const Frame3d& frRef)
|
|
{
|
|
return AreSameFrame( frRef, GLOB_FRM) ;
|
|
}
|