EgtGeomKernel 1.6w3 :

- correzioni nell'intersezione di archi tangenti o quasi
- pulizia uso distanze e relative costanti minime.
This commit is contained in:
Dario Sassi
2016-11-14 06:18:44 +00:00
parent 2c29509f29
commit 0dd8afedf9
17 changed files with 111 additions and 54 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ GetCircleCenTgLine( const Point3d& ptCen, const Vector3d& vtN, const CurveLine&
return nullptr ;
// verifico che stia sul segmento
double dSqDist ;
if ( ! DistPointLine( ptTg, ptP1, ptP2).GetSqDist( dSqDist) || dSqDist > EPS_SMALL * EPS_SMALL)
if ( ! DistPointLine( ptTg, ptP1, ptP2).GetSqDist( dSqDist) || dSqDist > SQ_EPS_SMALL)
return nullptr ;
// creo l'arco
+6 -6
View File
@@ -1329,7 +1329,7 @@ CurveArc::ModifyEnd( const Point3d& ptNewEnd)
Point3d ptEndIntr = ptNewEnd ;
ptEndIntr.ToLoc( frIntr) ;
// se coincidono nel piano XY, è cambiato solo il deltaN
if ( SqDistXY( ptOldEndIntr, ptEndIntr) < EPS_ZERO * EPS_ZERO) {
if ( AreSamePointXYExact( ptOldEndIntr, ptEndIntr)) {
m_dDeltaN += ptEndIntr.z - ptOldEndIntr.z ;
}
// altrimenti, calcolo un arco ausiliario nel riferimento intrinseco con i nuovi dati
@@ -1779,7 +1779,7 @@ CurveArc::CalcPointAngle( const Point3d& ptP, double& dAngDeg) const
//----------------------------------------------------------------------------
bool
CurveArc::CalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos) const
CurveArc::MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const
{
// calcolo la posizione angolare
double dAngDeg ;
@@ -1789,13 +1789,13 @@ CurveArc::CalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos) const
dU = dAngDeg / m_dAngCenDeg ;
// verifica posizione punto su arco
nPos = PP_NULL ; // fuori
if ( fabs( DiffAngle( dAngDeg, 0) * DEGTORAD * m_dRad) < EPS_SMALL) {
nPos = ( IsACircle() ? PP_MID : PP_START) ; // se cerchio interno, altrimenti vicino a inizio
if ( fabs( DiffAngle( dAngDeg, 0) * DEGTORAD * m_dRad) < dLinTol) {
nPos = ( IsACircle() ? PP_MID : PP_START) ; // se cerchio è interno, altrimenti vicino a inizio
dU = AngleNearAngle( dAngDeg, 0) / m_dAngCenDeg ;
dU = max( dU, 0.) ;
}
else if ( fabs( DiffAngle( dAngDeg, m_dAngCenDeg) * DEGTORAD * m_dRad) < EPS_SMALL) {
nPos = ( IsACircle() ? PP_MID : PP_END) ; // se cerchio interno, altrimenti vicino a fine
else if ( fabs( DiffAngle( dAngDeg, m_dAngCenDeg) * DEGTORAD * m_dRad) < dLinTol) {
nPos = ( IsACircle() ? PP_MID : PP_END) ; // se cerchio è interno, altrimenti vicino a fine
dU = AngleNearAngle( dAngDeg, m_dAngCenDeg) / m_dAngCenDeg ;
dU = min( dU, 1.) ;
}
+3 -1
View File
@@ -163,7 +163,8 @@ class CurveArc : public ICurveArc, public IGeoObjRW
{ return m_dDeltaN ; }
bool IsPointInSector( const Point3d& ptP) const override ;
bool CalcPointAngle( const Point3d& ptP, double& dAngDeg) const override ;
bool CalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos) const override ;
bool CalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos) const override
{ return MyCalcPointParamPosiz( ptP, dU, nPos, EPS_SMALL) ; }
bool InvertN( void) override ;
bool ChangeRadius( double dNewRadius) override ;
bool ChangeDeltaN( double dNewDeltaN) override ;
@@ -188,6 +189,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW
LOG_ERROR( GetEGkLogger(), "CurveArc : copy error")
return *this ; }
bool MyExtendedOffset( double dDist, bool bAll, int nType = OFF_FILLET) ;
bool MyCalcPointParamPosiz( const Point3d& ptP, double& dU, int& nPos, double dLinTol) const ;
private :
bool CopyFrom( const CurveArc& caSrc) ;
+3 -3
View File
@@ -256,7 +256,7 @@ bool
CurveLine::Validate( void)
{
if ( m_nStatus == TO_VERIFY)
m_nStatus = ( ( SqDist( m_PtStart, m_PtEnd) > EPS_SMALL * EPS_SMALL) ? OK : ERR) ;
m_nStatus = ( ! AreSamePointApprox( m_PtStart, m_PtEnd) ? OK : ERR) ;
return ( m_nStatus == OK) ;
}
@@ -593,7 +593,7 @@ CurveLine::ModifyStart( const Point3d& ptNewStart)
return false ;
// la linea modificata deve essere ancora valida
if ( SqDist( ptNewStart, m_PtEnd) <= EPS_SMALL * EPS_SMALL)
if ( AreSamePointApprox( ptNewStart, m_PtEnd))
return false ;
// assegno il nuovo inizio
m_PtStart = ptNewStart ;
@@ -613,7 +613,7 @@ CurveLine::ModifyEnd( const Point3d& ptNewEnd)
return false ;
// la linea modificata deve essere ancora valida
if ( SqDist( m_PtStart, ptNewEnd) <= EPS_SMALL * EPS_SMALL)
if ( AreSamePointApprox( m_PtStart, ptNewEnd))
return false ;
// assegno la nuova fine
m_PtEnd = ptNewEnd ;
+2 -2
View File
@@ -34,9 +34,9 @@ class DistPointLine
bool GetSqDist( double& dSqDist) ;
bool GetDist( double& dDist) ;
bool IsSmall( void)
{ double dSqDist ; return ( GetSqDist( dSqDist) && dSqDist < EPS_SMALL * EPS_SMALL) ; }
{ double dSqDist ; return ( GetSqDist( dSqDist) && dSqDist < SQ_EPS_SMALL) ; }
bool IsZero( void)
{ double dSqDist ; return ( GetSqDist( dSqDist) && dSqDist < EPS_ZERO * EPS_ZERO) ; }
{ double dSqDist ; return ( GetSqDist( dSqDist) && dSqDist < SQ_EPS_ZERO) ; }
int GetNbrMinDist( void)
{ return (( m_dSqDist < 0) ? 0 : 1) ; }
bool GetMinDistPoint( Point3d& ptMinDist) ;
BIN
View File
Binary file not shown.
+70 -8
View File
@@ -235,17 +235,18 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
double dSqH = m_Arc1.GetRadius() * m_Arc1.GetRadius() - dA * dA ;
// cerchi tangenti esterni -> una intersezione
if ( dSqH < EPS_SMALL * EPS_SMALL &&
fabs( dDist - ( m_Arc1.GetRadius() + m_Arc2.GetRadius())) < EPS_SMALL) {
if ( fabs( dDist - ( m_Arc1.GetRadius() + m_Arc2.GetRadius())) < EPS_SMALL) {
// tolleranza tangenziale sull'intersezione
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
// calcolo il punto di intersezione
Point3d ptInt = m_Arc1.GetCenter() + vtDir * m_Arc1.GetRadius() ;
// posizione parametrica dell'intersezione sul primo arco
int nPos1 ;
if ( ! m_Arc1.CalcPointParamPosiz( ptInt, m_Info[0].IciA[0].dU, nPos1))
if ( ! m_Arc1.MyCalcPointParamPosiz( ptInt, m_Info[0].IciA[0].dU, nPos1, dTgTol))
return ;
// posizione parametrica dell'intersezione sul secondo arco
int nPos2 ;
if ( ! m_Arc2.CalcPointParamPosiz( ptInt, m_Info[0].IciB[0].dU, nPos2))
if ( ! m_Arc2.MyCalcPointParamPosiz( ptInt, m_Info[0].IciB[0].dU, nPos2, dTgTol))
return ;
// se soluzione non accettata, esco
if ( nPos1 == ICurve::PP_NULL || nPos2 == ICurve::PP_NULL)
@@ -253,6 +254,36 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
// calcolo i punti sui due archi (possono differire in Z)
m_Arc1.GetPointD1D2( m_Info[0].IciA[0].dU, ICurve::FROM_MINUS, m_Info[0].IciA[0].ptI) ;
m_Arc2.GetPointD1D2( m_Info[0].IciB[0].dU, ICurve::FROM_MINUS, m_Info[0].IciB[0].ptI) ;
// verifico che non distino in XY più della tolleranza generale
if ( ! AreSamePointXYApprox( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].ptI)) {
// se entrambi interni, c'è un errore imprevisto (dovrebbero essere entro la tolleranza)
if ( nPos1 == ICurve::PP_MID && nPos2 == ICurve::PP_MID)
return ;
// se entrambi già agli estremi, non posso spostarli
if ( ( nPos1 == ICurve::PP_START || nPos1 == ICurve::PP_END) &&
( nPos2 == ICurve::PP_START || nPos2 == ICurve::PP_END))
return ;
// se primo all'estremo dell'entità, provo a spostare il secondo
if ( nPos1 == ICurve::PP_START || nPos1 == ICurve::PP_END) {
// ridetermino posizione parametrica del secondo
if ( ! m_Arc2.MyCalcPointParamPosiz( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].dU, nPos2, dTgTol) || nPos2 == ICurve::PP_NULL)
return ;
// ricalcolo il punto sull'arco e riverifico in XY
m_Arc2.GetPointD1D2( m_Info[0].IciB[0].dU, ICurve::FROM_MINUS, m_Info[0].IciB[0].ptI) ;
if ( ! AreSamePointXYApprox( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].ptI))
return ;
}
// altrimenti secondo all'estremo dell'entità, provo a spostare il primo
else {
// ridetermino posizione parametrica del primo
if ( ! m_Arc1.MyCalcPointParamPosiz( m_Info[0].IciB[0].ptI, m_Info[0].IciA[0].dU, nPos1, dTgTol) || nPos1 == ICurve::PP_NULL)
return ;
// ricalcolo il punto sull'arco e riverifico in XY
m_Arc1.GetPointD1D2( m_Info[0].IciA[0].dU, ICurve::FROM_MINUS, m_Info[0].IciA[0].ptI) ;
if ( ! AreSamePointXYApprox( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].ptI))
return ;
}
}
// calcolo dati ausiliari
bool bCCW1 = (( m_Arc1.GetAngCenter() > 0 && m_Arc1.GetNormVersor().IsZplus()) ||
( m_Arc1.GetAngCenter() < 0 && m_Arc1.GetNormVersor().IsZminus())) ;
@@ -326,19 +357,20 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
}
// cerchi tangenti interni -> una intersezione
if ( dSqH < EPS_SMALL * EPS_SMALL &&
fabs( dDist - fabs( m_Arc1.GetRadius() - m_Arc2.GetRadius())) < EPS_SMALL) {
if ( fabs( dDist - fabs( m_Arc1.GetRadius() - m_Arc2.GetRadius())) < EPS_SMALL) {
// tolleranza tangenziale sull'intersezione
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
// determino quale dei due contiene l'altro
bool bBiggest1 = ( m_Arc1.GetRadius() > m_Arc2.GetRadius()) ;
// calcolo il punto di intersezione
Point3d ptInt = m_Arc1.GetCenter() + ( bBiggest1 ? vtDir : - vtDir) * m_Arc1.GetRadius() ;
// posizione parametrica dell'intersezione sul primo arco
int nPos1 ;
if ( ! m_Arc1.CalcPointParamPosiz( ptInt, m_Info[0].IciA[0].dU, nPos1))
if ( ! m_Arc1.MyCalcPointParamPosiz( ptInt, m_Info[0].IciA[0].dU, nPos1, dTgTol))
return ;
// posizione parametrica dell'intersezione sul secondo arco
int nPos2 ;
if ( ! m_Arc2.CalcPointParamPosiz( ptInt, m_Info[0].IciB[0].dU, nPos2))
if ( ! m_Arc2.MyCalcPointParamPosiz( ptInt, m_Info[0].IciB[0].dU, nPos2, dTgTol))
return ;
// se soluzione non accettata, esco
if ( nPos1 == ICurve::PP_NULL || nPos2 == ICurve::PP_NULL)
@@ -346,6 +378,36 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
// calcolo i punti sui due archi (possono differire in Z)
m_Arc1.GetPointD1D2( m_Info[0].IciA[0].dU, ICurve::FROM_MINUS, m_Info[0].IciA[0].ptI) ;
m_Arc2.GetPointD1D2( m_Info[0].IciB[0].dU, ICurve::FROM_MINUS, m_Info[0].IciB[0].ptI) ;
// verifico che non distino in XY più della tolleranza generale
if ( ! AreSamePointXYApprox( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].ptI)) {
// se entrambi interni, c'è un errore imprevisto (dovrebbero essere entro la tolleranza)
if ( nPos1 == ICurve::PP_MID && nPos2 == ICurve::PP_MID)
return ;
// se entrambi già agli estremi, non posso spostarli
if ( ( nPos1 == ICurve::PP_START || nPos1 == ICurve::PP_END) &&
( nPos2 == ICurve::PP_START || nPos2 == ICurve::PP_END))
return ;
// se primo all'estremo dell'entità, provo a spostare il secondo
if ( nPos1 == ICurve::PP_START || nPos1 == ICurve::PP_END) {
// ridetermino posizione parametrica del secondo
if ( ! m_Arc2.MyCalcPointParamPosiz( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].dU, nPos2, dTgTol) || nPos2 == ICurve::PP_NULL)
return ;
// ricalcolo il punto sull'arco e riverifico in XY
m_Arc2.GetPointD1D2( m_Info[0].IciB[0].dU, ICurve::FROM_MINUS, m_Info[0].IciB[0].ptI) ;
if ( ! AreSamePointXYApprox( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].ptI))
return ;
}
// altrimenti secondo all'estremo dell'entità, provo a spostare il primo
else {
// ridetermino posizione parametrica del primo
if ( ! m_Arc1.MyCalcPointParamPosiz( m_Info[0].IciB[0].ptI, m_Info[0].IciA[0].dU, nPos1, dTgTol) || nPos1 == ICurve::PP_NULL)
return ;
// ricalcolo il punto sull'arco e riverifico in XY
m_Arc1.GetPointD1D2( m_Info[0].IciA[0].dU, ICurve::FROM_MINUS, m_Info[0].IciA[0].ptI) ;
if ( ! AreSamePointXYApprox( m_Info[0].IciA[0].ptI, m_Info[0].IciB[0].ptI))
return ;
}
}
// calcolo dati ausiliari
bool bCCW1 = (( m_Arc1.GetAngCenter() > 0 && m_Arc1.GetNormVersor().IsZplus()) ||
( m_Arc1.GetAngCenter() < 0 && m_Arc1.GetNormVersor().IsZminus())) ;
+1 -1
View File
@@ -51,7 +51,7 @@ IntersLineArc::IntersLineArc( const CurveLine& Line, const CurveArc& Arc)
m_vtDirL = m_Line.GetEnd() - m_Line.GetStart() ;
Vector3d vtDirLXY = m_vtDirL ;
vtDirLXY.z = 0 ;
if ( m_vtDirL.SqLenXY() < EPS_SMALL * EPS_SMALL)
if ( m_vtDirL.IsSmallXY())
return ;
// arco : copia
+1 -1
View File
@@ -61,7 +61,7 @@ GetLinePointTgLine( const Point3d& ptP, const CurveLine& crvLine, const Point3d&
// verifico che il punto giaccia sulla linea estesa
DistPointCurve dstPtCurve( ptP, crvLine, false) ;
double dSqDist ;
if ( ! dstPtCurve.GetSqDist( dSqDist) || dSqDist > EPS_SMALL * EPS_SMALL)
if ( ! dstPtCurve.GetSqDist( dSqDist) || dSqDist > SQ_EPS_SMALL)
return nullptr ;
// recupero il punto sulla linea più vicino al punto near
Point3d ptP2 ;
+1 -1
View File
@@ -162,7 +162,7 @@ PointGrid3d::RemovePoint( const Point3d& ptP, int nId)
// cerco quello con l'Id voluto
for ( ; MMrange.first != MMrange.second ; ++ MMrange.first) {
// se coincidono punto e Id lo cancello
if ( SqDist( (*MMrange.first).second.first, ptP) < ( EPS_SMALL * EPS_SMALL) &&
if ( SqDist( (*MMrange.first).second.first, ptP) < SQ_EPS_SMALL &&
abs( (*MMrange.first).second.second) == abs( nId)) {
m_MMap.erase( MMrange.first) ;
return true ;
+5 -5
View File
@@ -91,18 +91,18 @@ PointsPCA::Finalize( void)
// se l'autovalore corrente è il più grande in modulo
if ( fabs( es.eigenvalues()(i)) >= fabs( es.eigenvalues()(j)) &&
fabs( es.eigenvalues()(i)) >= fabs( es.eigenvalues()(k)) &&
fabs( es.eigenvalues()(i)) > EPS_SMALL * EPS_SMALL) {
fabs( es.eigenvalues()(i)) > SQ_EPS_SMALL) {
// il suo autovettore è il primo
++ m_nRank ;
m_vtPC[0].Set( es.eigenvectors()(0,i), es.eigenvectors()(1,i), es.eigenvectors()(2,i)) ;
// se il successivo autovalore è maggiore del rimanente in modulo
if ( fabs( es.eigenvalues()(j)) >= fabs(es.eigenvalues()(k)) &&
fabs( es.eigenvalues()(j)) > EPS_SMALL * EPS_SMALL) {
fabs( es.eigenvalues()(j)) > SQ_EPS_SMALL) {
// il suo autovettore è il secondo
++ m_nRank ;
m_vtPC[1].Set( es.eigenvectors()(0,j), es.eigenvectors()(1,j), es.eigenvectors()(2,j)) ;
// se il rimanente autovalore è non nullo
if ( fabs( es.eigenvalues()(k)) > EPS_SMALL * EPS_SMALL) {
if ( fabs( es.eigenvalues()(k)) > SQ_EPS_SMALL) {
// il suo autovettore è il terzo
++ m_nRank ;
m_vtPC[2].Set( es.eigenvectors()(0,k), es.eigenvectors()(1,k), es.eigenvectors()(2,k)) ;
@@ -110,12 +110,12 @@ PointsPCA::Finalize( void)
}
// altrimenti, se il rimanente autovalore è maggiore del successivo in modulo
else if ( fabs( es.eigenvalues()(k)) >= fabs( es.eigenvalues()(j)) &&
fabs( es.eigenvalues()(k)) > EPS_SMALL * EPS_SMALL) {
fabs( es.eigenvalues()(k)) > SQ_EPS_SMALL) {
// il suo autovettore è il secondo
++ m_nRank ;
m_vtPC[1].Set( es.eigenvectors()(0,k), es.eigenvectors()(1,k), es.eigenvectors()(2,k)) ;
// se il rimanente autovalore è non nullo
if ( fabs( es.eigenvalues()(j)) > EPS_SMALL * EPS_SMALL) {
if ( fabs( es.eigenvalues()(j)) > SQ_EPS_SMALL) {
// il suo autovettore è il terzo
++ m_nRank ;
m_vtPC[2].Set( es.eigenvectors()(0,j), es.eigenvectors()(1,j), es.eigenvectors()(2,j)) ;
+1 -1
View File
@@ -756,7 +756,7 @@ PolyLine::ApproxOnSide( const Vector3d& vtN, bool bLeftSide, double dToler)
double dSqDist = INFINITO * INFINITO ;
dPL.GetSqDist( dSqDist) ;
// se punti allineati
if ( dSqDist < EPS_SMALL * EPS_SMALL) {
if ( dSqDist < SQ_EPS_SMALL) {
// ripristino la tolleranza corrente
dCurrToler = dToler ;
// elimino il corrente
+3 -3
View File
@@ -61,15 +61,15 @@ AreSamePointApproxInPlane( int nPlane, const Point3d& ptP1, const Point3d& ptP2)
default : // PL_XY
dX = ptP1.x - ptP2.x ;
dY = ptP1.y - ptP2.y ;
return ( ( dX * dX + dY * dY) < EPS_SMALL * EPS_SMALL) ;
return ( ( dX * dX + dY * dY) < SQ_EPS_SMALL) ;
case PL_YZ :
dY = ptP1.y - ptP2.y ;
dZ = ptP1.z - ptP2.z ;
return ( ( dY * dY + dZ * dZ) < EPS_SMALL * EPS_SMALL) ;
return ( ( dY * dY + dZ * dZ) < SQ_EPS_SMALL) ;
case PL_ZX :
dZ = ptP1.z - ptP2.z ;
dX = ptP1.x - ptP2.x ;
return ( ( dZ * dZ + dX * dX) < EPS_SMALL * EPS_SMALL) ;
return ( ( dZ * dZ + dX * dX) < SQ_EPS_SMALL) ;
}
}
+1 -1
View File
@@ -834,7 +834,7 @@ SurfFlatRegion::GetCentroid( Point3d& ptCen) const
dArea += abs( dA) ;
}
// verifico di aver trovato qualcosa
if ( dArea < EPS_SMALL * EPS_SMALL)
if ( dArea < SQ_EPS_SMALL)
return false ;
// medio il centro
ptCen /= dArea ;
+1 -1
View File
@@ -321,7 +321,7 @@ SurfTriMesh::GetCentroid( Point3d& ptCen) const
ptCen += Tria.GetCentroid() * dTriaArea ;
nId = GetNextTriangle( nId, Tria) ;
}
if ( fabs( dArea) < EPS_SMALL * EPS_SMALL)
if ( fabs( dArea) < SQ_EPS_SMALL)
return false ;
ptCen /= dArea ;
}
+1 -1
View File
@@ -583,7 +583,7 @@ Triangulate::CalcTriangleAspectRatio( const Point3d& ptPa, const Point3d& ptPb,
double dSqDistB = SquareDist( ptPb, ptPc) ;
double dSqDistC = SquareDist( ptPc, ptPa) ;
double dTwoArea = fabs( TwoArea( ptPa, ptPb, ptPc)) ;
if ( dTwoArea < EPS_SMALL * EPS_SMALL)
if ( dTwoArea < SQ_EPS_SMALL)
return INFINITO ;
else
return ( (std::max)( dSqDistA, (std::max)( dSqDistB, dSqDistC)) / dTwoArea) ;
+11 -18
View File
@@ -346,7 +346,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d&
Vector3d vtTOrt = vtTest - vtTLong ;
// Movimento parallelo alla direzione dell'utensile (foratura)
if ( vtTOrt.SqLen() < EPS_SMALL * EPS_SMALL) {
if ( vtTOrt.IsSmall()) {
if ( m_nToolType == 0)
return DrillingGT( ptLs, ptLe, vtDir) ;
else
@@ -354,7 +354,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d&
}
// Movimento perpendicolare alla direzione dell'utensile
if ( vtTLong.SqLen() < EPS_SMALL * EPS_SMALL) {
if ( vtTLong.IsSmall()) {
if ( m_nToolType == GenericTool)
return MillingGT( ptLs, ptLe, vtDir) ;
else
@@ -375,7 +375,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d&
return MillingGT( ptLs, ptLe, vtDir) ;
// Movimento verticale
if ( SqDistXY( ptLs, ptLe) < EPS_SMALL * EPS_SMALL)
if ( AreSamePointXYApprox( ptLs, ptLe))
return MillingXYVert( ptLs, ptLe, vtDir) ;
// Grandezze geometriche per selezione
@@ -384,11 +384,11 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d&
Vector3d vtTOrt = vtMove - ( vtMove * vtDir) * vtDir ;
// Movimento LongVert
if ( vtTOrt.SqLenXY() < EPS_SMALL * EPS_SMALL)
if ( vtTOrt.IsSmallXY())
return MillingXYLongVert( ptLs, ptLe, vtDir) ;
// Movimento perpendicolare alla direzione dell'utensile
if ( vtTLong.SqLenXY() < EPS_SMALL * EPS_SMALL)
if ( vtTLong.IsSmallXY())
return MillingXY( ptLs, ptLe, vtDir) ;
// Movimento generico con versore direzione nel piano
@@ -403,7 +403,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d&
Vector3d vtOrt = vtMove - ( vtMove * vtLs) * vtLs ;
// Drilling
if ( vtOrt.SqLen() < EPS_SMALL * EPS_SMALL) {
if ( vtOrt.IsSmall()) {
if ( m_nToolType == GenericTool)
return DrillingGT( ptLs, ptLe, vtLs) ;
else
@@ -7286,12 +7286,9 @@ VolZmap::MillCyl2( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtT
bool
VolZmap::MillBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dRad)
{
double dMin, dMax ;
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
bool Control = BBoxComponent( ptLs, ptLe, vtToolDir, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dRad, 0, 0) ;
if ( ! Control)
bool bControl = BBoxComponent( ptLs, ptLe, vtToolDir, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dRad, 0, 0) ;
if ( ! bControl)
return true ;
Point3d ptI = ( ptLs.z < ptLe.z ? ptLs : ptLe) ;
@@ -7300,14 +7297,9 @@ VolZmap::MillBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtT
Point3d ptIxy( ptI.x, ptI.y, 0) ;
Vector3d vtMove = ptF - ptI ;
Vector3d vtMoveXY( vtMove.x, vtMove.y, 0) ;
if ( vtMove.x * vtMove.x + vtMove.y * vtMove.y < EPS_SMALL * EPS_SMALL)
vtMoveXY = ( ( 1 / sqrt( vtMove.x * vtMove.x + vtMove.y * vtMove.y)) * vtMoveXY) ;
Vector3d vtV1 = vtMoveXY ; vtV1.Normalize() ;
Vector3d vtV2 = vtV1 ; vtV2.Rotate( Z_AX, 90) ;
Vector3d vtV1( vtMove.x, vtMove.y, 0) ; vtV1.Normalize() ;
Vector3d vtV2( vtV1) ; vtV2.Rotate( Z_AX, 90) ;
double dZI = ptI.z ;
double dDeltaZ = ptF.z - ptI.z ;
@@ -7316,6 +7308,7 @@ VolZmap::MillBall( const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtT
double dSin = dPLen / vtMove.Len() ;
double dCos = dDeltaZ / vtMove.Len() ;
double dMin, dMax ;
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {