EgtMachKernel :
- preparazione nuova gestione calcolo elevazioni.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkCDeBoxClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCAvToolSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||
@@ -377,6 +378,8 @@ Operation::GetElevation( int nPhase, const Point3d& ptP1, const Point3d& ptP2, c
|
||||
return true ;
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad,
|
||||
@@ -457,6 +460,102 @@ Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool,
|
||||
return true ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad,
|
||||
const Vector3d& vtDir, double& dElev) const
|
||||
{
|
||||
const double STD_TOOL_LEN = 100 ;
|
||||
return GetElevation( nPhase, ptP, vtTool, dRad, STD_TOOL_LEN, vtDir, dElev) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Operation::GetElevation( int nPhase, const Point3d& ptP, const Vector3d& vtTool, double dRad, double dLen,
|
||||
const Vector3d& vtDir, double& dElev) const
|
||||
{
|
||||
// risultato di default
|
||||
dElev = 0 ;
|
||||
// verifico oggetti base
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// inizializzo elevazioni per ogni grezzo
|
||||
INTDBLVECTOR vRawElev ;
|
||||
// ciclo sui grezzi della fase
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
while ( nRawId != GDB_ID_NULL) {
|
||||
// verifico che il grezzo compaia nella fase
|
||||
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) {
|
||||
// recupero la trimesh del grezzo
|
||||
int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ;
|
||||
if ( pStm != nullptr) {
|
||||
// recupero il riferimento della trimesh
|
||||
Frame3d frStm ;
|
||||
m_pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||
// porto posizione e direzioni in questo riferimento
|
||||
Point3d ptPL = GetToLoc( ptP, frStm) ;
|
||||
Vector3d vtToolL = GetToLoc( vtTool, frStm) ;
|
||||
Vector3d vtDirL = GetToLoc( vtDir, frStm) ;
|
||||
// determino quanto allontanarsi
|
||||
PtrOwner<ICAvToolSurfTm> pCAvTlStm( CreateCAvToolSurfTm()) ;
|
||||
if ( IsNull( pCAvTlStm))
|
||||
return false ;
|
||||
pCAvTlStm->SetStdTool( dLen, dRad, 0) ;
|
||||
pCAvTlStm->SetSurfTm( *pStm) ;
|
||||
double dDist = 0 ;
|
||||
// per Collision Avoid il punto di riferimento non è il tip dell'utensile ma il naso mandrino
|
||||
if ( ! pCAvTlStm->TestPosition( ptPL + dLen * vtToolL, vtToolL, vtDirL, dDist))
|
||||
return false ;
|
||||
if ( dDist > 0)
|
||||
vRawElev.emplace_back( nStmId, dDist) ;
|
||||
}
|
||||
}
|
||||
// passo al grezzo successivo
|
||||
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
|
||||
}
|
||||
// se trovate elevazioni
|
||||
if ( ! vRawElev.empty()) {
|
||||
// ordino il vettore secondo l'elevazione crescente
|
||||
sort( vRawElev.begin(), vRawElev.end(), []( const INTDBL& a, const INTDBL& b)
|
||||
{ return a.second < b.second ; }) ;
|
||||
// box dell'utensile nella posizione iniziale
|
||||
BBox3d b3Tool ;
|
||||
b3Tool.Add( ptP) ;
|
||||
b3Tool.Add( ptP + dLen * vtTool) ;
|
||||
if ( vtTool.IsX())
|
||||
b3Tool.Expand( 0, dRad, dRad) ;
|
||||
else if ( vtTool.IsY())
|
||||
b3Tool.Expand( dRad, 0, dRad) ;
|
||||
else if ( vtTool.IsZ())
|
||||
b3Tool.Expand( dRad, dRad, 0) ;
|
||||
else {
|
||||
double dExpandX = dRad * sqrt( 1 - vtTool.x * vtTool.x) ;
|
||||
double dExpandY = dRad * sqrt( 1 - vtTool.y * vtTool.y) ;
|
||||
double dExpandZ = dRad * sqrt( 1 - vtTool.z * vtTool.z) ;
|
||||
b3Tool.Expand( dExpandX, dExpandY, dExpandZ) ;
|
||||
}
|
||||
b3Tool.Expand( MAX_DIST_RAW) ;
|
||||
// verifico la reale interferenza dell'utensile con i diversi grezzi
|
||||
for ( int i = 0 ; i < vRawElev.size() ; ++ i) {
|
||||
// box del grezzo
|
||||
BBox3d b3Raw ;
|
||||
m_pGeomDB->GetGlobalBBox( vRawElev[i].first, b3Raw) ;
|
||||
// confronto con il box dell'utensile nella posizione precedente
|
||||
BBox3d b3CurrTool = b3Tool ;
|
||||
b3CurrTool.Translate( dElev * vtDir) ;
|
||||
if ( b3Raw.Overlaps( b3CurrTool))
|
||||
dElev = vRawElev[i].second ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Operation::GetAhPointUnderRaw( const Point3d& ptP, const Vector3d& vtTool, double dToolRad, double dToolRadForElev,
|
||||
|
||||
Reference in New Issue
Block a user