Merge branch 'master' into abseil

This commit is contained in:
Daniele Bariletti
2025-09-26 12:56:07 +02:00
5 changed files with 587 additions and 729 deletions
+33 -18
View File
@@ -544,6 +544,13 @@ ArcToBezierCurve( const ICurveArc* pArc, int nDeg, bool bMakeRatOrNot)
PtrOwner<ICurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
if ( IsNull( pCrvBez) || ! pCrvBez->FromArc( *pArc))
return nullptr ;
if ( ! bMakeRatOrNot) {
Point3d ptCen = pArc->GetCenter() ;
Vector3d vtN = pArc->GetNormVersor() ;
pCrvBez.Set( ApproxArcCurveBezierWithSingleCubic( pCrvBez, ptCen, vtN)) ;
}
if ( IsNull( pCrvBez))
return nullptr ;
// aumento il grado della curva come richiesto
while ( pCrvBez->GetDegree() < nDeg)
pCrvBez.Set( BezierIncreaseDegree( pCrvBez)) ;
@@ -926,10 +933,8 @@ ApproxBezierWithCubics(const ICurve* pCrv, double dTol)
Vector3d vtStartDir, vtEndDir ;
pCrvBezier->GetPointD1D2( 0, ICurve::FROM_MINUS, ptStart, &vtStartDir) ;
pCrvBezier->GetPointD1D2( 1, ICurve::FROM_PLUS, ptEnd, &vtEndDir) ;
Plane3d plPLane ;
plPLane.Set( ptStart, ptCtrl, ptEnd) ;
vtStartDir.Rotate( plPLane.GetVersN(), 90) ;
vtEndDir.Rotate( plPLane.GetVersN(), 90) ;
vtStartDir.Rotate( vtN, 90) ;
vtEndDir.Rotate( vtN, 90) ;
Point3d ptAux1 = ptStart + vtStartDir ;
Point3d ptAux2 = ptEnd + vtEndDir ;
PtrOwner<CurveLine> pCL1( CreateBasicCurveLine()) ;
@@ -944,7 +949,7 @@ ApproxBezierWithCubics(const ICurve* pCrv, double dTol)
double dDist2 = Dist( ptEnd, ptCen) ;
if ( abs(dDist1 - dDist2) < EPS_SMALL ) {
CurveArc cArc ;
cArc.SetC2PN( ptCen, ptStart, ptEnd, plPLane.GetVersN()) ;
cArc.SetC2PN( ptCen, ptStart, ptEnd, vtN) ;
// controllo se il raggio della circonferenza risultante coincide con quello calcolato prima
// impongo inoltre che l'angolo al centro sia minore di 90 gradi
if ( abs( cArc.GetRadius() - dDist1) < EPS_SMALL && cArc.GetAngCenter() < 90 + EPS_SMALL)
@@ -988,7 +993,7 @@ ApproxBezierWithCubics(const ICurve* pCrv, double dTol)
if ( ! bIsArc)
pCrvCubic.Set( ApproxCurveBezierWithSingleCubic( pCrvPart)) ;
else {
pCrvCubic.Set( ApproxArcCurveBezierWithSingleCubic( pCrvPart, ptCen)) ;
pCrvCubic.Set( ApproxArcCurveBezierWithSingleCubic( pCrvPart, ptCen, vtN)) ;
if ( IsNull( pCrvCubic)) {
// se fallisce allora riprovo usando più di una bezier
bIsArc = false ;
@@ -1062,12 +1067,21 @@ ApproxCurveBezierWithSingleCubic( const ICurve* pCrv)
//----------------------------------------------------------------------------
ICurveBezier*
ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen)
ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen, const Vector3d& vtN)
{
// verifico sia una bezier
const CurveBezier* pCrvBez = GetBasicCurveBezier( pCrv) ;
if ( pCrvBez == nullptr)
return nullptr ;
// verifico sia una bezier
const CurveBezier* pCrvBez = GetBasicCurveBezier( pCrv) ;
if ( pCrvBez == nullptr)
return nullptr ;
// mi metto nel frame della curva ( lavoro nel piano XY)
Point3d ptStart = pCrvBez->GetControlPoint( 0) ;
Point3d ptEnd = pCrvBez->GetControlPoint( 2) ;
Frame3d frCrv; frCrv.Set( ptStart, vtN) ;
ptStart = ORIG ;
ptEnd.ToLoc( frCrv) ;
Point3d ptCenLoc = ptCen ;
ptCenLoc.ToLoc( frCrv) ;
// converto una curva di bezier che definisce un arco perfetto di circonferenza
// dato il centro( della circonferenza), inizio e fine
@@ -1077,9 +1091,7 @@ ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen)
bool bRat = pCrvBez->IsRational() ;
if ( nDeg != 2 || ! bRat)
return nullptr ;
Point3d ptStart = pCrvBez->GetControlPoint( 0) ;
Point3d ptEnd = pCrvBez->GetControlPoint( 2) ;
if ( AreSamePointEpsilon( ptStart, ptEnd, EPS_SMALL * 50))
return nullptr ;
nDeg = 3 ;
@@ -1089,10 +1101,10 @@ ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen)
pCrvCubic->SetControlPoint( 3, ptEnd) ;
// from the article of Aleksas Riškus "Approximation of a cubic bezier curve by circular arcs and vice versa"
// with corrections from "Hans Muller's Flex Blog", page "More About Approximating Circular Arcs With a Cubic Bezier Path"
double ax = ptStart.x - ptCen.x ;
double ay = ptStart.y - ptCen.y ;
double bx = ptEnd.x - ptCen.x ;
double by = ptEnd.y - ptCen.y ;
double ax = ptStart.x - ptCenLoc.x ;
double ay = ptStart.y - ptCenLoc.y ;
double bx = ptEnd.x - ptCenLoc.x ;
double by = ptEnd.y - ptCenLoc.y ;
double q1 = ax * ax + ay * ay ;
double q2 = q1 + ax * bx + ay * by ;
double k2 = 4. / 3 * ( sqrt( 2 * q1 * q2) - q2) / ( ax * by - ay * bx) ;
@@ -1104,6 +1116,9 @@ ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen)
pCrvCubic->SetControlPoint( 1, ptCtrl1) ;
pCrvCubic->SetControlPoint( 2, ptCtrl2) ;
// ritorno nel frame originale
pCrvCubic->ToGlob( frCrv) ;
return Release( pCrvCubic) ;
}
BIN
View File
Binary file not shown.
+4 -4
View File
@@ -877,7 +877,7 @@ GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const
// se ha il nome o la parte iniziale di nome cercato
string sObjName ;
if ( pGdbO->GetName( sObjName) &&
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
return ( pGdbO->m_nId) ;
// passo al successivo
pGdbO = pGdbO->GetNext() ;
@@ -905,7 +905,7 @@ GeomDB::GetNextName( int nId, const string& sName) const
// se ha il nome o la parte iniziale di nome cercato
string sObjName ;
if ( pGdbNext->GetName( sObjName) &&
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
return ( pGdbNext->m_nId) ;
// passo al successivo
pGdbNext = pGdbNext->GetNext() ;
@@ -933,7 +933,7 @@ GeomDB::GetLastNameInGroup( int nGroupId, const string& sName) const
// se ha il nome o la parte iniziale di nome cercato
string sObjName ;
if ( pGdbO->GetName( sObjName) &&
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
return ( pGdbO->m_nId) ;
// passo al precedente
pGdbO = pGdbO->GetPrev() ;
@@ -961,7 +961,7 @@ GeomDB::GetPrevName( int nId, const string& sName) const
// se ha il nome o la parte iniziale di nome cercato
string sObjName ;
if ( pGdbPrev->GetName( sObjName) &&
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
return ( pGdbPrev->m_nId) ;
// passo al precedente
pGdbPrev = pGdbPrev->GetPrev() ;
+11 -11
View File
@@ -268,7 +268,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtD, const Vector3d& vtA) ;
bool MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs,
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) ;
bool SelectGeneralMotion( int nGrid, const PNTVECTOR& ptPs, const PNTVECTOR& ptPe, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int n5AxisType) ;
bool SelectGeneralMotion( int nGrid, const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtLs, const Vector3d& vtLe, int n5AxisType) ;
bool SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtL, const Vector3d& vtAL) ;
bool InitializePointsAndVectors( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtDs, const Vector3d& vtAs,
Point3d ptLs[3], Point3d ptLe[3], Vector3d vtLs[3], Vector3d vtALs[3]) ;
@@ -307,10 +307,10 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
bool GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
// lavorazioni a 5 assi
bool GenTool_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
bool Cyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, double dHeightCorr = 0, int n5AxisType = ACROSS) ;
bool CylBall_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
bool Conus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
bool GenTool_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
bool Cyl_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, double dHeightCorr = 0, int n5AxisType = ACROSS) ;
bool CylBall_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
bool Conus_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
// COMPONENTI
// Asse di simmetria diretto come l'asse Z
@@ -346,13 +346,13 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ,
const Point3d& ptS, const Point3d& ptE,
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
// lavorazioni a 5 assi
bool Comp_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe,
// lavorazioni a 5 assi
bool Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe,
double dHeight, double dMaxRad, double dMinRad, int nToolNum, int n5AxisType) ;
bool CompCyl_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtLs, const VCT3DVECTOR& vtLe,
double dHeight, double dRadius, int nToolNum,int n5AxisType) ;
bool CompConus_5AxisMilling( int nGrid, const PNTVECTOR& ptS, const PNTVECTOR& ptE, const VCT3DVECTOR& vtToolDirS, const VCT3DVECTOR& vtToolDirE, double dHei, double dMaxRad, double dMinRad,
bool bTapB, bool bTapT,const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int n5AxisType) ;
bool CompCyl_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe,
double dHeight, double dRadius, int nToolNum, int n5AxisType) ;
bool CompConus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDirS, const Vector3d& vtToolDirE, double dHei, double dMaxRad, double dMinRad,
bool bTapB, bool bTapT, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int n5AxisType) ;
// Generica traslazione sfera
bool CompBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dRad, int nToolNum) ;
+539 -696
View File
File diff suppressed because it is too large Load Diff