Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d481c8a71 | |||
| 7968a4e5ed | |||
| 39d295f412 | |||
| 0bf2cc2a77 | |||
| 433f486091 | |||
| fee6604d5e | |||
| c339fced5c | |||
| a87351778d | |||
| 42687457e0 | |||
| 4a541402da | |||
| ecef487746 | |||
| df483b5623 | |||
| e4d3f5f9a4 | |||
| 02e164dcdf | |||
| ead94e7915 | |||
| dfc3c29439 | |||
| ab538f4bf7 | |||
| 00b6f8583a | |||
| 4cf4a99107 | |||
| 137289e843 | |||
| e7b066e75e | |||
| cd0828f3e0 | |||
| 563697f840 | |||
| 61fc814528 | |||
| 7c90dbabea | |||
| 5ee0f3c373 | |||
| 098bdd0076 | |||
| 40b6da6b44 | |||
| b083dabc6b | |||
| 7fcc3ed42d | |||
| 4ed362f226 | |||
| 39d98f79fb | |||
| c79f7ba245 | |||
| 16354ff435 | |||
| f3a191dd62 | |||
| cb0a5092fb | |||
| 8730f55308 | |||
| 932e98d19c | |||
| 3a69dcfa79 | |||
| 5930674d4a | |||
| df6b20d97f | |||
| 4200af5296 | |||
| b0c9c5be2e | |||
| f2bb1deac4 | |||
| 94ec83aa60 | |||
| e183eec3ea | |||
| b179771ec9 | |||
| d7380a09c1 | |||
| afc316cd1d | |||
| b6f820258a | |||
| 116b605cb1 | |||
| 9f5ce42393 | |||
| 9716d93c15 | |||
| 3465179379 | |||
| c7aad8d917 | |||
| 8ddc1c70e1 | |||
| 5230261be8 | |||
| 8cc8d6eb03 | |||
| 7a95e4c5a3 | |||
| 1c0f182bbc | |||
| 736e20e599 | |||
| c71c8e8c12 | |||
| 9c7a29f939 | |||
| 40bb15e46b | |||
| fb957b61d2 | |||
| 4da9dcb062 | |||
| 60f9302c3f | |||
| 2553f15e7b | |||
| e8d31f2020 | |||
| 4c693ccd60 | |||
| c550fb1848 | |||
| e49bd5a2a0 | |||
| 81be6ce7b9 | |||
| 2d6bf3d9dc | |||
| b2244b7f43 | |||
| 53dcd9c863 | |||
| 75f70d2b30 | |||
| 36b1df1a27 | |||
| 5a445c5c0b | |||
| db855ca99b | |||
| d79cb50aca | |||
| df7b4ff81f | |||
| 574041cf18 | |||
| ff2cc4f999 | |||
| 05c0b0a18b | |||
| 8ee5bc74d5 | |||
| 9286ab6535 | |||
| ffe3d44cac | |||
| dd23b848ac | |||
| d6f0fdac50 | |||
| cc4183a677 | |||
| c2bae56656 | |||
| ba75033f0a | |||
| c6e80a0b6a | |||
| fc18539472 | |||
| de7229aee7 | |||
| 2fc6c30c8f | |||
| 6af5591cf6 | |||
| 41cbe862e5 | |||
| 0aca5aeb07 | |||
| bdbd3583b8 | |||
| f03adb9206 | |||
| 529fa2e4a0 | |||
| acb0a5bd5e | |||
| 0247fe5e7c | |||
| 50bad83fba | |||
| 9c93d6c2f3 | |||
| 59755ec8a5 | |||
| 79dfb4ae87 |
+325
-204
@@ -55,6 +55,7 @@ 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
|
||||
bool bCalcUnclearedRegs = true ; // flag per calcolare o meno le regioni non svuotate
|
||||
bool bOptOffsets = true ; // flag per evitare Offset non necessari
|
||||
@@ -1015,7 +1016,7 @@ GetIndOfHypoteticalChunk( const ICRVCOMPOPOVECTOR& vCrv, const ICurveComposite*
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ExtendPath( ICurveComposite* pCompo, const ISurfFlatRegion* pSfr, const PocketParams& PockParams,
|
||||
const Vector3d& vtFirstOut, bool bEndOrStart, bool& bOkExtended)
|
||||
const Vector3d& vtFirstOut, bool bEndOrStart, double dExtension, bool& bOkExtended)
|
||||
{
|
||||
/*
|
||||
Estensione della curva pCompo con un segmento lineare.
|
||||
@@ -1056,7 +1057,7 @@ ExtendPath( ICurveComposite* pCompo, const ISurfFlatRegion* pSfr, const PocketPa
|
||||
// ruoto il versore d'uscita
|
||||
Vector3d vtRotOut = GetRotate( vtFirstOut, Z_AX, - vAngles[i]) ;
|
||||
// calcolo il punto di caduta dell'utensile
|
||||
Point3d ptFall = pt + vtRotOut * ( PockParams.dRad + PockParams.dOpenMinSafe) ;
|
||||
Point3d ptFall = pt + vtRotOut * dExtension ;
|
||||
// controllo che sia sufficientemente distante dalla superficie limite
|
||||
bool bInside = true ;
|
||||
bool bOkOut = true ;
|
||||
@@ -1170,29 +1171,10 @@ GetHomogeneousParts( ICurveComposite* pCrvCompo, const PocketParams& PockParams,
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
GetFirstOffsCrvFromSfr( const ISurfFlatRegion* pSfr, double dOffs, ICRVCOMPOPOVECTOR& vCrvFirstOffs)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pSfr == nullptr || ! pSfr->IsValid())
|
||||
return false ;
|
||||
vCrvFirstOffs.clear() ;
|
||||
|
||||
// creo la regione mediante Offset
|
||||
PtrOwner<ISurfFlatRegion> pSfrOffs( pSfr->CreateOffsetSurf( dOffs, ICurve::OFF_FILLET)) ;
|
||||
if ( IsNull( pSfrOffs) || ! pSfrOffs->IsValid())
|
||||
return false ;
|
||||
|
||||
// inserisco le curve orientante
|
||||
return ( GetSfrCrvCompoLoops( pSfrOffs, vCrvFirstOffs)) ;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
static bool
|
||||
CreateSurfFrIncidence( const ICurveComposite* pCrv, const PocketParams& PockParams,
|
||||
const Vector3d& vtTanS_, const Vector3d& vtTanE_, const double dRad,
|
||||
ISurfFlatRegion* pSfrInc)
|
||||
const double dRad, ISurfFlatRegion* pSfrInc)
|
||||
{
|
||||
// controllo dei parametri
|
||||
if ( pCrv == nullptr || ! pCrv->IsValid())
|
||||
@@ -1318,11 +1300,11 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
pCrvBorder == nullptr || ! pCrvBorder->IsValid() || pCrvBorder->GetCurveCount() == 0)
|
||||
return false ;
|
||||
|
||||
// definisco la regione di incidenza
|
||||
// definisco la regione di incidenza ( leggermente più grande )
|
||||
PtrOwner<ISurfFlatRegion> pSfrInc( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrInc))
|
||||
return false ;
|
||||
if ( ! CreateSurfFrIncidence( pCrvBorder, PockParams, vtTanS, vtTanE, dRad + 75 * EPS_SMALL, pSfrInc)) {
|
||||
if ( ! CreateSurfFrIncidence( pCrvBorder, PockParams, dRad + 75. * EPS_SMALL, pSfrInc)) {
|
||||
pSfrInc.Set( GetSurfFlatRegionFromFatCurve( CloneCurveComposite( pCrvBorder), dRad + 75 * EPS_SMALL, false, false)) ;
|
||||
if ( IsNull( pSfrInc) || ! pSfrInc->IsValid())
|
||||
return false ;
|
||||
@@ -1347,12 +1329,12 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
double dArea ; Plane3d plCheck ;
|
||||
if ( ! pCrvCompo->GetArea( plCheck, dArea))
|
||||
return false ;
|
||||
bIsIsland = AreSameVectorEpsilon( plCheck.GetVersN(), - Z_AX, 10 * EPS_SMALL) ;
|
||||
bIsIsland = AreSameVectorEpsilon( plCheck.GetVersN(), - Z_AX, 10. * EPS_SMALL) ;
|
||||
|
||||
// scorro il vettore creato...
|
||||
for ( int c = 0 ; c < int( vCrvToCheck.size()) ; ++ c) {
|
||||
for ( int i = 0 ; i < int( vCrvToCheck.size()) ; ++ i) {
|
||||
// 1) recupero la curva corrente
|
||||
PtrOwner<ICurveComposite> pCrvCurr( vCrvToCheck[c]->Clone()) ;
|
||||
PtrOwner<ICurveComposite> pCrvCurr( vCrvToCheck[i]->Clone()) ;
|
||||
if ( IsNull( pCrvCurr) || ! pCrvCurr->IsValid())
|
||||
return false ;
|
||||
// 2) ricavo i tratti con proprietà uniformi ( Aperti/Chiusi )
|
||||
@@ -1360,12 +1342,12 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
if ( ! GetHomogeneousParts( pCrvCurr, PockParams, vpCrvs))
|
||||
return false ;
|
||||
// 3) considero solo i tratti chiusi
|
||||
for ( int cl = 0 ; cl < int( vpCrvs.size()) ; ++ cl) {
|
||||
if ( vpCrvs[cl]->GetTempProp() == TEMP_PROP_OPEN_EDGE)
|
||||
for ( int nU = 0 ; nU < int( vpCrvs.size()) ; ++ nU) {
|
||||
if ( vpCrvs[nU]->GetTempProp() == TEMP_PROP_OPEN_EDGE)
|
||||
continue ;
|
||||
// 4) effettuo l'Offset della curva di metà dDiamJ
|
||||
OffsetCurve OffsCrv ;
|
||||
if ( ! OffsCrv.Make( vpCrvs[cl], - dDiamJ * 0.5 - 20 * EPS_SMALL, PockParams.nOffsType))
|
||||
if ( ! OffsCrv.Make( vpCrvs[nU], - dDiamJ / 2. - 20. * EPS_SMALL, PockParams.nOffsType))
|
||||
return false ;
|
||||
// 5) scorro tutte le curve di Offset che si sono formate, prendendo sempre la più lunga tra le rimanenti
|
||||
PtrOwner<ICurve> pOffLongestCrv( OffsCrv.GetLongerCurve()) ;
|
||||
@@ -1373,7 +1355,7 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
// 6) creo la regione di incidenza di tale curva ( "Curva a fagiolo")
|
||||
bool bSquareEnds = ( PockParams.nOffsType == ICurve::OFF_CHAMFER) ;
|
||||
bool bSquareMids = ( PockParams.nOffsType == ICurve::OFF_CHAMFER) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrBean( GetSurfFlatRegionFromFatCurve( Release( pOffLongestCrv), dDiamJ * 0.5, bSquareEnds, bSquareMids)) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrBean( GetSurfFlatRegionFromFatCurve( Release( pOffLongestCrv), dDiamJ / 2., bSquareEnds, bSquareMids)) ;
|
||||
if ( IsNull( pSfrBean) || ! pSfrBean->IsValid())
|
||||
return false ;
|
||||
// inverto se necessario
|
||||
@@ -1381,7 +1363,8 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
pSfrBean->Invert() ;
|
||||
// 7) se la "Regione a fagiolo" non influenza la regione di incidenza, la transcuro
|
||||
bool bDiscard = false ;
|
||||
if ( ! bIsIsland) { // se tratto un loop esterno
|
||||
if ( ! bIsIsland) {
|
||||
// se tratto un loop esterno
|
||||
PtrOwner<ISurfFlatRegion> pSfrBean_test( CloneSurfFlatRegion( pSfrBean)) ;
|
||||
if ( IsNull( pSfrBean_test) || ! pSfrBean_test->IsValid())
|
||||
return false ;
|
||||
@@ -1390,7 +1373,8 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
! pSfrBean_test->IsValid() ||
|
||||
pSfrBean_test->GetChunkCount() == 0) ;
|
||||
}
|
||||
else if ( bIsAllOpen && bIsIsland) { // se isola aperta
|
||||
else if ( bIsAllOpen && bIsIsland) {
|
||||
// se isola aperta
|
||||
for ( int cI = 0 ; cI < pSfrInc->GetChunkCount() && ! bDiscard ; ++ cI) {
|
||||
for ( int cB = 0 ; cB < pSfrBean->GetChunkCount() && ! bDiscard ; ++ cB) {
|
||||
if ( pSfrInc->GetChunkSimpleClassification( cI, *pSfrBean, cB) == REGC_IN1) {
|
||||
@@ -1424,8 +1408,7 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
PtrOwner<ISurfFlatRegion> pSfrLimit( PockParams.SfrLimit.Clone()) ;
|
||||
if ( IsNull( pSfrLimit) || ! pSfrLimit->IsValid())
|
||||
return false ;
|
||||
// piccolo Offset per sicurezza
|
||||
pSfrLimit->Offset( 50 * EPS_SMALL, ICurve::OFF_FILLET) ;
|
||||
pSfrLimit->Offset( 50. * EPS_SMALL, ICurve::OFF_FILLET) ;
|
||||
pSfrInc->Subtract( *pSfrLimit) ; // rimuovo la regione limite
|
||||
|
||||
// può capitare che la regione Limite mi crei più Chunk sulla pSfrInc
|
||||
@@ -1574,7 +1557,6 @@ AdjustOpenEdge( const ICurveComposite* pCrvCompo, const ICRVCOMPOPOVECTOR& vCrvI
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1601,9 +1583,14 @@ AdjustContourWithOpenEdges( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vCrvI
|
||||
if ( PockParams.bAllowZigZagOneWayBorders &&
|
||||
( PockParams.nType == POCKET_ZIGZAG || PockParams.nType == POCKET_ONEWAY))
|
||||
dRad += PockParams.dOffsExtra ;
|
||||
// se lavorazione a ZigZag con smusso, esco di Step/2 per pulire gli aperti
|
||||
// se lavorazione a ZigZag con smusso
|
||||
if ( PockParams.nType == POCKET_ZIGZAG && PockParams.bSmooth)
|
||||
dRad += max( PockParams.dSideStep / 2, PockParams.dRad / 8) ;
|
||||
dRad += PockParams.bSmooth ;
|
||||
// se lavorazione Conformal
|
||||
if ( PockParams.nType == POCKET_CONFORMAL_ZIGZAG || PockParams.nType == POCKET_CONFORMAL_ONEWAY) {
|
||||
if ( PockParams.dRad - PockParams.dSideStep > 0)
|
||||
dRad -= PockParams.dSideStep ;
|
||||
}
|
||||
|
||||
// salvo il raggio trovato
|
||||
PockParams.dOpenEdgeRad = dRad ;
|
||||
@@ -1639,25 +1626,21 @@ AdjustContourWithOpenEdges( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vCrvI
|
||||
// controllo che sia almeno lungo quanto il diametro utensile
|
||||
double dLen = 0. ;
|
||||
vpCrvs[i]->GetLength( dLen) ;
|
||||
if ( dLen > PockParams.dRad * 2 - 5 * EPS_SMALL) {
|
||||
// ricavo la tangenze dei lati chiusi agli estremi di questa curva
|
||||
Vector3d vtTanS = V_INVALID ;
|
||||
Vector3d vtTanE = V_INVALID ;
|
||||
if ( i != 0) {
|
||||
if ( ! vpCrvs[i-1]->GetEndDir( vtTanS) || // tangente finale del chiuso precedente
|
||||
! vpCrvs[( i + 1) % int( vpCrvs.size())]->GetStartDir( vtTanE)) // tangente iniziale del chiuso successivo...
|
||||
return false ;
|
||||
vtTanE.Invert() ; // invertita
|
||||
}
|
||||
if ( ! AdjustOpenEdge( pCrvCompo, vCrvIsl, dParS, dParE, vtTanS, vtTanE, dRad, dDiamJ, PockParams, vpCrvs[i]))
|
||||
// ricavo la tangenze dei lati chiusi agli estremi di questa curva
|
||||
Vector3d vtTanS = V_INVALID ;
|
||||
Vector3d vtTanE = V_INVALID ;
|
||||
if ( i != 0) {
|
||||
if ( ! vpCrvs[i-1]->GetEndDir( vtTanS) || // tangente finale del chiuso precedente
|
||||
! vpCrvs[( i + 1) % int( vpCrvs.size())]->GetStartDir( vtTanE)) // tangente iniziale del chiuso successivo...
|
||||
return false ;
|
||||
vtTanE.Invert() ; // invertita
|
||||
}
|
||||
else
|
||||
nCurrTmpProp = TEMP_PROP_CLOSE_EDGE ;
|
||||
if ( ! AdjustOpenEdge( pCrvCompo, vCrvIsl, dParS, dParE, vtTanS, vtTanE, dRad, dDiamJ, PockParams, vpCrvs[i]))
|
||||
return false ;
|
||||
}
|
||||
// assegno le proprietà di lato Aperto/Chiuso per la curva corrente
|
||||
for ( int u = 0 ; u < vpCrvs[i]->GetCurveCount() ; ++ u)
|
||||
vpCrvs[i]->SetCurveTempProp( u, nCurrTmpProp, 0) ;
|
||||
vpCrvs[i]->SetCurveTempProp( u, nCurrTmpProp, TEMP_PROP_CLOSE_EDGE) ;
|
||||
// aggiungo la curva ricavata ( se chiusa -> la copio, se aperta -> copio l'estesa)
|
||||
if ( ! pCrvCompo_final->AddCurve( vpCrvs[i]->Clone())) {
|
||||
// per sicurezza, se gli estremi non coincidono, creo un piccolo raccordo lineare
|
||||
@@ -1840,14 +1823,14 @@ AdvanceExtendCurves( ICRVCOMPOPOVECTOR& vCrvCompo, const ISurfFlatRegion* pSfr,
|
||||
Vector3d vtStart ; vCrvCompo[i]->GetStartDir( vtStart) ;
|
||||
vtStart.Invert() ;
|
||||
bool bIsStartExtended = false ;
|
||||
if ( ! ExtendPath( vCrvCompo[i], pSfr, PockParams, vtStart, false, bIsStartExtended))
|
||||
if ( ! ExtendPath( vCrvCompo[i], pSfr, PockParams, vtStart, false, PockParams.dRad + PockParams.dOpenMinSafe, bIsStartExtended))
|
||||
return false ;
|
||||
// se aperta, controllo la fine
|
||||
if ( ! bIsClosed) {
|
||||
// ricavo vettore tangente finale e provo ad estendere
|
||||
Vector3d vtEnd ; vCrvCompo[i]->GetEndDir( vtEnd) ;
|
||||
bool bIsEndExtended = false ;
|
||||
if ( ! ExtendPath( vCrvCompo[i], pSfr, PockParams, vtEnd, true, bIsEndExtended))
|
||||
if ( ! ExtendPath( vCrvCompo[i], pSfr, PockParams, vtEnd, true, PockParams.dRad + PockParams.dOpenMinSafe, bIsEndExtended))
|
||||
return false ;
|
||||
if ( bIsEndExtended)
|
||||
break ;
|
||||
@@ -2155,7 +2138,6 @@ GetSinglePocketingCurves( ISurfFlatRegion* pSfr, PocketParams& PockParams,
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ModifySurfByOpenEdges( ISurfFlatRegion* pSfr, PocketParams& PockParams)
|
||||
@@ -2295,7 +2277,6 @@ ModifySurfByOpenEdges( ISurfFlatRegion* pSfr, PocketParams& PockParams)
|
||||
if ( ! pSrfFinal->IsValid())
|
||||
return false ;
|
||||
|
||||
|
||||
// chiudo le isole che risultano ambigue ( quindi non omgenee)
|
||||
for ( int nC = 0 ; nC < pSrfFinal->GetChunkCount() ; ++ nC) {
|
||||
for ( int nL = 1 ; nL < pSrfFinal->GetLoopCount( nC) ; ++ nL) {
|
||||
@@ -3159,8 +3140,8 @@ CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, int nBase, int nSe
|
||||
int nProp = - 1 ;
|
||||
if ( ! pCrvPocket->GetCurveTempProp( nCrvId, nProp))
|
||||
return false ;
|
||||
// se open
|
||||
if ( nProp == 1) {
|
||||
// se Open
|
||||
if ( nProp == TEMP_PROP_OPEN_EDGE) {
|
||||
Point3d pt1, pt2 ;
|
||||
pCrvPocket->GetCurve( nCrvId)->GetStartPoint( pt1) ;
|
||||
pCrvPocket->GetCurve( nCrvId)->GetEndPoint( pt2) ;
|
||||
@@ -3169,10 +3150,10 @@ CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, int nBase, int nSe
|
||||
else
|
||||
dXCoord = max( pt1.x, pt2.x) ;
|
||||
}
|
||||
// se closed
|
||||
// se Closed
|
||||
else {
|
||||
// creo la curva destra/sinistra
|
||||
int nLast = bStart ? pCrvPocket->GetCurveCount() : nSecondBase ;
|
||||
int nLast = ( bStart ? pCrvPocket->GetCurveCount() : nSecondBase) ;
|
||||
PtrOwner<ICurveComposite> pCrvSide( ConvertCurveToComposite( pCrvPocket->CopyParamRange( nCrvId, nLast))) ;
|
||||
if ( IsNull( pCrvSide))
|
||||
return false ;
|
||||
@@ -3200,7 +3181,7 @@ CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, int nBase, int nSe
|
||||
PtrOwner<ICurveLine> pLineMid( CreateCurveLine()) ;
|
||||
if ( IsNull( pLineMid))
|
||||
return false ;
|
||||
pLineMid->Set( Point3d( - 3000, dYCoord, 0), Point3d( 3000, dYCoord, 0)) ;
|
||||
pLineMid->Set( Point3d( - 3000., dYCoord, 0.), Point3d( 3000., dYCoord, 0.)) ;
|
||||
IntersCurveCurve intCC( *pLineMid, *pCrvOffs) ;
|
||||
IntCrvCrvInfo ccClass ;
|
||||
if ( intCC.GetIntersCount() != 0) {
|
||||
@@ -3211,8 +3192,7 @@ CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, int nBase, int nSe
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
// se non ho intersezioni...
|
||||
// prendo il box della curva
|
||||
// se non ho intersezioni, prendo il box della curva
|
||||
BBox3d Box3d ;
|
||||
pCrvSide->GetLocalBBox( Box3d) ;
|
||||
// creo la linea limitie verticale
|
||||
@@ -3220,10 +3200,10 @@ CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, int nBase, int nSe
|
||||
if ( IsNull( pCrvVertLine))
|
||||
return false ;
|
||||
if ( bStart)
|
||||
pCrvVertLine->SetPDL( Box3d.GetMax() + 5 * TOL_TRAPEZOID * Y_AX, - 90 , 2 * dPocketSize) ;
|
||||
pCrvVertLine->SetPDL( Box3d.GetMax() + 5 * TOL_TRAPEZOID * Y_AX, - ANG_RIGHT , 2 * dPocketSize) ;
|
||||
else
|
||||
pCrvVertLine->SetPDL( Box3d.GetMin() - 5 * TOL_TRAPEZOID * Y_AX, 90, 2 * dPocketSize) ;
|
||||
// intersechiamo
|
||||
pCrvVertLine->SetPDL( Box3d.GetMin() - 5 * TOL_TRAPEZOID * Y_AX, ANG_RIGHT, 2 * dPocketSize) ;
|
||||
// intersezione
|
||||
IntersCurveCurve intCC2( *pCrvVertLine, *pCrvSide) ;
|
||||
if ( intCC2.GetOverlaps()) {
|
||||
if ( bStart)
|
||||
@@ -3232,7 +3212,7 @@ CalcTrapezoidSpiralXCoord( const ICurveComposite* pCrvPocket, int nBase, int nSe
|
||||
dXCoord = Box3d.GetMin().x - dRad ;
|
||||
}
|
||||
else {
|
||||
dXCoord = bStart ? -INFINITO : INFINITO ;
|
||||
dXCoord = ( bStart ? -INFINITO : INFINITO) ;
|
||||
for ( int i = 0 ; i < intCC2.GetIntersCount() ; ++ i) {
|
||||
IntCrvCrvInfo ccClass2 ;
|
||||
if ( intCC2.GetIntCrvCrvInfo( i, ccClass2)) {
|
||||
@@ -3259,24 +3239,25 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
const PocketParams& PockParams, bool bStart)
|
||||
{
|
||||
// parametri
|
||||
double dDiam = PockParams.dRad_prec > 0 ? 2 * PockParams.dRad_prec : 2 * PockParams.dRad ;
|
||||
double dOffsR = PockParams.dRad_prec > 0 ? PockParams.dRadialOffset_prec : PockParams.dRadialOffset ;
|
||||
double dDiam = ( PockParams.dRad_prec > 0 ? 2. * PockParams.dRad_prec : 2. * PockParams.dRad) ;
|
||||
double dOffsR = ( PockParams.dRad_prec > 0 ? PockParams.dRadialOffset_prec : PockParams.dRadialOffset) ;
|
||||
double dRad = 0.5 * dDiam + dOffsR ;
|
||||
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( ! bStart)
|
||||
pMCrv->Invert() ;
|
||||
|
||||
// recupero la coordinata Y del tratto lineare e la dimensione della tasca a trapezio
|
||||
Point3d ptTmp ;
|
||||
pMCrv->GetStartPoint( ptTmp) ;
|
||||
double dYCoord = ptTmp.y ; // quota verticale del percorso di svuotatura
|
||||
double dYCoord = ptTmp.y ;
|
||||
pCrvPocket->GetCurve( 2)->GetStartPoint( ptTmp) ;
|
||||
double dPocketSize = ptTmp.y ;
|
||||
|
||||
// offset del lato chiuso del raggio utensile, verso l'interno della tasca a trapezio
|
||||
int nCrvId = ( bStart ? 3 : 1) ;
|
||||
PtrOwner<ICurveLine> pLine( GetCurveLine( pCrvPocket->GetCurve( nCrvId)->Clone())) ;
|
||||
pLine->SimpleOffset( - dRad) ;
|
||||
|
||||
// inverto gli estremi se necessario
|
||||
Point3d ptP1, ptP2 ;
|
||||
pLine->GetStartPoint( ptP1) ;
|
||||
pLine->GetEndPoint( ptP2) ;
|
||||
@@ -3284,8 +3265,11 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
swap( ptP1, ptP2) ;
|
||||
|
||||
int nProp2 ;
|
||||
PtrOwner<ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
// lato opposto a quello di riferimento aperto
|
||||
if ( pCrvPocket->GetCurveTempProp( 2, nProp2) && nProp2 != 0) {
|
||||
if ( pCrvPocket->GetCurveTempProp( 2, nProp2) && nProp2 != TEMP_PROP_CLOSE_EDGE) {
|
||||
|
||||
// caso 1 : pLine ha un estremo sopra e uno sotto il percorso di svuotatura pMCrv
|
||||
if ( ptP2.y < dYCoord && dYCoord < ptP1.y) {
|
||||
@@ -3316,22 +3300,19 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
if ( ! pMCrv->TrimStartAtParam( dPar))
|
||||
pMCrv->Clear() ;
|
||||
|
||||
if ( ptP1.y > dPocketSize) {
|
||||
if ( ptP1.y > dPocketSize + 100. * EPS_SMALL) {
|
||||
// se ptP1 è esterno alla svuotatura scambio i punti in modo da usare ptP2 per il biarco ( così da non farlo fuoriuscire troppo)
|
||||
swap( ptP1, ptP2) ;
|
||||
pCompo->Invert() ;
|
||||
}
|
||||
|
||||
// creo biarco fra ptP1 e ptCrv
|
||||
Vector3d vtDir ;
|
||||
pCompo->GetStartDir( vtDir) ;
|
||||
double dAng ;
|
||||
vtDir.GetAngleXY( X_AX, dAng) ;
|
||||
PtrOwner<ICurve> pBiArc( GetBiArc( ptP1, - dAng, ptCrv, bStart ? 0 : 180, 0.8)) ;
|
||||
|
||||
Vector3d vtDir ; pCompo->GetStartDir( vtDir) ;
|
||||
double dAng ; vtDir.GetAngleXY( X_AX, dAng) ;
|
||||
bool bUseBiArc = false ;
|
||||
PtrOwner<ICurve> pBiArc( GetBiArc( ptP1, - dAng, ptCrv, bStart ? 0 : ANG_STRAIGHT, 0.8)) ;
|
||||
if ( ! IsNull( pBiArc)) {
|
||||
// verifico che con il biarco non si oltrepassi il lato obliquo chiuso della svuotatura
|
||||
// verifico che con il biarco non si oltrepassi il lato obliquo chiuso della svuotatura
|
||||
IntersCurveCurve intCC2( *pBiArc, *pCompo) ;
|
||||
if ( intCC2.GetIntersCount() == 1)
|
||||
bUseBiArc = true ;
|
||||
@@ -3356,9 +3337,9 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
|
||||
// trovo l'intersezione fra il prolungamento della linea e pMCrv
|
||||
if ( bStart)
|
||||
pLine->ExtendStartByLen( 1000) ;
|
||||
pLine->ExtendStartByLen( 1000.) ;
|
||||
else
|
||||
pLine->ExtendEndByLen( 1000) ;
|
||||
pLine->ExtendEndByLen( 1000.) ;
|
||||
IntersCurveCurve intCC ( *pLine, *pMCrv) ;
|
||||
if ( intCC.GetIntersCount() == 0)
|
||||
return false ;
|
||||
@@ -3376,7 +3357,7 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
}
|
||||
}
|
||||
|
||||
// se il lato opposto a quello di riferimento � chiuso bisogna distinguere i casi
|
||||
// se il lato opposto a quello di riferimento è chiuso bisogna distinguere i casi
|
||||
else {
|
||||
bool bStartPnt = false ;
|
||||
if ( ptP2.y < dYCoord) {
|
||||
@@ -3387,7 +3368,7 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
pLine->GetStartDir( vtDir) ;
|
||||
if ( bStart)
|
||||
vtDir.Invert() ;
|
||||
Point3d ptP2N = ptP2 - dDiam / 2 * abs( vtDir.x / vtDir.y) * vtDir ;
|
||||
Point3d ptP2N = ptP2 - dDiam / 2. * abs( vtDir.x / vtDir.y) * vtDir ;
|
||||
if ( ptP2N.y < dYCoord)
|
||||
bStartPnt = pCompo->AddPoint( ptP2N) ;
|
||||
}
|
||||
@@ -3399,12 +3380,13 @@ AdjustTrapezoidSpiralForAngles( ICurveComposite* pMCrv, const ICurveComposite* p
|
||||
}
|
||||
|
||||
// setto temp prop per ricordare che è curva aggiuntiva per pulire angoli
|
||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i++)
|
||||
pCompo->SetCurveTempProp( i, 1) ;
|
||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; ++ i)
|
||||
pCompo->SetCurveTempProp( i, TEMP_PROP_OPEN_EDGE) ;
|
||||
|
||||
pMCrv->AddCurve( Release( pCompo), false) ;
|
||||
if ( ! bStart)
|
||||
pMCrv->Invert() ; // ripristino la direzione originaria
|
||||
// se richiesto ripristino la direzione originaria
|
||||
if ( ! bStart)
|
||||
pMCrv->Invert() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -3418,7 +3400,6 @@ CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTrap, double
|
||||
// parametri
|
||||
double dDiam = 2 * PockParams.dRad ;
|
||||
double dOffsR = PockParams.dRadialOffset ;
|
||||
|
||||
bOptimizedTrap = false ;
|
||||
Vector3d vtExtr ; pCrvPocket->GetExtrusion( vtExtr) ;
|
||||
|
||||
@@ -3443,7 +3424,7 @@ CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTrap, double
|
||||
pCrvPocket->GetCurve( nSecondBase)->GetLength( dLen2) ;
|
||||
bool bRealTrap = ( pCrvPocket->GetCurveCount() == 4) ;
|
||||
for ( int i = 0 ; i < 4 && bRealTrap ; ++ i)
|
||||
bRealTrap = pCrvPocket->GetCurve( i)->GetType() == CRV_LINE ;
|
||||
bRealTrap = ( pCrvPocket->GetCurve( i)->GetType() == CRV_LINE) ;
|
||||
if ( bRealTrap) {
|
||||
pCrvPocket->GetCurve( nBase + 1)->GetLength( dLen1) ;
|
||||
pCrvPocket->GetCurve( nSecondBase + 1)->GetLength( dLen3) ;
|
||||
@@ -3469,13 +3450,17 @@ CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTrap, double
|
||||
else {
|
||||
// trovo la quota Y per centro del Tool
|
||||
double dYCoord ;
|
||||
if ( pCrvPocket->GetCurve( nBase)->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE) // se base principale chiusa
|
||||
// se base principale chiusa
|
||||
if ( pCrvPocket->GetCurve( nBase)->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE)
|
||||
dYCoord = 0.5 * dDiam + dOffsR ;
|
||||
else if ( pCrvPocket->GetCurve( nSecondBase)->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE) // se base principale aperta e secondaria chiusa
|
||||
// se base principale aperta e secondaria chiusa
|
||||
else if ( pCrvPocket->GetCurve( nSecondBase)->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE)
|
||||
dYCoord = dPocketSize - 0.5 * dDiam - dOffsR ;
|
||||
else // se entrambi i lati paralleli sono aperti mi posiziono a metà della svuotatura
|
||||
// se entrambi i lati paralleli sono aperti mi posiziono a metà della svuotatura
|
||||
else
|
||||
dYCoord = 0.5 * dPocketSize ;
|
||||
|
||||
// determino le quote coordinate in X inziale e finale
|
||||
double dXCoordStart = -INFINITO ;
|
||||
double dXCoordEnd = INFINITO ;
|
||||
if ( ! CalcTrapezoidSpiralXCoord( pCrvPocket, nBase, nSecondBase, true, dYCoord, dXCoordStart,
|
||||
@@ -3486,10 +3471,14 @@ CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTrap, double
|
||||
return false ;
|
||||
if ( dXCoordStart > dXCoordEnd + 500 * EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// determino gli estremi del segmento di svuotatura
|
||||
Point3d ptStart( dXCoordStart, dYCoord) ;
|
||||
Point3d ptEnd( dXCoordEnd, dYCoord) ;
|
||||
|
||||
if ( bRealTrap && AreSamePointEpsilon( ptStart, ptEnd, 500 * EPS_SMALL) && ( vnProp[0] != 0 || vnProp[2] != 0)) {
|
||||
// verifico se il punto iniziale e finale coincidono
|
||||
if ( bRealTrap && AreSamePointEpsilon( ptStart, ptEnd, 500 * EPS_SMALL) &&
|
||||
( vnProp[0] != TEMP_PROP_CLOSE_EDGE || vnProp[2] != TEMP_PROP_CLOSE_EDGE)) {
|
||||
Vector3d vtDir1, vtDir3 ;
|
||||
pCrvPocket->GetCurve( 1)->GetStartDir( vtDir1) ;
|
||||
pCrvPocket->GetCurve( 3)->GetStartDir( vtDir3) ;
|
||||
@@ -3532,6 +3521,7 @@ CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTrap, double
|
||||
pMCrv->SetCurveTempProp( 0, TEMP_PROP_OPEN_EDGE) ;
|
||||
}
|
||||
}
|
||||
// se estremi del segmento differenti, allora il percorso è definito
|
||||
else {
|
||||
if ( ! pMCrv->AddPoint( ptStart))
|
||||
return true ;
|
||||
@@ -3653,7 +3643,7 @@ GetSpiralOptimizedCurves( const ISurfFlatRegion* pSfrChunk, const PocketParams&
|
||||
pCrvRes->GetStartDir( vtMidOut) ;
|
||||
vtMidOut.Rotate( pSfrChunk->GetNormVersor(), PockParam.bInvert ? ANG_RIGHT : - ANG_RIGHT) ;
|
||||
bool bIsExtended ;
|
||||
ExtendPath( pCrvRes, pSfrChunk, PockParam, vtMidOut, false, bIsExtended) ;
|
||||
ExtendPath( pCrvRes, pSfrChunk, PockParam, vtMidOut, false, PockParam.dRad + PockParam.dOpenMinSafe, bIsExtended) ;
|
||||
}
|
||||
// se invece lavorazione in SpiralOut, inverto il percorso
|
||||
else if ( PockParam.nType == POCKET_SPIRALOUT)
|
||||
@@ -3685,11 +3675,11 @@ GetSpiralOptimizedCurves( const ISurfFlatRegion* pSfrChunk, const PocketParams&
|
||||
Vector3d vtRef ; pCrvRes->GetStartDir( vtRef) ;
|
||||
vtRef.Invert() ;
|
||||
bool bIsStartExtended = false ;
|
||||
if ( ! ExtendPath( pCrvRes, pSfrChunk, PockParam, vtRef, false, bIsStartExtended))
|
||||
if ( ! ExtendPath( pCrvRes, pSfrChunk, PockParam, vtRef, false, PockParam.dRad + PockParam.dOpenMinSafe, bIsStartExtended))
|
||||
return false ;
|
||||
pCrvRes->GetEndDir( vtRef) ;
|
||||
bool bIsEndExtended = false ;
|
||||
if ( ! ExtendPath( pCrvRes, pSfrChunk, PockParam, vtRef, true, bIsEndExtended))
|
||||
if ( ! ExtendPath( pCrvRes, pSfrChunk, PockParam, vtRef, true, PockParam.dRad + PockParam.dOpenMinSafe, bIsEndExtended))
|
||||
return false ;
|
||||
if ( bIsEndExtended && ! bIsStartExtended)
|
||||
pCrvRes->Invert() ;
|
||||
@@ -3883,7 +3873,7 @@ GetPtStartOnOpenEdgeByOrigCurve( const ICurveComposite* pCrvOrig, const PocketPa
|
||||
double dLen = 0. ;
|
||||
pCrvOpen->GetLength( dLen) ;
|
||||
// se lunghezza accettabile o maggiore della massima trovata
|
||||
if ( dLen > dLenRef) {
|
||||
if ( dLen > dLenRef - 10. * EPS_SMALL) {
|
||||
Point3d ptSTmp ;
|
||||
Vector3d vtMidOutTmp ;
|
||||
// ricavo il punto medio e il vettore tangente ad esso associato
|
||||
@@ -4934,7 +4924,7 @@ CalcBoundedSmoothedLink( const Point3d& ptStart, const Vector3d& vtStart, const
|
||||
return false ;
|
||||
}
|
||||
// La curva necessita di un ulteriore smusso, in quanto tagliata su un bordo
|
||||
ModifyCurveToSmoothed( pCompoTest, PockParams, PockParams.dRad / 4., PockParams.dRad / 4., false) ;
|
||||
ModifyCurveToSmoothed( pCompoTest, PockParams, PockParams.dSmooth, PockParams.dSmooth, false) ;
|
||||
// nel caso speciale della circonferenza, devo impostare il punto iniziale
|
||||
if ( dParMeet < EPS_ZERO) {
|
||||
if ( pCompoTest->IsClosed()) { // sempre...
|
||||
@@ -6055,7 +6045,7 @@ CalcSpiral( const ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig, co
|
||||
}
|
||||
|
||||
// smusso le curve di offset ( ad eccezione di quelle di primo Offset)
|
||||
double dSmoothPar = PockParams.dRad / 8. ;
|
||||
double dSmoothPar = PockParams.dSmooth / SQRT2 ;
|
||||
for ( int i = 0 ; i < int( vOffs.size()) ; ++ i) {
|
||||
if ( i >= nCrvFirstOffs)
|
||||
ModifyCurveToSmoothed( vOffs[i], PockParams, dSmoothPar, dSmoothPar, false) ;
|
||||
@@ -6655,7 +6645,7 @@ AddSpiralIn( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig,
|
||||
|
||||
bool bIsExtended = false ;
|
||||
if ( bSomeOpen)
|
||||
ExtendPath( pMCrv, pSfrOrig, PockParams, vtMidOut, false, bIsExtended) ;
|
||||
ExtendPath( pMCrv, pSfrOrig, PockParams, vtMidOut, false, PockParams.dRad + PockParams.dOpenMinSafe, bIsExtended) ;
|
||||
|
||||
// inserisco le curve nel vettore
|
||||
vCrvCompoRes.emplace_back( Release( pMCrv)) ;
|
||||
@@ -6937,10 +6927,10 @@ AddZigZag( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, PocketPar
|
||||
Vector3d vtRef ; vpCrvs[nU]->GetStartDir( vtRef) ;
|
||||
vtRef.Invert() ;
|
||||
bool bIsExtended = false ;
|
||||
if ( ! ExtendPath( vpCrvs[nU], pSfrOrig, PockParams, vtRef, false,bIsExtended))
|
||||
if ( ! ExtendPath( vpCrvs[nU], pSfrOrig, PockParams, vtRef, false, PockParams.dRad + PockParams.dOpenMinSafe, bIsExtended))
|
||||
return false ;
|
||||
vpCrvs[nU]->GetEndDir( vtRef) ;
|
||||
if ( ! ExtendPath( vpCrvs[nU], pSfrOrig, PockParams, vtRef, true, bIsExtended))
|
||||
if ( ! ExtendPath( vpCrvs[nU], pSfrOrig, PockParams, vtRef, true, PockParams.dRad + PockParams.dOpenMinSafe, bIsExtended))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -7138,10 +7128,10 @@ AddOneWay( ISurfFlatRegion* pSrfPock, const ISurfFlatRegion* pSfrOrig, PocketPar
|
||||
Vector3d vtRef ; pCrvSegCompo->GetStartDir( vtRef) ;
|
||||
vtRef.Invert() ;
|
||||
bool bIsExtended = false ;
|
||||
if ( ! ExtendPath( pCrvSegCompo, pSfrOrig, PockParams, vtRef, false,bIsExtended))
|
||||
if ( ! ExtendPath( pCrvSegCompo, pSfrOrig, PockParams, vtRef, false, PockParams.dRad + PockParams.dOpenMinSafe, bIsExtended))
|
||||
return false ;
|
||||
pCrvSegCompo->GetEndDir( vtRef) ;
|
||||
if ( ! ExtendPath( pCrvSegCompo, pSfrOrig, PockParams, vtRef, true, bIsExtended))
|
||||
if ( ! ExtendPath( pCrvSegCompo, pSfrOrig, PockParams, vtRef, true, PockParams.dRad + PockParams.dOpenMinSafe, bIsExtended))
|
||||
return false ;
|
||||
}
|
||||
vCrvCompoRes.emplace_back( Release( pCrvSegCompo)) ;
|
||||
@@ -7403,7 +7393,7 @@ CalcConformalLink( ICurveComposite* pCrvOffs0, ICurveComposite* pCrvOffs1, Pocke
|
||||
if ( PockParams.nType == POCKET_CONFORMAL_ZIGZAG) {
|
||||
// effettuo smusso del tratto lineare
|
||||
SmoothLinkByOffs( pCrvOffs0, pCrvOffs1, pCrvLink, PockParams, bFirstIterOffs0, bFirstIterOffs1,
|
||||
PockParams.dRad / 5., TOL) ;
|
||||
PockParams.dSmooth, TOL) ;
|
||||
// per sicurezza aggiorno i nuovi punti e i nuovi parametri
|
||||
double dUNewE ;
|
||||
Point3d ptStartNext ;
|
||||
@@ -7944,21 +7934,37 @@ ExtendConformalOffsAndSetFeed( const ISurfFlatRegion* pSfrPock, const ISurfFlatR
|
||||
return false ;
|
||||
if ( vCrvOffs.empty())
|
||||
return true ;
|
||||
/*
|
||||
dalla superificie estesa presso i lati aperti, effettuo un Offset interno pari alla somma del
|
||||
raggio utensile e dell'offset radiale. La ricerca delle zone non svuotate avviene all'interno
|
||||
di questa regione
|
||||
*/
|
||||
ICRVCOMPOPOVECTOR vCrvFirstOffs ;
|
||||
if ( ! GetFirstOffsCrvFromSfr( pSfrPock, - PockParams.dRad - PockParams.dRadialOffset, vCrvFirstOffs))
|
||||
|
||||
// definisco la regione di ricerca delle aree non svuotate come la regione originale
|
||||
PtrOwner<ISurfFlatRegion> pSfrBorder( CloneSurfFlatRegion( pSfrPock)) ;
|
||||
if ( IsNull( pSfrBorder) || ! pSfrBorder->IsValid())
|
||||
return false ;
|
||||
|
||||
// dalla superficie originale, rimuovo le parti definite dai lati chiusi
|
||||
double dOffs = PockParams.dRad + PockParams.dRadialOffset - 2. * EPS_SMALL ;
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
for ( int nC = 0 ; nC < pSfrPock->GetChunkCount() ; ++ nC) {
|
||||
for ( int nL = 0 ; nL < pSfrPock->GetLoopCount( nC) ; ++ nL) {
|
||||
PtrOwner<ICurveComposite> pCompoLoop( ConvertCurveToComposite( pSfrPock->GetLoop( nC, nL))) ;
|
||||
if ( IsNull( pCompoLoop) || ! pCompoLoop->IsValid())
|
||||
return false ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrToDiscard( GetSurfFlatRegionFromFatCurve( pCompoLoop->Clone(), dOffs, false, false)) ;
|
||||
if ( IsNull( pSfrToDiscard) || ! pSfrToDiscard->IsValid())
|
||||
return false ;
|
||||
if ( ! pSfrBorder->Subtract( *pSfrToDiscard))
|
||||
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( vCrvFirstOffs, vCrvOffs, vCrvLinks, pSfrOrig, PockParams, pSfrUncleared)) {
|
||||
if ( GetUnclearedRegionAndSetFeed( vCrvBorder, vCrvOffs, vCrvLinks, pSfrOrig, PockParams, pSfrUncleared)) {
|
||||
// estendo i percorsi di Offset se richiesto
|
||||
if ( ! RemoveUnclearedRegions( pSfrUncleared, vCrvOffs, vCrvFirstOffs, PockParams))
|
||||
if ( ! RemoveUnclearedRegions( pSfrUncleared, vCrvOffs, vCrvBorder, PockParams))
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -8049,14 +8055,24 @@ AddLeadInLeadOutToCurveConformalPaths( const ISurfFlatRegion* pSfrOrig, const IS
|
||||
}
|
||||
|
||||
// estendo il percorso sul tratto iniziale e finale ( se ammissibile)
|
||||
Vector3d vtTan ; vCrvPaths[i]->GetStartDir( vtTan) ;
|
||||
vtTan.Invert() ;
|
||||
bool bOkExtension ;
|
||||
if ( ! ExtendPath( vCrvPaths[i], pSfrOrig, PockParams, vtTan, false, bOkExtension))
|
||||
return false ;
|
||||
vCrvPaths[i]->GetEndDir( vtTan) ;
|
||||
if ( ! ExtendPath( vCrvPaths[i], pSfrOrig, PockParams, vtTan, true, bOkExtension))
|
||||
return false ;
|
||||
Vector3d vtTanS, vtTanE ;
|
||||
vCrvPaths[i]->GetStartDir( vtTanS) ; vtTanS.Invert() ;
|
||||
vCrvPaths[i]->GetEndDir( vtTanE) ;
|
||||
const int MAXTRY = 8 ;
|
||||
bool bOkStartExtension = false, bOkEndExtension = false ;
|
||||
for ( int j = 0 ; j <= MAXTRY ; ++ j) {
|
||||
if ( bOkStartExtension && bOkEndExtension)
|
||||
break ;
|
||||
double dDist = PockParams.dOpenMinSafe + j * ( PockParams.dRad / ( 1. * MAXTRY)) ;
|
||||
if ( ! bOkStartExtension) {
|
||||
if ( ! ExtendPath( vCrvPaths[i], pSfrOrig, PockParams, vtTanS, false, dDist, bOkStartExtension))
|
||||
return false ;
|
||||
}
|
||||
if ( ! bOkEndExtension) {
|
||||
if ( ! ExtendPath( vCrvPaths[i], pSfrOrig, PockParams, vtTanE, true, dDist, bOkEndExtension))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -8327,7 +8343,7 @@ ExtendGuideByIteration( ICurveComposite* pCompoTempGuide, const ICurveComposite*
|
||||
pCompoPerimeter == nullptr || ! pCompoPerimeter->IsValid())
|
||||
return false ;
|
||||
|
||||
const double EXTENSION_VAL = 1000. ;
|
||||
const double EXTENSION_VAL = 5000. ;
|
||||
|
||||
// ricavo il punto finale della guida
|
||||
Point3d ptEndGuide ; pCompoTempGuide->GetEndPoint( ptEndGuide) ;
|
||||
@@ -8356,7 +8372,9 @@ ExtendGuideByIteration( ICurveComposite* pCompoTempGuide, const ICurveComposite*
|
||||
Point3d ptPoly ;
|
||||
PL.GetFirstPoint( ptPoly) ;
|
||||
while ( PL.GetNextPoint( ptPoly)) {
|
||||
if ( ! pSeg->Set( ptEndGuide, ptEndGuide + ( ptPoly - ptEndGuide) * EXTENSION_VAL))
|
||||
Vector3d vtDir = ptPoly - ptEndGuide ;
|
||||
vtDir.Normalize() ;
|
||||
if ( ! pSeg->Set( ptEndGuide, ptEndGuide + vtDir * EXTENSION_VAL))
|
||||
return false ;
|
||||
// calcolo l'intersezione tra questo segmento e la curva di perimetro aperta
|
||||
IntersCurveCurve ICC( *pSeg, *pCompoPerimeter) ;
|
||||
@@ -8573,7 +8591,6 @@ GetConformalOffsets( const ISurfFlatRegion* pSfrChunk, const ISurfFlatRegion* pS
|
||||
ICRVCOMPOPOVECTOR vpCrvs ;
|
||||
PtrOwner<ICurveComposite> pCrvExtLoop( ConvertCurveToComposite( pSfrChunk->GetLoop( 0, 0))) ;
|
||||
if ( IsNull( pCrvExtLoop) || ! pCrvExtLoop->IsValid() ||
|
||||
! AdjustCloseEdgesForConformalGuide( pCrvExtLoop, PockParam) ||
|
||||
! IsCompoMadeBy2DifferentHomogeneousParts( pCrvExtLoop, PockParam, bOk, vpCrvs))
|
||||
return false ;
|
||||
if ( ! bOk)
|
||||
@@ -8738,10 +8755,94 @@ GetConformalOffsets( const ISurfFlatRegion* pSfrChunk, const ISurfFlatRegion* pS
|
||||
}
|
||||
|
||||
// smusso le curve di Offset ( ad eccezione di quelle generate alla prima iterazione)
|
||||
double dSmoothPar = PockParam.dRad / 8. ;
|
||||
for ( int i = 1 ; i < int( vCrvOffs.size()) ; ++ i) {
|
||||
for ( int j = 0 ; j < int( vCrvOffs[i].size()) ; ++ j)
|
||||
ModifyCurveToSmoothed( vCrvOffs[i][j], PockParam, dSmoothPar, dSmoothPar, false) ;
|
||||
ModifyCurveToSmoothed( vCrvOffs[i][j], PockParam, PockParam.dSmooth, PockParam.dSmooth, false) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CalcSpiralPocketing( const ISurfFlatRegion* pSfr, int nType, const PocketParams& PockParams,
|
||||
ICRVCOMPOPOVECTOR& vCrvCompoRes)
|
||||
{
|
||||
// verifica validità della superficie
|
||||
if ( pSfr == nullptr || ! pSfr->IsValid())
|
||||
return false ;
|
||||
// il tipo può essere solo SpiralIn o SpiralOut
|
||||
if ( nType != POCKET_SPIRALIN && nType != POCKET_SPIRALOUT)
|
||||
return false ;
|
||||
// calcolo il percorso di svuotatura spiral
|
||||
return ( CalcPocketing( pSfr, PockParams.dRad, PockParams.dRadialOffset, PockParams.dSideStep,
|
||||
PockParams.dAngle, PockParams.dOpenMinSafe, nType, PockParams.bSmooth,
|
||||
PockParams.bCalcUnclearedRegs, PockParams.bInvert, PockParams.bAvoidOpt,
|
||||
PockParams.bAllowZigZagOneWayBorders, PockParams.bCalcFeed, PockParams.ptStart,
|
||||
PockParams.SfrLimit.IsValid() ? PockParams.SfrLimit.Clone() : CreateSurfFlatRegion(),
|
||||
PockParams.bAvoidOpt, PockParams.dMaxOptSize, PockParams.dLiTang, PockParams.nLiType,
|
||||
vCrvCompoRes)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
GetOrigChunkForConformal( const ISurfFlatRegion* pSfrChunk, const ISurfFlatRegion* pSfrOrig,
|
||||
set<int>& setChunks)
|
||||
{
|
||||
// NB. funzione migliorabile... potrei calcolare tutto all'inizio senza ripetere le intersezioni
|
||||
// controllo validità delle regioni
|
||||
if ( pSfrChunk == nullptr || ! pSfrChunk->IsValid() ||
|
||||
pSfrOrig == nullptr || ! pSfrOrig->IsValid())
|
||||
return false ;
|
||||
|
||||
// se la superficie originale ha un solo Chunk allora è lui stesso
|
||||
if ( pSfrOrig->GetChunkCount() == 1) {
|
||||
setChunks.insert( 0) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// essendo la pSfrChunk estesa, cerco quale chunk di pSfrOrig ha una intersezione valida
|
||||
for ( int nC = 0 ; nC < pSfrOrig->GetChunkCount() ; ++ nC) {
|
||||
// se il Chunk è già stato analizzato in precedenza, passo al successivo
|
||||
if ( setChunks.find( nC) != setChunks.end())
|
||||
continue ;
|
||||
// recupero il Chunk corrente
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunkOrig( pSfrOrig->CloneChunk( nC)) ;
|
||||
if ( IsNull( pSfrChunkOrig) || ! pSfrChunkOrig->IsValid())
|
||||
return false ;
|
||||
// controllo se esiste l'intersezione
|
||||
if ( pSfrChunkOrig->Intersect( *pSfrChunk) && pSfrChunkOrig->IsValid())
|
||||
setChunks.insert( nC) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
CreateSurfFromOtherChunks( ISurfFlatRegion* pSfr, const ISurfFlatRegion* pSfrOther, const set<int>& setChunks)
|
||||
{
|
||||
// controllo della regione
|
||||
if ( pSfr == nullptr ||
|
||||
pSfrOther == nullptr || ! pSfrOther->IsValid())
|
||||
return false ;
|
||||
|
||||
// se non ho indici di Chunk non faccio nulla
|
||||
if ( setChunks.empty())
|
||||
return true ;
|
||||
|
||||
// scorro gli indici dei Chunks
|
||||
for ( auto it = setChunks.begin() ; it != setChunks.end() ; ++ it) {
|
||||
// recupero l'indice del Chunk
|
||||
int nChunk = *it ;
|
||||
// recupero il Chunk come regione piana
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunk( pSfrOther->CloneChunk( nChunk)) ;
|
||||
if ( ! IsNull( pSfrChunk) && pSfrChunk->IsValid()) {
|
||||
if ( ! pSfr->IsValid())
|
||||
pSfr->CopyFrom( pSfrChunk) ;
|
||||
else if ( ! pSfr->Add( *pSfrChunk))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -8758,99 +8859,119 @@ AddConformal( ISurfFlatRegion* pSfrPock, const ISurfFlatRegion* pSfrOrig,
|
||||
return true ;
|
||||
|
||||
// se superifice tutta aperta, lavoro in SPIRAL_IN
|
||||
if ( PockParams.bAllOpen) {
|
||||
PockParams.nType = POCKET_SPIRALIN ;
|
||||
return ( AddSpiralIn( pSfrPock, pSfrOrig, PockParams, vCrvCompoRes)) ;
|
||||
}
|
||||
if ( PockParams.bAllOpen)
|
||||
return ( CalcSpiralPocketing( pSfrOrig, POCKET_SPIRALIN, PockParams, vCrvCompoRes)) ;
|
||||
// se superficie tutta chiusa, lavoro in SPIRAL_OUT
|
||||
if ( PockParams.bAllClosed) {
|
||||
PockParams.nType = POCKET_SPIRALOUT ;
|
||||
return ( AddSpiralOut( pSfrPock, pSfrOrig, PockParams, vCrvCompoRes)) ;
|
||||
}
|
||||
if ( PockParams.bAllClosed)
|
||||
return ( CalcSpiralPocketing( pSfrOrig, POCKET_SPIRALOUT, PockParams, vCrvCompoRes)) ;
|
||||
|
||||
// definisco eventuali regioni da lavorare in SpiralIn e SpiralOut
|
||||
PtrOwner<ISurfFlatRegion> pSfrSpiralIn( CreateSurfFlatRegion()) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrSpiralOut( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrSpiralIn) || IsNull( pSfrSpiralOut))
|
||||
return false ;
|
||||
// NB. La supercicie pSfrPock è estesa presso i lati aperti, quindi il suo numero di Chunk potrebbe
|
||||
// essere differente dal numero di Chunk della superficie originale di svuotatura. Tengo un insieme di
|
||||
// di indici dei Chunk che devono essere lavorati in SpiralIn e in SpiralOut
|
||||
set<int> setIndChunkSpiralIn ;
|
||||
set<int> setIndChunkSpiralOut ;
|
||||
|
||||
// scorro i chunk della superficie da lavorare
|
||||
for ( int nC = 0 ; nC < pSfrPock->GetChunkCount() ; ++ nC) {
|
||||
|
||||
// controllo se il Chunk ha tutte proprietà omogenee tra loro
|
||||
bool bClose, bOpen ;
|
||||
if ( ! IsChunkAllHomogeneous( pSfrPock, nC, bClose, bOpen))
|
||||
return false ;
|
||||
|
||||
// recupero il Chunk come regione piana
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunk( pSfrPock->CloneChunk( nC)) ;
|
||||
if ( IsNull( pSfrChunk) || ! pSfrChunk->IsValid())
|
||||
return false ;
|
||||
// se Chunk tutto aperto, lo lavoro in SPIRAL_IN
|
||||
|
||||
// --- se Chunk tutto aperto, aggiorno i Chunk della superficie originale da lavorare in SpiralIn
|
||||
if ( bOpen) {
|
||||
int nType = PockParams.nType ;
|
||||
PockParams.nType = POCKET_SPIRALIN ;
|
||||
if ( ! AddSpiralIn( pSfrChunk, pSfrOrig, PockParams, vCrvCompoRes))
|
||||
if ( ! GetOrigChunkForConformal( pSfrChunk, pSfrOrig, setIndChunkSpiralIn))
|
||||
return false ;
|
||||
PockParams.nType = nType ;
|
||||
continue ;
|
||||
}
|
||||
// se Chunk tutto chiuso, lo lavoro in SPIRAL_OUT
|
||||
// --- se Chunk tutto chiuso, lo lavoro in SPIRAL_OUT
|
||||
else if ( bClose) {
|
||||
int nType = PockParams.nType ;
|
||||
PockParams.nType = POCKET_SPIRALOUT ;
|
||||
if ( ! AddSpiralOut( pSfrChunk, pSfrOrig, PockParams, vCrvCompoRes))
|
||||
return false ;
|
||||
PockParams.nType = nType ;
|
||||
if ( ! GetOrigChunkForConformal( pSfrChunk, pSfrOrig, setIndChunkSpiralOut))
|
||||
continue ;
|
||||
}
|
||||
// se Chunk non omogeneo
|
||||
else {
|
||||
// ricavo gli Offset ( se possibili) dei tratti chiusi del Chunk
|
||||
VICRVCOMPOPOVECTOR vvCrvOffs ;
|
||||
if ( ! GetConformalOffsets( pSfrChunk, pSfrChunk, pSfrOrig, PockParams, vvCrvOffs))
|
||||
// --- se chunk non omogoneo, ricavo gli Offset ( se possibili) dei tratti chiusi del Chunk
|
||||
VICRVCOMPOPOVECTOR vvCrvOffs ;
|
||||
if ( ! GetConformalOffsets( pSfrChunk, pSfrChunk, pSfrOrig, PockParams, vvCrvOffs))
|
||||
return false ;
|
||||
|
||||
// se non ottengo Curve di Offset, lavoro in SpiralIn ( il Chunk ha dei lati aperti)
|
||||
if ( vvCrvOffs.empty()) {
|
||||
if ( ! GetOrigChunkForConformal( pSfrChunk, pSfrOrig, setIndChunkSpiralIn))
|
||||
return false ;
|
||||
// se non ottengo Curve di Offset, lavoro in SpiralIn ( il Chunk ha dei lati aperti)
|
||||
if ( vvCrvOffs.empty()) {
|
||||
int nType = PockParams.nType ;
|
||||
PockParams.nType = POCKET_SPIRALIN ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunk_cl( CloneSurfFlatRegion( pSfrChunk)) ;
|
||||
if ( IsNull( pSfrChunk_cl) || ! pSfrChunk_cl->IsValid() ||
|
||||
! AddSpiralIn( pSfrChunk_cl, pSfrOrig, PockParams, vCrvCompoRes))
|
||||
return false ;
|
||||
PockParams.nType = nType ;
|
||||
}
|
||||
else {
|
||||
// definisco vettore degli Offset e dei Link
|
||||
ICRVCOMPOPOVECTOR vCrvOffs ;
|
||||
ICURVEPOVECTOR vCrvLink ;
|
||||
// ordino le curve di Offset e raccordo
|
||||
if ( ! CalcConformalOffsAndLinks( vvCrvOffs, pSfrChunk, pSfrPock, PockParams, vCrvOffs, vCrvLink)) {
|
||||
// se calcolare i raccordi risulta troppo ambiguo o complesso, ritorno a SpiralIn
|
||||
int nType = PockParams.nType ;
|
||||
PockParams.nType = POCKET_SPIRALIN ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunk_cl( CloneSurfFlatRegion( pSfrChunk)) ;
|
||||
if ( IsNull( pSfrChunk_cl) || ! pSfrChunk_cl->IsValid() ||
|
||||
! AddSpiralIn( pSfrChunk_cl, pSfrOrig, PockParams, vCrvCompoRes))
|
||||
return false ;
|
||||
PockParams.nType = nType ;
|
||||
continue ;
|
||||
}
|
||||
// flag per controllo
|
||||
bool bOk = true ;
|
||||
// estendo i percorsi per eventuali regioni non svuotate e calcolo le Feed
|
||||
bOk = bOk && ExtendConformalOffsAndSetFeed( pSfrPock, pSfrOrig, PockParams, vCrvOffs, vCrvLink) ;
|
||||
// concateno Offset e Links
|
||||
ICRVCOMPOPOVECTOR vCrvPaths ;
|
||||
bOk = bOk && ChainConformalOffsWithLinks( vCrvOffs, vCrvLink, vCrvPaths) ;
|
||||
// estendo per lati aperti ed ordino i percorsi trovati
|
||||
bOk = bOk && OrderAndExtendConformalPaths( vCrvPaths, pSfrChunk, pSfrOrig, PockParams) ;
|
||||
if ( ! bOk) {
|
||||
// se qualche passaggio restituisce errore, provo in SpiralIn
|
||||
int nType = PockParams.nType ;
|
||||
PockParams.nType = POCKET_SPIRALIN ;
|
||||
PtrOwner<ISurfFlatRegion> pSfrChunk_cl( CloneSurfFlatRegion( pSfrChunk)) ;
|
||||
if ( IsNull( pSfrChunk_cl) || ! pSfrChunk_cl->IsValid() ||
|
||||
! AddSpiralIn( pSfrChunk_cl, pSfrOrig, PockParams, vCrvCompoRes))
|
||||
return false ;
|
||||
PockParams.nType = nType ;
|
||||
}
|
||||
else {
|
||||
// aggiungo i percorsi ricavati
|
||||
for ( int i = 0 ; i < int( vCrvPaths.size()) ; ++ i)
|
||||
vCrvCompoRes.emplace_back( Release( vCrvPaths[i])) ;
|
||||
}
|
||||
}
|
||||
continue ;
|
||||
}
|
||||
|
||||
// definisco i vettori ordinati degli Offset e dei Link
|
||||
ICRVCOMPOPOVECTOR vCrvOffs ;
|
||||
ICURVEPOVECTOR vCrvLink ;
|
||||
if ( ! CalcConformalOffsAndLinks( vvCrvOffs, pSfrChunk, pSfrPock, PockParams, vCrvOffs, vCrvLink)) {
|
||||
if ( ! GetOrigChunkForConformal( pSfrChunk, pSfrOrig, setIndChunkSpiralIn))
|
||||
return false ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
// flag per controllo
|
||||
bool bOk = true ;
|
||||
// estendo i percorsi per eventuali regioni non svuotate e calcolo le Feed
|
||||
bOk = bOk && ExtendConformalOffsAndSetFeed( pSfrPock, pSfrOrig, PockParams, vCrvOffs, vCrvLink) ;
|
||||
// concateno Offset e Links
|
||||
ICRVCOMPOPOVECTOR vCrvPaths ;
|
||||
bOk = bOk && ChainConformalOffsWithLinks( vCrvOffs, vCrvLink, vCrvPaths) ;
|
||||
// estendo per lati aperti ed ordino i percorsi trovati
|
||||
bOk = bOk && OrderAndExtendConformalPaths( vCrvPaths, pSfrChunk, pSfrOrig, PockParams) ;
|
||||
|
||||
// se qualche passaggio restituisce errore, provo in SpiralIn
|
||||
if ( ! bOk) {
|
||||
if ( ! GetOrigChunkForConformal( pSfrChunk, pSfrOrig, setIndChunkSpiralIn))
|
||||
return false ;
|
||||
continue ;
|
||||
}
|
||||
// altrimenti aggiungo i percorsi ricavati
|
||||
for ( int i = 0 ; i < int( vCrvPaths.size()) ; ++ i)
|
||||
vCrvCompoRes.emplace_back( Release( vCrvPaths[i])) ;
|
||||
}
|
||||
|
||||
// se ho superfici da lavorare in SpiralIn, aggiungo le curve
|
||||
if ( ! setIndChunkSpiralIn.empty()) {
|
||||
// costruisco la regione di SpiralIn
|
||||
PtrOwner<ISurfFlatRegion> pSfrSpiralIn( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrSpiralIn) ||
|
||||
! CreateSurfFromOtherChunks( pSfrSpiralIn, pSfrOrig, setIndChunkSpiralIn))
|
||||
return false ;
|
||||
// recupero le curve di Pocketing SpiralIn
|
||||
ICRVCOMPOPOVECTOR vCrvSpiralIn ;
|
||||
if ( ! CalcSpiralPocketing( pSfrSpiralIn, POCKET_SPIRALIN, PockParams, vCrvSpiralIn))
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vCrvSpiralIn.size()) ; ++ i) {
|
||||
if ( vCrvSpiralIn[i] != nullptr && vCrvSpiralIn[i]->IsValid())
|
||||
vCrvCompoRes.emplace_back( Release( vCrvSpiralIn[i])) ;
|
||||
}
|
||||
}
|
||||
// se ho superfici da lavorare in SpiralOut, aggiungo le curve
|
||||
if ( ! setIndChunkSpiralOut.empty()) {
|
||||
// costruisco la regione di SpiralOut
|
||||
PtrOwner<ISurfFlatRegion> pSfrSpiralOut( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfrSpiralIn) ||
|
||||
! CreateSurfFromOtherChunks( pSfrSpiralOut, pSfrOrig, setIndChunkSpiralOut))
|
||||
return false ;
|
||||
// recupero le curve di Pocketing SpiralOut
|
||||
ICRVCOMPOPOVECTOR vCrvSpiralOut ;
|
||||
if ( ! CalcSpiralPocketing( pSfrSpiralOut, POCKET_SPIRALOUT, PockParams, vCrvSpiralOut))
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vCrvSpiralOut.size()) ; ++ i) {
|
||||
if ( vCrvSpiralOut[i] != nullptr && vCrvSpiralOut[i]->IsValid())
|
||||
vCrvCompoRes.emplace_back( Release( vCrvSpiralOut[i])) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+93
-51
@@ -515,6 +515,10 @@ CurveToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
ICurveBezier*
|
||||
LineToBezierCurve( const ICurveLine* pCrvLine, int nDeg, bool bMakeRatOrNot)
|
||||
{
|
||||
// verifico che esista la linea
|
||||
if ( pCrvLine == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
PtrOwner<ICurveBezier> pCrvBezier( CreateCurveBezier()) ;
|
||||
// rendo tutte le curve di grado 2 e razionali così posso convertire anche archi e avere tutte curve dello stesso grado e razionali
|
||||
pCrvBezier->Init( nDeg, true) ;
|
||||
@@ -526,12 +530,11 @@ LineToBezierCurve( const ICurveLine* pCrvLine, int nDeg, bool bMakeRatOrNot)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ArcToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
ArcToBezierCurve( const ICurveArc* pArc, int nDeg, bool bMakeRatOrNot)
|
||||
{
|
||||
// una spirale non può essere forzata al grado 2
|
||||
|
||||
// verifico sia un arco
|
||||
const CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
||||
// verifico che esista l'arco
|
||||
if ( pArc == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
@@ -541,8 +544,15 @@ ArcToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez) || ! pCrvBez->FromArc( *pArc))
|
||||
return nullptr ;
|
||||
if ( ! bMakeRatOrNot) {
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
pCrvBez.Set( ApproxArcCurveBezierWithSingleCubic( pCrvBez, ptCen, vtN)) ;
|
||||
}
|
||||
if ( IsNull( pCrvBez))
|
||||
return nullptr ;
|
||||
// aumento il grado della curva come richiesto
|
||||
while( pCrvBez->GetDegree() < nDeg)
|
||||
while ( pCrvBez->GetDegree() < nDeg)
|
||||
pCrvBez.Set( BezierIncreaseDegree( pCrvBez)) ;
|
||||
// restituisco la curva
|
||||
return Release( pCrvBez) ;
|
||||
@@ -555,20 +565,18 @@ ArcToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
return nullptr ;
|
||||
// inserisco nella CC le curve di Bezier equivalenti alle parti dell'arco
|
||||
int nParts = (int) ceil( abs( pArc->GetAngCenter()) / ( BEZARC_ANG_CEN_MAX + EPS_ANG_SMALL)) ;
|
||||
//if ( ! bDeg3OrDeg2 && abs( pArc->GetDeltaN()) > EPS_ZERO)
|
||||
// nParts *= 2 ;
|
||||
nParts = max( nParts, 2) ;
|
||||
for ( int i = 0 ; i < nParts ; ++ i) {
|
||||
// copio l'arco originale
|
||||
CurveArc cArc = *pArc ;
|
||||
CurveArc cArc = *GetBasicCurveArc( pArc) ;
|
||||
// lo limito alla parte di interesse
|
||||
cArc.TrimStartEndAtParam( i / double( nParts), ( i + 1) / double( nParts)) ;
|
||||
cArc.TrimStartEndAtParam( double( i) / nParts, double( i + 1) / nParts) ;
|
||||
// creo la curva di Bezier equivalente
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateBasicCurveBezier()) ;
|
||||
if ( IsNull( pCrvBez) || ! pCrvBez->FromArc( cArc))
|
||||
return nullptr ;
|
||||
// aumento il grado della curva come richiesto
|
||||
while( pCrvBez->GetDegree() < nDeg)
|
||||
while ( pCrvBez->GetDegree() < nDeg)
|
||||
pCrvBez.Set( BezierIncreaseDegree( pCrvBez)) ;
|
||||
// aggiungo la curva di Bezier a quella composita
|
||||
if ( ! pCrvCompo->AddCurve( Release( pCrvBez)))
|
||||
@@ -586,7 +594,11 @@ ArcToBezierCurve( const ICurve* pCrv, int nDeg, bool bMakeRatOrNot)
|
||||
ICurve*
|
||||
CompositeToBezierCurve( const ICurveComposite* pCC, int nDeg, bool bMakeRatOrNot)
|
||||
{
|
||||
// converto tutte le curve in bezier razionali di grado 2
|
||||
// verifico che esista la curva
|
||||
if ( pCC == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// converto tutte le curve in bezier razionali di grado 2
|
||||
PtrOwner<ICurveComposite> pCCBezier( CreateCurveComposite()) ;
|
||||
for ( int i = 0 ; i < int( pCC->GetCurveCount()) ; ++i) {
|
||||
PtrOwner<ICurve> pCrvNew ;
|
||||
@@ -595,7 +607,7 @@ CompositeToBezierCurve( const ICurveComposite* pCC, int nDeg, bool bMakeRatOrNot
|
||||
ICurve* pCrvBezier = ArcToBezierCurve( crArc) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
// se la curva è di grado superiore al secondo allora devo ricondurla al secondo grado
|
||||
// se la curva è di grado superiore al secondo allora devo ricondurla al secondo grado
|
||||
pCrvNew.Set( pCrvBezier) ;
|
||||
}
|
||||
else if ( pCC->GetCurve(i)->GetType() == CRV_LINE) {
|
||||
@@ -624,25 +636,28 @@ EditBezierCurve( const ICurveBezier* pCrvBezier, int nDeg, bool bMakeRatOrNot, d
|
||||
{
|
||||
// se nDeg == -1 allora viene mantenuto il grado della curva originale
|
||||
|
||||
if( nDeg == 2 || nDeg == 1)
|
||||
// verifico sia una bezier
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
if ( nDeg == 2 || nDeg == 1)
|
||||
return nullptr ;
|
||||
|
||||
PtrOwner<ICurveBezier> pCrvNew( pCrvBezier->Clone()) ;
|
||||
int nDegCurr = pCrvNew->GetDegree() ;
|
||||
bool bRat = pCrvNew->IsRational() ;
|
||||
int nDegWanted = nDeg == -1 ? nDegCurr : nDeg ;
|
||||
if( ! bMakeRatOrNot) {
|
||||
if( ! pCrvNew->MakeNonRational( dTol)) {
|
||||
if ( ! bMakeRatOrNot) {
|
||||
if ( ! pCrvNew->MakeNonRational( dTol)) {
|
||||
// se ho fallito la conversione diretta in curva non razionale allora la spezzo in bezier cubiche
|
||||
PtrOwner<ICurveComposite> pBezCubics( CreateCurveComposite()) ;
|
||||
pBezCubics->AddCurve( ApproxBezierWithCubics(pCrvBezier, dTol)) ;
|
||||
if( IsNull( pBezCubics))
|
||||
if ( IsNull( pBezCubics))
|
||||
return nullptr ;
|
||||
// adatto ogni sottocurva cubica
|
||||
PtrOwner<ICurveComposite> pCCEdited( CreateCurveComposite()) ;
|
||||
|
||||
for ( int i = 0 ; i < pBezCubics->GetCurveCount() ; ++i) {
|
||||
if( ! pCCEdited->AddCurve( EditBezierCurve( GetCurveBezier( pBezCubics->GetCurve( i)), nDegWanted, bMakeRatOrNot, dTol)) )
|
||||
if ( ! pCCEdited->AddCurve( EditBezierCurve( GetCurveBezier( pBezCubics->GetCurve( i)), nDegWanted, bMakeRatOrNot, dTol)) )
|
||||
return nullptr ;
|
||||
}
|
||||
return Release( pCCEdited) ;
|
||||
@@ -661,7 +676,7 @@ EditBezierCurve( const ICurveBezier* pCrvBezier, int nDeg, bool bMakeRatOrNot, d
|
||||
else if ( nDegCurr > nDegWanted) {
|
||||
while ( nDegCurr > nDegWanted) {
|
||||
ICurveBezier* pCrvDec = BezierDecreaseDegree( pCrvNew, dTol) ;
|
||||
if( pCrvDec == nullptr || ! pCrvDec->IsValid()) {
|
||||
if ( pCrvDec == nullptr || ! pCrvDec->IsValid()) {
|
||||
// se ho fallito la riduzione di grado entro la tolleranza richiesta allora la spezzo in bezier cubiche prima di adattare
|
||||
PtrOwner<ICurveComposite> pBezCubics( CreateCurveComposite()) ;
|
||||
pBezCubics->AddCurve( ApproxBezierWithCubics(pCrvBezier, dTol)) ;
|
||||
@@ -687,20 +702,22 @@ EditBezierCurve( const ICurveBezier* pCrvBezier, int nDeg, bool bMakeRatOrNot, d
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
BezierIncreaseDegree(const ICurveBezier* pCrvBezier)
|
||||
BezierIncreaseDegree( const ICurveBezier* pCrvBezier)
|
||||
{
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
// creo la versione con grado aumentato
|
||||
// creo la versione con grado aumentato
|
||||
PtrOwner<ICurveBezier> pNewBezier( CreateCurveBezier()) ;
|
||||
int nDeg = pCrvBezier->GetDegree() + 1;
|
||||
bool bRat = pCrvBezier->IsRational();
|
||||
pNewBezier->Init( nDeg , bRat) ;
|
||||
// prev e curr sono riferiti alla curva di partenza
|
||||
// salvo il primo punto
|
||||
if ( IsNull( pNewBezier))
|
||||
return nullptr ;
|
||||
int nDeg = pCrvBezier->GetDegree() + 1 ;
|
||||
bool bRat = pCrvBezier->IsRational() ;
|
||||
pNewBezier->Init( nDeg, bRat) ;
|
||||
// prev e curr sono riferiti alla curva di partenza
|
||||
// salvo il primo punto
|
||||
Point3d ptCtrlPrev = pCrvBezier->GetControlPoint( 0) ;
|
||||
double dWprev = 1 ;
|
||||
if ( bRat ) {
|
||||
if ( bRat) {
|
||||
dWprev = pCrvBezier->GetControlWeight( 0) ;
|
||||
pNewBezier->SetControlPoint( 0, ptCtrlPrev, dWprev) ;
|
||||
}
|
||||
@@ -709,26 +726,26 @@ BezierIncreaseDegree(const ICurveBezier* pCrvBezier)
|
||||
// ciclo sui punti di controllo intermedi per calcolare quelli nuovi
|
||||
Point3d ptCtrlCurr ;
|
||||
double dWcurr ;
|
||||
for ( double i = 1 ; i < nDeg ; ++i) {
|
||||
ptCtrlCurr = pCrvBezier->GetControlPoint( int( i)) ;
|
||||
double dAlpha = i / nDeg ;
|
||||
for ( int i = 1 ; i < nDeg ; ++i) {
|
||||
ptCtrlCurr = pCrvBezier->GetControlPoint( i) ;
|
||||
double dAlpha = double( i) / nDeg ;
|
||||
if ( bRat) {
|
||||
dWcurr = pCrvBezier->GetControlWeight( int( i)) ;
|
||||
dWcurr = pCrvBezier->GetControlWeight( i) ;
|
||||
double dWnew = dAlpha * dWprev + ( 1 - dAlpha) * dWcurr ;
|
||||
Point3d ptNew = dAlpha * ptCtrlPrev * dWprev + ( 1 - dAlpha) * ptCtrlCurr * dWcurr;
|
||||
ptNew /= dWnew ;
|
||||
pNewBezier->SetControlPoint( int( i), ptNew, dWnew) ;
|
||||
pNewBezier->SetControlPoint( i, ptNew, dWnew) ;
|
||||
dWprev = dWcurr ;
|
||||
}
|
||||
else {
|
||||
Point3d ptNew = dAlpha * ptCtrlPrev + ( 1 - dAlpha) * ptCtrlCurr ;
|
||||
pNewBezier->SetControlPoint( int( i), ptNew) ;
|
||||
pNewBezier->SetControlPoint( i, ptNew) ;
|
||||
}
|
||||
ptCtrlPrev = ptCtrlCurr ;
|
||||
}
|
||||
// salvo l'ultimo punto
|
||||
ptCtrlCurr = pCrvBezier->GetControlPoint( nDeg - 1) ;
|
||||
if ( bRat ) {
|
||||
if ( bRat) {
|
||||
dWcurr = pCrvBezier->GetControlWeight( nDeg - 1) ;
|
||||
pNewBezier->SetControlPoint( nDeg, ptCtrlCurr, dWcurr) ;
|
||||
}
|
||||
@@ -889,8 +906,13 @@ BezierDecreaseDegree(const ICurveBezier* pCrvBezier, double dTol)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
ApproxBezierWithCubics(const ICurve* pCrv, double dTol)
|
||||
{
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBezier = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// cerco di stimare quanti cambi di concavità ho
|
||||
// tiro una linea tra il primo punto di controllo e l'ultimo e poi scorro gli altri punti di controllo
|
||||
// controllando quante volte salto da un lato all'altro della linea
|
||||
@@ -911,10 +933,8 @@ ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
Vector3d vtStartDir, vtEndDir ;
|
||||
pCrvBezier->GetPointD1D2( 0, ICurve::FROM_MINUS, ptStart, &vtStartDir) ;
|
||||
pCrvBezier->GetPointD1D2( 1, ICurve::FROM_PLUS, ptEnd, &vtEndDir) ;
|
||||
Plane3d plPLane ;
|
||||
plPLane.Set( ptStart, ptCtrl, ptEnd) ;
|
||||
vtStartDir.Rotate( plPLane.GetVersN(), 90) ;
|
||||
vtEndDir.Rotate( plPLane.GetVersN(), 90) ;
|
||||
vtStartDir.Rotate( vtN, 90) ;
|
||||
vtEndDir.Rotate( vtN, 90) ;
|
||||
Point3d ptAux1 = ptStart + vtStartDir ;
|
||||
Point3d ptAux2 = ptEnd + vtEndDir ;
|
||||
PtrOwner<CurveLine> pCL1( CreateBasicCurveLine()) ;
|
||||
@@ -929,7 +949,7 @@ ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
double dDist2 = Dist( ptEnd, ptCen) ;
|
||||
if ( abs(dDist1 - dDist2) < EPS_SMALL ) {
|
||||
CurveArc cArc ;
|
||||
cArc.SetC2PN( ptCen, ptStart, ptEnd, plPLane.GetVersN()) ;
|
||||
cArc.SetC2PN( ptCen, ptStart, ptEnd, vtN) ;
|
||||
// controllo se il raggio della circonferenza risultante coincide con quello calcolato prima
|
||||
// impongo inoltre che l'angolo al centro sia minore di 90 gradi
|
||||
if ( abs( cArc.GetRadius() - dDist1) < EPS_SMALL && cArc.GetAngCenter() < 90 + EPS_SMALL)
|
||||
@@ -973,7 +993,7 @@ ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
if ( ! bIsArc)
|
||||
pCrvCubic.Set( ApproxCurveBezierWithSingleCubic( pCrvPart)) ;
|
||||
else {
|
||||
pCrvCubic.Set( ApproxArcCurveBezierWithSingleCubic( pCrvPart, ptCen)) ;
|
||||
pCrvCubic.Set( ApproxArcCurveBezierWithSingleCubic( pCrvPart, ptCen, vtN)) ;
|
||||
if ( IsNull( pCrvCubic)) {
|
||||
// se fallisce allora riprovo usando più di una bezier
|
||||
bIsArc = false ;
|
||||
@@ -1012,8 +1032,13 @@ ApproxBezierWithCubics(const ICurveBezier* pCrvBezier, double dTol)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez)
|
||||
ApproxCurveBezierWithSingleCubic( const ICurve* pCrv)
|
||||
{
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBez = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBez == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
Point3d ptStart, ptEnd ;
|
||||
pCrvBez->GetStartPoint( ptStart) ;
|
||||
pCrvBez->GetEndPoint( ptEnd) ;
|
||||
@@ -1042,8 +1067,22 @@ ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d& ptCen)
|
||||
ApproxArcCurveBezierWithSingleCubic( const ICurve* pCrv, const Point3d& ptCen, const Vector3d& vtN)
|
||||
{
|
||||
// verifico sia una bezier
|
||||
const CurveBezier* pCrvBez = GetBasicCurveBezier( pCrv) ;
|
||||
if ( pCrvBez == nullptr)
|
||||
return nullptr ;
|
||||
|
||||
// mi metto nel frame della curva ( lavoro nel piano XY)
|
||||
Point3d ptStart = pCrvBez->GetControlPoint( 0) ;
|
||||
Point3d ptEnd = pCrvBez->GetControlPoint( 2) ;
|
||||
Frame3d frCrv; frCrv.Set( ptStart, vtN) ;
|
||||
ptStart = ORIG ;
|
||||
ptEnd.ToLoc( frCrv) ;
|
||||
Point3d ptCenLoc = ptCen ;
|
||||
ptCenLoc.ToLoc( frCrv) ;
|
||||
|
||||
// converto una curva di bezier che definisce un arco perfetto di circonferenza
|
||||
// dato il centro( della circonferenza), inizio e fine
|
||||
// N.B. : per archi con angolo al centro < 90
|
||||
@@ -1052,9 +1091,7 @@ ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d&
|
||||
bool bRat = pCrvBez->IsRational() ;
|
||||
if ( nDeg != 2 || ! bRat)
|
||||
return nullptr ;
|
||||
|
||||
Point3d ptStart = pCrvBez->GetControlPoint( 0) ;
|
||||
Point3d ptEnd = pCrvBez->GetControlPoint( 2) ;
|
||||
|
||||
if ( AreSamePointEpsilon( ptStart, ptEnd, EPS_SMALL * 50))
|
||||
return nullptr ;
|
||||
nDeg = 3 ;
|
||||
@@ -1064,10 +1101,10 @@ ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d&
|
||||
pCrvCubic->SetControlPoint( 3, ptEnd) ;
|
||||
// from the article of Aleksas Riškus "Approximation of a cubic bezier curve by circular arcs and vice versa"
|
||||
// with corrections from "Hans Muller's Flex Blog", page "More About Approximating Circular Arcs With a Cubic Bezier Path"
|
||||
double ax = ptStart.x - ptCen.x ;
|
||||
double ay = ptStart.y - ptCen.y ;
|
||||
double bx = ptEnd.x - ptCen.x ;
|
||||
double by = ptEnd.y - ptCen.y ;
|
||||
double ax = ptStart.x - ptCenLoc.x ;
|
||||
double ay = ptStart.y - ptCenLoc.y ;
|
||||
double bx = ptEnd.x - ptCenLoc.x ;
|
||||
double by = ptEnd.y - ptCenLoc.y ;
|
||||
double q1 = ax * ax + ay * ay ;
|
||||
double q2 = q1 + ax * bx + ay * by ;
|
||||
double k2 = 4. / 3 * ( sqrt( 2 * q1 * q2) - q2) / ( ax * by - ay * bx) ;
|
||||
@@ -1079,6 +1116,9 @@ ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d&
|
||||
pCrvCubic->SetControlPoint( 1, ptCtrl1) ;
|
||||
pCrvCubic->SetControlPoint( 2, ptCtrl2) ;
|
||||
|
||||
// ritorno nel frame originale
|
||||
pCrvCubic->ToGlob( frCrv) ;
|
||||
|
||||
return Release( pCrvCubic) ;
|
||||
}
|
||||
|
||||
@@ -1086,7 +1126,9 @@ ApproxArcCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez, const Point3d&
|
||||
ICurve*
|
||||
ApproxCurveWithBezier( const ICurve*, double dTol)
|
||||
{
|
||||
// interpolazione di punti con una curva bezier
|
||||
// campiono punti lungo la curva e poi li interpolo
|
||||
|
||||
// oppure faccio la fat curve e poi calcolo una bezier che stia all'interno di quella regione
|
||||
|
||||
PtrOwner<ICurveComposite> pCC( CreateBasicCurveComposite()) ;
|
||||
return Release( pCC) ;
|
||||
@@ -1262,7 +1304,7 @@ CurveToNoArcsCurve( const ICurve* pCrv)
|
||||
return nullptr ;
|
||||
// se arco, devo trasformarlo in curva di Bezier (semplice o composta)
|
||||
if ( pCrv->GetType() == CRV_ARC) {
|
||||
return ArcToBezierCurve( pCrv) ;
|
||||
return ArcToBezierCurve( GetCurveArc( pCrv)) ;
|
||||
}
|
||||
// se curva composita, devo trasformarla in composita senza archi
|
||||
else if ( pCrv->GetType() == CRV_COMPO) {
|
||||
|
||||
+1
-1
@@ -33,5 +33,5 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
|
||||
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
||||
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez) ;
|
||||
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurve* pCrv) ;
|
||||
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
||||
|
||||
@@ -369,6 +369,7 @@ CurveBezier::CopyFrom( const CurveBezier& cbSrc)
|
||||
return true ;
|
||||
if ( ! Init( cbSrc.m_nDeg, cbSrc.m_bRat))
|
||||
return false ;
|
||||
m_dParSing = cbSrc.m_dParSing ;
|
||||
m_vPtCtrl = cbSrc.m_vPtCtrl ;
|
||||
if ( cbSrc.m_bRat)
|
||||
m_vWeCtrl = cbSrc.m_vWeCtrl ;
|
||||
@@ -2383,3 +2384,11 @@ CurveBezier::IsALine( void) const
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
PNTVECTOR
|
||||
CurveBezier::GetAllControlPoints( void) const
|
||||
{
|
||||
PNTVECTOR vPntCtrl = m_vPtCtrl ;
|
||||
return vPntCtrl ;
|
||||
}
|
||||
@@ -153,6 +153,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
bool MakeRationalStandardForm( void) override ;
|
||||
bool MakeNonRational( double dTol) override ;
|
||||
bool IsALine( void) const override ;
|
||||
PNTVECTOR GetAllControlPoints( void) const ; // non aggiunta in interfaccia
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
|
||||
+1
-1
@@ -3046,7 +3046,7 @@ CurveComposite::ArcsToBezierCurves( void)
|
||||
// se arco, devo trasformare in una o più curve di Bezier
|
||||
if ( (*Iter)->GetType() == CRV_ARC) {
|
||||
// eseguo trasformazione
|
||||
PtrOwner<ICurve> pNewCrv( ArcToBezierCurve( (*Iter))) ;
|
||||
PtrOwner<ICurve> pNewCrv( ArcToBezierCurve( GetCurveArc( *Iter))) ;
|
||||
if ( IsNull( pNewCrv))
|
||||
return false ;
|
||||
// se risultato è singola curva
|
||||
|
||||
@@ -94,6 +94,8 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
{
|
||||
// Inizializzo distanza non calcolata
|
||||
m_dDist = - 1. ;
|
||||
// Vettore di indici dei triangoli più vicini inizialmente vuoto
|
||||
m_vnMinDistTriaIndex.clear() ;
|
||||
// Controllo se la superficie è chiusa
|
||||
m_bIsSurfClosed = tmSurf.IsClosed() ;
|
||||
|
||||
@@ -184,6 +186,10 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
if ( nMinDistTriaIndex == SVT_NULL)
|
||||
return ;
|
||||
|
||||
// Inizializzo il vettore dei triangoli a minima distanza
|
||||
for ( auto& Tria : vTria)
|
||||
m_vnMinDistTriaIndex.emplace_back( Tria.first) ;
|
||||
|
||||
// salvo la distanza minima
|
||||
m_dDist = dMinDist ;
|
||||
// salvo il punto a distanza minima
|
||||
@@ -279,6 +285,18 @@ DistPointSurfTm::GetMinDistTriaIndex( int& nMinDistIndex) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfTm::GetMinDistTriaIndices( INTVECTOR& vMinDistTriaIndex) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < - EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
vMinDistTriaIndex = m_vnMinDistTriaIndex ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GetSurfTmNearestVertex( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
||||
|
||||
+10
-1
@@ -159,11 +159,20 @@ InitFontManager( const string& sNfeFontDir, const string& sDefaultFont)
|
||||
{
|
||||
// recupero il font manager
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
|
||||
// lo inizializzo
|
||||
fntMgr.Init( sNfeFontDir, sDefaultFont) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
SetDefaultFont( const string& sDefaultFont)
|
||||
{
|
||||
// recupero il font manager
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
// imposto il dato
|
||||
fntMgr.SetDefaultFont( sDefaultFont) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const string&
|
||||
GetNfeFontDir( void)
|
||||
|
||||
Binary file not shown.
@@ -320,6 +320,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="IntersLineVolZmap.cpp" />
|
||||
<ClCompile Include="IntersPlaneVolZmap.cpp" />
|
||||
<ClCompile Include="IntersLineSurfBez.cpp" />
|
||||
<ClCompile Include="MultiGeomDB.cpp" />
|
||||
<ClCompile Include="SurfTriMeshOffset.cpp" />
|
||||
<ClCompile Include="VolZmapOffset.cpp" />
|
||||
<ClCompile Include="PolygonElevation.cpp" />
|
||||
@@ -340,6 +341,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneBox.h" />
|
||||
<ClInclude Include="..\Include\EGkIntersPlaneVolZmap.h" />
|
||||
<ClInclude Include="..\Include\EGkMultiGeomDB.h" />
|
||||
<ClInclude Include="..\Include\EGkPolygonElevation.h" />
|
||||
<ClInclude Include="..\Include\EGkQuaternion.h" />
|
||||
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
|
||||
|
||||
@@ -552,6 +552,9 @@
|
||||
<ClCompile Include="SurfTriMeshOffset.cpp">
|
||||
<Filter>File di origine\GeoOffset</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MultiGeomDB.cpp">
|
||||
<Filter>File di origine\Gdb</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -1235,6 +1238,9 @@
|
||||
<ClInclude Include="..\Include\EGkSurfTriMeshAux.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkMultiGeomDB.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+3
-1
@@ -29,6 +29,8 @@ class FontManager
|
||||
|
||||
public :
|
||||
bool Init( const std::string& sNfeFontDir, const std::string& sDefaultFont) ;
|
||||
bool SetDefaultFont( const std::string& sDefaultFont)
|
||||
{ m_sDefaultFont = sDefaultFont ; return true ; }
|
||||
bool SetCurrFont( const std::string& sFont, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance) ;
|
||||
const std::string& GetNfeFontDir( void) const
|
||||
@@ -54,7 +56,7 @@ class FontManager
|
||||
OsFont m_OsFont ;
|
||||
|
||||
private :
|
||||
FontManager( void) {}
|
||||
FontManager( void) : m_bCurrNfeFont( false) {}
|
||||
FontManager( FontManager const& copy) = delete ;
|
||||
FontManager& operator=( FontManager const& copy) = delete ;
|
||||
} ;
|
||||
|
||||
+2
-2
@@ -336,7 +336,7 @@ GdbGeo::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoe
|
||||
// curva originale
|
||||
ICurve* pCrv = GetCurve( m_pGeoObj) ;
|
||||
// trasformo in curva di Bezier (semplice o composta)
|
||||
ICurve* pCrvNew = ArcToBezierCurve( pCrv) ;
|
||||
ICurve* pCrvNew = ArcToBezierCurve( GetCurveArc( pCrv)) ;
|
||||
if ( pCrvNew == nullptr)
|
||||
return false ;
|
||||
// assegno alla nuova curva estrusione e spessore di quella originale
|
||||
@@ -389,7 +389,7 @@ GdbGeo::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDi
|
||||
if ( ! pArc->IsPlane() ||
|
||||
! AreSameOrOppositeVectorExact( pArc->GetNormVersor(), vtNorm)) {
|
||||
// trasformo in curva di Bezier (semplice o composta)
|
||||
ICurve* pCrvNew = ArcToBezierCurve( GetCurve( m_pGeoObj)) ;
|
||||
ICurve* pCrvNew = ArcToBezierCurve( GetCurveArc( m_pGeoObj)) ;
|
||||
if ( pCrvNew == nullptr)
|
||||
return false ;
|
||||
// assegno alla nuova curva estrusione e spessore di quella originale
|
||||
|
||||
+14
@@ -101,6 +101,20 @@ GdbObj::CopyFrom( const GdbObj* pSou)
|
||||
return ( CopyAttribsFrom( pSou) && CopyTextureDataFrom( pSou) && CopyUserObjFrom( pSou)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::CopyStippleDataFrom( const GdbObj* pSou)
|
||||
{
|
||||
// se l'oggetto sorgente non esiste
|
||||
if ( pSou == nullptr)
|
||||
return false ;
|
||||
// copio stipple
|
||||
m_nStpFactor = pSou->m_nStpFactor ;
|
||||
m_nStpPattern = pSou->m_nStpPattern ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbObj::CopyAttribsFrom( const GdbObj* pSou)
|
||||
|
||||
@@ -57,6 +57,7 @@ class GdbObj
|
||||
GdbObj( void) ;
|
||||
bool CopyFrom( const GdbObj* pSou) ;
|
||||
bool CopyAttribsFrom( const GdbObj* pSou) ;
|
||||
bool CopyStippleDataFrom( const GdbObj* pSou) ;
|
||||
bool CopyTextureDataFrom( const GdbObj* pSou) ;
|
||||
bool CopyUserObjFrom( const GdbObj* pSou) ;
|
||||
|
||||
|
||||
+6
-6
@@ -38,7 +38,7 @@ using namespace std ;
|
||||
class LockAddErase
|
||||
{
|
||||
public :
|
||||
LockAddErase(std::atomic_flag& bAddEraseOn, bool bUse = true): m_bAddEraseOn( bAddEraseOn), m_bUse( bUse)
|
||||
LockAddErase( atomic_flag& bAddEraseOn, bool bUse = true): m_bAddEraseOn( bAddEraseOn), m_bUse( bUse)
|
||||
{ if ( ! m_bUse) return ;
|
||||
while ( m_bAddEraseOn.test_and_set()) {
|
||||
this_thread::sleep_for( chrono::nanoseconds{ 1}) ;
|
||||
@@ -51,7 +51,7 @@ class LockAddErase
|
||||
} ;
|
||||
|
||||
private :
|
||||
std::atomic_flag& m_bAddEraseOn ;
|
||||
atomic_flag& m_bAddEraseOn ;
|
||||
bool m_bUse ;
|
||||
} ;
|
||||
|
||||
@@ -877,7 +877,7 @@ GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const
|
||||
// se ha il nome o la parte iniziale di nome cercato
|
||||
string sObjName ;
|
||||
if ( pGdbO->GetName( sObjName) &&
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
|
||||
return ( pGdbO->m_nId) ;
|
||||
// passo al successivo
|
||||
pGdbO = pGdbO->GetNext() ;
|
||||
@@ -905,7 +905,7 @@ GeomDB::GetNextName( int nId, const string& sName) const
|
||||
// se ha il nome o la parte iniziale di nome cercato
|
||||
string sObjName ;
|
||||
if ( pGdbNext->GetName( sObjName) &&
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
|
||||
return ( pGdbNext->m_nId) ;
|
||||
// passo al successivo
|
||||
pGdbNext = pGdbNext->GetNext() ;
|
||||
@@ -933,7 +933,7 @@ GeomDB::GetLastNameInGroup( int nGroupId, const string& sName) const
|
||||
// se ha il nome o la parte iniziale di nome cercato
|
||||
string sObjName ;
|
||||
if ( pGdbO->GetName( sObjName) &&
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
|
||||
return ( pGdbO->m_nId) ;
|
||||
// passo al precedente
|
||||
pGdbO = pGdbO->GetPrev() ;
|
||||
@@ -961,7 +961,7 @@ GeomDB::GetPrevName( int nId, const string& sName) const
|
||||
// se ha il nome o la parte iniziale di nome cercato
|
||||
string sObjName ;
|
||||
if ( pGdbPrev->GetName( sObjName) &&
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.find( sToFind) == 0)))
|
||||
(( ! bWild && sObjName == sToFind) || ( bWild && sObjName.rfind( sToFind, 0) == 0)))
|
||||
return ( pGdbPrev->m_nId) ;
|
||||
// passo al precedente
|
||||
pGdbPrev = pGdbPrev->GetPrev() ;
|
||||
|
||||
@@ -29,6 +29,8 @@ class GeomDB : public IGeomDB
|
||||
friend class GdbObj ;
|
||||
friend class GdbGroup ;
|
||||
friend class GdbGeo ;
|
||||
friend int CopyGeoObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob) ;
|
||||
friend int CopyGroupObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob) ;
|
||||
|
||||
public :
|
||||
~GeomDB( void) override ;
|
||||
|
||||
+265
-7
@@ -14,11 +14,17 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "CurveLine.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfFr.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfBez.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -67,11 +73,11 @@ 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)
|
||||
{
|
||||
if ( nILT == ILTT_IN || nILT == ILTT_EDGE || nILT == ILTT_VERT) {
|
||||
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) ;
|
||||
}
|
||||
else if ( nILT == ILTT_SEGM || nILT == ILTT_SEGM_ON_EDGE) {
|
||||
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) ;
|
||||
@@ -88,8 +94,8 @@ 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.nILTT == ILTT_SEGM || a.nILTT == ILTT_SEGM_ON_EDGE) ? ( a.dU + a.dU2) / 2 : a.dU) ;
|
||||
double dUb = ( ( b.nILTT == ILTT_SEGM || b.nILTT == ILTT_SEGM_ON_EDGE) ? ( b.dU + b.dU2) / 2 : b.dU) ;
|
||||
{ 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) ; }) ;
|
||||
}
|
||||
|
||||
@@ -146,7 +152,7 @@ IntersLineSurfBz( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
|
||||
double dCos = vtN * vtL ;
|
||||
double dCos2 = 0 ;
|
||||
// eventualmente ripeto tutto per ptI2 ( se ho un'intersezione con sovrapposizione)
|
||||
if ( InfoTm.nILTT == ILTT_SEGM || InfoTm.nILTT == ILTT_SEGM_ON_EDGE ) {
|
||||
if ( InfoTm.nILTT == ILTA_SEGM || InfoTm.nILTT == ILTA_SEGM_ON_EDGE ) {
|
||||
pSurfBz->UnprojectPointFromStm( InfoTm.nT, InfoTm.ptI2, ptSP2, InfoTm.nILTT) ;
|
||||
if ( ! RefineIntersNewton(ptL, vtL, dLen, bFinite, pSurfBz, ptSP2, ptIBz2) ) {
|
||||
int nVert[3] ;
|
||||
@@ -176,7 +182,7 @@ FilterLineSurfBzInters( const ILSBIVECTOR& vInfo, INTDBLVECTOR& vInters)
|
||||
// ciclo sulle intersezioni
|
||||
for ( const auto& Info : vInfo) {
|
||||
// se intersezione puntuale
|
||||
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
|
||||
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 ;
|
||||
@@ -185,7 +191,7 @@ FilterLineSurfBzInters( const ILSBIVECTOR& vInfo, INTDBLVECTOR& vInters)
|
||||
vInters.emplace_back( nFlag, Info.dU) ;
|
||||
}
|
||||
// se altrimenti intersezione con coincidenza
|
||||
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
|
||||
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) ;
|
||||
}
|
||||
@@ -232,3 +238,255 @@ FilterLineSurfBzInters( const ILSBIVECTOR& vInfo, INTDBLVECTOR& vInters)
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Intersezione di una linea con una superficie di Bezier
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
IntersLineSurfBzBilinear( 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 bilineare
|
||||
if( nDegU > 1 || nDegV > 1 || nSpanU > 1 || nSpanV > 1 || bRat)
|
||||
return false ;
|
||||
|
||||
int nInters = int( vInfo.size()) ;
|
||||
|
||||
PNTVECTOR vPntCtrl ;
|
||||
for( int p = 0 ; p < 4 ; ++p) {
|
||||
bool bOk = false ;
|
||||
vPntCtrl.push_back( pSurfBz->GetControlPoint( p, &bOk)) ;
|
||||
}
|
||||
|
||||
Vector3d a = vPntCtrl[3] - vPntCtrl[1] + ( vPntCtrl[0] - vPntCtrl[2]) ;
|
||||
Vector3d b = vPntCtrl[1] - vPntCtrl[0] ;
|
||||
Vector3d c = vPntCtrl[2] - vPntCtrl[0] ;
|
||||
Vector3d d = vPntCtrl[0] - ORIG ;
|
||||
|
||||
double A1 = a.x * vtL.z - a.z * vtL.x ;
|
||||
double B1 = b.x * vtL.z - b.z * vtL.x ;
|
||||
double C1 = c.x * vtL.z - c.z * vtL.x ;
|
||||
double A2 = a.y * vtL.z - a.z * vtL.y ;
|
||||
double B2 = b.y * vtL.z - b.z * vtL.y ;
|
||||
double C2 = c.y * vtL.z - c.z * vtL.y ;
|
||||
|
||||
double D1 = ( d.x - ptL.x) * vtL.z - ( d.z - ptL.z) * vtL.x ;
|
||||
double D2 = ( d.y - ptL.y) * vtL.z - ( d.z - ptL.z) * vtL.y ;
|
||||
|
||||
DBLVECTOR vdCoeff, vdRoots ;
|
||||
vdCoeff = { (B2 * D1 - B1 * D2), ( A2 * D1 - A1 * D2 + B2 * C1 - B1 * C2), ( A2 * C1 - A1 * C2)} ;
|
||||
int nRoots = PolynomialRoots( 2, vdCoeff, vdRoots) ;
|
||||
bool bFound = false ;
|
||||
for( int w = 0 ; w < nRoots ; ++w) {
|
||||
if ( vdRoots[w] > 0 - EPS_ZERO && vdRoots[w] < 1 + EPS_ZERO ) {
|
||||
double dU = 0, dV = 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( dV - vdRoots[k]) < EPS_PARAM ;
|
||||
if( ! bAlreadyFound) {
|
||||
dU = (dV * (C1 - C2) + ( D1 - D2)) / ( dV * ( A2 - A1) + ( B2 - B1)) ;
|
||||
if ( dU > - EPS_ZERO && dU < 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 ;
|
||||
UpdateInfoIntersLineSurfBz( ptL, vtL, ILTA_NO_TRIA, -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 ;
|
||||
}
|
||||
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2025-2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : MultiGeomDB.cpp Data : 08.10.25 Versione : 2.7j1
|
||||
// Contenuto : Implementazione delle funzioni tra due GeomDB.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 08.10.25 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "GeomDB.h"
|
||||
#include "/EgtDev/Include/EGkMultiGeomDB.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
CopyGeoObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob)
|
||||
{
|
||||
// verifico i puntatori ai GeomDB
|
||||
if ( pSouGDB == nullptr || pDstGDB == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero l'oggetto da copiare dal GeomDB sorgente
|
||||
PtrOwner<IGeoObj> pGObj( pSouGDB->GetGeoObj( nSouId)->Clone()) ;
|
||||
if ( IsNull( pGObj))
|
||||
return GDB_ID_NULL ;
|
||||
// se in globale
|
||||
if ( bGlob) {
|
||||
// recupero il riferimento del sorgente
|
||||
Frame3d frSou ;
|
||||
if ( ! pSouGDB->GetGlobFrame( nSouId, frSou))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
int nDestParentId = ( IS_GDB_SON( nSonBeforeAfter) ? nRefId : pDstGDB->GetParentId( nRefId)) ;
|
||||
if ( ! pDstGDB->GetGroupGlobFrame( nDestParentId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// porto la copia da riferimento sorgente a quello destinazione
|
||||
pGObj->LocToLoc( frSou, frDest) ;
|
||||
}
|
||||
// lo inserisco nel GeomDB destinazione
|
||||
int nNewId = pDstGDB->InsertGeoObj( nDestId, nRefId, nSonBeforeAfter, Release( pGObj)) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// copio le caratteristiche non geometriche
|
||||
const GdbObj* pSouGdbObj = pSouGDB->GetGdbObj( nSouId) ;
|
||||
GdbObj* pDstGdbObj = pDstGDB->GetGdbObj( nNewId) ;
|
||||
if ( pSouGDB == nullptr || pDstGdbObj == nullptr ||
|
||||
! pDstGdbObj->CopyAttribsFrom( pSouGdbObj) ||
|
||||
! pDstGdbObj->CopyTextureDataFrom( pSouGdbObj) ||
|
||||
! pDstGdbObj->CopyStippleDataFrom( pSouGdbObj) ||
|
||||
! pDstGdbObj->CopyUserObjFrom( pSouGdbObj)) {
|
||||
pDstGDB->Erase( nNewId) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
CopyGroupObj( const GeomDB* pSouGDB, int nSouId, GeomDB* pDstGDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob)
|
||||
{
|
||||
// recupero il riferimento del gruppo
|
||||
Frame3d frFrame ;
|
||||
pSouGDB->GetGroupFrame( nSouId) ;
|
||||
// se in globale
|
||||
if ( bGlob) {
|
||||
// recupero il riferimento del gruppo in globale
|
||||
if ( ! pSouGDB->GetGlobFrame( nSouId, frFrame))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
int nDestParentId = ( IS_GDB_SON( nSonBeforeAfter) ? nRefId : pDstGDB->GetParentId( nRefId)) ;
|
||||
if ( ! pDstGDB->GetGroupGlobFrame( nDestParentId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// porto la copia da riferimento sorgente a quello destinazione
|
||||
frFrame.ToLoc( frDest) ;
|
||||
}
|
||||
// inserisco un nuovo gruppo nel GeomDB destinazione
|
||||
int nNewId = pDstGDB->InsertGroup( nDestId, nRefId, nSonBeforeAfter, frFrame) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// copio le caratteristiche non geometriche
|
||||
const GdbObj* pSouGdbObj = pSouGDB->GetGdbObj( nSouId) ;
|
||||
GdbObj* pDstGdbObj = pDstGDB->GetGdbObj( nNewId) ;
|
||||
if ( pSouGDB == nullptr || pDstGdbObj == nullptr ||
|
||||
! pDstGdbObj->CopyAttribsFrom( pSouGdbObj) ||
|
||||
! pDstGdbObj->CopyTextureDataFrom( pSouGdbObj) ||
|
||||
! pDstGdbObj->CopyStippleDataFrom( pSouGdbObj) ||
|
||||
! pDstGdbObj->CopyUserObjFrom( pSouGdbObj)) {
|
||||
pDstGDB->Erase( nNewId) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
// copio gli eventuali figli
|
||||
int nSonSouId = pSouGDB->GetFirstInGroup( nSouId) ;
|
||||
while ( nSonSouId != GDB_ID_NULL) {
|
||||
// nuovo identificativo oggetto destinazione
|
||||
int nSonNewId = GDB_ID_NULL ;
|
||||
// recupero il tipo di oggetto sorgente
|
||||
int nSonSouType = pSouGDB->GetGdbType( nSonSouId) ;
|
||||
// se l'oggetto da copiare è geometrico
|
||||
if ( nSonSouType == GDB_TY_GEO)
|
||||
nSonNewId = CopyGeoObj( pSouGDB, nSonSouId, pDstGDB, GDB_ID_NULL, nNewId, GDB_LAST_SON, false) ;
|
||||
// se altrimenti è un gruppo
|
||||
else if ( nSonSouType == GDB_TY_GROUP)
|
||||
nSonNewId = CopyGroupObj( pSouGDB, nSonSouId, pDstGDB, GDB_ID_NULL, nNewId, GDB_LAST_SON, false) ;
|
||||
// se copia non riuscita, esco con errore
|
||||
if ( nSonNewId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// passo al figlio successivo
|
||||
nSonSouId = pSouGDB->GetNext( nSonSouId) ;
|
||||
}
|
||||
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
Copy( IGeomDB* pSouGeomDB, int nSouId, IGeomDB* pDestGeomDB, int nDestId, int nRefId, int nSonBeforeAfter, bool bGlob)
|
||||
{
|
||||
// adatto e verifico i GeomDB
|
||||
const GeomDB* pSouGDB = static_cast<GeomDB*>( pSouGeomDB) ;
|
||||
GeomDB* pDstGDB = static_cast<GeomDB*>( pDestGeomDB) ;
|
||||
if ( pSouGDB == nullptr || pDstGDB == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// nuovo identificativo oggetto destinazione
|
||||
int nNewId = GDB_ID_NULL ;
|
||||
// recupero il tipo di oggetto sorgente
|
||||
int nSouType = pSouGDB->GetGdbType( nSouId) ;
|
||||
// se l'oggetto da copiare è geometrico
|
||||
if ( nSouType == GDB_TY_GEO) {
|
||||
nNewId = CopyGeoObj( pSouGDB, nSouId, pDstGDB, nDestId, nRefId, nSonBeforeAfter, bGlob) ;
|
||||
}
|
||||
// se altrimenti è un gruppo
|
||||
else if ( nSouType == GDB_TY_GROUP) {
|
||||
nNewId = CopyGroupObj( pSouGDB, nSouId, pDstGDB, nDestId, nRefId, nSonBeforeAfter, bGlob) ;
|
||||
}
|
||||
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Copy( IGeomDB* pSouGeomDB, int nSouId, IGeomDB* pDestGeomDB, int nDestId, int nRefId, int nSonBeforeAfter)
|
||||
{
|
||||
return Copy( pSouGeomDB, nSouId, pDestGeomDB, nDestId, nRefId, nSonBeforeAfter, false) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
CopyGlob( IGeomDB* pSouGeomDB, int nSouId, IGeomDB* pDestGeomDB, int nDestId, int nRefId, int nSonBeforeAfter)
|
||||
{
|
||||
return Copy( pSouGeomDB, nSouId, pDestGeomDB, nDestId, nRefId, nSonBeforeAfter, true) ;
|
||||
}
|
||||
+330
-11
@@ -18,6 +18,8 @@
|
||||
#include "PolygonPlane.h"
|
||||
#include "PointsPCA.h"
|
||||
#include "GeoConst.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
@@ -796,7 +798,7 @@ PolyLine::RemoveAlignedPoints( double dToler)
|
||||
vInd.push_back( 0) ;
|
||||
if ( ! DouglasPeuckerSimplification( vPtU, dSqTol, 0, int( vPtU.size()) - 1, vInd))
|
||||
return false ;
|
||||
vInd.push_back( vPtU.size() - 1) ;
|
||||
vInd.push_back( int( vPtU.size()) - 1) ;
|
||||
}
|
||||
// altrimenti chiusa
|
||||
else {
|
||||
@@ -817,7 +819,7 @@ PolyLine::RemoveAlignedPoints( double dToler)
|
||||
vInd.push_back( nMaxInd) ;
|
||||
if ( ! DouglasPeuckerSimplification( vPtU, dSqTol, nMaxInd, int( vPtU.size()) - 1, vInd))
|
||||
return false ;
|
||||
vInd.push_back( vPtU.size() - 1) ;
|
||||
vInd.push_back( int( vPtU.size()) - 1) ;
|
||||
}
|
||||
|
||||
// ordino in senso crescente
|
||||
@@ -825,7 +827,7 @@ PolyLine::RemoveAlignedPoints( double dToler)
|
||||
|
||||
// se chiusa e almeno 4 punti rimasti, controllo allineamento dell'inizio con precedente e successivo rimasti
|
||||
if ( IsClosed() && vInd.size() >= 4) {
|
||||
if ( DistPointLine( vPtU[vInd[0]].first, vPtU[vInd[1]].first, vPtU[vInd[vInd.size()-2]].first).IsEpsilon( dToler)) {
|
||||
if ( DistPointLine( vPtU[vInd[0]].first, vPtU[vInd[1]].first, vPtU[vInd[int(vInd.size())-2]].first).IsEpsilon( dToler)) {
|
||||
vInd.erase( vInd.begin()) ;
|
||||
vInd.back() = vInd.front() ;
|
||||
}
|
||||
@@ -1445,7 +1447,7 @@ IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler
|
||||
}
|
||||
// Determino tangente di riferimento
|
||||
Vector3d vtTang ;
|
||||
// se minima distanza nell'estremo iniziale del segmento
|
||||
// se minima distanza nell'estremo iniziale del segmento
|
||||
if ( AreSamePointApprox( ptMinDist, prev( itMinDistEnd)->first)) {
|
||||
// direzione del segmento
|
||||
Vector3d vtCurrTg = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
@@ -1461,7 +1463,7 @@ IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler
|
||||
vtTang = vtPrevTg + vtCurrTg ;
|
||||
vtTang.Normalize() ;
|
||||
}
|
||||
// se altrimenti minima distanza nell'estremo finale del segmento
|
||||
// se altrimenti minima distanza nell'estremo finale del segmento
|
||||
else if ( AreSamePointApprox( ptMinDist, itMinDistEnd->first)) {
|
||||
// direzione del segmento
|
||||
Vector3d vtCurrTg = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
@@ -1477,7 +1479,7 @@ IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler
|
||||
vtTang = vtCurrTg + vtNextTg ;
|
||||
vtTang.Normalize() ;
|
||||
}
|
||||
// altrimenti minima distanza con l'interno
|
||||
// altrimenti minima distanza con l'interno
|
||||
else {
|
||||
vtTang = itMinDistEnd->first - prev( itMinDistEnd)->first ;
|
||||
}
|
||||
@@ -1612,8 +1614,9 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
||||
int nPnt2 = PL2.GetPointNbr() ;
|
||||
if ( nPnt1 == 0 || nPnt2 == 0)
|
||||
return false ;
|
||||
|
||||
bCommonInternalPoints = false ; // indica la presenza di punti interni in comune tra le due polylines
|
||||
|
||||
// indica la presenza di punti interni in comune tra le due polylines
|
||||
bCommonInternalPoints = false ;
|
||||
|
||||
vPnt1.reserve( PL1.GetPointNbr()) ;
|
||||
Point3d ptP1 ;
|
||||
@@ -1657,7 +1660,7 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
||||
nMinJ = nLastJ ;
|
||||
|
||||
// verifica se è un punto interno in comune con l'altra polyline
|
||||
if ( i < nTotP1 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL)
|
||||
if ( i < nTotP1 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL)
|
||||
bCommonInternalPoints = true ;
|
||||
|
||||
vPnt1[i].second = nMinJ ;
|
||||
@@ -1687,12 +1690,328 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
||||
if ( nMinI < nLastI)
|
||||
nMinI = nLastI ;
|
||||
|
||||
if ( j < nTotP2 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL)
|
||||
if ( j < nTotP2 - 1 && dDist < EPS_SMALL && abs( dMinDistPar - floor( dMinDistPar + 0.5)) < EPS_SMALL)
|
||||
bCommonInternalPoints = true ;
|
||||
|
||||
vPnt2[j].second = nMinI ;
|
||||
nLastI = nMinI ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MatchPolyLinesAddingPoints( const PolyLine& PL1, const PolyLine& PL2, int nType, PNTIVECTOR& vPnt1, PNTIVECTOR& vPnt2)
|
||||
{
|
||||
// prima trovo le associazioni senza aggiunte di punti
|
||||
Point3d ptP2 ;
|
||||
CurveComposite cc1, cc2 ;
|
||||
cc1.FromPolyLine( PL1) ;
|
||||
cc2.FromPolyLine( PL2) ;
|
||||
int nPnt1 = PL1.GetPointNbr() ;
|
||||
int nPnt2 = PL2.GetPointNbr() ;
|
||||
vector<POINTU> vMatch2 ;
|
||||
PL2.GetFirstPoint( ptP2) ;
|
||||
while ( PL2.GetNextPoint( ptP2, true)) {
|
||||
DistPointCurve dpc( ptP2, cc1, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
vMatch2.emplace_back( ptJoint, dParam) ;
|
||||
}
|
||||
|
||||
int nAtStart2 = 0 ; // match ripetuti dalla curva U0 allo start della curva U1
|
||||
int nAtEnd2 = 0 ;
|
||||
Point3d ptP1 ; PL1.GetFirstPoint( ptP1) ;
|
||||
int c = 0 ;
|
||||
int nRep1 = 0 ; // match interni consecutivi uguali di punti della curva U0 con punti della curva U1
|
||||
int nRep2 = 0 ;
|
||||
double dLastParamMatch = 0 ;
|
||||
Point3d ptLastPointMatch = ptP1 ;
|
||||
BOOLVECTOR vbRep1( nPnt1) ;
|
||||
INTVECTOR vnAddedOrNextIsRep1 ; // 0 non Rep, 1 Rep, 2 Next is Rep ;
|
||||
DBLVECTOR vdSplit1 ;
|
||||
DBLVECTOR vdMatch1 ;
|
||||
fill( vbRep1.begin(), vbRep1.end(), false) ;
|
||||
while ( PL1.GetNextPoint( ptP1, true)) {
|
||||
// devo salvarmi se matcho più punti con lo start o l'end della curva totale
|
||||
DistPointCurve dpc( ptP1, cc2, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
vdMatch1.push_back( dParam) ;
|
||||
if ( dParam < EPS_SMALL ) {
|
||||
++nAtStart2 ;
|
||||
vbRep1[c] = true ;
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
else if ( dParam > nPnt2 - EPS_SMALL ) {
|
||||
vbRep1[c] = nAtEnd2 == 0 ? false : true ;
|
||||
vbRep1.back() = true ;
|
||||
++ nAtEnd2 ;
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
if ( dParam <= dLastParamMatch || AreSamePointApprox( ptJoint, ptLastPointMatch)) {
|
||||
dParam = dLastParamMatch ;
|
||||
vbRep1[c] = true ;
|
||||
++ nRep1 ;
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
else {
|
||||
dLastParamMatch = dParam ;
|
||||
ptLastPointMatch = ptJoint ;
|
||||
// se sono già troppo vicino ad un split esistente allora non faccio nulla
|
||||
if ( abs(dParam - round( dParam)) < 100 * EPS_PARAM) {
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
vdSplit1.push_back( dParam) ;
|
||||
// verifico se ho un match per questo punto
|
||||
// in tal caso vuol dire che sto creando una ripetizione nRep1
|
||||
int nCase = 0 ;
|
||||
for ( int j = 0 ; j < int( vMatch2.size()) ; ++j) {
|
||||
if ( abs(vMatch2[j].second - (c + 1)) < EPS_SMALL) {
|
||||
// devo però verificare che non ci sia un match successivo, perché in quel caso non ho una ripetizione
|
||||
bool bFoundMatch = false ;
|
||||
for ( int z = int( vMatch2[j].second) ; z < int( vdMatch1.size()) ; ++z) {
|
||||
if ( abs( vdMatch1[z] - ( j + 1 )) < EPS_SMALL ) {
|
||||
bFoundMatch = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! bFoundMatch) {
|
||||
++ nRep2 ;
|
||||
// capisco se il punto è rep o se lo è il suo successivo
|
||||
if ( j + 1 < dParam)
|
||||
nCase = 1 ;
|
||||
else
|
||||
nCase = 2 ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
vnAddedOrNextIsRep1.push_back( nCase) ;
|
||||
}
|
||||
++c ;
|
||||
}
|
||||
int nAtStart1 = 0 ;
|
||||
int nAtEnd1 = 0 ;
|
||||
PL2.GetFirstPoint( ptP2) ;
|
||||
c = 0 ;
|
||||
dLastParamMatch = 0 ;
|
||||
ptLastPointMatch = ptP2 ;
|
||||
INTVECTOR vnAddedOrNextIsRep2 ; // 0 non Rep, 1 Rep, 2 Next is Rep ;
|
||||
DBLVECTOR vdSplit2 ;
|
||||
BOOLVECTOR vbRep2( nPnt2) ;
|
||||
fill( vbRep2.begin(), vbRep2.end(), false) ;
|
||||
while ( PL2.GetNextPoint( ptP2, true)) {
|
||||
DistPointCurve dpc( ptP2, cc1, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
if ( dParam < EPS_SMALL ) {
|
||||
++nAtStart1 ;
|
||||
vbRep2[c] = true ;
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
else if ( dParam > nPnt1 - EPS_SMALL ) {
|
||||
vbRep2[c] = ( nAtEnd1 == 0 ? false : true) ;
|
||||
vbRep2.back() = true ;
|
||||
++ nAtEnd1 ;
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
if ( dParam <= dLastParamMatch || AreSamePointApprox( ptJoint, ptLastPointMatch)) {
|
||||
dParam = dLastParamMatch ;
|
||||
vbRep2[c] = true ;
|
||||
++ nRep2 ;
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
else {
|
||||
dLastParamMatch = dParam ;
|
||||
ptLastPointMatch = ptJoint ;
|
||||
// se sono troppo vicino ad uno split esistente allora non faccio nulla
|
||||
if ( abs( dParam - round( dParam)) < 100 * EPS_PARAM) {
|
||||
++c ;
|
||||
continue ;
|
||||
}
|
||||
vdSplit2.push_back( dParam) ;
|
||||
// verifico se ho un match per questo punto
|
||||
// in tal caso vuol dire che sto creando una ripetizione nRep0
|
||||
int nCase = 0 ;
|
||||
for ( int j = 0 ; j < int( vdMatch1.size()) ; ++j) {
|
||||
if ( abs( vdMatch1[j] - (c + 1)) < EPS_SMALL) {
|
||||
// devo però verificare che non ci sia un match successivo, perché in quel caso non ho una ripetizione
|
||||
bool bFoundMatch = false ;
|
||||
for ( int z = int( vdMatch1[j]) ; z < int( vMatch2.size()) ; ++z) {
|
||||
if ( abs( vMatch2[z].second - ( j + 1 )) < EPS_SMALL) {
|
||||
bFoundMatch = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! bFoundMatch) {
|
||||
++nRep1 ;
|
||||
// capisco se il punto è rep o se lo è il suo successivo
|
||||
if ( j + 1 < dParam)
|
||||
nCase = 1 ;
|
||||
else
|
||||
nCase = 2 ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
vnAddedOrNextIsRep2.push_back( nCase) ;
|
||||
}
|
||||
++c ;
|
||||
}
|
||||
|
||||
// applico effettivamente gli split e aggiungo gli elementi ai vettori vbRep
|
||||
int nUnit = 0 ;
|
||||
if ( ! vdSplit1.empty())
|
||||
nUnit = int( vdSplit1.back()) ;
|
||||
for ( int z = int( vdSplit1.size()) - 1 ; z >= 0 ; --z) {
|
||||
double dSplit = vdSplit1[z] ;
|
||||
int nSplit = int( dSplit) ;
|
||||
// se sto cercando di fare uno split sulla stessa curva che ho già splittato al passaggio precedente allora devo
|
||||
// riscalare
|
||||
if ( nSplit == nUnit && z < int( vdSplit1.size()) - 1) {
|
||||
dSplit = nSplit + ( dSplit - nSplit) / ( vdSplit1[z+1] - nSplit) ;
|
||||
}
|
||||
nUnit = nSplit ;
|
||||
cc2.AddJoint( dSplit) ;
|
||||
switch ( vnAddedOrNextIsRep1[z]) {
|
||||
case 0 :
|
||||
if ( vbRep2[nSplit])
|
||||
++ nRep2 ;
|
||||
// di default aggiungerei false, ma se il successivo è già un Rep allora anche questo deve esserlo
|
||||
vbRep2.insert( vbRep2.begin() + nSplit, vbRep2[nSplit]) ;
|
||||
break ;
|
||||
case 1 :
|
||||
vbRep2.insert( vbRep2.begin() + nSplit, true) ;
|
||||
break ;
|
||||
case 2 :
|
||||
if ( vbRep2[nSplit])
|
||||
--nRep2 ;
|
||||
else
|
||||
vbRep2[nSplit] = true ;
|
||||
vbRep2.insert( vbRep2.begin() + nSplit, false) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( ! vdSplit2.empty())
|
||||
nUnit = int( vdSplit2.back()) ;
|
||||
for ( int z = int( vdSplit2.size()) - 1 ; z >= 0 ; --z) {
|
||||
double dSplit = vdSplit2[z] ;
|
||||
int nSplit = int( dSplit) ;
|
||||
// se sto cercando di fare uno split sulla stessa curva che ho già splittato al passaggio precedente allora devo
|
||||
// riscalare
|
||||
if ( nSplit == nUnit && z < int( vdSplit2.size()) - 1) {
|
||||
dSplit = nSplit + ( dSplit - nSplit) / (vdSplit2[z+1] - nSplit) ;
|
||||
}
|
||||
nUnit = nSplit ;
|
||||
cc1.AddJoint( dSplit) ;
|
||||
switch ( vnAddedOrNextIsRep2[z]) {
|
||||
case 0 :
|
||||
if ( vbRep1[nSplit])
|
||||
++ nRep1 ;
|
||||
// di default aggiungerei false, ma se il successivo è già un Rep allora anche questo deve esserlo
|
||||
vbRep1.insert( vbRep1.begin() + nSplit, vbRep1[nSplit]) ;
|
||||
break ;
|
||||
case 1 :
|
||||
vbRep1.insert( vbRep1.begin() + nSplit, true) ;
|
||||
break ;
|
||||
case 2 :
|
||||
if ( vbRep1[nSplit])
|
||||
-- nRep1 ;
|
||||
else
|
||||
vbRep1[nSplit] = true ;
|
||||
vbRep1.insert( vbRep1.begin() + nSplit, false) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
nPnt1 = cc1.GetCurveCount() ;
|
||||
nPnt2 = cc2.GetCurveCount() ;
|
||||
//aggiusto i vettori delle ripetizioni in modo in modo che non arrivino mai ad essere contemporaneamente true
|
||||
int nAddedSpan = 0 ;
|
||||
int nCrv1 = 0 ;
|
||||
int nCrv2 = 0 ;
|
||||
while ( nAddedSpan < nPnt1 + nAtStart1 + nAtEnd1 + nRep2) {
|
||||
if ( nCrv1 >= nPnt1)
|
||||
nCrv1 = nPnt1 - 1 ;
|
||||
if ( nCrv2 >= nPnt2)
|
||||
nCrv2 = nPnt2 - 1 ;
|
||||
bool bRep1 = vbRep1[nCrv1] ;
|
||||
bool bRep2 = vbRep2[nCrv2] ;
|
||||
if ( bRep1 && bRep2) {
|
||||
vbRep1[nCrv1] = false ;
|
||||
bRep1 = false ;
|
||||
vbRep2[nCrv2] = false ;
|
||||
bRep2 = false ;
|
||||
-- nRep1 ;
|
||||
-- nRep2 ;
|
||||
}
|
||||
if ( ! bRep1 || nCrv2 == nPnt2 - 1)
|
||||
++ nCrv2 ;
|
||||
if ( ! bRep2 || nCrv1 == nPnt1 - 1)
|
||||
++ nCrv1 ;
|
||||
++ nAddedSpan ;
|
||||
}
|
||||
// se non sono arrivato all'ultima curva su U0 o U1 vuol dire che ho creato delle ripetizioni che non ho contato prima
|
||||
if ( nCrv2 < nPnt2) {
|
||||
nRep2 += nPnt2 - nCrv2 ;
|
||||
for ( int z = int( vbRep2.size()) - 1 ; z >= nCrv2 ; --z)
|
||||
vbRep2[z] = true ;
|
||||
}
|
||||
if( nCrv1 < nPnt1) {
|
||||
nRep1 += nPnt1 - nCrv1 ;
|
||||
for ( int z = int( vbRep1.size()) - 1 ; z >= nCrv1 ; --z)
|
||||
vbRep1[z] = true ;
|
||||
}
|
||||
|
||||
// trovo il numero di span che dovrà avere la superficie
|
||||
// ( numero di sottocurve che compongono la U0 + tutte le ripetizioni dei match di punti della curva U1 con i punti di U0)
|
||||
int nPnt = nPnt1 + nAtStart1 + nAtEnd1 + nRep2 ;
|
||||
|
||||
if ( nPnt != nPnt2 + nAtStart2 + nAtEnd2 + nRep1)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "There could be an error in the creation of a ruled surface in mode RLT_B_MINDIST_PLUS") ;
|
||||
|
||||
// aggiungo i punti di controllo scorrendo in contemporanea le due curve
|
||||
nAddedSpan = 0 ;
|
||||
nCrv1 = 0 ;
|
||||
nCrv2 = 0 ;
|
||||
bool bLast1 = false ;
|
||||
bool bLast2 = false ;
|
||||
while ( nAddedSpan < nPnt) {
|
||||
if ( nCrv1 >= nPnt1) {
|
||||
nCrv1 = nPnt1 - 1 ;
|
||||
bLast1 = true ;
|
||||
}
|
||||
if ( nCrv2 >= nPnt2) {
|
||||
nCrv2 = nPnt2 - 1 ;
|
||||
bLast2 = true ;
|
||||
}
|
||||
bool bRep1 = vbRep1[nCrv1] ;
|
||||
bool bRep2 = vbRep2[nCrv2] ;
|
||||
const ICurve* pSubCrv1 = cc1.GetCurve( nCrv1) ;
|
||||
Point3d ptStart1 ; pSubCrv1->GetStartPoint( ptStart1) ;
|
||||
vPnt1.emplace_back( ptStart1, nAddedSpan) ;
|
||||
const ICurve* pSubCrv2 = cc2.GetCurve( nCrv2) ;
|
||||
Point3d ptStart2 ; pSubCrv2->GetStartPoint( ptStart2) ;
|
||||
vPnt2.emplace_back( ptStart2, nAddedSpan) ;
|
||||
if ( ! bRep2)
|
||||
++ nCrv1 ;
|
||||
if ( ! bRep1)
|
||||
++ nCrv2 ;
|
||||
++ nAddedSpan ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
+36
-13
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2023-2023
|
||||
// EgalTech 2023-2025
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ProjectCurveSurfTm.cpp Data : 16.11.23 Versione : 2.5kh3
|
||||
// File : ProjectCurveSurfTm.cpp Data : 29.08.25 Versione : 2.7h2
|
||||
// Contenuto : Implementazione funzioni proiezione curve su superficie Trimesh.
|
||||
//
|
||||
//
|
||||
@@ -40,6 +40,13 @@ const int P5AX_CONC = 3 ; // in angolo concavo
|
||||
const int P5AX_BEFORE_CONC = 4 ; // adiacente ad angolo concavo
|
||||
const int P5AX_AFTER_CONC = 5 ; // adiacente ad angolo concavo
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static double
|
||||
GetSurfBezierTol( double dLinTol)
|
||||
{
|
||||
return max( dLinTol / 10, EPS_SMALL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext, double dSqTol)
|
||||
@@ -154,7 +161,8 @@ RemovePointsInExcess( PNT5AXVECTOR& vPt5ax, double dLinTol, double dMaxSegmLen,
|
||||
return true ;
|
||||
}
|
||||
|
||||
typedef std::vector<IntersParLinesSurfTm*> INTPARLINESTMPVECTOR ; // vettore di oggetti intersezione massiva rette parallele SurfTM
|
||||
// --- vettore di oggetti intersezione massiva rette parallele SurfTM --------
|
||||
typedef std::vector<IntersParLinesSurfTm*> INTPARLINESTMPVECTOR ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
@@ -230,8 +238,11 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const Vect
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
{ double dOldLinTol = GetSurfBezierAuxSurfRefinedTol() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( GetSurfBezierTol( dLinTol)) ;
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurfRefined() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( dOldLinTol) ;
|
||||
} break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
@@ -440,8 +451,11 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const IGeo
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
{ double dOldLinTol = GetSurfBezierAuxSurfRefinedTol() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( GetSurfBezierTol( dLinTol)) ;
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurfRefined() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( dOldLinTol) ;
|
||||
} break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
@@ -593,8 +607,11 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ICur
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
{ double dOldLinTol = GetSurfBezierAuxSurfRefinedTol() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( GetSurfBezierTol( dLinTol)) ;
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurfRefined() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( dOldLinTol) ;
|
||||
} break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
@@ -804,8 +821,11 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ISur
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
{ double dOldLinTol = GetSurfBezierAuxSurfRefinedTol() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( GetSurfBezierTol( dLinTol)) ;
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurfRefined() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( dOldLinTol) ;
|
||||
} break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
@@ -824,8 +844,11 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf, const ISur
|
||||
pRefTm = GetBasicSurfTriMesh( &sfRef) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
pRefTm = GetBasicSurfBezier( &sfRef)->GetAuxSurf() ;
|
||||
break ;
|
||||
{ double dOldLinTol = GetSurfBezierAuxSurfRefinedTol() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( GetSurfBezierTol( dLinTol)) ;
|
||||
pRefTm = GetBasicSurfBezier( &sfRef)->GetAuxSurfRefined() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( dOldLinTol) ;
|
||||
} break ;
|
||||
case SRF_FLATRGN :
|
||||
pRefTm = GetBasicSurfFlatRegion( &sfRef)->GetAuxSurf() ;
|
||||
break ;
|
||||
|
||||
+22
-8
@@ -48,7 +48,16 @@ using namespace std ;
|
||||
GEOOBJ_REGISTER( SRF_BEZIER, NGE_S_BEZ, SurfBezier) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct PairHashIntInt {
|
||||
size_t operator()(const pair<int, int>& key) const {
|
||||
size_t h1 = hash<int>{}( key.first) ;
|
||||
size_t h2 = hash<int>{}( key.second) ;
|
||||
return h1 ^ ( h2 << 1) ; // Combine hashes
|
||||
}
|
||||
};
|
||||
static unordered_map<INTINT, DBLVECTOR, PairHashIntInt> s_mBernCache ; // mappa dei polinomi di bernstein
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static double s_dAuxSurfTol = 200 * EPS_SMALL ;
|
||||
static double s_dAuxSurfRefinedTol = 50 * EPS_SMALL ;
|
||||
|
||||
@@ -2162,7 +2171,7 @@ bool
|
||||
SurfBezier::IncreaseUV( double& dUV, double dxy, bool bUOrV, double* dUVCopy, bool bModifyOrig) const
|
||||
{
|
||||
double dUVTest ;
|
||||
if (dUVCopy == nullptr && !bModifyOrig)
|
||||
if ( dUVCopy == nullptr && ! bModifyOrig)
|
||||
return false ;
|
||||
if ( dUVCopy != nullptr) {
|
||||
*dUVCopy = dUV + dxy ;
|
||||
@@ -2175,15 +2184,15 @@ SurfBezier::IncreaseUV( double& dUV, double dxy, bool bUOrV, double* dUVCopy, bo
|
||||
|
||||
if ( bUOrV) {
|
||||
if ( dUVTest < 0)
|
||||
dUVTest = 0 ;
|
||||
dUVTest = 0 ;
|
||||
else if ( dUVTest > m_nSpanU * SBZ_TREG_COEFF )
|
||||
dUVTest = m_nSpanU * SBZ_TREG_COEFF ;
|
||||
dUVTest = m_nSpanU * SBZ_TREG_COEFF ;
|
||||
}
|
||||
else {
|
||||
if ( dUVTest < 0)
|
||||
dUVTest = 0 ;
|
||||
dUVTest = 0 ;
|
||||
else if ( dUVTest > m_nSpanV * SBZ_TREG_COEFF )
|
||||
dUVTest = m_nSpanV * SBZ_TREG_COEFF ;
|
||||
dUVTest = m_nSpanV * SBZ_TREG_COEFF ;
|
||||
}
|
||||
if ( bModifyOrig)
|
||||
dUV = dUVTest ;
|
||||
@@ -2849,7 +2858,6 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
// se sono in polo e mi hanno passato un punto precedente allora devo prendere il triangolo di quel punto
|
||||
bool bIsPole = false ;
|
||||
bool bNearPole = false ; // devo capire se il triangolo di riferimento ha un vertice in un polo
|
||||
int nInters = 0 ;
|
||||
INTVECTOR vInters(4) ;
|
||||
fill( vInters.begin(), vInters.end(), 0) ;
|
||||
// se il vettore dei poli non è stato riempito vuol dire che quando è stata creata la superficie non è stata chiamata la funzione CalcPoles
|
||||
@@ -2867,11 +2875,9 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
vInters[c] = AreSamePointApprox( pt, ptI) ? 1 : 0 ;
|
||||
if ( vInters[c] == 1)
|
||||
bIsPole = true ;
|
||||
nInters += vInters[c] ;
|
||||
}
|
||||
else {
|
||||
vInters[c] = m_mCCEdge[c][i]->IsPointOn(ptI) ? 1 : 0 ;
|
||||
nInters += vInters[c] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5389,3 +5395,11 @@ SurfBezier::CreateBySetOfCurves( const ICURVEPOVECTOR& vCrvBez, bool bReduceToDe
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
PNTVECTOR
|
||||
SurfBezier::GetAllControlPoints( void) const
|
||||
{
|
||||
PNTVECTOR vPntCtrl = m_vPtCtrl ;
|
||||
return vPntCtrl ;
|
||||
}
|
||||
|
||||
+3
-13
@@ -22,17 +22,6 @@
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||
|
||||
using namespace std ;
|
||||
class Tree ;
|
||||
|
||||
struct PairHashIntInt {
|
||||
std::size_t operator()(const std::pair<int, int>& key) const {
|
||||
std::size_t h1 = std::hash<int>{}(key.first);
|
||||
std::size_t h2 = std::hash<int>{}(key.second);
|
||||
return h1 ^ (h2 << 1); // Combine hashes
|
||||
}
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
{
|
||||
@@ -157,6 +146,7 @@ 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 ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -168,7 +158,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
|
||||
public :
|
||||
SurfBezier( void) ;
|
||||
SurfBezier( const SurfBezier& sbSrc)
|
||||
SurfBezier( const SurfBezier& sbSrc) : m_pSTM( nullptr), m_pSTMRefined( nullptr), m_pTrimReg(nullptr)
|
||||
{ if ( ! CopyFrom( sbSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "SurfBezier : copy constructor error") }
|
||||
SurfBezier& operator =( const SurfBezier& sbSrc)
|
||||
@@ -238,7 +228,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable vector<ICRVCOMPOPOVECTOR> m_mCCEdge ; // vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
|
||||
mutable std::vector<ICRVCOMPOPOVECTOR> m_mCCEdge ; // vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
|
||||
mutable ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
|
||||
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
|
||||
mutable DBLVECTOR m_vBernU ;
|
||||
|
||||
+2
-1
@@ -56,6 +56,7 @@ SurfFlatRegion::Clear( void)
|
||||
for ( auto& pLoop : m_vpLoop)
|
||||
delete pLoop ;
|
||||
m_vpLoop.clear() ;
|
||||
m_vExtInd.clear() ;
|
||||
|
||||
m_nTempProp[0] = 0 ;
|
||||
m_nTempProp[1] = 0 ;
|
||||
@@ -827,7 +828,7 @@ SurfFlatRegion::ConvertArcsToBezierCurves( void)
|
||||
// ciclo sui loop
|
||||
for ( auto& pLoop : m_vpLoop) {
|
||||
if ( pLoop->GetType() == CRV_ARC) {
|
||||
ICurve* pCrvNew = ArcToBezierCurve( pLoop) ;
|
||||
ICurve* pCrvNew = ArcToBezierCurve( GetCurveArc(pLoop)) ;
|
||||
if ( pCrvNew == nullptr)
|
||||
return false ;
|
||||
delete pLoop ;
|
||||
|
||||
@@ -3637,6 +3637,18 @@ SurfTriMesh::Invert( void)
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i)
|
||||
InvertTriangle( i) ;
|
||||
|
||||
// se bordi della sfaccettatura validi
|
||||
if ( m_bFacEdged) {
|
||||
for ( int nE = 0 ; nE < GetEdgeCount() ; ++ nE) {
|
||||
// inversione dei vertici nel vettore delle sfaccettature
|
||||
swap( m_vFacEdge[nE].nIdVert[0], m_vFacEdge[nE].nIdVert[1]) ;
|
||||
// inversione delle adiacenze nel vettore delle sfaccettature
|
||||
swap( m_vFacEdge[nE].nIdFacAdj[0], m_vFacEdge[nE].nIdFacAdj[1]) ;
|
||||
// inversione dell'angolo interno
|
||||
m_vFacEdge[nE].dIntAng *= -1. ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+135
-9
@@ -15,8 +15,21 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "VolZmap.h"
|
||||
#include "SurfTriMesh.h"
|
||||
#include "EgtDev/Include/EGkDistPointSurfTm.h"
|
||||
#include "\EgtDev\Include\EGkSurfTriMeshAux.h"
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include "/EgtDev/Include/EGkGeoObjSave.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EGkStmStandard.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
std::vector<IGeoObj*> VT ;
|
||||
std::vector<Color> VC ;
|
||||
#endif
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -73,20 +86,131 @@ CreateSurfTriMeshesOffset( const CISURFTMPVECTOR& vStm, double dOffs, double dPr
|
||||
if ( vStm.empty())
|
||||
return nullptr ;
|
||||
// controllo sul valore di tolleranza lineare
|
||||
double dMyPrec = max( dPrec, 100 * EPS_SMALL) ;
|
||||
double dMyPrec = max( dPrec, 100. * EPS_SMALL) ;
|
||||
// --- NB. ( Il valore di Offset deve essere maggiore di 10 * EPS_SMALL in valore assoluto)
|
||||
// Nel caso sia minore, restituisco semplicemente la somma delle superfici
|
||||
// ( questo valore serve per rimanere coerente con l'Offset delle curve)
|
||||
if ( abs( dOffs) < 10 * EPS_SMALL)
|
||||
if ( abs( dOffs) < 10. * EPS_SMALL)
|
||||
return SumStm( vStm) ;
|
||||
|
||||
// creo lo Zmap associato alle superfici TriMesh
|
||||
PtrOwner<IVolZmap> pVolZmap( CreateVolZmap()) ;
|
||||
if ( IsNull( pVolZmap) || ! pVolZmap->CreateFromTriMeshOffset( vStm, dOffs, dMyPrec, nType))
|
||||
VolZmap OneVolZmap ;
|
||||
if ( ! OneVolZmap.CreateFromTriMeshOffset( vStm, dOffs, dMyPrec, nType))
|
||||
return nullptr ;
|
||||
if ( ! OneVolZmap.IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// restituisco la superficie TriMesh
|
||||
return ( pVolZmap->GetSurfTriMesh()) ;
|
||||
// recupero le superfici aperte
|
||||
CISURFTMPVECTOR vStmOpen ;
|
||||
for ( const ISurfTriMesh* pStm : vStm) {
|
||||
if ( pStm != nullptr && pStm->IsValid() && ! pStm->IsClosed())
|
||||
vStmOpen.emplace_back( pStm) ;
|
||||
}
|
||||
|
||||
// --- se non ho superfici aperte
|
||||
if ( vStmOpen.empty()) {
|
||||
// restituisco la superficie TriMesh di Offset
|
||||
return ( OneVolZmap.GetSurfTriMesh()) ;
|
||||
}
|
||||
|
||||
// --- se ho delle superfici aperte
|
||||
// lo Zmap creato è orientato e definisce una superficie chiusa; devo rimuovere i triangoli in eccesso
|
||||
|
||||
// anzitutto controllo che lo Zmap sia valido
|
||||
if ( ! OneVolZmap.IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// inzializzo la superficie TriMesh da restituire
|
||||
PtrOwner<SurfTriMesh> pStm( CreateBasicSurfTriMesh()) ;
|
||||
if ( IsNull( pStm) || ! pStm->Init( 3, 1))
|
||||
return nullptr ;
|
||||
PointGrid3d VertGrid ; VertGrid.Init( 50000) ;
|
||||
|
||||
// tolleranza di vicinanza alla superficie
|
||||
double dTolDist = 30. * EPS_SMALL ;
|
||||
|
||||
#if DEBUG
|
||||
VT.emplace_back( OneVolZmap.Clone()) ;
|
||||
VC.emplace_back( BLACK) ;
|
||||
#endif
|
||||
|
||||
// ciclo lungo i blocchi dello ZMap
|
||||
for ( int nB = 0 ; nB < OneVolZmap.GetBlockCount() ; ++ nB) {
|
||||
|
||||
// recupero i triangoli
|
||||
TRIA3DEXVECTOR vTria, vTriaSafe ;
|
||||
OneVolZmap.GetBlockTriangles( nB, vTria) ;
|
||||
|
||||
// un triangolo viene ritenuto valido se è non è troppo vicino ( dOffs) alle superfici aperte
|
||||
for ( int nT = 0 ; nT < int( vTria.size()) ; ++ nT) {
|
||||
|
||||
// recupero il triangolo
|
||||
Triangle3dEx& Tria = vTria[nT] ;
|
||||
|
||||
// scorro le superficie aperte
|
||||
bool bInsert = true ;
|
||||
for ( int nS = 0 ; bInsert && nS < int( vStm.size()) ; ++ nS) {
|
||||
|
||||
// controllo se posso inserirlo
|
||||
vector<DistPointSurfTm> vDistPtStm ;
|
||||
for ( int i = 0 ; i < 3 && bInsert ; ++ i) {
|
||||
double dDist = 0. ;
|
||||
vDistPtStm.emplace_back( DistPointSurfTm( Tria.GetP( i), *vStm[nS])) ;
|
||||
bInsert = ( vDistPtStm.back().GetDist( dDist) && dDist > abs( dOffs) - dTolDist) ;
|
||||
}
|
||||
// se il triangolo è al più a distanza di |dOffs| - dTolDist
|
||||
if ( bInsert) {
|
||||
// recupero i triangoli a distanza minima dai vertici del triangolo corrente
|
||||
bool bPerp = true ;
|
||||
for ( int i = 0 ; i < 3 && bPerp ; ++ i) {
|
||||
INTVECTOR vTria ;
|
||||
vDistPtStm[i].GetMinDistTriaIndices( vTria) ;
|
||||
for ( int j = 0 ; j < int( vTria.size()) && bPerp ; ++ j) {
|
||||
Triangle3d TriaCloser ;
|
||||
vStm[nS]->GetTriangle( vTria[j], TriaCloser) ;
|
||||
bPerp = ( abs( Tria.GetN() * TriaCloser.GetN()) < dTolDist) ;
|
||||
}
|
||||
}
|
||||
// se tutti i triangoli a distanza minima sono perpendicolari, allora non lo inserisco
|
||||
bInsert = ( ! bPerp) ;
|
||||
}
|
||||
}
|
||||
|
||||
// se triangolo da inserire
|
||||
if ( bInsert)
|
||||
vTriaSafe.emplace_back( Tria) ;
|
||||
|
||||
#if DEBUG
|
||||
ICurveComposite* pCompo = CreateCurveComposite() ;
|
||||
pCompo->AddPoint( Tria.GetP( 0)) ;
|
||||
pCompo->AddLine( Tria.GetP( 1)) ;
|
||||
pCompo->AddLine( Tria.GetP( 2)) ;
|
||||
pCompo->Close() ;
|
||||
Color myCol = ( bInsert ? Color( 0., 1., 0., .5) : Color( 1., 0., 0., .5)) ;
|
||||
VT.emplace_back( CloneCurveComposite( pCompo)) ;
|
||||
VC.emplace_back( myCol) ;
|
||||
ISurfFlatRegion* pSfrTria = CreateSurfFlatRegion() ;
|
||||
pSfrTria->AddExtLoop( pCompo) ;
|
||||
VT.emplace_back( pSfrTria) ;
|
||||
VC.emplace_back( myCol) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// inserisco tutti i triangoli validi
|
||||
if ( ! pStm->AddTriaFromZMap( vTriaSafe, VertGrid))
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
SaveGeoObj( VT, VC, "C:\\Temp\\TriangleSelection.nge") ;
|
||||
#endif
|
||||
|
||||
|
||||
// sistemo la topologia
|
||||
if ( ! pStm->AdjustTopologyFromZMap())
|
||||
return nullptr ;
|
||||
|
||||
return ( Release( pStm)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -107,10 +231,12 @@ CreateSurfTriMeshesThickeningOffset( const CISURFTMPVECTOR& vStm, double dOffs,
|
||||
return SumStm( vStm) ;
|
||||
|
||||
// creo lo Zmap associato alle superfici TriMesh
|
||||
PtrOwner<IVolZmap> pVolZmap( CreateVolZmap()) ;
|
||||
if ( IsNull( pVolZmap) || ! pVolZmap->CreateFromTriMeshThickeningOffset( vStm, dOffs, dMyPrec, nType))
|
||||
VolZmap OneVolZmap ;
|
||||
if ( ! OneVolZmap.CreateFromTriMeshThickeningOffset( vStm, dOffs, dMyPrec, nType))
|
||||
return nullptr ;
|
||||
if ( ! OneVolZmap.IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// restituisco la superficie TriMesh
|
||||
return ( pVolZmap->GetSurfTriMesh()) ;
|
||||
return ( OneVolZmap.GetSurfTriMesh()) ;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ Tree::GetPoint( double dU, double dV, Point3d& ptP) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Tree::SavePoint( double dU, double dV, Point3d& ptP)
|
||||
Tree::SavePoint( double dU, double dV, const Point3d& ptP)
|
||||
{
|
||||
pair<int64_t, int64_t> key( int64_t( GetHalfKey( dU)), int64_t( GetHalfKey( dV))) ;
|
||||
if ( m_mPt3d.find( key) == m_mPt3d.end())
|
||||
@@ -727,7 +727,12 @@ Tree::BuildTree( double dLinTol, double dSideMin, double dSideMax)
|
||||
// se la cella è abbastanza grande da poter essere divisa ancora, calcolo l'errore di approssimazione
|
||||
// ( dSideMinVal è zero se entrambi i lati da splittare sono collassati in un punto, controllo dLengMinVal)
|
||||
bool bSplit = false ;
|
||||
bool bDimOk = ( dSideMinVal / 2 >= dSideMin || ( dSideMinVal < EPS_SMALL && dLengMinVal / 2 >= dSideMin)) ;
|
||||
bool bParamDimOk = false ;
|
||||
if( bVert)
|
||||
bParamDimOk = ( pcToSplit->GetTopRight().x - pcToSplit->GetBottomLeft().x) / 2 > 100 * EPS_PARAM ;
|
||||
else
|
||||
bParamDimOk = ( pcToSplit->GetTopRight().y - pcToSplit->GetBottomLeft().y) / 2 > 100 * EPS_PARAM ;
|
||||
bool bDimOk = ( dSideMinVal / 2 >= dSideMin || ( dSideMinVal < EPS_SMALL && dLengMinVal / 2 >= dSideMin)) && bParamDimOk ;
|
||||
if ( dSideMaxVal > dSideMax) {
|
||||
bSplit = true ;
|
||||
//LOG_DBG_INFO( GetEGkLogger(), " Split by SideMax")
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <utility>
|
||||
|
||||
struct PairHashInt64 {
|
||||
size_t operator()(const pair<int64_t, int64_t>& key) const {
|
||||
size_t operator()(const std::pair<int64_t, int64_t>& key) const {
|
||||
size_t h1 = std::hash<int64_t>{}(key.first) ;
|
||||
size_t h2 = std::hash<int64_t>{}(key.second) ;
|
||||
return h1 ^ (h2 << 1); // Combine hashes
|
||||
@@ -251,12 +251,12 @@ class Tree
|
||||
bool BuildTree( double dLinTol = LIN_TOL_STD,
|
||||
double dSideMin = 1, // è la minima lunghezza del lato di una cella
|
||||
double dSideMax = INFINITO) ; // è la massima dimensione di un triangolo della trimesh
|
||||
bool GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d, vector<ICRVCOMPOPOVECTOR>& vCCEdges3D, ICRVCOMPOPOVECTOR& vCCLoops) ;
|
||||
bool GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d, std::vector<ICRVCOMPOPOVECTOR>& vCCEdges3D, ICRVCOMPOPOVECTOR& vCCLoops) ;
|
||||
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, POLYLINEVECTOR& vPolygonsCorrected, POLYLINEVECTOR& vPolygons3d) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
|
||||
// ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
|
||||
// ad alcuni poligoni potrebbero venire tolti dei punti per evitare errori dovuti ad eventuali poli sui bordi del parametrico
|
||||
bool GetLeaves( std::vector<Cell>& vLeaves) const ; // restituisce gli indici delle foglie nell'albero
|
||||
bool GetEdges3D ( vector<ICRVCOMPOPOVECTOR>& mCCEdge, POLYLINEVECTOR& vPolygons) ; // restituisce gli edge 3D come polyline
|
||||
bool GetEdges3D( std::vector<ICRVCOMPOPOVECTOR>& mCCEdge, POLYLINEVECTOR& vPolygons) ; // restituisce gli edge 3D come polyline
|
||||
bool GetSplitLoops( ICRVCOMPOPOVECTOR& vCCLoopSplit) const // restituisce i loop splitatti ai confini delle celle
|
||||
{ for ( int i = 0 ; i < int( m_vCCLoop2D.size()); ++i)
|
||||
vCCLoopSplit.emplace_back( m_vCCLoop2D[i]->Clone()) ;
|
||||
@@ -306,14 +306,14 @@ class Tree
|
||||
bool UpdateSplitLoop( ICurveComposite* pCC, Point3d& pt) ;
|
||||
bool VerifyLoopOrientation( ICURVEPLIST& vpCrv, BOOLVECTOR& vbOrientation) const ; // verifico l'orientazione ( CCW o CW) delle polyline in base a come sono contenute le une nelle altre
|
||||
bool AdjustLoop( PolyLine& pl, POLYLINEVECTOR& vPl, BOOLVECTOR& vbOrientation) const ;
|
||||
bool GetPoint(double dU, double dV, Point3d& pt) const ;
|
||||
bool SavePoint( double dU, double dV, Point3d& pt) ;
|
||||
bool GetPoint(double dU, double dV, Point3d& ptP) const ;
|
||||
bool SavePoint( double dU, double dV, const Point3d& ptP) ;
|
||||
|
||||
private :
|
||||
const SurfBezier* m_pSrfBz ; // superficie di bezier
|
||||
bool m_bTrimmed ; // superficie trimmata
|
||||
unordered_map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
|
||||
vector<tuple<PolyLine,bool>> m_vPlApprox ; // vettore contenente le approssimazioni dei loop // il bool indica se la curva è CCW
|
||||
std::unordered_map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
|
||||
std::vector<std::tuple<PolyLine,bool>> m_vPlApprox ; // vettore contenente le approssimazioni dei loop // il bool indica se la curva è CCW
|
||||
bool m_bBilinear ; // superficie bilineare
|
||||
bool m_bMulti ; // superficie multi-patch
|
||||
bool m_bClosedU ; // superficie chiusa lungo il parametro U
|
||||
@@ -323,10 +323,10 @@ class Tree
|
||||
int m_nDegV ; // grado della superficie nel parametro V
|
||||
int m_nSpanU ; // numero di span lungo il parametro U
|
||||
int m_nSpanV ; // numero di span lungo il parametro V
|
||||
unordered_map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root
|
||||
mutable unordered_map<pair<int64_t,int64_t>,Point3d,PairHashInt64> m_mPt3d ; // mappa che contiene tutti i punti 3d della superficie calcolati (la chiave sono le coordinate, moltiplicate per 2^24 e trasformate in int)
|
||||
std::unordered_map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root
|
||||
mutable std::unordered_map<std::pair<int64_t,int64_t>,Point3d,PairHashInt64> m_mPt3d ; // mappa che contiene tutti i punti 3d della superficie calcolati (la chiave sono le coordinate, moltiplicate per 2^24 e trasformate in int)
|
||||
INTVECTOR m_vnLeaves ; // vettore delle foglie
|
||||
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
|
||||
ICRVCOMPOPOVECTOR m_vCCLoop2D ; // vettore che contiene le CurveCompo che rappresentano i loop di trim tenendo conto della divisione in celle
|
||||
vector<pair<BIPNTVECTOR, ChainCurves>> m_vCEdge2D ; // vettore che le chain che rappresentano ciò che resta degli edge originali, tenendo conto dei trim.
|
||||
std::vector<std::pair<BIPNTVECTOR, ChainCurves>> m_vCEdge2D ; // vettore che le chain che rappresentano ciò che resta degli edge originali, tenendo conto dei trim.
|
||||
} ;
|
||||
+217
-124
@@ -1,4 +1,4 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2016
|
||||
//----------------------------------------------------------------------------
|
||||
// File : VolZmap.cpp Data : 22.01.15 Versione : 1.6a4
|
||||
@@ -563,10 +563,10 @@ VolZmap::GetPartLocalBBox( int nPart, BBox3d& b3Loc, int nFlag) const
|
||||
// Verifico lo stato.
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// Se una sola mappa o il numero di componenti è indefinito, vi è un errore.
|
||||
// Se una sola mappa o il numero di componenti è indefinito, vi è un errore.
|
||||
if ( m_nMapNum == 1 || m_nConnectedCompoCount == - 1)
|
||||
return false ;
|
||||
// Se la componente richiesta non esiste, vi è un errore.
|
||||
// Se la componente richiesta non esiste, vi è un errore.
|
||||
if ( nPart < 0 || nPart > m_nConnectedCompoCount - 1)
|
||||
return false ;
|
||||
// Calcolo Bounding-box
|
||||
@@ -614,10 +614,10 @@ VolZmap::GetPartBBox( int nPart, const Frame3d& frRef, BBox3d& b3Ref, int nFlag)
|
||||
// Verifico lo stato.
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// Se una sola mappa o il numero di componenti è indefinito, vi è un errore.
|
||||
// Se una sola mappa o il numero di componenti è indefinito, vi è un errore.
|
||||
if ( m_nMapNum == 1 || m_nConnectedCompoCount == - 1)
|
||||
return false ;
|
||||
// Se la componente richiesta non esiste, vi è un errore.
|
||||
// Se la componente richiesta non esiste, vi è un errore.
|
||||
if ( nPart < 0 || nPart > m_nConnectedCompoCount - 1)
|
||||
return false ;
|
||||
// Calcolo Bounding-box
|
||||
@@ -689,7 +689,7 @@ VolZmap::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, doub
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dell'asse di rotazione
|
||||
// verifico validità dell'asse di rotazione
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -722,7 +722,7 @@ VolZmap::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del piano di specchiatura
|
||||
// verifico validità del piano di specchiatura
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -736,7 +736,7 @@ VolZmap::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtD
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei parametri
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
@@ -750,11 +750,11 @@ VolZmap::ToGlob( const Frame3d& frRef)
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
@@ -773,11 +773,11 @@ VolZmap::ToLoc( const Frame3d& frRef)
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità del frame
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se frame identità, non devo fare alcunché
|
||||
// se frame identità, non devo fare alcunché
|
||||
if ( IsGlobFrame( frRef))
|
||||
return true ;
|
||||
|
||||
@@ -796,11 +796,11 @@ VolZmap::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei frame
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
@@ -816,10 +816,10 @@ VolZmap::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
int
|
||||
VolZmap::GetPartCount( void) const
|
||||
{
|
||||
// Se mono-dexel la connessione è incalcolabile.
|
||||
// Se mono-dexel la connessione è incalcolabile.
|
||||
if ( m_nMapNum == 1)
|
||||
return - 1 ;
|
||||
// Se il numero delle componenti è indefinito
|
||||
// Se il numero delle componenti è indefinito
|
||||
// lo ricalcolo e restituisco il risultato.
|
||||
if ( m_nConnectedCompoCount == - 1) {
|
||||
const_cast<VolZmap*>(this)->CheckMapConnection() ;
|
||||
@@ -870,7 +870,7 @@ VolZmap::CheckMapConnection( void)
|
||||
IntervalsToProcessStackVec.resize( nThreadMax) ;
|
||||
// Mi espando dal primo intervallo mettendo gli intervalli che intersecano nei vari thread
|
||||
FirstExpansionFromZ( nThreadMax, NewInt, IntervalsToProcessStackVec) ;
|
||||
// Lancio in parallelo più ricerche
|
||||
// Lancio in parallelo più ricerche
|
||||
int nActiveThread = 0 ;
|
||||
vector<future<bool>> vRes ;
|
||||
vRes.resize( nThreadMax) ;
|
||||
@@ -891,7 +891,7 @@ VolZmap::CheckMapConnection( void)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Se l'intervallo non attraversa un nodo o ha già
|
||||
// Se l'intervallo non attraversa un nodo o ha già
|
||||
// un indice assegnato salto questa iterazione.
|
||||
else
|
||||
continue ;
|
||||
@@ -935,7 +935,7 @@ VolZmap::ExpandFromXInterval( IntContainer& IntCont)
|
||||
double dZmin = m_Values[0][tGrIndex1 * m_nNx[0] + tI][tIntZ].dMin ;
|
||||
double dZmax = m_Values[0][tGrIndex1 * m_nNx[0] + tI][tIntZ].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dZmin - 2 * EPS_SMALL < dZ &&
|
||||
dZmax + 2 * EPS_SMALL > dZ &&
|
||||
@@ -955,7 +955,7 @@ VolZmap::ExpandFromXInterval( IntContainer& IntCont)
|
||||
double dYmin = m_Values[2][tI * m_nNx[2] + tGrIndex2][tIntY].dMin ;
|
||||
double dYmax = m_Values[2][tI * m_nNx[2] + tGrIndex2][tIntY].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dYmin - 2 * EPS_SMALL < dY &&
|
||||
dYmax + 2 * EPS_SMALL > dY &&
|
||||
@@ -1006,7 +1006,7 @@ VolZmap::ExpandFromYInterval( IntContainer& IntCont)
|
||||
double dZmin = m_Values[0][tJ * m_nNx[0] + tGrIndex2][tIntZ].dMin ;
|
||||
double dZmax = m_Values[0][tJ * m_nNx[0] + tGrIndex2][tIntZ].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dZmin - 2 * EPS_SMALL < dZ &&
|
||||
dZmax + 2 * EPS_SMALL > dZ &&
|
||||
@@ -1026,7 +1026,7 @@ VolZmap::ExpandFromYInterval( IntContainer& IntCont)
|
||||
double dXmin = m_Values[1][tGrIndex1 * m_nNx[1] + tJ][tIntX].dMin ;
|
||||
double dXmax = m_Values[1][tGrIndex1 * m_nNx[1] + tJ][tIntX].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dXmin - 2 * EPS_SMALL < dX &&
|
||||
dXmax + 2 * EPS_SMALL > dX &&
|
||||
@@ -1077,7 +1077,7 @@ VolZmap::ExpandFromZInterval( IntContainer& IntCont)
|
||||
double dXmin = m_Values[1][tK * m_nNx[1] + tGrIndex2][tIntX].dMin ;
|
||||
double dXmax = m_Values[1][tK * m_nNx[1] + tGrIndex2][tIntX].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dXmin - 2 * EPS_SMALL < dX &&
|
||||
dXmax + 2 * EPS_SMALL > dX &&
|
||||
@@ -1097,7 +1097,7 @@ VolZmap::ExpandFromZInterval( IntContainer& IntCont)
|
||||
double dYmin = m_Values[2][tGrIndex1 * m_nNx[2] + tK][tIntY].dMin ;
|
||||
double dYmax = m_Values[2][tGrIndex1 * m_nNx[2] + tK][tIntY].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dYmin - 2 * EPS_SMALL < dY &&
|
||||
dYmax + 2 * EPS_SMALL > dY &&
|
||||
@@ -1146,7 +1146,7 @@ VolZmap::FirstExpansionFromZ( int nNumThread, IntervalIndexes IntSt, IntContaine
|
||||
double dXmin = m_Values[1][tK * m_nNx[1] + tGrIndex2][tIntX].dMin ;
|
||||
double dXmax = m_Values[1][tK * m_nNx[1] + tGrIndex2][tIntX].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dXmin - 2 * EPS_SMALL < dX &&
|
||||
dXmax + 2 * EPS_SMALL > dX &&
|
||||
@@ -1167,7 +1167,7 @@ VolZmap::FirstExpansionFromZ( int nNumThread, IntervalIndexes IntSt, IntContaine
|
||||
double dYmin = m_Values[2][tGrIndex1 * m_nNx[2] + tK][tIntY].dMin ;
|
||||
double dYmax = m_Values[2][tGrIndex1 * m_nNx[2] + tK][tIntY].dMax ;
|
||||
// Se i segmenti si incrociano e il nuovo trovato non
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// ha già un indice assegnato, assegno l'indice e
|
||||
// aggiungo l'intervallo trovato allo stack.
|
||||
if ( dYmin - 2 * EPS_SMALL < dY &&
|
||||
dYmax + 2 * EPS_SMALL > dY &&
|
||||
@@ -1214,13 +1214,13 @@ VolZmap::ClonePart( int nPart) const
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return nullptr ;
|
||||
// Se è definita una sola griglia non sono definibili le parti, errore
|
||||
// Se è definita una sola griglia non sono definibili le parti, errore
|
||||
if ( m_nMapNum == 1)
|
||||
return nullptr ;
|
||||
// Se è richiesta una componente fuori intervallo, errore
|
||||
// Se è richiesta una componente fuori intervallo, errore
|
||||
if ( nPart < 0 || nPart >= m_nConnectedCompoCount)
|
||||
return nullptr ;
|
||||
// Se il numero di componenti è indefinito, lo ricalcolo.
|
||||
// Se il numero di componenti è indefinito, lo ricalcolo.
|
||||
if ( m_nConnectedCompoCount == - 1)
|
||||
const_cast<VolZmap*>(this)->CheckMapConnection() ;
|
||||
// Se non vi sono componenti, errore
|
||||
@@ -1291,7 +1291,7 @@ VolZmap::ClonePart( int nPart) const
|
||||
pVolume->m_Values[nMap].resize( pVolume->m_nDim[nMap]) ;
|
||||
}
|
||||
|
||||
// Se almeno una griglia è nulla, non ha senso Zmap
|
||||
// Se almeno una griglia è nulla, non ha senso Zmap
|
||||
if ( pVolume->m_nDim[0] == 0 ||
|
||||
pVolume->m_nDim[1] == 0 ||
|
||||
pVolume->m_nDim[2] == 0)
|
||||
@@ -1343,8 +1343,8 @@ VolZmap::ClonePart( int nPart) const
|
||||
dNewOy = nMinIndJ[0] * m_dStep ;
|
||||
dNewOz = nMinIndJ[1] * m_dStep ;
|
||||
|
||||
// Porto i dexel nel nuovo sistema di riferimento e le quote estreme Z. Non c'è bisogno di trasformare le normali,
|
||||
// infatti i sistemi di riferimento in gioco differiscono al più per una traslazione.
|
||||
// Porto i dexel nel nuovo sistema di riferimento e le quote estreme Z. Non c'è bisogno di trasformare le normali,
|
||||
// infatti i sistemi di riferimento in gioco differiscono al più per una traslazione.
|
||||
for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) {
|
||||
// Quote estreme Z
|
||||
switch ( nMap) {
|
||||
@@ -1407,10 +1407,10 @@ VolZmap::RemovePart( int nPart)
|
||||
// verifico lo stato
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// Se è definita una sola griglia non sono definibili le parti, errore
|
||||
// Se è definita una sola griglia non sono definibili le parti, errore
|
||||
if ( m_nMapNum == 1)
|
||||
return false ;
|
||||
// Se il numero di componenti è indefinito, lo ricalcolo
|
||||
// Se il numero di componenti è indefinito, lo ricalcolo
|
||||
if ( m_nConnectedCompoCount == - 1)
|
||||
CheckMapConnection() ;
|
||||
// Se non vi sono componenti, abbiamo finito
|
||||
@@ -1452,7 +1452,7 @@ VolZmap::GetPartMinDistFromPoint( const Point3d& ptP) const
|
||||
// Verifico lo stato e che siano definibili le componenti connesse
|
||||
if ( m_nStatus != OK || m_nMapNum == 1)
|
||||
return - 1 ;
|
||||
// Se il numero di componenti è indefinito, lo ricalcolo
|
||||
// Se il numero di componenti è indefinito, lo ricalcolo
|
||||
if ( m_nConnectedCompoCount == -1)
|
||||
const_cast<VolZmap*>( this)->CheckMapConnection() ;
|
||||
// Se non vi sono componenti, abbiamo finito
|
||||
@@ -1485,7 +1485,7 @@ VolZmap::GetPartMinDistFromPoint( const Point3d& ptP) const
|
||||
swap( ptEn.y, ptEn.z) ;
|
||||
swap( ptEn.x, ptEn.z) ;
|
||||
}
|
||||
// Calcolo la distanza del punto dal segmento corrente. Se è minore della minima distanza aggiorno quest'ultima
|
||||
// Calcolo la distanza del punto dal segmento corrente. Se è minore della minima distanza aggiorno quest'ultima
|
||||
// e la corrispondente componente connessa di minima distanza con la distanza e la componente connessa correnti.
|
||||
double dDist ;
|
||||
DistPointLine DistCalc( ptPL, ptSt, ptEn) ;
|
||||
@@ -1677,107 +1677,197 @@ VolZmap::SubtractSurfTm( const ISurfTriMesh* pStm)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::MakeUniform( double dToler)
|
||||
VolZmap::MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum)
|
||||
{
|
||||
// controllo validità dello Zmap
|
||||
// Controllo validità dello Zmap
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
// la tolleranza deve essere minore dello step
|
||||
dToler = min( dToler, 0.95 * m_dStep) ;
|
||||
|
||||
// creo lo Zmpa che andrà a sostituire il corrente
|
||||
PtrOwner<VolZmap> pOldVolZmap( CloneBasicVolZmap( this)) ;
|
||||
if ( IsNull( pOldVolZmap))
|
||||
// creo lo ZMap per i riferimenti degli intervalli sulle griglie
|
||||
PtrOwner<VolZmap> pZMapCopy( CloneBasicVolZmap( this)) ;
|
||||
if ( IsNull( pZMapCopy) || ! pZMapCopy->IsValid())
|
||||
return false ;
|
||||
|
||||
// ciclo sulle griglie
|
||||
for ( int nGrid = 0 ; nGrid < m_nMapNum ; ++ nGrid) {
|
||||
// salvo lo Zmap prima di modificare gli spilloni
|
||||
PtrOwner<VolZmap> pVolZMapCurrGrid( CloneBasicVolZmap( this)) ;
|
||||
if ( IsNull( pVolZMapCurrGrid))
|
||||
// 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],
|
||||
m_dStep, IsTriDexel()))
|
||||
return false ;
|
||||
// ciclo sul numero di dexel presenti
|
||||
for ( int nDex = 0 ; nDex < int( m_Values[nGrid].size()) ; ++ nDex) {
|
||||
// se il dexel corrente non ha sotto-intervalli passo al successivo
|
||||
if ( int( m_Values[nGrid][nDex].size()) == 0)
|
||||
|
||||
// Dovendo effettuare estensioni, allargo gli ingobri nelle direzioni principali
|
||||
m_dMinZ[0] -= dToler ;
|
||||
m_dMinZ[1] -= dToler ;
|
||||
m_dMinZ[2] -= dToler ;
|
||||
m_dMaxZ[0] += dToler ;
|
||||
m_dMaxZ[1] += dToler ;
|
||||
m_dMaxZ[2] += dToler ;
|
||||
|
||||
// NB. Tutti i parametri sono sempre presi dalla Copia dello ZMap corrente
|
||||
// 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) {
|
||||
// Se il dexel corrente non ha sotto-intervalli passo al successivo
|
||||
if ( pZMapCopy->m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// indici del dexel
|
||||
// Indici del dexel
|
||||
int nI = nDex % m_nNx[nGrid] ;
|
||||
int nJ = nDex / m_nNx[nGrid] ;
|
||||
// salvo le informazioni dei sotto-intervalli del dexel corrente
|
||||
vector<Data> vInfo ;
|
||||
for ( int nExtr = 0 ; nExtr < int( m_Values[nGrid][nDex].size()) ; ++ nExtr)
|
||||
vInfo.push_back( m_Values[nGrid][nDex][nExtr]) ;
|
||||
// per ogni sotto-intervallo, estendo a destra e a sinistra della tolleranza
|
||||
int nSub_intervals = int( vInfo.size()) ;
|
||||
// scorro gli intervalli
|
||||
for ( int nInfo = 0 ; nInfo < int( pVolZMapCurrGrid->m_Values[nGrid][nDex].size()) ; ++ nInfo) {
|
||||
// estremo inferiore
|
||||
if ( vInfo[nInfo].dMin - dToler > m_dMinZ[nGrid]) {
|
||||
AddIntervals( nGrid, nI, nJ,
|
||||
vInfo[nInfo].dMin - dToler,
|
||||
vInfo[nInfo].dMin + dToler,
|
||||
vInfo[nInfo].vtMinN, vInfo[nInfo].vtMinN, vInfo[nInfo].nToolMin,
|
||||
true) ;
|
||||
// se si sono uniti degli intervalli, potrei dover aggiungere degli spilloni nelle altre due
|
||||
// direzioni nel voxel corrispondente
|
||||
if ( IsTriDexel() && dToler > 0.5 * m_dStep - EPS_SMALL &&
|
||||
nSub_intervals != int( m_Values[nGrid][nDex].size())) {
|
||||
nSub_intervals = int( m_Values[nGrid][nDex].size()) ; // aggiorno gli intervalli correnti
|
||||
// l'intervallo corrente si è unito con il precedente...
|
||||
AddMissingIntervalsInVoxel( pOldVolZmap, nGrid, nI, nJ, vInfo[nInfo].dMin, dToler,
|
||||
vInfo[nInfo].vtMinN, vInfo[nInfo].vtMinN,
|
||||
vInfo[nInfo].nToolMin) ;
|
||||
// Recupero il numero di intervalli presenti nel Dexel corrente
|
||||
int nIntervals = int( pZMapCopy->m_Values[nGrid][nDex].size()) ;
|
||||
// Scorro gli intervalli presenti
|
||||
for ( int nInfo = 0 ; nInfo < int( pZMapCopy->m_Values[nGrid][nDex].size()) ; ++ nInfo) {
|
||||
// Recupero l'intervallo corrente
|
||||
Data& Interval = pZMapCopy->m_Values[nGrid][nDex][nInfo] ;
|
||||
// --- Se richiesta prima estensione
|
||||
if ( bIsExtensionFirst) {
|
||||
// *** Estremo inferiore -> Intervallo : [ dMin - dToler, dMin + dToler ]
|
||||
// Aggiungo l'intervallo nello Zmap corrente ( lascio invariato lo ZMapCopy)
|
||||
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())) {
|
||||
// Aggiorno gli intervalli correnti ( dato che il corrente si è unito al precedente)
|
||||
// ( lascio invariato lo ZMapCopy)
|
||||
nIntervals = int( m_Values[nGrid][nDex].size()) ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
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())) {
|
||||
// Aggiorno gli intervalli correnti ( dato che il corrente si è unito al successivo)
|
||||
// ( lascio invariato lo ZMapCopy)
|
||||
nIntervals = int( m_Values[nGrid][nDex].size()) ;
|
||||
pZMapExtra->UniformIntervalsInVoxel( nGrid, nI, nJ,
|
||||
Interval.dMax,
|
||||
pZMapCopy->m_Values[nGrid][nDex][nInfo+1].dMin, dToler, true,
|
||||
nToolNum, V_INVALID, V_INVALID) ;
|
||||
}
|
||||
}
|
||||
// estremo superiore
|
||||
if ( vInfo[nInfo].dMax + dToler < m_dMaxZ[nGrid]) {
|
||||
AddIntervals( nGrid, nI, nJ,
|
||||
vInfo[nInfo].dMax - dToler,
|
||||
vInfo[nInfo].dMax + dToler,
|
||||
vInfo[nInfo].vtMaxN, vInfo[nInfo].vtMaxN, vInfo[nInfo].nToolMax,
|
||||
true) ;
|
||||
if ( IsTriDexel() && dToler > 0.5 * m_dStep - EPS_SMALL &&
|
||||
nSub_intervals != int( m_Values[nGrid][nDex].size())) {
|
||||
nSub_intervals = int( m_Values[nGrid][nDex].size()) ; // aggiorno gli intervalli correnti
|
||||
AddMissingIntervalsInVoxel( pOldVolZmap, nGrid, nI, nJ, vInfo[nInfo].dMax, dToler,
|
||||
vInfo[nInfo].vtMaxN, vInfo[nInfo].vtMaxN,
|
||||
vInfo[nInfo].nToolMax) ;
|
||||
// --- 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) ;
|
||||
}
|
||||
// *** 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) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// per ogni sotto-intervallo ricavato fino ad ora, restringo della tolleranza
|
||||
// ( NB. avendo aggiunto intervalli, il dexel può modificare la sua struttura interna )
|
||||
for ( int nInfo = 0 ; nInfo < int( m_Values[nGrid][nDex].size()) ; ++ nInfo) {
|
||||
// ( NB. la rimozione di un intervallo ora va definita per intervalli a destra e a sinistra,
|
||||
// altrimenti rimuovo parti in eccesso )
|
||||
if ( ! pVolZMapCurrGrid->m_Values[nGrid][nDex].empty()) {
|
||||
if ( nInfo != 0 ||
|
||||
pVolZMapCurrGrid->m_Values[nGrid][nDex][0].dMin - dToler > m_dMinZ[nGrid])
|
||||
m_Values[nGrid][nDex][nInfo].dMin += dToler ;
|
||||
if ( nInfo != int( m_Values[nGrid][nDex].size()) - 1 ||
|
||||
pVolZMapCurrGrid->m_Values[nGrid][nDex].back().dMax + dToler < m_dMaxZ[nGrid])
|
||||
m_Values[nGrid][nDex][nInfo].dMax -= dToler ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// 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) {
|
||||
// --- Se richiesta prima estensione
|
||||
if ( bIsExtensionFirst) {
|
||||
m_Values[nGrid][nDex][nInfo].dMin += dToler ;
|
||||
m_Values[nGrid][nDex][nInfo].dMax -= dToler ;
|
||||
}
|
||||
// --- Se richiesta prima restrizione
|
||||
else {
|
||||
m_Values[nGrid][nDex][nInfo].dMin -= dToler ;
|
||||
m_Values[nGrid][nDex][nInfo].dMax += dToler ;
|
||||
}
|
||||
// Definisco il colore
|
||||
for ( int nOrigInfo = 0 ; nOrigInfo < int( pZMapCopy->m_Values[nGrid][nDex].size()) ; ++ 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)
|
||||
m_Values[nGrid][nDex][nInfo].nToolMax = pZMapCopy->m_Values[nGrid][nDex][nOrigInfo].nToolMax ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gestisco le parti Extra ricavate
|
||||
// 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) {
|
||||
// Se l'intervallo è vuoto, non faccio nulla
|
||||
if ( pZMapExtra->m_Values[nGrid][nDex].empty())
|
||||
continue ;
|
||||
// Indici del dexel
|
||||
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) {
|
||||
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) ;
|
||||
}
|
||||
// --- Se richiesta prima restrizione
|
||||
else {
|
||||
// ... sottraggo i contributi
|
||||
SubtractIntervals( nGrid, nI, nJ, dMin, dMax, vtNMin, vtNMax, nToolNum, true) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restringo gli ingombri espensi in precedenza
|
||||
m_dMinZ[0] += dToler ;
|
||||
m_dMinZ[1] += dToler ;
|
||||
m_dMinZ[2] += dToler ;
|
||||
m_dMaxZ[0] -= dToler ;
|
||||
m_dMaxZ[1] -= dToler ;
|
||||
m_dMaxZ[2] -= dToler ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
VolZmap::SetToModifyDexelBlocks( int nGrid, int nDex, int nInt)
|
||||
{
|
||||
// Controllo sulla validità della griglia
|
||||
// Controllo sulla validità della griglia
|
||||
if ( nGrid < 0 || nGrid > 2)
|
||||
return false ;
|
||||
// Controllo sulla validità del dexel
|
||||
// Controllo sulla validità del dexel
|
||||
if ( nDex <= - 1 || nDex >= int( m_Values[nGrid].size()))
|
||||
return false ;
|
||||
// Controllo sulla validità dell'intervallo
|
||||
// Controllo sulla validità dell'intervallo
|
||||
if ( nInt <= - 1 || nInt >= int( m_Values[nGrid][nDex].size()))
|
||||
return false ;
|
||||
|
||||
@@ -1929,8 +2019,6 @@ VolZmap::SetToModifyDexelBlocks( int nGrid, int nDex, int nInt)
|
||||
bool
|
||||
VolZmap::IsMapPartABox( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, double& dMinZ, double& dMaxZ)
|
||||
{
|
||||
if ( ! m_bIsBox)
|
||||
return true ;
|
||||
dMinZ = m_dMaxZ[nMap] ;
|
||||
dMaxZ = m_dMinZ[nMap] ;
|
||||
for ( int i = nInfI ; i < nSupI ; ++ i) {
|
||||
@@ -1959,7 +2047,8 @@ VolZmap::IsMapPartABox( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, do
|
||||
bool
|
||||
VolZmap::IsBox( void)
|
||||
{
|
||||
// Se non tridexel, non posso stabilire con il metodo seguente se è un box
|
||||
// Se non tridexel, non posso stabilire con il metodo seguente se è un box
|
||||
// Verifico solo che gli spilloni di una mappa o sono nulli o hanno gli stessi estremi
|
||||
if ( m_nMapNum == 1)
|
||||
return false ;
|
||||
// Numero massimo di thread per il calcolo parallelo.
|
||||
@@ -1968,13 +2057,16 @@ VolZmap::IsBox( void)
|
||||
if ( nThreadMax == 1) {
|
||||
for ( int nMap = 0 ; nMap < m_nMapNum ; ++ nMap) {
|
||||
double dMinZ, dMaxZ ;
|
||||
if ( ! IsMapPartABox( nMap, 0, m_nNx[nMap], 0, m_nNy[nMap], dMinZ, dMaxZ))
|
||||
if ( ! IsMapPartABox( nMap, 0, m_nNx[nMap], 0, m_nNy[nMap], dMinZ, dMaxZ)) {
|
||||
m_bIsBox = false ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
m_bIsBox = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Caso di più thread
|
||||
// Caso di più thread
|
||||
m_bIsBox = true ;
|
||||
for ( int nMap = 0 ; nMap < m_nMapNum ; ++ nMap) {
|
||||
vector< future<bool>> vRes ;
|
||||
@@ -2019,15 +2111,16 @@ VolZmap::IsBox( void)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Se uno dei thread trova che la sua porzione non è un box, non lo può essere il solido intero.
|
||||
// Se uno dei thread trova che la sua porzione non è un box, non lo può essere il solido intero.
|
||||
if ( ! m_bIsBox)
|
||||
return false ;
|
||||
// Controllo che gli estremi Z siano uguali.
|
||||
for ( int nT = 1 ; nT < nThreadMax ; ++ nT) {
|
||||
if ( abs( vMinZ[nT] - vMinZ[0]) > EPS_SMALL)
|
||||
return false ;
|
||||
if ( abs( vMaxZ[nT] - vMaxZ[0]) > EPS_SMALL)
|
||||
if ( abs( vMinZ[nT] - vMinZ[0]) > EPS_SMALL ||
|
||||
abs( vMaxZ[nT] - vMaxZ[0]) > EPS_SMALL) {
|
||||
m_bIsBox = false ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2055,7 +2148,7 @@ VolZmap::Cut( const Plane3d& plPlane)
|
||||
}
|
||||
// Ciclo sui dexel della mappa
|
||||
for ( int nD = 0 ; nD < int( m_Values[nMap].size()) ; ++ nD) {
|
||||
// Se spillone già vuoto, passo al successivo
|
||||
// Se spillone già vuoto, passo al successivo
|
||||
if ( m_Values[nMap][nD].empty())
|
||||
continue ;
|
||||
// Indici di spillone
|
||||
@@ -2071,20 +2164,20 @@ VolZmap::Cut( const Plane3d& plPlane)
|
||||
double dEnDist = DistPointPlane( ptEn, plMyPlane) ;
|
||||
// Se entrambi sotto il piano
|
||||
if ( dStDist < EPS_SMALL && dEnDist < EPS_SMALL)
|
||||
// Non devo fare alcunché
|
||||
// Non devo fare alcunché
|
||||
;
|
||||
// se altrimenti entrambi gli estremi sono oltre il piano
|
||||
else if ( dStDist > -EPS_SMALL && dEnDist > -EPS_SMALL) {
|
||||
// Si elimina tutto
|
||||
SubtractIntervals( nMap, nI, nJ, dMin, dMax, V_NULL, V_NULL, 1) ;
|
||||
}
|
||||
// se altrimenti è da tenere il punto iniziale
|
||||
// se altrimenti è da tenere il punto iniziale
|
||||
else if ( dStDist < 0) {
|
||||
// Si elimina la parte tra intersezione e punto finale
|
||||
double dInt = dMin + ( dMax - dMin) * abs( dStDist) / ( abs( dStDist) + abs( dEnDist)) ;
|
||||
SubtractIntervals( nMap, nI, nJ, dInt, dMax, plMyPlane.GetVersN(), V_NULL, 1) ;
|
||||
}
|
||||
// se altrimenti è da tenere il punto finale
|
||||
// se altrimenti è da tenere il punto finale
|
||||
else if (dEnDist < 0) {
|
||||
// Si elimina la parte tra punto iniziale e intersezione
|
||||
double dInt = dMin + ( dMax - dMin) * abs( dStDist) / ( abs( dStDist) + abs( dEnDist)) ;
|
||||
@@ -2174,7 +2267,7 @@ VolZmap::Compact( void)
|
||||
}
|
||||
}
|
||||
|
||||
// Se non vi è materiale
|
||||
// Se non vi è materiale
|
||||
if ( ! bNotEmptyGrid) {
|
||||
m_nStatus = TO_VERIFY ;
|
||||
m_nNumBlock = 0 ;
|
||||
@@ -2196,8 +2289,8 @@ VolZmap::Compact( void)
|
||||
double dNewOy = nMinJ[0] * m_dStep ;
|
||||
double dNewOz = nMinJ[1] * m_dStep ;
|
||||
|
||||
// Porto i dexel nel nuovo sistema di riferimento e le quote estreme Z. Non c'è bisogno di trasformare le normali,
|
||||
// infatti i sistemi di riferimento in gioco differiscono al più per una traslazione.
|
||||
// Porto i dexel nel nuovo sistema di riferimento e le quote estreme Z. Non c'è bisogno di trasformare le normali,
|
||||
// infatti i sistemi di riferimento in gioco differiscono al più per una traslazione.
|
||||
for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) {
|
||||
// Quote estreme Z
|
||||
switch ( nMap) {
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
#include <stack>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <tuple>
|
||||
|
||||
typedef std::pair<Point3d, Vector3d> PNTVEC3D ;
|
||||
typedef std::vector<PNTVEC3D> PNTVEC3DVECTOR ; // vettore di intersezioni punto, vettore, tipo superficie
|
||||
|
||||
// ------------------------- FORWARD -------------------------------------------------------------
|
||||
class IntersParLinesSurfTm ;
|
||||
@@ -81,9 +85,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
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 CreateFromTriMeshOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType = STMOFF_FILLET) override ;
|
||||
bool CreateFromTriMeshThickeningOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType = STMOFF_FILLET) override ;
|
||||
bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex, double dExtraBox = 0) override ;
|
||||
int GetBlockCount( void) const override ;
|
||||
int GetBlockUpdatingCounter( int nBlock) const override ;
|
||||
bool GetBlockTriangles( int nBlock, TRIA3DEXVECTOR& vTria) const override ;
|
||||
@@ -97,7 +99,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
{ return m_nDexVoxRatio ; }
|
||||
bool ChangeResolution( int nDexVoxRatio) override ;
|
||||
void SetShowEdges( bool bShow) override
|
||||
{ m_bShowEdges = bShow ; // qui è necessario far ricreare la grafica
|
||||
{ m_bShowEdges = bShow ; // qui è necessario far ricreare la grafica
|
||||
m_OGrMgr.Clear() ; }
|
||||
bool GetShowEdges( void) const override
|
||||
{ return m_bShowEdges ; }
|
||||
@@ -149,7 +151,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
int GetPartMinDistFromPoint( const Point3d& ptP) const override ;
|
||||
bool AddSurfTm( const ISurfTriMesh* pStm) override ;
|
||||
bool SubtractSurfTm( const ISurfTriMesh* pStm) override ;
|
||||
bool MakeUniform( double dToler) override ;
|
||||
bool MakeUniform( double dToler, bool bIsExtensionFirst, int nToolNum) override ;
|
||||
bool Offset( double dOffs, int nType) override ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
@@ -170,6 +173,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
return *this ; }
|
||||
bool GetLineIntersection( const Point3d& ptP, const Vector3d& vtD, ILZIVECTOR& vIntersInfo) const ;
|
||||
bool GetPlaneIntersection( const Plane3d& plPlane, ICURVEPOVECTOR& vpLoop) const ;
|
||||
bool CreateFromTriMeshOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType = STMOFF_FILLET) ;
|
||||
bool CreateFromTriMeshThickeningOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol, int nType = STMOFF_FILLET) ;
|
||||
|
||||
private :
|
||||
enum CubeType { VOX_EXTERN = 1,
|
||||
@@ -255,17 +260,21 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool AddIntervals( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap = false) ;
|
||||
bool AddMissingIntervalsInVoxel( VolZmap* VolZmapRef, int nGrid, int nI, int nJ, double dZ, double dToler,
|
||||
Vector3d vtToolMin, Vector3d vtToolMax, int nToolNum) ;
|
||||
bool AddSubIntervalInVoxel( VolZmap* VolZmapRef, int nGrid, int nI, int nJ, int nK, double& dMin, double& dMax,
|
||||
Vector3d& vtMin, Vector3d& vtMax) ;
|
||||
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 ManageSubIntervalInVoxel( VolZmap* VolZmapRef, int nGrid, int nI, int nJ, int nK, double& dMin, double& dMax,
|
||||
Vector3d& vtMin, Vector3d& vtMax) ;
|
||||
// Spostamenti utensile
|
||||
bool MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtD, const Vector3d& vtA) ;
|
||||
bool MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs,
|
||||
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) ;
|
||||
bool SelectGeneralMotion( int nGrid, const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtLs, const Vector3d& vtLe, int n5AxisType) ;
|
||||
bool SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtL, const Vector3d& vtAL) ;
|
||||
bool InitializePointsAndVectors( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtDs, const Vector3d& vtAs,
|
||||
Point3d ptLs[3], Point3d ptLe[3], Vector3d vtLs[3], Vector3d vtALs[3]) ;
|
||||
bool InitializeAuxPoints( Point3d ptTop1s[3], Point3d ptTop1e[3], Point3d ptTop2s[3], Point3d ptTop2e[3],
|
||||
Point3d ptBottom1s[3], Point3d ptBottom1e[3], Point3d ptBottom2s[3], Point3d ptBottom2e[3]) ;
|
||||
// SOTTRAZIONI
|
||||
// UTENSILI
|
||||
// Asse di simmetria parallelo a Z
|
||||
@@ -293,11 +302,16 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool Conus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
bool Conus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
bool Mrt_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ;
|
||||
bool Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realtà un Perp
|
||||
bool Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realt� un Perp
|
||||
bool Chs_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ;
|
||||
bool Chs_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realtà un Perp
|
||||
bool Chs_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realt� un Perp
|
||||
bool GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
bool GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) ;
|
||||
// lavorazioni a 5 assi
|
||||
bool GenTool_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
|
||||
bool Cyl_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, double dHeightCorr = 0, int n5AxisType = ACROSS) ;
|
||||
bool CylBall_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
|
||||
bool Conus_5AxisMilling(int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe, int nToolNum, int n5AxisType = ACROSS) ;
|
||||
|
||||
// COMPONENTI
|
||||
// Asse di simmetria diretto come l'asse Z
|
||||
@@ -316,7 +330,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ;
|
||||
bool CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ,
|
||||
const Point3d& ptS, const Point3d& ptE,
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realt� MillingPerp
|
||||
// Asse di simmetria con orientazione generica
|
||||
bool CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir,
|
||||
double dHei, double dRad, bool bTapB, bool bTapT, int nToolNum) ;
|
||||
@@ -332,7 +346,15 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ;
|
||||
bool CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ,
|
||||
const Point3d& ptS, const Point3d& ptE,
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
|
||||
const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp
|
||||
// lavorazioni a 5 assi
|
||||
bool Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe,
|
||||
double dHeight, double dMaxRad, double dMinRad, int nToolNum, int n5AxisType) ;
|
||||
bool CompCyl_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtLs, const Vector3d& vtLe,
|
||||
double dHeight, double dRadius, int nToolNum, int n5AxisType) ;
|
||||
bool CompConus_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDirS, const Vector3d& vtToolDirE, double dHei, double dMaxRad, double dMinRad,
|
||||
bool bTapB, bool bTapT, const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum, int n5AxisType) ;
|
||||
|
||||
// Generica traslazione sfera
|
||||
bool CompBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dRad, int nToolNum) ;
|
||||
// Additivi
|
||||
@@ -346,7 +368,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
// BBox per utensili e solidi semplici con movimenti di traslazione
|
||||
inline bool TestToolBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV,
|
||||
int& nStI, int& nStJ, int& nEnI, int& nEnJ) ;
|
||||
inline bool TestCompoBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV,
|
||||
inline bool TestCompoBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV, const Vector3d& vtV2,
|
||||
double dRad, double dTipRad, double dHei,
|
||||
int& nStI, int& nStJ, int& nEnI, int& nEnJ) ;
|
||||
inline bool TestParaBBox( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtD, const Vector3d& vtA,
|
||||
@@ -440,30 +462,51 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
bool SubtractMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
||||
// Funzioni per Offset di superfici
|
||||
bool InitVolZMapOffs( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol) ;
|
||||
bool InitVolZMapThickeningOffs( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol) ;
|
||||
bool InitVolZMapOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol) ;
|
||||
bool InitVolZMapThickeningOffset( const CISURFTMPVECTOR& vSurf, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapByOpenSurfFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapByOpenSurfSharpedOffset( const ISurfTriMesh* Surf, int nType, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapByClosedSurfFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapByClosedSurfSharpedOffset( const ISurfTriMesh* Surf, int nType, double dOffs, double dTol) ;
|
||||
bool UpdateVolZMapBySurfThickeningFilletOffset( const ISurfTriMesh* Surf, double dOffs, double dTol) ;
|
||||
bool CreateOffsSphereOnVertex( const Point3d& ptV, double dOffs, int nGrid, int nVertexType = 0) ;
|
||||
bool CreateOffsCylinderOnEdge( const Point3d& ptP1, const Point3d& ptP2, double dOffs, int nGrid, int nVertexType = 0) ;
|
||||
bool UpdateVolZMapBySurfThickeningSharpedOffset( const ISurfTriMesh* Surf, int nType, double dOffs, double dTol) ;
|
||||
bool CreateOffsetSphereOnVertex( const Point3d& ptV, double dOffs, int nGrid, int nVertexType = 0) ;
|
||||
bool CreateOffsetCylinderOnEdge( const Point3d& ptP1, const Point3d& ptP2, double dOffs, int nGrid, int nVertexType = 0) ;
|
||||
bool CreateFatOffsetExtrusionFace( const ISurfTriMesh* Surf, double dOffs, bool bThickle) ;
|
||||
bool CreateOrientedOffsetExtrusionFace( const ISurfTriMesh* Surf, double dOffs) ;
|
||||
bool SubtractIntervalsForOffset( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap = false) ;
|
||||
bool AddIntervalsForOffset( int nGrid, int nI, int nJ,
|
||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
||||
int nToolNum, bool bSkipSwap = false) ;
|
||||
bool CutByPlaneForOffset( const Plane3d& plCut) ;
|
||||
// Funzioni per Offset di Zmap
|
||||
bool OffsetFillet( double dOffs) ;
|
||||
bool OffsetSharped( double dOffs, int nType) ;
|
||||
|
||||
private :
|
||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||
enum Shape { GENERIC = 0, BOX = 1, EXTRUSION = 2, OFFSET = 3} ;
|
||||
enum Move5Axis {
|
||||
ALONG_CONVEX = 0 ,
|
||||
ALONG_CONCAVE = 1 ,
|
||||
ACROSS = 2 ,
|
||||
NO_BASE_INTERS = 3} ;
|
||||
enum Status {
|
||||
ERR = 0,
|
||||
OK = 1,
|
||||
TO_VERIFY = 2} ;
|
||||
enum Shape {
|
||||
GENERIC = 0,
|
||||
BOX = 1,
|
||||
EXTRUSION = 2,
|
||||
OFFSET = 3} ;
|
||||
static const int N_MAPS = 3 ;
|
||||
static const int N_VOXBLOCK = 32 ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Status m_nStatus ; // stato
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
bool m_bShowEdges ; // flag di visualizzazione spigoli vivi
|
||||
Frame3d m_MapFrame ; // riferimento intrinseco dello Zmap
|
||||
@@ -497,8 +540,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
mutable BOOLVECTOR m_BlockToUpdate ;
|
||||
mutable INTVECTOR m_BlockUpdatingCounter ;
|
||||
|
||||
int m_nConnectedCompoCount ; // Se == - 1 il numero di componenti non è noto
|
||||
// Se >= 0 è il numero di componenti connesse
|
||||
int m_nConnectedCompoCount ; // Se == - 1 il numero di componenti non è noto
|
||||
// Se >= 0 è il numero di componenti connesse
|
||||
|
||||
mutable std::vector<VoxelContainer> m_InterBlockVox ;
|
||||
mutable SharpTriaMatrix m_InterBlockOriginalSharpTria ;
|
||||
@@ -521,6 +564,12 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
||||
double m_dToolAngTolDeg ;
|
||||
} ;
|
||||
|
||||
// Offset
|
||||
enum {
|
||||
VOLZMAP_OFFS_FILLET = 0,
|
||||
VOLZMAP_OFFS_CHANFER = 1,
|
||||
VOLZMAP_OFFS_EXTENDED = 2
|
||||
} ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
inline VolZmap* CreateBasicVolZmap( void)
|
||||
|
||||
+62
-47
@@ -505,6 +505,8 @@ VolZmap::CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, co
|
||||
nSupJ < 0 || nSupJ > m_nNy[nMap])
|
||||
return false ;
|
||||
|
||||
double dCosSmall = sin( EPS_ANG_SMALL * DEGTORAD) ;
|
||||
|
||||
// Determinazione e ridimensionamento dei dexel interni alla trimesh
|
||||
for ( int i = nInfI ; i < nSupI ; ++ i) {
|
||||
for ( int j = nInfJ ; j < nSupJ ; ++ j) {
|
||||
@@ -552,7 +554,7 @@ VolZmap::CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, co
|
||||
double dCos = IntersectionResults[k].dCosDN ;
|
||||
|
||||
// entro nella superficie trimesh
|
||||
if ( dCos < - EPS_SMALL) {
|
||||
if ( dCos < - dCosSmall) {
|
||||
|
||||
ptIn = IntersectionResults[k].ptI ;
|
||||
|
||||
@@ -565,7 +567,7 @@ VolZmap::CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, co
|
||||
}
|
||||
|
||||
// esco dalla superficie trimesh
|
||||
else if ( dCos > EPS_SMALL && bInside) {
|
||||
else if ( dCos > dCosSmall && bInside) {
|
||||
|
||||
Point3d ptOut = IntersectionResults[k].ptI ;
|
||||
|
||||
@@ -804,7 +806,9 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
// quindi espandiamo il bounding box per ovviare al problema.
|
||||
if ( dExtraBox > EPS_ZERO)
|
||||
SurfBBox.Expand( dExtraBox) ;
|
||||
|
||||
else
|
||||
dExtraBox = 0 ;
|
||||
|
||||
// Determino i punti estremi del bounding box
|
||||
Point3d ptMapOrig, ptMapEnd ;
|
||||
SurfBBox.GetMinMax( ptMapOrig, ptMapEnd) ;
|
||||
@@ -870,58 +874,69 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex
|
||||
// Oggetto per calcolo massivo intersezioni
|
||||
IntersParLinesSurfTm intPLSTM( frMapFrame, Surf) ;
|
||||
|
||||
// Numero massimo di thread
|
||||
int nThreadMax = max( 1, int( thread::hardware_concurrency()) - 1) ;
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( nThreadMax) ;
|
||||
if ( m_nNx[nG] > m_nNy[nG]) {
|
||||
int nDexNum = m_nNx[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNx[nG] % nThreadMax ;
|
||||
int nInfI = 0 ;
|
||||
int nSupI = 0 ;
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfI = nSupI ;
|
||||
nSupI = nInfI + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, nG,
|
||||
nInfI, nSupI, 0, m_nNy[nG], ref( vtLen), ref( ptMapOrig), ref( Surf), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int nDexNum = m_nNy[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNy[nG] % nThreadMax ;
|
||||
int nInfJ = 0 ;
|
||||
int nSupJ = 0 ;
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfJ = nSupJ ;
|
||||
nSupJ = nInfJ + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, nG,
|
||||
0, m_nNx[nG], nInfJ, nSupJ, ref( vtLen), ref( ptMapOrig), ref( Surf),ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Ciclo per attendere che tutti gli async abbiano terminato.
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < nThreadMax) {
|
||||
for ( int nL = 0 ; nL < nThreadMax ; ++ nL) {
|
||||
// Async terminato
|
||||
if ( vRes[nL].valid() && vRes[nL].wait_for( chrono::microseconds{ 1}) == future_status::ready) {
|
||||
++ nTerminated ;
|
||||
bCompleted = bCompleted && vRes[nL].get() ;
|
||||
// Standarda è multithread
|
||||
constexpr bool MULTITHREAD = true ;
|
||||
if ( MULTITHREAD) {
|
||||
|
||||
// Numero massimo di thread
|
||||
int nThreadMax = max( 1, int( thread::hardware_concurrency()) - 1) ;
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( nThreadMax) ;
|
||||
if ( m_nNx[nG] > m_nNy[nG]) {
|
||||
int nDexNum = m_nNx[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNx[nG] % nThreadMax ;
|
||||
int nInfI = 0 ;
|
||||
int nSupI = 0 ;
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfI = nSupI ;
|
||||
nSupI = nInfI + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, nG,
|
||||
nInfI, nSupI, 0, m_nNy[nG], ref( vtLen), ref( ptMapOrig), ref( Surf), ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int nDexNum = m_nNy[nG] / nThreadMax ;
|
||||
int nRemainder = m_nNy[nG] % nThreadMax ;
|
||||
int nInfJ = 0 ;
|
||||
int nSupJ = 0 ;
|
||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
||||
nInfJ = nSupJ ;
|
||||
nSupJ = nInfJ + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
||||
vRes[nThread] = async( launch::async, &VolZmap::CreateMapPart, this, nG,
|
||||
0, m_nNx[nG], nInfJ, nSupJ, ref( vtLen), ref( ptMapOrig), ref( Surf),ref( intPLSTM)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Ciclo per attendere che tutti gli async abbiano terminato.
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < nThreadMax) {
|
||||
for ( int nL = 0 ; nL < nThreadMax ; ++ nL) {
|
||||
// Async terminato
|
||||
if ( vRes[nL].valid() && vRes[nL].wait_for( chrono::microseconds{ 1}) == future_status::ready) {
|
||||
++ nTerminated ;
|
||||
bCompleted = bCompleted && vRes[nL].get() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// !!!! NON MULTITHREAD : SOLO PER DEBUG !!!!
|
||||
else {
|
||||
CreateMapPart( nG, 0, m_nNx[nG], 0, m_nNy[nG], vtLen, ptMapOrig, Surf, intPLSTM) ;
|
||||
}
|
||||
}
|
||||
|
||||
// Assegno il minimo e massimo valore di Z della mappa
|
||||
m_dMinZ[0] = 0 ;
|
||||
m_dMaxZ[0] = vtLen.z ;
|
||||
m_dMinZ[1] = 0 ;
|
||||
m_dMaxZ[1] = ( bTriDex ? vtLen.x : 0) ;
|
||||
m_dMinZ[2] = 0 ;
|
||||
m_dMaxZ[2] = ( bTriDex ? vtLen.y : 0) ;
|
||||
m_dMinZ[0] = dExtraBox ;
|
||||
m_dMaxZ[0] = vtLen.z - dExtraBox ;
|
||||
m_dMinZ[1] = ( bTriDex ? dExtraBox : 0) ;
|
||||
m_dMaxZ[1] = ( bTriDex ? vtLen.x - dExtraBox : 0) ;
|
||||
m_dMinZ[2] = ( bTriDex ? dExtraBox : 0) ;
|
||||
m_dMaxZ[2] = ( bTriDex ? vtLen.y - dExtraBox : 0) ;
|
||||
|
||||
// Tipologia
|
||||
m_nShape = ( dExtraBox > EPS_ZERO && IsBox() ? BOX : GENERIC) ;
|
||||
// Con espansione non va considerato box (calcolo trimesh va in crash)
|
||||
m_nShape = ( dExtraBox <= EPS_ZERO && IsBox() ? BOX : GENERIC) ;
|
||||
|
||||
// Aggiornamento dello stato
|
||||
m_nStatus = OK ;
|
||||
|
||||
+32
-16
@@ -950,25 +950,41 @@ VolZmap::UpdateTripleMapGraphics( void) const
|
||||
}
|
||||
}
|
||||
|
||||
// Calcolo i triangoli sui blocchi
|
||||
int nBlockUpdated = 0 ;
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( m_nNumBlock) ;
|
||||
for ( int i = 0 ; i < m_nNumBlock ; ++ i) {
|
||||
// Se il blocco deve essere processato
|
||||
if ( m_BlockToUpdate[i]) {
|
||||
// processo ...
|
||||
++ nBlockUpdated ;
|
||||
vRes[i] = async( launch::async, &VolZmap::ExtMarchingCubes, this, i, ref( vVoxContainerVec[i])) ;
|
||||
// Standarda è multithread
|
||||
constexpr bool MULTITHREAD = true ;
|
||||
if ( MULTITHREAD) {
|
||||
|
||||
// Calcolo i triangoli sui blocchi
|
||||
int nBlockUpdated = 0 ;
|
||||
vector< future<bool>> vRes ;
|
||||
vRes.resize( m_nNumBlock) ;
|
||||
for ( int i = 0 ; i < m_nNumBlock ; ++ i) {
|
||||
// Se il blocco deve essere processato
|
||||
if ( m_BlockToUpdate[i]) {
|
||||
// processo ...
|
||||
++ nBlockUpdated ;
|
||||
vRes[i] = async( launch::async, &VolZmap::ExtMarchingCubes, this, i, ref( vVoxContainerVec[i])) ;
|
||||
}
|
||||
}
|
||||
bool bOk = true ;
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < nBlockUpdated) {
|
||||
for ( int i = 0 ; i < m_nNumBlock ; ++ i) {
|
||||
if ( m_BlockToUpdate[i] && vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
bOk = vRes[i].get() && bOk ;
|
||||
++ nTerminated ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bOk = true ;
|
||||
int nTerminated = 0 ;
|
||||
while ( nTerminated < nBlockUpdated) {
|
||||
else {
|
||||
// Calcolo i triangoli sui blocchi
|
||||
bool bOk = true ;
|
||||
for ( int i = 0 ; i < m_nNumBlock ; ++ i) {
|
||||
if ( m_BlockToUpdate[i] && vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
bOk = vRes[i].get() && bOk ;
|
||||
++ nTerminated ;
|
||||
// Se il blocco deve essere processato
|
||||
if ( m_BlockToUpdate[i]) {
|
||||
// processo ...
|
||||
bOk = ExtMarchingCubes( i, vVoxContainerVec[i]) && bOk ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1797
-110
File diff suppressed because it is too large
Load Diff
+1655
-334
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user