Compare commits
88 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3d44261bb | |||
| 9220fd568f | |||
| 17346e1b42 | |||
| c95ef6764d | |||
| d0f2d56bdb | |||
| fb037f2f2a | |||
| 2d94dddccb | |||
| d2d025a594 | |||
| 64abf640f6 | |||
| cb2b63320a | |||
| 951d3781d6 | |||
| 27bd0e579e | |||
| ff7d564de8 | |||
| a27b9e871a | |||
| eb497cbd39 | |||
| dd3091fc13 | |||
| 69d463713c | |||
| 5e918ff3aa | |||
| b4522c712d | |||
| fa9a9e89cb | |||
| d51a0d2258 | |||
| 580230b38b | |||
| 4b24906d2e | |||
| 2094a1cc0d | |||
| b8b639699a | |||
| 0b86c4f72b | |||
| 5c93384690 | |||
| b77db4a5bc | |||
| c704d94829 | |||
| 0373021b7a | |||
| 6de856b3e1 | |||
| a231d8f26c | |||
| 745a7eb38c | |||
| 78c40ebca7 | |||
| a39af1c3a3 | |||
| c2a0f9dff1 | |||
| 6be67258d2 | |||
| 6c76943bf4 | |||
| 9306f5be9d | |||
| 944ce79776 | |||
| 313c735956 | |||
| 007ed1701c | |||
| 7385709bb4 | |||
| da4cd4c482 | |||
| dee744725c | |||
| 2aca943de4 | |||
| 25f6bae120 | |||
| c92d841011 | |||
| 398c8c430a | |||
| 79dc8f8fc2 | |||
| 1545bc07cd | |||
| 44edef378a | |||
| 679efc22e8 | |||
| 1076dc54dc | |||
| e091f253d0 | |||
| 3206961b88 | |||
| 48b2029d19 | |||
| a2ca0ac6f7 | |||
| 4155dd3e5a | |||
| 5a3b7e311c | |||
| 991586a880 | |||
| de4165889a | |||
| 42c5ffb014 | |||
| e394615f84 | |||
| 1008ba4229 | |||
| f4328430b9 | |||
| 1d6bc847da | |||
| d76beb09ee | |||
| 026436b914 | |||
| ebc5fd7ee7 | |||
| 82a211753e | |||
| a258e9cb31 | |||
| 157885f71a | |||
| f227a9cba7 | |||
| 98c576afe0 | |||
| ae8f80d6e9 | |||
| 9b933bd26d | |||
| baa8736276 | |||
| c75a7e9514 | |||
| 233f64e68f | |||
| da7ebd6f61 | |||
| 8db1765505 | |||
| 5d2e1ff608 | |||
| a9f8ef2ff3 | |||
| a1c448d8dd | |||
| 25d53338c2 | |||
| 1ad96ce8ca | |||
| 36422c43b3 |
+2
-2
@@ -151,11 +151,11 @@ MyAdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst)
|
||||
else {
|
||||
double dParA = vIccInfo[i].IciA[0].dU ;
|
||||
double dParB = vIccInfo[i].IciB[0].dU ;
|
||||
if ( abs( dParA - dEnd) < EPS_SMALL)
|
||||
if ( dParA > dParB)
|
||||
swap( dParA, dParB) ;
|
||||
// verifico se uno dei due intervalli dà origine ad un tratto trascurabile
|
||||
PtrOwner<ICurve> pCrv1( pMyCrv->CopyParamRange( dParA, dParB)) ;
|
||||
PtrOwner<ICurve> pCrv2( pMyCrv->CopyParamRange( dParB, dParA)) ;
|
||||
PtrOwner<ICurve> pCrv2( pMyCrv->CopyParamRange( dParB, dParA)) ;
|
||||
double dArea1 = 0, dArea2 = 0 ;
|
||||
if ( ! IsNull( pCrv1))
|
||||
pCrv1->GetAreaXY( dArea1) ;
|
||||
|
||||
@@ -140,16 +140,20 @@ MyCAvSimpleSurfFrMove::Translate( const Vector3d& vtDir, double& dLen)
|
||||
if ( scInfoCurr.nType == SCI_LINE_LINE || scInfoCurr.nType == SCI_PNT_LINE) {
|
||||
m_SCollInfo = scInfoCurr ;
|
||||
m_SCollInfo.nChunkM = j ;
|
||||
m_SCollInfo.nLoopM = 0 ;
|
||||
m_SCollInfo.nCrvM = k ;
|
||||
m_SCollInfo.nChunkF = i ;
|
||||
m_SCollInfo.nLoopF = 0 ;
|
||||
m_SCollInfo.nCrvF = l ;
|
||||
}
|
||||
}
|
||||
else if ( dNewLenXY < dPrevLenXY) {
|
||||
m_SCollInfo = scInfoCurr ;
|
||||
m_SCollInfo.nChunkM = j ;
|
||||
m_SCollInfo.nLoopM = 0 ;
|
||||
m_SCollInfo.nCrvM = k ;
|
||||
m_SCollInfo.nChunkF = i ;
|
||||
m_SCollInfo.nLoopF = 0 ;
|
||||
m_SCollInfo.nCrvF = l ;
|
||||
}
|
||||
pCrv2 = ( pCompo2 != nullptr ? pCompo2->GetNextCurve() : nullptr) ;
|
||||
|
||||
@@ -30,7 +30,7 @@ class MyCAvSimpleSurfFrMove
|
||||
const SCollInfo& GetSCollInfo()
|
||||
{ return m_SCollInfo ;}
|
||||
|
||||
private :
|
||||
protected :
|
||||
bool TranslateCurveNoCollisionCurve( const ICurve* pCrv1, const ICurve* pCrv2,
|
||||
const Vector3d& vtDir, double& dLen, SCollInfo& scInfo) ;
|
||||
bool TranslateLineNoCollisionLine( const CurveLine* pLine1, const CurveLine* pLine2,
|
||||
@@ -40,7 +40,7 @@ class MyCAvSimpleSurfFrMove
|
||||
bool RotateLineNoCollisionLine( const CurveLine* pLine1, const CurveLine* pLine2,
|
||||
const Point3d& ptCen, double& dAng) ;
|
||||
|
||||
private :
|
||||
protected :
|
||||
const SurfFlatRegion* m_pRegM ;
|
||||
const SurfFlatRegion* m_pRegF ;
|
||||
SCollInfo m_SCollInfo ;
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2026-2026
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CASurfFrMove.cpp Data : 26.03.2026 Versione : 3.1c7
|
||||
// Contenuto : Implementazione delle funzioni di movimento per SurfFlatRegion
|
||||
// senza collisione con altri oggetti dello stesso tipo e nello
|
||||
// stesso piano o in piani paralleli.
|
||||
//
|
||||
//
|
||||
// Modifiche : 26.03.2026 RE Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CAvSurfFrMove.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "IntersLineArc.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkCAvSurfFrMove.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// CASurfFrMove
|
||||
//----------------------------------------------------------------------------
|
||||
CAvSurfFrMove::CAvSurfFrMove( const ISurfFlatRegion& SfrM, const ISurfFlatRegion& SfrF)
|
||||
{
|
||||
// salvo puntatori alle regioni
|
||||
m_pRegM = &SfrM ;
|
||||
m_pRegF = &SfrF ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CAvSurfFrMove::Translate( const Vector3d& vtDir, double& dLen)
|
||||
{
|
||||
MyCAvSurfFrMove ScdMove( *m_pRegM, *m_pRegF) ;
|
||||
m_CollInfo.nType = SCI_NONE ;
|
||||
if ( ! ScdMove.Translate( vtDir, dLen))
|
||||
return false ;
|
||||
m_CollInfo = ScdMove.GetCollInfo() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CAvSurfFrMove::Rotate( const Point3d& ptCen, double& dAng)
|
||||
{
|
||||
MyCAvSurfFrMove ScdMove( *m_pRegM, *m_pRegF) ;
|
||||
m_CollInfo.nType = SCI_NONE ;
|
||||
return ScdMove.Rotate( ptCen, dAng) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MyCAvSurfFrMove::Translate( const Vector3d& vtDir, double& dLen)
|
||||
{
|
||||
// verifico validità regioni
|
||||
if ( m_pRegM == nullptr || m_pRegF == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifico che le due regioni giacciano in piani paralleli
|
||||
if ( ! AreSameVectorApprox( m_pRegM->m_frF.VersZ(), m_pRegF->m_frF.VersZ()))
|
||||
return false ;
|
||||
|
||||
// reset info di collisione
|
||||
m_SCollInfo.nType = SCI_NONE ;
|
||||
|
||||
// porto il vettore di movimento nel riferimento intrinseco e ne annullo la componente Z
|
||||
Vector3d vtDirL = vtDir ;
|
||||
vtDirL.ToLoc( m_pRegM->m_frF) ;
|
||||
vtDirL.z = 0 ;
|
||||
double dLenXY = vtDirL.Len() ;
|
||||
if ( dLenXY < EPS_SMALL)
|
||||
return true ;
|
||||
vtDirL /= dLenXY ;
|
||||
dLenXY *= dLen ;
|
||||
double dNewLenXY = dLenXY ;
|
||||
|
||||
// ciclo sui chunk della seconda superficie
|
||||
for ( int nCF = 0 ; nCF < m_pRegF->GetChunkCount() ; ++ nCF) {
|
||||
// ciclo sui bordi dei chunk
|
||||
for ( int nLF = 0 ; nLF < m_pRegF->GetLoopCount( nCF) ; ++ nLF) {
|
||||
|
||||
// curva corrente del chunk della seconda regione in locale nel riferimento intrinseco della prima
|
||||
const ICurve* pCrv2Loc = nullptr ;
|
||||
PtrOwner<ICurve> pCopyCrv ;
|
||||
if ( AreSameFrame( m_pRegM->m_frF, m_pRegF->m_frF))
|
||||
pCrv2Loc = m_pRegF->GetMyLoop( nCF, nLF) ;
|
||||
else {
|
||||
pCopyCrv.Set( m_pRegF->GetMyLoop( nCF, nLF)->Clone()) ;
|
||||
if ( IsNull( pCopyCrv))
|
||||
return false ;
|
||||
pCopyCrv->LocToLoc( m_pRegF->m_frF, m_pRegM->m_frF) ;
|
||||
pCrv2Loc = pCopyCrv ;
|
||||
}
|
||||
const CurveComposite* pCompo2 = GetBasicCurveComposite( pCrv2Loc) ;
|
||||
|
||||
// ciclo sui chunk della prima superficie
|
||||
for ( int nCM = 0 ; nCM < m_pRegM->GetChunkCount() ; ++ nCM) {
|
||||
// ciclo sui bordi del chunk
|
||||
for ( int nLM = 0 ; nLM < m_pRegM->GetLoopCount( nCM) ; ++ nLM) {
|
||||
|
||||
// per CAv non ha senso confrontare due loop interni tra di loro.
|
||||
// posso confrontatare - due loop esterni (come per la CAvSimpleSurfFrMove)
|
||||
// - un loop esterno con uno interno (nel caso in cui un Chunk sia contenuto dentro un isola)
|
||||
if ( nLF > 0 && nLM > 0)
|
||||
continue ;
|
||||
|
||||
// curva corrente del chunk della prima regione (ovviamente già in locale al riferimento intrinseco)
|
||||
const ICurve* pCrv1Loc = m_pRegM->GetMyLoop( nCM, nLM) ;
|
||||
const CurveComposite* pCompo1 = GetBasicCurveComposite( pCrv1Loc) ;
|
||||
|
||||
// verifico la collisione tra le entità dei loop esterni dei due chunk
|
||||
int k = 0 ;
|
||||
const ICurve* pCrv1 = ( pCompo1 != nullptr ? pCompo1->GetFirstCurve() : pCrv1Loc) ;
|
||||
while ( pCrv1 != nullptr) {
|
||||
int l = 0 ;
|
||||
const ICurve* pCrv2 = ( pCompo2 != nullptr ? pCompo2->GetFirstCurve() : pCrv2Loc) ;
|
||||
while ( pCrv2 != nullptr) {
|
||||
SCollInfo cInfoCurr ;
|
||||
double dPrevLenXY = dNewLenXY ;
|
||||
if ( ! TranslateCurveNoCollisionCurve( pCrv1, pCrv2, vtDirL, dNewLenXY, cInfoCurr))
|
||||
return false ;
|
||||
if ( abs( dNewLenXY - dPrevLenXY) < EPS_SMALL) {
|
||||
if ( cInfoCurr.nType == SCI_LINE_LINE || cInfoCurr.nType == SCI_PNT_LINE) {
|
||||
m_SCollInfo = cInfoCurr ;
|
||||
m_SCollInfo.nChunkM = nCM ;
|
||||
m_SCollInfo.nLoopM = nLM ;
|
||||
m_SCollInfo.nCrvM = k ;
|
||||
m_SCollInfo.nChunkF = nCF ;
|
||||
m_SCollInfo.nLoopF = nLF ;
|
||||
m_SCollInfo.nCrvF = l ;
|
||||
}
|
||||
}
|
||||
else if ( dNewLenXY < dPrevLenXY) {
|
||||
m_SCollInfo = cInfoCurr ;
|
||||
m_SCollInfo.nChunkM = nCM ;
|
||||
m_SCollInfo.nLoopM = nLM ;
|
||||
m_SCollInfo.nCrvM = k ;
|
||||
m_SCollInfo.nChunkF = nCF ;
|
||||
m_SCollInfo.nLoopF = nLF ;
|
||||
m_SCollInfo.nCrvF = l ;
|
||||
}
|
||||
pCrv2 = ( pCompo2 != nullptr ? pCompo2->GetNextCurve() : nullptr) ;
|
||||
++ l ;
|
||||
}
|
||||
pCrv1 = ( pCompo1 != nullptr ? pCompo1->GetNextCurve() : nullptr) ;
|
||||
++ k ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se da limitare il movimento
|
||||
if ( dNewLenXY < dLenXY - EPS_SMALL)
|
||||
dLen *= dNewLenXY / dLenXY ;
|
||||
|
||||
// porto i punti e le direzioni di SCollInfo da intrinseco a locale della prima regione
|
||||
if ( m_SCollInfo.nType != SCI_NONE) {
|
||||
m_SCollInfo.ptP1.ToGlob( m_pRegM->m_frF) ;
|
||||
m_SCollInfo.vtDirM.ToGlob( m_pRegM->m_frF) ;
|
||||
m_SCollInfo.vtDirF.ToGlob( m_pRegM->m_frF) ;
|
||||
}
|
||||
if ( m_SCollInfo.nType == SCI_LINE_LINE)
|
||||
m_SCollInfo.ptP2.ToGlob( m_pRegM->m_frF) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MyCAvSurfFrMove::Rotate( const Point3d& ptCen, double& dAng)
|
||||
{
|
||||
// verifico validità regioni
|
||||
if ( m_pRegM == nullptr || m_pRegF == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifico che le due regioni giacciano in piani paralleli
|
||||
if ( ! AreSameVectorApprox( m_pRegM->m_frF.VersZ(), m_pRegF->m_frF.VersZ()))
|
||||
return false ;
|
||||
|
||||
// reset info di collisione
|
||||
m_SCollInfo.nType = SCI_NONE ;
|
||||
|
||||
// porto il centro di rotazione nel riferimento intrinseco e ne annullo la componente Z
|
||||
Point3d ptCenL = ptCen ;
|
||||
ptCenL.ToLoc( m_pRegM->m_frF) ;
|
||||
ptCenL.z = 0 ;
|
||||
if ( abs( dAng) < EPS_ANG_SMALL)
|
||||
return true ;
|
||||
double dNewAng = dAng ;
|
||||
|
||||
// ciclo sui chunk della seconda superficie
|
||||
for ( int nCF = 0 ; nCF < m_pRegF->GetChunkCount() ; ++ nCF) {
|
||||
// ciclo sui bordi del Chunk
|
||||
for ( int nLF = 0 ; nLF < m_pRegF->GetLoopCount( nCF) ; ++ nLF) {
|
||||
|
||||
// curva corrente del chunk della seconda regione in locale nel riferimento intrinseco della prima
|
||||
const ICurve* pCrv2Loc = nullptr ;
|
||||
PtrOwner<ICurve> pCopyCrv ;
|
||||
if ( AreSameFrame( m_pRegM->m_frF, m_pRegF->m_frF))
|
||||
pCrv2Loc = m_pRegF->GetMyLoop( nCF, nLF) ;
|
||||
else {
|
||||
pCopyCrv.Set( m_pRegF->GetMyLoop( nCF, nLF)->Clone()) ;
|
||||
if ( IsNull( pCopyCrv))
|
||||
return false ;
|
||||
pCopyCrv->LocToLoc( m_pRegF->m_frF, m_pRegM->m_frF) ;
|
||||
pCrv2Loc = pCopyCrv ;
|
||||
}
|
||||
const CurveComposite* pCompo2 = GetBasicCurveComposite( pCrv2Loc) ;
|
||||
|
||||
// ciclo sui chunk della prima superficie
|
||||
for ( int nCM = 0 ; nCM < m_pRegM->GetChunkCount() ; ++ nCM) {
|
||||
// ciclo sui bordi del chunk
|
||||
for ( int nLM = 0 ; nLM < m_pRegM->GetLoopCount( nCM) ; ++ nLM) {
|
||||
|
||||
// per CAv non ha senso confrontare due loop interni tra di loro.
|
||||
// posso confrontatare - due loop esterni (come per la CAvSimpleSurfFrMove)
|
||||
// - un loop esterno con uno interno (nel caso in cui un Chunk sia contenuto dentro un isola)
|
||||
if ( nLF > 0 && nLM > 0)
|
||||
continue ;
|
||||
|
||||
// curva esterna del chunk della prima regione (ovviamente già in locale al riferimento intrinseco)
|
||||
const ICurve* pCrv1Loc = m_pRegM->GetMyLoop( nCM, nLM) ;
|
||||
const CurveComposite* pCompo1 = GetBasicCurveComposite( pCrv1Loc) ;
|
||||
|
||||
// verifico la collisione tra le entità dei loop esterni dei due chunk
|
||||
const ICurve* pCrv1 = ( pCompo1 != nullptr ? pCompo1->GetFirstCurve() : pCrv1Loc) ;
|
||||
while ( pCrv1 != nullptr) {
|
||||
const ICurve* pCrv2 = ( pCompo2 != nullptr ? pCompo2->GetFirstCurve() : pCrv2Loc) ;
|
||||
while ( pCrv2 != nullptr) {
|
||||
if ( ! RotateCurveNoCollisionCurve( pCrv1, pCrv2, ptCenL, dNewAng))
|
||||
return false ;
|
||||
pCrv2 = ( pCompo2 != nullptr ? pCompo2->GetNextCurve() : nullptr) ;
|
||||
}
|
||||
pCrv1 = ( pCompo1 != nullptr ? pCompo1->GetNextCurve() : nullptr) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se da limitare il movimento
|
||||
if ( ( dAng > 0 && dNewAng < dAng - EPS_ANG_SMALL) ||
|
||||
( dAng < 0 && dNewAng > dAng + EPS_ANG_SMALL))
|
||||
dAng = dNewAng ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : CAvSurfFrMove.h Data : 27.04.18 Versione : 3.1c7
|
||||
// Contenuto : Dich.ne classe privata per movimento di superfici flat region
|
||||
// nel loro piano evitando collisioni
|
||||
//
|
||||
// Modifiche : 26.03.2026 RE Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CAvSimpleSurfFrMove.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class MyCAvSurfFrMove : public MyCAvSimpleSurfFrMove
|
||||
{
|
||||
public :
|
||||
MyCAvSurfFrMove( const ISurfFlatRegion& SfrM, const ISurfFlatRegion& SfrF) :
|
||||
MyCAvSimpleSurfFrMove( SfrM, SfrF) {} ;
|
||||
|
||||
public :
|
||||
bool Translate( const Vector3d& vtDir, double& dLen) ;
|
||||
bool Rotate( const Point3d& ptCen, double& dAng) ;
|
||||
const SCollInfo& GetCollInfo()
|
||||
{ return m_SCollInfo ; }
|
||||
} ;
|
||||
+404
-119
@@ -45,6 +45,7 @@ using namespace std ;
|
||||
struct PocketParams {
|
||||
int nType = POCKET_SPIRALIN ; // tipo di lavorazione
|
||||
int nLiType = LEAD_IN_NONE ; // tipo di ingresso (LeadIn)
|
||||
int nLoType = LEAD_OUT_NONE ; // tipo di uscita (LeadOut)
|
||||
double dRad = 0. ; // raggio utensile
|
||||
double dRad_prec = -1. ; // raggio utensile della lavorazione precedente
|
||||
double dSideStep = 0. ; // step
|
||||
@@ -55,8 +56,10 @@ struct PocketParams {
|
||||
double dOpenMinSafe = 5. ; // estensione minima di sicurezza
|
||||
double dMaxOptSize = 0. ; // dimensione per ottimizzazione
|
||||
double dAngle = 0. ; // angolo per orientare le passate OneWay e ZigZag
|
||||
double dSmooth = 5. ; // parametro di smusso per link ( raccordo )
|
||||
double dLiTang = INFINITO ; // valore di LeadIn in ingresso
|
||||
double dSmooth = 5. ; // parametro di smusso per link (raccordo)
|
||||
double dLiTang = INFINITO ; // valore tangente di LeadIn
|
||||
double dLiElev = INFINITO ; // valore elevazione di LeadIn (usato anche per LeadOut)
|
||||
double dLoTang = INFINITO ; // valore di LeadOut
|
||||
bool bCalcUnclearedRegs = true ; // flag per calcolare o meno le regioni non svuotate
|
||||
bool bOptOffsets = true ; // flag per evitare Offset non necessari
|
||||
bool bAboveHead = true ; // flag per testa da sopra ( Z+)
|
||||
@@ -77,6 +80,10 @@ struct PocketParams {
|
||||
Frame3d frLocXY ; // frame per conti nel piano XY
|
||||
int nOffsType = ICurve::OFF_FILLET ; // tipologia di Offset per estensione degli aperti
|
||||
double dOpenEdgeRad = 0. ; // raggio effettivo di estensione degli aperti
|
||||
// --------------------------------------------------------
|
||||
bool bPolishing = false ; // flag per lucidatura
|
||||
double dEpicyclesRad = 0. ; // raggio degli epicicli
|
||||
double dEpicyclesDist = 0. ; // distanza degli epicicli
|
||||
} ;
|
||||
static double TOL_TRAPEZOID = 50 * EPS_SMALL ; // tolleranza per casi a trapezio SpiralPocket
|
||||
static double TOL_REMOVE_OFFSET = 2. ; // tolleranza per controllo materiale lasciato da un Offset
|
||||
@@ -1601,6 +1608,8 @@ AdjustContourWithOpenEdges( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vCrvI
|
||||
double dDiamJ = 1.05 * ( dDiam) + 2 * dOffR ;
|
||||
if ( abs( PockParams.dMaxOpenEdgeRad) > 0)
|
||||
dDiamJ = 100 * EPS_SMALL ;
|
||||
else if ( PockParams.nType == POCKET_CONFORMAL_ZIGZAG || PockParams.nType == POCKET_CONFORMAL_ONEWAY)
|
||||
dDiamJ = 1.05 * ( PockParams.dRad + dRad) + dOffR ;
|
||||
// NB. 1.05 serve per eccedere leggermente, in modo che il contro-offset della prima curva di svuotatura presenti
|
||||
// dei piccoli archi tra i chiusi e gli aperti ( in modo da svuotare bene lungo il chiuso)
|
||||
|
||||
@@ -1662,33 +1671,34 @@ AdjustContourWithOpenEdges( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vCrvI
|
||||
static bool
|
||||
ChainCompoCurves( ICRVCOMPOPOVECTOR& vCrvCompo)
|
||||
{
|
||||
/* concatenamento delle curve composite */
|
||||
if ( int( vCrvCompo.size() < 2))
|
||||
// concatenamento delle curve composite
|
||||
if ( ssize( vCrvCompo) < 2)
|
||||
return true ;
|
||||
|
||||
// controllo validità delle curve
|
||||
for ( int i = 0 ; i < int( vCrvCompo.size()) ; ++ i)
|
||||
for ( int i = 0 ; i < ssize( vCrvCompo) ; ++ i) {
|
||||
if ( IsNull( vCrvCompo[i]) || ! vCrvCompo[i]->IsValid())
|
||||
return false ;
|
||||
}
|
||||
|
||||
// preparo i dati per il concatenamento
|
||||
bool bFirst = true ;
|
||||
Point3d ptNear = ORIG ;
|
||||
double dToler = 500 * EPS_SMALL ; // leggermente maggiore della tolleranza sulla superficie limite
|
||||
double dToler = 500. * EPS_SMALL ; // leggermente maggiore della tolleranza sulla superficie limite
|
||||
ChainCurves chainC ;
|
||||
chainC.Init( false, dToler, int( vCrvCompo.size())) ;
|
||||
for ( int i = 0 ; i < int( vCrvCompo.size()) ; ++ i) {
|
||||
chainC.Init( false, dToler, ssize( vCrvCompo)) ; // evito inversioni, le curve devono essere coerenti
|
||||
for ( int i = 0 ; i < ssize( vCrvCompo) ; ++ i) {
|
||||
// recupero i dati della curva necessari al concatenamento e li assegno
|
||||
Point3d ptStart, ptEnd ;
|
||||
Vector3d vtStart, vtEnd ;
|
||||
if ( ! vCrvCompo[i]->GetStartPoint( ptStart) || ! vCrvCompo[i]->GetStartDir( vtStart) ||
|
||||
! vCrvCompo[i]->GetEndPoint( ptEnd) || ! vCrvCompo[i]->GetEndDir( vtEnd))
|
||||
return false ;
|
||||
if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd))
|
||||
if ( ! chainC.AddCurve( i + 1, ptStart, vtStart, ptEnd, vtEnd))
|
||||
return false ;
|
||||
// se prima curva, assegno inizio della ricerca
|
||||
if ( bFirst) {
|
||||
ptNear = ptStart + 10 * EPS_SMALL * vtStart ;
|
||||
ptNear = ptStart + 10. * EPS_SMALL * vtStart ;
|
||||
bFirst = false ;
|
||||
}
|
||||
}
|
||||
@@ -1704,14 +1714,14 @@ ChainCompoCurves( ICRVCOMPOPOVECTOR& vCrvCompo)
|
||||
if ( IsNull( pCrvCompo))
|
||||
return false ;
|
||||
// recupero le curve semplici e le inserisco nella curva composita
|
||||
for ( size_t i = 0 ; i < vnInd.size() ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vnInd) ; ++ i) {
|
||||
int nId = abs( vnInd[i]) - 1 ;
|
||||
bool bInvert = ( vnInd[i] < 0) ;
|
||||
// se necessario, la inverto
|
||||
if ( bInvert)
|
||||
vCrvCompo[nId]->Invert() ;
|
||||
// la aggiungo alla curva composta
|
||||
if ( ! pCrvCompo->AddCurve( ::Release( vCrvCompo[nId]), true, dToler))
|
||||
if ( ! pCrvCompo->AddCurve( Release( vCrvCompo[nId]), true, dToler))
|
||||
return false ;
|
||||
}
|
||||
// aggiorno il nuovo punto vicino
|
||||
@@ -1735,15 +1745,18 @@ ChangePtStartForSinglePocketCurve( ICurveComposite* pCrvCompo, const PocketParam
|
||||
return false ;
|
||||
|
||||
// se la curva è aperta
|
||||
if ( ! pCrvCompo->IsClosed() && bInvertOpenCrv) {
|
||||
// se non ho un punto di riferimento, allora non faccio nulla
|
||||
if ( ! ptRef.IsValid())
|
||||
return true ;
|
||||
// se ho un punto di riferimento controllo quale estremo è più vicino
|
||||
Point3d ptStart ; pCrvCompo->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pCrvCompo->GetEndPoint( ptEnd) ;
|
||||
if ( SqDist( ptRef, ptEnd) < SqDist( ptRef, ptStart))
|
||||
pCrvCompo->Invert() ;
|
||||
if ( ! pCrvCompo->IsClosed()) {
|
||||
// se richiesta inversione
|
||||
if ( bInvertOpenCrv) {
|
||||
// se non ho un punto di riferimento, non faccio nulla
|
||||
if ( ! ptRef.IsValid())
|
||||
return true ;
|
||||
// se ho un punto di riferimento controllo quale estremo è più vicino
|
||||
Point3d ptStart ; pCrvCompo->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pCrvCompo->GetEndPoint( ptEnd) ;
|
||||
if ( SqDist( ptRef, ptEnd) < SqDist( ptRef, ptStart))
|
||||
pCrvCompo->Invert() ;
|
||||
}
|
||||
}
|
||||
// se la curva è chiusa
|
||||
else {
|
||||
@@ -1772,13 +1785,12 @@ static bool
|
||||
AdvanceExtendCurves( ICRVCOMPOPOVECTOR& vCrvCompo, const ISurfFlatRegion* pSfr,
|
||||
const PocketParams& PockParams, bool bInvertOpenCrv)
|
||||
{
|
||||
|
||||
// se non ho curve, allora non faccio nulla
|
||||
if ( vCrvCompo.empty())
|
||||
return true ;
|
||||
|
||||
// per ogni curva composita...
|
||||
for ( int i = 0 ; i < int( vCrvCompo.size()) ; ++ i) {
|
||||
// per ogni curva
|
||||
for ( int i = 0 ; i < ssize( vCrvCompo) ; ++ i) {
|
||||
// controllo validità della curva
|
||||
if ( IsNull( vCrvCompo[i]) || ! vCrvCompo[i]->IsValid())
|
||||
return false ;
|
||||
@@ -1800,7 +1812,7 @@ AdvanceExtendCurves( ICRVCOMPOPOVECTOR& vCrvCompo, const ISurfFlatRegion* pSfr,
|
||||
|
||||
// scorro ogni singola curva composita
|
||||
const int MAX_ITER = 4 ;
|
||||
for ( int i = 0 ; i < int( vCrvCompo.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCrvCompo) ; ++ i) {
|
||||
// controllo se la curva è chiusa o aperta
|
||||
bool bIsClosed = vCrvCompo[i]->IsClosed() ;
|
||||
// calcolo il numero massimo di punti in cui testare l'entrata da fuori
|
||||
@@ -1851,10 +1863,10 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
// controllo se la superficie si annulla con un controOffset del raggio utensile
|
||||
double dMaxOffs ;
|
||||
pSfrChunk->GetMaxOffset( dMaxOffs) ;
|
||||
if ( dMaxOffs > PockParams.dRad + 200 * EPS_SMALL)
|
||||
if ( dMaxOffs > PockParams.dRad + 200. * EPS_SMALL)
|
||||
return true ;
|
||||
// controllo che il MaxOptSize sia coerente
|
||||
if ( 2 * dMaxOffs > PockParams.dMaxOptSize + 10 * EPS_SMALL)
|
||||
if ( 2. * dMaxOffs > PockParams.dMaxOptSize + 10. * EPS_SMALL)
|
||||
return true ;
|
||||
|
||||
/*
|
||||
@@ -1874,8 +1886,8 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
// recupero i tratti con proprietà uniformi
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
GetHomogeneousParts( pCrvExtLoop, PockParams, vpCrvs) ;
|
||||
if ( vpCrvs.size() > 1) { // unisco il primo e l'ultimo se estremi compatibili
|
||||
// NB. GetHomogeneousParts() cambia il punto di inizio nel lato chiuso più lungo ( se presente)
|
||||
// unisco il primo e l'ultimo se estremi compatibili
|
||||
if ( ssize( vpCrvs) > 1) {
|
||||
Point3d ptE ; vpCrvs.back()->GetEndPoint( ptE) ;
|
||||
Point3d ptS ; vpCrvs[0]->GetStartPoint( ptS) ;
|
||||
if ( AreSamePointApprox( ptS, ptE)) {
|
||||
@@ -1889,15 +1901,15 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
// controllo se il loop Esterno è uniforme ( quindi tutto chiuso o tutto aperto)
|
||||
bool bExtAllClose = false ;
|
||||
bool bExtAllOpen = false ;
|
||||
if ( int( vpCrvs.size()) == 1) {
|
||||
if ( ssize( vpCrvs) == 1) {
|
||||
if ( vpCrvs[0]->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE)
|
||||
bExtAllClose = true ;
|
||||
else
|
||||
bExtAllOpen = true ;
|
||||
}
|
||||
// NB. Se regione estena tutta chiusa o aperta e senza isole... allora non faccio nulla ( es caso trapezi)
|
||||
// NB. Se regione estena tutta chiusa o aperta e senza isole, non faccio nulla ( es. caso trapezi)
|
||||
// Se tutta chiusa -> Chunk non svuotabile, il contro-offset del raggio utensile annulla la regione
|
||||
// Se tutta aperta -> La regione è definita mediante Offset esterno del contorno aperto
|
||||
// Se tutta aperta -> La regione è definita mediante Offset esterno del contorno aperto
|
||||
if ( ( bExtAllClose || bExtAllOpen) && ! bHasIslands)
|
||||
return true ;
|
||||
// Se il contorno esterno è misto -> non devo avere isole
|
||||
@@ -1909,9 +1921,9 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
|
||||
// scorro i chiusi e sottraggo la regione da loro creata mediante l'utensile
|
||||
// NB. Queste curve sono orientate in maniera corretta
|
||||
ICRVCOMPOPOVECTOR vCrvCompoRes_tmp ; // salvo il vettore di curve offsettate del raggio utensile
|
||||
ICRVCOMPOPOVECTOR vCrvCompoResTmp ; // salvo il vettore di curve offsettate del raggio utensile
|
||||
Voronoi myVRONI ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vpCrvs) ; ++ i) {
|
||||
// se tratto chiuso
|
||||
if ( vpCrvs[i]->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE)
|
||||
myVRONI.AddCurve( vpCrvs[i]) ;
|
||||
@@ -1919,8 +1931,8 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
// offset delle parti chiuse
|
||||
ICURVEPOVECTOR vCrvVroniOffs ;
|
||||
myVRONI.CalcOffset( vCrvVroniOffs, - PockParams.dRad - PockParams.dRadialOffset + EPS_SMALL, ICurve::OFF_FILLET) ;
|
||||
for ( int i = 0 ; i < int( vCrvVroniOffs.size()) ; ++ i)
|
||||
vCrvCompoRes_tmp.emplace_back( ConvertCurveToComposite( Release( vCrvVroniOffs[i]))) ;
|
||||
for ( int i = 0 ; i < ssize( vCrvVroniOffs) ; ++ i)
|
||||
vCrvCompoResTmp.emplace_back( ConvertCurveToComposite( Release( vCrvVroniOffs[i]))) ;
|
||||
|
||||
/*
|
||||
Casi gestiti :
|
||||
@@ -1937,22 +1949,22 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
bool bValidIslands = true ; // flag per isole tutte uniformi
|
||||
for ( int i = 1 ; i < pSfrChunk->GetLoopCount( 0) && bValidIslands ; ++ i) {
|
||||
// controllo uniformità dell'isola
|
||||
int nCurrTmpProp = -1 ;
|
||||
int nPrecTmpProp = -1 ;
|
||||
int nCurrTmpProp = TEMP_PROP_INVALID ;
|
||||
int nPrecTmpProp = TEMP_PROP_INVALID ;
|
||||
bool bIsMixed = false ;
|
||||
PtrOwner<ICurveComposite> pCrvIsl( ConvertCurveToComposite( pSfrChunk->GetLoop( 0, i))) ;
|
||||
if ( IsNull( pCrvIsl) || ! pCrvIsl->IsValid())
|
||||
return false ;
|
||||
for ( int u = 0 ; u < pCrvIsl->GetCurveCount() && ! bIsMixed ; ++ u) {
|
||||
pCrvIsl->GetCurveTempProp( u, nCurrTmpProp, 0) ;
|
||||
bIsMixed = ( u != 0 && nCurrTmpProp != nPrecTmpProp) ;
|
||||
for ( int nU = 0 ; nU < pCrvIsl->GetCurveCount() && ! bIsMixed ; ++ nU) {
|
||||
pCrvIsl->GetCurveTempProp( nU, nCurrTmpProp, 0) ;
|
||||
bIsMixed = ( nU != 0 && nCurrTmpProp != nPrecTmpProp) ;
|
||||
nPrecTmpProp = nCurrTmpProp ;
|
||||
}
|
||||
// se proprità non uniformi -> tutta chiusa ( isole non uniformi non sono definite)
|
||||
if ( bIsMixed) {
|
||||
for ( int u = 0 ; u < pCrvIsl->GetCurveCount() ; ++ u)
|
||||
pCrvIsl->SetTempProp( u, TEMP_PROP_CLOSE_EDGE) ;
|
||||
nCurrTmpProp = 0 ; // aggiorno il Flag
|
||||
for ( int nU = 0 ; nU < pCrvIsl->GetCurveCount() ; ++ nU)
|
||||
pCrvIsl->SetTempProp( nU, TEMP_PROP_CLOSE_EDGE) ;
|
||||
nCurrTmpProp = TEMP_PROP_CLOSE_EDGE ; // aggiorno il Flag
|
||||
}
|
||||
// 2) e 3)
|
||||
bValidIslands = ( ( nCurrTmpProp == TEMP_PROP_CLOSE_EDGE && bExtAllOpen) ||
|
||||
@@ -1966,44 +1978,46 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
PtrOwner<ISurfFlatRegion> pSrfIslands( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSrfIslands))
|
||||
return false ;
|
||||
for ( int i = 1 ; i < pSfrChunk->GetLoopCount( 0) ; ++ i) {
|
||||
pSrfIslands->AddExtLoop( pSfrChunk->GetLoop( 0, i)) ;
|
||||
vpCrvs.emplace_back( ConvertCurveToComposite( pSfrChunk->GetLoop( 0, i))) ;
|
||||
for ( int nL = 1 ; nL < pSfrChunk->GetLoopCount( 0) ; ++ nL) {
|
||||
pSrfIslands->AddExtLoop( pSfrChunk->GetLoop( 0, nL)) ;
|
||||
vpCrvs.emplace_back( ConvertCurveToComposite( pSfrChunk->GetLoop( 0, nL))) ;
|
||||
}
|
||||
pSrfIslands->Offset( PockParams.dRad + PockParams.dRadialOffset, ICurve::OFF_FILLET) ;
|
||||
for ( int nC = 0 ; nC < pSrfIslands->GetChunkCount() ; ++ nC)
|
||||
for ( int nC = 0 ; nC < pSrfIslands->GetChunkCount() ; ++ nC) {
|
||||
for ( int nL = 0 ; nL < pSrfIslands->GetLoopCount( nL) ; ++ nL)
|
||||
vCrvCompoRes_tmp.emplace_back( ConvertCurveToComposite( pSrfIslands->GetLoop( nC, nL))) ;
|
||||
vCrvCompoResTmp.emplace_back( ConvertCurveToComposite( pSrfIslands->GetLoop( nC, nL))) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// se non ho ottenuto curve, allora ho finito
|
||||
if ( vCrvCompoRes_tmp.empty())
|
||||
if ( vCrvCompoResTmp.empty())
|
||||
return true ;
|
||||
|
||||
// controllo che effettivamente l'utensile svuoti la regione
|
||||
PtrOwner<ISurfFlatRegion> pSfrNoRemoved( CloneSurfFlatRegion( pSfrChunk)) ;
|
||||
if ( IsNull( pSfrNoRemoved) || ! pSfrNoRemoved->IsValid())
|
||||
PtrOwner<ISurfFlatRegion> pSfrNotRemoved( CloneSurfFlatRegion( pSfrChunk)) ;
|
||||
if ( IsNull( pSfrNotRemoved) || ! pSfrNotRemoved->IsValid())
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vCrvCompoRes_tmp.size()) ; ++ i) {
|
||||
PtrOwner<ISurfFlatRegion> pSfrRemoved( GetSurfFlatRegionFromFatCurve( CloneCurveComposite( vCrvCompoRes_tmp[i]), PockParams.dRad + PockParams.dRadialOffset + 50 * EPS_SMALL, false, false)) ;
|
||||
double dOffs = PockParams.dRad + PockParams.dRadialOffset + 50. * EPS_SMALL ;
|
||||
double dTol = 25. * EPS_SMALL ;
|
||||
for ( int i = 0 ; i < ssize( vCrvCompoResTmp) ; ++ i) {
|
||||
PtrOwner<ISurfFlatRegion> pSfrRemoved( GetSurfFlatRegionFromFatCurve( CloneCurveComposite( vCrvCompoResTmp[i]), dOffs, false, false)) ;
|
||||
if ( ! IsNull( pSfrRemoved) && pSfrRemoved->IsValid()) {
|
||||
if ( AreOppositeVectorEpsilon( pSfrRemoved->GetNormVersor(), pSfrNoRemoved->GetNormVersor(), 25. * EPS_SMALL))
|
||||
if ( AreOppositeVectorEpsilon( pSfrRemoved->GetNormVersor(), pSfrNotRemoved->GetNormVersor(), dTol))
|
||||
pSfrRemoved->Invert() ;
|
||||
pSfrNoRemoved->Subtract( *pSfrRemoved) ;
|
||||
pSfrNotRemoved->Subtract( *pSfrRemoved) ;
|
||||
}
|
||||
}
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vpCrvs) ; ++ i) {
|
||||
if ( vpCrvs[i]->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE) {
|
||||
PtrOwner<ISurfFlatRegion> pSfrRemoved( GetSurfFlatRegionFromFatCurve( CloneCurveComposite( vpCrvs[i]), PockParams.dRad + PockParams.dRadialOffset + 50 * EPS_SMALL, false, false)) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrRemoved( GetSurfFlatRegionFromFatCurve( CloneCurveComposite( vpCrvs[i]), dOffs, false, false)) ;
|
||||
if ( ! IsNull( pSfrRemoved) && pSfrRemoved->IsValid()) {
|
||||
if ( AreOppositeVectorEpsilon( pSfrRemoved->GetNormVersor(), pSfrNoRemoved->GetNormVersor(), 25. * EPS_SMALL))
|
||||
if ( AreOppositeVectorEpsilon( pSfrRemoved->GetNormVersor(), pSfrNotRemoved->GetNormVersor(), dTol))
|
||||
pSfrRemoved->Invert() ;
|
||||
pSfrNoRemoved->Subtract( *pSfrRemoved) ;
|
||||
pSfrNotRemoved->Subtract( *pSfrRemoved) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( pSfrNoRemoved->IsValid() && pSfrNoRemoved->GetChunkCount() > 0)
|
||||
if ( pSfrNotRemoved->IsValid() && pSfrNotRemoved->GetChunkCount() > 0)
|
||||
return true ;
|
||||
|
||||
bAllRemoved = true ;
|
||||
@@ -2012,42 +2026,41 @@ GetPocketCurvesByClosedEdges( const ISurfFlatRegion* pSfrChunk, const PocketPara
|
||||
PtrOwner<ISurfFlatRegion> pSfrLimit( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrLimit))
|
||||
return false ;
|
||||
|
||||
// per tutte le curve inserite, devo tenere solamente quelle esterne alla superficie limite
|
||||
if ( PockParams.SfrLimit.IsValid()) { // se esiste, allora classifico
|
||||
if ( PockParams.SfrLimit.IsValid()) {
|
||||
// recupero la superficie limite
|
||||
pSfrLimit.Set( PockParams.SfrLimit.Clone()) ;
|
||||
if ( IsNull( pSfrLimit) || ! pSfrLimit->IsValid())
|
||||
return false ;
|
||||
// effettuo un Offset della regione, tutto ciò che dista più del raggio utensile non la rovina
|
||||
pSfrLimit->Offset( PockParams.dRad + PockParams.dRadialOffset - 25 * EPS_SMALL, ICurve::OFF_FILLET) ; // c'è un offset radiale, quindi tengo tolleranza alta
|
||||
ICRVCOMPOPOVECTOR vCrvCompoRes_tmp_Splitted ;
|
||||
for ( int i = 0 ; i < int( vCrvCompoRes_tmp.size()) ; ++ i) {
|
||||
pSfrLimit->Offset( PockParams.dRad + PockParams.dRadialOffset - dTol, ICurve::OFF_FILLET) ; // c'è un offset radiale, quindi tengo tolleranza alta
|
||||
ICRVCOMPOPOVECTOR vCrvCompoResTmpSplitted ;
|
||||
for ( int i = 0 ; i < ssize( vCrvCompoResTmp) ; ++ i) {
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( pSfrLimit->GetCurveClassification( *vCrvCompoRes_tmp[i], EPS_SMALL, ccClass)) {
|
||||
for ( int j = 0 ; j < int( ccClass.size()) ; ++ j) {
|
||||
if ( pSfrLimit->GetCurveClassification( *vCrvCompoResTmp[i], EPS_SMALL, ccClass)) {
|
||||
for ( int j = 0 ; j < ssize( ccClass) ; ++ j) {
|
||||
if ( ccClass[j].nClass == CRVC_OUT) {
|
||||
PtrOwner<ICurveComposite> pCrvRes( ConvertCurveToComposite( vCrvCompoRes_tmp[i]->CopyParamRange( ccClass[j].dParS, ccClass[j].dParE))) ;
|
||||
PtrOwner<ICurveComposite> pCrvRes( ConvertCurveToComposite( vCrvCompoResTmp[i]->CopyParamRange( ccClass[j].dParS, ccClass[j].dParE))) ;
|
||||
if ( ! IsNull( pCrvRes) && pCrvRes->IsValid())
|
||||
vCrvCompoRes_tmp_Splitted.emplace_back( Release( pCrvRes)) ;
|
||||
vCrvCompoResTmpSplitted.emplace_back( Release( pCrvRes)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se non ho curve, allora esco
|
||||
if ( vCrvCompoRes_tmp_Splitted.empty())
|
||||
if ( vCrvCompoResTmpSplitted.empty())
|
||||
return true ;
|
||||
// altrimenti aggiorno il vettore di curve con quelle solo esterne alla regione limite
|
||||
swap( vCrvCompoRes_tmp, vCrvCompoRes_tmp_Splitted) ;
|
||||
swap( vCrvCompoResTmp, vCrvCompoResTmpSplitted) ;
|
||||
}
|
||||
|
||||
// salvo come primo tempParam l'offset massimo della regione ( servirà per la Feed)
|
||||
for ( int i = 0 ; i < int( vCrvCompoRes_tmp.size()) ; ++ i) {
|
||||
vCrvCompoRes_tmp[i]->SetTempParam( dMaxOffs, 0) ;
|
||||
for ( int i = 0 ; i < ssize( vCrvCompoResTmp) ; ++ i) {
|
||||
vCrvCompoResTmp[i]->SetTempParam( dMaxOffs, 0) ;
|
||||
// se richiesta inversione della curva, allora inverto
|
||||
if ( PockParams.bInvert)
|
||||
vCrvCompoRes_tmp[i]->Invert() ;
|
||||
vCrvCompoRes.emplace_back( Release( vCrvCompoRes_tmp[i])) ; // aggiungo la curva al vettore
|
||||
vCrvCompoResTmp[i]->Invert() ;
|
||||
vCrvCompoRes.emplace_back( Release( vCrvCompoResTmp[i])) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -2064,8 +2077,8 @@ GetSinglePocketingCurves( ISurfFlatRegion* pSfr, PocketParams& PockParams,
|
||||
vCrvSingleCurves.clear() ;
|
||||
|
||||
// tengo una copia della superficie ( serve per l'estensione dei percorsi fuori dal grezzo)
|
||||
PtrOwner<ISurfFlatRegion> pSfr_clone( CloneSurfFlatRegion( pSfr)) ;
|
||||
if ( IsNull( pSfr_clone) || ! pSfr_clone->IsValid())
|
||||
PtrOwner<ISurfFlatRegion> pSfrClone( CloneSurfFlatRegion( pSfr)) ;
|
||||
if ( IsNull( pSfrClone) || ! pSfrClone->IsValid())
|
||||
return false ;
|
||||
|
||||
// scorro i Chunk della superficie
|
||||
@@ -2090,35 +2103,38 @@ GetSinglePocketingCurves( ISurfFlatRegion* pSfr, PocketParams& PockParams,
|
||||
// potrei doverle riconcatenare
|
||||
if ( ! ChainCompoCurves( vCrvSingleCurves))
|
||||
return false ;
|
||||
// estendo le curve, definendo ptStart e calcolando le Feeds (non inverto le curve aperte)
|
||||
if ( ! AdvanceExtendCurves( vCrvSingleCurves, pSfr_clone, PockParams, false))
|
||||
// estendo le curve, definendo ptStart e calcolando le Feeds
|
||||
if ( ! AdvanceExtendCurves( vCrvSingleCurves, pSfrClone, PockParams, false))
|
||||
return false ;
|
||||
// imposto le Feed per tali curve se richiesto
|
||||
for ( int i = 0 ; i < int( vCrvSingleCurves.size()) ; ++ i) {
|
||||
|
||||
// imposto le Feed e inverto i percorsi per tali curve se richiesto
|
||||
bool bAllowInvert = ( PockParams.nType == POCKET_ZIGZAG || PockParams.nType == POCKET_CONFORMAL_ZIGZAG) ;
|
||||
for ( int i = 0 ; i < ssize( vCrvSingleCurves) ; ++ i) {
|
||||
/*
|
||||
Idea : Feed proporzionale al minimo Offset per annullare la regione
|
||||
-> Massimo parametro sui bisettori di VORONOI
|
||||
se le curve risultano aperte, cambio il loro punto iniziale a seconda dell'estensione fatta
|
||||
*/
|
||||
if ( vCrvSingleCurves[i]->IsValid() && vCrvSingleCurves[i]->GetCurveCount() != 0 &&
|
||||
! vCrvSingleCurves[i]->IsClosed()) {
|
||||
int nTempProp_firstCrv = vCrvSingleCurves[i]->GetFirstCurve()->GetTempProp( 0) ;
|
||||
int nTempProp_lastCrv = vCrvSingleCurves[i]->GetLastCurve()->GetTempProp( 0) ;
|
||||
if ( vCrvSingleCurves[i]->IsValid() && vCrvSingleCurves[i]->GetCurveCount() > 0 && ! vCrvSingleCurves[i]->IsClosed()) {
|
||||
int nFirstTempProp = vCrvSingleCurves[i]->GetFirstCurve()->GetTempProp( 0) ;
|
||||
int nLastTempProp = vCrvSingleCurves[i]->GetLastCurve()->GetTempProp( 0) ;
|
||||
// se estremi entrambi estesi
|
||||
if ( nTempProp_firstCrv == TEMP_PROP_OUT_START && nTempProp_lastCrv == TEMP_PROP_OUT_START) {
|
||||
// !!! ---> cancellare se si vuole evitare inversione delle curve <--- !!!
|
||||
if ( PockParams.ptStart.IsValid()) {
|
||||
Point3d ptStart ; vCrvSingleCurves[i]->GetStartPoint( ptStart) ;
|
||||
double dSqDist_first = SqDist( PockParams.ptStart, ptStart) ;
|
||||
Point3d ptEnd ; vCrvSingleCurves[i]->GetEndPoint( ptEnd) ;
|
||||
double dSqDist_last = SqDist( PockParams.ptStart, ptEnd) ;
|
||||
if ( dSqDist_last < dSqDist_first)
|
||||
vCrvSingleCurves[i]->Invert() ;
|
||||
vCrvSingleCurves[i]->GetEndPoint( PockParams.ptStart) ;
|
||||
if ( nFirstTempProp == TEMP_PROP_OUT_START && nLastTempProp == TEMP_PROP_OUT_START) {
|
||||
// se inversione delle curve accettata
|
||||
if ( bAllowInvert) {
|
||||
if ( PockParams.ptStart.IsValid()) {
|
||||
Point3d ptStart ; vCrvSingleCurves[i]->GetStartPoint( ptStart) ;
|
||||
double dSqStartDist = SqDist( PockParams.ptStart, ptStart) ;
|
||||
Point3d ptEnd ; vCrvSingleCurves[i]->GetEndPoint( ptEnd) ;
|
||||
double dSqEndDist = SqDist( PockParams.ptStart, ptEnd) ;
|
||||
if ( dSqEndDist < dSqStartDist)
|
||||
vCrvSingleCurves[i]->Invert() ;
|
||||
}
|
||||
}
|
||||
vCrvSingleCurves[i]->GetEndPoint( PockParams.ptStart) ;
|
||||
}
|
||||
// se invece l'estensione è alla fine
|
||||
else if ( nTempProp_lastCrv == TEMP_PROP_OUT_START)
|
||||
// se invece l'estensione è alla fine, sono forzato ad invertila per entrare presso il lato aperto
|
||||
else if ( nLastTempProp == TEMP_PROP_OUT_START)
|
||||
vCrvSingleCurves[i]->Invert() ;
|
||||
}
|
||||
// recupero il MaxOffset per la curva
|
||||
@@ -2691,14 +2707,27 @@ IsForcedStepTrapezoid( const ICurveComposite* pCrvTrap, const PocketParams& Pock
|
||||
break ;
|
||||
// se ho tre lati chiusi
|
||||
case 3 : {
|
||||
// diventa forzato se il lato aperto non è grande
|
||||
// diventa forzato se il lato aperto non ha una componente perpendicolare grande rispetto al chiuso precedente e successivo
|
||||
double dLenOpen = 0. ;
|
||||
for ( int i = 0 ; i < 4 ; ++ i) {
|
||||
if ( vnProps[i] == TEMP_PROP_OPEN_EDGE) {
|
||||
const ICurve* pCrvOpen = pCrvTrap->GetCurve( i) ;
|
||||
if ( pCrvOpen == nullptr || ! pCrvOpen->IsValid())
|
||||
return false ;
|
||||
// essendo nei casi a trapezio, ho solo segmenti
|
||||
pCrvOpen->GetLength( dLenOpen) ;
|
||||
Vector3d vtDir ; pCrvOpen->GetStartDir( vtDir) ;
|
||||
vtDir *= dLenOpen ;
|
||||
const ICurve* pCrvClosePrev = pCrvTrap->GetCurve( ( i == 0 ? 3 : i - 1)) ;
|
||||
if ( pCrvClosePrev == nullptr || ! pCrvClosePrev->IsValid())
|
||||
return false ;
|
||||
const ICurve* pCrvCloseAft = pCrvTrap->GetCurve( ( i == 3 ? 0 : i + 1)) ;
|
||||
if ( pCrvCloseAft == nullptr || ! pCrvCloseAft->IsValid())
|
||||
return false ;
|
||||
// essendo un trapezio queste due direzioni me le apsetto parallele tra loro
|
||||
Vector3d vtDirPrev ; pCrvClosePrev->GetEndDir( vtDirPrev) ;
|
||||
Vector3d vtDirAft ; pCrvCloseAft->GetStartDir( vtDirAft) ;
|
||||
dLenOpen = min( { OrthoCompo( vtDir, vtDirPrev).Len(), OrthoCompo( vtDir, vtDirAft).Len(), dLenOpen}) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@@ -6199,6 +6228,198 @@ CalcInversionForSpiralOffset( const ISurfFlatRegion* pSfrChunk)
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
AddEpicycles( const PocketParams& PockParam, ICurveComposite* pCompo, ICurveComposite* pCrv, ICurveComposite* pCrvBound)
|
||||
{
|
||||
// verifico che la curva sia valida
|
||||
if ( pCompo == nullptr || ! pCompo->IsValid())
|
||||
return false ;
|
||||
|
||||
// calcolo l'Offset definito dal valore dell'raggio dell'epiciclo
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( pCompo, PockParam.dEpicyclesRad, ICurve::OFF_FILLET) || OffsCrv.GetCurveCount() > 1)
|
||||
return false ;
|
||||
PtrOwner<ICurveComposite> pCrvOffs( GetCurveComposite( OffsCrv.GetCurve())) ;
|
||||
if ( IsNull( pCrvOffs))
|
||||
return false ;
|
||||
|
||||
// verifico se devo resitituire la curva offsettata
|
||||
if ( pCrvBound != nullptr)
|
||||
pCrvBound->AddCurve( pCrvOffs->Clone()) ;
|
||||
|
||||
pCrv->Clear() ;
|
||||
double dParPrec = 0. ;
|
||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; ++ i) {
|
||||
|
||||
// calcolo distanza epicili specifica per quel tratto
|
||||
double dLen ;
|
||||
pCompo->GetCurve( i)->GetLength( dLen) ;
|
||||
int nStep = max( 1, static_cast<int>( ceil( ( dLen) / PockParam.dEpicyclesDist))) ;
|
||||
double dStep = 1.0 / nStep ;
|
||||
|
||||
for ( int k = 1 ; k <= nStep ; ++ k) {
|
||||
// creo epiciclo
|
||||
Point3d ptCen ;
|
||||
Vector3d vtDir ;
|
||||
pCompo->GetCurve( i)->GetPointD1D2( k * dStep, ICurve::FROM_MINUS, ptCen, &vtDir) ;
|
||||
vtDir.Normalize() ;
|
||||
vtDir.Rotate( Z_AX, - 90.) ;
|
||||
Point3d pt = ptCen + vtDir * PockParam.dEpicyclesRad ;
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
pCrvArc->Set( ptCen, Z_AX, PockParam.dEpicyclesRad) ;
|
||||
double dU ;
|
||||
pCrvArc->GetParamAtPoint( pt, dU) ;
|
||||
pCrvArc->ChangeStartPoint( dU) ;
|
||||
|
||||
// aggiungo tratto della curva offsettata
|
||||
double dPar ;
|
||||
pCrvOffs->GetParamAtPoint( pt, dPar) ;
|
||||
bool bAdd = ( pCrv->AddCurve( pCrvOffs->CopyParamRange( dParPrec, dPar))) ;
|
||||
|
||||
// aggiungo epiciclo
|
||||
if ( ! pCrv->AddCurve( Release( pCrvArc))) {
|
||||
// se fallisco nell'aggiungere l'epiciclo tento nuovamente spostandolo di EPS_SMALL
|
||||
if ( bAdd)
|
||||
PtrOwner<ICurve> pCrvErased( pCrv->RemoveFirstOrLastCurve( true)) ;
|
||||
k -- ;
|
||||
dStep -= EPS_SMALL ;
|
||||
if ( dStep < EPS_SMALL)
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
dParPrec = dPar ;
|
||||
}
|
||||
}
|
||||
// se necessario ripristino orientamento originale
|
||||
if ( PockParam.bInvert)
|
||||
pCrv->Invert() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcBoundedPolishingLink( const Point3d& ptStart, const Vector3d& vtStart, const Point3d& ptEnd, const Vector3d& vtEnd,
|
||||
const ICurve* pCrvBound, ICurveComposite* pCrvLink)
|
||||
{
|
||||
double dAngStart, dAngEnd ;
|
||||
vtStart.GetAngleXY( X_AX, dAngStart) ;
|
||||
vtEnd.GetAngleXY( X_AX, dAngEnd) ;
|
||||
PtrOwner<ICurve> pBiArcLink( GetBiArc( ptStart, -dAngStart, ptEnd, -dAngEnd, 0.5)) ;
|
||||
if ( IsNull( pBiArcLink))
|
||||
return false ;
|
||||
|
||||
// verifico se esce dalla svuotatura
|
||||
CRVCVECTOR ccClass ;
|
||||
IntersCurveCurve intCC( *pBiArcLink, *pCrvBound) ;
|
||||
intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ;
|
||||
// se nessuno o un solo tratto e interno, il biarco è il collegamento
|
||||
if ( ccClass.empty() || ( ssize( ccClass) == 1 && ccClass[0].nClass == CRVC_IN)) {
|
||||
pCrvLink->AddCurve( Release( pBiArcLink)) ;
|
||||
}
|
||||
// altrimenti creo un percorso con biarchi e opportuni tratti della curva di contenimento
|
||||
else {
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
|
||||
double dPar1, dPar2 ;
|
||||
Point3d ptMinDist1, ptMinDist2 ;
|
||||
Vector3d vtDir1, vtDir2 ;
|
||||
double dAng1, dAng2 ;
|
||||
int nFlag ;
|
||||
|
||||
DistPointCurve distPtSCrv( ptStart, *pCrvBound) ;
|
||||
distPtSCrv.GetParamAtMinDistPoint( 0, dPar1, nFlag) ;
|
||||
pCrvBound->GetPointTang( dPar1, ICurve::FROM_MINUS, ptMinDist1, vtDir1) ;
|
||||
vtDir1.GetAngleXY( X_AX, dAng1) ;
|
||||
|
||||
DistPointCurve distPtECrv( ptEnd, *pCrvBound) ;
|
||||
distPtECrv.GetParamAtMinDistPoint( 0, dPar2, nFlag) ;
|
||||
pCrvBound->GetPointTang( dPar2, ICurve::FROM_MINUS, ptMinDist2, vtDir2) ;
|
||||
vtDir2.GetAngleXY( X_AX, dAng2) ;
|
||||
|
||||
pCompo->AddCurve( GetBiArc( ptStart, -dAngStart, ptMinDist1, -dAng1, 0.5)) ; // primo biarco
|
||||
pCompo->AddCurve( pCrvBound->CopyParamRange( dPar1, dPar2)) ; // tratto di pCrvBound
|
||||
pCompo->AddCurve( GetBiArc( ptMinDist2, -dAng2, ptEnd, -dAngEnd, 0.5)) ; // secondo biarco
|
||||
|
||||
pCrvLink->AddCurve( Release( pCompo)) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ComputePolishingPath( const PocketParams& PockParam, ICRVCOMPOPOVECTOR& vOffs, ICurveComposite* pMCrv)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( vOffs.empty() || pMCrv == nullptr)
|
||||
return false ;
|
||||
pMCrv->Clear() ;
|
||||
|
||||
// Offset con epicicli
|
||||
ICRVCOMPOPOVECTOR vpCrvsEp ; vpCrvsEp.reserve( vOffs.size()) ;
|
||||
|
||||
// definisco la curva di bordo
|
||||
PtrOwner<ICurveComposite> pCrvBound( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvBound))
|
||||
return false ;
|
||||
|
||||
// recupero il punto iniziale
|
||||
Point3d ptStartRef ;
|
||||
GetPtStartOnGenericEdge( vOffs[0], PockParam, ptStartRef) ;
|
||||
|
||||
// scorro le curve di Offset
|
||||
for ( int i = 0 ; i < ssize( vOffs) ; ++ i) {
|
||||
PtrOwner<ICurveComposite> pCrvEp( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvEp))
|
||||
return false ;
|
||||
double dUStart = 0. ;
|
||||
int nFlag = 0 ;
|
||||
DistPointCurve( ptStartRef, *vOffs[i]).GetParamAtMinDistPoint( 0., dUStart, nFlag) ;
|
||||
vOffs[i]->ChangeStartPoint( dUStart) ;
|
||||
// la curva di bound è l'offset che calcolo in AddEpicycles per la prima curva compo trovata in pMCrv
|
||||
if ( ! AddEpicycles( PockParam, vOffs[i], pCrvEp, ( i == 0 ? pCrvBound : nullptr)))
|
||||
return false ;
|
||||
vpCrvsEp.emplace_back( Release( pCrvEp)) ;
|
||||
}
|
||||
|
||||
// calcolo i collegamenti
|
||||
ICURVEPOVECTOR vLinks( vpCrvsEp.size()) ;
|
||||
for ( int i = 1 ; i < ssize( vpCrvsEp) ; ++ i) {
|
||||
// punti e direzioni di inizio e fine
|
||||
Point3d ptStart ; Vector3d vtStart ;
|
||||
vpCrvsEp[i-1]->GetEndPoint( ptStart) ;
|
||||
vpCrvsEp[i-1]->GetEndDir( vtStart) ;
|
||||
Point3d ptEnd ; Vector3d vtEnd ;
|
||||
vpCrvsEp[i]->GetStartPoint( ptEnd) ;
|
||||
vpCrvsEp[i]->GetStartDir( vtEnd) ;
|
||||
|
||||
// calcolo il collegamento con biarchi (garantendo che non esca dalla svuotatura)
|
||||
PtrOwner<ICurveComposite> pCrvLink( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvLink))
|
||||
return false ;
|
||||
if ( ! CalcBoundedPolishingLink( ptStart, vtStart, ptEnd, vtEnd, pCrvBound, pCrvLink))
|
||||
return false ;
|
||||
vLinks[i].Set( pCrvLink) ;
|
||||
}
|
||||
|
||||
// creo il percorso di lavoro a partire dalla raccolta delle curve con epicicli e dei collegamenti
|
||||
for ( int i = 0 ; i < int( vpCrvsEp.size()) ; ++ i) {
|
||||
// se collegamento da aggiungere
|
||||
if ( ! IsNull( vLinks[i])) {
|
||||
// accodo nel percorso di lavorazione
|
||||
pMCrv->AddCurve( Release( vLinks[i])) ;
|
||||
}
|
||||
// aggiungo la curva
|
||||
pMCrv->AddCurve( Release( vpCrvsEp[i])) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcSpiral( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig, const PocketParams& PockParams, int& nReg, Point3d& ptStart,
|
||||
@@ -6209,6 +6430,9 @@ CalcSpiral( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig, co
|
||||
|
||||
// Offset corrente ( il primo è definito dal raggio utensile)
|
||||
double dOffs = PockParams.dRad + PockParams.dRadialOffset ;
|
||||
// se lucidatura
|
||||
if ( PockParams.bPolishing && nReg == 0)
|
||||
dOffs += PockParams.dEpicyclesRad ;
|
||||
|
||||
// ciclo di offset verso l'interno
|
||||
const int MAX_ITER = 1000 ;
|
||||
@@ -6317,7 +6541,7 @@ CalcSpiral( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig, co
|
||||
}
|
||||
// se non ho Chunks e devo usare un Offset più piccolo...
|
||||
else if ( ! bSmallRad) {
|
||||
if ( PockParams.dRad < EPS_SMALL)
|
||||
if ( PockParams.dRad < EPS_SMALL || PockParams.bPolishing)
|
||||
break ;
|
||||
dOffs = dOffsPrec + ( nIter == 0 ? PockParams.dRad + PockParams.dRadialOffset : PockParams.dRad) ;
|
||||
}
|
||||
@@ -6332,6 +6556,13 @@ CalcSpiral( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig, co
|
||||
if ( vOffs.empty())
|
||||
return true ;
|
||||
|
||||
// se lucidatura
|
||||
if ( PockParams.bPolishing && nReg == 1) {
|
||||
// si suppone che gli offset siano tutti concentrici ( già ordinati dall'esterno all'interno)
|
||||
bMidOut = false ; // per definizione di lucidatura
|
||||
return ( ComputePolishingPath( PockParams, vOffs, pMCrv)) ;
|
||||
}
|
||||
|
||||
// cambio il punto iniziale della prima Curva di Offset
|
||||
Point3d ptRef = PockParams.ptStart ;
|
||||
Point3d ptNewStart ;
|
||||
@@ -7199,7 +7430,7 @@ AddZigZag( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, PocketPar
|
||||
|
||||
// offset della regione per curva ZigZag
|
||||
double dOffs = PockParams.dRad + PockParams.dRadialOffset ;
|
||||
if ( PockParams.bAllowZigZagOneWayBorders)
|
||||
if ( PockParams.bAllowZigZagOneWayBorders && ! PockParams.bPolishing)
|
||||
dOffs += PockParams.dOffsExtra ;
|
||||
|
||||
// ciclo su tutti i chunks della superficie originale
|
||||
@@ -7237,7 +7468,7 @@ AddZigZag( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, PocketPar
|
||||
// controllo esistenza di lati aperti per il Chunk attuale
|
||||
bool bIsChunkClosed = true ;
|
||||
bool bIsChunkAllOpen = true ;
|
||||
if ( ! PockParams.bAllClosed) {
|
||||
if ( ! PockParams.bAllClosed && ! PockParams.bPolishing) {
|
||||
if ( ! IsChunkAllHomogeneous( pSrfPock, nChunkInd, bIsChunkClosed, bIsChunkAllOpen))
|
||||
return false ;
|
||||
// se il Chunk originale aveva lati aperti, estendo il percorso a ZigZag
|
||||
@@ -7252,6 +7483,31 @@ AddZigZag( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, PocketPar
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se lucidatura
|
||||
if ( PockParams.bPolishing) {
|
||||
// ciclo sui percorsi
|
||||
for ( int k = 0 ; k < int( vpCrvs.size()) ; ++ k) {
|
||||
// se attacco a scivolo
|
||||
if ( PockParams.nLiType == LEAD_IN_GLIDE) {
|
||||
double dU ;
|
||||
vpCrvs[k]->GetParamAtLength( PockParams.dLiTang, dU) ;
|
||||
vpCrvs[k]->AddJoint( dU) ;
|
||||
Point3d ptStart ;
|
||||
vpCrvs[k]->GetStartPoint( ptStart) ;
|
||||
vpCrvs[k]->ModifyStart( ptStart + Z_AX * PockParams.dLiElev) ;
|
||||
}
|
||||
// se uscita a scivolo
|
||||
if ( PockParams.nLoType == LEAD_OUT_GLIDE) {
|
||||
double dLen, dU ;
|
||||
vpCrvs[k]->GetLength( dLen) ;
|
||||
vpCrvs[k]->GetParamAtLength( dLen - PockParams.dLoTang, dU) ;
|
||||
vpCrvs[k]->AddJoint( dU) ;
|
||||
Point3d ptEnd ;
|
||||
vpCrvs[k]->GetEndPoint( ptEnd) ;
|
||||
vpCrvs[k]->ModifyEnd( ptEnd + Z_AX * PockParams.dLiElev) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// inserisco le curve nel vettore risultante
|
||||
for ( int nU = 0 ; nU < int( vpCrvs.size()) ; ++ nU)
|
||||
@@ -7262,7 +7518,7 @@ AddZigZag( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, PocketPar
|
||||
}
|
||||
|
||||
// se richiesto, aggiungo le curve chiuse di Bordo
|
||||
if ( PockParams.bAllowZigZagOneWayBorders) {
|
||||
if ( PockParams.bAllowZigZagOneWayBorders && ! PockParams.bPolishing) {
|
||||
// recupero il Chunk nC-esimo
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunk( pSrfPock->CloneChunk( nChunkInd)) ;
|
||||
if ( IsNull( pSfrChunk) || ! pSfrChunk->IsValid() ||
|
||||
@@ -8273,17 +8529,38 @@ ExtendConformalOffsAndSetFeed( const ISurfFlatRegion* pSfrPock, const ISurfFlatR
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
ICRVCOMPOPOVECTOR vCrvBorder ;
|
||||
if ( ! GetSfrCrvCompoLoops( pSfrBorder, vCrvBorder))
|
||||
return false ;
|
||||
// determino eventuale regioni con parti non svuotate e imposto la Feed alle curve
|
||||
PtrOwner<ISurfFlatRegion> pSfrUncleared( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrUncleared))
|
||||
return false ;
|
||||
if ( GetUnclearedRegionAndSetFeed( vCrvBorder, vCrvOffs, vCrvLinks, pSfrOrig, PockParams, pSfrUncleared)) {
|
||||
// estendo i percorsi di Offset se richiesto
|
||||
if ( ! RemoveUnclearedRegions( pSfrUncleared, vCrvOffs, vCrvBorder, PockParams))
|
||||
// se non ho nessuna superficie di bordo, allora vuol dire che la regione è più stretta del diametro utensile
|
||||
// ( capita soprattutto se ho un SideStep da rispettare presso gli aperti)
|
||||
// non controllo le regioni rimosse ( dovrebbero essere rimosse dalle passate)
|
||||
if ( pSfrBorder->IsValid()) {
|
||||
ICRVCOMPOPOVECTOR vCrvBorder ;
|
||||
if ( ! GetSfrCrvCompoLoops( pSfrBorder, vCrvBorder))
|
||||
return false ;
|
||||
// determino eventuale regioni con parti non svuotate e imposto la Feed alle curve
|
||||
PtrOwner<ISurfFlatRegion> pSfrUncleared( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrUncleared))
|
||||
return false ;
|
||||
if ( GetUnclearedRegionAndSetFeed( vCrvBorder, vCrvOffs, vCrvLinks, pSfrOrig, PockParams, pSfrUncleared)) {
|
||||
// estendo i percorsi di Offset se richiesto
|
||||
if ( ! RemoveUnclearedRegions( pSfrUncleared, vCrvOffs, vCrvBorder, PockParams))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( int i = 0 ; i < ssize( vCrvOffs) ; ++ i) {
|
||||
if ( ! IsNull( vCrvOffs[i]) && vCrvOffs[i]->IsValid())
|
||||
AssignMaxFeed( vCrvOffs[i], PockParams) ;
|
||||
}
|
||||
for ( int i = 0 ; i < ssize( vCrvLinks) ; ++ i) {
|
||||
if ( ! IsNull( vCrvLinks[i]) && vCrvLinks[i]->IsValid()) {
|
||||
PtrOwner<ICurveComposite> pCompoLink( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompoLink))
|
||||
return false ;
|
||||
pCompoLink->AddCurve( Release( vCrvLinks[i])) ;
|
||||
AssignMaxFeed( pCompoLink, PockParams) ;
|
||||
vCrvLinks[i].Set( pCompoLink) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -9098,8 +9375,9 @@ CalcSpiralPocketing( const ISurfFlatRegion* pSfr, int nType, const PocketParams&
|
||||
PockParams.dAngle, PockParams.dOpenMinSafe, nType, PockParams.bSmooth,
|
||||
PockParams.bCalcUnclearedRegs, PockParams.bInvert, PockParams.bAvoidOpt,
|
||||
PockParams.bAllowZigZagOneWayBorders, PockParams.bCalcFeed, PockParams.ptStart,
|
||||
pSfrLimit, PockParams.bAvoidOpt, PockParams.dMaxOptSize, PockParams.dLiTang,
|
||||
PockParams.nLiType, vCrvCompoRes)) ;
|
||||
pSfrLimit, PockParams.bAvoidOpt, PockParams.dMaxOptSize,
|
||||
PockParams.nLiType, PockParams.dLiTang, PockParams.dLiElev, PockParams.nLoType, PockParams.dLoTang,
|
||||
PockParams.bPolishing, PockParams.dEpicyclesRad, PockParams.dEpicyclesDist, vCrvCompoRes)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -9396,8 +9674,9 @@ bool
|
||||
CalcPocketing( const ISurfFlatRegion* pSfr, double dRad, double dRadOffs, double dStep, double dAngle,
|
||||
double dOpenMinSafe, int nType, bool bSmooth, bool bCalcUnclReg, bool bInvert, bool bAvoidOpt,
|
||||
bool bAllowZigZagOneWayBorders, bool bCalcFeed, const Point3d& ptEndPrec,
|
||||
const ISurfFlatRegion* pSfrLimit, bool bAllOffs, double dMaxOptSize, double dLiTang,
|
||||
int nLiType, ICRVCOMPOPOVECTOR& vCrvCompoRes)
|
||||
const ISurfFlatRegion* pSfrLimit, bool bAllOffs, double dMaxOptSize,
|
||||
int nLiType, double dLiTang, double dLiElev, int nLoType, double dLoTang,
|
||||
bool bPolishing, double dEpicyclesRad, double dEpicyclesDist, ICRVCOMPOPOVECTOR& vCrvCompoRes)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pSfr == nullptr || ! pSfr->IsValid() ||
|
||||
@@ -9425,8 +9704,14 @@ CalcPocketing( const ISurfFlatRegion* pSfr, double dRad, double dRadOffs, double
|
||||
myParams.bAllowZigZagOneWayBorders = bAllowZigZagOneWayBorders ;
|
||||
myParams.bOptOffsets = ( ! bAllOffs) ;
|
||||
myParams.dMaxOptSize = dMaxOptSize ;
|
||||
myParams.dLiTang = dLiTang ;
|
||||
myParams.nLiType = nLiType ;
|
||||
myParams.dLiTang = dLiTang ;
|
||||
myParams.dLiElev = dLiElev ;
|
||||
myParams.nLoType = nLoType ;
|
||||
myParams.dLoTang = dLoTang ;
|
||||
myParams.bPolishing = bPolishing ;
|
||||
myParams.dEpicyclesRad = dEpicyclesRad ;
|
||||
myParams.dEpicyclesDist = dEpicyclesDist ;
|
||||
if ( ptEndPrec.IsValid())
|
||||
myParams.ptStart = ptEndPrec ;
|
||||
if ( pSfrLimit != nullptr && pSfrLimit->IsValid())
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ ChainCurves::GetChainFromPoint( const Point3d& ptStart, const Vector3d& vtStart,
|
||||
ptCurr = bEquiv ? m_vCrvData[nId].ptEnd : m_vCrvData[nId].ptStart ;
|
||||
vtCurr = bEquiv ? m_vCrvData[nId].vtEnd : - m_vCrvData[nId].vtStart ;
|
||||
// verifico se sono arrivato al punto di chiusura
|
||||
if ( AreSamePointEpsilon( ptCurr, ptStop, m_dToler)) {
|
||||
if ( AreSamePointEpsilon( ptCurr, ptStop, 0.5 * EPS_SMALL)) {
|
||||
bStopped = true ;
|
||||
break ;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ static const NamedColor StdColor[] = {
|
||||
{ "FUCHSIA", FUCHSIA},
|
||||
{ "PURPLE", PURPLE},
|
||||
{ "ORANGE", ORANGE},
|
||||
{ "BROWN", BROWN}
|
||||
{ "BROWN", BROWN},
|
||||
{ "INVISIBLE", INVISIBLE}
|
||||
} ;
|
||||
static const int NUM_STDCOLOR = ( sizeof(StdColor) / sizeof(StdColor[0]) ) ;
|
||||
|
||||
|
||||
+12
-3
@@ -2656,12 +2656,21 @@ GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert)
|
||||
INTVECTOR vIds ;
|
||||
Point3d ptStart = ORIG ;
|
||||
while ( chainCrv.GetChainFromNear( ptStart, false, vIds)) {
|
||||
ICurveComposite* pFirstCrv = vCrv[abs(vIds[0]) - 1] ;
|
||||
int nFirst = vIds[0] ;
|
||||
bool bInvert = false ;
|
||||
if ( nFirst < 0)
|
||||
bInvert = true ;
|
||||
nFirst = abs( nFirst) - 1 ;
|
||||
if ( bInvert)
|
||||
vCrv[nFirst]->Invert() ;
|
||||
ICurveComposite* pFirstCrv = vCrv[nFirst] ;
|
||||
for ( int nId : vIds) {
|
||||
bool bInvert = false ;
|
||||
bInvert = false ;
|
||||
if ( nId < 0)
|
||||
bInvert = true ;
|
||||
nId = abs( nId) - 1 ;
|
||||
if ( nId == nFirst)
|
||||
continue ;
|
||||
if ( bInvert)
|
||||
vCrv[nId]->Invert() ;
|
||||
if ( ! pFirstCrv->AddCurve( Release( vCrv[nId]), true, dChainTol))
|
||||
@@ -2670,7 +2679,7 @@ GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert)
|
||||
pFirstCrv->GetEndPoint( ptStart) ;
|
||||
}
|
||||
// elimino gli elementi del vettore che non contengono più curve
|
||||
int c = ssize( vCrv) ;
|
||||
int c = ssize( vCrv) - 1 ;
|
||||
while ( c > -1) {
|
||||
if ( IsNull( vCrv[c]))
|
||||
vCrv.erase( vCrv.begin() + c) ;
|
||||
|
||||
+5
-5
@@ -211,13 +211,13 @@ DistPointCurve::GetParamAtMinDistPoint( double dNearParam, double& dParam, int&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide) const
|
||||
DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide, double dTol) const
|
||||
{
|
||||
if ( m_dDist < 0 || nInd < 0 || nInd >= (int) m_Info.size())
|
||||
return false ;
|
||||
|
||||
// se distanza nulla, il punto giace sulla curva
|
||||
if ( m_dDist <= EPS_SMALL) {
|
||||
if ( m_dDist <= dTol) {
|
||||
nSide = MDS_ON ;
|
||||
return true ;
|
||||
}
|
||||
@@ -259,7 +259,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
|
||||
|
||||
// determino il lato di giacitura del punto
|
||||
double dSide = vtRef * ( m_ptP - ptQ) ;
|
||||
if ( abs( dSide) < EPS_SMALL)
|
||||
if ( abs( dSide) < dTol)
|
||||
nSide = MDS_ON ;
|
||||
else if ( dSide > 0)
|
||||
nSide = MDS_LEFT ;
|
||||
@@ -270,7 +270,7 @@ DistPointCurve::GetSideAtMinDistPoint( int nInd, const Vector3d& vtN, int& nSide
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide) const
|
||||
DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, int& nSide, double dTol) const
|
||||
{
|
||||
if ( m_dDist < 0 || m_Info.empty())
|
||||
return false ;
|
||||
@@ -286,7 +286,7 @@ DistPointCurve::GetSideAtMinDistPoint( double dNearParam, const Vector3d& vtN, i
|
||||
}
|
||||
}
|
||||
// mi sono ricondotto al caso precedente
|
||||
return GetSideAtMinDistPoint( nInd, vtN, nSide) ;
|
||||
return GetSideAtMinDistPoint( nInd, vtN, nSide, dTol) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
@@ -284,6 +284,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="CalcDerivate.cpp" />
|
||||
<ClCompile Include="CAvSilhouetteSurfTm.cpp" />
|
||||
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
|
||||
<ClCompile Include="CAvSurfFrMove.cpp" />
|
||||
<ClCompile Include="CAvToolSurfTm.cpp" />
|
||||
<ClCompile Include="CAvToolTriangle.cpp" />
|
||||
<ClCompile Include="CDeBoxClosedSurfTm.cpp" />
|
||||
@@ -353,6 +354,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
||||
<ClInclude Include="..\Include\EGkSurfTriMeshAux.h" />
|
||||
<ClInclude Include="CAvSilhouetteSurfTm.h" />
|
||||
<ClInclude Include="CAvSurfFrMove.h" />
|
||||
<ClInclude Include="CDeBoxTria.h" />
|
||||
<ClInclude Include="CDeCapsTria.h" />
|
||||
<ClInclude Include="CDeConeFrustumTria.h" />
|
||||
|
||||
@@ -570,6 +570,9 @@
|
||||
<ClCompile Include="CalcDerivate.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CAvSurfFrMove.cpp">
|
||||
<Filter>File di origine\GeoCollisionAvoid</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -1256,6 +1259,9 @@
|
||||
<ClInclude Include="..\Include\EGkMultiGeomDB.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CAvSurfFrMove.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+317
-82
@@ -19,14 +19,15 @@
|
||||
#include "/EgtDev/Include/EGkAngle.h"
|
||||
#include "/EgtDev/Include/EGkHashGrids2d.h"
|
||||
#include <algorithm>
|
||||
#include <ranges>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//--------------------------- Local functions --------------------------------
|
||||
static bool CompatibleParamA( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
|
||||
bool bCrvAClosed, double dCrvASpan) ;
|
||||
bool bCrvAClosed, double dCrvASpan, bool bOrderedOnB = false) ;
|
||||
static bool CompatibleParamB( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
|
||||
bool bCrvBClosed, double dCrvBSpan) ;
|
||||
bool bCrvBClosed, double dCrvBSpan, bool bOrderedOnB = false) ;
|
||||
static void MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2, const ICurveComposite& crvCompo) ;
|
||||
static int GetCrvBDirAPrev( IntCrvCrvInfo& Icci) ;
|
||||
static int GetCrvBDirANext( IntCrvCrvInfo& Icci) ;
|
||||
@@ -34,7 +35,6 @@ static bool CalcATypeFromDisk( const ICurve& CurveA, double dUA, ICurve::Side nS
|
||||
const ICurve& CurveB, double dUB, int& nType) ;
|
||||
static bool CalcATypeFromDisk2( const ICurve& CurveA, double dUA, ICurve::Side nSideA,
|
||||
const ICurve& CurveB, double dUB1, double dUB2, int& nType) ;
|
||||
static bool CalcSide( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2, const ICurve* pThisCrv, const ICurve* pOtherCrv, bool bCrvAOrB, int& nType) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
@@ -262,8 +262,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[0].dU) < EPS_PARAM &&
|
||||
abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[1].dU) < EPS_PARAM) {
|
||||
// cancello entrambe
|
||||
EraseOtherInfo( i, j) ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
EraseBothInfo( i, j) ;
|
||||
}
|
||||
// caso DET-(NULL) -> (NULL)-DET per prima curva
|
||||
else if ( m_Info[j].IciA[kj].nPrevTy != ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
|
||||
@@ -383,8 +382,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
|
||||
m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
|
||||
// cancello entrambe
|
||||
EraseOtherInfo( i, j) ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
EraseBothInfo( i, j) ;
|
||||
}
|
||||
// caso NULL-DET -> NULL-DET per prima curva con NULL-NULL -> NULL-NULL su seconda curva
|
||||
else if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy != ICCT_NULL &&
|
||||
@@ -392,12 +390,10 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
|
||||
m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
|
||||
// cancello entrambe
|
||||
EraseOtherInfo( i, j) ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
EraseBothInfo( i, j) ;
|
||||
}
|
||||
// caso NULL-NULL per corrente di prima curva
|
||||
else if ( m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
|
||||
m_Info[j].IciA[kj].nNextTy = ICCT_NULL ;
|
||||
if ( m_Info[j].IciB[kj].nNextTy == ICCT_NULL)
|
||||
m_Info[j].IciB[kj].nNextTy = m_Info[i].IciB[ki].nNextTy ;
|
||||
if ( m_Info[j].IciB[kj].nPrevTy == ICCT_NULL)
|
||||
@@ -407,7 +403,6 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
}
|
||||
// caso NULL-NULL per precedente di prima curva
|
||||
else if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL) {
|
||||
m_Info[i].IciA[ki].nPrevTy = ICCT_NULL ;
|
||||
if ( m_Info[i].IciB[ki].nPrevTy == ICCT_NULL)
|
||||
m_Info[i].IciB[ki].nPrevTy = m_Info[j].IciB[kj].nPrevTy ;
|
||||
if ( m_Info[i].IciB[ki].nNextTy == ICCT_NULL)
|
||||
@@ -430,20 +425,19 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
continue ;
|
||||
}
|
||||
// calcolo sottoindici
|
||||
int ki = 0 ; // del successivo si prende sempre il primo
|
||||
int kj = ( m_Info[j].bOverlap ? 1 : 0) ; // del precedente si prende il secondo se overlap
|
||||
int ki = ( m_Info[i].bOverlap && ! m_Info[i].bCBOverEq ? 1 : 0) ;
|
||||
int kj = ( m_Info[j].bOverlap && m_Info[j].bCBOverEq ? 1 : 0) ;
|
||||
// verifico se precedente e corrente si riferiscono alla stessa intersezione (10 * EPS_SMALL)
|
||||
if ( AreSamePointXYEpsilon( m_Info[j].IciA[kj].ptI, m_Info[i].IciA[ki].ptI, 10 * EPS_SMALL) &&
|
||||
AreSamePointXYEpsilon( m_Info[j].IciB[kj].ptI, m_Info[i].IciB[ki].ptI, 10 * EPS_SMALL) &&
|
||||
CompatibleParamA( m_Info[j], m_Info[i], bCrvAClosed, dCrvASpan) &&
|
||||
CompatibleParamB( m_Info[j], m_Info[i], bCrvBClosed, dCrvBSpan)) {
|
||||
CompatibleParamA( m_Info[j], m_Info[i], bCrvAClosed, dCrvASpan, true) &&
|
||||
CompatibleParamB( m_Info[j], m_Info[i], bCrvBClosed, dCrvBSpan, true)) {
|
||||
// caso entrambi Overlap ma di tipo opposto e sullo stesso tratto
|
||||
if ( m_Info[i].bOverlap && m_Info[j].bOverlap && m_Info[i].bCBOverEq != m_Info[j].bCBOverEq &&
|
||||
abs( m_Info[i].IciB[0].dU - m_Info[j].IciB[0].dU) < EPS_PARAM &&
|
||||
abs( m_Info[i].IciB[1].dU - m_Info[j].IciB[1].dU) < EPS_PARAM) {
|
||||
// cancello entrambe
|
||||
EraseOtherInfo( i, j) ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
EraseBothInfo( i, j) ;
|
||||
}
|
||||
// caso DET-(NULL) -> (NULL)-DET per seconda curva
|
||||
else if ( m_Info[j].IciB[kj].nPrevTy != ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
|
||||
@@ -463,6 +457,12 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[i].IciA[ki].nPrevTy = m_Info[i].IciB[ki].nNextTy ;
|
||||
m_Info[i].IciA[ki].nNextTy = m_Info[i].IciB[ki].nPrevTy ;
|
||||
}
|
||||
else {
|
||||
if ( m_Info[i].IciA[ki].nPrevTy == ICCT_NULL)
|
||||
m_Info[i].IciA[ki].nPrevTy = m_Info[j].IciA[kj].nPrevTy ;
|
||||
if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL)
|
||||
m_Info[i].IciA[ki].nNextTy = m_Info[j].IciA[kj].nNextTy ;
|
||||
}
|
||||
// se overlap equiverso
|
||||
if ( m_Info[j].bOverlap && m_Info[j].bCBOverEq) {
|
||||
// per la prima curva ogni sottotipo è il duale di quello della seconda
|
||||
@@ -475,6 +475,12 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[j].IciA[kj].nPrevTy = m_Info[i].IciB[ki].nNextTy ;
|
||||
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciB[ki].nPrevTy ;
|
||||
}
|
||||
else {
|
||||
if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL)
|
||||
m_Info[j].IciA[kj].nPrevTy = m_Info[i].IciA[ki].nPrevTy ;
|
||||
if ( m_Info[j].IciA[kj].nNextTy == ICCT_NULL)
|
||||
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciA[ki].nNextTy ;
|
||||
}
|
||||
// medio parametri e punti separatamente per le due curve
|
||||
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj], CCompoA) ;
|
||||
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj], CCompoB) ;
|
||||
@@ -507,6 +513,12 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[i].IciA[ki].nPrevTy = m_Info[i].IciB[ki].nNextTy ;
|
||||
m_Info[i].IciA[ki].nNextTy = m_Info[i].IciB[ki].nPrevTy ;
|
||||
}
|
||||
else {
|
||||
if ( m_Info[i].IciA[ki].nPrevTy == ICCT_NULL)
|
||||
m_Info[i].IciA[ki].nPrevTy = m_Info[j].IciA[kj].nPrevTy ;
|
||||
if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL)
|
||||
m_Info[i].IciA[ki].nNextTy = m_Info[j].IciA[kj].nNextTy ;
|
||||
}
|
||||
// se overlap equiverso
|
||||
if ( m_Info[j].bOverlap && m_Info[j].bCBOverEq) {
|
||||
// per la prima curva ogni sottotipo è il duale di quello della seconda
|
||||
@@ -519,6 +531,12 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[j].IciA[kj].nPrevTy = m_Info[i].IciB[ki].nNextTy ;
|
||||
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciB[ki].nPrevTy ;
|
||||
}
|
||||
else {
|
||||
if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL)
|
||||
m_Info[j].IciA[kj].nPrevTy = m_Info[i].IciA[ki].nPrevTy ;
|
||||
if ( m_Info[j].IciA[kj].nNextTy == ICCT_NULL)
|
||||
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciA[ki].nNextTy ;
|
||||
}
|
||||
// medio parametri e punti separatamente per le due curve
|
||||
MediaParamPoints( m_Info[i].IciA[ki], m_Info[j].IciA[kj], CCompoA) ;
|
||||
MediaParamPoints( m_Info[i].IciB[ki], m_Info[j].IciB[kj], CCompoB) ;
|
||||
@@ -539,8 +557,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
|
||||
m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
|
||||
// cancello entrambe
|
||||
EraseOtherInfo( i, j) ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
EraseBothInfo( i, j) ;
|
||||
}
|
||||
// caso NULL-DET -> NULL-DET per seconda curva con NULL-NULL -> NULL-NULL su prima curva
|
||||
else if ( m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy != ICCT_NULL &&
|
||||
@@ -548,12 +565,10 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
|
||||
m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
|
||||
// cancello entrambe
|
||||
EraseOtherInfo( i, j) ;
|
||||
EraseCurrentInfo( i, j) ;
|
||||
EraseBothInfo( i, j) ;
|
||||
}
|
||||
// caso NULL-NULL per corrente di seconda curva
|
||||
else if ( m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
|
||||
m_Info[j].IciB[kj].nNextTy = ICCT_NULL ;
|
||||
if ( m_Info[j].IciA[kj].nNextTy == ICCT_NULL)
|
||||
m_Info[j].IciA[kj].nNextTy = m_Info[i].IciA[ki].nNextTy ;
|
||||
if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL)
|
||||
@@ -563,7 +578,6 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
}
|
||||
// caso NULL-NULL per precedente di seconda curva
|
||||
else if ( m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL) {
|
||||
m_Info[i].IciB[ki].nPrevTy = ICCT_NULL ;
|
||||
if ( m_Info[i].IciA[ki].nPrevTy == ICCT_NULL)
|
||||
m_Info[i].IciA[ki].nPrevTy = m_Info[j].IciA[kj].nPrevTy ;
|
||||
if ( m_Info[i].IciA[ki].nNextTy == ICCT_NULL)
|
||||
@@ -599,18 +613,19 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
stable_sort( m_Info.begin(), m_Info.end(), SortGreaterB) ;
|
||||
for ( int i = 0 ; i < m_nNumInters ; ++ i) {
|
||||
// se il tipo di accostamento per la curva B non è definito
|
||||
if ( m_Info[i].IciB[0].nPrevTy == ICCT_NULL) {
|
||||
int ki = ( m_Info[i].bOverlap && ! m_Info[i].bCBOverEq ? 1 : 0) ;
|
||||
if ( m_Info[i].IciB[ki].nPrevTy == ICCT_NULL) {
|
||||
if ( i > 0 || ( bCrvBClosed && ! bAutoInters)) {
|
||||
int j = ( i > 0 ? i - 1 : m_nNumInters - 1) ;
|
||||
m_Info[i].IciB[0].nPrevTy = ( m_Info[j].bOverlap ? m_Info[j].IciB[1].nNextTy : m_Info[j].IciB[0].nNextTy) ;
|
||||
m_Info[i].IciB[ki].nPrevTy = ( m_Info[j].bOverlap && m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nNextTy : m_Info[j].IciB[0].nNextTy) ;
|
||||
}
|
||||
}
|
||||
// se il tipo di allontanamento per la curva B non è definito
|
||||
int ki = ( m_Info[i].bOverlap ? 1 : 0) ;
|
||||
ki = ( m_Info[i].bOverlap && m_Info[i].bCBOverEq ? 1 : 0) ;
|
||||
if ( m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
|
||||
if ( i < m_nNumInters - 1 || ( bCrvBClosed && ! bAutoInters)) {
|
||||
int j = ( i < m_nNumInters - 1 ? i + 1 : 0) ;
|
||||
m_Info[i].IciB[ki].nNextTy = m_Info[j].IciB[0].nPrevTy ;
|
||||
m_Info[i].IciB[ki].nNextTy = ( m_Info[j].bOverlap && ! m_Info[j].bCBOverEq ? m_Info[j].IciB[1].nPrevTy : m_Info[j].IciB[0].nPrevTy) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -781,63 +796,109 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
}
|
||||
|
||||
// verifico se una curva ha tutte le info e queste info sono coerenti
|
||||
if ( m_nNumInters > 1) {
|
||||
if ( m_nNumInters > 1 && ! bAutoInters) {
|
||||
bool bCoherent = true ;
|
||||
INTVECTOR vIncoherenceWithPrev ;
|
||||
INTVECTOR vNewOverlap ;
|
||||
// salvo eventuali incoerenze col precedente
|
||||
for ( int i = bCrvAClosed ? 0 : 1 ; i < m_nNumInters ; ++i) {
|
||||
int j = i == 0 ? m_nNumInters - 1 : i - 1 ;
|
||||
int kj = m_Info[j].bOverlap ? 1 : 0 ;
|
||||
if ( m_Info[j].IciA[kj].nNextTy != m_Info[i].IciA[0].nPrevTy &&
|
||||
m_Info[j].IciA[kj].nNextTy != ICCT_SPK && m_Info[i].IciA[0].nPrevTy != ICCT_SPK) {
|
||||
vIncoherenceWithPrev.push_back( i) ;
|
||||
int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ;
|
||||
int kj = ( m_Info[j].bOverlap ? 1 : 0) ;
|
||||
bool bSpike = m_Info[i].bOverlap && m_Info[j].bOverlap && m_Info[i].bCBOverEq != m_Info[j].bCBOverEq ;
|
||||
if ( bSpike) {
|
||||
bSpike = abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[0].dU) < EPS_PARAM ||
|
||||
abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[1].dU) < EPS_PARAM ||
|
||||
abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[0].dU) < EPS_PARAM ||
|
||||
abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[1].dU) < EPS_PARAM ;
|
||||
}
|
||||
if ( (m_Info[j].IciA[kj].nNextTy == ICCT_NULL || m_Info[i].IciA[0].nPrevTy == ICCT_NULL || m_Info[j].IciA[kj].nNextTy != m_Info[i].IciA[0].nPrevTy) &&
|
||||
m_Info[j].IciA[kj].nNextTy != ICCT_SPK && m_Info[i].IciA[0].nPrevTy != ICCT_SPK) {
|
||||
if ( vIncoherenceWithPrev.empty() || vIncoherenceWithPrev.back() != i)
|
||||
vIncoherenceWithPrev.push_back( i) ;
|
||||
if ( bSpike) {
|
||||
// se ho uno spike sistemo anche il successivo
|
||||
int k = i == m_nNumInters - 1 ? -1 : i + 1 ;
|
||||
if ( k == -1 && bCrvAClosed)
|
||||
k = 0 ;
|
||||
|
||||
if ( k != -1)
|
||||
vIncoherenceWithPrev.push_back( k) ;
|
||||
}
|
||||
bCoherent = false ;
|
||||
}
|
||||
}
|
||||
// incoerenze sulla curva A
|
||||
if ( ! bCoherent) {
|
||||
for ( int i : vIncoherenceWithPrev) {
|
||||
int j = i == 0 ? m_nNumInters - 1 : i - 1 ;
|
||||
int kj = m_Info[j].bOverlap ? 1 : 0 ;
|
||||
int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ;
|
||||
int kj = ( m_Info[j].bOverlap ? 1 : 0) ;
|
||||
int nType = 0 ;
|
||||
CalcSide( m_Info[j], m_Info[i], &CCompoA, &CCompoB, true, nType) ;
|
||||
if ( nType == MDS_LEFT)
|
||||
nType = ICCT_IN ;
|
||||
else if ( nType == MDS_RIGHT)
|
||||
nType = ICCT_OUT ;
|
||||
m_Info[i].IciA[0].nPrevTy = nType ;
|
||||
m_Info[j].IciA[kj].nNextTy = nType ;
|
||||
CalcSide( j, i, &CCompoA, &CCompoB, true, nType) ;
|
||||
if ( nType != ICCT_ON) {
|
||||
m_Info[i].IciA[0].nPrevTy = nType ;
|
||||
m_Info[j].IciA[kj].nNextTy = nType ;
|
||||
}
|
||||
else
|
||||
vNewOverlap.push_back( i) ;
|
||||
}
|
||||
}
|
||||
|
||||
// faccio il merge se ho trasformato delle intersezioni in overlap
|
||||
for ( int i : views::reverse( vNewOverlap))
|
||||
MergeNewOverlap( i, true) ;
|
||||
|
||||
vNewOverlap.clear() ;
|
||||
stable_sort( m_Info.begin(), m_Info.end(), SortGreaterB) ;
|
||||
bCoherent = true ;
|
||||
vIncoherenceWithPrev.clear() ;
|
||||
// salvo eventuali incoerenze col precedente
|
||||
for ( int i = bCrvBClosed ? 0 : 1 ; i < m_nNumInters ; ++i) {
|
||||
int j = i == 0 ? m_nNumInters - 1 : i - 1 ;
|
||||
int kj = m_Info[j].bOverlap ? 1 : 0 ;
|
||||
if ( m_Info[j].IciB[kj].nNextTy != m_Info[i].IciB[0].nPrevTy &&
|
||||
m_Info[j].IciB[kj].nNextTy != ICCT_SPK && m_Info[i].IciB[0].nPrevTy != ICCT_SPK) {
|
||||
vIncoherenceWithPrev.push_back( i) ;
|
||||
int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ;
|
||||
int ki = ( m_Info[i].bOverlap && ! m_Info[i].bCBOverEq ? 1 : 0) ;
|
||||
int kj = ( m_Info[j].bOverlap && m_Info[j].bCBOverEq ? 1 : 0) ;
|
||||
bool bSpike = m_Info[i].bOverlap && m_Info[j].bOverlap && m_Info[i].bCBOverEq != m_Info[j].bCBOverEq ;
|
||||
if ( bSpike) {
|
||||
bSpike = abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[0].dU) < EPS_PARAM ||
|
||||
abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[1].dU) < EPS_PARAM ||
|
||||
abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[0].dU) < EPS_PARAM ||
|
||||
abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[1].dU) < EPS_PARAM ;
|
||||
}
|
||||
if ( ( m_Info[j].IciB[kj].nNextTy == ICCT_NULL || m_Info[i].IciB[ki].nPrevTy == ICCT_NULL || m_Info[j].IciB[kj].nNextTy != m_Info[i].IciB[ki].nPrevTy) &&
|
||||
m_Info[j].IciB[kj].nNextTy != ICCT_SPK && m_Info[i].IciB[ki].nPrevTy != ICCT_SPK) {
|
||||
if ( vIncoherenceWithPrev.empty() || vIncoherenceWithPrev.back() != i)
|
||||
vIncoherenceWithPrev.push_back( i) ;
|
||||
if ( bSpike) {
|
||||
// se ho uno spike sistemo anche il successivo
|
||||
int k = ( i == m_nNumInters - 1 ? -1 : i + 1) ;
|
||||
if ( k == -1 && bCrvBClosed)
|
||||
k = 0 ;
|
||||
|
||||
if ( k != -1)
|
||||
vIncoherenceWithPrev.push_back( k) ;
|
||||
}
|
||||
bCoherent = false ;
|
||||
}
|
||||
}
|
||||
// incoerenze sulla curva B
|
||||
if ( ! bCoherent) {
|
||||
for ( int i : vIncoherenceWithPrev) {
|
||||
int j = i == 0 ? m_nNumInters - 1 : i - 1 ;
|
||||
int kj = m_Info[j].bOverlap ? 1 : 0 ;
|
||||
int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ;
|
||||
int ki = ( m_Info[i].bOverlap && !m_Info[i].bCBOverEq ? 1 : 0) ;
|
||||
int kj = ( m_Info[j].bOverlap && m_Info[j].bCBOverEq ? 1 : 0) ;
|
||||
int nType = 0 ;
|
||||
CalcSide( m_Info[j], m_Info[i], &CCompoB, &CCompoA, false, nType) ;
|
||||
if ( nType == MDS_LEFT)
|
||||
nType = ICCT_IN ;
|
||||
else if ( nType == MDS_RIGHT)
|
||||
nType = ICCT_OUT ;
|
||||
m_Info[i].IciB[0].nPrevTy = nType ;
|
||||
m_Info[j].IciB[kj].nNextTy = nType ;
|
||||
CalcSide( j, i, &CCompoB, &CCompoA, false, nType) ;
|
||||
if ( nType != ICCT_ON) {
|
||||
m_Info[i].IciB[ki].nPrevTy = nType ;
|
||||
m_Info[j].IciB[kj].nNextTy = nType ;
|
||||
}
|
||||
else
|
||||
vNewOverlap.push_back( i) ;
|
||||
}
|
||||
}
|
||||
|
||||
// faccio il merge se ho trasformato delle intersezioni in overlap
|
||||
for ( int i : views::reverse( vNewOverlap))
|
||||
MergeNewOverlap( i, false) ;
|
||||
}
|
||||
else {
|
||||
// posso completare A guardando B e viceversa
|
||||
@@ -849,34 +910,171 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcSide( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,const ICurve* pThisCrv, const ICurve* pOtherCrv, bool bCrvAOrB, int& nType)
|
||||
bool
|
||||
IntersCrvCompoCrvCompo::CalcSide( int j, int i,const ICurve* pThisCrv, const ICurve* pOtherCrv, bool bCrvAOrB, int& nType)
|
||||
{
|
||||
const IntCrvCrvInfo& Icci1 = m_Info[j] ;
|
||||
const IntCrvCrvInfo& Icci2 = m_Info[i] ;
|
||||
// calcolo tra l'intersezione 1 e 2 se la curva sta dentro o fuori
|
||||
int kj = Icci1.bOverlap ? 1 : 0 ;
|
||||
int ki = 0 ;
|
||||
int kj = ( Icci1.bOverlap ? 1 : 0) ;
|
||||
if ( ! bCrvAOrB) {
|
||||
ki = ( m_Info[i].bOverlap && !m_Info[i].bCBOverEq ? 1 : 0) ;
|
||||
kj = ( m_Info[j].bOverlap && m_Info[j].bCBOverEq ? 1 : 0) ;
|
||||
}
|
||||
|
||||
double dU = 0 ;
|
||||
bool bPrevIsBefore = true ;
|
||||
if ( bCrvAOrB) {
|
||||
// se precedente minore del successivo faccio la media
|
||||
if ( Icci1.IciA[kj].dU < Icci2.IciA[0].dU)
|
||||
dU = (Icci2.IciA[0].dU + Icci1.IciA[kj].dU) / 2 ;
|
||||
if ( Icci1.IciA[kj].dU < Icci2.IciA[ki].dU)
|
||||
dU = ( Icci2.IciA[ki].dU + Icci1.IciA[kj].dU) / 2 ;
|
||||
// altrimenti guardo tra lo start e il successivo
|
||||
else
|
||||
dU = (Icci2.IciA[0].dU + 0.) / 2 ;
|
||||
else {
|
||||
bPrevIsBefore = false ;
|
||||
dU = ( Icci2.IciA[0].dU + 0.) / 2 ;
|
||||
if ( dU < EPS_SMALL) {
|
||||
double dStart, dEnd ;
|
||||
pThisCrv->GetDomain( dStart, dEnd) ;
|
||||
double dUNew = dEnd - Icci1.IciA[kj].dU / 2 ;
|
||||
if ( dUNew > dU)
|
||||
dU = dUNew ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// se precedente minore del successivo faccio la media
|
||||
if ( Icci1.IciB[kj].dU < Icci2.IciB[0].dU)
|
||||
dU = (Icci2.IciB[0].dU + Icci1.IciB[kj].dU) / 2 ;
|
||||
if ( Icci1.IciB[kj].dU < Icci2.IciB[ki].dU)
|
||||
dU = ( Icci2.IciB[ki].dU + Icci1.IciB[kj].dU) / 2 ;
|
||||
// altrimenti guardi tra lo start e il successivo
|
||||
else
|
||||
dU = (Icci2.IciB[0].dU + 0.) / 2 ;
|
||||
else {
|
||||
bPrevIsBefore = false ;
|
||||
dU = ( Icci2.IciB[0].dU + 0.) / 2 ;
|
||||
if ( dU < EPS_SMALL) {
|
||||
double dStart, dEnd ;
|
||||
pThisCrv->GetDomain( dStart, dEnd) ;
|
||||
double dUNew = dEnd - Icci1.IciB[kj].dU / 2 ;
|
||||
if ( dUNew > dU)
|
||||
dU = dUNew ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Point3d ptTest ; pThisCrv->GetPointD1D2( dU, ICurve::FROM_MINUS, ptTest) ;
|
||||
DistPointCurve dpc( ptTest, *pOtherCrv) ;
|
||||
dpc.GetSideAtMinDistPoint( 0, Z_AX, nType) ;
|
||||
dpc.GetSideAtMinDistPoint( 0, Z_AX, nType, EPS_ZERO) ;
|
||||
if ( nType == MDS_LEFT)
|
||||
nType = ICCT_IN ;
|
||||
else if ( nType == MDS_RIGHT)
|
||||
nType = ICCT_OUT ;
|
||||
// se lo trovo sulla curva controllo se posso definire un tratto overlap
|
||||
if ( nType == MDS_ON) {
|
||||
double dFactor = 1./3. ;
|
||||
DBLVECTOR vdU(2) ;
|
||||
bool bIsOn = false ;
|
||||
if ( bCrvAOrB) {
|
||||
if ( bPrevIsBefore) {
|
||||
vdU[0] = ( 1 - dFactor) * Icci2.IciA[ki].dU + dFactor * Icci1.IciA[kj].dU ;
|
||||
vdU[1] = ( 1 - 2 * dFactor) * Icci2.IciA[ki].dU + 2 * dFactor * Icci1.IciA[kj].dU ;
|
||||
}
|
||||
else if ( Icci2.IciA[ki].dU > 2 * EPS_SMALL){
|
||||
vdU[0] = ( Icci2.IciA[ki].dU + 0.) * dFactor ;
|
||||
vdU[1] = ( Icci2.IciA[ki].dU + 0.) * 2 * dFactor ;
|
||||
}
|
||||
else
|
||||
bIsOn = true ;
|
||||
}
|
||||
else {
|
||||
if ( bPrevIsBefore) {
|
||||
vdU[0] = ( 1 - dFactor) * Icci2.IciB[ki].dU + dFactor * Icci1.IciB[kj].dU ;
|
||||
vdU[1] = ( 1 - 2 * dFactor) * Icci2.IciB[ki].dU + 2 * dFactor * Icci1.IciB[kj].dU ;
|
||||
}
|
||||
else if ( Icci2.IciB[ki].dU > 2 * EPS_SMALL) {
|
||||
vdU[0] = ( Icci2.IciB[ki].dU + 0.) * dFactor ;
|
||||
vdU[1] = ( Icci2.IciB[ki].dU + 0.) * 2 * dFactor ;
|
||||
}
|
||||
else
|
||||
bIsOn = true ;
|
||||
}
|
||||
if ( ! bIsOn) {
|
||||
bIsOn = true ;
|
||||
for ( int k = 0 ; k < ssize(vdU) && bIsOn ; ++k) {
|
||||
Point3d ptTest2 ; pThisCrv->GetPointD1D2( vdU[k], ICurve::FROM_MINUS, ptTest2) ;
|
||||
DistPointCurve dpc2( ptTest2, *pOtherCrv) ;
|
||||
dpc2.GetSideAtMinDistPoint( 0, Z_AX, nType, EPS_ZERO) ;
|
||||
if ( nType != MDS_ON)
|
||||
bIsOn = false ;
|
||||
}
|
||||
}
|
||||
if ( bIsOn) {
|
||||
m_Info[i].bOverlap = true ;
|
||||
Vector3d vtDirThis, vtDirOther ;
|
||||
Point3d ptCommon ;
|
||||
double dUThis = 0 ;
|
||||
if ( bCrvAOrB)
|
||||
dUThis = m_Info[i].IciA[0].dU ;
|
||||
else
|
||||
dUThis = m_Info[i].IciB[0].dU ;
|
||||
pThisCrv->GetPointD1D2( dUThis, ICurve::Side::FROM_MINUS, ptCommon, &vtDirThis) ;
|
||||
double dUOther = 0 ; pOtherCrv->GetParamAtPoint( ptCommon, dUOther) ;
|
||||
pOtherCrv->GetPointD1D2( dUOther, ICurve::Side::FROM_MINUS, ptCommon, &vtDirOther) ;
|
||||
m_Info[i].bCBOverEq = vtDirThis * vtDirOther > 0 ;
|
||||
if ( m_Info[i].bCBOverEq) {
|
||||
m_Info[i].IciA[1] = m_Info[i].IciA[0] ;
|
||||
m_Info[i].IciB[1] = m_Info[i].IciB[0] ;
|
||||
m_Info[i].IciA[0] = m_Info[j].IciA[kj] ;
|
||||
m_Info[i].IciB[0] = m_Info[j].IciB[kj] ;
|
||||
m_Info[i].IciA[1].nPrevTy = ICCT_ON ;
|
||||
m_Info[i].IciB[1].nPrevTy = ICCT_ON ;
|
||||
m_Info[i].IciA[0].nNextTy = ICCT_ON ;
|
||||
m_Info[i].IciB[0].nNextTy = ICCT_ON ;
|
||||
}
|
||||
else {
|
||||
if ( bCrvAOrB) {
|
||||
m_Info[i].IciA[1] = m_Info[i].IciA[0] ;
|
||||
m_Info[i].IciA[0] = m_Info[j].IciA[kj] ;
|
||||
m_Info[i].IciA[1].nPrevTy = ICCT_ON ;
|
||||
m_Info[i].IciA[0].nNextTy = ICCT_ON ;
|
||||
m_Info[i].IciB[1] = m_Info[j].IciB[kj] ;
|
||||
m_Info[i].IciB[0].nPrevTy = ICCT_ON ;
|
||||
m_Info[i].IciB[1].nNextTy = ICCT_ON ;
|
||||
}
|
||||
else {
|
||||
m_Info[i].IciB[1] = m_Info[i].IciB[0] ;
|
||||
m_Info[i].IciB[0] = m_Info[j].IciB[kj] ;
|
||||
m_Info[i].IciB[1].nPrevTy = ICCT_ON ;
|
||||
m_Info[i].IciB[0].nNextTy = ICCT_ON ;
|
||||
m_Info[i].IciA[1] = m_Info[j].IciA[kj] ;
|
||||
m_Info[i].IciA[0].nPrevTy = ICCT_ON ;
|
||||
m_Info[i].IciA[1].nNextTy = ICCT_ON ;
|
||||
}
|
||||
}
|
||||
nType = ICCT_ON ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCrvCompoCrvCompo::MergeNewOverlap( int i, bool bCrvAOrB)
|
||||
{
|
||||
if ( i >= ssize(m_Info))
|
||||
return false ;
|
||||
|
||||
// faccio il merge col precedente
|
||||
int j = ( i == 0 ? m_nNumInters - 1 : i - 1) ;
|
||||
if ( m_Info[j].bOverlap) {
|
||||
m_Info[i].IciA[0] = m_Info[j].IciA[0] ;
|
||||
m_Info[i].IciB[0] = m_Info[j].IciB[0] ;
|
||||
}
|
||||
m_Info.erase( m_Info.begin() + j) ;
|
||||
-- j ;
|
||||
-- m_nNumInters ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCrvCompoCrvCompo::IntersSimpleCurves( const ICurve& CurveA, int nA, const ICurve& CurveB, int nB,
|
||||
@@ -941,13 +1139,27 @@ bool
|
||||
IntersCrvCompoCrvCompo::EraseOtherInfo( int& nIndCurr, int& nIndOther)
|
||||
{
|
||||
m_Info.erase( m_Info.begin() + nIndOther) ;
|
||||
if ( nIndOther < nIndCurr)
|
||||
-- nIndCurr ;
|
||||
-- nIndCurr ;
|
||||
-- nIndOther ;
|
||||
-- m_nNumInters ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCrvCompoCrvCompo::EraseBothInfo( int& nIndCurr, int& nIndOther)
|
||||
{
|
||||
m_Info.erase( m_Info.begin() + nIndOther) ;
|
||||
-- nIndCurr ;
|
||||
-- nIndOther ;
|
||||
-- m_nNumInters ;
|
||||
m_Info.erase( m_Info.begin() + nIndCurr) ;
|
||||
if ( nIndCurr != -1)
|
||||
-- nIndCurr ;
|
||||
-- m_nNumInters ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Global functions
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -990,21 +1202,25 @@ SortGreaterB( const IntCrvCrvInfo& aInfo1, const IntCrvCrvInfo& aInfo2)
|
||||
dU1 = aInfo1.IciB[0].dU ;
|
||||
if ( aInfo1.bOverlap) {
|
||||
// caso normale
|
||||
if ( aInfo1.IciB[0].dU < aInfo1.IciB[1].dU)
|
||||
if ( ( aInfo1.bCBOverEq && aInfo1.IciB[0].dU < aInfo1.IciB[1].dU) || ( ! aInfo1.bCBOverEq && aInfo1.IciB[0].dU > aInfo1.IciB[1].dU))
|
||||
dU1 = 0.5 * ( aInfo1.IciB[0].dU + aInfo1.IciB[1].dU) ;
|
||||
// a cavallo di fine / inizio
|
||||
else
|
||||
else if ( aInfo1.bCBOverEq)
|
||||
dU1 = aInfo1.IciB[0].dU + SPAN_PARAM ;
|
||||
else
|
||||
dU1 = aInfo1.IciB[1].dU + SPAN_PARAM ;
|
||||
}
|
||||
// determino il secondo termine del confronto
|
||||
dU2 = aInfo2.IciB[0].dU ;
|
||||
if ( aInfo2.bOverlap) {
|
||||
// caso normale
|
||||
if ( aInfo2.IciB[0].dU < aInfo2.IciB[1].dU)
|
||||
if ( ( aInfo2.bCBOverEq && aInfo2.IciB[0].dU < aInfo2.IciB[1].dU) || ( ! aInfo2.bCBOverEq && aInfo2.IciB[0].dU > aInfo2.IciB[1].dU))
|
||||
dU2 = 0.5 * ( aInfo2.IciB[0].dU + aInfo2.IciB[1].dU) ;
|
||||
// a cavallo di fine / inizio
|
||||
else
|
||||
else if ( aInfo2.bCBOverEq)
|
||||
dU2 = aInfo2.IciB[0].dU + SPAN_PARAM ;
|
||||
else
|
||||
dU2 = aInfo2.IciB[1].dU + SPAN_PARAM ;
|
||||
}
|
||||
|
||||
return ( dU2 > dU1 + EPS_PARAM) ;
|
||||
@@ -1095,11 +1311,20 @@ OrderNonManifoldInters( ICCIVECTOR& Info, const ICurve& CurveA, const ICurve& Cu
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CompatibleParamA( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
|
||||
bool bCrvAClosed, double dCrvASpan)
|
||||
bool bCrvAClosed, double dCrvASpan, bool bOrderedOnB)
|
||||
{
|
||||
int k = ( Icci1.bOverlap ? 1 : 0) ; // del precedente si prende il secondo se overlap
|
||||
if ( abs( Icci1.IciA[k].dU - Icci2.IciA[0].dU) > 0.1 * SPAN_PARAM &&
|
||||
( ! bCrvAClosed || abs( abs( Icci1.IciA[k].dU - Icci2.IciA[0].dU) - dCrvASpan) > 0.1 * SPAN_PARAM))
|
||||
int ki = 0 ;
|
||||
int kj = 0 ;
|
||||
if ( ! bOrderedOnB) {
|
||||
ki = 0 ;
|
||||
kj = Icci1.bOverlap ? 1 : 0 ;
|
||||
}
|
||||
else {
|
||||
ki = Icci2.bOverlap && ! Icci2.bCBOverEq ? 1 : 0 ;
|
||||
kj = Icci1.bOverlap && Icci1.bCBOverEq ? 1 : 0 ;
|
||||
}
|
||||
if ( abs( Icci1.IciA[kj].dU - Icci2.IciA[ki].dU) > 0.1 * SPAN_PARAM &&
|
||||
( ! bCrvAClosed || abs( abs( Icci1.IciA[kj].dU - Icci2.IciA[ki].dU) - dCrvASpan) > 0.1 * SPAN_PARAM))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
@@ -1107,11 +1332,21 @@ CompatibleParamA( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CompatibleParamB( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
|
||||
bool bCrvBClosed, double dCrvBSpan)
|
||||
bool bCrvBClosed, double dCrvBSpan, bool bOrderedOnB)
|
||||
{
|
||||
int k = ( Icci1.bOverlap ? 1 : 0) ; // del precedente si prende il secondo se overlap
|
||||
if ( abs( Icci1.IciB[k].dU - Icci2.IciB[0].dU) > 0.1 * SPAN_PARAM &&
|
||||
( ! bCrvBClosed || abs( abs( Icci1.IciB[k].dU - Icci2.IciB[0].dU) - dCrvBSpan) > 0.1 * SPAN_PARAM))
|
||||
int ki = 0 ;
|
||||
int kj = 0 ;
|
||||
if ( ! bOrderedOnB) {
|
||||
ki = 0 ;
|
||||
kj = Icci1.bOverlap ? 1 : 0 ;
|
||||
}
|
||||
else {
|
||||
ki = Icci2.bOverlap && ! Icci2.bCBOverEq ? 1 : 0 ;
|
||||
kj = Icci1.bOverlap && Icci1.bCBOverEq ? 1 : 0 ;
|
||||
}
|
||||
|
||||
if ( abs( Icci1.IciB[kj].dU - Icci2.IciB[ki].dU) > 0.1 * SPAN_PARAM &&
|
||||
( ! bCrvBClosed || abs( abs( Icci1.IciB[kj].dU - Icci2.IciB[ki].dU) - dCrvBSpan) > 0.1 * SPAN_PARAM))
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,9 @@ class IntersCrvCompoCrvCompo
|
||||
bool bAutoInters, bool bClosed, int nCurvesNbr) ;
|
||||
bool EraseCurrentInfo( int& nIndCurr, int& nIndOther) ;
|
||||
bool EraseOtherInfo( int& nIndCurr, int& nIndOther) ;
|
||||
bool EraseBothInfo( int& nIndCurr, int& nIndOther) ;
|
||||
bool CalcSide( int j, int i,const ICurve* pThisCrv, const ICurve* pOtherCrv, bool bCrvAOrB, int& nType) ;
|
||||
bool MergeNewOverlap( int i, bool bCrvAOrB) ;
|
||||
|
||||
private :
|
||||
bool m_bOverlaps ;
|
||||
|
||||
+23
-3
@@ -576,9 +576,25 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
}
|
||||
}
|
||||
// costruisco il vettore delle classificazioni
|
||||
for ( int i = 0 ; i < nNumInters ; ++ i) {
|
||||
for ( int i = 0 ; i < nNumInters ; ++ i) {
|
||||
// se è definito un tratto precedente
|
||||
double dLenU ; pCurve->GetLengthAtParam( InfoCorr[i].IciA[0].dU, dLenU) ;
|
||||
/*int j = i < nNumInters - 1 ? i + 1 : -1 ;
|
||||
if ( pCurve->IsClosed() && j == - 1)
|
||||
j = 0 ;*/
|
||||
int j = i == 0 ? -1 : i - 1 ;
|
||||
if ( pCurve->IsClosed() && j == - 1)
|
||||
j = nNumInters - 1 ;
|
||||
bool bSpike = false ;
|
||||
if ( j != -1) {
|
||||
bSpike = InfoCorr[i].bOverlap && InfoCorr[j].bOverlap && InfoCorr[i].bCBOverEq != InfoCorr[j].bCBOverEq ;
|
||||
if ( bSpike) {
|
||||
bSpike = abs( InfoCorr[i].IciA[0].dU - InfoCorr[j].IciA[0].dU) < EPS_PARAM ||
|
||||
abs( InfoCorr[i].IciA[0].dU - InfoCorr[j].IciA[1].dU) < EPS_PARAM ||
|
||||
abs( InfoCorr[i].IciA[1].dU - InfoCorr[j].IciA[0].dU) < EPS_PARAM ||
|
||||
abs( InfoCorr[i].IciA[1].dU - InfoCorr[j].IciA[1].dU) < EPS_PARAM ;
|
||||
}
|
||||
}
|
||||
if ( InfoCorr[i].IciA[0].dU > dCurrPar + EPS_PARAM && dLenU - dCurrLen > dLenMin) {
|
||||
// verifico che la definizione sul tratto sia omogenea e valida
|
||||
int nPrevTy = InfoCorr[i].IciA[0].nPrevTy ;
|
||||
@@ -610,7 +626,11 @@ IntersCurveCurve::CalcCurveClassification( const ICurve* pCurve, const ICCIVECTO
|
||||
// salvo dati correnti
|
||||
dCurrPar = InfoCorr[i].IciA[1].dU ;
|
||||
dCurrLen = dLenU ;
|
||||
nLastTy = InfoCorr[i].IciA[1].nNextTy ;
|
||||
// se sono in un caso di spike devo trattare l'overlap in modo diverso
|
||||
if ( ! bSpike)
|
||||
nLastTy = InfoCorr[i].IciA[1].nNextTy ;
|
||||
else
|
||||
nLastTy = InfoCorr[i].IciA[0].nPrevTy ;
|
||||
}
|
||||
}
|
||||
// eventuale tratto finale rimasto
|
||||
@@ -736,7 +756,7 @@ IntersCurveCurve::GetCurveOutClass( const ICurve* pCurve, int& nClass)
|
||||
double dArea ;
|
||||
if ( ! pCurve->GetAreaXY( dArea))
|
||||
return false ;
|
||||
nClass = (( dArea > 0) ? CRVC_OUT : CRVC_IN) ;
|
||||
nClass = (( dArea >= 0) ? CRVC_OUT : CRVC_IN) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,6 +235,16 @@ IntersCurvePlane::GetIntersCount( void)
|
||||
return m_nIntersCount ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurvePlane::GetIntCrvPlnInfo( int nInd, IntCrvPlnInfo& aInfo)
|
||||
{
|
||||
if ( nInd < 0 || nInd >= m_nIntersCount)
|
||||
return false ;
|
||||
aInfo = m_Info[nInd] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersCurvePlane::GetIntersPointNearTo( const Point3d& ptNear, Point3d& ptI, double& dParam)
|
||||
|
||||
+357
-19
@@ -72,14 +72,28 @@ static void
|
||||
UpdateInfoIntersLineSurfBz( const Point3d& ptL, const Vector3d& vtDir, int nILT, int nT, const Point3d& ptSP, const Point3d& ptIBz, double dCos,
|
||||
const Point3d& ptSP2, const Point3d& ptIBz2, double dCos2, ILSBIVECTOR& vInfo)
|
||||
{
|
||||
int nType = LSBT_NONE ;
|
||||
if ( dCos > EPS_ZERO)
|
||||
nType = LSBT_IN ;
|
||||
else if ( dCos < EPS_ZERO)
|
||||
nType = LSBT_OUT ;
|
||||
else
|
||||
nType = LSBT_TOUCH ;
|
||||
|
||||
if ( nILT == ILTA_IN || nILT == ILTA_EDGE || nILT == ILTA_VERT || nILT == ILTA_NO_TRIA) {
|
||||
double dU = ( ptIBz - ptL) * vtDir ;
|
||||
vInfo.emplace_back( nILT, dU, nT, dCos, ptIBz, ptSP) ;
|
||||
vInfo.emplace_back( nType, dU, nT, dCos, ptIBz, ptSP) ;
|
||||
}
|
||||
else if ( nILT == ILTA_SEGM || nILT == ILTA_SEGM_ON_EDGE) {
|
||||
double dU = ( ptIBz - ptL) * vtDir ;
|
||||
double dU2 = ( ptIBz2 - ptL) * vtDir ;
|
||||
vInfo.emplace_back( nILT, dU, dU2, nT, dCos2, ptIBz, ptIBz2, ptSP, ptSP2) ;
|
||||
int nType2 = LSBT_NONE ;
|
||||
if ( dCos2 > EPS_ZERO)
|
||||
nType2 = LSBT_IN ;
|
||||
else if ( dCos2 < EPS_ZERO)
|
||||
nType2 = LSBT_OUT ;
|
||||
vInfo.emplace_back( nType, dU, 0, nT, dCos, ptIBz, P_INVALID, ptSP, P_INVALID) ;
|
||||
vInfo.emplace_back( nType2, dU2, 0, nT, dCos2, ptIBz2, P_INVALID, ptSP2, P_INVALID) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +107,7 @@ OrderInfoIntersLineSurfBz( ILSBIVECTOR& vInfo)
|
||||
// ordino il vettore delle intersezioni secondo il senso crescente del parametro di linea
|
||||
sort( vInfo.begin(), vInfo.end(),
|
||||
[]( const IntLinSbzInfo& a, const IntLinSbzInfo& b)
|
||||
{ double dUa = ( ( a.nILTA == ILTA_SEGM || a.nILTA == ILTA_SEGM_ON_EDGE) ? ( a.dU + a.dU2) / 2 : a.dU) ;
|
||||
double dUb = ( ( b.nILTA == ILTA_SEGM || b.nILTA == ILTA_SEGM_ON_EDGE) ? ( b.dU + b.dU2) / 2 : b.dU) ;
|
||||
return ( dUa < dUb) ; }) ;
|
||||
{ return ( a.dU < b.dU) ; }) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -181,19 +193,9 @@ FilterLineSurfBzInters( const ILSBIVECTOR& vInfo, INTDBLVECTOR& vInters)
|
||||
// ciclo sulle intersezioni
|
||||
for ( const auto& Info : vInfo) {
|
||||
// se intersezione puntuale
|
||||
if ( Info.nILTA == ILTA_VERT || Info.nILTA == ILTA_EDGE || Info.nILTA == ILTA_IN) {
|
||||
int nFlag = LSBT_TOUCH ;
|
||||
if ( Info.dCosDN > EPS_ZERO)
|
||||
nFlag = LSBT_OUT ;
|
||||
else if ( Info.dCosDN < -EPS_ZERO)
|
||||
nFlag = LSBT_IN ;
|
||||
vInters.emplace_back( nFlag, Info.dU) ;
|
||||
}
|
||||
// se altrimenti intersezione con coincidenza
|
||||
else if ( Info.nILTA == ILTA_SEGM || Info.nILTA == ILTA_SEGM_ON_EDGE) {
|
||||
vInters.emplace_back( LSBT_TG_INI, Info.dU) ;
|
||||
vInters.emplace_back( LSBT_TG_FIN, Info.dU2) ;
|
||||
}
|
||||
vInters.emplace_back( Info.nILSB, Info.dU) ;
|
||||
// se intersezione sovrapposta
|
||||
// da sviluppare
|
||||
}
|
||||
// elimino intersezioni ripetute
|
||||
for ( size_t j = 1 ; j < vInters.size() ; ) {
|
||||
@@ -239,7 +241,343 @@ FilterLineSurfBzInters( const ILSBIVECTOR& vInfo, INTDBLVECTOR& vInters)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Intersezione di una linea con una superficie di Bezier
|
||||
// Intersezione di una linea con una superficie di Bezier di grado 3x1 monopatch
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineSurfBzCubicLinear( const Point3d& ptL, const Vector3d& vtL, double dLen, const ISurfBezier* pSurfBz,
|
||||
ILSBIVECTOR& vInfo, bool bFinite)
|
||||
{
|
||||
int nDegU, nDegV, nSpanU, nSpanV ;
|
||||
bool bRat, bTrimmed ;
|
||||
pSurfBz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bRat, bTrimmed) ;
|
||||
|
||||
// funzione pensata per funzionare solo con una monopatch di grado 3x1
|
||||
if ( nDegU != 3 || nDegV != 1 || nSpanU > 1 || nSpanV > 1 || bRat)
|
||||
return false ;
|
||||
|
||||
int nInters = int( vInfo.size()) ;
|
||||
|
||||
Point3d r = ptL ;
|
||||
Vector3d q = vtL ;
|
||||
bool bNeedToRotX = AreSameVectorApprox( q, X_AX) ;
|
||||
bool bNeedToRotY = AreSameVectorApprox( q, Y_AX) ;
|
||||
bool bNeedToRot = bNeedToRotX || bNeedToRotY ;
|
||||
Frame3d frRot ;
|
||||
if ( bNeedToRotX)
|
||||
frRot.Set( ORIG, X_AX) ;
|
||||
if ( bNeedToRotY)
|
||||
frRot.Set( ORIG, Y_AX) ;
|
||||
if ( bNeedToRot) {
|
||||
r.ToLoc( frRot) ;
|
||||
q.ToLoc( frRot) ;
|
||||
}
|
||||
|
||||
PNTVECTOR vPntCtrl = pSurfBz->GetAllControlPoints() ;
|
||||
|
||||
if ( bNeedToRot) {
|
||||
for ( Point3d& pt: vPntCtrl)
|
||||
pt.ToLoc( frRot) ;
|
||||
}
|
||||
|
||||
Vector3d A = vPntCtrl[4] - vPntCtrl[0] ;
|
||||
Vector3d B = vPntCtrl[5] - vPntCtrl[1] ;
|
||||
Vector3d C = vPntCtrl[6] - vPntCtrl[2] ;
|
||||
Vector3d D = vPntCtrl[7] - vPntCtrl[3] ;
|
||||
Vector3d E = vPntCtrl[0] - ORIG ;
|
||||
Vector3d F = vPntCtrl[1] - ORIG ;
|
||||
Vector3d G = vPntCtrl[2] - ORIG ;
|
||||
Vector3d H = vPntCtrl[3] - ORIG ;
|
||||
|
||||
Vector3d a3 = -A + 3 * B - 3 * C + D ;
|
||||
Vector3d a2 = 3 * A - 6 * B + 3 * C ;
|
||||
Vector3d a1 = -3 * A + 3 * B ;
|
||||
Vector3d a0 = A ;
|
||||
|
||||
Vector3d b3 = -E + 3 * F - 3 * G + H ;
|
||||
Vector3d b2 = 3 * E - 6 * F + 3 * G ;
|
||||
Vector3d b1 = -3 * E + 3 * F ;
|
||||
Vector3d b0 = E ;
|
||||
|
||||
|
||||
|
||||
DBLVECTOR vdCoeff, vdRoots ;
|
||||
// coefficienti dal grado più basso al grado più alto
|
||||
vdCoeff = { // c0
|
||||
q.x*q.z*a0.y*b0.z - q.x*q.y*a0.z*b0.z // 3
|
||||
- r.z*q.x*q.z*a0.y + r.z*q.x*q.y*a0.z + // 3
|
||||
q.y*q.z*a0.z*b0.z - q.z*q.z*a0.y*b0.x // 4
|
||||
- r.x*q.y*q.z*a0.z + r.x*q.z*q.z*a0.y + // 4
|
||||
q.z*q.z*a0.x*b0.y - q.y*q.z*a0.x*b0.z - q.x*q.z*a0.z*b0.y + q.x*q.y*a0.z*b0.z // 5
|
||||
- r.y*q.z*q.z*a0.x + r.z*q.y*q.z*a0.x + r.y*q.x*q.z*a0.z - r.z*q.x*q.y*a0.z, // 5
|
||||
|
||||
// c1
|
||||
q.x*q.z*(a1.y*b0.z + a0.y*b1.z) - q.x*q.y*(a1.z*b0.z + a0.z*b1.z) // 3
|
||||
- r.z*q.x*q.z*a1.y + r.z*q.x*q.y*a1.z + // 3
|
||||
q.y*q.z*(a1.z*b0.x + a0.z*b1.x) - q.z*q.z*(a1.y*b0.x + a0.y*b1.x) // 4
|
||||
- r.x*q.y*q.z*a1.z + r.x*q.z*q.z*a1.y + // 4
|
||||
q.z*q.z*(a1.x*b0.y + a0.x*b1.y) - q.y*q.z*(a1.x*b0.z + a0.x*b1.z) // 5
|
||||
- q.x*q.z*(a1.z*b0.y + a0.z*b1.y) + q.x*q.y*(a1.z*b0.z + a0.z*b1.z) // 5
|
||||
- r.y*q.z*q.z*a1.x + r.z*q.y*q.z*a1.x + r.y*q.x*q.z*a1.z - r.z*q.x*q.y*a1.z, // 5
|
||||
|
||||
// c2
|
||||
q.x*q.z*(a2.y*b0.z + a1.y*b1.z + a0.y*b2.z) - q.x*q.y*(a2.z*b0.z + a1.z*b1.z + a0.z*b2.z) // 3
|
||||
- r.z*q.x*q.z*a2.y + r.z*q.x*q.y*a2.z + // 3
|
||||
q.y*q.z*(a2.z*b0.x + a1.z*b1.x + a0.z*b2.x) - q.z*q.z*(a2.y*b0.x + a1.y*b1.x + a0.y*b2.x) // 4
|
||||
- r.x*q.y*q.z*a2.z + r.x*q.z*q.z*a2.y + // 4
|
||||
q.z*q.z*(a2.x*b0.y + a1.x*b1.y + a0.x*b2.y) - q.y*q.z*(a2.x*b0.z + a1.x*b1.z + a0.x*b2.z) // 5
|
||||
- q.x*q.z*(a2.z*b0.y + a1.z*b1.y + a0.z*b2.y) + q.x*q.y*(a2.z*b0.z + a1.z*b1.z + a0.z*b2.z)// 5
|
||||
- r.y*q.z*q.z*a2.x + r.z*q.y*q.z*a2.x + r.y*q.x*q.z*a2.z - r.z*q.x*q.y*a2.z, // 5
|
||||
|
||||
// c3
|
||||
q.x*q.z*(a3.y*b0.z + a2.y*b1.z + a1.y*b2.z + a0.y*b3.z) - q.x*q.y*(a3.z*b0.z + a2.z*b1.z + a1.z*b2.z + a0.z*b3.z) // 3
|
||||
- r.z*q.x*q.z*a3.y + r.z*q.x*q.y*a3.z + // 3
|
||||
q.y*q.z*(a3.z*b0.x + a2.z*b1.x + a1.z*b2.x + a0.z*b3.x) - q.z*q.z*(a3.y*b0.x + a2.y*b1.x + a1.y*b2.x + a0.y*b3.x) // 4
|
||||
- r.x*q.y*q.z*a3.z + r.x*q.z*q.z*a3.y + // 4
|
||||
q.z*q.z*(a3.x*b0.y + a2.x*b1.y + a1.x*b2.y + a0.x*b3.y) - q.y*q.z*(a3.x*b0.z + a2.x*b1.z + a1.x*b2.z + a0.x*b3.z) // 5
|
||||
- q.x*q.z*(a3.z*b0.y + a2.z*b1.y + a1.z*b2.y + a0.z*b3.y) + q.x*q.y*(a3.z*b0.z + a2.z*b1.z + a1.z*b2.z + a0.z*b3.z)// 5
|
||||
- r.y*q.z*q.z*a3.x + r.z*q.y*q.z*a3.x + r.y*q.x*q.z*a3.z - r.z*q.x*q.y*a3.z, // 5
|
||||
|
||||
// c4
|
||||
q.x*q.z*(a3.y*b1.z + a2.y*b2.z + a1.y*b3.z) - q.x*q.y*(a3.z*b1.z + a2.z*b2.z + a1.z*b3.z) + // 3
|
||||
q.y*q.z*(a3.z*b1.x + a2.z*b2.x + a1.z*b3.x) - q.z*q.z*(a3.y*b1.x + a2.y*b2.x + a1.y*b3.x) + // 4
|
||||
q.z*q.z*(a3.x*b1.y + a2.x*b2.y + a1.x*b3.y) - q.y*q.z*(a3.x*b1.z + a2.x*b2.z + a1.x*b3.z) // 5
|
||||
- q.x*q.z*(a3.z*b1.y + a2.z*b2.y + a1.z*b3.y) + q.x*q.y*(a3.z*b1.z + a2.z*b2.z + a1.z*b3.z), // 5
|
||||
|
||||
// c5
|
||||
q.x*q.z*(a3.y*b2.z + a2.y*b3.z) - q.x*q.y*(a3.z*b2.z + a2.z*b3.z) + // 3
|
||||
q.y*q.z*(a3.z*b2.x + a2.z*b3.x) - q.z*q.z*(a3.y*b2.x + a2.y*b3.x) + // 4
|
||||
q.z*q.z*(a3.x*b2.y + a2.x*b3.y) - q.y*q.z*(a3.x*b2.z + a2.x*b3.z) // 5
|
||||
- q.x*q.z*(a3.z*b2.y + a2.z*b3.y) + q.x*q.y*(a3.z*b2.z + a2.z*b3.z), // 5
|
||||
|
||||
// c6
|
||||
q.x*q.z*a3.y*b3.z - q.x*q.y*a3.z*b3.z + // 3
|
||||
q.y*q.z*a3.z*b3.x - q.z*q.z*a3.y*b3.x + // 4
|
||||
q.z*q.z*a3.x*b3.y - q.y*q.z*a3.x*b3.z - q.x*q.z*a3.z*b3.y + q.x*q.y*a3.z*b3.z} ; // 5
|
||||
int nRoots = PolynomialRoots( 6, vdCoeff, vdRoots) ;
|
||||
bool bFound = false ;
|
||||
for ( int w = 0 ; w < nRoots ; ++w) {
|
||||
double dU = 0, dV = 0 ;
|
||||
if ( vdRoots[w] > 0 - EPS_ZERO && vdRoots[w] < 1 + EPS_ZERO) {
|
||||
dU = vdRoots[w] ;
|
||||
// verifico che non sia una soluzione con molteplicità > 1
|
||||
bool bAlreadyFound = false ;
|
||||
for ( int k = w - 1 ; k >= 0 && ! bAlreadyFound ; --k)
|
||||
bAlreadyFound = ( abs( dU - vdRoots[k]) < EPS_PARAM) ;
|
||||
if ( ! bAlreadyFound) {
|
||||
Vector3d vAlpha = a3 * pow(dU, 3) + a2 * pow( dU, 2) + a1 * dU + a0 ;
|
||||
Vector3d vBeta = b3 * pow(dU, 3) + b2 * pow( dU, 2) + b1 * dU + b0 ;
|
||||
double dDen = ( vAlpha.x * q.z - vAlpha.z * q.x) ;
|
||||
if ( abs( dDen) > EPS_ZERO)
|
||||
dV = ( ( vBeta.z - r.z) * q.x - ( vBeta.x - r.x ) * q.z) / dDen ;
|
||||
else {
|
||||
// se la prima equazione risulta un x/0 allora uso la seconda equazione per trovare il secondo parametro
|
||||
double dDen2 = ( vAlpha.y * q.z - vAlpha.z * q.y) ;
|
||||
dV = ( ( vBeta.z - r.z) * q.y - ( vBeta.y - r.y ) * q.z) / dDen2 ;
|
||||
}
|
||||
if ( dV > - EPS_ZERO && dV < 1 + EPS_ZERO) {
|
||||
Point3d ptIBez, ptIBez2 ;
|
||||
Vector3d vtN ;
|
||||
pSurfBz->GetPointNrmD1D2(dU, dV, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptIBez, vtN) ;
|
||||
Point3d ptSP( dU, dV, 0), ptSP2 ;
|
||||
double dCos = vtN * vtL, dCos2 = 0 ;
|
||||
int nType = ILTA_NO_TRIA ;
|
||||
UpdateInfoIntersLineSurfBz( ptL, vtL, nType, -1, ptSP, ptIBez, dCos, ptSP2, ptIBez2, dCos2, vInfo) ;
|
||||
bFound = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// se tutti i coefficienti sono zero allora potrei avere una linea che giace sulla superficie
|
||||
//// per trovare i punti di inizio e fine sovrapposizione trovo i punti a minima distanza tra la linea e gli edge della superficie
|
||||
//if ( ! bFound && abs( vdCoeff[0]) < EPS_ZERO && abs( vdCoeff[1]) < EPS_ZERO && abs( vdCoeff[2]) < EPS_ZERO) {
|
||||
// ICRVCOMPOPOVECTOR vCrvEdge( 4) ;
|
||||
// vCrvEdge[0].Set(pSurfBz->GetCurveOnU( 0)) ;
|
||||
// vCrvEdge[1].Set(pSurfBz->GetCurveOnV( 1)) ;
|
||||
// vCrvEdge[2].Set(pSurfBz->GetCurveOnU( 1)) ;
|
||||
// vCrvEdge[3].Set(pSurfBz->GetCurveOnV( 0)) ;
|
||||
// double dAngTolDeg = 5 ;
|
||||
// for ( int i = 0 ; i < 4 ; ++i) {
|
||||
// PolyLine plApprox ; vCrvEdge[0]->ApproxWithLines( EPS_SMALL, dAngTolDeg, ICurve::ApprLineType::APL_STD, plApprox) ;
|
||||
// //CurveComposite cCC ;
|
||||
// //cCC.FromPolyLine( plApprox) ;
|
||||
// int nClosestLine = -1 ;
|
||||
// double dMinDist = INFINITO ;
|
||||
// Point3d pt ; plApprox.GetFirstPoint( pt) ;
|
||||
// Point3d ptClosest ;
|
||||
// int c = 0 ;
|
||||
// int nTot = plApprox.GetPointNbr() ;
|
||||
// for ( int j = 0 ; j < nTot ; ++j) {
|
||||
// DistPointLine dpl( pt, ptL, vtL, dLen, bFinite) ;
|
||||
// double dDist = INFINITO ;
|
||||
// dpl.GetDist( dDist) ;
|
||||
// if ( dDist < dMinDist) {
|
||||
// nClosestLine = c ;
|
||||
// dMinDist = dDist ;
|
||||
// }
|
||||
// plApprox.GetNextPoint( pt) ;
|
||||
// ++ c ;
|
||||
// }
|
||||
|
||||
// Point3d ptInt1, ptInt2 ;
|
||||
// if ( nClosestLine < nTot - 1 && nClosestLine > 0) {
|
||||
// // tra i due tratti dell'approssimazione che arrivano al punto selezionato come più vicino, devo trovare quale si avvicina di più
|
||||
// Point3d ptStart ; plApprox.GetFirstPoint( ptStart) ;
|
||||
// Point3d ptEnd ;
|
||||
// for ( int z = 1 ; z < nClosestLine - 1 ; ++z)
|
||||
// plApprox.GetNextPoint( ptStart) ;
|
||||
// plApprox.GetNextPoint( ptEnd) ;
|
||||
// // linea precedente al punto
|
||||
// Vector3d vtLinePre = ptEnd - ptStart ;
|
||||
// double dLenPre = vtLinePre.Len() ;
|
||||
// DistLineLine dllPre( ptStart, vtLinePre, dLenPre, ptL, vtL,dLen) ;
|
||||
// double dDistPre = INFINITO ;
|
||||
// dllPre.GetDist( dDistPre) ;
|
||||
// // linea che inzia con quel punto
|
||||
// ptStart = ptEnd ;
|
||||
// plApprox.GetNextPoint( ptEnd) ;
|
||||
// Vector3d vtLineCurr = ptEnd - ptStart ;
|
||||
// double dLenCurr = vtLineCurr.Len() ;
|
||||
// DistLineLine dllCurr( ptStart, vtLineCurr, dLenCurr, ptL, vtL,dLen) ;
|
||||
// double dDistCurr = INFINITO ;
|
||||
// dllCurr.GetDist( dDistCurr) ;
|
||||
|
||||
// if ( dDistPre < dDistCurr)
|
||||
// dllPre.GetMinDistPoints( ptInt1, ptInt2) ;
|
||||
// else
|
||||
// dllCurr.GetMinDistPoints( ptInt1, ptInt2) ;
|
||||
// }
|
||||
// else if ( nClosestLine == 0) {
|
||||
// // il punto più vicino è sulla prima linea
|
||||
// Point3d ptStart ; plApprox.GetFirstPoint( ptStart) ;
|
||||
// Point3d ptEnd ; plApprox.GetNextPoint( ptEnd) ;
|
||||
// Vector3d vtLineCurr = ptEnd - ptStart ;
|
||||
// double dLenCurr = vtLineCurr.Len() ;
|
||||
// DistLineLine dllCurr( ptStart, vtLineCurr, dLenCurr, ptL, vtL,dLen) ;
|
||||
// dllCurr.GetMinDistPoints( ptInt1, ptInt2) ;
|
||||
// }
|
||||
// else if ( nClosestLine == nTot- 1) {
|
||||
// // il punto più vicino è sull'ultima linea
|
||||
// Point3d ptStart ; plApprox.GetFirstPoint( ptStart) ;
|
||||
// Point3d ptEnd ;
|
||||
// for ( int z = 1 ; z < nClosestLine - 1 ; ++z)
|
||||
// plApprox.GetNextPoint( ptStart) ;
|
||||
// plApprox.GetNextPoint( ptEnd) ;
|
||||
// Vector3d vtLinePre = ptEnd - ptStart ;
|
||||
// double dLenPre = vtLinePre.Len() ;
|
||||
// DistLineLine dllCurr( ptStart, vtLinePre, dLenPre, ptL, vtL,dLen) ;
|
||||
// dllCurr.GetMinDistPoints( ptInt1, ptInt2) ;
|
||||
// }
|
||||
//
|
||||
// double dU1 = 0, dV1 = 0, dU2 = 0, dV2 = 0 ;
|
||||
// // se ho trovato due punti vuol dire che la linea coincide con un edge e ho trovato tutto quello che serve
|
||||
// if ( ! AreSamePointExact( ptInt2, ORIG)) {
|
||||
// if ( i == 0) {
|
||||
// //dV1 = 0 ; dV2 = 0 ;
|
||||
// vCrvEdge[0]->GetParamAtPoint( ptInt1, dU1) ;
|
||||
// vCrvEdge[0]->GetParamAtPoint( ptInt2, dU2) ;
|
||||
// }
|
||||
// else if ( i == 1) {
|
||||
// //dU1 = 1 ; dU2 = 1 ;
|
||||
// vCrvEdge[1]->GetParamAtPoint( ptInt1, dV1) ;
|
||||
// vCrvEdge[1]->GetParamAtPoint( ptInt2, dV2) ;
|
||||
// }
|
||||
// else if ( i == 2){
|
||||
// //dV1 = 1 ; dV2 = 1 ;
|
||||
// vCrvEdge[2]->GetParamAtPoint( ptInt1, dU1) ;
|
||||
// vCrvEdge[2]->GetParamAtPoint( ptInt2, dU2) ;
|
||||
// }
|
||||
// else if ( i == 3){
|
||||
// //dU1 = 0 ; dU2 = 0 ;
|
||||
// vCrvEdge[3]->GetParamAtPoint( ptInt1, dV1) ;
|
||||
// vCrvEdge[3]->GetParamAtPoint( ptInt2, dV2) ;
|
||||
// }
|
||||
// Point3d ptIBez1, ptIBez2 ;
|
||||
// Vector3d vtN1, vtN2 ;
|
||||
// pSurfBz->GetPointNrmD1D2(dU1, dV1, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptIBez1, vtN1) ;
|
||||
// pSurfBz->GetPointNrmD1D2(dU2, dV2, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptIBez2, vtN2) ;
|
||||
// Point3d ptSP1( dU1, dV1, 0) ;
|
||||
// double dCos1 = vtN1 * vtL ;
|
||||
// Point3d ptSP2( dU2, dV2, 0) ;
|
||||
// double dCos2 = vtN2 * vtL ;
|
||||
// // se avevo già trovato un punto singolo che coincide col primo punto di questa intersezione sovrapposta, allora cancello l'intersezione singola che
|
||||
// // avevo salvato e aggiungo quella sovrapposto che ho trovato ora
|
||||
// if ( bFound) {
|
||||
// int nNewTot = int(vInfo.size()) ;
|
||||
// int nNewInters = nNewTot - nInters ;
|
||||
// bool bAlreadyFound = false ;
|
||||
// for ( int i = 0 ; i < nNewInters ; ++i) {
|
||||
// bAlreadyFound = AreSamePointApprox(vInfo[nNewTot - i].ptUV, ptSP1) || AreSamePointApprox(vInfo[nNewTot - i].ptUV, ptSP2) ;
|
||||
// if ( bAlreadyFound) {
|
||||
// vInfo.erase( vInfo.begin() + nNewTot - i) ;
|
||||
// break ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// UpdateInfoIntersLineSurfBz( ptL, vtL, ILTA_NO_TRIA, -1, ptSP1, ptIBez1, dCos1, ptSP2, ptIBez2, dCos2, vInfo) ;
|
||||
// bFound = true ;
|
||||
// break ;
|
||||
// }
|
||||
// // se ho trovato un punto a distanza zero dalla linea allora ho trovato l'intersezione
|
||||
// else if ( dMinDist < EPS_SMALL) {
|
||||
// if ( i == 0) {
|
||||
// //dV1 = 0 ;
|
||||
// vCrvEdge[0]->GetParamAtPoint( ptInt1, dU1) ;
|
||||
// }
|
||||
// else if ( i == 1) {
|
||||
// //dU1 = 1 ;
|
||||
// vCrvEdge[1]->GetParamAtPoint( ptInt1, dV1) ;
|
||||
// }
|
||||
// else if ( i == 2) {
|
||||
// //dV1 = 1 ;
|
||||
// vCrvEdge[2]->GetParamAtPoint( ptInt1, dU1) ;
|
||||
// }
|
||||
// else if ( i == 3) {
|
||||
// //dU1 = 0 ;
|
||||
// vCrvEdge[3]->GetParamAtPoint( ptInt1, dV1) ;
|
||||
// }
|
||||
// Point3d ptSP1( dU1, dV1, 0), ptSP2 ;
|
||||
// // se avevo trovato già altri punti controllo di non essere esattamente su una diagonale ( e quindi avere un'intersezione con ogni edge, ma due sono doppie)
|
||||
// if ( bFound) {
|
||||
// int nNewTot = int(vInfo.size()) ;
|
||||
// int nNewInters = nNewTot - nInters ;
|
||||
// bool bAlreadyFound = false ;
|
||||
// for ( int i = 0 ; i < nNewInters ; ++i)
|
||||
// bAlreadyFound = AreSamePointApprox(vInfo[nNewTot - i].ptUV, ptSP1) ;
|
||||
// if ( bAlreadyFound)
|
||||
// continue ;
|
||||
// }
|
||||
|
||||
// Point3d ptIBez1, ptIBez2 ;
|
||||
// Vector3d vtN1, vtN2 ;
|
||||
// pSurfBz->GetPointNrmD1D2(dU1, dV1, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptIBez1, vtN1) ;
|
||||
// double dCos1 = vtN1 * vtL, dCos2 = 0 ;
|
||||
// UpdateInfoIntersLineSurfBz( ptL, vtL, ILTA_NO_TRIA, -1, ptSP1, ptIBez1, dCos1, ptSP2, ptIBez2, dCos2, vInfo) ;
|
||||
// bFound = true ;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// se la superficie è trimmed verifico che i punti trovati siano all'interno del parametrico trimmato
|
||||
if ( bTrimmed && bFound) {
|
||||
int nNewTot = int(vInfo.size()) ;
|
||||
int nNewInters = nNewTot - nInters ;
|
||||
const ISurfFlatRegion* pFRTrim = pSurfBz->GetTrimRegion() ;
|
||||
for ( int i = 0 ; i < nNewInters ; ++i) {
|
||||
Point3d ptTest = vInfo[nNewTot - i].ptUV * SBZ_TREG_COEFF ;
|
||||
bool bInside = false ;
|
||||
double dDist = INFINITO ;
|
||||
IsPointInsideSurfFr( ptTest, pFRTrim, dDist, bInside) ;
|
||||
if ( ! bInside)
|
||||
vInfo.erase( vInfo.begin() + nNewTot - i) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Intersezione di una linea con una superficie di Bezier bilineare monopatch
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineSurfBzBilinear( const Point3d& ptL, const Vector3d& vtL, double dLen, const ISurfBezier* pSurfBz,
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ Polygon3d::FromPlaneTrimmedWithBox( const Point3d& ptOn, const Vector3d& vtN,
|
||||
{
|
||||
Plane3d plPlane ;
|
||||
plPlane.Set( ptOn, vtN) ;
|
||||
return FromPlaneTrimmedWithBox( plPlane, ptMin, ptMax, bOnEq, bOnCt) ;
|
||||
return FromPlaneTrimmedWithBox( plPlane, ptMin, ptMax, bOnEq, bOnCt, dToler) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -733,6 +733,42 @@ GetSurfBezierRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, dou
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierRuledSmooth( const ICurve* pCurve1, const ICurve* pCurve2, double dSampleLen)
|
||||
{
|
||||
// verifica parametri
|
||||
if ( pCurve1 == nullptr || pCurve2 == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// dLinTol servirà quando ci sarà la funzione ApproxWithCurveBezier
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
PtrOwner<ICurveComposite> pCC1( CreateCurveComposite()) ;
|
||||
if ( pCurve1->GetType() != CRV_BEZIER)
|
||||
pCC1->AddCurve( CurveToBezierCurve( pCurve1, 3, false)) ;
|
||||
else
|
||||
pCC1->AddCurve( pCurve1->Clone()) ;
|
||||
if ( IsNull( pCC1) || ! pCC1->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
PtrOwner<ICurveComposite> pCC2( CreateCurveComposite()) ;
|
||||
if ( pCurve2->GetType() != CRV_BEZIER)
|
||||
pCC2->AddCurve( CurveToBezierCurve( pCurve2, 3, false)) ;
|
||||
else
|
||||
pCC2->AddCurve( pCurve2->Clone()) ;
|
||||
if ( IsNull( pCC2) || ! pCC2->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateSmoothRuledByTwoCurves( pCC1, pCC2, dSampleLen))
|
||||
return nullptr ;
|
||||
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierRuledGuided( const ICurve* pCurve1, const ICurve* pCurve2, const BIPNTVECTOR& vCrv, double dLinTol)
|
||||
|
||||
+110
-22
@@ -29,6 +29,7 @@
|
||||
|
||||
#define SAVEMKUNIF_CRVS 0
|
||||
#if SAVEMKUNIF_CRVS
|
||||
std::vector<IGeoObj*> vGeo ;
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#endif
|
||||
|
||||
@@ -618,7 +619,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
|
||||
#if SAVEMKUNIF_CRVS
|
||||
//debug
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vGeo.clear() ;
|
||||
for( int i = 0 ; i < ssize( vLoop); ++i){
|
||||
vGeo.push_back(vLoop[i]->Clone()) ;
|
||||
}
|
||||
@@ -632,7 +633,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
nDir == 0 ? bRescaledU = true : bRescaledV = true ;
|
||||
// creo il vettore delle curve all'interno di una striscia
|
||||
ICRVCOMPOPOVECTOR vCrvStrip ;
|
||||
for ( int p = 0 ; p < (int)vU.size() - 1 ; ++p) {
|
||||
for ( int p = 0 ; p < ssize(vU) - 1 ; ++p) {
|
||||
double dLenStrip = abs( vU[p+1] - vU[p]) ;
|
||||
if ( dLenStrip < EPS_SMALL)
|
||||
continue ;
|
||||
@@ -654,24 +655,85 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
for ( int l = 0 ; l < ssize( vLoop); ++l) {
|
||||
#if SAVEMKUNIF_CRVS
|
||||
//debug
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vGeo.clear() ;
|
||||
vGeo.push_back(pTrimMask->Clone()) ;
|
||||
vGeo.push_back(vLoop[l]->Clone()) ;
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\bezier\\import3dm\\trim_error\\failed_trim_crv_inters.nge") ;
|
||||
//debug
|
||||
#endif
|
||||
IntersCurveCurve icc( *pTrimMask, *vLoop[l]) ;
|
||||
CRVCVECTOR vCurveClass ;
|
||||
icc.GetCurveClassification( 1, 10 * EPS_SMALL, vCurveClass) ;
|
||||
for( int i = 0 ; i < ssize( vCurveClass); ++i) {
|
||||
if( vCurveClass[i].nClass == CRVC_IN || vCurveClass[i].nClass == CRVC_ON_P)
|
||||
vCrvStrip.emplace_back( ConvertCurveToComposite( vLoop[l]->CopyParamRange( vCurveClass[i].dParS, vCurveClass[i].dParE))) ;
|
||||
IntersCurveCurve icc( *vLoop[l], *pTrimMask) ;
|
||||
int nInters = icc.GetIntersCount() ;
|
||||
ICCIVECTOR vICCI ;
|
||||
for ( int i = 0 ; i < nInters ; ++i) {
|
||||
IntCrvCrvInfo icci ; icc.GetIntCrvCrvInfo( i, icci) ;
|
||||
vICCI.push_back( std::move( icci)) ;
|
||||
}
|
||||
CRVCVECTOR vCrvClass, vMaskClass ;
|
||||
icc.GetCurveClassification( 0, EPS_SMALL, vCrvClass) ;
|
||||
icc.GetCurveClassification( 1, EPS_SMALL, vMaskClass) ;
|
||||
// se dei pezzi di trim risultano esterni allo spazio parametrico tengo il bordo della maschera di trim
|
||||
double dLastParam1 = 0 ;
|
||||
double dStartA = 0, dEndA = 0 ; vLoop[l]->GetDomain( dStartA, dEndA) ;
|
||||
double dEndB = 4 ;
|
||||
for ( int i = 0 ; i < ssize( vCrvClass); ++i) {
|
||||
if ( vCrvClass[i].nClass == CRVC_IN || vCrvClass[i].nClass == CRVC_ON_P) {
|
||||
vCrvStrip.emplace_back( ConvertCurveToComposite( vLoop[l]->CopyParamRange( vCrvClass[i].dParS, vCrvClass[i].dParE))) ;
|
||||
|
||||
for ( int j = 0 ; j < ssize( vICCI) ; ++j) {
|
||||
int k = vICCI[j].bOverlap ? 1 : 0 ;
|
||||
if ( abs( vICCI[j].IciA[k].dU - vCrvClass[i].dParE) < EPS_PARAM) {
|
||||
dLastParam1 = vICCI[j].IciB[k].dU ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( vCrvClass[i].nClass == CRVC_OUT && ( p == 0 || p == ssize(vU) - 2)){
|
||||
double dMin, dMax ;
|
||||
if ( p == 0) {
|
||||
dMin = nDir == 0 ? 3 : 0 ;
|
||||
dMax = nDir == 0 ? 4 : 1 ;
|
||||
}
|
||||
else {
|
||||
dMin = nDir == 0 ? 1 : 2 ;
|
||||
dMax = nDir == 0 ? 2 : 3 ;
|
||||
}
|
||||
// aggiungo la parte di curva di edge al posto della parte di curva che esce dal parametrico
|
||||
// se non ho ancora aggiunto un tratto parto dal primo punto di intersezione
|
||||
if ( ssize( vCrvStrip) == 0) {
|
||||
double dPar0 = vCrvClass[i].dParS ;
|
||||
for ( int j = 0 ; j < ssize( vICCI) ; ++j) {
|
||||
int k = vICCI[j].bOverlap ? 1 : 0 ;
|
||||
if ( abs(vICCI[j].IciA[k].dU - dPar0) < EPS_PARAM ||
|
||||
( abs( dEndA - vICCI[j].IciA[k].dU - dPar0) < EPS_PARAM)) {
|
||||
if ( abs( dEndB - vICCI[j].IciB[k].dU) < EPS_PARAM)
|
||||
dLastParam1 = 0 ;
|
||||
else
|
||||
dLastParam1 = vICCI[j].IciB[k].dU ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
int c = 0 ;
|
||||
while ( c < ssize( vMaskClass) - 1 && abs( vMaskClass[c].dParS - dLastParam1) > EPS_PARAM)
|
||||
++c ;
|
||||
|
||||
if ( vMaskClass[c].nClass == CRVC_IN && vMaskClass[c].dParS < dMax && vMaskClass[c].dParS >= dMin) {
|
||||
vCrvStrip.emplace_back( ConvertCurveToComposite( pTrimMask->CopyParamRange( vMaskClass[c].dParS, vMaskClass[c].dParE))) ;
|
||||
dLastParam1 = vMaskClass[c].dParE ;
|
||||
// se sono alla fine curva verifico se devo aggiungere anche un pezzo di inizio
|
||||
if ( dLastParam1 == dEndB && vMaskClass[0].nClass == CRVC_IN) {
|
||||
c = 0 ;
|
||||
vCrvStrip.emplace_back( ConvertCurveToComposite( pTrimMask->CopyParamRange( vMaskClass[c].dParS, vMaskClass[c].dParE))) ;
|
||||
dLastParam1 = vMaskClass[c].dParE ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if SAVEMKUNIF_CRVS
|
||||
//debug
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vGeo.clear() ;
|
||||
for( int i = 0 ; i < ssize( vCrvStrip); ++i){
|
||||
vGeo.push_back(vCrvStrip[i]->Clone()) ;
|
||||
}
|
||||
@@ -694,25 +756,27 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
return false ;
|
||||
}
|
||||
|
||||
// prima di riunire le curve al resto devo traslarle sul bordo destro della superificie che sto ricostruendo
|
||||
// prima di riunire le curve al resto devo traslarle sul bordo destro della superificie che sto ricostruendo (nDir == 0)
|
||||
// oppure sul bordo superiore ( nDir == 1)
|
||||
Point3d pt ;
|
||||
nDir == 0 ? pt.Set( abs(vU[p] - vU.front()), 0, 0) : pt.Set( 0,abs(vU[p] - vU.front()), 0) ;
|
||||
if ( nDir == 0)
|
||||
pt.Scale( GLOB_FRM, SBZ_TREG_COEFF / dLenStrip, 1, 1) ;
|
||||
else
|
||||
pt.Scale( GLOB_FRM, 1, SBZ_TREG_COEFF / dLenStrip, 1) ;
|
||||
|
||||
Vector3d vtJoin ;
|
||||
if ( nDir == 0)
|
||||
if ( nDir == 0) {
|
||||
pt.Set( abs( vU[p] - vU.front()), 0, 0) ;
|
||||
pt.Scale( GLOB_FRM, SBZ_TREG_COEFF / dLenStrip, 1, 1) ;
|
||||
vtJoin.Set( p * SBZ_TREG_COEFF - pt.x, 0, 0) ;
|
||||
else
|
||||
}
|
||||
else {
|
||||
pt.Set( 0, abs(vU[p] - vU.front()), 0) ;
|
||||
pt.Scale( GLOB_FRM, 1, SBZ_TREG_COEFF / dLenStrip, 1) ;
|
||||
vtJoin.Set( 0, p * SBZ_TREG_COEFF - pt.y, 0) ;
|
||||
}
|
||||
|
||||
for( int i = 0 ; i < ssize( vCrvStrip); ++i)
|
||||
vCrvStrip[i]->Translate( vtJoin) ;
|
||||
|
||||
#if SAVEMKUNIF_CRVS
|
||||
//debug
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vGeo.clear() ;
|
||||
for( int i = 0 ; i < ssize( vCrvStrip); ++i){
|
||||
vGeo.push_back(vCrvStrip[i]->Clone()) ;
|
||||
}
|
||||
@@ -725,7 +789,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
if ( ! vUniformedCurves.empty() || ! vCrvStrip.empty()) {
|
||||
#if SAVEMKUNIF_CRVS
|
||||
//debug
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vGeo.clear() ;
|
||||
for( int i = 0 ; i < ssize( vUniformedCurves); ++i){
|
||||
vGeo.push_back(vUniformedCurves[i]->Clone()) ;
|
||||
}
|
||||
@@ -758,6 +822,20 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
ICRVCOMPOPOVECTOR vNewCrv ;
|
||||
int nCrvPrec = ssize( vUniformedCurves) ;
|
||||
while ( chainCrv.GetChainFromNear( ORIG, false, vIds)) {
|
||||
// se ho una solo curva piccola allora la salto
|
||||
if ( ssize(vIds) == 1) {
|
||||
double dLen = 0 ;
|
||||
int nId = vIds[0] - 1 ;
|
||||
bool bSkip = false ;
|
||||
if ( nId < nCrvPrec)
|
||||
bSkip = vUniformedCurves[nId]->GetLength( dLen) && dLen < dChainTol ;
|
||||
else
|
||||
bSkip = vCrvStrip[nId - ssize(vUniformedCurves)]->GetLength(dLen) && dLen < dChainTol ;
|
||||
|
||||
if ( bSkip)
|
||||
continue ;
|
||||
}
|
||||
|
||||
vNewCrv.emplace_back( CreateBasicCurveComposite()) ;
|
||||
for ( int nId : vIds) {
|
||||
nId -= 1 ;
|
||||
@@ -767,6 +845,16 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
vNewCrv.back()->AddCurve( Release( vCrvStrip[nId - ssize( vUniformedCurves)]), true, dChainTol) ;
|
||||
}
|
||||
}
|
||||
#if SAVEMKUNIF_CRVS
|
||||
//debug
|
||||
vGeo.clear() ;
|
||||
for( int i = 0 ; i < ssize( vNewCrv); ++i){
|
||||
vGeo.push_back(vNewCrv[i]->Clone()) ;
|
||||
}
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\bezier\\import3dm\\trim_error\\trim_crv_unif_AFTERchain.nge") ;
|
||||
//debug
|
||||
#endif
|
||||
|
||||
// aggiorno le curve
|
||||
vUniformedCurves.clear() ;
|
||||
vUniformedCurves.swap( vNewCrv) ;
|
||||
@@ -799,7 +887,7 @@ MakeUniform( ISurfFlatRegion*& pSfr, bool& bRescaled, const DBLVECTOR& vU0, cons
|
||||
|
||||
// controllo che tutte le curve siano chiuse, sennò vuol dire che ho perso qualche pezzo durante le intersezioni
|
||||
for ( int i = 0 ; i < ssize( vUniformedCurves); ++i) {
|
||||
if ( ! vUniformedCurves[i]->IsClosed())
|
||||
if ( ! vUniformedCurves[i]->IsClosed() && ! vUniformedCurves[i]->Close())
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
+1127
-259
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -148,11 +148,13 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool CreateByPointCurve( const Point3d& pt, const ICurve* pCurve) override ;
|
||||
bool CreateByTwoCurves( const ICurve* pCurve1, const ICurve* pCurve2, int nType) override ;
|
||||
bool CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez, bool bReduceToDeg3) override ;
|
||||
PNTVECTOR GetAllControlPoints( void) const ;
|
||||
PNTVECTOR GetAllControlPoints( void) const override ;
|
||||
bool GetAllPatchesIsocurves( bool bUorV, ICURVEPOVECTOR& vCrv) const ;
|
||||
bool CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, const BIPNTVECTOR& vCrv) ;
|
||||
bool RemoveCollapsedSpans( void) override ;
|
||||
bool SwapParameters( void) ;
|
||||
bool LimitSurfToTrimmedRegion( void) override ;
|
||||
bool CreateSmoothRuledByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, double dSampleLen) override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
|
||||
+188
-35
@@ -28,6 +28,13 @@
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
#define SAVECLASSCRV 0
|
||||
#define SAVEADJUSTCRV 0
|
||||
#if SAVECLASSCRV || SAVEADJUSTCRV
|
||||
std::vector<IGeoObj*> vGeo ;
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#endif
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -107,8 +114,20 @@ SurfFlatRegion::AddExtLoop( ICurve* pCrv)
|
||||
pMyCrv->SetThickness( 0) ;
|
||||
// rimuovo eventuali sovrapposizioni (calcolate nel suo piano)
|
||||
ICURVEPLIST CrvLst ;
|
||||
|
||||
#if SAVEADJUSTCRV
|
||||
SaveGeoObj( pMyCrv->Clone(), "D:\\Temp\\inters\\CrvCrvInters\\before_adjust.nge") ;
|
||||
#endif
|
||||
|
||||
if ( ! AdjustLoops( Release( pMyCrv), CrvLst, true))
|
||||
return false ;
|
||||
|
||||
#if SAVEADJUSTCRV
|
||||
for ( auto& pSingCrv : CrvLst)
|
||||
vGeo.push_back( pSingCrv->Clone()) ;
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\inters\\CrvCrvInters\\after_adjust.nge") ;
|
||||
#endif
|
||||
|
||||
// aggiungo le singole curve
|
||||
int nExtAdded = 0 ;
|
||||
bool bOk = true ;
|
||||
@@ -169,14 +188,18 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv, bool& bAdded)
|
||||
Vector3d vtExtr ;
|
||||
if ( pMyCrv->GetExtrusion( vtExtr) && ! vtExtr.IsSmall())
|
||||
pMyCrv->SetExtrusion( Z_AX) ;
|
||||
// verifico non abbia auto-intersezioni che si attraversano o si sovrappongano
|
||||
SelfIntersCurve sInt( *pMyCrv) ;
|
||||
if ( sInt.GetCrossOrOverlapIntersCount() > 0)
|
||||
return false ;
|
||||
|
||||
// verifico che sia esterna alle curve esterne degli altri chunk
|
||||
bool bOk = true ;
|
||||
CRVCVECTOR ccClass ;
|
||||
for ( auto i : m_vExtInd) {
|
||||
#if SAVEADJUSTCRV
|
||||
vGeo.clear() ;
|
||||
vGeo.push_back( pMyCrv->Clone()) ;
|
||||
vGeo.push_back( m_vpLoop[i]->Clone()) ;
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\inters\\CrvCrvInters\\during_add_simpleExt.nge") ;
|
||||
#endif
|
||||
|
||||
IntersCurveCurve ccInt( *pMyCrv, *m_vpLoop[i]) ;
|
||||
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
||||
! ccInt.GetCurveClassification( 0, EPS_SMALL, ccClass) ||
|
||||
@@ -216,14 +239,9 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv, bool& bAdded)
|
||||
bool
|
||||
SurfFlatRegion::MyAddExtLoop( ICurve* pCrv)
|
||||
{
|
||||
try {
|
||||
m_vpLoop.push_back( pCrv) ;
|
||||
m_vExtInd.push_back( int( m_vpLoop.size()) - 1) ;
|
||||
m_nStatus = OK ;
|
||||
}
|
||||
catch (...) {
|
||||
return false ;
|
||||
}
|
||||
m_vpLoop.push_back( pCrv) ;
|
||||
m_vExtInd.push_back( int( m_vpLoop.size()) - 1) ;
|
||||
m_nStatus = OK ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -304,10 +322,7 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
|
||||
// sistemo il senso di rotazione (deve essere CW -> se N==Z+ area < 0, se N==Z- area > 0)
|
||||
if ( ( plPlane.GetVersN().z > 0 && dArea > 0) || ( plPlane.GetVersN().z < 0 && dArea < 0))
|
||||
pMyCrv->Invert() ;
|
||||
// verifico non abbia auto-intersezioni
|
||||
SelfIntersCurve sInt( *pMyCrv) ;
|
||||
if ( sInt.GetCrossOrOverlapIntersCount() > 0)
|
||||
return false ;
|
||||
|
||||
// ricerca del chunk in cui andrebbe inserito
|
||||
int nChunk = -1 ;
|
||||
for ( int i = 0 ; i < int( m_vExtInd.size()) ; ++ i) {
|
||||
@@ -354,23 +369,18 @@ SurfFlatRegion::AddSimpleIntLoop( ICurve* pCrv)
|
||||
bool
|
||||
SurfFlatRegion::MyAddIntLoop( ICurve* pCrv, int nChunk)
|
||||
{
|
||||
try {
|
||||
// se da aggiungere all'ultimo chunk
|
||||
if ( nChunk == -1)
|
||||
m_vpLoop.push_back( pCrv) ;
|
||||
// altrimenti aggiungo al chunck indicato
|
||||
else {
|
||||
int nLoopCnt = GetLoopCount( nChunk) ;
|
||||
if ( nLoopCnt == 0)
|
||||
return false ;
|
||||
int nOffset = m_vExtInd[nChunk] + nLoopCnt ;
|
||||
m_vpLoop.insert( m_vpLoop.begin() + nOffset, pCrv) ;
|
||||
for ( int i = nChunk + 1 ; i < int( m_vExtInd.size()) ; ++ i)
|
||||
++ m_vExtInd[i] ;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
return false ;
|
||||
//se da aggiungere all'ultimo chunk
|
||||
if ( nChunk == -1)
|
||||
m_vpLoop.push_back( pCrv) ;
|
||||
//altrimenti aggiungo al chunck indicato
|
||||
else {
|
||||
int nLoopCnt = GetLoopCount( nChunk) ;
|
||||
if ( nLoopCnt == 0)
|
||||
return false ;
|
||||
int nOffset = m_vExtInd[nChunk] + nLoopCnt ;
|
||||
m_vpLoop.insert( m_vpLoop.begin() + nOffset, pCrv) ;
|
||||
for ( int i = nChunk + 1 ; i < int( m_vExtInd.size()) ; ++ i)
|
||||
++ m_vExtInd[i] ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -1374,6 +1384,15 @@ SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRV
|
||||
for ( int nLoop = 0 ; nLoop < GetLoopCount( nChunk) ; ++ nLoop) {
|
||||
const ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
|
||||
// intersezione
|
||||
|
||||
#if SAVECLASSCRV
|
||||
//debug
|
||||
vector<IGeoObj*> vGeo ;
|
||||
vGeo.push_back( Crv.Clone()) ;
|
||||
vGeo.push_back( pLoop->Clone()) ;
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\inters\\CrvCrvInters\\crv_and_loop.nge") ;
|
||||
#endif
|
||||
|
||||
IntersCurveCurve ccInt( Crv, *pLoop) ;
|
||||
// classificazione
|
||||
CRVCVECTOR ccPart ;
|
||||
@@ -1537,7 +1556,7 @@ SurfFlatRegion::GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion&
|
||||
// classifico il loop esterno del chunk della prima regione rispetto a quello del chunk della seconda
|
||||
IntersCurveCurve ccInt( *pCrv1Loc, *pCrv2Loc) ;
|
||||
int nClass = ccInt.GetRegionCurveClassification() ;
|
||||
switch ( nClass){
|
||||
switch ( nClass) {
|
||||
default : // CCREGC_NULL
|
||||
return REGC_NULL ;
|
||||
case CCREGC_IN1 :
|
||||
@@ -1550,7 +1569,141 @@ SurfFlatRegion::GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion&
|
||||
return REGC_OUT ;
|
||||
case CCREGC_INTERS :
|
||||
return REGC_INTERS ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfFlatRegion::CheckChunkInterference( int nChunk, const ISurfFlatRegion& Other, int nOthChunk, bool& bInterference) const
|
||||
{
|
||||
bInterference = false ;
|
||||
// verifico lo stato e il numero di chunk
|
||||
if ( m_nStatus != OK || m_vpLoop.empty() || nChunk >= GetChunkCount())
|
||||
return false ;
|
||||
// recupero rappresentazione base dell'altra regione
|
||||
const SurfFlatRegion& Reg2 = *GetBasicSurfFlatRegion( &Other) ;
|
||||
// verifico lo stato e il numero di chunk dell'altra regione
|
||||
if ( Reg2.m_nStatus != OK || Reg2.m_vpLoop.empty() || nOthChunk >= Reg2.GetChunkCount())
|
||||
return false ;
|
||||
|
||||
// verifico che le due regioni giacciano in piani paralleli
|
||||
if ( ! AreSameVectorApprox( m_frF.VersZ(), Reg2.m_frF.VersZ()))
|
||||
return false ;
|
||||
|
||||
// classifico il loop esterno del chunk della prima regione rispetto a quello del chunk della seconda
|
||||
int nClass = GetChunkSimpleClassification( nChunk, Other, nOthChunk) ;
|
||||
if ( nClass == REGC_NULL)
|
||||
return false ;
|
||||
// se le regioni non hanno isole, allora ho già identificato se i Chunks fanno interferenza
|
||||
int nLoopCnt = GetLoopCount( nChunk) ;
|
||||
int nOtherLoopCnt = Other.GetLoopCount( nOthChunk) ;
|
||||
if ( nLoopCnt == 1 && nOtherLoopCnt == 1) {
|
||||
bInterference = ( nClass != REGC_OUT) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// --- a prescindere dalle isole presenti nei 2 Chunks in esame :
|
||||
// se i due loop esterni si intersecano tra loro o sono gli stessi, allora fanno per forza interferenza
|
||||
if ( nClass == REGC_INTERS || nClass == CCREGC_SAME) {
|
||||
bInterference = true ;
|
||||
return true ;
|
||||
}
|
||||
// se invece sono esterni tra loro, allora non c'è interferenza
|
||||
else if ( nClass == REGC_OUT)
|
||||
return true ;
|
||||
// --- Analisi del loop interni :
|
||||
// se la curva esterna corrente è interna alla curva esterna dell'altro chunk
|
||||
else if ( nClass == REGC_IN1) {
|
||||
// se l'altro chunk non ha isole, c'è interferenza (a prescinere da numero di loop interni del primo chunk)
|
||||
if ( nOtherLoopCnt == 1) {
|
||||
bInterference = true ;
|
||||
return true ;
|
||||
}
|
||||
// curva esterna del chunk della prima regione (ovviamente già in locale al riferimento intrinseco)
|
||||
const ICurve* pCrv1Loc = GetMyLoop( nChunk, 0) ;
|
||||
// per ogni loop interno (isole)
|
||||
for ( int i = 1 ; i < nOtherLoopCnt ; ++ i) {
|
||||
const ICurve* pCrv2Loc = nullptr ;
|
||||
PtrOwner<ICurve> pCopyCrv ;
|
||||
if ( AreSameFrame( m_frF, Reg2.m_frF))
|
||||
pCrv2Loc = Reg2.GetMyLoop( nOthChunk, i) ;
|
||||
else {
|
||||
pCopyCrv.Set( Reg2.GetMyLoop( nOthChunk, i)->Clone()) ;
|
||||
if ( IsNull( pCopyCrv))
|
||||
return false ;
|
||||
pCopyCrv->LocToLoc( Reg2.m_frF, m_frF) ;
|
||||
pCrv2Loc = pCopyCrv ;
|
||||
}
|
||||
// classifico il loop esterno del chunk della prima regione rispetto all'interno corrente del chunk della seconda
|
||||
IntersCurveCurve ccInt( *pCrv1Loc, *pCrv2Loc) ;
|
||||
int nInternalClass = ccInt.GetRegionCurveClassification() ;
|
||||
// se le curve non sono classificabili, errore
|
||||
if ( nInternalClass == REGC_NULL)
|
||||
return false ;
|
||||
// se la curva di bordo corrente è interna (le isole girano al contrario) all'isola corrente
|
||||
else if ( nInternalClass == REGC_IN1)
|
||||
; // non faccio nulla, potrebbe non essere l'isola adatta per la classificazione
|
||||
// se la curva di bordo corrente è esterna (le isole girano al contrario) all'isola corrente, allora non ho interferenza
|
||||
else if ( nInternalClass == REGC_OUT)
|
||||
return true ;
|
||||
// se la curva di bordo corrente interseca l'isola o coincide con essa allora c'è interferenza
|
||||
else if ( nInternalClass == REGC_INTERS || nInternalClass == REGC_SAME) {
|
||||
bInterference = true ;
|
||||
return true ;
|
||||
}
|
||||
// negli altri casi ho un orientamento errato dei loop o delle regioni
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se la curva esterna dell'altro chunk è interna alla curva esterna corrente
|
||||
else if ( nClass == REGC_IN2) {
|
||||
// se l'altro chunk non ha isole, c'è interferenza
|
||||
if ( nLoopCnt == 1) {
|
||||
bInterference = true ;
|
||||
return true ;
|
||||
}
|
||||
// curva esterna del chunk della prima regione (ovviamente già in locale al riferimento intrinseco)
|
||||
const ICurve* pCrv2Loc = Reg2.GetMyLoop( nChunk, 0) ;
|
||||
// per ogni loop interno (isole)
|
||||
for ( int i = 1 ; i < nLoopCnt ; ++ i) {
|
||||
const ICurve* pCrv1Loc = nullptr ;
|
||||
PtrOwner<ICurve> pCopyCrv ;
|
||||
if ( AreSameFrame( Reg2.m_frF, m_frF))
|
||||
pCrv1Loc = GetMyLoop( nOthChunk, i) ;
|
||||
else {
|
||||
pCopyCrv.Set( GetMyLoop( nOthChunk, i)->Clone()) ;
|
||||
if ( IsNull( pCopyCrv))
|
||||
return false ;
|
||||
pCopyCrv->LocToLoc( m_frF, Reg2.m_frF) ;
|
||||
pCrv1Loc = pCopyCrv ;
|
||||
}
|
||||
// classifico il loop esterno del chunk della prima regione rispetto a quello del chunk della seconda
|
||||
IntersCurveCurve ccInt( *pCrv2Loc, *pCrv1Loc) ;
|
||||
int nInternalClass = ccInt.GetRegionCurveClassification() ;
|
||||
// se le curve non sono classificabili, errore
|
||||
if ( nInternalClass == REGC_NULL)
|
||||
return false ;
|
||||
// se la curva di bordo corrente è interna (le isole girano al contrario) all'isola corrente
|
||||
else if ( nInternalClass == REGC_IN1)
|
||||
; // non faccio nulla, potrebbe non essere l'isola adatta per la classificazione
|
||||
// se la curva di bordo corrente è esterna (le isole girano al contrario) all'isola corrente, allora non ho interferenza
|
||||
else if ( nInternalClass == REGC_OUT)
|
||||
return true ;
|
||||
// se la curva di bordo corrente interseca l'isola o coincide con essa allora c'è interferenza
|
||||
else if ( nInternalClass == REGC_INTERS || nInternalClass == REGC_SAME) {
|
||||
bInterference = true ;
|
||||
return true ;
|
||||
}
|
||||
// negli altri casi ho un orientamento errato dei loop o delle regioni
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// in questo la curva di bordo è interna ad ogni isola ma interna anche al loop esterno, quindi esiste interferenza
|
||||
bInterference = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -107,6 +107,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
bool GetChunkArea( int nChunk, double& dArea) const override ;
|
||||
bool GetChunkPerimeter( int nChunk, double& dLen) const override ;
|
||||
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
|
||||
bool CheckChunkInterference( int nChunk, const ISurfFlatRegion& Other, int nOthChunk, bool& bInterference) const override ; // compare alls
|
||||
bool GetChunkMaxOffset( int nChunk, double& dOffs) const override ;
|
||||
int GetLoopCount( int nChunk) const override ;
|
||||
int GetLoopCurveCount( int nChunk, int nLoop) const override ;
|
||||
@@ -139,6 +140,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
||||
SurfTriMesh* CalcAuxSurf( double dLinTol, double dAngTolDeg) const ;
|
||||
|
||||
friend class MyCAvSimpleSurfFrMove ;
|
||||
friend class MyCAvSurfFrMove ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
#define SAVELOOPS 0
|
||||
#if SAVELOOPS
|
||||
std::vector<IGeoObj*> vGeo ;
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#endif
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -172,6 +178,13 @@ SurfFlatRegion::Subtract( const ISurfFlatRegion& Other)
|
||||
pSfr.Set( new( nothrow) SurfFlatRegion) ;
|
||||
else
|
||||
pSfr.Set( MyNewSurfFromLoops( vpLoop)) ;
|
||||
|
||||
#if SAVELOOPS
|
||||
for (int i = 0 ; i < ssize( vpLoop) ; ++i)
|
||||
vGeo.push_back( vpLoop[i]) ;
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\inters\\CrvCrvInters\\NewLoops.nge") ;
|
||||
#endif
|
||||
|
||||
if ( IsNull( pSfr)) {
|
||||
MyTestAndDelete( vpCurve) ;
|
||||
MyTestAndDelete( vpLoop) ;
|
||||
|
||||
@@ -352,10 +352,6 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const Point3d& ptMin, const Point3d& pt
|
||||
}
|
||||
// se ho fatto solo 1 split orizzontale e ho due celle foglie nId = 0 e nId = 1
|
||||
if ( m_mTree.size() == 3 && ! m_mTree.at(-1).IsSplitVert()) {
|
||||
m_mTree[0].m_nLeft = -1 ;
|
||||
m_mTree[0].m_nRight = -1 ;
|
||||
m_mTree[1].m_nLeft = -1 ;
|
||||
m_mTree[1].m_nRight = -1 ;
|
||||
m_mTree[0].SetSplitDirVert( true) ;
|
||||
Split( 0) ;
|
||||
m_mTree[1].SetSplitDirVert( true) ;
|
||||
|
||||
+111
-2
@@ -284,6 +284,115 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Funzione per spezzare una curva compo in diversi tratti in corrispondenza
|
||||
// di cambi di direzione maggiori della tolleranza angolare passata
|
||||
static bool
|
||||
SplitCurveCompoByAngTol( const ICurveComposite* pCC, double dAngTol, ICRVCOMPOPOVECTOR& vCC)
|
||||
{
|
||||
int nCurves = pCC->GetCurveCount() ;
|
||||
vCC.emplace_back( CreateCurveComposite()) ;
|
||||
vCC.back()->AddCurve( pCC->GetCurve(0)->Clone()) ;
|
||||
// Cos della tolleranza angolare massima
|
||||
double dCosTol = cos( dAngTol * DEGTORAD) ;
|
||||
|
||||
for ( int nC = 0 ; nC < nCurves - 2; ++ nC) {
|
||||
// Recupero l'angolo tra la fine della curva corrente e l'inizio della successiva
|
||||
const ICurve* pCrvCurr = pCC->GetCurve( nC) ;
|
||||
const ICurve* pCrvNext = pCC->GetCurve( nC + 1) ;
|
||||
Vector3d vtCurrEnd ; pCrvCurr->GetEndDir( vtCurrEnd) ;
|
||||
Vector3d vtNextStart ; pCrvNext->GetStartDir( vtNextStart) ;
|
||||
// Calcolo il Coseno tra i due versori
|
||||
double dCos = vtCurrEnd * vtNextStart ;
|
||||
// Se dentro alla tolleranza, allora i punti apparterranno alla stessa curva
|
||||
if ( dCos > dCosTol) {
|
||||
// Aggiungo la curva
|
||||
vCC.back()->AddCurve( pCrvNext->Clone()) ;
|
||||
}
|
||||
// Se tratto al di fuori della tolleranza, devo definire una nuova curva
|
||||
else {
|
||||
vCC.emplace_back( CreateCurveComposite()) ;
|
||||
vCC.back()->AddCurve( pCrvNext->Clone()) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Se curva originale chiusa
|
||||
if ( pCC->IsClosed() && ssize( vCC) > 1) {
|
||||
// Se ho più tratti, potrei riunire il primo con l'ultimo
|
||||
const ICurve* pCrvFirst = pCC->GetCurve( 0) ;
|
||||
const ICurve* pCrvLast = pCC->GetCurve( nCurves - 1) ;
|
||||
Vector3d vtFirstStart ; pCrvFirst->GetEndDir( vtFirstStart) ;
|
||||
Vector3d vtLastEnd ; pCrvLast->GetStartDir( vtLastEnd) ;
|
||||
// Calcolo il Coseno tra i due versori
|
||||
double dCos = vtFirstStart * vtLastEnd ;
|
||||
// Se dentro alla tolleranza, allora i punti appartengono alla stessa curva
|
||||
if ( dCos > dCosTol) {
|
||||
// Aggiungo la curva
|
||||
vCC.back()->AddCurve( Release( vCC.front())) ;
|
||||
vCC.erase( vCC.begin()) ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
////-----------------------------------------------------------------------------
|
||||
//// Funzione che approssima la curva di bordo per la costruzione della Bezier Ruled mediante
|
||||
//// Patches di curve di Bezier
|
||||
//static bool
|
||||
//ApproxBorder( ICurveComposite* pCrvCompo, double dLinTol, double dAngTol, double dAngTolSplit)
|
||||
//{
|
||||
// // N.B.:in futuro bisognerebbe fare l'approssimazione direttamente con le bezier.
|
||||
//
|
||||
// // Controllo dei parametri
|
||||
// if ( pCrvCompo == nullptr || ! pCrvCompo->IsValid())
|
||||
// return false ;
|
||||
//
|
||||
// // splitto la curva considerando la tolleranza angolare
|
||||
// ICRVCOMPOPOVECTOR vCC ;
|
||||
// SplitCurveCompoByAngTol( pCrvCompo, dAngTolSplit, vCC) ;
|
||||
// #if DEBUG_BEZIER_INTERP
|
||||
// VT.clear() ;
|
||||
// for( int i = 0 ; i < ssize(vCC) ; ++i)
|
||||
// VT.push_back( vCC[i]->Clone()) ;
|
||||
// SaveGeoObj( VT, "D:\\Temp\\trimming\\AngBorderApprox.nge") ;
|
||||
// VT.clear() ;
|
||||
// #endif
|
||||
//
|
||||
// pCrvCompo->Clear() ;
|
||||
//
|
||||
// // Ogni PolyLine ricavata viene approssimata con un tratto di Bezier
|
||||
// const double MAXLEN = 1.5 ;
|
||||
// for ( ICurveComposite* pCC : vCC) {
|
||||
// // Se meno di due curve, non la considero ( non dovrebbe mai capitare )
|
||||
// if ( pCC->GetCurveCount() < 2)
|
||||
// continue ;
|
||||
// PolyArc PA ;
|
||||
// if ( ! pCC->ApproxWithArcs( dLinTol, dAngTol, PA))
|
||||
// return false ;
|
||||
// CurveComposite CrvTemp ;
|
||||
// if ( ! CrvTemp.FromPolyArc( PA) || ! CrvTemp.MergeCurves( dLinTol, dAngTol))
|
||||
// return false ;
|
||||
// #if DEBUG_BEZIER_INTERP
|
||||
// VT.emplace_back( CrvTemp->Clone()) ;
|
||||
// #endif
|
||||
// // Converto in Bezier
|
||||
// PtrOwner<ICurve> pCrvBz( CurveToBezierCurve( &CrvTemp)) ;
|
||||
// if ( IsNull( pCrvBz) || ! pCrvBz->IsValid()) {
|
||||
// LOG_ERROR( GetEGkLogger(), "Error : converrting curve to bezier") ;
|
||||
// return false ;
|
||||
// }
|
||||
// // Aggiungo il tratto approssimato alla curva finale complessiva
|
||||
// if ( ! pCrvCompo->AddCurve( Release( pCrvBz)))
|
||||
// return false ;
|
||||
// }
|
||||
// #if DEBUG_BEZIER_INTERP
|
||||
// SaveGeoObj( VT, VC, "D:\\Temp\\trimming\\bezier_edge.nge") ;
|
||||
// #endif
|
||||
//
|
||||
// return ( pCrvCompo->IsValid()) ;
|
||||
//}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Funzione che approssima la curva di bordo per la costruzione della Bezier Ruled mediante
|
||||
// Patches di curve di Bezier
|
||||
@@ -4110,7 +4219,7 @@ GetTrimmingRuledBezier( const CISURFPVECTOR& vSurf, const ICurve* pCrvEdge1,
|
||||
|
||||
// Se non ho punti di controllo forzati
|
||||
if ( vSyncPoints.empty()) {
|
||||
pSurfBz.Set( GetSurfBezierRuled( pCompoEdge1, pCompoEdge2, ISurfBezier::RLT_B_MINDIST_PLUS, dMyLinTol)) ;
|
||||
pSurfBz.Set( GetSurfBezierRuledSmooth( pCompoEdge1, pCompoEdge2, 10)) ;
|
||||
if ( IsNull( pSurfBz) || ! pSurfBz->IsValid()) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in Trimming : Ruled Bezier invalid") ;
|
||||
return nullptr ;
|
||||
@@ -4746,7 +4855,7 @@ GetTrimmingHoleBorders( const CISURFPVECTOR& vpSurf, const Point3d& ptRef, doubl
|
||||
// Scorro le curve successive
|
||||
for ( int j = i + 1 ; nIndJ == -1 && j < ssize( vHoles) ; ++ j) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
if ( IsNull( vHoles[j].pCompoHole))
|
||||
continue ;
|
||||
// Se il tipo è differente non possono essere in coppia
|
||||
if ( vHoles[i].nType != vHoles[j].nType)
|
||||
|
||||
+253
-49
@@ -29,8 +29,21 @@
|
||||
#include <thread>
|
||||
#include <future>
|
||||
|
||||
#define DEBUG_REMOVE_FINS 0
|
||||
#if DEBUG_REMOVE_FINS
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
std::vector<IGeoObj*> VT ;
|
||||
std::vector<Color> VC ;
|
||||
#endif
|
||||
|
||||
using namespace std ;
|
||||
|
||||
#if !defined(_WIN64)
|
||||
int VolZmap::m_nDexelNbr = 0 ;
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GEOOBJ_REGISTER( VOL_ZMAP, NGE_V_ZMP, VolZmap) ;
|
||||
|
||||
@@ -55,6 +68,13 @@ VolZmap::VolZmap(void)
|
||||
//----------------------------------------------------------------------------
|
||||
VolZmap::~VolZmap( void)
|
||||
{
|
||||
// Se versione 32-bit aggiorno il numero di Dexel complessivi rimuovendo il numero dei correnti
|
||||
#if !defined(_WIN64)
|
||||
int nDexelNbr = 0 ;
|
||||
for ( int i = 0 ; i < ssize( m_nDim) ; ++ i)
|
||||
nDexelNbr += m_nDim[i] ;
|
||||
m_nDexelNbr = max( 0, m_nDexelNbr - nDexelNbr) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -75,6 +95,13 @@ VolZmap::Clear( void)
|
||||
m_nNumBlock = 0 ;
|
||||
m_nConnectedCompoCount = 0 ;
|
||||
m_MapFrame.Reset() ;
|
||||
// Se versione 32-bit aggiorno il numero di Dexel complessivi rimuovendo il numero dei correnti
|
||||
#if !defined(_WIN64)
|
||||
int nDexelNbr = 0 ;
|
||||
for ( int i = 0 ; i < ssize( m_nDim) ; ++ i)
|
||||
nDexelNbr += m_nDim[i] ;
|
||||
m_nDexelNbr = max( 0, m_nDexelNbr - nDexelNbr) ;
|
||||
#endif
|
||||
for ( int i = 0 ; i < N_MAPS ; ++ i) {
|
||||
m_nNx[i] = 0 ;
|
||||
m_nNy[i] = 0 ;
|
||||
@@ -1694,16 +1721,15 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// creo lo ZMap per i riferimenti degli intervalli sulle griglie
|
||||
// Creo lo ZMap per i riferimenti degli intervalli sulle griglie
|
||||
PtrOwner<VolZmap> pZMapCopy( CloneBasicVolZmap( this)) ;
|
||||
if ( IsNull( pZMapCopy) || ! pZMapCopy->IsValid())
|
||||
return false ;
|
||||
|
||||
// creo uno ZMap per gli intervalli da aggiungere o da rimuovere
|
||||
// Creo uno ZMap per gli intervalli da aggiungere o da rimuovere
|
||||
PtrOwner<VolZmap> pZMapExtra( CreateBasicVolZmap()) ;
|
||||
if ( IsNull( pZMapExtra) ||
|
||||
! pZMapExtra->CreateEmpty( m_MapFrame.Orig(), m_dMaxZ[1] - m_dMinZ[1],
|
||||
m_dMaxZ[2] - m_dMinZ[2], m_dMaxZ[0] - m_dMinZ[0],
|
||||
! pZMapExtra->CreateEmpty( m_MapFrame.Orig(), m_dMaxZ[1] - m_dMinZ[1], m_dMaxZ[2] - m_dMinZ[2], m_dMaxZ[0] - m_dMinZ[0],
|
||||
m_dStep, IsTriDexel()))
|
||||
return false ;
|
||||
|
||||
@@ -1719,7 +1745,7 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
// Ciclo sulle griglie
|
||||
for ( int nGrid = 0 ; nGrid < pZMapCopy->m_nMapNum ; ++ nGrid) {
|
||||
// Ciclo sul numero di dexel presenti nella Copia
|
||||
for ( int nDex = 0 ; nDex < int( pZMapCopy->m_Values[nGrid].size()) ; ++ nDex) {
|
||||
for ( int nDex = 0 ; nDex < ssize( pZMapCopy->m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se il dexel corrente non ha sotto-intervalli passo al successivo
|
||||
if ( pZMapCopy->m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
@@ -1727,9 +1753,9 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
int nI = nDex % m_nNx[nGrid] ;
|
||||
int nJ = nDex / m_nNx[nGrid] ;
|
||||
// Recupero il numero di intervalli presenti nel Dexel corrente
|
||||
int nIntervals = int( pZMapCopy->m_Values[nGrid][nDex].size()) ;
|
||||
int nIntervals = ssize( pZMapCopy->m_Values[nGrid][nDex]) ;
|
||||
// Scorro gli intervalli presenti
|
||||
for ( int nInfo = 0 ; nInfo < int( pZMapCopy->m_Values[nGrid][nDex].size()) ; ++ nInfo) {
|
||||
for ( int nInfo = 0 ; nInfo < ssize( pZMapCopy->m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
// Recupero l'intervallo corrente
|
||||
Data& Interval = pZMapCopy->m_Values[nGrid][nDex][nInfo] ;
|
||||
// --- Se richiesta prima estensione
|
||||
@@ -1739,57 +1765,54 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
AddIntervals( nGrid, nI, nJ, Interval.dMin - dToler, Interval.dMin + dToler,
|
||||
Interval.vtMinN, Interval.vtMinN, nToolNum, true) ;
|
||||
// Se si sono uniti degli intervalli, potrei dover aggiungere degli spilloni nelle altre due direzioni
|
||||
if ( IsTriDexel() && nIntervals != int( m_Values[nGrid][nDex].size())) {
|
||||
if ( IsTriDexel() && nIntervals != ssize( m_Values[nGrid][nDex])) {
|
||||
// Aggiorno gli intervalli correnti ( dato che il corrente si è unito al precedente)
|
||||
// ( lascio invariato lo ZMapCopy)
|
||||
nIntervals = int( m_Values[nGrid][nDex].size()) ;
|
||||
nIntervals = ssize( m_Values[nGrid][nDex]) ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
pZMapCopy->m_Values[nGrid][nDex][nInfo-1].dMax,
|
||||
Interval.dMin, dToler, true,
|
||||
nToolNum, V_INVALID, V_INVALID) ;
|
||||
pZMapCopy->m_Values[nGrid][nDex][nInfo-1].dMax, Interval.dMin,
|
||||
dToler, true, nToolNum, V_INVALID, V_INVALID) ;
|
||||
}
|
||||
// *** Estremo superiore -> Intervallo : [ dMax - dToler, dMax + dToler ]
|
||||
// Aggiungo l'intervallo nello Zmap corrente ( lascio invariato lo ZMapCopy)
|
||||
AddIntervals( nGrid, nI, nJ, Interval.dMax - dToler, Interval.dMax + dToler,
|
||||
Interval.vtMaxN, Interval.vtMaxN, nToolNum, true) ;
|
||||
// Se si sono uniti degli intervalli, potrei dover aggiungere degli spilloni nelle altre due direzioni
|
||||
if ( IsTriDexel() && nIntervals != int( m_Values[nGrid][nDex].size())) {
|
||||
if ( IsTriDexel() && nIntervals != ssize( m_Values[nGrid][nDex])) {
|
||||
// Aggiorno gli intervalli correnti ( dato che il corrente si è unito al successivo)
|
||||
// ( lascio invariato lo ZMapCopy)
|
||||
nIntervals = int( m_Values[nGrid][nDex].size()) ;
|
||||
nIntervals = ssize( m_Values[nGrid][nDex]) ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
Interval.dMax,
|
||||
pZMapCopy->m_Values[nGrid][nDex][nInfo+1].dMin, dToler, true,
|
||||
nToolNum, V_INVALID, V_INVALID) ;
|
||||
Interval.dMax, pZMapCopy->m_Values[nGrid][nDex][nInfo+1].dMin,
|
||||
dToler, true, nToolNum, V_INVALID, V_INVALID) ;
|
||||
}
|
||||
}
|
||||
// --- Se richiesta prima restrizione
|
||||
else {
|
||||
// *** Estremo inferiore -> Intervallo : [ dMin - dToler, dMin + dToler ]
|
||||
// Sottraggo l'intervallo nello Zmap corrente ( lascio invariato lo ZMapCopy)
|
||||
SubtractIntervals( nGrid, nI, nJ, Interval.dMin - dToler, Interval.dMin + dToler,
|
||||
Interval.vtMinN, Interval.vtMinN, nToolNum, true) ;
|
||||
// Se l'intervallo si è annullato, potrei dover sottrarre degli spilloni nelle altre due direzioni
|
||||
if ( IsTriDexel() && nIntervals != int( m_Values[nGrid][nDex].size())) {
|
||||
// Aggiorno gli intervalli correnti ( lascio invariato lo ZMapCopy)
|
||||
nIntervals = int( m_Values[nGrid][nDex].size()) ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
Interval.dMin,
|
||||
Interval.dMax, dToler, true,
|
||||
Tool::UNDEF, V_INVALID, V_INVALID) ;
|
||||
// Se la lunghezza dell'intervallo non è almeno il doppio della tolleranza
|
||||
double dLen = Interval.dMax - Interval.dMin ;
|
||||
if ( dLen < 2. * ( dToler + EPS_SMALL)) {
|
||||
// L'intervallo sparisce completamente
|
||||
SubtractIntervals( nGrid, nI, nJ, Interval.dMin - EPS_SMALL, Interval.dMax + EPS_SMALL,
|
||||
Interval.vtMinN, Interval.vtMaxN, nToolNum, true) ;
|
||||
// Rimuovo le parti di spillone nelle altre dimensioni
|
||||
if ( IsTriDexel()) {
|
||||
-- nIntervals ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
Interval.dMin, Interval.dMax,
|
||||
dToler, true, Tool::UNDEF, V_INVALID, V_INVALID) ;
|
||||
}
|
||||
}
|
||||
// *** Estremo superiore -> Intervallo : [ dMax - dToler, dMax + dToler ]
|
||||
// Sottraggo l'intervallo nello Zmap corrente ( lascio invariato lo ZMapCopy)
|
||||
SubtractIntervals( nGrid, nI, nJ, Interval.dMax - dToler, Interval.dMax + dToler,
|
||||
Interval.vtMaxN, Interval.vtMaxN, nToolNum, true) ;
|
||||
// Se l'intervallo si è annullato, potrei dover sottrarre degli spilloni nelle altre due direzioni
|
||||
if ( IsTriDexel() && nIntervals != int( m_Values[nGrid][nDex].size())) {
|
||||
// Aggiorno gli intervalli correnti ( lascio invariato lo ZMapCopy)
|
||||
nIntervals = int( m_Values[nGrid][nDex].size()) ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
Interval.dMin,
|
||||
Interval.dMax, dToler, true,
|
||||
Tool::UNDEF, V_INVALID, V_INVALID) ;
|
||||
// Se sufficientemente lungo, allora
|
||||
else {
|
||||
// *** Estremo inferiore -> Intervallo : [ dMin, dMin + dToler ]
|
||||
// Sottraggo l'intervallo nello Zmap corrente ( lascio invariato lo ZMapCopy)
|
||||
SubtractIntervals( nGrid, nI, nJ, Interval.dMin - EPS_SMALL, Interval.dMin + dToler,
|
||||
Interval.vtMinN, Interval.vtMinN, nToolNum, true) ;
|
||||
// *** Estremo superiore -> Intervallo : [ dMax - dToler, dMax ]
|
||||
// Sottraggo l'intervallo nello Zmap corrente ( lascio invariato lo ZMapCopy)
|
||||
SubtractIntervals( nGrid, nI, nJ, Interval.dMax - dToler, Interval.dMax + EPS_SMALL,
|
||||
Interval.vtMaxN, Interval.vtMaxN, nToolNum, true) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1799,12 +1822,12 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
// Ciclo sulle griglie ( uso lo Zmap Corrente, lascio invariato pZMapCopy)
|
||||
for ( int nGrid = 0 ; nGrid < m_nMapNum ; ++ nGrid) {
|
||||
// Ciclo sul numero di dexel presenti
|
||||
for ( int nDex = 0 ; nDex < int( m_Values[nGrid].size()) ; ++ nDex) {
|
||||
for ( int nDex = 0 ; nDex < ssize( m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se l'intervallo è vuoto, non faccio nulla
|
||||
if ( m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// Per ogni intervallo ricavato fino ad ora, restringo della tolleranza
|
||||
for ( int nInfo = 0 ; nInfo < int( m_Values[nGrid][nDex].size()) ; ++ nInfo) {
|
||||
for ( int nInfo = 0 ; nInfo < ssize( m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
// --- Se richiesta prima estensione
|
||||
if ( bIsExtensionFirst) {
|
||||
m_Values[nGrid][nDex][nInfo].dMin += dToler ;
|
||||
@@ -1816,7 +1839,7 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
m_Values[nGrid][nDex][nInfo].dMax += dToler ;
|
||||
}
|
||||
// Definisco il colore
|
||||
for ( int nOrigInfo = 0 ; nOrigInfo < int( pZMapCopy->m_Values[nGrid][nDex].size()) ; ++ nOrigInfo) {
|
||||
for ( int nOrigInfo = 0 ; nOrigInfo < ssize( pZMapCopy->m_Values[nGrid][nDex]) ; ++ nOrigInfo) {
|
||||
if ( pZMapCopy->m_Values[nGrid][nDex][nOrigInfo].dMin - m_Values[nGrid][nDex][nInfo].dMin < EPS_SMALL)
|
||||
m_Values[nGrid][nDex][nInfo].nToolMin = pZMapCopy->m_Values[nGrid][nDex][nOrigInfo].nToolMin ;
|
||||
if ( pZMapCopy->m_Values[nGrid][nDex][nOrigInfo].dMax - m_Values[nGrid][nDex][nInfo].dMax < EPS_SMALL)
|
||||
@@ -1830,7 +1853,7 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
// Ciclo sulle griglie ( uso lo ZmapExtra, lascio invariato pZMapCopy)
|
||||
for ( int nGrid = 0 ; nGrid < pZMapExtra->m_nMapNum ; ++ nGrid) {
|
||||
// Ciclo sul numero di dexel presenti
|
||||
for ( int nDex = 0 ; nDex < int( pZMapExtra->m_Values[nGrid].size()) ; ++ nDex) {
|
||||
for ( int nDex = 0 ; nDex < ssize( pZMapExtra->m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se l'intervallo è vuoto, non faccio nulla
|
||||
if ( pZMapExtra->m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
@@ -1838,19 +1861,19 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
int nI = nDex % m_nNx[nGrid] ;
|
||||
int nJ = nDex / m_nNx[nGrid] ;
|
||||
// Per ogni intervallo ricavato fino ad ora...
|
||||
for ( int nInfo = 0 ; nInfo < int( pZMapExtra->m_Values[nGrid][nDex].size()) ; ++ nInfo) {
|
||||
for ( int nInfo = 0 ; nInfo < ssize( pZMapExtra->m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
double dMin = pZMapExtra->m_Values[nGrid][nDex][nInfo].dMin ;
|
||||
double dMax = pZMapExtra->m_Values[nGrid][nDex][nInfo].dMax ;
|
||||
Vector3d vtNMin = pZMapExtra->m_Values[nGrid][nDex][nInfo].vtMinN ;
|
||||
Vector3d vtNMax = pZMapExtra->m_Values[nGrid][nDex][nInfo].vtMaxN ;
|
||||
// --- Se richiesta prima estensione
|
||||
if ( bIsExtensionFirst) {
|
||||
// ... aggiungo i contributi
|
||||
AddIntervals( nGrid, nI, nJ, dMin, dMax, vtNMin, vtNMax, nToolNum, true) ;
|
||||
// Aggiungo i contributi
|
||||
AddIntervals( nGrid, nI, nJ, dMin, dMax, vtNMin, vtNMax, nToolNum, true) ;
|
||||
}
|
||||
// --- Se richiesta prima restrizione
|
||||
else {
|
||||
// ... sottraggo i contributi
|
||||
// Sottraggo i contributi
|
||||
SubtractIntervals( nGrid, nI, nJ, dMin, dMax, vtNMin, vtNMax, nToolNum, true) ;
|
||||
}
|
||||
}
|
||||
@@ -1868,6 +1891,187 @@ VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::RemoveFins( const Vector3d& vtDir, double dThick)
|
||||
{
|
||||
// Verifico la Validità dello ZMap
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// Per sicurezza normalizzo la direzione
|
||||
Vector3d vtMyDir = vtDir ;
|
||||
if ( ! vtMyDir.Normalize())
|
||||
return false ;
|
||||
double dMyThick = max( 10. * EPS_SMALL, dThick) ;
|
||||
|
||||
// Creo lo ZMap per i riferimenti degli intervalli sulle griglie
|
||||
PtrOwner<VolZmap> pZMapCopy( CloneBasicVolZmap( this)) ;
|
||||
if ( IsNull( pZMapCopy) || ! pZMapCopy->IsValid())
|
||||
return false ;
|
||||
|
||||
// Creo uno ZMap per gli intervalli da aggiungere e successivamente da rimuovere
|
||||
VolZmap ZMapExtra ;
|
||||
if ( ! ZMapExtra.CreateEmpty( m_MapFrame.Orig(), m_dMaxZ[1] - m_dMinZ[1], m_dMaxZ[2] - m_dMinZ[2], m_dMaxZ[0] - m_dMinZ[0],
|
||||
m_dStep, IsTriDexel()))
|
||||
return false ;
|
||||
|
||||
const double FIN_ANG_DEG_TOL = 55. ; // Approssimazione per eccesso dell'angolo massimo possibile tra una direzione generica
|
||||
// e un versore della terna globale ( arccos( 1 / sqrt( 3) ~ 54.375)
|
||||
const double COS_FIN_ANG_DEG_TOL = cos( FIN_ANG_DEG_TOL * DEGTORAD) ;
|
||||
const int NUM_TOOL = 1000 ; // Identificativo Utensile per riconoscere le parti rimosse
|
||||
|
||||
// NB. Tutti i parametri sono sempre presi dalla Copia dello ZMap corrente
|
||||
// Ciclo sulle griglie
|
||||
DBLVECTOR vdThicks ;
|
||||
if ( IsTriDexel())
|
||||
vdThicks = { dThick, dThick, dThick} ;
|
||||
else
|
||||
vdThicks = { dThick} ;
|
||||
for ( int nGrid = 0 ; nGrid < pZMapCopy->m_nMapNum ; ++ nGrid) {
|
||||
// Verifico se l'angolo tra la direzione degli spilloni della griglia corrente è sotto alla tolleranza rispetto alla direzione
|
||||
double dCosDir = ( nGrid == 0 ? vtMyDir.z :
|
||||
( nGrid == 1 ? vtMyDir.x :
|
||||
vtMyDir.y)) ;
|
||||
if ( abs( dCosDir) < COS_FIN_ANG_DEG_TOL + EPS_ANG_SMALL)
|
||||
continue ;
|
||||
// Aggiorno l'effettivo valore dello spessore da considerare
|
||||
double dCurrThick = dMyThick / abs( dCosDir) ; // (sicuramente esiste, essendo 55deg il limite)
|
||||
vdThicks[nGrid] = dCurrThick ;
|
||||
// Ciclo sul numero di dexel presenti nella Copia
|
||||
for ( int nDex = 0 ; nDex < ssize( pZMapCopy->m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se il dexel corrente non ha sotto-intervalli passo al successivo
|
||||
if ( pZMapCopy->m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// Indici del dexel
|
||||
int nI = nDex % m_nNx[nGrid] ;
|
||||
int nJ = nDex / m_nNx[nGrid] ;
|
||||
// Scorro gli intervalli presenti
|
||||
for ( int nInfo = 0 ; nInfo < ssize( pZMapCopy->m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
// Recupero l'intervallo corrente
|
||||
Data& Interval = pZMapCopy->m_Values[nGrid][nDex][nInfo] ;
|
||||
// Se entrambi gli estremi dell'intervallo non sono stati toccati dall'utensile, allora passo al successivo
|
||||
bool bAnalyze = ( ( Interval.nToolMin == 1 && Interval.nToolMax == 1) ||
|
||||
( Interval.dMax > m_dMaxZ[nGrid] - EPS_SMALL || Interval.dMin < m_dMinZ[nGrid] + EPS_SMALL)) ;
|
||||
if ( ! bAnalyze)
|
||||
continue ;
|
||||
// Se la lunghezza dell'intervallo è superiore allo spessore richiesto, non faccio nulla
|
||||
double dLen = Interval.dMax - Interval.dMin ;
|
||||
if ( dLen > dCurrThick + EPS_ZERO)
|
||||
continue ;
|
||||
// Se ZMap composto da una sola griglia, elimino il contributo lungo la direzione corrente
|
||||
if ( ! IsTriDexel()) {
|
||||
SubtractIntervals( nGrid, nI, nJ, Interval.dMin - EPS_SMALL, Interval.dMax + EPS_SMALL,
|
||||
- Interval.vtMinN, - Interval.vtMaxN, NUM_TOOL, true) ;
|
||||
}
|
||||
// Se Tridexel, aggiungo il contributo del cubetto corrente allo ZMap Extra
|
||||
else
|
||||
ZMapExtra.AddStripInterval( nGrid, nI, nJ, Interval.dMin - EPS_SMALL, Interval.dMax + EPS_SMALL, NUM_TOOL) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Se non ho aggiunto alcun elemento allo ZMap Extra, non devo fare nulla
|
||||
if ( ! ZMapExtra.IsValid())
|
||||
return true ;
|
||||
#if DEBUG_REMOVE_FINS
|
||||
SaveGeoObj( ZMapExtra.Clone(), "C:\\Temp\\VolZMapSubt0.nge") ;
|
||||
#endif
|
||||
|
||||
// Ciclo sulle griglie dello ZMap Extra
|
||||
for ( int nGrid = 0 ; nGrid < ZMapExtra.m_nMapNum ; ++ nGrid) {
|
||||
// Ciclo sul numero di dexel presenti
|
||||
for ( int nDex = 0 ; nDex < ssize( ZMapExtra.m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se l'intervallo è vuoto, non faccio nulla
|
||||
if ( ZMapExtra.m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// Indici del dexel
|
||||
int nI = nDex % m_nNx[nGrid] ;
|
||||
int nJ = nDex / m_nNx[nGrid] ;
|
||||
// Scorro i gli Intervalli dello Spillone corrente
|
||||
for ( int nInfo = 0 ; nInfo < ssize( ZMapExtra.m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
double dMin = ZMapExtra.m_Values[nGrid][nDex][nInfo].dMin ;
|
||||
double dMax = ZMapExtra.m_Values[nGrid][nDex][nInfo].dMax ;
|
||||
Vector3d vtNMin = ZMapExtra.m_Values[nGrid][nDex][nInfo].vtMinN ;
|
||||
Vector3d vtNMax = ZMapExtra.m_Values[nGrid][nDex][nInfo].vtMaxN ;
|
||||
// sottraggo tali contributi
|
||||
SubtractIntervals( nGrid, nI, nJ, dMin, dMax, - vtNMin, - vtNMax, NUM_TOOL, true) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! IsValid())
|
||||
return true ;
|
||||
#if DEBUG_REMOVE_FINS
|
||||
SaveGeoObj( this->Clone(), "C:\\Temp\\VolZMapSubt1.nge") ;
|
||||
#endif
|
||||
|
||||
// Sistemo le Normali sullo ZMap ricavato
|
||||
for ( int nGrid = 0 ; nGrid < m_nMapNum ; ++ nGrid) {
|
||||
// Ciclo sul numero di dexel presenti
|
||||
for ( int nDex = 0 ; nDex < ssize( m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se l'Intervallo è vuoto non faccio nulla
|
||||
if ( m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// Indici del dexel
|
||||
int nI = nDex % m_nNx[nGrid] ;
|
||||
int nJ = nDex / m_nNx[nGrid] ;
|
||||
// Scorro gli intervalli dello spillone corrente
|
||||
for ( int nInfo = 0 ; nInfo < ssize( m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
// Se intervallo con estremo minimo derivante dalla sottrazione con ZMapExtra, medio le normali
|
||||
int nToolMin = m_Values[nGrid][nDex][nInfo].nToolMin ;
|
||||
if ( nToolMin == NUM_TOOL) {
|
||||
// Recupero il valore minimo, se sul bordo dello ZMap corrente non faccio nulla
|
||||
double dMin = m_Values[nGrid][nDex][nInfo].dMin ;
|
||||
if ( dMin > m_dMinZ[nGrid] + EPS_SMALL) {
|
||||
Vector3d vtMinN = V_NULL ;
|
||||
double dZMin = INFINITO ;
|
||||
if ( ! pZMapCopy->ComputePointAndNormalForRemovingFins( nGrid, nI, nJ, dMin, vtMyDir, dThick, true, 1, vtMinN, dZMin)) {
|
||||
vtMinN = - ( nGrid == 0 ? m_MapFrame.VersZ() : nGrid == 1 ? m_MapFrame.VersX() : m_MapFrame.VersY()) ;
|
||||
dZMin = dMin ;
|
||||
}
|
||||
m_Values[nGrid][nDex][nInfo].vtMinN = vtMinN ;
|
||||
m_Values[nGrid][nDex][nInfo].dMin = dZMin ;
|
||||
}
|
||||
}
|
||||
// Se intervallo con estremo massimo derivante dalla sottrazione con ZMapExtra, medio le normali
|
||||
int nToolMax = m_Values[nGrid][nDex][nInfo].nToolMax ;
|
||||
if ( nToolMax == NUM_TOOL) {
|
||||
// Recupero il valore massimo, se sul bordo dello ZMap corrente non faccio nulla
|
||||
double dMax = m_Values[nGrid][nDex][nInfo].dMax ;
|
||||
if ( dMax < m_dMaxZ[nGrid] - EPS_SMALL) {
|
||||
Vector3d vtMaxN = V_NULL ;
|
||||
double dZMax = INFINITO ;
|
||||
if ( ! pZMapCopy->ComputePointAndNormalForRemovingFins( nGrid, nI, nJ, dMax, vtMyDir, dThick, false, 1, vtMaxN, dZMax)) {
|
||||
vtMaxN = ( nGrid == 0 ? m_MapFrame.VersZ() : nGrid == 1 ? m_MapFrame.VersX() : m_MapFrame.VersY()) ;
|
||||
dZMax = dMax ;
|
||||
}
|
||||
m_Values[nGrid][nDex][nInfo].vtMaxN = vtMaxN ;
|
||||
m_Values[nGrid][nDex][nInfo].dMax = dZMax ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Riassegno il Tool dell'utensile alle nuove parti
|
||||
for ( int nGrid = 0 ; nGrid < m_nMapNum ; ++ nGrid) {
|
||||
// Ciclo sul numero di dexel presenti
|
||||
for ( int nDex = 0 ; nDex < ssize( m_Values[nGrid]) ; ++ nDex) {
|
||||
// Se l'Intervallo è vuoto non faccio nulla
|
||||
if ( m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// Scorro gli intervalli dello spillone corrente
|
||||
for ( int nInfo = 0 ; nInfo < ssize( m_Values[nGrid][nDex]) ; ++ nInfo) {
|
||||
if ( m_Values[nGrid][nDex][nInfo].nToolMin == NUM_TOOL)
|
||||
m_Values[nGrid][nDex][nInfo].nToolMin = 1 ;
|
||||
if ( m_Values[nGrid][nDex][nInfo].nToolMax == NUM_TOOL)
|
||||
m_Values[nGrid][nDex][nInfo].nToolMax = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::SetToModifyDexelBlocks( int nGrid, int nDex, int nInt)
|
||||
|
||||
@@ -81,10 +81,10 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
public : // IVolZmap
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
bool Clear( void) override ;
|
||||
bool Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
||||
bool CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
||||
bool CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double dStep, bool bTriDex) override ;
|
||||
bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox = 0) override ;
|
||||
bool Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex, int* nError = nullptr) override ;
|
||||
bool CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex, int* nError = nullptr) override ;
|
||||
bool CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double dStep, bool bTriDex, int* nError = nullptr) override ;
|
||||
bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox = 0, int* nError = nullptr) override ;
|
||||
int GetBlockCount( void) const override ;
|
||||
int GetBlockUpdatingCounter( int nBlock) const override ;
|
||||
bool GetBlockTriangles( int nBlock, TRIA3DEXVECTOR& vTria) const override ;
|
||||
@@ -151,6 +151,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool AddSurfTm( const ISurfTriMesh* pStm) override ;
|
||||
bool SubtractSurfTm( const ISurfTriMesh* pStm) override ;
|
||||
bool MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum) override ;
|
||||
bool RemoveFins( const Vector3d& vtDir, double dThick) override ;
|
||||
bool Offset( double dOffs, int nType) override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
@@ -226,7 +227,16 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
typedef std::unordered_map<int, Voxel> VoxelContainer ;
|
||||
// Unordered map per la coerenza topologica
|
||||
typedef std::unordered_map<int, bool> InterVoxMatter ;
|
||||
|
||||
#if !defined(_WIN64)
|
||||
// Numero massimo approssimativo di Dexel per versione 32-bit per evitare Crash con memoria
|
||||
#if defined(_DEBUG)
|
||||
static const int MAX_DEXEL_32_BIT = 3000000 + 1 ;
|
||||
#else
|
||||
static const int MAX_DEXEL_32_BIT = 5000000 + 1 ;
|
||||
#endif
|
||||
static int m_nDexelNbr ; // numero corrente di Dexel presenti
|
||||
#endif
|
||||
|
||||
private :
|
||||
bool CopyFrom( const VolZmap& clSrc) ;
|
||||
bool ResetGraphics( void) ;
|
||||
@@ -262,6 +272,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool UniformIntervalsInVoxel( int nGrid, int nI, int nJ, double dZMin, double dZMax,
|
||||
double dToler, bool bAdd, int nToolNum, const Vector3d& vtToolMin,
|
||||
const Vector3d& vtToolMax) ;
|
||||
bool AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax, int nToolNum) ;
|
||||
bool ManageSubIntervalInVoxel( VolZmap* VolZmapRef, int nGrid, int nI, int nJ, int nK, double& dMin, double& dMax,
|
||||
Vector3d& vtMin, Vector3d& vtMax) ;
|
||||
// Spostamenti utensile
|
||||
@@ -486,6 +497,11 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
// Funzioni per Offset di Zmap
|
||||
bool OffsetFillet( double dOffs) ;
|
||||
bool OffsetSharped( double dOffs, int nType) ;
|
||||
// Funzione analisi punti/Normali per Alette
|
||||
bool GetLocalPoint( int nGrid, int nI, int nJ, double dZ, Point3d& ptLoc) ;
|
||||
bool ComputePointAndNormalForRemovingFins( int nGrid, int nI, int nJ, double dZ,
|
||||
const Vector3d& vtDir, double dThick, bool bMinVsMax, int nTool,
|
||||
Vector3d& vtN, double& dNewZ) ;
|
||||
|
||||
private :
|
||||
enum Move5Axis {
|
||||
|
||||
+79
-14
@@ -27,8 +27,8 @@ using namespace std ;
|
||||
// ------------------------- CREAZIONE MAPPA --------------------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex)
|
||||
bool
|
||||
VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex, int* nError)
|
||||
{
|
||||
// Controlli sull'ammissibilità delle dimensioni lineari del grezzo e del passo
|
||||
if ( dStep < EPS_SMALL || dDimX < EPS_SMALL || dDimY < EPS_SMALL || dDimZ < EPS_SMALL)
|
||||
@@ -51,7 +51,7 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
||||
m_nNx[0] = max( int( ( dDimX + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||
m_nNy[0] = max( int( ( dDimY + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||
|
||||
// Numero di componenti connesse
|
||||
// Numero di componenti connesse
|
||||
m_nConnectedCompoCount = 1 ;
|
||||
|
||||
// Se tridexel
|
||||
@@ -67,7 +67,7 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
||||
m_nNx[1] = 0 ;
|
||||
m_nNy[1] = 0 ;
|
||||
m_nNx[2] = 0 ;
|
||||
m_nNy[2] = 0 ;
|
||||
m_nNy[2] = 0 ;
|
||||
}
|
||||
|
||||
// Definisco il numero di blocchi lungo x,y e z
|
||||
@@ -81,12 +81,24 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i)
|
||||
m_nDim[i] = m_nNx[i] * m_nNy[i] ;
|
||||
|
||||
// Se versione 32-bit controllo di non superare il numero di Dexel massimo
|
||||
#if !defined(_WIN64)
|
||||
for ( int i = 0 ; i < ssize( m_nDim) ; ++ i)
|
||||
m_nDexelNbr += m_nDim[i] ;
|
||||
if ( m_nDexelNbr >= MAX_DEXEL_32_BIT) {
|
||||
Clear() ;
|
||||
if ( nError != nullptr)
|
||||
*nError = 1 ;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creazione delle celle per ogni mappa
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i)
|
||||
m_Values[i].resize( m_nDim[i]) ;
|
||||
|
||||
// Riempimento delle celle
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i)
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i) {
|
||||
for ( int j = 0 ; j < m_nDim[i] ; ++ j) {
|
||||
|
||||
// Aggiungo il tratto al dexel vuoto
|
||||
@@ -98,7 +110,7 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
||||
switch ( i) {
|
||||
case 0 :
|
||||
m_Values[i][j][0].vtMinN = - Z_AX ;
|
||||
m_Values[i][j][0].dMax = dDimZ ;
|
||||
m_Values[i][j][0].dMax = dDimZ ;
|
||||
m_Values[i][j][0].vtMaxN = Z_AX ;
|
||||
m_Values[i][j][0].nToolMax = 0 ;
|
||||
break ;
|
||||
@@ -113,9 +125,10 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
||||
m_Values[i][j][0].dMax = dDimY ;
|
||||
m_Values[i][j][0].vtMaxN = Y_AX ;
|
||||
m_Values[i][j][0].nToolMax = 0 ;
|
||||
break ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Definizione delle limitazioni iniziali in Z per ogni mappa
|
||||
m_dMinZ[0] = 0 ;
|
||||
@@ -136,7 +149,7 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex)
|
||||
VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex, int* nError)
|
||||
{
|
||||
// Controlli sull'ammissibilità delle dimensioni lineari del grezzo e del passo
|
||||
if ( dStep < EPS_SMALL || dDimX < EPS_SMALL || dDimY < EPS_SMALL || dDimZ < EPS_SMALL)
|
||||
@@ -187,6 +200,18 @@ VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDi
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i)
|
||||
m_nDim[i] = m_nNx[i] * m_nNy[i] ;
|
||||
|
||||
// Se versione 32-bit controllo di non superare il numero di Dexel massimo
|
||||
#if !defined(_WIN64)
|
||||
for ( int i = 0 ; i < ssize( m_nDim) ; ++ i)
|
||||
m_nDexelNbr += m_nDim[i] ;
|
||||
if ( m_nDexelNbr >= MAX_DEXEL_32_BIT) {
|
||||
Clear() ;
|
||||
if ( nError != nullptr)
|
||||
*nError = 1 ;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creazione delle celle per ogni mappa
|
||||
for ( int i = 0 ; i < m_nMapNum ; ++ i)
|
||||
m_Values[i].resize( m_nDim[i]) ;
|
||||
@@ -210,7 +235,7 @@ VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDi
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double dStep, bool bTriDex)
|
||||
VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double dStep, bool bTriDex, int* nError)
|
||||
{
|
||||
// Aggiorno la dimensione della mappa 1 o 3
|
||||
m_nMapNum = ( bTriDex ? 3 : 1) ;
|
||||
@@ -250,14 +275,35 @@ VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double
|
||||
m_nNx[1] = m_nNy[0] ;
|
||||
m_nNy[1] = int( ( dDimZ + EPS_SMALL) / m_dStep + 0.5) ;
|
||||
m_nDim[1] = m_nNx[1] * m_nNy[1] ;
|
||||
m_Values[1].resize( m_nDim[1]) ;
|
||||
m_nNx[2] = m_nNy[1] ;
|
||||
m_nNy[2] = m_nNx[0] ;
|
||||
m_nDim[2] = m_nNx[2] * m_nNy[2] ;
|
||||
// Se versione 32-bit controllo di non superare il numero di Dexel massimo
|
||||
#if !defined(_WIN64)
|
||||
for ( int i = 0 ; i < ssize( m_nDim) ; ++ i)
|
||||
m_nDexelNbr += m_nDim[i] ;
|
||||
if ( m_nDexelNbr >= MAX_DEXEL_32_BIT) {
|
||||
Clear() ;
|
||||
if ( nError != nullptr)
|
||||
*nError = 1 ;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
m_Values[1].resize( m_nDim[1]) ;
|
||||
m_Values[2].resize( m_nDim[2]) ;
|
||||
}
|
||||
|
||||
// Se dimensione singola
|
||||
else {
|
||||
// Se versione 32-bit controllo di non superare il numero di Dexel massimo
|
||||
#if !defined(_WIN64)
|
||||
m_nDexelNbr += m_nDim[0] ;
|
||||
if ( m_nDexelNbr >= MAX_DEXEL_32_BIT) {
|
||||
Clear() ;
|
||||
if ( nError != nullptr)
|
||||
*nError = 1 ;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
m_nNx[1] = 0 ;
|
||||
m_nNy[1] = 0 ;
|
||||
m_nDim[1] = 0 ;
|
||||
@@ -788,7 +834,7 @@ VolZmap::SubtractMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox)
|
||||
VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox, int* nError)
|
||||
{
|
||||
// Se la superficie non è chiusa oppure orientata al contrario non ha senso continuare
|
||||
double dVol ;
|
||||
@@ -838,14 +884,33 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
m_nNx[1] = m_nNy[0] ;
|
||||
m_nNy[1] = int( ( vtLen.z + EPS_SMALL) / m_dStep + 0.5) ;
|
||||
m_nDim[1] = m_nNx[1] * m_nNy[1] ;
|
||||
m_Values[1].resize( m_nDim[1]) ;
|
||||
m_nNx[2] = m_nNy[1] ;
|
||||
m_nNy[2] = m_nNx[0] ;
|
||||
m_nDim[2] = m_nNx[2] * m_nNy[2] ;
|
||||
#if !defined(_WIN64)
|
||||
for ( int i = 0 ; i < ssize( m_nDim) ; ++ i)
|
||||
m_nDexelNbr += m_nDim[i] ;
|
||||
if ( m_nDexelNbr >= MAX_DEXEL_32_BIT) {
|
||||
Clear() ;
|
||||
if ( nError != nullptr)
|
||||
*nError = 1 ;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
m_Values[1].resize( m_nDim[1]) ;
|
||||
m_Values[2].resize( m_nDim[2]) ;
|
||||
}
|
||||
|
||||
// Se a dimensione singola
|
||||
else {
|
||||
#if !defined(_WIN64)
|
||||
m_nDexelNbr += m_nDim[0] ;
|
||||
if ( m_nDexelNbr >= MAX_DEXEL_32_BIT) {
|
||||
Clear() ;
|
||||
if ( nError != nullptr)
|
||||
*nError = 1 ;
|
||||
return false ;
|
||||
}
|
||||
#endif
|
||||
m_nNx[1] = 0 ;
|
||||
m_nNy[1] = 0 ;
|
||||
m_nDim[1] = 0 ;
|
||||
|
||||
+404
-85
@@ -31,6 +31,13 @@
|
||||
#include <future>
|
||||
#include <numeric>
|
||||
|
||||
#define SAVETRIMMINGTOOL 0
|
||||
|
||||
#if SAVETRIMMINGTOOL
|
||||
std::vector<IGeoObj*> vGeo ;
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#endif
|
||||
|
||||
using namespace std ;
|
||||
|
||||
// ------------------------- OPERAZIONI SU INTERVALLI --------------------------------------------------------------------------------------
|
||||
@@ -838,6 +845,183 @@ VolZmap::UniformIntervalsInVoxel( int nGrid, int nI, int nJ, double dZMin,
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::AddStripInterval( int nGrid, int nI, int nJ, double dZMin, double dZMax, int nToolNum)
|
||||
{
|
||||
// Se non Tridex, esco
|
||||
if ( ! IsTriDexel())
|
||||
return true ;
|
||||
|
||||
// Controllo che il numero di griglia sia entro i limiti
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
|
||||
// Controllo che indici nI, nJ siano entro i limiti
|
||||
if ( nI < 0 && nI >= m_nNx[nGrid] && nJ < 0 && nJ >= m_nNy[nGrid])
|
||||
return false ;
|
||||
|
||||
// Numero di voxel contenuti nel dexel corrente ( uguale per ogni dexel di una specifica griglia)
|
||||
int nVoxNum = int( m_nNy[(( nGrid + 1) % 3)] / m_nDexVoxRatio +
|
||||
( m_nNy[(( nGrid + 1) % 3)] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
||||
|
||||
// Scorro i Voxel correnti
|
||||
for ( int nVox = - 1 ; nVox < nVoxNum - 1 ; ++ nVox) {
|
||||
// Considero solo i Voxel interni all'intervallo corrente
|
||||
if ( ( nVox + 1) * m_dStep > dZMin && ( nVox - 1) * m_dStep < dZMax) {
|
||||
// Recupero gli indici per la griglia successiva
|
||||
int nMyGrid = ( nGrid + 1) % 3 ;
|
||||
int nMyI = nJ ;
|
||||
int nMyJ = nVox ;
|
||||
int nMyK = nI ;
|
||||
double dMyMinZ = nMyK * m_dStep ;
|
||||
double dMyMaxZ = ( nMyK + 1) * m_dStep ;
|
||||
Vector3d vtMyMaxN = ( nMyGrid == 0 ? m_MapFrame.VersZ() :
|
||||
nMyGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY()) ;
|
||||
Vector3d vtMyMinN = - vtMyMaxN ;
|
||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMinZ - EPS_SMALL, dMyMaxZ + EPS_SMALL, vtMyMinN, vtMyMaxN, nToolNum, true) ;
|
||||
// Recupero gli indici della griglia precedente
|
||||
nMyGrid = ( nGrid + 2) % 3 ;
|
||||
nMyI = nVox ;
|
||||
nMyJ = nI ;
|
||||
nMyK = nJ ;
|
||||
dMyMinZ = nMyK * m_dStep ;
|
||||
dMyMaxZ = ( nMyK + 1) * m_dStep ;
|
||||
vtMyMaxN = ( nMyGrid == 0 ? m_MapFrame.VersZ() :
|
||||
nMyGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY()) ;
|
||||
vtMyMinN = - vtMyMaxN ;
|
||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMinZ - EPS_SMALL, dMyMaxZ + EPS_SMALL, vtMyMinN, vtMyMaxN, nToolNum, true) ;
|
||||
}
|
||||
}
|
||||
// Aggiungo l'intervallo corrente
|
||||
Vector3d vtMyMaxN = ( nGrid == 0 ? m_MapFrame.VersZ() :
|
||||
nGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY()) ;
|
||||
Vector3d vtMyMinN = - vtMyMaxN ;
|
||||
AddIntervals( nGrid, nI, nJ, dZMin, dZMax, vtMyMinN, vtMyMaxN, nToolNum, true) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::GetLocalPoint( int nGrid, int nI, int nJ, double dZ, Point3d& ptLoc)
|
||||
{
|
||||
// Verifico che lo ZMap corrente sia valido
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// Controllo che il numero di griglia sia entro i limiti
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
|
||||
// Controllo che indici nI, nJ siano entro i limiti
|
||||
if ( nI < 0 && nI >= m_nNx[nGrid] && nJ < 0 && nJ >= m_nNy[nGrid])
|
||||
return false ;
|
||||
|
||||
// Calcolo il punto
|
||||
ptLoc = m_MapFrame.Orig() ;
|
||||
if ( nGrid == 0)
|
||||
ptLoc += ( ( nI + 0.5) * m_dStep * m_MapFrame.VersX() + ( nJ + 0.5) * m_dStep * m_MapFrame.VersY() + dZ * m_MapFrame.VersZ()) ;
|
||||
else if ( nGrid == 1)
|
||||
ptLoc += ( ( nI + 0.5) * m_dStep * m_MapFrame.VersY() + ( nJ + 0.5) * m_dStep * m_MapFrame.VersZ() + dZ * m_MapFrame.VersX()) ;
|
||||
else
|
||||
ptLoc += ( ( nI + 0.5) * m_dStep * m_MapFrame.VersZ() + ( nJ + 0.5) * m_dStep * m_MapFrame.VersX() + dZ * m_MapFrame.VersY()) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::ComputePointAndNormalForRemovingFins( int nGrid, int nI, int nJ, double dZ,
|
||||
const Vector3d& vtDir, double dThick, bool bMinVsMax, int nTool,
|
||||
Vector3d& vtN, double& dNewZ)
|
||||
{
|
||||
// Verifico che lo ZMap corrente sia valido
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// Controllo che il numero di griglia sia entro i limiti
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
|
||||
// Inizializzo il vettore da restituire
|
||||
vtN = V_NULL ;
|
||||
dNewZ = INFINITO ;
|
||||
|
||||
// Proietto la direzione lungo la mappa della griglia corrente
|
||||
Vector3d vtDirProj = OrthoCompo( vtDir, ( nGrid == 0 ? m_MapFrame.VersZ() :
|
||||
nGrid == 1 ? m_MapFrame.VersX() :
|
||||
m_MapFrame.VersY())) ;
|
||||
// Sposto il punto corrente nella direzione opposta a quella trovata
|
||||
Point3d ptLoc ;
|
||||
if ( ! GetLocalPoint( nGrid, nI, nJ, dZ, ptLoc))
|
||||
return false ;
|
||||
Point3d ptCenterLoc = ptLoc ;
|
||||
ptCenterLoc.Translate( - vtDirProj * dThick) ;
|
||||
|
||||
// Recupero il Box nel punto
|
||||
BBox3d BBoxLoc ; BBoxLoc.Add( ptCenterLoc) ;
|
||||
double dExpandX = ( m_MapFrame.VersX() * X_AX) * dThick * ( vtDirProj * X_AX) ;
|
||||
double dExpandY = ( m_MapFrame.VersY() * Y_AX) * dThick * ( vtDirProj * Y_AX) ;
|
||||
double dExpandZ = ( m_MapFrame.VersZ() * Z_AX) * dThick * ( vtDirProj * Z_AX) ;
|
||||
BBoxLoc.Expand( max( ( m_dStep + EPS_SMALL), dExpandX),
|
||||
max( ( m_dStep + EPS_SMALL), dExpandY),
|
||||
max( ( m_dStep + EPS_SMALL), dExpandZ)) ;
|
||||
|
||||
// Porto il Box nel Frame della Mappa corrente
|
||||
BBox3d BBoxInGrid = GetToLoc( BBoxLoc, m_MapFrame) ;
|
||||
// Recupero i suoi estremi
|
||||
Point3d ptBoxLocMax = BBoxInGrid.GetMax() ;
|
||||
Point3d ptBoxLocMin = BBoxInGrid.GetMin() ;
|
||||
// Determino gli intervalli locali in X e Y locali alla Griglia correnti
|
||||
double dMinXLoc = ( nGrid == 0 ? ptBoxLocMin.x : nGrid == 1 ? ptBoxLocMin.y : ptBoxLocMin.z) ;
|
||||
double dMinYLoc = ( nGrid == 0 ? ptBoxLocMin.y : nGrid == 1 ? ptBoxLocMin.z : ptBoxLocMin.x) ;
|
||||
double dMaxXLoc = ( nGrid == 0 ? ptBoxLocMax.x : nGrid == 1 ? ptBoxLocMax.y : ptBoxLocMax.z) ;
|
||||
double dMaxYLoc = ( nGrid == 0 ? ptBoxLocMax.y : nGrid == 1 ? ptBoxLocMax.z : ptBoxLocMax.x) ;
|
||||
|
||||
// Recupero gli Spilloni coinvolti nel Box
|
||||
int nStartI = max( 0, int( dMinXLoc / m_dStep)) ;
|
||||
int nEndI = min( m_nNx[nGrid] - 1, int( dMaxXLoc / m_dStep)) ;
|
||||
int nStartJ = max( 0, int( dMinYLoc / m_dStep)) ;
|
||||
int nEndJ = min( m_nNy[nGrid] - 1, int( dMaxYLoc / m_dStep)) ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||
// Determino la posizione corrente dello Spillone
|
||||
int nPos = j * m_nNx[nGrid] + i ;
|
||||
vector<Data>& vDexel = m_Values[nGrid][nPos] ;
|
||||
// Scorro i suoi Intervalli
|
||||
for ( int nInterval = 0 ; nInterval < ssize( vDexel) ; ++ nInterval) {
|
||||
// Se l'Intervallo presenta un indice del Tool da evitare, passo al successivo
|
||||
if ( ( bMinVsMax && vDexel[nInterval].nToolMin != nTool) ||
|
||||
( ! bMinVsMax && vDexel[nInterval].nToolMax != nTool))
|
||||
continue ;
|
||||
// Recupero l'estremo da analizzare
|
||||
double dZInterval = ( bMinVsMax ? vDexel[nInterval].dMin : vDexel[nInterval].dMax) ;
|
||||
// Recupero il punto associato
|
||||
Point3d ptInterval ;
|
||||
if ( ! GetLocalPoint( nGrid, i, j, dZInterval, ptInterval))
|
||||
return false ;
|
||||
// Se il punto è dentro nel Box, aggiungo il contributo della normale presente
|
||||
if ( BBoxLoc.Encloses( ptInterval)) {
|
||||
double dCurrSqDist = ( SqDist( ptInterval, ptLoc)) ;
|
||||
if ( dCurrSqDist < dSqMinDist) {
|
||||
dSqMinDist = dCurrSqDist ;
|
||||
vtN = ( bMinVsMax ? vDexel[nInterval].vtMinN : vDexel[nInterval].vtMaxN) ;
|
||||
dNewZ = dZInterval ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ( ! vtN.IsSmall() && dZ < INFINITO - 1) ;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------- BOUNDING BOX --------------------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1569,10 +1753,6 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
else if ( n5AxisType == Move5Axis::ACROSS)
|
||||
nTotSurf = 2 + nSub * 4 + nSub * 2 + 16 ; // come sopra
|
||||
|
||||
int nSurfInd = 0 ;
|
||||
vector<SurfBezForInters> vSurfBez( nTotSurf) ;
|
||||
double dSide = 0 ;
|
||||
|
||||
// punti di riferimento sul tool
|
||||
// tip del tool
|
||||
Point3d ptP1T ;
|
||||
@@ -1585,6 +1765,15 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
Vector3d vtDirTip = ptP2T - ptP1T ;
|
||||
bool bTopIsPivot = vtDirTop.IsSmall() ;
|
||||
bool bTipIsPivot = vtDirTip.IsSmall() ;
|
||||
bool bSmallMovement = vtDirTop.Len() < 10 * EPS_SMALL && vtDirTip.Len() < 10 * EPS_SMALL ;
|
||||
bool bInverse = ! (bTopIsPivot || bTipIsPivot) && vtDirTop * vtDirTip < 0 ;
|
||||
|
||||
if ( bInverse)
|
||||
nTotSurf += 4 ;
|
||||
|
||||
int nSurfInd = 0 ;
|
||||
vector<SurfBezForInters> vSurfBez( nTotSurf) ;
|
||||
double dSide = 0 ;
|
||||
|
||||
// box dell'intero volume spazzato, nel riferimento object oriented
|
||||
BBox3d bbVol ;
|
||||
@@ -1617,10 +1806,10 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
dSide = ( ptRefEnd - ptRefStart) * vtLs ;
|
||||
|
||||
// calcolo anche i vettori per le basi inferiori
|
||||
Vector3d vtTipBaseStart = -( vtLs ^ vtDirTip) ;
|
||||
Vector3d vtTipBaseStart = bInverse ? ( vtLs ^ vtDirTip) : -( vtLs ^ vtDirTip) ;
|
||||
vtTipBaseStart.Normalize() ;
|
||||
vtTipBaseStart *= dMinRad ;
|
||||
Vector3d vtTipBaseEnd = -( vtLe ^ vtDirTip) ;
|
||||
Vector3d vtTipBaseEnd = bInverse ? ( vtLe ^ vtDirTip) : -( vtLe ^ vtDirTip) ;
|
||||
vtTipBaseEnd.Normalize() ;
|
||||
vtTipBaseEnd *= dMinRad ;
|
||||
// aggiungo il primo punto per ognuno dei gruppi
|
||||
@@ -1669,22 +1858,44 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
}
|
||||
|
||||
vector<PNTVECTOR> vvPtCtrl ;
|
||||
// superficie laterale sinistra
|
||||
CurveLine cLineLeftStart ; cLineLeftStart.Set( vPntTipStartFront.back(), vPntTopStartFront.back()) ;
|
||||
PtrOwner<CurveBezier> cBezLeftStart( GetBasicCurveBezier( LineToBezierCurve( &cLineLeftStart, nDegU, bRat))) ;
|
||||
CurveLine cLineLeftEnd ; cLineLeftEnd.Set( vPntTipEndFront.back(), vPntTopEndFront.back()) ;
|
||||
PtrOwner<CurveBezier> cBezLeftEnd( GetBasicCurveBezier( LineToBezierCurve( &cLineLeftEnd, nDegU, bRat))) ;
|
||||
vvPtCtrl.emplace_back( cBezLeftStart->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntLeft = cBezLeftEnd->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntLeft.begin(), vPntLeft.end()) ;
|
||||
// superficie laterale destra
|
||||
CurveLine cLineRightStart ; cLineRightStart.Set( vPntTopStartFront.front(), vPntTipStartFront.front()) ;
|
||||
PtrOwner<CurveBezier> cBezRightStart( GetBasicCurveBezier( LineToBezierCurve( &cLineRightStart, nDegU, bRat))) ;
|
||||
CurveLine cLineRightEnd ; cLineRightEnd.Set( vPntTopEndFront.front(), vPntTipEndFront.front()) ;
|
||||
PtrOwner<CurveBezier> cBezRightEnd( GetBasicCurveBezier( LineToBezierCurve( &cLineRightEnd, nDegU, bRat))) ;
|
||||
vvPtCtrl.emplace_back( cBezRightStart->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntRight = cBezRightEnd->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntRight.begin(), vPntRight.end()) ;
|
||||
if ( ! bSmallMovement) {
|
||||
// superficie laterale sinistra
|
||||
CurveLine cLineLeftBottom ; cLineLeftBottom.Set( vPntTipEndFront.back(), vPntTipStartFront.back()) ;
|
||||
if ( ! cLineLeftBottom.IsValid())
|
||||
return false ;
|
||||
if ( bInverse)
|
||||
cLineLeftBottom.Invert() ;
|
||||
PtrOwner<CurveBezier> cBezLeftBottom( GetBasicCurveBezier( LineToBezierCurve( &cLineLeftBottom, nDegU, bRat))) ;
|
||||
if ( IsNull( cBezLeftBottom))
|
||||
return false ;
|
||||
CurveLine cLineLeftTop ; cLineLeftTop.Set( vPntTopEndFront.back(), vPntTopStartFront.back()) ;
|
||||
if ( ! cLineLeftTop.IsValid())
|
||||
return false ;
|
||||
PtrOwner<CurveBezier> cBezLeftTop( GetBasicCurveBezier( LineToBezierCurve( &cLineLeftTop, nDegU, bRat))) ;
|
||||
if ( IsNull( cBezLeftTop))
|
||||
return false ;
|
||||
vvPtCtrl.emplace_back( cBezLeftBottom->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntLeft = cBezLeftTop->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntLeft.begin(), vPntLeft.end()) ;
|
||||
// superficie laterale destra
|
||||
CurveLine cLineRightBottom ; cLineRightBottom.Set( vPntTipStartFront.front(), vPntTipEndFront.front()) ;
|
||||
if ( ! cLineRightBottom.IsValid())
|
||||
return false ;
|
||||
if ( bInverse)
|
||||
cLineRightBottom.Invert() ;
|
||||
PtrOwner<CurveBezier> cBezRightBottom( GetBasicCurveBezier( LineToBezierCurve( &cLineRightBottom, nDegU, bRat))) ;
|
||||
if ( IsNull( cBezRightBottom))
|
||||
return false ;
|
||||
CurveLine cLineRightTop ; cLineRightTop.Set( vPntTopStartFront.front(), vPntTopEndFront.front()) ;
|
||||
if ( ! cLineRightTop.IsValid())
|
||||
return false ;
|
||||
PtrOwner<CurveBezier> cBezRightTop( GetBasicCurveBezier( LineToBezierCurve( &cLineRightTop, nDegU, bRat))) ;
|
||||
if ( IsNull( cBezRightTop))
|
||||
return false ;
|
||||
vvPtCtrl.emplace_back( cBezRightBottom->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntRight = cBezRightTop->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntRight.begin(), vPntRight.end()) ;
|
||||
}
|
||||
if ( nSub == 1) {
|
||||
// superficie inferiore
|
||||
vvPtCtrl.emplace_back( PNTVECTOR( { vPntTipStartFront.front(), vPntTipStartFront.back(), vPntTipEndFront.front(), vPntTipEndFront.back() })) ;
|
||||
@@ -1748,43 +1959,83 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
if ( ! bTipIsPivot) {
|
||||
// inferiori
|
||||
if ( dSide > 0) {
|
||||
vvPtCtrl.emplace_back(cBezTipStartF1->GetAllControlPoints());
|
||||
PNTVECTOR vPntTipEnd1 = cBezTipEndF1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTipEnd1.begin(), vPntTipEnd1.end());
|
||||
vvPtCtrl.emplace_back(cBezTipStartF2->GetAllControlPoints());
|
||||
PNTVECTOR vPntTipEnd2 = cBezTipEndF2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTipEnd2.begin(), vPntTipEnd2.end());
|
||||
PNTVECTOR vPntTipEnd01 = cBezTipStartF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTipEnd01.begin(), vPntTipEnd01.end()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTipEnd01.rbegin(), vPntTipEnd01.rend()) ;
|
||||
PNTVECTOR vPntTipEnd1 = cBezTipEndF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd1.begin(), vPntTipEnd1.end()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd1.rbegin(), vPntTipEnd1.rend()) ;
|
||||
PNTVECTOR vPntTipEnd02 = cBezTipStartF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTipEnd02.begin(), vPntTipEnd02.end()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTipEnd02.rbegin(), vPntTipEnd02.rend()) ;
|
||||
PNTVECTOR vPntTipEnd2 = cBezTipEndF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd2.begin(), vPntTipEnd2.end()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd2.rbegin(), vPntTipEnd2.rend()) ;
|
||||
}
|
||||
else {
|
||||
PNTVECTOR vPntTipEnd01 = cBezTipStartB1->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTipEnd01.rbegin(), vPntTipEnd01.rend());
|
||||
PNTVECTOR vPntTipEnd1 = cBezTipEndB1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTipEnd1.rbegin(), vPntTipEnd1.rend());
|
||||
PNTVECTOR vPntTipEnd02 = cBezTipStartB2->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTipEnd02.rbegin(), vPntTipEnd02.rend());
|
||||
PNTVECTOR vPntTipEnd2 = cBezTipEndB2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTipEnd2.rbegin(), vPntTipEnd2.rend());
|
||||
PNTVECTOR vPntTipEnd01 = cBezTipStartB1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTipEnd01.rbegin(), vPntTipEnd01.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTipEnd01.begin(), vPntTipEnd01.end()) ;
|
||||
PNTVECTOR vPntTipEnd1 = cBezTipEndB1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd1.rbegin(), vPntTipEnd1.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd1.begin(), vPntTipEnd1.end()) ;
|
||||
PNTVECTOR vPntTipEnd02 = cBezTipStartB2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTipEnd02.rbegin(), vPntTipEnd02.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTipEnd02.begin(), vPntTipEnd02.end()) ;
|
||||
PNTVECTOR vPntTipEnd2 = cBezTipEndB2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd2.rbegin(), vPntTipEnd2.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTipEnd2.begin(), vPntTipEnd2.end()) ;
|
||||
}
|
||||
}
|
||||
if ( ! bTopIsPivot) {
|
||||
// superiori
|
||||
if ( dSide > 0) {
|
||||
vvPtCtrl.emplace_back(cBezTopStartB1->GetAllControlPoints());
|
||||
PNTVECTOR vPntTopEnd1 = cBezTopEndB1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTopEnd1.begin(), vPntTopEnd1.end());
|
||||
vvPtCtrl.emplace_back(cBezTopStartB2->GetAllControlPoints());
|
||||
PNTVECTOR vPntTopEnd2 = cBezTopEndB2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTopEnd2.begin(), vPntTopEnd2.end());
|
||||
PNTVECTOR vPntTopEnd01 = cBezTopStartB1->GetAllControlPoints() ;
|
||||
vvPtCtrl.emplace_back( vPntTopEnd01.begin(), vPntTopEnd01.end()) ;
|
||||
PNTVECTOR vPntTopEnd1 = cBezTopEndB1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd1.begin(), vPntTopEnd1.end()) ;
|
||||
PNTVECTOR vPntTopEnd02 = cBezTopStartB2->GetAllControlPoints() ;
|
||||
vvPtCtrl.emplace_back( vPntTopEnd02.begin(), vPntTopEnd02.end()) ;
|
||||
PNTVECTOR vPntTopEnd2 = cBezTopEndB2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd2.begin(), vPntTopEnd2.end()) ;
|
||||
}
|
||||
else {
|
||||
PNTVECTOR vPntTopEnd01 = cBezTopStartF1->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTopEnd01.rbegin(), vPntTopEnd01.rend());
|
||||
PNTVECTOR vPntTopEnd1 = cBezTopEndF1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTopEnd1.rbegin(), vPntTopEnd1.rend());
|
||||
PNTVECTOR vPntTopEnd02 = cBezTopStartF2->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTopEnd02.rbegin(), vPntTopEnd02.rend());
|
||||
PNTVECTOR vPntTopEnd2 = cBezTopEndF2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTopEnd2.rbegin(), vPntTopEnd2.rend());
|
||||
PNTVECTOR vPntTopEnd01 = cBezTopStartF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTopEnd01.rbegin(), vPntTopEnd01.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTopEnd01.begin(), vPntTopEnd01.end()) ;
|
||||
PNTVECTOR vPntTopEnd1 = cBezTopEndF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd1.rbegin(), vPntTopEnd1.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd1.begin(), vPntTopEnd1.end()) ;
|
||||
PNTVECTOR vPntTopEnd02 = cBezTopStartF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTopEnd02.rbegin(), vPntTopEnd02.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTopEnd02.begin(), vPntTopEnd02.end()) ;
|
||||
PNTVECTOR vPntTopEnd2 = cBezTopEndF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd2.rbegin(), vPntTopEnd2.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTopEnd2.begin(), vPntTopEnd2.end()) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1793,36 +2044,74 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
if ( ! bTipIsPivot) {
|
||||
// inferiori
|
||||
if ( dSide > 0) {
|
||||
PNTVECTOR vPntTip01 = cBezTipStartB1->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTip01.rbegin(), vPntTip01.rend());
|
||||
PNTVECTOR vPntTip1 = cBezTipEndB1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTip1.rbegin(), vPntTip1.rend());
|
||||
PNTVECTOR vPntTip02 = cBezTipStartB2->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTip02.rbegin(), vPntTip02.rend());
|
||||
PNTVECTOR vPntTip2 = cBezTipEndB2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTip2.rbegin(), vPntTip2.rend());
|
||||
PNTVECTOR vPntTip01 = cBezTipStartB1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTip01.rbegin(), vPntTip01.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTip01.begin(), vPntTip01.end()) ;
|
||||
PNTVECTOR vPntTip1 = cBezTipEndB1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip1.rbegin(), vPntTip1.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip1.begin(), vPntTip1.end()) ;
|
||||
PNTVECTOR vPntTip02 = cBezTipStartB2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTip02.rbegin(), vPntTip02.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTip02.begin(), vPntTip02.end()) ;
|
||||
PNTVECTOR vPntTip2 = cBezTipEndB2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip2.rbegin(), vPntTip2.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip2.begin(), vPntTip2.end()) ;
|
||||
}
|
||||
else {
|
||||
vvPtCtrl.emplace_back(cBezTipStartF1->GetAllControlPoints());
|
||||
PNTVECTOR vPntTip1 = cBezTipEndF1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTip1.begin(), vPntTip1.end());
|
||||
vvPtCtrl.emplace_back(cBezTipStartF2->GetAllControlPoints());
|
||||
PNTVECTOR vPntTip2 = cBezTipEndF2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTip2.begin(), vPntTip2.end());
|
||||
PNTVECTOR vPntTip01 = cBezTipStartF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTip01.begin(), vPntTip01.end()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTip01.rbegin(), vPntTip01.rend()) ;
|
||||
PNTVECTOR vPntTip1 = cBezTipEndF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip1.begin(), vPntTip1.end()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip1.rbegin(), vPntTip1.rend()) ;
|
||||
PNTVECTOR vPntTip02 = cBezTipStartF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTip02.begin(), vPntTip02.end()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTip02.rbegin(), vPntTip02.rend()) ;
|
||||
PNTVECTOR vPntTip2 = cBezTipEndF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip2.begin(), vPntTip2.end()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTip2.rbegin(), vPntTip2.rend()) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! bTopIsPivot) {
|
||||
// superiori
|
||||
if ( dSide > 0) {
|
||||
PNTVECTOR vPntTop01 = cBezTopStartF1->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTop01.rbegin(), vPntTop01.rend());
|
||||
PNTVECTOR vPntTop1 = cBezTopEndF1->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTop1.rbegin(), vPntTop1.rend());
|
||||
PNTVECTOR vPntTop02 = cBezTopStartF2->GetAllControlPoints();
|
||||
vvPtCtrl.emplace_back(vPntTop02.rbegin(), vPntTop02.rend());
|
||||
PNTVECTOR vPntTop2 = cBezTopEndF2->GetAllControlPoints();
|
||||
vvPtCtrl.back().insert(vvPtCtrl.back().end(), vPntTop2.rbegin(), vPntTop2.rend());
|
||||
PNTVECTOR vPntTop01 = cBezTopStartF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTop01.rbegin(), vPntTop01.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTop01.begin(), vPntTop01.end()) ;
|
||||
PNTVECTOR vPntTop1 = cBezTopEndF1->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTop1.rbegin(), vPntTop1.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTop1.begin(), vPntTop1.end()) ;
|
||||
PNTVECTOR vPntTop02 = cBezTopStartF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.emplace_back( vPntTop02.rbegin(), vPntTop02.rend()) ;
|
||||
else
|
||||
vvPtCtrl.emplace_back( vPntTop02.begin(), vPntTop02.end()) ;
|
||||
PNTVECTOR vPntTop2 = cBezTopEndF2->GetAllControlPoints() ;
|
||||
if ( ! bInverse)
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTop2.rbegin(), vPntTop2.rend()) ;
|
||||
else
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntTop2.begin(), vPntTop2.end()) ;
|
||||
}
|
||||
else {
|
||||
vvPtCtrl.emplace_back(cBezTopStartB1->GetAllControlPoints());
|
||||
@@ -1838,23 +2127,43 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
|
||||
// chiudo il volume con le superfici verticali e le basi dei tool
|
||||
|
||||
// chiudo il volume con le superici verticali end 1
|
||||
// chiudo il volume con le superici verticali end front 1
|
||||
vvPtCtrl.emplace_back( cBezTipEndF1->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntEnd1 = cBezTopEndF1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntEnd1.begin(), vPntEnd1.end()) ;
|
||||
// chiudo il volume con le superici verticali end 2
|
||||
PNTVECTOR vPntEndF1 = cBezTopEndF1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntEndF1.begin(), vPntEndF1.end()) ;
|
||||
// chiudo il volume con le superici verticali end front 2
|
||||
vvPtCtrl.emplace_back( cBezTipEndF2->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntEnd2 = cBezTopEndF2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntEnd2.begin(), vPntEnd2.end()) ;
|
||||
PNTVECTOR vPntEndF2 = cBezTopEndF2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntEndF2.begin(), vPntEndF2.end()) ;
|
||||
if ( bInverse || bSmallMovement) {
|
||||
// chiudo il volume con le superici verticali end back 1
|
||||
vvPtCtrl.emplace_back( cBezTipEndB1->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntEndB1 = cBezTopEndB1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntEndB1.begin(), vPntEndB1.end()) ;
|
||||
// chiudo il volume con le superici verticali end back 2
|
||||
vvPtCtrl.emplace_back( cBezTipEndB2->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntEndB2 = cBezTopEndB2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntEndB2.begin(), vPntEndB2.end()) ;
|
||||
}
|
||||
|
||||
// chiudo il volume con le superici verticali start 1
|
||||
// chiudo il volume con le superici verticali start back 1
|
||||
vvPtCtrl.emplace_back( cBezTipStartB1->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntStart1 = cBezTopStartB1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStart1.begin(), vPntStart1.end()) ;
|
||||
// chiudo il volume con le superfici verticali start 2
|
||||
PNTVECTOR vPntStartB1 = cBezTopStartB1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStartB1.begin(), vPntStartB1.end()) ;
|
||||
// chiudo il volume con le superfici verticali start back 2
|
||||
vvPtCtrl.emplace_back( cBezTipStartB2->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntStart2 = cBezTopStartB2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStart2.begin(), vPntStart2.end()) ;
|
||||
PNTVECTOR vPntStartB2 = cBezTopStartB2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStartB2.begin(), vPntStartB2.end()) ;
|
||||
if ( bInverse || bSmallMovement) {
|
||||
// chiudo il volume con le superici verticali start front 1
|
||||
vvPtCtrl.emplace_back( cBezTipStartF1->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntStartF1 = cBezTopStartF1->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStartF1.begin(), vPntStartF1.end()) ;
|
||||
// chiudo il volume con le superfici verticali start front 2
|
||||
vvPtCtrl.emplace_back( cBezTipStartF2->GetAllControlPoints()) ;
|
||||
PNTVECTOR vPntStartF2 = cBezTopStartF2->GetAllControlPoints() ;
|
||||
vvPtCtrl.back().insert( vvPtCtrl.back().end(), vPntStartF2.begin(), vPntStartF2.end()) ;
|
||||
}
|
||||
|
||||
// superfici di base dei tool
|
||||
if ( ! ( n5AxisType == Move5Axis::NO_BASE_INTERS && dSide < 0)) {
|
||||
@@ -1925,7 +2234,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
}
|
||||
|
||||
// inizializzo le superfici bilineari e i parametri per le intersezioni
|
||||
for ( int z = 0 ; z < int( vvPtCtrl.size()) ; ++z) {
|
||||
for ( int z = 0 ; z < ssize( vvPtCtrl) ; ++z) {
|
||||
vSurfBez[nSurfInd].sBez.Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
vSurfBez[nSurfInd].sBez.SetControlPoint( 0, vvPtCtrl[z][0]) ;
|
||||
vSurfBez[nSurfInd].sBez.SetControlPoint( 1, vvPtCtrl[z][1]) ;
|
||||
@@ -1936,6 +2245,11 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
vSurfBez[nSurfInd].sBez.SetControlPoint( 6, vvPtCtrl[z][6]) ;
|
||||
vSurfBez[nSurfInd].sBez.SetControlPoint( 7, vvPtCtrl[z][7]) ;
|
||||
|
||||
#if SAVETRIMMINGTOOL
|
||||
if ( nGrid == 0)
|
||||
vGeo.push_back( vSurfBez[nSurfInd].sBez.Clone()) ;
|
||||
#endif
|
||||
|
||||
Vector3d A = vvPtCtrl[z][4] - vvPtCtrl[z][0] ;
|
||||
Vector3d B = vvPtCtrl[z][5] - vvPtCtrl[z][1] ;
|
||||
Vector3d C = vvPtCtrl[z][6] - vvPtCtrl[z][2] ;
|
||||
@@ -1984,6 +2298,11 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
++ nSurfInd ;
|
||||
}
|
||||
|
||||
#if SAVETRIMMINGTOOL
|
||||
if ( nGrid == 0)
|
||||
SaveGeoObj( vGeo, "D:\\Temp\\VirtualMilling\\5axisAdvanced\\marmo sottosquadra\\volume.nge") ;
|
||||
#endif
|
||||
|
||||
// scorro tutti gli spilloni interessati
|
||||
int j = 0 ;
|
||||
int nLastForwardJ = -1 ;
|
||||
|
||||
+1
-1
@@ -1155,7 +1155,7 @@ Voronoi::AdjustOffsetStart( ICurveComposite* pCrv) const
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
bool
|
||||
Voronoi::Translate( const Vector3d & vtMove)
|
||||
Voronoi::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
Reference in New Issue
Block a user