Merge branch 'master' into MoreBezier

This commit is contained in:
Daniele Bariletti
2024-07-12 12:07:26 +02:00
5 changed files with 107 additions and 85 deletions
+24 -12
View File
@@ -171,14 +171,20 @@ CAvToolSurfTm::TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vecto
// Se vettore vuoto, non devo fare alcunché
if ( vPntM.empty())
return true ;
// Imposto il riferimento di movimento
// Calcolo nuovo riferimento di movimento
Frame3d frMove ;
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
m_frMove.Set( ORIG, vtMove, vtDir) ;
frMove.Set( ORIG, vtMove, vtDir) ;
else
m_frMove.Set( ORIG, vtMove) ;
// Predispongo Hash Grid
if ( ! PrepareHashGrid())
return false ;
frMove.Set( ORIG, vtMove) ;
// Se riferimento di movimento non presente o diverso dal calcolato
if ( ! m_frMove.IsValid() || ! AreSameFrame( frMove, m_frMove)) {
// Ricalcolo HashGrid
if ( ! PrepareHashGrid())
return false ;
// Salvo nuovo riferimento
m_frMove = frMove ;
}
// Determino il numero di punti dell'insieme
m_nTotPnt = int( vPntM.size()) ;
// Recupero il numero massimo di thread concorrenti
@@ -281,14 +287,20 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
dLinTol = max( dLinTol, EPS_SMALL) ;
else
dLinTol = -1 ;
// Imposto il riferimento di movimento
// Calcolo nuovo riferimento di movimento
Frame3d frMove ;
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
m_frMove.Set( ORIG, vtMove, vtDir) ;
frMove.Set( ORIG, vtMove, vtDir) ;
else
m_frMove.Set( ORIG, vtMove) ;
// Predispongo Hash Grid
if ( ! PrepareHashGrid())
return false ;
frMove.Set( ORIG, vtMove) ;
// Se riferimento di movimento non presente o diverso dal calcolato
if ( ! m_frMove.IsValid() || ! AreSameFrame( frMove, m_frMove)) {
// Ricalcolo HashGrid
if ( ! PrepareHashGrid())
return false ;
// Salvo nuovo riferimento
m_frMove = frMove ;
}
// Determino il numero di punti del path
m_nTotPnt = int( lPntM.size()) ;
// Recupero il numero massimo di thread concorrenti
+50 -40
View File
@@ -125,7 +125,24 @@ AssignMinFeed( ICurveComposite* pCrv, const PocketParams& PockParams)
//---------------------------------------------------------------------------
static bool
GetFeedForParam( double& dPar, const PocketParams& PockParams, double& dFeed)
AssignCustomFeed( ICurveComposite* pCrv, const PocketParams& PockParams, double dFeed)
{
// controllo dei parametri
if ( pCrv == nullptr || ! pCrv->IsValid() || pCrv->GetCurveCount() == 0)
return false ;
// La Feed deve essere compresa tra la minima e la massima
dFeed = Clamp( dFeed, GetMinFeed( PockParams), GetMaxFeed( PockParams)) ;
// assegno la Feed ad ogni sottocurva di pCrv
for ( int u = 0 ; u < pCrv->GetCurveCount() ; ++ u)
pCrv->SetCurveTempParam( u, dFeed, 0) ;
return true ;
}
//---------------------------------------------------------------------------
static bool
GetFeedForParam( double dPar, const PocketParams& PockParams, double& dFeed)
{
/*
Feed
@@ -1692,12 +1709,11 @@ GetPocketCurvesByCloseEdges( const ISurfFlatRegion* pSfrChunk, const PocketParam
bAllRemoved = false ;
// controllo se la superficie si annulla con un controOffset del raggio utensile
PtrOwner<ISurfFlatRegion> pSfrCheck( CloneSurfFlatRegion( pSfrChunk)) ;
if ( IsNull( pSfrCheck) || ! pSfrCheck->IsValid())
return false ;
pSfrCheck->Offset( - PockParams.dRad + 200 * EPS_SMALL, ICurve::OFF_FILLET) ;
if ( pSfrCheck->IsValid() && pSfrCheck->GetChunkCount() > 0)
return true ; // se la superficie non si annulla, allora non ricavo nessuna curva
double dMaxOffs ;
pSfrChunk->GetMaxOffset( dMaxOffs) ;
if ( dMaxOffs > PockParams.dRad + 200 * EPS_SMALL)
return true ;
/*
NB. Si poteva calcolare la Fat curve del raggio utensile dell'Offset di tutti i chiusi e vedere
se l'unione di queste regioni copriva interamente il Chunk attuale... così facendo rischio di
@@ -1909,17 +1925,18 @@ GetPocketCurvesByCloseEdges( const ISurfFlatRegion* pSfrChunk, const PocketParam
// imposto le Feed per tali curve e aggiungo eventuale entrata da fuori
for ( int i = 0 ; i < int( vCrvCompoRes_tmp.size()) ; ++ i) {
// per ora è default ( sono passate singole)...
/*
Idea : Feed proporzionale al minimo Offset per annullare la regione ?
-> Massimo parametro sui bisettori di VORONOI (?)
-> Massimo parametro sui bisettori di VORONOI
*/
AssignMinFeed( vCrvCompoRes_tmp[i], PockParams) ;
double dFeed ;
GetFeedForParam( 2 * dMaxOffs, PockParams, dFeed) ;
AssignCustomFeed( vCrvCompoRes_tmp[i], PockParams, dFeed) ;
// ricavo punto di inizio e vettore tangente
Point3d ptStart ; vCrvCompoRes_tmp[i]->GetStartPoint( ptStart) ;
Vector3d vtStart ; vCrvCompoRes_tmp[i]->GetStartDir( vtStart) ;
// recupero il punto di caduta dell'utensile
Point3d ptFall = ptStart - vtStart * ( PockParams.dRad + PockParams.dOpenMinSafe) ;
Point3d ptFall = ptStart - vtStart * ( 2 * PockParams.dRad + PockParams.dOpenMinSafe) ;
// controllo che il tool non sia interno alla regione limite
if ( pSfrLimit->IsValid()) {
PtrOwner<ICurveArc> pCrvToolShape( CreateCurveArc()) ;
@@ -1933,8 +1950,8 @@ GetPocketCurvesByCloseEdges( const ISurfFlatRegion* pSfrChunk, const PocketParam
vCrvCompoRes_tmp[i]->SetCurveTempParam( 0, GetMinFeed( PockParams) , 0) ; // Feed minima
}
else { // se trovo intersezione, provo a ruotare di 90°
vtStart.Rotate( Z_AX, ANG_RIGHT) ; // verso sinistra
ptFall = ptStart + vtStart * ( PockParams.dRad + PockParams.dOpenMinSafe) ;
vtStart.Rotate( Z_AX, PockParams.bInvert ? - ANG_RIGHT : ANG_RIGHT) ;
ptFall = ptStart + vtStart * ( 2 * PockParams.dRad + PockParams.dOpenMinSafe) ;
if ( ! pCrvToolShape->Set( ptFall, Z_AX, PockParams.dRad - 100 * EPS_SMALL))
return false ;
ccClass.clear() ;
@@ -4362,7 +4379,7 @@ CalcBoundedSmoothedLink( const Point3d& ptStart, const Vector3d& vtStart, const
PtrOwner<CurveArc> pCrvCir( CreateBasicCurveArc()) ;
if ( IsNull( pCrvCir))
return false ;
pCrvCir->SetCPAN( Media( ptStart, ptEnd), ptStart, - 360, 0, Z_AX) ;
pCrvCir->SetCPAN( Media( ptStart, ptEnd), ptStart, PockParams.bInvert ? 360 : - 360, 0, Z_AX) ;
pBiArcLink.Set( pCrvCir->Clone()) ;
pCrvLink->AddCurve( pBiArcLink->Clone()) ;
return true ;
@@ -5901,7 +5918,7 @@ CheckIfOffsetIsNecessary( const ICurveComposite* pCrvOffs, const double dOffs, c
{
// controllo dei parametri
if ( pCrvOffs == nullptr || ! pCrvOffs->IsValid() || pCrvOffs->GetCurveCount() == 0 || dOffs < EPS_SMALL)
if ( pCrvOffs == nullptr || ! pCrvOffs->IsValid() || pCrvOffs->GetCurveCount() == 0)
return false ;
bInsert = true ; // di base inserisco
@@ -6434,7 +6451,7 @@ CalcZigZag( const ISurfFlatRegion* pSrfZigZag, const PocketParams& PockParams, I
dYStep = PockParams.dSideStep ;
}
int nRef = (( nYStep + ( 1)) % 2) ;
int nRef = (( nYStep + ( PockParams.bInvert ? 0 : 1)) % 2) ;
// tratto valido
struct Section {
@@ -6860,7 +6877,6 @@ AddSpiralOut( const ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig,
static bool
AddZigZag( const ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, const PocketParams& PockParams, ICRVCOMPOPOVECTOR& vCrvCompoRes)
{
// Offset della regione per curva ZigZag
double dOffs = PockParams.dRad + PockParams.dRadialOffset ;
@@ -7003,13 +7019,11 @@ OptimizeChunkOneWay( ISurfFlatRegion* pSrfOrig, ISURFFRPOVECTOR& vSrfIdeal)
return ( int( vSrfIdeal.size() != 0)) ;
}
//----------------------------------------------------------------------------
static bool
AddOneWay( const ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, const PocketParams& PockParams, ICRVCOMPOPOVECTOR& vCrvCompoRes)
{
double dOffs = PockParams.dRad ;
double dOffs = PockParams.dRad + PockParams.dRadialOffset ;
double dExtra = 0. ;
// copio la regione da svuotare
@@ -7076,6 +7090,10 @@ AddOneWay( const ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, con
if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN))
return false ;
// se richiesta inversione
if ( PockParams.bInvert)
pLine->Invert() ;
// linea come composita per Feed ( la dovrò spezzare)
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
if ( IsNull( pCrvCompo))
@@ -7127,11 +7145,11 @@ AddOneWay( const ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, con
//----------------------------------------------------------------------------
bool
CalcPocketing( const ISurfFlatRegion* pSfr, double dRad, double dRadOffs, double dStep, double dAngle,
int nType, bool bSmooth, ISurfFlatRegion* pSfrLimit, ICRVCOMPOPOVECTOR& vCrvCompoRes)
int nType, bool bSmooth, bool bInvert, ISurfFlatRegion* pSfrLimit, ICRVCOMPOPOVECTOR& vCrvCompoRes)
{
// controllo dei parametri
if ( pSfr == nullptr || ! pSfr->IsValid() ||
dStep < EPS_SMALL ||
dStep < 10 * EPS_SMALL ||
( nType != POCKET_ZIGZAG && nType != POCKET_ONEWAY && nType != POCKET_SPIRALIN && nType != POCKET_SPIRALOUT))
return false ;
@@ -7146,6 +7164,7 @@ CalcPocketing( const ISurfFlatRegion* pSfr, double dRad, double dRadOffs, double
myParams.bSmooth = bSmooth ;
myParams.dAngle = dAngle ;
myParams.dSideStep = dStep ;
myParams.bInvert = bInvert ;
if ( pSfrLimit != nullptr && pSfrLimit->IsValid())
myParams.SfrLimit.CopyFrom( pSfrLimit) ;
@@ -7179,25 +7198,16 @@ CalcPocketing( const ISurfFlatRegion* pSfr, double dRad, double dRadOffs, double
// ------------ calcolo delle curve elementari della superficie -------------------
switch ( nType) {
case POCKET_ZIGZAG :
if ( ! AddZigZag( pSfrAdj, pSfr, myParams, vCrvCompoRes))
return false ;
break ;
case POCKET_ONEWAY :
if ( ! AddOneWay( pSfrAdj, pSfr, myParams, vCrvCompoRes))
return false ;
break ;
case POCKET_SPIRALIN :
if ( ! AddSpiralIn( pSfrAdj, pSfr, myParams, vCrvCompoRes))
return false ;
break ;
case POCKET_SPIRALOUT :
if ( ! AddSpiralOut( pSfrAdj, pSfr, myParams, vCrvCompoRes))
return true ;
break ;
case POCKET_ZIGZAG :
return AddZigZag( pSfrAdj, pSfr, myParams, vCrvCompoRes) ;
case POCKET_ONEWAY :
return AddOneWay( pSfrAdj, pSfr, myParams, vCrvCompoRes) ;
case POCKET_SPIRALIN :
return AddSpiralIn( pSfrAdj, pSfr, myParams, vCrvCompoRes) ;
case POCKET_SPIRALOUT :
return AddSpiralOut( pSfrAdj, pSfr, myParams, vCrvCompoRes) ;
}
return true ;
return false ;
}
//----------------------------------------------------------------------------
+11 -11
View File
@@ -116,7 +116,7 @@ HashGrid1d::~HashGrid1d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_CellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
@@ -396,8 +396,10 @@ HashGrid1d::Enlarge( void)
for ( auto pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
pCell->m_neighborOffset = nullptr ;
}
delete[] m_cell ;
m_cell = nullptr ;
// ... the number of cells is doubled in each coordinate direction, ...
m_CellCount *= 2 ;
@@ -641,17 +643,15 @@ HashGrids1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
void
HashGrids1d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_ObjsList.clear() ;
m_ObjsMap.clear() ;
m_objsToAdd.clear() ;
m_nonGridObjs.clear() ;
for ( auto pGrid : m_GridList)
delete pGrid ;
m_GridList.clear() ;
m_bActivate = true ;
m_bGridActive = false ;
m_b3Objs.Reset() ;
}
+11 -11
View File
@@ -125,7 +125,7 @@ HashGrid2d::~HashGrid2d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_xyCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
@@ -445,8 +445,10 @@ HashGrid2d::Enlarge( void)
for ( auto pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
pCell->m_neighborOffset = nullptr ;
}
delete[] m_cell ;
m_cell = nullptr ;
// ... the number of cells is doubled in each coordinate direction, ...
m_xCellCount *= 2 ;
@@ -695,17 +697,15 @@ HashGrids2d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
void
HashGrids2d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_ObjsList.clear() ;
m_ObjsMap.clear() ;
m_objsToAdd.clear() ;
m_nonGridObjs.clear() ;
for ( auto pGrid : m_GridList)
delete pGrid ;
m_GridList.clear() ;
m_bActivate = true ;
m_bGridActive = false ;
m_b3Objs.Reset() ;
}
+11 -11
View File
@@ -132,7 +132,7 @@ HashGrid3d::~HashGrid3d( void)
{
Clear() ;
for ( Cell* pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_xyzCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
}
@@ -486,8 +486,10 @@ HashGrid3d::Enlarge( void)
for ( auto pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
delete[] pCell->m_neighborOffset ;
pCell->m_neighborOffset = nullptr ;
}
delete[] m_cell ;
m_cell = nullptr ;
// ... the number of cells is doubled in each coordinate direction, ...
m_xCellCount *= 2 ;
@@ -739,17 +741,15 @@ HashGrids3d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
void
HashGrids3d::Clear( void)
{
for ( auto pGrid : m_GridList) {
delete pGrid ;
}
m_GridList.clear() ;
m_bGridActive = false ;
m_nonGridObjs.clear() ;
m_ObjsList.clear() ;
m_ObjsMap.clear() ;
m_objsToAdd.clear() ;
m_nonGridObjs.clear() ;
for ( auto pGrid : m_GridList)
delete pGrid ;
m_GridList.clear() ;
m_bActivate = true ;
m_bGridActive = false ;
m_b3Objs.Reset() ;
}