EgtGeomKernel :

- in TestPosition di CollisionAvoid possibilità di restituire normale alla superficie nell'ultimo punto di contatto.
This commit is contained in:
Dario Sassi
2024-07-09 16:48:54 +02:00
parent 98eff1b0b9
commit ff9ea34ae1
2 changed files with 26 additions and 11 deletions
+22 -8
View File
@@ -121,7 +121,8 @@ CAvToolSurfTm::SetGenTool( const ICurveComposite* pToolOutline)
//----------------------------------------------------------------------------
bool
CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist) const
CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove,
double& dTotDist, Vector3d* pvtTriaN) const
{
// Se utensile non definito, errore
if ( m_Tool.GetType() == Tool::UNDEF)
@@ -141,13 +142,19 @@ CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Ve
if ( AreSameFrame( frMove, m_frMove)) {
// Eseguo controllo
Point3d ptCurr = ptT ;
dTotDist = MyTestPositionHG( ptCurr, vtDir) ;
Vector3d vtTriaN ;
dTotDist = MyTestPositionHG( ptCurr, vtDir, vtTriaN) ;
if ( pvtTriaN != nullptr)
*pvtTriaN = vtTriaN ;
return ( dTotDist > - EPS_SMALL) ;
}
}
// Altrimenti eseguo controllo diretto
Point3d ptCurr = ptT ;
dTotDist = MyTestPosition( ptCurr, vtDir, vtMove) ;
Vector3d vtTriaN ;
dTotDist = MyTestPosition( ptCurr, vtDir, vtMove, vtTriaN) ;
if ( pvtTriaN != nullptr)
*pvtTriaN = vtTriaN ;
return ( dTotDist > - EPS_SMALL) ;
}
@@ -232,7 +239,8 @@ CAvToolSurfTm::TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir,
// Ciclo sui punti da verificare
for ( int i = nFirst ; i <= nLast ; ++ i) {
// verifico il punto
double dMove = MyTestPositionHG( vPntM[i].first, vtDir) ;
Vector3d vtTriaN ;
double dMove = MyTestPositionHG( vPntM[i].first, vtDir, vtTriaN) ;
vPntM[i].second = dMove ;
if ( dMove < - EPS_SMALL)
return false ;
@@ -353,7 +361,8 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
while ( itPntMCurr != lPntM.end()) {
// verifico il punto
ptCurr = itPntMCurr->first ;
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir) ;
Vector3d vtTriaN ;
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir, vtTriaN) ;
itPntMCurr->second = dMove ;
if ( dMove < - EPS_SMALL)
return false ;
@@ -397,7 +406,8 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
Point3d ptMid = Media( ptPrev, ptCurr, 0.5) ;
// ne effettuo la correzione per evitare la collisione
Point3d ptNewMid = ptMid ;
double dMidMove = MyTestPositionHG( ptNewMid, vtDir) ;
Vector3d vtTriaN ;
double dMidMove = MyTestPositionHG( ptNewMid, vtDir, vtTriaN) ;
if ( dMidMove < - EPS_SMALL)
return false ;
// massima distanza ammissibile
@@ -419,9 +429,10 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
//----------------------------------------------------------------------------
double
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove) const
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, Vector3d& vtTriaN) const
{
double dTotDist = 0 ;
vtTriaN = V_NULL ;
for ( auto pStm : m_vSTM) {
Triangle3d Tria ;
for ( int nTria = pStm->GetFirstTriangle( Tria) ;
@@ -433,6 +444,7 @@ CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector
if ( dDist > EPS_SMALL) {
dTotDist += dDist ;
ptT += dDist * vtMove ;
vtTriaN = Tria.GetN() ;
}
}
}
@@ -441,7 +453,7 @@ CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector
//----------------------------------------------------------------------------
double
CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) const
CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d& vtTriaN) const
{
// calcolo box utensile nel riferimento di movimento
BBox3d b3Tool ;
@@ -463,6 +475,7 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) const
}
// ciclo sui triangoli che intersecano box in 2d
double dTotDist = 0 ;
vtTriaN = V_NULL ;
INTVECTOR vnIds ;
if ( m_HGrids.Find( b3Tool, vnIds)) {
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
@@ -478,6 +491,7 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) const
if ( dDist > EPS_SMALL) {
dTotDist += dDist ;
ptT += dDist * m_frMove.VersZ() ;
vtTriaN = Tria.GetN() ;
}
else if ( dDist < -EPS_SMALL)
return -1 ;
+4 -3
View File
@@ -36,7 +36,8 @@ class CAvToolSurfTm : public ICAvToolSurfTm
{ return m_Tool.GetHeigth() ; }
const ICurveComposite& GetToolOutline( bool bApprox = false) const override
{ return ( bApprox ? m_Tool.GetApproxOutline() : m_Tool.GetOutline()) ;}
bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist) const override ;
bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove,
double& dTotDist, Vector3d* pvtTriaN = nullptr) const override ;
bool TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dProgCoeff = 1) override ;
bool TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol, double dProgCoeff = 1) override ;
@@ -47,8 +48,8 @@ class CAvToolSurfTm : public ICAvToolSurfTm
private :
bool TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir, int nFirst, int nLast, double dProgCoeff) ;
bool TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol, double dProgCoeff) ;
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove) const ;
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) const ;
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, Vector3d& vtTriaN) const ;
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d& vtTriaN) const ;
bool MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) const ;
bool PrepareHashGrid( void) ;