EgtGeomKernel :
- miglioramenti al calcolo silhouette con CollisionAvoid - modifiche a CollisionAvoid per permettere accelerazione con HashGrid anche a TestPosition.
This commit is contained in:
+96
-63
@@ -12,9 +12,8 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "CAvToolSurfTm.h"
|
||||
#include "CAvSilhouetteSurfTm.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkCAvSilhouetteSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
|
||||
@@ -37,14 +36,46 @@ using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static Point3d
|
||||
CalcPoint( const Point3d& ptS, const Point3d& ptE, double dLevel)
|
||||
CalcPoint( const Point3d& ptS, const Point3d& ptE, double dLevel,
|
||||
const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid)
|
||||
{
|
||||
return Media( ptS, ptE, ( ptS.z - dLevel) / ( ptS.z - ptE.z)) ;
|
||||
// Distanza tra gli estremi iniziali
|
||||
double dDist = max( abs( ptS.x - ptE.x), abs( ptS.y - ptE.y)) ;
|
||||
|
||||
// Ricerca con metodo di bisezione (si arresta quando il medio è allineato agli estremi)
|
||||
const int MAX_ITER = 8 ;
|
||||
int nCount = 0 ;
|
||||
Point3d ptP1 = ptS ;
|
||||
Point3d ptP2 = ptE ;
|
||||
Point3d ptMid = Media( ptP1, ptP2) ;
|
||||
while ( nCount < MAX_ITER) {
|
||||
// verifica del punto medio
|
||||
ptMid.z = 0 ;
|
||||
Point3d ptTest = GetToGlob( ptMid + cavTstm.GetToolHeight() * Z_AX, frGrid) ;
|
||||
double dMove ;
|
||||
const_cast<ICAvToolSurfTm*>( &cavTstm)->TestPosition( ptTest, frGrid.VersZ(), frGrid.VersZ(), dMove) ;
|
||||
ptMid.z = dMove ;
|
||||
// se sta sulla linea che unisce gli estremi, basta interpolazione lineare
|
||||
if ( abs( ptMid.z - ( ptP1.z + ptP2.z) / 2) < 0.004 * dDist)
|
||||
return Media( ptP1, ptP2, ( ptP1.z - dLevel) / ( ptP1.z - ptP2.z)) ;
|
||||
// altrimenti nuova suddivisione della parte con estremi da parte opposta rispetto al livello
|
||||
bool b1On = ( ptP1.z > dLevel) ;
|
||||
bool bMidOn = ( ptMid.z > dLevel) ;
|
||||
if ( b1On != bMidOn)
|
||||
ptP2 = ptMid ;
|
||||
else
|
||||
ptP1 = ptMid ;
|
||||
ptMid = Media( ptP1, ptP2) ;
|
||||
++ nCount ;
|
||||
}
|
||||
ptMid.z = dLevel ;
|
||||
return ptMid ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
ProcessSquare( int nFlag, const Point3d ptP[4], double dLevel,
|
||||
const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid,
|
||||
Point3d& ptL1s, Point3d& ptL1e, Point3d& ptL2s, Point3d& ptL2e)
|
||||
{
|
||||
static int LineTable[16][5] = { { 0, -1, -1, -1, -1},
|
||||
@@ -73,20 +104,20 @@ ProcessSquare( int nFlag, const Point3d ptP[4], double dLevel,
|
||||
else if ( LineTable[nFlag][0] == 1) {
|
||||
int nI1s = LineTable[nFlag][1] ;
|
||||
int nI1e = LineTable[nFlag][2] ;
|
||||
ptL1s = CalcPoint( ptP[nI1s], ptP[( nI1s + 1) % 4], dLevel) ;
|
||||
ptL1e = CalcPoint( ptP[nI1e], ptP[( nI1e + 1) % 4], dLevel) ;
|
||||
ptL1s = CalcPoint( ptP[nI1s], ptP[( nI1s + 1) % 4], dLevel, cavTstm, frGrid) ;
|
||||
ptL1e = CalcPoint( ptP[nI1e], ptP[( nI1e + 1) % 4], dLevel, cavTstm, frGrid) ;
|
||||
return ( AreSamePointApprox( ptL1s, ptL1e) ? 0 : 1) ;
|
||||
}
|
||||
// due linee
|
||||
else if ( LineTable[nFlag][0] == 2) {
|
||||
int nI1s = LineTable[nFlag][1] ;
|
||||
int nI1e = LineTable[nFlag][2] ;
|
||||
ptL1s = CalcPoint( ptP[nI1s], ptP[( nI1s + 1) % 4], dLevel) ;
|
||||
ptL1e = CalcPoint( ptP[nI1e], ptP[( nI1e + 1) % 4], dLevel) ;
|
||||
ptL1s = CalcPoint( ptP[nI1s], ptP[( nI1s + 1) % 4], dLevel, cavTstm, frGrid) ;
|
||||
ptL1e = CalcPoint( ptP[nI1e], ptP[( nI1e + 1) % 4], dLevel, cavTstm, frGrid) ;
|
||||
int nI2s = LineTable[nFlag][3] ;
|
||||
int nI2e = LineTable[nFlag][4] ;
|
||||
ptL2s = CalcPoint( ptP[nI2s], ptP[( nI2s + 1) % 4], dLevel) ;
|
||||
ptL2e = CalcPoint( ptP[nI2e], ptP[( nI2e + 1) % 4], dLevel) ;
|
||||
ptL2s = CalcPoint( ptP[nI2s], ptP[( nI2s + 1) % 4], dLevel, cavTstm, frGrid) ;
|
||||
ptL2e = CalcPoint( ptP[nI2e], ptP[( nI2e + 1) % 4], dLevel, cavTstm, frGrid) ;
|
||||
return 2 ;
|
||||
}
|
||||
return -1 ;
|
||||
@@ -94,7 +125,8 @@ ProcessSquare( int nFlag, const Point3d ptP[4], double dLevel,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep, double dLevel, POLYLINEVECTOR& vPL)
|
||||
MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep, double dLevel,
|
||||
const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid, POLYLINEVECTOR& vPL)
|
||||
{
|
||||
// Predispongo il concatenamento
|
||||
BIPNTVECTOR vBiPnt ;
|
||||
@@ -121,7 +153,7 @@ MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep,
|
||||
{ i * dStep, ( j + 1) * dStep, vdGrid[nInd3]}} ;
|
||||
// calcolo segmenti da inserire
|
||||
Point3d ptL1s, ptL1e, ptL2s, ptL2e ;
|
||||
int nSegCnt = ProcessSquare( nFlag, ptP, dLevel, ptL1s, ptL1e, ptL2s, ptL2e) ;
|
||||
int nSegCnt = ProcessSquare( nFlag, ptP, dLevel, cavTstm, frGrid, ptL1s, ptL1e, ptL2s, ptL2e) ;
|
||||
if ( nSegCnt == -1)
|
||||
return false ;
|
||||
else if ( nSegCnt == 1) {
|
||||
@@ -159,13 +191,13 @@ MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep,
|
||||
vPL.emplace_back( PolyLine()) ;
|
||||
crvCompo.ApproxWithLines( 0, 0, ICurve::APL_SPECIAL, vPL.back()) ;
|
||||
#else
|
||||
// eseguo offset a sinistra pari a metà step
|
||||
// eseguo offset a sinistra pari allo step
|
||||
OffsetCurve offsCompo ;
|
||||
offsCompo.Make( &crvCompo, -0.5 * dStep, ICurve::OFF_CHAMFER) ;
|
||||
offsCompo.Make( &crvCompo, -( dStep - 10 * EPS_SMALL), ICurve::OFF_CHAMFER) ;
|
||||
PtrOwner<ICurve> pCrvOffset( offsCompo.GetLongerCurve()) ;
|
||||
if ( ! IsNull( pCrvOffset)) {
|
||||
vPL.emplace_back( PolyLine()) ;
|
||||
pCrvOffset->ApproxWithLines( 0.1 * dStep, ANG_TOL_APPROX_DEG, ICurve::APL_STD, vPL.back()) ;
|
||||
pCrvOffset->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, vPL.back()) ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -173,6 +205,7 @@ MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep,
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Silhouette rispetto ad una direzione e sopra una quota di una superficie TriMesh
|
||||
// ( dTol è il passo della griglia di campionamento e il raggio del cilindro di prova)
|
||||
@@ -194,32 +227,30 @@ CAvSilhouetteSurfTm( const ISurfTriMesh& Stm, const Plane3d& plPlane, double dTo
|
||||
vPL.clear() ;
|
||||
|
||||
// sistema di riferimento nel piano
|
||||
Frame3d frPlane ;
|
||||
if ( ! frPlane.Set( plPlane.GetPoint(), plPlane.GetVersN()))
|
||||
Frame3d frGrid ;
|
||||
if ( ! frGrid.Set( plPlane.GetPoint(), plPlane.GetVersN()))
|
||||
return false ;
|
||||
|
||||
// bounding box della superficie nel riferimento del piano
|
||||
BBox3d b3Surf ;
|
||||
if ( ! Stm.GetBBox( GetInvert( frPlane), b3Surf, BBF_STANDARD))
|
||||
if ( ! Stm.GetBBox( GetInvert( frGrid), b3Surf, BBF_STANDARD))
|
||||
return false ;
|
||||
// calcolo dati della griglia
|
||||
const double EXTRA_XY = 1.5 * dTol ;
|
||||
const double EXTRA_Z = 10 ;
|
||||
const double EXTRA_Z = 10 * dTol ;
|
||||
b3Surf.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
|
||||
Point3d ptOrig = GetToGlob( b3Surf.GetMin(), frPlane) ;
|
||||
Vector3d vtAxX = frPlane.VersX() ;
|
||||
Vector3d vtAxY = frPlane.VersY() ;
|
||||
Vector3d vtAxZ = frPlane.VersZ() ;
|
||||
int nStepX = int( ceil( b3Surf.GetDimX() / dTol)) ;
|
||||
int nStepY = int( ceil( b3Surf.GetDimY() / dTol)) ;
|
||||
frGrid.ChangeOrig( GetToGlob( b3Surf.GetMin(), frGrid)) ;
|
||||
double dDimZ = b3Surf.GetDimZ() ;
|
||||
double dLevelOffs = - b3Surf.GetMin().z ;
|
||||
|
||||
// calcolo dei punti della griglia (sul top del cilindro)
|
||||
PNTUVECTOR vPntM( ( nStepX + 1) * ( nStepY + 1)) ;
|
||||
for ( int j = 0 ; j <= nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= nStepX ; ++ i) {
|
||||
int nInd = i + j * ( nStepX + 1) ;
|
||||
Point3d ptP = ptOrig + i * dTol * vtAxX + j * dTol * vtAxY + dDimZ * vtAxZ ;
|
||||
Point3d ptP = GetToGlob( Point3d( i * dTol, j * dTol, dDimZ), frGrid) ;
|
||||
vPntM[nInd] = { ptP, 0.} ;
|
||||
}
|
||||
}
|
||||
@@ -228,46 +259,58 @@ CAvSilhouetteSurfTm( const ISurfTriMesh& Stm, const Plane3d& plPlane, double dTo
|
||||
CAvToolSurfTm cavTstm ;
|
||||
cavTstm.SetStdTool( dDimZ, dTol, 0) ;
|
||||
cavTstm.SetSurfTm( Stm) ;
|
||||
if ( ! cavTstm.TestSeries( vPntM, vtAxZ, vtAxZ, -1))
|
||||
if ( ! cavTstm.TestSeries( vPntM, frGrid.VersZ(), frGrid.VersZ(), -1))
|
||||
return false ;
|
||||
|
||||
// riporto i punti sul tip del cilindro
|
||||
for ( auto& PntU : vPntM)
|
||||
PntU.first -= dDimZ * vtAxZ ;
|
||||
|
||||
// griglia degli spostamenti
|
||||
DBLVECTOR vdGrid( ( nStepX + 1) * ( nStepY + 1)) ;
|
||||
for ( int j = 0 ; j <= nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= nStepX ; ++ i) {
|
||||
int nInd = i + j * ( nStepX + 1) ;
|
||||
vdGrid[nInd] = -vPntM[nInd].second ;
|
||||
vdGrid[nInd] = vPntM[nInd].second ;
|
||||
}
|
||||
}
|
||||
|
||||
// calcolo della silhouette con il metodo MarchingSquares
|
||||
double dLevel = -b3Surf.GetMin().z ;
|
||||
if ( ! MarchingSquares( vdGrid, nStepX, nStepY, dTol, dLevel, vPL))
|
||||
double dLevel = dLevelOffs ;
|
||||
if ( ! MarchingSquares( vdGrid, nStepX, nStepY, dTol, dLevel, cavTstm, frGrid, vPL))
|
||||
return false ;
|
||||
// riporto nella corretta posizione le curve trovate
|
||||
for ( auto& PL : vPL) {
|
||||
PL.Translate( b3Surf.GetMin() - ORIG) ;
|
||||
PL.ToGlob( frPlane) ;
|
||||
}
|
||||
for ( auto& PL : vPL)
|
||||
PL.ToGlob( frGrid) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICAvParSilhouettesSurfTm*
|
||||
CreateCAvParSilhouettesSurfTm( void)
|
||||
{
|
||||
return static_cast<ICAvParSilhouettesSurfTm*> ( new(nothrow) CAvParSilhouettesSurfTm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Silhouette rispetto ad una direzione e sopra diverse quote di una superficie TriMesh
|
||||
//----------------------------------------------------------------------------
|
||||
CAvParSilhouettesSurfTm::CAvParSilhouettesSurfTm( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol)
|
||||
CAvParSilhouettesSurfTm::CAvParSilhouettesSurfTm( void)
|
||||
: m_dTol( 100 * EPS_SMALL), m_nStepX( 0), m_nStepY( 0), m_dLevelOffs( 0), m_bGridOk( false)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CAvParSilhouettesSurfTm::SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol)
|
||||
{
|
||||
m_vpStm = vpStm ;
|
||||
m_frPlanes = frPlanes ;
|
||||
m_frGrid = frPlanes ;
|
||||
m_dTol = max( dTol, 100 * EPS_SMALL) ;
|
||||
m_nStepX = 0 ;
|
||||
m_nStepY = 0 ;
|
||||
m_dDimZ = 0 ;
|
||||
m_dLevelOffs = 0 ;
|
||||
m_bGridOk = false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -276,7 +319,7 @@ CAvParSilhouettesSurfTm::Prepare( void)
|
||||
{
|
||||
// ingombro delle superfici nel riferimento dei piani
|
||||
BBox3d b3All ;
|
||||
Frame3d frInv = GetInvert( m_frPlanes) ;
|
||||
Frame3d frInv = GetInvert( m_frGrid) ;
|
||||
for ( auto pStm : m_vpStm) {
|
||||
BBox3d b3Surf ;
|
||||
if ( ! pStm->GetBBox( frInv, b3Surf, BBF_STANDARD))
|
||||
@@ -286,49 +329,41 @@ CAvParSilhouettesSurfTm::Prepare( void)
|
||||
|
||||
// calcolo dati della griglia
|
||||
const double EXTRA_XY = 1.5 * m_dTol ;
|
||||
const double EXTRA_Z = 10 ;
|
||||
const double EXTRA_Z = 10 * m_dTol ;
|
||||
b3All.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
|
||||
Point3d ptOrig = GetToGlob( b3All.GetMin(), m_frPlanes) ;
|
||||
Vector3d vtAxX = m_frPlanes.VersX() ;
|
||||
Vector3d vtAxY = m_frPlanes.VersY() ;
|
||||
Vector3d vtAxZ = m_frPlanes.VersZ() ;
|
||||
m_nStepX = int( ceil( b3All.GetDimX() / m_dTol)) ;
|
||||
m_nStepY = int( ceil( b3All.GetDimY() / m_dTol)) ;
|
||||
m_vtMove = b3All.GetMin() - ORIG ;
|
||||
double dDimZ = b3All.GetDimZ() ;
|
||||
m_frGrid.ChangeOrig( GetToGlob( b3All.GetMin(), m_frGrid)) ;
|
||||
m_dDimZ = b3All.GetDimZ() ;
|
||||
m_dLevelOffs = - b3All.GetMin().z ;
|
||||
|
||||
// calcolo dei punti della griglia (sul top del cilindro)
|
||||
PNTUVECTOR vPntM( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
|
||||
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
|
||||
int nInd = i + j * ( m_nStepX + 1) ;
|
||||
Point3d ptP = ptOrig + i * m_dTol * vtAxX + j * m_dTol * vtAxY + dDimZ * vtAxZ ;
|
||||
Point3d ptP = GetToGlob( Point3d( i * m_dTol, j * m_dTol, m_dDimZ), m_frGrid) ;
|
||||
vPntM[nInd] = { ptP, 0.} ;
|
||||
}
|
||||
}
|
||||
|
||||
// esecuzione della verifica
|
||||
CAvToolSurfTm cavTstm ;
|
||||
if ( ! cavTstm.SetStdTool( dDimZ, m_dTol, 0))
|
||||
if ( ! m_cavTstm.SetStdTool( m_dDimZ, m_dTol, 0))
|
||||
return false ;
|
||||
if ( m_vpStm.empty() || ! cavTstm.SetSurfTm( *( m_vpStm[0])))
|
||||
if ( m_vpStm.empty() || ! m_cavTstm.SetSurfTm( *( m_vpStm[0])))
|
||||
return false ;
|
||||
for ( int k = 1 ; k < int( m_vpStm.size()) ; ++ k)
|
||||
cavTstm.AddSurfTm( *( m_vpStm[k])) ;
|
||||
if ( ! cavTstm.TestSeries( vPntM, vtAxZ, vtAxZ, -1))
|
||||
m_cavTstm.AddSurfTm( *( m_vpStm[k])) ;
|
||||
if ( ! m_cavTstm.TestSeries( vPntM, m_frGrid.VersZ(), m_frGrid.VersZ(), -1))
|
||||
return false ;
|
||||
|
||||
// riporto i punti sul tip del cilindro
|
||||
for ( auto& PntU : vPntM)
|
||||
PntU.first -= dDimZ * vtAxZ ;
|
||||
|
||||
// griglia degli spostamenti
|
||||
m_vdGrid.clear() ;
|
||||
m_vdGrid.resize( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
|
||||
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
|
||||
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
|
||||
int nInd = i + j * ( m_nStepX + 1) ;
|
||||
m_vdGrid[nInd] = -vPntM[nInd].second ;
|
||||
m_vdGrid[nInd] = vPntM[nInd].second ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,13 +383,11 @@ CAvParSilhouettesSurfTm::GetSilhouette( double dLevel, POLYLINEVECTOR& vPL)
|
||||
m_bGridOk = true ;
|
||||
|
||||
// calcolo della silhouette con il metodo MarchingSquares
|
||||
dLevel -= m_vtMove.z ;
|
||||
if ( ! MarchingSquares( m_vdGrid, m_nStepX, m_nStepY, m_dTol, dLevel, vPL))
|
||||
dLevel += m_dLevelOffs ;
|
||||
if ( ! MarchingSquares( m_vdGrid, m_nStepX, m_nStepY, m_dTol, dLevel, m_cavTstm, m_frGrid, vPL))
|
||||
return false ;
|
||||
// riporto nella corretta posizione le curve trovate
|
||||
for ( auto& PL : vPL) {
|
||||
PL.Translate( m_vtMove) ;
|
||||
PL.ToGlob( m_frPlanes) ;
|
||||
}
|
||||
for ( auto& PL : vPL)
|
||||
PL.ToGlob( m_frGrid) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+15
-7
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2024-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CAvSilhouetteSurfTm.h Data : 10.06.24 Versione : 2.6f2
|
||||
// File : CAvSilhouetteSurfTm.h Data : 16.06.24 Versione : 2.6f2
|
||||
// Contenuto : Dichiarazione della classe calcolo multi-silhouette.
|
||||
//
|
||||
//
|
||||
@@ -20,16 +20,24 @@
|
||||
class CAvParSilhouettesSurfTm : public ICAvParSilhouettesSurfTm
|
||||
{
|
||||
public :
|
||||
bool SetSurfTm( const ISurfTriMesh& Stm) override ;
|
||||
bool AddSurfTm( const ISurfTriMesh& Stm) override ;
|
||||
bool Calculate( const Frame3d& frPlanes, double dTol) override ;
|
||||
bool SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol) override ;
|
||||
bool GetSilhouette( double dLevel, POLYLINEVECTOR& vPL) override ;
|
||||
|
||||
public :
|
||||
CAvParSilhouettesSurfTm( void) ;
|
||||
|
||||
private :
|
||||
bool m_bOk ;
|
||||
const Frame3d m_frPlanes ;
|
||||
CAvToolSurfTm m_cavTstm ;
|
||||
bool Prepare( void) ;
|
||||
|
||||
private :
|
||||
CISURFTMPVECTOR m_vpStm ;
|
||||
CAvToolSurfTm m_cavTstm ;
|
||||
Frame3d m_frGrid ;
|
||||
double m_dTol ;
|
||||
int m_nStepX ;
|
||||
int m_nStepY ;
|
||||
double m_dDimZ ;
|
||||
double m_dLevelOffs ;
|
||||
bool m_bGridOk ;
|
||||
DBLVECTOR m_vdGrid ;
|
||||
} ;
|
||||
+47
-18
@@ -37,10 +37,29 @@ CreateCAvToolSurfTm( void)
|
||||
// CAvToolSurfTm
|
||||
//----------------------------------------------------------------------------
|
||||
CAvToolSurfTm::CAvToolSurfTm( void)
|
||||
: m_Tool( false)
|
||||
: m_frMove( false), m_Tool( false)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CAvToolSurfTm::Clear( void)
|
||||
{
|
||||
// pulisco la lista dei puntatori a Stm
|
||||
m_vSTM.clear() ;
|
||||
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
|
||||
m_vBaseInd.clear() ;
|
||||
m_vBaseInd.emplace_back( 0) ;
|
||||
// pulisco HashGrid 2d
|
||||
m_HGrids.Clear() ;
|
||||
// reset utensile
|
||||
m_Tool.Clear() ;
|
||||
// reset riferimento
|
||||
m_frMove.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
|
||||
@@ -50,6 +69,9 @@ CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
|
||||
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
|
||||
m_vBaseInd.clear() ;
|
||||
m_vBaseInd.emplace_back( 0) ;
|
||||
// pulisco HashGrid 2d
|
||||
m_HGrids.Clear() ;
|
||||
// non tocco l'utensile
|
||||
// aggiungo la superficie
|
||||
return AddSurfTm( Stm) ;
|
||||
}
|
||||
@@ -107,14 +129,25 @@ CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Ve
|
||||
// Se direzioni non definite, errore
|
||||
if ( vtDir.IsSmall() || vtMove.IsSmall())
|
||||
return false ;
|
||||
// Imposto il riferimento di movimento
|
||||
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
||||
m_frMove.Set( ORIG, vtMove, vtDir) ;
|
||||
else
|
||||
m_frMove.Set( ORIG, vtMove) ;
|
||||
// Eseguo controllo
|
||||
// Se riferimento di movimento già presente
|
||||
if ( m_frMove.IsValid()) {
|
||||
// Calcolo nuovo riferimento di movimento
|
||||
Frame3d frMove ;
|
||||
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
||||
frMove.Set( ORIG, vtMove, vtDir) ;
|
||||
else
|
||||
frMove.Set( ORIG, vtMove) ;
|
||||
// Se riferimenti di movimento uguali, sfrutto HashGrid 2d
|
||||
if ( AreSameFrame( frMove, m_frMove)) {
|
||||
// Eseguo controllo
|
||||
Point3d ptCurr = ptT ;
|
||||
dTotDist = MyTestPositionHG( ptCurr, vtDir) ;
|
||||
return ( dTotDist > - EPS_SMALL) ;
|
||||
}
|
||||
}
|
||||
// Altrimenti eseguo controllo diretto
|
||||
Point3d ptCurr = ptT ;
|
||||
dTotDist = MyTestPosition( ptCurr, vtDir) ;
|
||||
dTotDist = MyTestPosition( ptCurr, vtDir, vtMove) ;
|
||||
return ( dTotDist > - EPS_SMALL) ;
|
||||
}
|
||||
|
||||
@@ -186,8 +219,6 @@ CAvToolSurfTm::TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vecto
|
||||
}
|
||||
ProcessEvents( int( 100 * dProgCoeff), 0) ;
|
||||
}
|
||||
// pulisco HashGrid 2d
|
||||
m_HGrids.Clear() ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -202,7 +233,7 @@ CAvToolSurfTm::TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir,
|
||||
for ( int i = nFirst ; i <= nLast ; ++ i) {
|
||||
// verifico il punto
|
||||
double dMove = MyTestPositionHG( vPntM[i].first, vtDir) ;
|
||||
vPntM[i].second = - dMove ;
|
||||
vPntM[i].second = dMove ;
|
||||
if ( dMove < - EPS_SMALL)
|
||||
return false ;
|
||||
++ m_nCurrPnt ;
|
||||
@@ -305,8 +336,6 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
||||
}
|
||||
ProcessEvents( int( 100 * dProgCoeff), 0) ;
|
||||
}
|
||||
// pulisco HashGrid 2d
|
||||
m_HGrids.Clear() ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -325,7 +354,7 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
|
||||
// verifico il punto
|
||||
ptCurr = itPntMCurr->first ;
|
||||
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir) ;
|
||||
itPntMCurr->second = - dMove ;
|
||||
itPntMCurr->second = dMove ;
|
||||
if ( dMove < - EPS_SMALL)
|
||||
return false ;
|
||||
// se esiste il punto precedente e richiesto devo verificare il medio
|
||||
@@ -377,7 +406,7 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
|
||||
if ( abs(( Media( itPntMPrev->first, itPntMCurr->first, 0.5) - ptNewMid) * m_frMove.VersZ()) > 0.5 * dLinTol ||
|
||||
SqDist( itPntMPrev->first, itPntMCurr->first) > dMaxSqDist) {
|
||||
// aggiungo
|
||||
lPntM.emplace( itPntMCurr, ptNewMid, - dMidMove) ;
|
||||
lPntM.emplace( itPntMCurr, ptNewMid, dMidMove) ;
|
||||
auto itPntMMid = itPntMCurr ;
|
||||
-- itPntMMid ;
|
||||
// verifico intervallo precedente
|
||||
@@ -390,7 +419,7 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir)
|
||||
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove)
|
||||
{
|
||||
double dTotDist = 0 ;
|
||||
for ( auto pStm : m_vSTM) {
|
||||
@@ -398,12 +427,12 @@ CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir)
|
||||
for ( int nTria = pStm->GetFirstTriangle( Tria) ;
|
||||
nTria != SVT_NULL ;
|
||||
nTria = pStm->GetNextTriangle( nTria, Tria)) {
|
||||
double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, m_frMove.VersZ()) ;
|
||||
double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, vtMove) ;
|
||||
if ( dDist < - EPS_SMALL)
|
||||
return -1 ;
|
||||
if ( dDist > EPS_SMALL) {
|
||||
dTotDist += dDist ;
|
||||
ptT += dDist * m_frMove.VersZ() ;
|
||||
ptT += dDist * vtMove ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -42,11 +42,12 @@ class CAvToolSurfTm : public ICAvToolSurfTm
|
||||
|
||||
public :
|
||||
CAvToolSurfTm( void) ;
|
||||
bool Clear( void) ;
|
||||
|
||||
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) ;
|
||||
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove) ;
|
||||
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) ;
|
||||
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) ;
|
||||
|
||||
+3
-3
@@ -1669,10 +1669,10 @@ SetSpecialPtStartForOpenEdges( const ICurveComposite* pCrvOrig, const Frame3d& f
|
||||
// se il punto trovato è a cavallo tra due curve...
|
||||
if ( abs( dU_check - floor( dU_check)) < EPS_PARAM ||
|
||||
abs( dU_check - ceil( dU_check)) < EPS_PARAM) {
|
||||
const ICurve* pCrvA = pCrvCompo->GetCurve( floor( dU_check)) ;
|
||||
const ICurve* pCrvA = pCrvCompo->GetCurve( int( floor( dU_check))) ;
|
||||
if ( pCrvA == nullptr)
|
||||
return false ;
|
||||
const ICurve* pCrvB = pCrvCompo->GetCurve( ceil( dU_check)) ;
|
||||
const ICurve* pCrvB = pCrvCompo->GetCurve( int( ceil( dU_check))) ;
|
||||
if ( pCrvB == nullptr)
|
||||
return false ;
|
||||
if ( pCrvA->GetTempProp( 0) == 0 || pCrvB->GetTempProp( 0) == 1)
|
||||
@@ -1680,7 +1680,7 @@ SetSpecialPtStartForOpenEdges( const ICurveComposite* pCrvOrig, const Frame3d& f
|
||||
}
|
||||
// se invece tocca una sola curva, controllo che sia aperta
|
||||
else {
|
||||
const ICurve* pCrvA = pCrvCompo->GetCurve( floor( dU_check)) ;
|
||||
const ICurve* pCrvA = pCrvCompo->GetCurve( int( floor( dU_check))) ;
|
||||
if ( pCrvA == nullptr)
|
||||
return false ;
|
||||
if ( pCrvA->GetTempProp( 0) == 0)
|
||||
|
||||
@@ -341,6 +341,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
|
||||
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h" />
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
||||
<ClInclude Include="CAvSilhouetteSurfTm.h" />
|
||||
<ClInclude Include="CDeBoxTria.h" />
|
||||
<ClInclude Include="CDeCapsTria.h" />
|
||||
<ClInclude Include="CDeConeFrustumTria.h" />
|
||||
|
||||
@@ -1217,6 +1217,9 @@
|
||||
<ClInclude Include="..\Include\EGkDistPointLine.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CAvSilhouetteSurfTm.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
Reference in New Issue
Block a user