EgtGeomKernel :

- miglioria per il VM 5 assi: riduco i tagli inutili.
This commit is contained in:
Daniele Bariletti
2025-09-08 12:25:54 +02:00
parent e8d31f2020
commit c71c8e8c12
+72 -20
View File
@@ -24,6 +24,7 @@
#include "/EgtDev/Include/EgtPerfCounter.h"
#include "/EgtDev/Include/EGkSurfBezier.h"
#include "/EgtDev/Include/ENkPolynomialRoots.h"
#include "/EgtDev/Include/EGkIntersLineBox.h"
#include "/EgtDev/Include/EGkGeoObjSave.h" // debug
#include "SurfBezier.h"
#include <future>
@@ -1387,8 +1388,15 @@ struct SurfBezForInters {
Vector3d a3, a2, a1, a0, b3, b2, b1, b0 ;
};
static int nIntersCalc = 0 ;
typedef std::pair<double, double> DBLDBL ;
static bool
IntersLineBezierSurfSet( const Point3d& ptLineStart, const Vector3d& vtLineDir, const vector<SurfBezForInters>& vSurfBez, PNTVEC3DVECTOR& vInters, INTVECTOR& vSurfInters) {
IntersLineBezierSurfSet( const Point3d& ptLineStart, const Vector3d& vtLineDir, double dMin, double dMax,
const vector<SurfBezForInters>& vSurfBez, PNTVEC3DVECTOR& vInters, INTVECTOR& vSurfInters,
int nGrid, const Vector3d& vtN, vector<DBLDBL>& vInterv)
{
Point3d r = ptLineStart ;
Vector3d q = vtLineDir ;
@@ -1410,8 +1418,34 @@ IntersLineBezierSurfSet( const Point3d& ptLineStart, const Vector3d& vtLineDir,
BBox3d bbox = srf.bbSurf ;
if( bNeedToRot)
bbox.ToLoc( frRot) ;
INTDBLVECTOR vIntBoxBox ;
bool bCalcInters = false ;
if( dMax > EPS_ZERO) {
/*IntersLineBox( r + q * dMin, r + q * dMax, bbox, vIntBoxBox, true) ;
bCalcInters = int( vIntBoxBox.size()) != 0 ;*/
Point3d ptMin = bbox.GetMin(), ptMax = bbox.GetMax() ;
for ( int k = 0 ; k < int(vInterv.size()) && ! bCalcInters; ++k) {
bCalcInters = (vInterv[k].first > ptMin.z && vInterv[k].first < ptMax.z) || (vInterv[k].second > ptMin.z && vInterv[k].second < ptMax.z) ;
}
bCalcInters = bCalcInters && bbox.SqDistFromPointXY( r) < EPS_ZERO ;
}
else
bCalcInters = bbox.SqDistFromPointXY( r) < EPS_ZERO ;
if( dMax > EPS_ZERO) {
bool bBetter = int( vIntBoxBox.size()) == 0 && bbox.SqDistFromPointXY( r) < EPS_ZERO ;
if( bBetter)
int a = 0 ;
}
// verifico che lo spillone faccia interferenza con il box della superficie
if ( bbox.SqDistFromPointXY( r) < EPS_ZERO) {
if ( bCalcInters && dMax > - EPS_ZERO) {
++nIntersCalc ;
string sOut = " actual inters calc " + ToString(nIntersCalc) + " Griglia" + ToString(nGrid); // debug
if( nGrid != 1)
sOut += " toolZ: " + ToString( vtN.z, 3) ;
LOG_INFO( GetEGkLogger(), sOut.c_str())
// se la linea è parallela all'asse X o Y allora ruoto tutto di 45 gradi rispetto a Z
Vector3d a3, a2, a1, a0, b3, b2, b1, b0 ;
if ( ! bNeedToRot) {
@@ -2205,7 +2239,21 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
//debug
INTVECTOR vSurfInters ;
//debug
IntersLineBezierSurfSet( r, q, vSurfBez, vInters, vSurfInters) ;
int nPos = j * m_nNx[nGrid] + i ;
vector<Data>& vDexel = m_Values[nGrid][nPos] ;
vector<DBLDBL> vInterv, vEmpty ;
for ( int k = 0 ; k < int(vDexel.size()) ; ++k ) {
vInterv.emplace_back( vDexel[k].dMin, vDexel[k].dMax) ;
}
double dMin = 0 , dMax = 0 ;
if ( vDexel.size() != 0) {
dMin = vDexel.front().dMin ;
dMax = vDexel.back().dMax ;
}
else
dMax = - 1 ;
IntersLineBezierSurfSet( r, q, dMin, dMax, vSurfBez, vInters, vSurfInters, nGrid, vtLs[0], vInterv) ;
if ( vInters.size() > 2) {
SortGroupInters( vInters, vStartEnds, Z_AX) ;
if ( bForward && vStartEnds.size() > 1) {
@@ -2227,7 +2275,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
INTVECTOR vSurfX ;
INTINTVECTOR vStartEndsX ;
bool bXInclude = false ;
IntersLineBezierSurfSet( ptLineStart, vtLineStart, vSurfBez, vIntersX, vSurfX) ;
IntersLineBezierSurfSet( ptLineStart, vtLineStart, 0, 0, vSurfBez, vIntersX, vSurfX, -1, V_NULL, vEmpty) ;
if( vIntersX.size() > 1) {
SortGroupInters( vIntersX, vStartEndsX, X_AX) ;
if( vStartEndsX.size() != 0)
@@ -2240,7 +2288,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
INTVECTOR vSurfY ;
INTINTVECTOR vStartEndsY ;
bool bYInclude = false ;
IntersLineBezierSurfSet( ptLineStart, vtLineStart, vSurfBez, vIntersY, vSurfY) ;
IntersLineBezierSurfSet( ptLineStart, vtLineStart, 0, 0, vSurfBez, vIntersY, vSurfY, -1, V_NULL, vEmpty) ;
if ( vIntersY.size() > 1) {
SortGroupInters( vIntersY, vStartEndsY, Y_AX) ;
if( vStartEndsY.size() != 0)
@@ -2478,6 +2526,7 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
double dAlongAngDeg, dAcrossAngDeg ;
GetAlongAcrossRotation( vtDs, vtDe, ptPe - ptPs, dAlongAngDeg, dAcrossAngDeg) ;
// Divido il movimento in tratti con direzione utensile costante
//
#ifdef OLD_LINEAR
const double ANG_ACROSS_STEP = 0.04 ;
#else
@@ -2625,21 +2674,23 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
InitializePointsAndVectors( ptSti, ptEni, vtDSi, vtDEi, ptLs[i], ptLe[i], vtLs[i], vtLe[i]) ;
}
/////// decommentare solo per debug // versione a singolo thread
//for( int j = 0 ; j < N_MAPS; ++j) {
// PNTVECTOR ptLs_j( nStepCnt) ;
// PNTVECTOR ptLe_j( nStepCnt) ;
// VCT3DVECTOR vtLs_j( nStepCnt) ;
// VCT3DVECTOR vtLe_j( nStepCnt) ;
// for ( int z = 0 ; z < nStepCnt ; ++z) {
// ptLs_j[z] = ptLs[z][j] ;
// ptLe_j[z] = ptLe[z][j] ;
// vtLs_j[z] = vtLs[z][j] ;
// vtLe_j[z] = vtLe[z][j] ;
// }
// SelectGeneralMotion( j, ptLs_j, ptLe_j, vtLs_j,vtLe_j, n5AxisType) ;
//}
/////// decommentare solo per debug
#ifdef _DEBUG
///// decommentare solo per debug // versione a singolo thread
for( int j = 0 ; j < N_MAPS; ++j) {
PNTVECTOR ptLs_j( nStepCnt) ;
PNTVECTOR ptLe_j( nStepCnt) ;
VCT3DVECTOR vtLs_j( nStepCnt) ;
VCT3DVECTOR vtLe_j( nStepCnt) ;
for ( int z = 0 ; z < nStepCnt ; ++z) {
ptLs_j[z] = ptLs[z][j] ;
ptLe_j[z] = ptLe[z][j] ;
vtLs_j[z] = vtLs[z][j] ;
vtLe_j[z] = vtLe[z][j] ;
}
SelectGeneralMotion( j, ptLs_j, ptLe_j, vtLs_j,vtLe_j, n5AxisType) ;
}
///// decommentare solo per debug
#else
// Ciclo sulle mappe
vector< future<bool>> vRes ;
@@ -2674,6 +2725,7 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
}
}
}
#endif
return bOk ;
}