Merge commit '4a2f6fa43980530393a28617d0b230f106150edd'
This commit is contained in:
+319
-53
@@ -42,6 +42,8 @@
|
||||
#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
#include <EgtDev/Include/EGkGeoPoint3d.h>
|
||||
// per far dimenticare macro di WinUser.h
|
||||
#undef GetClassName
|
||||
|
||||
@@ -76,6 +78,7 @@ using namespace std ;
|
||||
// 3026 = "Error in SurfRoughing : Detecting open edges failed"
|
||||
// 3027 = "Error in SurfRoughing : Slicing Raw failed"
|
||||
// 3028 = "Error in SurfRoughing : Error in CalcPocketing"
|
||||
// 3029 = "Error in SurfRoughing : Error in Classifying border"
|
||||
// 3029 = "Error in SurfRoughing : Simplify Chunks for SubSteps failed"
|
||||
// 3051 = "Warning in SurfRoughing : Skipped entity (xx)"
|
||||
// 3052 = "Warning in SurfRoughing : No machinable path"
|
||||
@@ -1313,6 +1316,8 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
|
||||
// vettore Id salvati nel gruppo Temp
|
||||
INTINTVECTOR vPocket ;
|
||||
// vettore delle curve composite con proprietà Aperto/Chiuso riferite ai vari step della curva originale
|
||||
ICRVCOMPOPOVECTOR vCrvPocketCompo ;
|
||||
|
||||
// definisco la dimensione dello step ( base ) e il numero di passate
|
||||
double dOkStep = min( m_Params.m_dStep, m_TParams.m_dMaxMat + EPS_SMALL) ;
|
||||
@@ -1412,8 +1417,19 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
m_pMchMgr->SetLastError( 3027, "Error in SurfRoughing : Slicing Raw failed") ;
|
||||
return false ;
|
||||
}
|
||||
if ( pSfrRaw->IsValid() && pSfrRaw->GetChunkCount() > 0)
|
||||
PtrOwner<ICurveComposite> pCompoPocket( CloneCurveComposite( pCompo)) ;
|
||||
if ( IsNull( pCompoPocket) || ! pCompoPocket->IsValid() ||
|
||||
! pCompoPocket->Translate( ( it->dDepth - GetOffsL()) * vtTool))
|
||||
return false ;
|
||||
if ( pSfrRaw->IsValid() && pSfrRaw->GetChunkCount() > 0) {
|
||||
// per la curva composita selezionata, assegno i lati aperti e chiusi controllando
|
||||
// la geometria del grezzo ( servirà per controllare i LeadIn)
|
||||
if ( ! AssignOpenEdgesForPocketCrvCompo( pCompoPocket, pSfrRaw)) {
|
||||
m_pMchMgr->SetLastError( 3029, "Error in SurfRoughing : Error in Classifying border") ;
|
||||
return false ;
|
||||
}
|
||||
pSfr->Intersect( *pSfrRaw) ;
|
||||
}
|
||||
else
|
||||
continue ; // step fuori dal grezzo, passo al successivo
|
||||
|
||||
@@ -1517,6 +1533,12 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
it->pSfrRemoved = nullptr ;
|
||||
continue ;
|
||||
}
|
||||
// estendo la superficie di riferimento considerando le sottocurve chiuse della
|
||||
// curva di sgrossatura
|
||||
if ( ! ModifySurfRefForOpenCloseEdges( pSfrOpenClose, pCompoPocket)) {
|
||||
m_pMchMgr->SetLastError( 3026, "Error in SurfRoughing : Detecting open edges failed") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// determino i lati aperti ( mediante vicinanza dei tratti di curva al volume progressivo non svuotato)
|
||||
@@ -1538,12 +1560,15 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
pSfr->SetTempProp( it->bSubStep ? 1 : 0, 0) ;
|
||||
|
||||
// salvo nel temp Param della FlatRegion la sua Depth di traslazione
|
||||
pSfr->SetTempParam( it->dDepth, 0) ;
|
||||
pSfr->SetTempParam( it->dDepth - GetOffsL(), 0) ;
|
||||
|
||||
// salvo come temp Param 1 della FlatRegion il Coefficiente correttivo
|
||||
// per Zloc della Feed ( valore compreso tra 0 e 1)
|
||||
pSfr->SetTempParam( GetAdaptedCoeffFeed( it->bSubStep, it->nNumStep, dStep, dSubStep), 1) ;
|
||||
|
||||
// aggiungo la Curva composita con tempProp di Open/Close settate al vettore
|
||||
vCrvPocketCompo.emplace_back( Release( pCompoPocket)) ;
|
||||
|
||||
// la salvo nel gruppo temporaneo
|
||||
int nNew_SfrPock_Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nTempId, Release( pSfr)) ;
|
||||
if ( nNew_SfrPock_Id == GDB_ID_NULL) {
|
||||
@@ -1589,7 +1614,7 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId)
|
||||
|
||||
// Eseguo le svuotature
|
||||
double dElev = dDepth ;
|
||||
if ( ! AddPocket( vPocket, vtTool, vtExtr, dElev, dStep, bSplitArcs))
|
||||
if ( ! AddPocket( vPocket, vtTool, vtExtr, vCrvPocketCompo, dElev, dStep, bSplitArcs))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1773,7 +1798,7 @@ SurfRoughing::GetActiveSurfaces( INTVECTOR& vSurfId) const
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||
double dElev, double dStep, bool bSplitArcs)
|
||||
const ICRVCOMPOPOVECTOR& vCrvPocketCompo, double dElev, double dStep, bool bSplitArcs)
|
||||
{
|
||||
// recupero distanze di sicurezza
|
||||
double dSafeZ = GetSafeZ() ;
|
||||
@@ -1846,18 +1871,36 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
|
||||
// ciclo sui percorsi
|
||||
for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) {
|
||||
|
||||
// controllo se il percorso ha un ingresso presso un lato aperto
|
||||
bool bOutStart = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetCurve( 0)->GetTempProp( 0) == 2) ;
|
||||
bool bOutStart = ( vpCrvs[k]->GetCurveCount() > 0 &&
|
||||
vpCrvs[k]->GetCurve( 0)->GetTempProp( 0) == TEMP_PROP_OUT_START) ;
|
||||
// controllo se il punto di ingresso è valido
|
||||
bool bValidOutLeadIn = true ;
|
||||
if ( bOutStart) {
|
||||
bool bValidOutLeadIn = true ;
|
||||
if ( ! VerifyLeadIn( vpCrvs[k]->GetFirstCurve(), vCrvPocketCompo[nCurrStep], bValidOutLeadIn))
|
||||
return false ;
|
||||
if ( ! bValidOutLeadIn) {
|
||||
// se non valido, rimuovo il primo tratto
|
||||
bOutStart = false ;
|
||||
vpCrvs[k]->RemoveFirstOrLastCurve( false) ;
|
||||
}
|
||||
}
|
||||
// controllo se il percorso è formato da una singola curva seguente il lato chiuso
|
||||
bool bSingleCrv = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetTempProp( 0) == 3) ;
|
||||
bool bSingleCrv = ( vpCrvs[k]->GetCurveCount() > 0 &&
|
||||
vpCrvs[k]->GetTempProp( 0) == TEMP_PROP_SINGLE_CURVE) ;
|
||||
// controllo se caso ottimizzato a trapezio
|
||||
bool bOptTrap = ( vpCrvs[k]->GetCurveCount() > 0 && vpCrvs[k]->GetTempProp( 0) == 4) ;
|
||||
// inizializzo la curva di Ritorno per LeadIn/LeadOut
|
||||
bool bOptTrap = ( vpCrvs[k]->GetCurveCount() > 0 &&
|
||||
vpCrvs[k]->GetTempProp( 0) == TEMP_PROP_OPT_TRAPEZOID) ;
|
||||
// controllo se è un percorso a ZigZag/OneWay ( non curva di bordo)
|
||||
bool bIsZigZagOneWayPath = ( vpCrvs[k]->GetCurveCount() > 0 &&
|
||||
( nSubType == SURFROU_SUB_ONEWAY || nSubType == SURFROU_SUB_ZIGZAG) &&
|
||||
vpCrvs[k]->GetTempProp( 0) != TEMP_PROP_BORDER_CURVE) ;
|
||||
// inizializzo la curva di Ritorno per LeadIn/LeadOut
|
||||
PtrOwner<ICurveComposite> pRCrv( CreateCurveComposite()) ;
|
||||
if ( IsNull( pRCrv))
|
||||
return false ;
|
||||
// ciclo sulle curve elementari
|
||||
// ciclo sulle curve elementari
|
||||
int nMaxInd = vpCrvs[k]->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
@@ -1884,8 +1927,7 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
if ( ! CalcRetCrv( vpCrvs[k], ptUp, bOutStart, pRCrv))
|
||||
return false ;
|
||||
// flag approccio libero in aria
|
||||
bool bOutLeadIn = ( bOutStart || bSingleCrv || bOptTrap) ;
|
||||
if ( bOutLeadIn)
|
||||
if ( bOutStart)
|
||||
dCoeffFeed = ( dTempParam > EPS_SMALL ? dTempParam : 1) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
@@ -1911,14 +1953,14 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
}
|
||||
// altrimenti, approccio di collegamento
|
||||
else {
|
||||
if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr, bOutLeadIn)) {
|
||||
if ( ! AddLinkApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr, bOutStart)) {
|
||||
m_pMchMgr->SetLastError( 3012, "Error in SurfRoughing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// se attacco elica od equivalente di step pieno, devo fare elica o similari solo sulla parte con materiale
|
||||
if ( nSubType != SURFROU_SUB_ONEWAY &&
|
||||
nSubType != SURFROU_SUB_ZIGZAG &&
|
||||
nBasicStep > 0 && ! bIsSubStep &&
|
||||
nBasicStep > 0 && ! bOutStart &&
|
||||
( GetLeadInType() == POCKET_LI_ZIGZAG ||
|
||||
GetLeadInType() == POCKET_LI_HELIX ||
|
||||
GetLeadInType() == POCKET_LI_GLIDE)) {
|
||||
@@ -1931,23 +1973,11 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
// cerco il chunk più vicino al punto iniziale
|
||||
int nInd = 0 ;
|
||||
double dMinDist = INFINITO ;
|
||||
for ( int idx = 0 ; idx < int( vLoops.size()) ; ++ idx) {
|
||||
double dCurrDist = INFINITO ;
|
||||
if ( DistPointCurve( ptStart, *vLoops[idx]).GetDist( dCurrDist) && dCurrDist < dMinDist) {
|
||||
dMinDist = dCurrDist ;
|
||||
nInd = idx ;
|
||||
}
|
||||
}
|
||||
PtrOwner<ICurveComposite> pCompo( ConvertCurveToComposite( pSfrPock->GetLoop( nInd, 0))) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pCompo,
|
||||
bool bNoneForced = ( bOutStart || bSingleCrv || bIsZigZagOneWayPath) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSfrPock,
|
||||
( ( nSubType == SURFROU_SUB_SPIRALIN || nSubType == SURFROU_SUB_SPIRALOUT)) ? Get( pRCrv) : nullptr,
|
||||
( nSubType == SURFROU_SUB_SPIRALOUT) ? m_Params.m_bInvert : ! m_Params.m_bInvert,
|
||||
bSplitArcs, bOutLeadIn, false)) {
|
||||
( nSubType == SURFROU_SUB_SPIRALOUT) ? bInvert : ! bInvert,
|
||||
bSplitArcs, bNoneForced, false)) {
|
||||
m_pMchMgr->SetLastError( 3013, "Error in SurfRoughing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
@@ -2173,7 +2203,7 @@ SurfRoughing::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart,
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
||||
const ICurveComposite* pCompo, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs,
|
||||
const ISurfFlatRegion* pSfr, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs,
|
||||
bool bNoneForced, bool bSkipControl)
|
||||
{
|
||||
// Assegno il tipo
|
||||
@@ -2193,7 +2223,7 @@ SurfRoughing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vect
|
||||
double dDeltaN = ( ptStart - ptP1) * vtN ;
|
||||
double dAngCen = ceil( - dDeltaN / ( m_Params.m_dLiElev + 20 * EPS_SMALL)) * ( bAtLeft ? ANG_FULL : - ANG_FULL) ;
|
||||
// verifico se fattibile
|
||||
if ( bSkipControl || VerifyLeadInHelix( pCompo, ptStart, ptCen, dRad)) {
|
||||
if ( bSkipControl || VerifyLeadInHelix( pSfr, ptStart, ptCen, dRad)) {
|
||||
// creo l'elica
|
||||
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc) || ! pArc->Set( ptCen, vtN, dRad, - vtCen, dAngCen, dDeltaN))
|
||||
@@ -2214,7 +2244,7 @@ SurfRoughing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vect
|
||||
Point3d ptPa = ptP1 + vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ;
|
||||
Point3d ptPb = ptP1 - vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ;
|
||||
// verifico se fattibile
|
||||
if ( bSkipControl || VerifyLeadInZigZag( pCompo, ptStart, ptPa, ptPb)) {
|
||||
if ( bSkipControl || VerifyLeadInZigZag( pSfr, ptStart, ptPa, ptPb)) {
|
||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||
if ( AddLinearMove( ptPa - vtN * ( i - 0.75) * dStep, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
@@ -2609,6 +2639,42 @@ SurfRoughing::CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::ModifySurfRefForOpenCloseEdges( ISurfFlatRegion* pSfrRef, const ICurveComposite* pCrvCompo) const
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pSfrRef == nullptr || pCrvCompo == nullptr || ! pCrvCompo->IsValid())
|
||||
return false ;
|
||||
|
||||
/*
|
||||
NB. Questa funzione è richiamata per i sub steps.
|
||||
Alcuni subStep potrebbero avere dei lati aperti molto vicini ai lati chiusi della curva
|
||||
scelta per la sgrossatura; modifico la superficie di riferimento per la scelta dei lati
|
||||
Aperti/Chiusi estendendola con le regione generate dalle FatCurve dei tratti chiusi
|
||||
*/
|
||||
|
||||
// ricavo i tratti chiusi della curva di sgrossatura
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
if ( ! GetHomogeneousParts( pCrvCompo, vpCrvs))
|
||||
return false ;
|
||||
// scorro tutti i tratti chiusi e li aggiungo alla pSfrDanger
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
if ( vpCrvs[i]->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE) {
|
||||
PtrOwner<ISurfFlatRegion> pSfrFat( GetSurfFlatRegionFromFatCurve( vpCrvs[i]->Clone(), m_TParams.m_dDiam / 2, false, false)) ;
|
||||
if ( ! IsNull( pSfrFat) && pSfrFat->IsValid()) {
|
||||
if ( ! pSfrRef->IsValid())
|
||||
pSfrRef->CopyFrom( pSfrFat) ;
|
||||
else
|
||||
pSfrRef->Add( *pSfrFat) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrRef) const
|
||||
@@ -2620,7 +2686,7 @@ SurfRoughing::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegio
|
||||
if ( pSfrRef == nullptr || ! pSfrRef->IsValid())
|
||||
return false ;
|
||||
|
||||
// piccola tolleranza sulla regione di classfica
|
||||
// recupero la regione di riferimento ( effettuerò un piccolo Offset per tolleranza)
|
||||
PtrOwner<ISurfFlatRegion> pSfrRef_Offs( CloneSurfFlatRegion( pSfrRef)) ;
|
||||
if ( IsNull( pSfrRef_Offs))
|
||||
return false ;
|
||||
@@ -2653,6 +2719,15 @@ SurfRoughing::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegio
|
||||
// per ogni curva dei Loop della FlatRegion vengono presi 4 punti di controllo equidistanti.
|
||||
// " IL LATO E' APERTO <=> TUTTI I PUNTI DI CONTROLLO NON SONO DENTRO A pSfrRef "
|
||||
|
||||
/*
|
||||
Invece di classificare i punti con la FlatRegion stessa è stata creata una struttura
|
||||
che contiene le PolyLine dei singoli loop. Quando io classifico un punto rispetto ad una
|
||||
regione piana, vengono presi tutti i loops e, una volta trasformati in PolyLine, viene
|
||||
classificato il punto rispetto ad esse. Invece di approssimare tutti i Loop da curve
|
||||
composite e Polyline per ogni punto ( per classificarlo), vengono direttamente salvate
|
||||
le PolyLine, in modo che questo passaggio sia fatto solo una volta all'inizio
|
||||
*/
|
||||
|
||||
const int NUM_POINTS = 4 ;
|
||||
// scorro tutti i loop
|
||||
for ( int c = 0 ; c < pSfr->GetChunkCount() ; ++ c) {
|
||||
@@ -2664,7 +2739,7 @@ SurfRoughing::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegio
|
||||
// scorro ogni sua sottocurva
|
||||
for ( int u = 0 ; u < pCrvCompoLoop->GetCurveCount() ; ++ u) {
|
||||
// metto a 1 la TmpProp della sottocurva corrente della superficie
|
||||
pSfr->SetCurveTempProp( c, l, u, 1, 0) ;
|
||||
pSfr->SetCurveTempProp( c, l, u, TEMP_PROP_OPEN_EDGE, 0) ;
|
||||
// recupero la sottocurva
|
||||
const ICurve* pCrv = pCrvCompoLoop->GetCurve( u) ;
|
||||
if ( pCrv == nullptr)
|
||||
@@ -2700,7 +2775,7 @@ SurfRoughing::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegio
|
||||
}
|
||||
}
|
||||
if ( ! bIsOut) {
|
||||
pSfr->SetCurveTempProp( c, l, u, 0, 0) ;
|
||||
pSfr->SetCurveTempProp( c, l, u, TEMP_PROP_CLOSE_EDGE, 0) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@@ -2712,6 +2787,59 @@ SurfRoughing::ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegio
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::AssignOpenEdgesForPocketCrvCompo( ICurveComposite* pCrvCompo, const ISurfFlatRegion* pSfr) const
|
||||
{
|
||||
/*
|
||||
Assegno i lati aperti/Chiusi alla curva di Pocketing modificando però i punti iniziali/finali
|
||||
delle sue sottocurve adattandoli alla geomtria di pSfr
|
||||
*/
|
||||
|
||||
// controllo validità dei parametri
|
||||
if ( pCrvCompo == nullptr || ! pCrvCompo->IsValid() ||
|
||||
pSfr == nullptr || ! pSfr->IsValid())
|
||||
return false ;
|
||||
|
||||
// creo la nuova curva di riferimento
|
||||
PtrOwner<ICurveComposite> pMyNewCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pMyNewCompo))
|
||||
return false ;
|
||||
|
||||
// classifico la curva in base alla superficie
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( pSfr->GetCurveClassification( *pCrvCompo, EPS_SMALL, ccClass)) {
|
||||
for ( int i = 0 ; i < int( ccClass.size()) ; ++ i) {
|
||||
// il sottotratto di curva interno è chiuso, tutto il resto è aperto
|
||||
PtrOwner<ICurve> pCrv( pCrvCompo->CopyParamRange( ccClass[i].dParS, ccClass[i].dParE)) ;
|
||||
if ( ! IsNull( pCrv) && pCrv->IsValid()) {
|
||||
// se sottotratto valido, lo converto in curva composita
|
||||
PtrOwner<ICurveComposite> pCompo( ConvertCurveToComposite( Release( pCrv))) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->IsValid())
|
||||
return false ;
|
||||
// assegno le proprietà di lato aperto/chiuso alla sottocurve ricavate
|
||||
for ( int j = 0 ; j < pCompo->GetCurveCount() ; ++ j)
|
||||
pCompo->SetCurveTempProp( j, ( ccClass[i].nClass == CRVC_IN ? TEMP_PROP_CLOSE_EDGE : TEMP_PROP_OPEN_EDGE), 0) ;
|
||||
// aggiungo la curva al risultato
|
||||
if ( ! pMyNewCompo->AddCurve( Release( pCompo)))
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se tutto è andato a buon fine allora restituisco la curva
|
||||
if ( pMyNewCompo->IsValid() && pMyNewCompo->IsClosed())
|
||||
pCrvCompo->CopyFrom( pMyNewCompo) ;
|
||||
else {
|
||||
// tutta chiusa per sicurezza
|
||||
for ( int i = 0 ; i < pCrvCompo->GetCurveCount() ; ++ i)
|
||||
pCrvCompo->SetCurveTempProp( i, TEMP_PROP_CLOSE_EDGE, 0) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
SurfRoughing::GetRadiusForStartEndElevation( void) const
|
||||
@@ -2752,36 +2880,174 @@ SurfRoughing::CalcRetCrv( const ICurveComposite* pCompo, const Point3d& ptRef, b
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptStart, const Point3d& ptCen, double dRad)
|
||||
SurfRoughing::VerifyLeadInHelix( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptCen,
|
||||
double dHelixRad)
|
||||
{
|
||||
// recupero il piano della curva di contorno
|
||||
Vector3d vtN ;
|
||||
if ( pCompo == nullptr || ! pCompo->GetExtrusion( vtN))
|
||||
// controllo validità dei parametri
|
||||
if ( pSfr == nullptr || ! pSfr->IsValid())
|
||||
return false ;
|
||||
Vector3d vtN = pSfr->GetNormVersor() ;
|
||||
// porto il centro sullo stesso piano del contorno
|
||||
Point3d ptCenL = ptCen - ( ptCen - ptStart) * vtN * vtN ;
|
||||
// calcolo la distanza del centro dal contorno
|
||||
// calcolo Offset della regione
|
||||
PtrOwner<ISurfFlatRegion> pSfrOffs( CloneSurfFlatRegion( pSfr)) ;
|
||||
if ( IsNull( pSfrOffs) || ! pSfrOffs->IsValid() ||
|
||||
! pSfrOffs->Offset( - m_TParams.m_dDiam / 2, ICurve::OFF_FILLET))
|
||||
return false ;
|
||||
// recupero le curve da tale regione
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
for ( int nC = 0 ; nC < pSfrOffs->GetChunkCount() ; ++ nC)
|
||||
for ( int nL = 0 ; nL < pSfrOffs->GetLoopCount( nC) ; ++ nL)
|
||||
vCrv.emplace_back( pSfrOffs->GetLoop( nC, nL)) ;
|
||||
if ( vCrv.empty())
|
||||
return false ;
|
||||
// calcolo la distanza del centro da tutti i loop ricavati
|
||||
double dMinDist ;
|
||||
return ( DistPointCurve( ptCenL, *pCompo).GetDist( dMinDist) && dMinDist > dRad + 0.5 * m_TParams.m_dDiam + GetOffsR() - 10 * EPS_SMALL) ;
|
||||
bool bOk = true ;
|
||||
for ( int i = 0 ; i < int( vCrv.size()) && bOk ; ++ i) {
|
||||
bOk = ( DistPointCurve( ptCenL, *vCrv[i]).GetDist( dMinDist) &&
|
||||
dMinDist > dHelixRad - 10 * EPS_SMALL) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptStart, const Point3d& ptPa, const Point3d& ptPb) const
|
||||
SurfRoughing::VerifyLeadInZigZag( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptPa,
|
||||
const Point3d& ptPb)
|
||||
{
|
||||
// recupero il piano della curva di contorno
|
||||
Vector3d vtN ;
|
||||
if ( pCompo == nullptr || ! pCompo->GetExtrusion( vtN))
|
||||
// controllo validità dei parametri
|
||||
if ( pSfr == nullptr || ! pSfr->IsValid())
|
||||
return false ;
|
||||
Vector3d vtN = pSfr->GetNormVersor() ;
|
||||
// porto i punti sullo stesso piano del contorno
|
||||
Point3d ptPaL = ptPa - ( ptPa - ptStart) * vtN * vtN ;
|
||||
Point3d ptPbL = ptPb - ( ptPb - ptStart) * vtN * vtN ;
|
||||
// calcolo la distanza dei due punti dal contorno
|
||||
double dMinDistPa ;
|
||||
if ( ! DistPointCurve( ptPaL, *pCompo).GetDist( dMinDistPa))
|
||||
// recupero le curve da tale regione
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC)
|
||||
for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; ++ nL)
|
||||
vCrv.emplace_back( pSfr->GetLoop( nC, nL)) ;
|
||||
if ( vCrv.empty())
|
||||
return false ;
|
||||
double dMinDistPb ;
|
||||
if ( ! DistPointCurve( ptPbL, *pCompo).GetDist( dMinDistPb))
|
||||
// calcolo la distanza dei due punti dalle curve ricavate
|
||||
double dMinDist ;
|
||||
bool bOk = true ;
|
||||
for ( int i = 0 ; i < int( vCrv.size()) && bOk ; ++ i) {
|
||||
bOk = ( ( DistPointCurve( ptPaL, *vCrv[i]).GetDist( dMinDist) &&
|
||||
dMinDist > 0.5 * m_TParams.m_dDiam - 10 * EPS_SMALL) &&
|
||||
( DistPointCurve( ptPbL, *vCrv[i]).GetDist( dMinDist) &&
|
||||
dMinDist > 0.5 * m_TParams.m_dDiam - 10 * EPS_SMALL)) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pCrvCompo == nullptr || ! pCrvCompo->IsValid())
|
||||
return false ;
|
||||
return ( dMinDistPa > 0.5 * m_TParams.m_dDiam + GetOffsR() - 10 * EPS_SMALL && dMinDistPb > 0.5 * m_TParams.m_dDiam + GetOffsR() - 10 * EPS_SMALL) ;
|
||||
}
|
||||
vpCrvs.clear() ;
|
||||
|
||||
// scorro tutte le curve semplici nella composita
|
||||
int nCurrTempProp ;
|
||||
int nParStart = 0 ;
|
||||
for ( int i = 0 ; i < pCrvCompo->GetCurveCount() ; ++ i) {
|
||||
// ricavo la TmpProp
|
||||
int nTempProp ;
|
||||
pCrvCompo->GetCurveTempProp( i, nTempProp) ;
|
||||
if ( i == 0) {
|
||||
nCurrTempProp = nTempProp ;
|
||||
nParStart = i ;
|
||||
}
|
||||
// se TmpProp differiscono, ricavo il tratto di curva omogeneo
|
||||
else if ( nCurrTempProp != nTempProp) {
|
||||
PtrOwner<ICurveComposite> pCrv( ConvertCurveToComposite( pCrvCompo->CopyParamRange( nParStart, i))) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
pCrv->SetTempProp( nCurrTempProp) ; // globale, al tratto di curva nel vettore
|
||||
vpCrvs.emplace_back( Release( pCrv)) ;
|
||||
nCurrTempProp = nTempProp ;
|
||||
nParStart = i ;
|
||||
}
|
||||
}
|
||||
// ultima curva...
|
||||
PtrOwner<ICurveComposite> pCrvLast( ConvertCurveToComposite( pCrvCompo->CopyParamRange( nParStart, pCrvCompo->GetCurveCount()))) ;
|
||||
if ( ! IsNull( pCrvLast)) {
|
||||
pCrvLast->SetTempProp( nCurrTempProp) ;
|
||||
vpCrvs.emplace_back( Release( pCrvLast)) ;
|
||||
}
|
||||
if ( vpCrvs.size() > 1) { // unisco il primo e l'ultimo se estremi compatibili
|
||||
Point3d ptE ; vpCrvs.back()->GetEndPoint( ptE) ;
|
||||
Point3d ptS ; vpCrvs[0]->GetStartPoint( ptS) ;
|
||||
if ( AreSamePointApprox( ptS, ptE) && vpCrvs[0]->GetTempProp() == vpCrvs.back()->GetTempProp()) {
|
||||
vpCrvs[0]->AddCurve( Release( vpCrvs.back()), false) ;
|
||||
vpCrvs.erase( vpCrvs.end() - 1) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfRoughing::VerifyLeadIn( const ICurve* pCrv, const ICurveComposite* pCrvPock, bool& bValidLeadIn) const
|
||||
{
|
||||
/*
|
||||
Verifica se il segmento di LeadIn per entrate da fuori sia valido
|
||||
*/
|
||||
|
||||
// controllo dei parametri
|
||||
if ( pCrv == nullptr || ! pCrv->IsValid() ||
|
||||
pCrvPock == nullptr || ! pCrvPock->IsValid())
|
||||
return false ;
|
||||
|
||||
// recupero i tratti chiusi della curva di pocketing
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
if ( ! GetHomogeneousParts( pCrvPock, vpCrvs))
|
||||
return false ;
|
||||
|
||||
// porto tutto nel piano XY ( la Fat curve di una Linea è ambigua)
|
||||
Frame3d frLoc ;
|
||||
Point3d ptFrLoc ; pCrvPock->GetStartPoint( ptFrLoc) ;
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
pCrvPock->GetArea( plPlane, dArea) ;
|
||||
Vector3d vtFrLoc = plPlane.GetVersN() ;
|
||||
if ( ! frLoc.Set( ptFrLoc, vtFrLoc))
|
||||
return false ;
|
||||
|
||||
// porto la curva in locale
|
||||
PtrOwner<ICurve> pCrvLoc( pCrv->Clone()) ;
|
||||
if ( IsNull( pCrvLoc) || ! pCrvLoc->IsValid() || ! pCrvLoc->ToLoc( frLoc))
|
||||
return false ;
|
||||
|
||||
// calcolo la Fat Curve del tratto lineare e la porto in globale
|
||||
PtrOwner<ISurfFlatRegion> pSfrFat( GetSurfFlatRegionFromFatCurve( pCrvLoc->Clone(), m_TParams.m_dDiam / 2, false, false)) ;
|
||||
if ( IsNull( pSfrFat) || ! pSfrFat->IsValid())
|
||||
return false ;
|
||||
|
||||
bValidLeadIn = true ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) && bValidLeadIn ; ++ i) {
|
||||
// se tratto chiuso...
|
||||
if ( vpCrvs[i]->GetTempProp( 0) == 0) {
|
||||
// porto nel frame locale
|
||||
vpCrvs[i]->ToLoc( frLoc) ;
|
||||
// controllo se interseca la fat curve
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( pSfrFat->GetCurveClassification( *vpCrvs[i], EPS_SMALL, ccClass))
|
||||
bValidLeadIn = ( int( ccClass.size()) == 1 && ccClass[0].nClass == CRVC_OUT) ;
|
||||
else
|
||||
bValidLeadIn = false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -77,15 +77,16 @@ class SurfRoughing : public Machining
|
||||
bool Chain( int nGrpDestId) ;
|
||||
bool ProcessPath( int nPathId, int nTempId, int nPvId, int nClId) ;
|
||||
bool AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||
double dElev, double dStep, bool bSplitArcs) ;
|
||||
const ICRVCOMPOPOVECTOR& vCrvPocketCompo, double dElev, double dStep, bool bSplitArcs) ;
|
||||
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr, bool bOutMove) ;
|
||||
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtTool, const ICurveComposite* pCrvPath, Point3d& ptP1) const ;
|
||||
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart,
|
||||
const Vector3d& vtN, const ICurveComposite* pCompo, const ICurveComposite* pRCrv,
|
||||
bool bAtLeft, bool bSplitArcs, bool bNoneForced, bool bSkipControl) ;
|
||||
bool VerifyLeadIn( const ICurve* pCrv, const ICurveComposite* pCrvPock, bool& bSkip) const ;
|
||||
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
||||
const ISurfFlatRegion* pSfr, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs,
|
||||
bool bNoneForced, bool bSkipControl) ;
|
||||
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
||||
const ICurveComposite* pRCrv, bool bSplitArcs, bool bNoneForced,
|
||||
Point3d& ptP1, double& dElev) ;
|
||||
@@ -94,16 +95,19 @@ class SurfRoughing : public Machining
|
||||
bool GetActiveSurfaces( INTVECTOR& vSurfId) const ;
|
||||
double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) const ;
|
||||
double GetRadiusForStartEndElevation( void) const ;
|
||||
bool AssignOpenEdgesForPocketCrvCompo( ICurveComposite* pCrvCompo, const ISurfFlatRegion* pSfr) const ;
|
||||
bool ResetCurveAllTempProp( ICurve* pCurve) const ;
|
||||
bool RemoveChunksUnderTolerance( ISurfFlatRegion* pSfr) const ;
|
||||
bool CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler) ;
|
||||
bool ModifySurfRefForOpenCloseEdges( ISurfFlatRegion* pSfrRef, const ICurveComposite* pCrvCompo) const ;
|
||||
bool ChooseCloseOrOpenEdge( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrRef) const ;
|
||||
bool SimplifyCurve( ICurveComposite* pCompo) const ;
|
||||
bool SimplyfySfr( ISurfFlatRegion* pSfr) const ;
|
||||
bool CalcRetCrv( const ICurveComposite* pCompo, const Point3d& ptRef, bool bOutStart,
|
||||
ICurveComposite* pRCrv) const ;
|
||||
bool VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptStart, const Point3d& ptCen, double dRad) ;
|
||||
bool VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptStart, const Point3d& ptPb) const ;
|
||||
bool GetHomogeneousParts( const ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCrvs) const ;
|
||||
bool VerifyLeadInHelix( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptCen, double dHelixRad) ;
|
||||
bool VerifyLeadInZigZag( const ISurfFlatRegion* pSfr, const Point3d& ptStart, const Point3d& ptPa, const Point3d& ptPb) ;
|
||||
|
||||
private :
|
||||
double GetSpeed() const
|
||||
|
||||
Reference in New Issue
Block a user