EgtGeomKernel :

- correzioni e ottimizzazioni al VM 5 assi 3x1.
This commit is contained in:
Daniele Bariletti
2025-09-12 09:02:39 +02:00
parent 116b605cb1
commit d7380a09c1
+84 -19
View File
@@ -1385,7 +1385,12 @@ SortGroupInters( PNTVEC3DVECTOR& vInters, INTINTVECTOR& vStartEnds, const Vector
struct SurfBezForInters {
SurfBezier sBez ;
BBox3d bbSurf ;
BBox3d bbSurfZ ;
BBox3d bbSurfX ;
BBox3d bbSurfY ;
Frame3d frZMainDim ;
Frame3d frXMainDim ;
Frame3d frYMainDim ;
Vector3d a3, a2, a1, a0, b3, b2, b1, b0 ;
};
@@ -1409,7 +1414,7 @@ IntersLineBezierSurfSet( const Point3d& ptLineStart, const Vector3d& vtLineDir,
frRot.Set( ORIG, X_AX) ;
if( bNeedToRotY)
frRot.Set( ORIG, Y_AX) ;
if ( bNeedToRot ) {
if ( bNeedToRot) {
r.ToLoc( frRot) ;
q.ToLoc( frRot) ;
}
@@ -1426,9 +1431,35 @@ IntersLineBezierSurfSet( const Point3d& ptLineStart, const Vector3d& vtLineDir,
continue ;
const SurfBezForInters& srf = vSurfBez[s] ;
BBox3d bbox = srf.bbSurf ;
if( bNeedToRot)
bbox.ToLoc( frRot) ;
BBox3d bbox ;
bool bNotValid = false ;
Point3d rLoc = r ;
if( ! bNeedToRot) {
bbox = srf.bbSurfZ ;
if( srf.frZMainDim.IsValid())
rLoc.ToLoc( srf.frZMainDim) ;
}
else if( bNeedToRotX) {
if( srf.frXMainDim.IsValid()) {
bbox = srf.bbSurfX ;
rLoc.LocToLoc(frRot, srf.frXMainDim) ;
}
else
bNotValid = true ;
}
else if( bNeedToRotY) {
if( srf.frYMainDim.IsValid()) {
bbox = srf.bbSurfY ;
rLoc.LocToLoc(frRot, srf.frYMainDim) ;
}
else
bNotValid = true ;
}
if( bNotValid) {
bbox = srf.bbSurfZ ;
bbox.ToLoc(frRot) ;
}
INTDBLVECTOR vIntBoxBox ;
bool bCalcInters = false ;
int nInterv = -1 ;
@@ -1441,10 +1472,10 @@ IntersLineBezierSurfSet( const Point3d& ptLineStart, const Vector3d& vtLineDir,
if( bCalcInters)
nInterv = k ;
}
bCalcInters = bCalcInters && bbox.SqDistFromPointXY( r) < EPS_ZERO ;
bCalcInters = bCalcInters && bbox.SqDistFromPointXY( rLoc) < EPS_ZERO ;
}
else
bCalcInters = bbox.SqDistFromPointXY( r) < EPS_ZERO ;
bCalcInters = bbox.SqDistFromPointXY( rLoc) < EPS_ZERO ;
// verifico che lo spillone faccia interferenza con il box della superficie
if ( bCalcInters) {
@@ -2123,10 +2154,10 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
cArcTopStartBack2.SetC2PN( ptS.front(), vPntTopStartExB[2], vPntTopStartExB[1], vtLs.front()) ;
PtrOwner<CurveBezier> cBezTopStartBack1( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopStartBack1, nDegU, bRat))) ;
PtrOwner<CurveBezier> cBezTopStartBack2( GetBasicCurveBezier(ArcToBezierCurve( &cArcTopStartBack2, nDegU, bRat))) ;
vvPtCtrl.emplace_back( PNTVECTOR{ ptS[s], ptS[s], ptS[s], ptS[s]}) ;
vvPtCtrl.emplace_back( PNTVECTOR{ ptS[0], ptS[0], ptS[0], ptS[0]}) ;
PNTVECTOR vPntTopStartBack1 = cBezTopStartBack1->GetAllControlPoints() ;
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopStartBack1.begin(), vPntTopStartBack1.end()) ;
vvPtCtrl.emplace_back( PNTVECTOR{ ptS[s], ptS[s], ptS[s], ptS[s]}) ;
vvPtCtrl.emplace_back( PNTVECTOR{ ptS[0], ptS[0], ptS[0], ptS[0]}) ;
PNTVECTOR vPntTopStartBack2 = cBezTopStartBack2->GetAllControlPoints() ;
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopStartBack2.begin(), vPntTopStartBack2.end()) ;
if( n5AxisType != VolZmap::Move5Axis::ALONG_CONCAVE) {
@@ -2187,7 +2218,6 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
vSurfBez[nSurfInd].sBez.SetControlPoint( 5, vvPtCtrl[z][5]) ;
vSurfBez[nSurfInd].sBez.SetControlPoint( 6, vvPtCtrl[z][6]) ;
vSurfBez[nSurfInd].sBez.SetControlPoint( 7, vvPtCtrl[z][7]) ;
vSurfBez[nSurfInd].bbSurf.Add( vvPtCtrl[z]) ;
Vector3d A = vvPtCtrl[z][4] - vvPtCtrl[z][0] ;
Vector3d B = vvPtCtrl[z][5] - vvPtCtrl[z][1] ;
@@ -2208,6 +2238,41 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
vSurfBez[nSurfInd].b1 = -3*E + 3*F ;
vSurfBez[nSurfInd].b0 = E ;
Vector3d vtDirX ;
Vector3d vtDir0 = vvPtCtrl[z][4] - vvPtCtrl[z][0] ;
Vector3d vtDir1 = vvPtCtrl[z][3] - vvPtCtrl[z][0] ;
if( vtDir0.Len() > vtDir1.Len())
vtDirX = vtDir0 ;
else
vtDirX = vtDir1 ;
// calcolo il box in un riferimento che usi come asse x la direzione P01 - P00 ( proiettata sul piano perperndicolare a Z)
if( vSurfBez[nSurfInd].frZMainDim.Set( ORIG, Z_AX, vtDirX)) {
// porto tutti i punti in quel riferimento e calcolo il box
PNTVECTOR vPtCtrlLoc = vvPtCtrl[z] ;
for( int p = 0 ; p < int( vPtCtrlLoc.size()) ; ++p)
vPtCtrlLoc[p].ToLoc( vSurfBez[nSurfInd].frZMainDim) ;
vSurfBez[nSurfInd].bbSurfZ.Add( vPtCtrlLoc) ;
}
else {
// in ogni caso definisco la box rispetto al rifemento di nGrid
vSurfBez[nSurfInd].bbSurfZ.Add( vvPtCtrl[z]) ;
}
if( vSurfBez[nSurfInd].frXMainDim.Set( ORIG, X_AX, vtDirX)) {
PNTVECTOR vPtCtrlLoc = vvPtCtrl[z] ;
// porto tutti i punti in quel riferimento e calcolo il box
for( int p = 0 ; p < int( vPtCtrlLoc.size()) ; ++p)
vPtCtrlLoc[p].ToLoc( vSurfBez[nSurfInd].frXMainDim) ;
vSurfBez[nSurfInd].bbSurfX.Add( vPtCtrlLoc) ;
}
if( vSurfBez[nSurfInd].frYMainDim.Set( ORIG, Y_AX, vtDirX)) {
PNTVECTOR vPtCtrlLoc = vvPtCtrl[z] ;
// porto tutti i punti in quel riferimento e calcolo il box
for( int p = 0 ; p < int( vPtCtrlLoc.size()) ; ++p)
vPtCtrlLoc[p].ToLoc( vSurfBez[nSurfInd].frYMainDim) ;
vSurfBez[nSurfInd].bbSurfY.Add( vPtCtrlLoc) ;
}
#ifdef TEST
if ( nGrid == 0)
vGeo.push_back( vSurfBez[nSurfInd].sBez.Clone()) ;
@@ -2218,7 +2283,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
#ifdef TEST
//debug
if ( nGrid == 0) {
if ( nGrid == 0 && false) {
vector<Color> vCol( vGeo.size()) ;
fill(vCol.begin(), vCol.end(), Color( 255,128,0)) ;
SaveGeoObj( vGeo, vCol, "D:/Temp/VirtualMilling/5axisAdvanced/finalApprox.nge", 2) ;
@@ -2294,8 +2359,14 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
if ( ! bForward && vStartEnds.size() > 1) {
// salvo la prima intersezione dubbia e comincio a scorrere al contrario per trovare l'ultima e capire se è dello stesso tipo della prima
if( ! bAllSameType || false) { // DEBUG se a true !!!!!!!!!!!
if( ! bAllSameType) {
bUseOnlyExtremes = false ;
//debug
string sOut = " calcoli addizionali per capire dentro/fouri" ; // debug
LOG_INFO( GetEGkLogger(), sOut.c_str())
//debug
// calcolo le intersezioni anche sugli altri due spilloni passanti per un punto a metà tra due dei vari intervalli
// ho almeno due intervalli; prendo un punto a metà tra la fine del primo e l'inzio del secondo
Point3d ptLineStart = (vInters[vStartEnds[0].second].first + vInters[vStartEnds[1].first].first ) / 2 ;
@@ -2340,12 +2411,6 @@ VolZmap::Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& pt
// questo tipo e calcolare solo le intersezioni
if ( bUseOnlyExtremes == bFirstAmbiguousCaseType)
bAllSameType = true ;
if ( bUseOnlyExtremes != bFirstAmbiguousCaseType && bAllSameType ) {
string sOut = " Taglio multiplo ambiguo che avrebbe bisogno di più calcoli!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ; // debug
LOG_INFO( GetEGkLogger(), sOut.c_str())
return false ;
}
}
if( ! bAllSameType)
@@ -2545,7 +2610,7 @@ bool
VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs,
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe)
{
#if true
#if false
#define OLD_LINEAR
#endif