EgtMachKernel :
- in SawRoughing e SawFinishing aggiunti controlli per parametro "Extend" - in SawRoughing e SawFinishing affinata la gestione del grezzo.
This commit is contained in:
@@ -63,7 +63,7 @@ static const std::string UN_FEND = "Fend" ;
|
||||
static const std::string UN_SWE = "SWE" ;
|
||||
static const std::string UN_EWE = "EWE" ;
|
||||
|
||||
// Solo per SawFinishing
|
||||
// Solo per SawFinishing e SawRoughing
|
||||
static const std::string UN_EXTEND = "Extend" ;
|
||||
|
||||
// Solo per SurfFinishing
|
||||
|
||||
+270
-58
@@ -24,10 +24,15 @@
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkSurfLocal.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurveOnX.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EGkPolygonElevation.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
@@ -1021,7 +1026,7 @@ SawFinishing::AdjustGeometry( int nAuxId)
|
||||
Point3d ptStStart, ptGdStart ;
|
||||
if ( ! vpSects[0]->GetStartPoint( ptStStart) ||
|
||||
! pGuide->GetStartPoint( ptGdStart) ||
|
||||
( ptGdStart - ptStStart) * vtGdDir > 10 * EPS_SMALL)
|
||||
abs( ( ptGdStart - ptStStart) * vtGdDir) > 10 * EPS_SMALL)
|
||||
return false ;
|
||||
// creo sottogruppo di ausiliario per le sezioni con riferimento avente
|
||||
// l'origine nel punto di inizio della guida e la Z opposta alla direzione della guida
|
||||
@@ -1082,7 +1087,7 @@ SawFinishing::CalculateStraightAlongToolPath( int nAuxId, int nClId)
|
||||
Point3d ptGdStart, ptGdEnd ;
|
||||
Vector3d vtGdDir ;
|
||||
int nGuideId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nAuxId, MCH_GUIDE)) ;
|
||||
if ( ! CalculateGuideLine( nGuideId, b3Sect, bExtend, ptGdStart, ptGdEnd, vtGdDir))
|
||||
if ( ! CalculateGuideLine( nGuideId, pSect, ptGdStart, ptGdEnd, vtGdDir, nSectGrpId, false))
|
||||
return false ;
|
||||
if ( m_Params.m_bInvert) {
|
||||
swap( ptGdStart, ptGdEnd) ;
|
||||
@@ -1133,6 +1138,34 @@ SawFinishing::CalculateStraightAlongToolPath( int nAuxId, int nClId)
|
||||
// assegno il vettore estrazione al gruppo del percorso
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ;
|
||||
|
||||
// recupero la TriMesh del grezzo in globale
|
||||
PtrOwner<ISurfTriMesh> pStmRaw( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pStmRaw))
|
||||
return false ;
|
||||
pStmRaw->AdjustTopology() ;
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
while ( nRawId != GDB_ID_NULL) {
|
||||
// verifico che il grezzo compaia nella fase
|
||||
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, m_nPhase)) {
|
||||
// recupero l'oggetto dal database con tale Id
|
||||
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( nRawSolidId) ;
|
||||
if ( pGObj != nullptr) {
|
||||
// recupero il frame in cui si trova
|
||||
Frame3d frRaw ;
|
||||
m_pGeomDB->GetGlobFrame( nRawSolidId, frRaw) ;
|
||||
// controllo che sia una Trimesh
|
||||
if ( pGObj->GetType() == SRF_TRIMESH) {
|
||||
SurfLocal StmRawPart( GetSurfTriMesh( pGObj), frRaw, GLOB_FRM) ;
|
||||
// lo aggiungo alla Trimesh complessiva
|
||||
pStmRaw->Add( *GetSurfTriMesh( StmRawPart)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// passo al grezzo successivo
|
||||
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
|
||||
}
|
||||
|
||||
// Classifico i tratti a seconda della pendenza (salita, discesa, verticale, orizzontale)
|
||||
INTVECTOR vnClass ;
|
||||
ClassifySection( pCrv, vnClass) ;
|
||||
@@ -1153,9 +1186,8 @@ SawFinishing::CalculateStraightAlongToolPath( int nAuxId, int nClId)
|
||||
if ( ( vnClass[i] != CCL_VERT && vnClass[i] != CCL_SMALL) || i == vnClass.size() - 1) {
|
||||
if ( nUmin >= 0) {
|
||||
// eseguo la passata
|
||||
if ( ! CalcAlongVerticalCuts( pCrv, nUmin, nUmax, frSect, bExtend,
|
||||
ptGdStart, ptGdEnd, vtGdDir,
|
||||
dDepth, b3Raw.GetMax().z, vtTool, vtCorr))
|
||||
if ( ! CalcAlongVerticalCuts( pCrv, nUmin, nUmax, frSect, bExtend, ptGdStart, ptGdEnd, vtGdDir, dDepth, b3Raw.GetMax().z,
|
||||
vtTool, vtCorr, pStmRaw))
|
||||
return false ;
|
||||
nUmin = - 1 ;
|
||||
}
|
||||
@@ -1192,9 +1224,8 @@ SawFinishing::CalculateStraightAlongToolPath( int nAuxId, int nClId)
|
||||
bSkipMax = ( vnClass[i] == CCL_VERT) ;
|
||||
bool bInvert = ( nStatus == CCL_RISE) ;
|
||||
if ( ! CalcAlongStdCuts( pCrv, nUmin, nUmax,
|
||||
bSkipMin, bSkipMax, bInvert, frSect, bExtend,
|
||||
ptGdStart, ptGdEnd, vtGdDir,
|
||||
dDepth, b3Raw.GetMax().z, vtTool, vtCorr))
|
||||
bSkipMin, bSkipMax, bInvert, frSect, bExtend, ptGdStart, ptGdEnd, vtGdDir, dDepth, b3Raw.GetMax().z,
|
||||
vtTool, vtCorr, pStmRaw))
|
||||
return false ;
|
||||
// aggiorno stato
|
||||
if ( vnClass[i] == CCL_VERT)
|
||||
@@ -1212,10 +1243,8 @@ SawFinishing::CalculateStraightAlongToolPath( int nAuxId, int nClId)
|
||||
if ( nStatus != CCL_VERT) {
|
||||
bSkipMax = false ;
|
||||
bool bInvert = ( nStatus == CCL_RISE) ;
|
||||
if ( ! CalcAlongStdCuts( pCrv, nUmin, nUmax,
|
||||
bSkipMin, bSkipMax, bInvert, frSect, bExtend,
|
||||
ptGdStart, ptGdEnd, vtGdDir,
|
||||
dDepth, b3Raw.GetMax().z, vtTool, vtCorr))
|
||||
if ( ! CalcAlongStdCuts( pCrv, nUmin, nUmax, bSkipMin, bSkipMax, bInvert, frSect, bExtend, ptGdStart, ptGdEnd, vtGdDir, dDepth,
|
||||
b3Raw.GetMax().z, vtTool, vtCorr, pStmRaw))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1248,7 +1277,7 @@ SawFinishing::CalculateStraightAcrossToolPath( int nAuxId, int nClId)
|
||||
Point3d ptGdStart, ptGdEnd ;
|
||||
Vector3d vtGdDir ;
|
||||
int nGuideId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nAuxId, MCH_GUIDE)) ;
|
||||
if ( ! CalculateGuideLine( nGuideId, b3Sect, bExtend, ptGdStart, ptGdEnd, vtGdDir))
|
||||
if ( ! CalculateGuideLine( nGuideId, pSect, ptGdStart, ptGdEnd, vtGdDir, nSectGrpId, bExtend))
|
||||
return false ;
|
||||
Vector3d vtDeltaSect = vtGdDir * ( vtGdDir * ( ptGdStart - frSect.Orig())) ;
|
||||
if ( m_Params.m_bInvert) {
|
||||
@@ -1861,8 +1890,173 @@ SawFinishing::TrimSection( ICurve* pCrv)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawFinishing::CalculateGuideLine( int nGuideId, const BBox3d& b3Sect, bool bExtend,
|
||||
Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir)
|
||||
SawFinishing::AdaptGuideLineToRaw( Point3d& ptGdStart, Point3d& ptGdEnd, const Vector3d& vtGdDir, bool bExtend, const ISurfTriMesh* pStmRaw) const
|
||||
{
|
||||
// se non richiesta estensione, non faccio nulla
|
||||
if ( ! bExtend)
|
||||
return true ;
|
||||
// se grezzo non presente, non faccio nulla
|
||||
if ( pStmRaw == nullptr || ! pStmRaw->IsValid() || pStmRaw->GetTriangleCount() == 0)
|
||||
return true ;
|
||||
|
||||
// calcolo l'intersezione tra la linea corrente e la superficie del grezzo per prolungare l'entrata
|
||||
const double LINE_LEN = 1e5 ;
|
||||
const double COS_SMALL = sin( EPS_ANG_SMALL * DEGTORAD) ;
|
||||
ILSIVECTOR vInfo ;
|
||||
if ( ! IntersLineSurfTm( ptGdStart, - vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
Point3d ptNewStart = ptGdStart ;
|
||||
// se esistono intersezioni, cerco la prima uscente dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed esco dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN > COS_SMALL) {
|
||||
ptNewStart = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non esistono intersezioni e il tipo di prolungamento non richiede il collegamento, devo solo verificare
|
||||
// che non ci siano parti nel vuoto
|
||||
else {
|
||||
vInfo.clear() ;
|
||||
if ( ! IntersLineSurfTm( ptGdStart, vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
// se esistono intersezioni, cerco la prima entrante dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed entro dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN < - COS_SMALL) {
|
||||
ptNewStart = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calcolo l'interszione tra la linea corrente e la superficie del grezzo per prolungare l'uscita
|
||||
if ( ! IntersLineSurfTm( ptGdEnd, vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
Point3d ptNewEnd = ptGdEnd ;
|
||||
// se esistono intersezioni, cerco la prima cerco la prima uscente dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed esco dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO) {
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN > COS_SMALL) {
|
||||
ptNewEnd = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non esistono intersezioni e il tipo di collegamento non richiede allungamento devo solo verificare che
|
||||
// non ci siano parti nel vuoto
|
||||
else {
|
||||
vInfo.clear() ;
|
||||
if ( ! IntersLineSurfTm( ptGdEnd, - vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
// se esitono intersezioni, cerco la prima entrante dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed entro dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN < - COS_SMALL) {
|
||||
ptNewEnd = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// assegno i valori trovati
|
||||
ptGdStart = ptNewStart ;
|
||||
ptGdEnd = ptNewEnd ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawFinishing::CalculateSectElevation( const Polygon3d& pgFacet, double& dElev) const
|
||||
{
|
||||
// verifico che il poligono sia valido
|
||||
if ( ! pgFacet.IsValid())
|
||||
return true ;
|
||||
dElev = 0. ;
|
||||
|
||||
// inizializzo elevazioni per ogni grezzo
|
||||
INTDBLVECTOR vRawElev ;
|
||||
// ciclo sui grezzi della fase
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
while ( nRawId != GDB_ID_NULL) {
|
||||
// verifico che il grezzo compaia nella fase
|
||||
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, m_nPhase)) {
|
||||
// recupero la trimesh del grezzo
|
||||
int nStmId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( m_pGeomDB->GetGeoObj( nStmId)) ;
|
||||
if ( pStm != nullptr) {
|
||||
// recupero il riferimento della trimesh
|
||||
Frame3d frStm ;
|
||||
m_pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||
// porto il poligono in questo riferimento
|
||||
Polygon3d pgFacetL = pgFacet ;
|
||||
pgFacetL.ToLoc( frStm) ;
|
||||
// calcolo l'elevazione iniziale
|
||||
double dCurrElev = 0. ;
|
||||
if ( ! PolygonElevationInClosedSurfTm( pgFacetL, *pStm, true, dCurrElev))
|
||||
return false ;
|
||||
if ( dCurrElev > EPS_SMALL)
|
||||
vRawElev.emplace_back( nStmId, dCurrElev) ;
|
||||
}
|
||||
}
|
||||
// passo al grezzo successivo
|
||||
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
|
||||
}
|
||||
|
||||
// se trovate elevazioni
|
||||
if ( ! vRawElev.empty()) {
|
||||
// ordino il vettore secondo l'elevazione crescente
|
||||
sort( vRawElev.begin(), vRawElev.end(), []( const INTDBL& a, const INTDBL& b) { return a.second < b.second ; }) ;
|
||||
// box dell'insieme delle posizioni utensile all'inizioe
|
||||
const double MAX_DIST_RAW = 200.0 ;
|
||||
BBox3d b3Tool ;
|
||||
pgFacet.GetLocalBBox( b3Tool) ;
|
||||
Vector3d vtDir = pgFacet.GetVersN() ;
|
||||
b3Tool.Add( b3Tool.GetMin() + m_TParams.m_dLen * vtDir) ;
|
||||
b3Tool.Add( b3Tool.GetMax() + m_TParams.m_dLen * vtDir) ;
|
||||
if ( vtDir.IsX())
|
||||
b3Tool.Expand( 0, m_TParams.m_dDiam / 2., m_TParams.m_dDiam / 2.) ;
|
||||
else if ( vtDir.IsY())
|
||||
b3Tool.Expand( m_TParams.m_dDiam / 2., 0., m_TParams.m_dDiam / 2.) ;
|
||||
else if ( vtDir.IsZ())
|
||||
b3Tool.Expand( m_TParams.m_dDiam / 2., m_TParams.m_dDiam / 2., 0.) ;
|
||||
else {
|
||||
double dExpandX = ( m_TParams.m_dDiam / 2.) * sqrt( 1. - vtDir.x * vtDir.x) ;
|
||||
double dExpandY = ( m_TParams.m_dDiam / 2.) * sqrt( 1. - vtDir.y * vtDir.y) ;
|
||||
double dExpandZ = ( m_TParams.m_dDiam / 2.) * sqrt( 1. - vtDir.z * vtDir.z) ;
|
||||
b3Tool.Expand( dExpandX, dExpandY, dExpandZ) ;
|
||||
}
|
||||
b3Tool.Expand( MAX_DIST_RAW) ;
|
||||
// verifico la reale interferenza dell'utensile con i diversi grezzi
|
||||
for ( int i = 0 ; i < int( vRawElev.size()) ; ++ i) {
|
||||
// box del grezzo
|
||||
BBox3d b3Raw ;
|
||||
m_pGeomDB->GetGlobalBBox( vRawElev[i].first, b3Raw) ;
|
||||
// confronto con il box dell'utensile nella posizione precedente
|
||||
BBox3d b3CurrTool = b3Tool ;
|
||||
b3CurrTool.Translate( dElev * vtDir) ;
|
||||
if ( b3Raw.Overlaps( b3CurrTool))
|
||||
dElev = vRawElev[i].second ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawFinishing::CalculateGuideLine( int nGuideId, const ICurve* pSect, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir,
|
||||
int nSectGrpId, bool bExtendToRawBox) const
|
||||
{
|
||||
// recupero la linea guida
|
||||
ICurve* pGuide = ::GetCurve( m_pGeomDB->GetGeoObj( nGuideId)) ;
|
||||
@@ -1878,46 +2072,55 @@ SawFinishing::CalculateGuideLine( int nGuideId, const BBox3d& b3Sect, bool bExte
|
||||
pGuide->GetEndPoint( ptGdEnd) ;
|
||||
// recupero la direzione della linea guida
|
||||
pGuide->GetStartDir( vtGdDir) ;
|
||||
// se non va estesa al limite del grezzo, posso uscire
|
||||
if ( ! bExtend)
|
||||
return true ;
|
||||
// non esteso, quindi ammesse solo linee guida (rettilinee) dirette lungo X o Y
|
||||
if ( ! AreSameOrOppositeVectorApprox( vtGdDir, X_AX) &&
|
||||
! AreSameOrOppositeVectorApprox( vtGdDir, Y_AX)) {
|
||||
m_pMchMgr->SetLastError( 2707, "Error in SawFinishing : Guide Line not along X or Y") ;
|
||||
return false ;
|
||||
}
|
||||
// recupero il box globale della linea guida
|
||||
BBox3d b3Guide ;
|
||||
m_pGeomDB->GetGlobalBBox( nGuideId, b3Guide) ;
|
||||
|
||||
// recupero il box del grezzo in globale
|
||||
BBox3d b3Test ;
|
||||
b3Test.Add( b3Sect) ;
|
||||
b3Test.Add( b3Guide) ;
|
||||
BBox3d b3Raw ;
|
||||
if ( ! GetRawGlobBox( m_nPhase, b3Test, 10 * EPS_SMALL, b3Raw) || b3Raw.IsEmpty()) {
|
||||
m_pMchMgr->SetLastError( 2703, "Error in SawFinishing : Empty RawBox") ;
|
||||
return false ;
|
||||
// se richiesta estensione lungo il Box
|
||||
if ( bExtendToRawBox) {
|
||||
// recupero le sezioni
|
||||
ICURVEPVECTOR vpSects ;
|
||||
int nSectId = m_pGeomDB->GetFirstInGroup( nSectGrpId) ;
|
||||
while ( nSectId != GDB_ID_NULL) {
|
||||
vpSects.emplace_back( ::GetCurve( m_pGeomDB->GetGeoObj( nSectId))) ;
|
||||
if ( vpSects.back() == nullptr)
|
||||
return false ;
|
||||
nSectId = m_pGeomDB->GetNext( nSectId) ;
|
||||
}
|
||||
// per ogni sezione calcolo eventuale elevazione
|
||||
for ( const ICurve* pCrvSect : vpSects) {
|
||||
// applico offset radiale
|
||||
OffsetCurve OffsCrv ;
|
||||
OffsCrv.Make( pCrvSect, GetOffsR(), ICurve::OFF_FILLET) ;
|
||||
PtrOwner<ICurve> pSectOffsR( OffsCrv.GetLongerCurve()) ;
|
||||
if ( ! IsNull( pSectOffsR) && pSectOffsR->IsValid()) {
|
||||
// porto la sezione in globale
|
||||
Frame3d frSect ;
|
||||
m_pGeomDB->GetGroupGlobFrame( nSectGrpId, frSect) ;
|
||||
pSectOffsR->ToGlob( frSect) ;
|
||||
// approssimo la curva con una polilinea che uso per creare il poligono equivalente
|
||||
PolyLine PL ;
|
||||
if ( ! pSectOffsR->ApproxWithLines( LIN_TOL_RAW, ANG_TOL_MAX_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return false ;
|
||||
Polygon3d pgFacet ;
|
||||
if ( ! pgFacet.FromPolyLine( PL))
|
||||
return false ;
|
||||
// calcolo l'estensione della guida fino alla proiezione in eccesso del grezzo
|
||||
double dSectStartElev = 0. ;
|
||||
if ( ! CalculateSectElevation( pgFacet, dSectStartElev))
|
||||
return false ;
|
||||
// calcolo l'estensione della guida fino alla proiezione in eccesso del grezzo
|
||||
pgFacet.Translate( ptGdEnd - ptGdStart) ;
|
||||
pgFacet.Invert() ;
|
||||
double dSectEndElev = 0. ;
|
||||
if ( ! CalculateSectElevation( pgFacet, dSectEndElev))
|
||||
return false ;
|
||||
// estendo la guida delle quantità calcolate
|
||||
if ( dSectStartElev > EPS_SMALL)
|
||||
ptGdStart -= ( vtGdDir * dSectStartElev) ;
|
||||
if ( dSectEndElev > EPS_SMALL)
|
||||
ptGdEnd += ( vtGdDir * dSectEndElev) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aggiusto la linea guida al bordo del box
|
||||
if ( AreSameVectorApprox( vtGdDir, X_AX)) {
|
||||
ptGdStart.x = b3Raw.GetMin().x ;
|
||||
ptGdEnd.x = b3Raw.GetMax().x ;
|
||||
}
|
||||
else if ( AreOppositeVectorApprox( vtGdDir, X_AX)) {
|
||||
ptGdStart.x = b3Raw.GetMax().x ;
|
||||
ptGdEnd.x = b3Raw.GetMin().x ;
|
||||
}
|
||||
else if ( AreSameVectorApprox( vtGdDir, Y_AX)) {
|
||||
ptGdStart.y = b3Raw.GetMin().y ;
|
||||
ptGdEnd.y = b3Raw.GetMax().y ;
|
||||
}
|
||||
else {
|
||||
ptGdStart.y = b3Raw.GetMax().y ;
|
||||
ptGdEnd.y = b3Raw.GetMin().y ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1968,8 +2171,8 @@ SawFinishing::ClassifySection( ICurve* pCrv, INTVECTOR& vnClass)
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawFinishing::CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const Frame3d& frSect, bool bExtend,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
|
||||
double dDepth, double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr)
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir, double dDepth,
|
||||
double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr, const ISurfTriMesh* pStmRaw)
|
||||
{
|
||||
// Ingombro del taglio
|
||||
BBox3d b3Cut ;
|
||||
@@ -1999,6 +2202,11 @@ SawFinishing::CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const
|
||||
Vector3d vtMove = dX * frSect.VersX() + dY * frSect.VersY() - 0.5 * m_TParams.m_dThick * vtTool ;
|
||||
Point3d ptStart = ptGdStart + vtMove ;
|
||||
Point3d ptEnd = ptGdEnd + vtMove ;
|
||||
// verifico eventuale estensione degli estremi sul grezzo
|
||||
if ( bExtend) {
|
||||
if ( ! AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, bExtend, pStmRaw))
|
||||
return false ;
|
||||
}
|
||||
// determino l'elevazione del taglio
|
||||
Vector3d vtThick = vtTool * m_TParams.m_dThick ;
|
||||
double dElev, dElev2 ;
|
||||
@@ -2050,10 +2258,9 @@ SawFinishing::CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawFinishing::CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
|
||||
bool bSkipMin, bool bSkipMax, bool bInvert, const Frame3d& frSect, bool bExtend,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
|
||||
double dDepth, double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr)
|
||||
SawFinishing::CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax, bool bSkipMin, bool bSkipMax, bool bInvert, const Frame3d& frSect,
|
||||
bool bExtend, const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir, double dDepth,
|
||||
double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr, const ISurfTriMesh* pStmRaw)
|
||||
{
|
||||
// Calcolo dello step tra le passate
|
||||
double dStep = max( m_Params.m_dSideStep, 10 * EPS_SMALL) ;
|
||||
@@ -2086,6 +2293,11 @@ SawFinishing::CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
|
||||
Vector3d vtMove = ptP.x * frSect.VersX() + ptP.y * frSect.VersY() - 0.5 * m_TParams.m_dThick * vtTool ;
|
||||
Point3d ptStart = ptGdStart + vtMove ;
|
||||
Point3d ptEnd = ptGdEnd + vtMove ;
|
||||
// verifico eventuale estensione degli estremi sul grezzo
|
||||
if ( bExtend) {
|
||||
if ( ! AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, bExtend, pStmRaw))
|
||||
return false ;
|
||||
}
|
||||
// determino l'elevazione del taglio
|
||||
Vector3d vtThick = vtTool * m_TParams.m_dThick ;
|
||||
double dElev, dElev2 ;
|
||||
|
||||
+12
-9
@@ -22,6 +22,8 @@ class ICurve ;
|
||||
class ICurveLine ;
|
||||
class ICurveArc ;
|
||||
class ICurveComposite ;
|
||||
class ISurfTriMesh ;
|
||||
class Polygon3d ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class SawFinishing : public Machining
|
||||
@@ -85,16 +87,17 @@ class SawFinishing : public Machining
|
||||
bool CalculateCurvedAcrossToolPath( int nAuxId, int nClId) ;
|
||||
bool CalculateSection( int nSectGrpId, ICurve*& pSect) ;
|
||||
bool TrimSection( ICurve* pCrv) ;
|
||||
bool CalculateGuideLine( int nGuideId, const BBox3d& b3Sect, bool bExtend,
|
||||
Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir) ;
|
||||
bool AdaptGuideLineToRaw( Point3d& ptGdStart, Point3d& ptGdEnd, const Vector3d& vtGdDir, bool bExtend, const ISurfTriMesh* pStmRaw) const ;
|
||||
bool CalculateSectElevation( const Polygon3d& pgFacet, double& dElev) const ;
|
||||
bool CalculateGuideLine( int nGuideId, const ICurve* pSect, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir,
|
||||
int nSectGrpId, bool bExtendToRawBox) const ;
|
||||
bool ClassifySection( ICurve* pCrv, INTVECTOR& vnClass) ;
|
||||
bool CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const Frame3d& frSect, bool bExtend,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
|
||||
double dDepth, double dRaxMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr) ;
|
||||
bool CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax,
|
||||
bool bSkipMin, bool bSkipMax, bool bInvert, const Frame3d& frSect, bool bExtend,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir,
|
||||
double dDepth, double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr) ;
|
||||
bool CalcAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, const Frame3d& frSect, bool bExtend, const Point3d& ptGdStart,
|
||||
const Point3d& ptGdEnd, const Vector3d& vtGdDir, double dDepth, double dRaxMaxZ,
|
||||
const Vector3d& vtTool, const Vector3d& vtCorr, const ISurfTriMesh* pStmRaw) ;
|
||||
bool CalcAlongStdCuts( ICurve* pSect, double dUmin, double dUmax, bool bSkipMin, bool bSkipMax, bool bInvert, const Frame3d& frSect,
|
||||
bool bExtend, const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir, double dDepth,
|
||||
double dRawMaxZ, const Vector3d& vtTool, const Vector3d& vtCorr, const ISurfTriMesh* pStmRaw) ;
|
||||
bool CalcAlongOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
|
||||
const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bExtend, bool bVert) ;
|
||||
bool CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
|
||||
|
||||
+142
-81
@@ -17,18 +17,21 @@
|
||||
#include "DllMain.h"
|
||||
#include "SawRoughing.h"
|
||||
#include "OperationConst.h"
|
||||
#include "OperUserNotesConst.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EXeCmdLogOff.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfLocal.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurveOnX.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
// per far dimenticare macro di WinUser.h
|
||||
@@ -1086,11 +1089,16 @@ SawRoughing::CalculateToolPath( int nAuxId, int nPvId, int nClId)
|
||||
BBox3d b3Sect ;
|
||||
m_pGeomDB->GetGlobalBBox( nSectGrpId, b3Sect) ;
|
||||
|
||||
// Recupero da UserNotes il flag di estensione al bordo del grezzo
|
||||
bool bExtend ;
|
||||
if ( ! GetValInNotes( m_Params.m_sUserNotes, UN_EXTEND, bExtend))
|
||||
bExtend = true ;
|
||||
|
||||
// Recupero ed elaboro la linea guida
|
||||
Point3d ptGdStart, ptGdEnd ;
|
||||
Vector3d vtGdDir ;
|
||||
int nGuideId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstNameInGroup( nAuxId, MCH_GUIDE)) ;
|
||||
if ( ! CalculateGuideLine( nGuideId, b3Sect, ptGdStart, ptGdEnd, vtGdDir))
|
||||
if ( ! CalculateGuideLine( nGuideId, ptGdStart, ptGdEnd, vtGdDir))
|
||||
return false ;
|
||||
// recupero il box globale della linea guida
|
||||
BBox3d b3Guide ;
|
||||
@@ -1161,6 +1169,34 @@ SawRoughing::CalculateToolPath( int nAuxId, int nPvId, int nClId)
|
||||
// assegno il vettore estrazione al gruppo del percorso
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ;
|
||||
|
||||
// recupero la TriMesh del grezzo in globale
|
||||
PtrOwner<ISurfTriMesh> pStmRaw( CreateSurfTriMesh()) ;
|
||||
if ( IsNull( pStmRaw))
|
||||
return false ;
|
||||
pStmRaw->AdjustTopology() ;
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
while ( nRawId != GDB_ID_NULL) {
|
||||
// verifico che il grezzo compaia nella fase
|
||||
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, m_nPhase)) {
|
||||
// recupero l'oggetto dal database con tale Id
|
||||
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( nRawSolidId) ;
|
||||
if ( pGObj != nullptr) {
|
||||
// recupero il frame in cui si trova
|
||||
Frame3d frRaw ;
|
||||
m_pGeomDB->GetGlobFrame( nRawSolidId, frRaw) ;
|
||||
// controllo che sia una Trimesh
|
||||
if ( pGObj->GetType() == SRF_TRIMESH) {
|
||||
SurfLocal StmRawPart( GetSurfTriMesh( pGObj), frRaw, GLOB_FRM) ;
|
||||
// lo aggiungo alla Trimesh complessiva
|
||||
pStmRaw->Add( *GetSurfTriMesh( StmRawPart)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// passo al grezzo successivo
|
||||
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
|
||||
}
|
||||
|
||||
// Determino eventuali pareti verticali ( sono in senso decrescente di X)
|
||||
DBLVECTOR vdVr ;
|
||||
DBLVECTOR vdVrDelta ;
|
||||
@@ -1175,7 +1211,7 @@ SawRoughing::CalculateToolPath( int nAuxId, int nPvId, int nClId)
|
||||
if ( abs( ptEnd.x - ptStart.x) < EPS_SMALL) {
|
||||
double dX = ( ptEnd.x + ptStart.x) / 2 ;
|
||||
if ( dX < dPrevX - EPS_SMALL) {
|
||||
vdVr.push_back( dX) ;
|
||||
vdVr.push_back( dX) ;
|
||||
vdVrDelta.push_back( ptEnd.y - ptStart.y) ;
|
||||
dPrevX = dX ;
|
||||
}
|
||||
@@ -1235,27 +1271,27 @@ SawRoughing::CalculateToolPath( int nAuxId, int nPvId, int nClId)
|
||||
int nCount = 0 ;
|
||||
for ( int j = 1 ; j < int( vdPp.size()) ; ++ j) {
|
||||
double dXmax = vdPp[j-1] ;
|
||||
double dXmin = vdPp[j] ;
|
||||
double dXmin = vdPp[j] ;
|
||||
|
||||
if ( m_Params.m_nStepType == SAWROU_ST_ZCONST) {
|
||||
// le pareti verticali vanno trattate nell'intervallo della quota più bassa
|
||||
bool bIncludeMax = ( vdPDelta[j-1] < EPS_SMALL) ;
|
||||
bool bIncludeMin = ( vdPDelta[j] > - EPS_SMALL) ;
|
||||
bool bIncludeMin = ( vdPDelta[j] > - EPS_SMALL) ;
|
||||
// verifico se devo trattare l'estremo a dXmax singolarmente
|
||||
if ( j == 1 && ! bIncludeMax) {
|
||||
if ( ! CalculateZConstCut( pCrv, dXmax, dXmax, true, false, ptGdStart, ptGdEnd, vtGdDir, frSect, b3Raw, dMaxDepth,
|
||||
if ( ! CalculateZConstCut( pCrv, dXmax, dXmax, true, false, ptGdStart, ptGdEnd, vtGdDir, frSect, pStmRaw, b3Raw, bExtend, dMaxDepth,
|
||||
true, false, nCount))
|
||||
return false ;
|
||||
}
|
||||
// tratto l'intervallo
|
||||
bool bFirstInterval = ( j == 1) && bIncludeMax ;
|
||||
bool bLastInterval = ( j == vdPp.size() - 1) && bIncludeMin ;
|
||||
if ( ! CalculateZConstCut( pCrv, dXmin, dXmax, bIncludeMax, bIncludeMin, ptGdStart, ptGdEnd, vtGdDir, frSect, b3Raw, dMaxDepth,
|
||||
bool bLastInterval = ( j == vdPp.size() - 1) && bIncludeMin ;
|
||||
if ( ! CalculateZConstCut( pCrv, dXmin, dXmax, bIncludeMax, bIncludeMin, ptGdStart, ptGdEnd, vtGdDir, frSect, pStmRaw, b3Raw, bExtend, dMaxDepth,
|
||||
bFirstInterval, bLastInterval, nCount))
|
||||
return false ;
|
||||
// verifico se devo trattare l'estremo a dXmin singolarmente
|
||||
if ( j == vdPp.size() - 1 && ! bIncludeMin) {
|
||||
if ( ! CalculateZConstCut( pCrv, dXmin, dXmin, false, true, ptGdStart, ptGdEnd, vtGdDir, frSect, b3Raw, dMaxDepth,
|
||||
if ( j == vdPp.size() - 1 && ! bIncludeMin) {
|
||||
if ( ! CalculateZConstCut( pCrv, dXmin, dXmin, false, true, ptGdStart, ptGdEnd, vtGdDir, frSect, pStmRaw, b3Raw, bExtend, dMaxDepth,
|
||||
false, true, nCount))
|
||||
return false ;
|
||||
}
|
||||
@@ -1284,12 +1320,12 @@ SawRoughing::CalculateToolPath( int nAuxId, int nPvId, int nClId)
|
||||
Point3d ptStart = ptGdStart + vtMove ;
|
||||
Point3d ptEnd = ptGdEnd + vtMove ;
|
||||
// adatto la guida corrente al grezzo
|
||||
AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, b3Raw) ;
|
||||
AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, bExtend, pStmRaw) ;
|
||||
// determino l'elevazione del taglio
|
||||
Vector3d vtThick = vtTool * m_TParams.m_dThick ;
|
||||
double dElev, dElev2 ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart, ptEnd, vtCorr, dElev) ||
|
||||
! GetElevation( m_nPhase, ptStart + vtThick, ptEnd + vtThick, vtCorr, dElev2) ) {
|
||||
! GetElevation( m_nPhase, ptStart + vtThick, ptEnd + vtThick, vtCorr, dElev2) ) {
|
||||
m_pMchMgr->SetLastError( 2609, "Error in SawRoughing : GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1312,8 +1348,8 @@ SawRoughing::CalculateToolPath( int nAuxId, int nPvId, int nClId)
|
||||
if ( ! CalculateZigZagCut( ptStart, ptEnd, vtGdDir, vtTool, vtCorr, dElev, bFirst, bLast, nCount, b3Raw))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1516,7 +1552,7 @@ SawRoughing::CalculateSection( int nSectGrpId, ICurve*& pSect)
|
||||
if ( vpSects.back() == nullptr)
|
||||
return false ;
|
||||
// passo alla successiva
|
||||
nSectId = m_pGeomDB->GetNext( nSectId) ;
|
||||
nSectId = m_pGeomDB->GetNext( nSectId) ;
|
||||
}
|
||||
|
||||
// elimino eventuali sottosquadra
|
||||
@@ -1597,7 +1633,7 @@ SawRoughing::CalculateSection( int nSectGrpId, ICurve*& pSect)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawRoughing::TrimSection( ICurve* pCrv)
|
||||
SawRoughing::TrimSection( ICurve* pCrv) const
|
||||
{
|
||||
// se parametri di accorciamento iniziale e finale sono nulli, non faccio alcunché
|
||||
if ( m_Params.m_dStartAddLen > - EPS_SMALL && m_Params.m_dEndAddLen > -EPS_SMALL)
|
||||
@@ -1642,7 +1678,7 @@ SawRoughing::TrimSection( ICurve* pCrv)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawRoughing::CalculateGuideLine( int nGuideId, const BBox3d& b3Sect, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir)
|
||||
SawRoughing::CalculateGuideLine( int nGuideId, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir) const
|
||||
{
|
||||
// recupero la linea guida
|
||||
ICurve* pGuide = ::GetCurve( m_pGeomDB->GetGeoObj( nGuideId)) ;
|
||||
@@ -1658,68 +1694,87 @@ SawRoughing::CalculateGuideLine( int nGuideId, const BBox3d& b3Sect, Point3d& pt
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawRoughing::AdaptGuideLineToRaw( Point3d& ptGdStart, Point3d& ptGdEnd, const Vector3d& vtGdDir, const BBox3d& b3Raw) const
|
||||
SawRoughing::AdaptGuideLineToRaw( Point3d& ptGdStart, Point3d& ptGdEnd, const Vector3d& vtGdDir, bool bExtend, const ISurfTriMesh* pStmRaw) const
|
||||
{
|
||||
// se il tipo di collegamento non richiede allungamento devo solo verificare che non ci siano parti nel vuoto
|
||||
if ( m_Params.m_nLeadLinkType == SAWROU_LL_INT) {
|
||||
// se guida allineata con asse
|
||||
if ( AreSameVectorApprox( vtGdDir, X_AX)) {
|
||||
ptGdStart.x = max( b3Raw.GetMin().x, ptGdStart.x) ;
|
||||
ptGdEnd.x = min( b3Raw.GetMax().x, ptGdEnd.x) ;
|
||||
}
|
||||
else if ( AreOppositeVectorApprox( vtGdDir, X_AX)) {
|
||||
ptGdStart.x = min( b3Raw.GetMax().x, ptGdStart.x) ;
|
||||
ptGdEnd.x = max( b3Raw.GetMin().x, ptGdEnd.x) ;
|
||||
}
|
||||
else if ( AreSameVectorApprox( vtGdDir, Y_AX)) {
|
||||
ptGdStart.y = max( b3Raw.GetMin().y, ptGdStart.y) ;
|
||||
ptGdEnd.y = min( b3Raw.GetMax().y, ptGdEnd.y) ;
|
||||
}
|
||||
else if ( AreOppositeVectorApprox( vtGdDir, Y_AX)) {
|
||||
ptGdStart.y = min( b3Raw.GetMax().y, ptGdStart.y) ;
|
||||
ptGdEnd.y = max( b3Raw.GetMin().y, ptGdEnd.y) ;
|
||||
}
|
||||
// se direzione generica
|
||||
else {
|
||||
INTDBLVECTOR vInters ;
|
||||
IntersLineBox( ptGdStart, ptGdEnd, b3Raw, vInters, true) ;
|
||||
if ( vInters.size() != 2)
|
||||
return false ;
|
||||
ptGdEnd = ptGdStart + vtGdDir * vInters[1].second ;
|
||||
ptGdStart = ptGdStart + vtGdDir * vInters[0].second ;
|
||||
// se non richiesta estensione, non faccio nulla
|
||||
if ( ! bExtend)
|
||||
return true ;
|
||||
// se grezzo non presente, non faccio nulla
|
||||
if ( pStmRaw == nullptr || ! pStmRaw->IsValid() || pStmRaw->GetTriangleCount() == 0)
|
||||
return true ;
|
||||
|
||||
// calcolo l'intersezione tra la linea corrente e la superficie del grezzo per prolungare l'entrata
|
||||
const double LINE_LEN = 1e5 ;
|
||||
const double COS_SMALL = sin( EPS_ANG_SMALL * DEGTORAD) ;
|
||||
ILSIVECTOR vInfo ;
|
||||
if ( ! IntersLineSurfTm( ptGdStart, - vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
Point3d ptNewStart = ptGdStart ;
|
||||
// se esistono intersezioni, cerco la prima uscente dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed esco dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN > COS_SMALL) {
|
||||
ptNewStart = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se richiesto allungamento fino al bordo del grezzo
|
||||
// se non esistono intersezioni e il tipo di prolungamento non richiede il collegamento, devo solo verificare
|
||||
// che non ci siano parti nel vuoto
|
||||
else {
|
||||
// se guida allineata con asse
|
||||
if ( AreSameVectorApprox( vtGdDir, X_AX)) {
|
||||
ptGdStart.x = b3Raw.GetMin().x ;
|
||||
ptGdEnd.x = b3Raw.GetMax().x ;
|
||||
}
|
||||
else if ( AreOppositeVectorApprox( vtGdDir, X_AX)) {
|
||||
ptGdStart.x = b3Raw.GetMax().x ;
|
||||
ptGdEnd.x = b3Raw.GetMin().x ;
|
||||
}
|
||||
else if ( AreSameVectorApprox( vtGdDir, Y_AX)) {
|
||||
ptGdStart.y = b3Raw.GetMin().y ;
|
||||
ptGdEnd.y = b3Raw.GetMax().y ;
|
||||
}
|
||||
else if ( AreOppositeVectorApprox( vtGdDir, Y_AX)) {
|
||||
ptGdStart.y = b3Raw.GetMax().y ;
|
||||
ptGdEnd.y = b3Raw.GetMin().y ;
|
||||
}
|
||||
// se direzione generica
|
||||
else {
|
||||
INTDBLVECTOR vInters ;
|
||||
IntersLineBox( ptGdStart, ptGdEnd, b3Raw, vInters, false) ;
|
||||
if ( vInters.size() != 2)
|
||||
return false ;
|
||||
ptGdEnd = ptGdStart + vtGdDir * vInters[1].second ;
|
||||
ptGdStart = ptGdStart + vtGdDir * vInters[0].second ;
|
||||
vInfo.clear() ;
|
||||
if ( ! IntersLineSurfTm( ptGdStart, vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
// se esistono intersezioni, cerco la prima entrante dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed entro dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN < - COS_SMALL) {
|
||||
ptNewStart = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calcolo l'interszione tra la linea corrente e la superficie del grezzo per prolungare l'uscita
|
||||
if ( ! IntersLineSurfTm( ptGdEnd, vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
Point3d ptNewEnd = ptGdEnd ;
|
||||
// se esistono intersezioni, cerco la prima cerco la prima uscente dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed esco dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO) {
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN > COS_SMALL) {
|
||||
ptNewEnd = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non esistono intersezioni e il tipo di collegamento non richiede allungamento devo solo verificare che
|
||||
// non ci siano parti nel vuoto
|
||||
else {
|
||||
vInfo.clear() ;
|
||||
if ( ! IntersLineSurfTm( ptGdEnd, - vtGdDir, LINE_LEN, *pStmRaw, vInfo, true))
|
||||
return false ;
|
||||
// se esitono intersezioni, cerco la prima entrante dalla superficie
|
||||
if ( ! vInfo.empty()) {
|
||||
for ( int i = 0 ; i < ssize( vInfo) ; ++ i) {
|
||||
// se c'è intersezione ed entro dalla superficie
|
||||
if ( vInfo[i].nILTT != ILTT_NO && vInfo[i].dCosDN < - COS_SMALL) {
|
||||
ptNewEnd = vInfo[i].ptI ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// assegno i valori trovati
|
||||
ptGdStart = ptNewStart ;
|
||||
ptGdEnd = ptNewEnd ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -2046,9 +2101,10 @@ SawRoughing::CalculateZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, c
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SawRoughing::CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax, bool bIncludeMax, bool bIncludeMin,
|
||||
SawRoughing::CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax, bool bIncludeMax, bool bIncludeMin,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir, const Frame3d& frSect,
|
||||
const BBox3d& b3Raw, double dDepth, bool bFirstInterval, bool bLastInterval, int& nCount)
|
||||
const ISurfTriMesh* pStmRaw, const BBox3d& b3Raw, bool bExtend, double dDepth,
|
||||
bool bFirstInterval, bool bLastInterval, int& nCount)
|
||||
{
|
||||
// calcolo step orizzontali
|
||||
double dLargh = dXmax - dXmin ;
|
||||
@@ -2079,11 +2135,11 @@ SawRoughing::CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax,
|
||||
Vector3d vtMove = vIntersX[i] * frSect.VersX() + vIntersY[i] * frSect.VersY() - 0.5 * m_TParams.m_dThick * m_vtTool ;
|
||||
Vector3d vtThick = m_vtTool * m_TParams.m_dThick ;
|
||||
Point3d ptStart = ptGdStart + vtMove ;
|
||||
Point3d ptEnd = ptGdEnd + vtMove ;
|
||||
Point3d ptEnd = ptGdEnd + vtMove ;
|
||||
Point3d ptStart2 = ptStart + vtThick ;
|
||||
Point3d ptEnd2 = ptEnd + vtThick ;
|
||||
AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, b3Raw) ;
|
||||
AdaptGuideLineToRaw( ptStart2, ptEnd2, vtGdDir, b3Raw) ;
|
||||
AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, bExtend, pStmRaw) ;
|
||||
AdaptGuideLineToRaw( ptStart2, ptEnd2, vtGdDir, bExtend, pStmRaw) ;
|
||||
|
||||
// determino l'elevazione del taglio
|
||||
double dCurrElev1, dCurrElev2 ;
|
||||
@@ -2238,7 +2294,7 @@ SawRoughing::CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax,
|
||||
Point3d ptStart = ptGdStart + vtMove ;
|
||||
Point3d ptEnd = ptGdEnd + vtMove ;
|
||||
// adatto la guida corrente al grezzo
|
||||
AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, b3Raw) ;
|
||||
AdaptGuideLineToRaw( ptStart, ptEnd, vtGdDir, bExtend, pStmRaw) ;
|
||||
|
||||
// quantità necessaria per arrivare alla quota di lavoro dalla quota della sezione
|
||||
double dDelta = vStepCoord[j].first - dY ;
|
||||
@@ -2362,7 +2418,7 @@ SawRoughing::CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax,
|
||||
}
|
||||
|
||||
// 4 -> retrazione soltanto se ultimo in assoluto oppure se attacco interno e ultimo dell'ultimo step
|
||||
if ( bLast ||
|
||||
if ( bLast ||
|
||||
( m_Params.m_nLeadLinkType != SAWROU_LL_OUT && j == vStepCoord.size() - 1 && i == vStepCoord[j].second.size() - 1)) {
|
||||
if ( ! AddRetract( ptNewEnd, m_vtCorr, dSafeZ, dElev, dAppr))
|
||||
return false ;
|
||||
@@ -2821,8 +2877,13 @@ SawRoughing::GeneratePreView( int nPathId, const ICurve* pSect, const Frame3d& f
|
||||
ptStart.ToGlob( frSect) ;
|
||||
ptStart += 0.5 * m_TParams.m_dThick * frSect.VersX() ;
|
||||
double dDimX = dGuideLen ;
|
||||
|
||||
bool bExtend ;
|
||||
if ( ! GetValInNotes( m_Params.m_sUserNotes, UN_EXTEND, bExtend))
|
||||
bExtend = true ;
|
||||
|
||||
// se link non interno la lavorazione viene estesa fino al bordo del grezzo
|
||||
if ( m_Params.m_nLeadLinkType != SAWROU_LL_INT) {
|
||||
if ( ! bExtend) {
|
||||
BBox3d b3RawLoc( b3Raw) ;
|
||||
b3RawLoc.ToLoc( frSect) ;
|
||||
double dMaxDim = max( b3RawLoc.GetDimX(), b3RawLoc.GetDimY()) ;
|
||||
@@ -2861,7 +2922,7 @@ SawRoughing::GeneratePreView( int nPathId, const ICurve* pSect, const Frame3d& f
|
||||
m_pGeomDB->SetMaterial( nId, LIME) ;
|
||||
|
||||
// se collegamento interno preparo le aree dei baffi
|
||||
if ( m_Params.m_nLeadLinkType == SAWROU_LL_INT) {
|
||||
if ( ! bExtend) {
|
||||
|
||||
// stima dell'elevazione per il calcolo dei baffi considerando la quota minima della sezione
|
||||
Point3d ptElev = b3Sect.GetMin() ;
|
||||
|
||||
+8
-6
@@ -22,6 +22,7 @@ class ICurve ;
|
||||
class ICurveLine ;
|
||||
class ICurveArc ;
|
||||
class ICurveComposite ;
|
||||
class ISurfTriMesh ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class SawRoughing : public Machining
|
||||
@@ -84,17 +85,18 @@ class SawRoughing : public Machining
|
||||
bool GeneratePreView( int nPathId, const ICurve* pSect, const Frame3d& frSect, double dGuideLen,
|
||||
const Vector3d& vtGdDir, const BBox3d& b3Raw) ;
|
||||
bool CalculateSection( int nSectGrpId, ICurve*& pSect) ;
|
||||
bool TrimSection( ICurve* pCrv) ;
|
||||
bool CalculateGuideLine( int nGuideId, const BBox3d& b3Sect, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir) ;
|
||||
bool AdaptGuideLineToRaw( Point3d& ptGdStart, Point3d& ptGdEnd, const Vector3d& vtGdDir, const BBox3d& b3Raw) const ;
|
||||
bool TrimSection( ICurve* pCrv) const ;
|
||||
bool CalculateGuideLine( int nGuideId, Point3d& ptGdStart, Point3d& ptGdEnd, Vector3d& vtGdDir) const ;
|
||||
bool AdaptGuideLineToRaw( Point3d& ptGdStart, Point3d& ptGdEnd, const Vector3d& vtGdDir, bool bExtend, const ISurfTriMesh* pStmRaw) const ;
|
||||
bool CalculateOneWayCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
|
||||
const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bFirst, bool bLast, const BBox3d& b3Raw) ;
|
||||
bool CalculateZigZagCut( const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtDir,
|
||||
const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, bool bFirst, bool bLast,
|
||||
int& nCount, const BBox3d& b3Raw) ;
|
||||
bool CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax, bool bIncludeMax, bool bIncludeMin,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir, const Frame3d& frSect,
|
||||
const BBox3d& b3Raw, double dDepth, bool bFirstInterval, bool bLastInterval, int& nCount) ;
|
||||
bool CalculateZConstCut( const ICurve* pCrv, double dXmin, double dXmax, bool bIncludeMax, bool bIncludeMin,
|
||||
const Point3d& ptGdStart, const Point3d& ptGdEnd, const Vector3d& vtGdDir, const Frame3d& frSect,
|
||||
const ISurfTriMesh* pStmRaw, const BBox3d& b3Raw, bool bExtend, double dDepth,
|
||||
bool bFirstInterval, bool bLastInterval, int& nCount) ;
|
||||
bool CalculateCurvedZigZagCut( const ICurve* pCut, const Vector3d& vtTool, double dElev, bool bFirst, bool bLast,
|
||||
int& nCount) ;
|
||||
bool AddApproach( const Point3d& ptP, const Vector3d& vtCorr, bool bFirst,
|
||||
|
||||
Reference in New Issue
Block a user