EgtGeomKernel :
- modifiche a Zmap per utensili generici e per features.
This commit is contained in:
+202
-326
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "VolZmap.h"
|
||||
#include "GeoConst.h"
|
||||
#include "IntersLineSurfTm.h"
|
||||
@@ -669,6 +670,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
// Fresatura con vettore movimento perpendicolare all'utensile
|
||||
else if ( abs( vtMove.z) < EPS_SMALL) {
|
||||
switch ( m_Tool.GetType()) {
|
||||
@@ -690,6 +692,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
// Fresatura con vettore movimento generico rispetto all'utensile
|
||||
else {
|
||||
switch ( m_Tool.GetType()) {
|
||||
@@ -705,6 +708,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Versore utensile nel piano
|
||||
else if ( abs( vtLs[i].z) < EPS_SMALL) {
|
||||
|
||||
@@ -825,6 +829,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else ;
|
||||
// Altri casi al momento non gestiti
|
||||
// return false ;
|
||||
@@ -1764,105 +1769,84 @@ VolZmap::Chs_ZMilling( unsigned int nGrid, const Point3d& ptS, const Point3d& pt
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GenTool_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
|
||||
VolZmap::GenTool_ZDrilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
|
||||
{
|
||||
// Posizioni iniziale e finale dell'utensile
|
||||
// Posizioni iniziale e finale dell'utensile
|
||||
Point3d ptI = ptS ;
|
||||
Point3d ptF = ptE ;
|
||||
|
||||
// vettore movimento
|
||||
// Vettore movimento
|
||||
Vector3d vtMove = ptE - ptS ;
|
||||
|
||||
// Settaggio profilo
|
||||
const CurveComposite* pToolProfile = m_Tool.GetOutline() ;
|
||||
|
||||
// Ciclo sulle curve
|
||||
const CurveComposite* pToolProfile = m_Tool.GetOutline() ;
|
||||
const ICurve* pCurve = pToolProfile->GetFirstCurve() ;
|
||||
while ( pCurve != nullptr) {
|
||||
|
||||
|
||||
double dHeight ;
|
||||
int nCurveType = pCurve -> GetType() ;
|
||||
|
||||
// Caso segmento
|
||||
if ( nCurveType == CRV_LINE) {
|
||||
|
||||
Point3d ptStart, ptEnd ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
|
||||
if ( abs( ptStart.y - ptEnd.y) > EPS_SMALL) {
|
||||
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
|
||||
// Il componente è un cilindro
|
||||
// Se segmento
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
// Recupero gli estremi
|
||||
const ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptStart = pLine->GetStart() ;
|
||||
Point3d ptEnd = pLine->GetEnd() ;
|
||||
// Ne determino l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
if ( dHeight > EPS_SMALL) {
|
||||
// Se X costante, è un cilindro
|
||||
if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) {
|
||||
double dRadius = ptStart.x ;
|
||||
CompCyl_ZDrilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore equiverso a quello dell'utensile
|
||||
// Se X crescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
else if ( ptStart.x > ptEnd.x) {
|
||||
double dMaxRad = ptStart.x ;
|
||||
double dMinRad = ptEnd.x ;
|
||||
CompConus_ZDrilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore opposto a quello dell'utesile
|
||||
// Se X decrescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else if ( ptStart.x < ptEnd.x) {
|
||||
double dMaxRad = ptEnd.x ;
|
||||
double dMinRad = ptStart.x ;
|
||||
Point3d ptIn = ptI - vtToolDir * dHeight ;
|
||||
Point3d ptFn = ptIn + vtMove ;
|
||||
CompConus_ZDrilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad) ;
|
||||
}
|
||||
CompConus_ZDrilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad) ;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
dHeight = 0 ;
|
||||
}
|
||||
|
||||
// Caso arco
|
||||
else if ( nCurveType == CRV_ARC) {
|
||||
|
||||
// Centro e Punti iniziale e finale del cerchio
|
||||
Point3d ptStart, ptEnd, ptO ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
pCurve -> GetCenterPoint( ptO) ;
|
||||
|
||||
// Determino il raggio
|
||||
Vector3d vtStRad = ptStart - ptO ;
|
||||
Vector3d vtEnRad = ptEnd - ptO ;
|
||||
|
||||
double dRadius = 0.5 * ( vtStRad.LenXY() + vtEnRad.LenXY()) ;
|
||||
|
||||
// Determino le posizioni iniziale e finale del centrodella sfera
|
||||
Point3d ptOSt = ptI - vtToolDir * ( ptStart.y - ptO.y) ;
|
||||
Point3d ptOEn = ptOSt + vtMove ;
|
||||
|
||||
// Eseguo l'asportazione del materiale
|
||||
CompBall_Milling( nGrid, ptOSt, ptOEn, dRadius) ;
|
||||
|
||||
|
||||
// se altrimenti arco
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
// Recupero estremi, centro e raggio
|
||||
const ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptStart ; pArc->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pArc->GetEndPoint( ptEnd) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dRadius = pArc->GetRadius() ;
|
||||
// Determino le posizioni iniziale e finale del centro della sfera
|
||||
Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ;
|
||||
Point3d ptCenE = ptCenS + vtMove ;
|
||||
// Eseguo l'asportazione del materiale
|
||||
CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ;
|
||||
// aggiorno l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Determino le posizioni iniziale e finale del componente successivo
|
||||
ptI = ptI - vtToolDir * dHeight ;
|
||||
ptF = ptI + vtMove ;
|
||||
|
||||
// Aggiorno il puntatore
|
||||
// Passo alla curva successiva del profilo
|
||||
pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GenTool_ZMilling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
|
||||
VolZmap::GenTool_ZMilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
|
||||
{
|
||||
// Posizioni iniziale e finale dell'utensile
|
||||
Point3d ptI = ptS ;
|
||||
@@ -1871,43 +1855,34 @@ VolZmap::GenTool_ZMilling( unsigned int nGrid, const Point3d & ptS, const Point3
|
||||
// vettore movimento
|
||||
Vector3d vtMove = ptE - ptS ;
|
||||
|
||||
// Settaggio profilo
|
||||
// Ciclo sulle curve del profilo utensile
|
||||
const CurveComposite* pToolProfile = m_Tool.GetOutline() ;
|
||||
|
||||
// Ciclo sulle curve
|
||||
const ICurve* pCurve = pToolProfile->GetFirstCurve() ;
|
||||
while ( pCurve != nullptr) {
|
||||
|
||||
double dHeight ;
|
||||
|
||||
int nCurveType = pCurve -> GetType() ;
|
||||
|
||||
// Caso segmento
|
||||
if ( nCurveType == CRV_LINE) {
|
||||
|
||||
Point3d ptStart, ptEnd ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
|
||||
if ( abs( ptStart.y - ptEnd.y) > EPS_SMALL) {
|
||||
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
|
||||
// Il componente è un cilindro
|
||||
// Se segmento
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
// Recupero gli estremi
|
||||
const ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptStart = pLine->GetStart() ;
|
||||
Point3d ptEnd = pLine->GetEnd() ;
|
||||
// Ne determino l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
if ( dHeight > EPS_SMALL) {
|
||||
// Se X costante, è un cilindro
|
||||
if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) {
|
||||
double dRadius = ptStart.x ;
|
||||
CompCyl_ZMilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore equiverso a quello dell'utensile
|
||||
// Se X crescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
else if ( ptStart.x > ptEnd.x) {
|
||||
double dMaxRad = ptStart.x ;
|
||||
double dMinRad = ptEnd.x ;
|
||||
CompConus_ZMilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore opposto a quello dell'utensile
|
||||
// Se X decrescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else if ( ptStart.x < ptEnd.x) {
|
||||
double dMaxRad = ptEnd.x ;
|
||||
double dMinRad = ptStart.x ;
|
||||
@@ -1916,34 +1891,21 @@ VolZmap::GenTool_ZMilling( unsigned int nGrid, const Point3d & ptS, const Point3
|
||||
CompConus_ZMilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad) ;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
dHeight = 0 ;
|
||||
}
|
||||
|
||||
// Caso arco
|
||||
else if ( nCurveType == CRV_ARC) {
|
||||
|
||||
// Centro e Punti iniziale e finale del cerchio
|
||||
Point3d ptStart, ptEnd, ptO ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
pCurve -> GetCenterPoint( ptO) ;
|
||||
|
||||
// Determino il raggio
|
||||
Vector3d vtStRad = ptStart - ptO ;
|
||||
Vector3d vtEnRad = ptEnd - ptO ;
|
||||
|
||||
double dRadius = 0.5 * ( vtStRad.LenXY() + vtEnRad.LenXY()) ;
|
||||
|
||||
// Determino le posizioni iniziale e finale del centrodella sfera
|
||||
Point3d ptOSt = ptI - vtToolDir * ( ptStart.y - ptO.y) ;
|
||||
Point3d ptOEn = ptOSt + vtMove ;
|
||||
|
||||
// se altrimenti arco
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
// Recupero estremi, centro e raggio
|
||||
const ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptStart ; pArc->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pArc->GetEndPoint( ptEnd) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dRadius = pArc->GetRadius() ;
|
||||
// Determino le posizioni iniziale e finale del centro della sfera
|
||||
Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ;
|
||||
Point3d ptCenE = ptCenS + vtMove ;
|
||||
// Eseguo l'asportazione del materiale
|
||||
CompBall_Milling( nGrid, ptOSt, ptOEn, dRadius) ;
|
||||
|
||||
CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ;
|
||||
// aggiorno l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
}
|
||||
@@ -1952,9 +1914,10 @@ VolZmap::GenTool_ZMilling( unsigned int nGrid, const Point3d & ptS, const Point3
|
||||
ptI = ptI - vtToolDir * dHeight ;
|
||||
ptF = ptI + vtMove ;
|
||||
|
||||
// Aggiorno il puntatore
|
||||
// Passo alla curva successiva del profilo
|
||||
pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -3029,95 +2992,61 @@ VolZmap::Chs_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GenTool_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
|
||||
VolZmap::GenTool_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
|
||||
{
|
||||
// Descrizione geometrica del moto
|
||||
Point3d ptI = ptS ;
|
||||
Point3d ptF = ptE ;
|
||||
Vector3d vtMove = ptE - ptS ;
|
||||
|
||||
// Settaggio profilo
|
||||
// Ciclo sulle curve del profilo
|
||||
const CurveComposite* pToolProfile = m_Tool.GetOutline() ;
|
||||
|
||||
// Ciclo sulle curve
|
||||
const ICurve* pPrevCurve = nullptr ;
|
||||
const ICurve* pCurve = pToolProfile->GetFirstCurve() ;
|
||||
const ICurve* pFirstConst = pCurve ;
|
||||
|
||||
while ( pCurve != nullptr) {
|
||||
|
||||
double dHeight ;
|
||||
|
||||
int nCurveType = pCurve -> GetType() ;
|
||||
|
||||
// Caso di segmento
|
||||
if ( nCurveType == CRV_LINE) {
|
||||
|
||||
Point3d ptStart, ptEnd ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
|
||||
if ( abs( ptStart.y - ptEnd.y) > EPS_SMALL) {
|
||||
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
|
||||
bool bTapB, bTapT ;
|
||||
|
||||
pCurve = pToolProfile -> GetPrevCurve() ;
|
||||
|
||||
// Dettagli curva precedente
|
||||
int nPrevType = pCurve -> GetType() ;
|
||||
Point3d ptPrevFirst, ptPrevLast ;
|
||||
pCurve -> GetStartPoint( ptPrevFirst) ;
|
||||
pCurve -> GetEndPoint( ptPrevLast) ;
|
||||
|
||||
double dAbsDYPr = abs( ptPrevFirst.y - ptPrevLast.y) ;
|
||||
double dDeltaXPr = ptPrevFirst.x - ptPrevLast.x ;
|
||||
|
||||
// Setto le variabili per il tappo superiore
|
||||
if ( pCurve == pFirstConst ||
|
||||
nPrevType == CRV_ARC ||
|
||||
( dDeltaXPr < 0 && dAbsDYPr))
|
||||
bTapB = false ;
|
||||
else
|
||||
bTapB = true ;
|
||||
|
||||
// Dettagli curva successiva
|
||||
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
|
||||
int nNextType = pCurve -> GetType() ;
|
||||
Point3d ptNextFirst ;
|
||||
Point3d ptNextLast ;
|
||||
pCurve -> GetStartPoint( ptNextFirst) ;
|
||||
pCurve -> GetEndPoint( ptNextLast) ;
|
||||
|
||||
double dAbsDYNx = abs( ptNextFirst.y - ptNextLast.y) ;
|
||||
double dDeltaXNx = ptNextFirst.x - ptNextLast.x ;
|
||||
double dAbsXEnd = abs( ptNextLast.x) ;
|
||||
|
||||
if ( pCurve == nullptr ||
|
||||
nNextType == CRV_ARC ||
|
||||
( dAbsDYNx < EPS_SMALL && ( dDeltaXNx > 0 || dAbsXEnd < EPS_SMALL)))
|
||||
bTapT = false ;
|
||||
else
|
||||
bTapT = true ;
|
||||
|
||||
// Il componente è un cilindro
|
||||
// Se segmento
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
// Recupero gli estremi
|
||||
const ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptStart = pLine->GetStart() ;
|
||||
Point3d ptEnd = pLine->GetEnd() ;
|
||||
// Ne determino l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
if ( dHeight > EPS_SMALL) {
|
||||
// Verifiche curva precedente per eventuale tappo sopra
|
||||
bool bTapT = false ;
|
||||
if ( pPrevCurve != nullptr && pPrevCurve->GetType() == CRV_LINE) {
|
||||
const ICurveLine* pOthLine = GetCurveLine( pPrevCurve) ;
|
||||
Point3d ptOthStart = pOthLine->GetStart() ;
|
||||
Point3d ptOthEnd = pOthLine->GetEnd() ;
|
||||
if ( abs( ptOthStart.y - ptOthEnd.y) < EPS_SMALL && ptOthStart.x < ptOthEnd.x)
|
||||
bTapT = true ;
|
||||
}
|
||||
// Verifiche curva successiva per eventuale tappo sotto
|
||||
bool bTapB = false ;
|
||||
const ICurve* pNextCurve = pToolProfile->GetNextCurve() ;
|
||||
if ( pNextCurve != nullptr && pNextCurve->GetType() == CRV_LINE) {
|
||||
const ICurveLine* pOthLine = GetCurveLine( pNextCurve) ;
|
||||
Point3d ptOthStart = pOthLine->GetStart() ;
|
||||
Point3d ptOthEnd = pOthLine->GetEnd() ;
|
||||
if ( abs( ptOthStart.y - ptOthEnd.y) < EPS_SMALL && ptOthStart.x > ptOthEnd.x)
|
||||
bTapB = true ;
|
||||
}
|
||||
// Se X costante, è un cilindro
|
||||
if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) {
|
||||
double dRadius = ptStart.x ;
|
||||
CompCyl_Drilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore equiverso a quello dell'utensile
|
||||
// Se X crescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
else if ( ptStart.x > ptEnd.x) {
|
||||
double dMaxRad = ptStart.x ;
|
||||
double dMinRad = ptEnd.x ;
|
||||
CompConus_Drilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, bTapB, bTapT) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore opposto a quello dell'utensile
|
||||
// Se X decrescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else if ( ptStart.x < ptEnd.x) {
|
||||
double dMaxRad = ptEnd.x ;
|
||||
double dMinRad = ptStart.x ;
|
||||
@@ -3125,49 +3054,40 @@ VolZmap::GenTool_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3
|
||||
Point3d ptFn = ptIn + vtMove ;
|
||||
CompConus_Drilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, bTapT, bTapB) ;
|
||||
}
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
pCurve = pNextCurve ;
|
||||
}
|
||||
|
||||
else {
|
||||
dHeight = 0 ;
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
}
|
||||
|
||||
// Caso arco
|
||||
else if ( nCurveType == CRV_ARC) {
|
||||
|
||||
// Centro e Punti iniziale e finale del cerchio
|
||||
Point3d ptStart, ptEnd, ptO ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
pCurve -> GetCenterPoint( ptO) ;
|
||||
|
||||
// Determino il raggio
|
||||
Vector3d vtStRad = ptStart - ptO ;
|
||||
Vector3d vtEnRad = ptEnd - ptO ;
|
||||
|
||||
double dRadius = 0.5 * ( vtStRad.LenXY() + vtEnRad.LenXY()) ;
|
||||
|
||||
// Se arco
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
// Recupero estremi, centro e raggio
|
||||
const ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptStart ; pArc->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pArc->GetEndPoint( ptEnd) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dRadius = pArc->GetRadius() ;
|
||||
// Determino le posizioni iniziale e finale del centro della sfera
|
||||
Point3d ptOSt = ptI - vtToolDir * ( ptStart.y - ptO.y) ;
|
||||
Point3d ptOEn = ptOSt + vtMove ;
|
||||
|
||||
Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ;
|
||||
Point3d ptCenE = ptCenS + vtMove ;
|
||||
// Eseguo l'asportazione del materiale
|
||||
CompBall_Milling( nGrid, ptOSt, ptOEn, dRadius) ;
|
||||
|
||||
CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ;
|
||||
// aggiorno l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
|
||||
// Determino le posizioni iniziale e finale del componente successivo
|
||||
ptI = ptI - vtToolDir * dHeight ;
|
||||
ptF = ptI + vtMove ;
|
||||
|
||||
// Aggiorno il puntatore
|
||||
// pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -3175,137 +3095,97 @@ VolZmap::GenTool_Drilling( unsigned int nGrid, const Point3d & ptS, const Point3
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GenTool_Milling( unsigned int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir)
|
||||
VolZmap::GenTool_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir)
|
||||
{
|
||||
// Descrizione geometrica del moto
|
||||
Point3d ptI = ptS ;
|
||||
Point3d ptF = ptE ;
|
||||
Vector3d vtMove = ptE - ptS ;
|
||||
|
||||
// Settaggio profilo
|
||||
|
||||
// Ciclo sulle curve del profilo
|
||||
const CurveComposite* pToolProfile = m_Tool.GetOutline() ;
|
||||
|
||||
// Ciclo sulle curve
|
||||
const ICurve* pPrevCurve = nullptr ;
|
||||
const ICurve* pCurve = pToolProfile->GetFirstCurve() ;
|
||||
const ICurve* pFirstConst = pCurve ;
|
||||
|
||||
while ( pCurve != nullptr) {
|
||||
|
||||
double dHeight ;
|
||||
|
||||
int nCurveType = pCurve -> GetType() ;
|
||||
|
||||
// Caso di segmento
|
||||
if ( nCurveType == CRV_LINE) {
|
||||
|
||||
Point3d ptStart, ptEnd ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
|
||||
if ( abs( ptStart.y - ptEnd.y) > EPS_SMALL) {
|
||||
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
|
||||
bool bTapB, bTapT ;
|
||||
|
||||
pCurve = pToolProfile -> GetPrevCurve() ;
|
||||
|
||||
// Dettagli curva precedente
|
||||
int nPrevType = pCurve -> GetType() ;
|
||||
Point3d ptPrevFirst, ptPrevLast ;
|
||||
pCurve -> GetStartPoint( ptPrevFirst) ;
|
||||
pCurve -> GetEndPoint( ptPrevLast) ;
|
||||
|
||||
double dAbsDYPr = abs( ptPrevFirst.y - ptPrevLast.y) ;
|
||||
double dDeltaXPr = ptPrevFirst.x - ptPrevLast.x ;
|
||||
|
||||
// Setto le variabili per il tappo superiore
|
||||
if ( pCurve == pFirstConst ||
|
||||
nPrevType == CRV_ARC ||
|
||||
( dDeltaXPr < 0 && dAbsDYPr))
|
||||
bTapB = false ;
|
||||
else
|
||||
bTapB = true ;
|
||||
|
||||
// Dettagli curva successiva
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
|
||||
int nNextType = pCurve -> GetType() ;
|
||||
Point3d ptNextFirst ;
|
||||
Point3d ptNextLast ;
|
||||
pCurve -> GetStartPoint( ptNextFirst) ;
|
||||
pCurve -> GetEndPoint( ptNextLast) ;
|
||||
|
||||
double dAbsDYNx = abs( ptNextFirst.y - ptNextLast.y) ;
|
||||
double dDeltaXNx = ptNextFirst.x - ptNextLast.x ;
|
||||
double dAbsXEnd = abs( ptNextLast.x) ;
|
||||
|
||||
if ( pCurve == nullptr ||
|
||||
nNextType == CRV_ARC ||
|
||||
( dAbsDYNx < EPS_SMALL && ( dDeltaXNx > 0 || dAbsXEnd < EPS_SMALL)))
|
||||
|
||||
bTapT = false ;
|
||||
else
|
||||
bTapT = true ;
|
||||
|
||||
// Il componente è un cilindro
|
||||
// Se segmento
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
// Recupero gli estremi
|
||||
const ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptStart = pLine->GetStart() ;
|
||||
Point3d ptEnd = pLine->GetEnd() ;
|
||||
// Ne determino l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
if ( dHeight > EPS_SMALL) {
|
||||
// verifiche curva precedente per eventuale tappo sopra
|
||||
bool bTapT = false ;
|
||||
if ( pPrevCurve != nullptr && pPrevCurve->GetType() == CRV_LINE) {
|
||||
const ICurveLine* pOthLine = GetCurveLine( pPrevCurve) ;
|
||||
Point3d ptOthStart = pOthLine->GetStart() ;
|
||||
Point3d ptOthEnd = pOthLine->GetEnd() ;
|
||||
if ( abs( ptOthStart.y - ptOthEnd.y) < EPS_SMALL && ptOthStart.x < ptOthEnd.x)
|
||||
bTapT = true ;
|
||||
}
|
||||
// verifiche curva successiva per eventuale tappo sotto
|
||||
bool bTapB = false ;
|
||||
const ICurve* pNextCurve = pToolProfile->GetNextCurve() ;
|
||||
if ( pNextCurve != nullptr && pNextCurve->GetType() == CRV_LINE) {
|
||||
const ICurveLine* pOthLine = GetCurveLine( pNextCurve) ;
|
||||
Point3d ptOthStart = pOthLine->GetStart() ;
|
||||
Point3d ptOthEnd = pOthLine->GetEnd() ;
|
||||
if ( abs( ptOthStart.y - ptOthEnd.y) < EPS_SMALL && ptOthStart.x > ptOthEnd.x)
|
||||
bTapB = true ;
|
||||
}
|
||||
// Se X costante, è un cilindro
|
||||
if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) {
|
||||
double dRadius = ptStart.x ;
|
||||
CompCyl_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore equiverso a quello dell'utensile
|
||||
// Se X crescente, è un cono con vettore equiverso a quello dell'utensile
|
||||
else if ( ptStart.x > ptEnd.x) {
|
||||
double dMaxRad = ptStart.x ;
|
||||
double dMinRad = ptEnd.x ;
|
||||
CompConus_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, bTapB, bTapT) ;
|
||||
}
|
||||
|
||||
// Il componente è un cono con vettore opposto a quello dell'utensile
|
||||
// Se X decrescente, è un cono con vettore opposto a quello dell'utensile
|
||||
else if ( ptStart.x < ptEnd.x) {
|
||||
double dMaxRad = ptEnd.x ;
|
||||
double dMinRad = ptStart.x ;
|
||||
Point3d ptIn = ptI - vtToolDir * dHeight ;
|
||||
Point3d ptFn = ptIn + vtMove ;
|
||||
CompConus_Milling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, bTapT, bTapB) ;
|
||||
}
|
||||
}
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
pCurve = pNextCurve ;
|
||||
}
|
||||
|
||||
else {
|
||||
dHeight = 0 ;
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
}
|
||||
|
||||
// Caso arco
|
||||
else if ( nCurveType == CRV_ARC) {
|
||||
|
||||
// Centro e Punti iniziale e finale del cerchio
|
||||
Point3d ptStart, ptEnd, ptO ;
|
||||
|
||||
pCurve -> GetStartPoint( ptStart) ;
|
||||
pCurve -> GetEndPoint( ptEnd) ;
|
||||
pCurve -> GetCenterPoint( ptO) ;
|
||||
|
||||
// Determino il raggio
|
||||
Vector3d vtStRad = ptStart - ptO ;
|
||||
Vector3d vtEnRad = ptEnd - ptO ;
|
||||
|
||||
double dRadius = 0.5 * ( vtStRad.LenXY() + vtEnRad.LenXY()) ;
|
||||
|
||||
// Se arco
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
// Recupero estremi, centro e raggio
|
||||
const ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptStart ; pArc->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pArc->GetEndPoint( ptEnd) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dRadius = pArc->GetRadius() ;
|
||||
// Determino le posizioni iniziale e finale del centro della sfera
|
||||
Point3d ptOSt = ptI - vtToolDir * ( ptStart.y - ptO.y) ;
|
||||
Point3d ptOEn = ptOSt + vtMove ;
|
||||
|
||||
Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ;
|
||||
Point3d ptCenE = ptCenS + vtMove ;
|
||||
// Eseguo l'asportazione del materiale
|
||||
CompBall_Milling( nGrid, ptOSt, ptOEn, dRadius) ;
|
||||
|
||||
CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ;
|
||||
// aggiorno l'altezza
|
||||
dHeight = abs( ptStart.y - ptEnd.y) ;
|
||||
|
||||
pCurve = pToolProfile -> GetNextCurve() ;
|
||||
// Passo alla curva successiva
|
||||
pPrevCurve = pCurve ;
|
||||
pCurve = pToolProfile->GetNextCurve() ;
|
||||
}
|
||||
|
||||
// Determino le posizioni iniziale e finale del componente successivo
|
||||
@@ -3325,18 +3205,15 @@ VolZmap::CompCyl_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Point
|
||||
{
|
||||
// Verifica sull'interferenza con lo Zmap
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool bTest = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
dRad, dRad, dHei) ;
|
||||
|
||||
if ( ! bTest)
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dRad, dRad, dHei) ;
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
// Proiezione dei punti sul piano
|
||||
Point3d ptSxy( ptS.x, ptS.y, 0) ;
|
||||
|
||||
// Parametri geometrici dell'utensile
|
||||
double dSqRad = dRad * dRad ;
|
||||
double dSafeSqRad = dSqRad - 2 * dRad * EPS_SMALL ;
|
||||
double dSafeSqRad = dRad * dRad - 2 * dRad * EPS_SMALL ;
|
||||
|
||||
// Punte del gambo
|
||||
Point3d ptTStemS = ptS - vtToolDir * dHei ;
|
||||
@@ -3350,15 +3227,17 @@ VolZmap::CompCyl_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Point
|
||||
for ( unsigned int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
for ( unsigned int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
|
||||
double dX = ( i + 0.5) * m_dStep ; double dY = ( j + 0.5) * m_dStep ;
|
||||
double dX = ( i + 0.5) * m_dStep ;
|
||||
double dY = ( j + 0.5) * m_dStep ;
|
||||
|
||||
Point3d ptC( dX, dY, 0) ; Vector3d vtC = ptC - ptSxy ;
|
||||
Point3d ptC( dX, dY, 0) ;
|
||||
Vector3d vtC = ptC - ptSxy ;
|
||||
|
||||
double dSqLen = vtC.SqLen() ;
|
||||
|
||||
// Se il punto si trova dentro il cerchio taglio
|
||||
if ( dSqLen < dSafeSqRad)
|
||||
SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, - Z_AX) ;
|
||||
SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, -Z_AX) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
@@ -3370,9 +3249,8 @@ VolZmap::CompConus_ZDrilling( unsigned int nGrid, const Point3d & ptS, const Poi
|
||||
{
|
||||
// Verifica sull'interferenza con lo Zmap
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dMaxRad, dMinRad, dHei) ;
|
||||
|
||||
if ( ! Control)
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dMaxRad, dMinRad, dHei) ;
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
Point3d ptO( ptS.x, ptS.y, 0) ;
|
||||
@@ -3512,9 +3390,8 @@ VolZmap::CompCyl_ZMilling( unsigned int nGrid, const Point3d & ptS, const Point3
|
||||
{
|
||||
// Verifica sull'interferenza con lo Zmap
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool bTest = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dRad, dRad, dHei) ;
|
||||
|
||||
if ( ! bTest)
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dRad, dRad, dHei) ;
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
// Parametri geometrici
|
||||
@@ -3642,9 +3519,8 @@ bool
|
||||
VolZmap::CompConus_ZMilling( unsigned int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad)
|
||||
{
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dMaxRad, dMinRad, dHei) ;
|
||||
|
||||
if ( ! Control)
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ, dMaxRad, dMinRad, dHei) ;
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
Point3d ptI = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) ;
|
||||
@@ -4023,9 +3899,9 @@ VolZmap::CompCyl_Drilling( unsigned int nGrid, const Point3d& ptS, const Point3d
|
||||
double dHei, double dRad, bool bTapB, bool bTapT)
|
||||
{
|
||||
unsigned int nStartI, nEndI, nStartJ, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
dRad, dRad, dHei) ;
|
||||
if ( ! Control)
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
// Studio delle simmetrie
|
||||
@@ -4092,9 +3968,9 @@ VolZmap::CompConus_Drilling( unsigned int nGrid, const Point3d & ptS, const Poin
|
||||
double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT)
|
||||
{
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
dMaxRad, dMinRad, dHei) ;
|
||||
if ( ! Control)
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
// Apertura del cono
|
||||
@@ -4251,9 +4127,9 @@ VolZmap::CompCyl_Milling( unsigned int nGrid, const Point3d& ptS, const Point3d&
|
||||
{
|
||||
// Verifica sull'interferenza utensile Zmap
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptS, ptE, vtToolDir,
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir,
|
||||
nStartI, nStartJ, nEndI, nEndJ, dRad, dRad, dHei) ;
|
||||
if ( ! Control)
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
// Studio delle simmetrie
|
||||
@@ -4404,9 +4280,9 @@ VolZmap::CompConus_Milling( unsigned int nGrid, const Point3d & ptS, const Point
|
||||
double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT)
|
||||
{
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
bool bInterf = BBoxComponent( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ,
|
||||
dMaxRad, dMinRad, dHei) ;
|
||||
if ( ! Control)
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
// Geometria del cono
|
||||
@@ -4941,8 +4817,8 @@ bool
|
||||
VolZmap::CompBall_Milling( unsigned int nGrid, const Point3d & ptLs, const Point3d & ptLe, double dRad)
|
||||
{
|
||||
unsigned int nStartI, nStartJ, nEndI, nEndJ ;
|
||||
bool Control = BBoxComponent( nGrid, ptLs, ptLe, V_NULL, nStartI, nStartJ, nEndI, nEndJ, dRad, 0, 0) ;
|
||||
if ( ! Control)
|
||||
bool bInterf = BBoxComponent( nGrid, ptLs, ptLe, V_NULL, nStartI, nStartJ, nEndI, nEndJ, dRad, 0, 0) ;
|
||||
if ( ! bInterf)
|
||||
return true ;
|
||||
|
||||
Vector3d vtV = ptLe - ptLs ;
|
||||
|
||||
Reference in New Issue
Block a user