Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8538bc2d30 |
@@ -317,8 +317,6 @@ AdjustLoops( ICurve* pCurve, ICURVEPLIST& CrvLst, bool bNeedSameProp)
|
|||||||
pCrvCo->RemoveSmallDefects( 2 * LIN_TOL_MIN, ANG_TOL_STD_DEG, true) ;
|
pCrvCo->RemoveSmallDefects( 2 * LIN_TOL_MIN, ANG_TOL_STD_DEG, true) ;
|
||||||
// unisco eventuali tratti allineati
|
// unisco eventuali tratti allineati
|
||||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, bNeedSameProp) ;
|
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, bNeedSameProp) ;
|
||||||
// richiudo i loop per sicurezza
|
|
||||||
pCrvCo->Close() ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
#include "CurveBezier.h"
|
#include "CurveBezier.h"
|
||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
#include "CreateCurveAux.h"
|
#include "CreateCurveAux.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkArcPntDirTgCurve.h"
|
#include "/EgtDev/Include/EGkArcPntDirTgCurve.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
|
|||||||
+1
-2
@@ -134,8 +134,7 @@ GetArc3P( const Point3d& ptStart, const Point3d& ptOther, const Point3d& ptEnd,
|
|||||||
|
|
||||||
// calcolo arco non riuscito, se i punti sono allineati nel giusto verso per essere una retta
|
// calcolo arco non riuscito, se i punti sono allineati nel giusto verso per essere una retta
|
||||||
// verifico se i punti sono allineati nel giusto verso
|
// verifico se i punti sono allineati nel giusto verso
|
||||||
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO ||
|
if ( ( ptOther - ptStart) * ( ptEnd - ptOther) > EPS_ZERO) {
|
||||||
AreSamePointApprox( ptOther, ptStart) || AreSamePointApprox( ptEnd, ptOther)) {
|
|
||||||
// creo l'oggetto retta
|
// creo l'oggetto retta
|
||||||
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
PtrOwner<CurveLine> pLine( CreateBasicCurveLine()) ;
|
||||||
if ( IsNull( pLine))
|
if ( IsNull( pLine))
|
||||||
|
|||||||
+8
-8
@@ -133,22 +133,22 @@ Attribs::Load( NgeReader& ngeIn)
|
|||||||
unsigned char ucLev ;
|
unsigned char ucLev ;
|
||||||
if ( ! ngeIn.ReadUchar( ucLev, ","))
|
if ( ! ngeIn.ReadUchar( ucLev, ","))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[LEVEL] = Clamp( ucLev, GDB_LV_USER, GDB_LV_TEMP) ;
|
m_Data[LEVEL] = CLIP( ucLev, GDB_LV_USER, GDB_LV_TEMP) ;
|
||||||
// modo
|
// modo
|
||||||
unsigned char ucMode ;
|
unsigned char ucMode ;
|
||||||
if ( ! ngeIn.ReadUchar( ucMode, ","))
|
if ( ! ngeIn.ReadUchar( ucMode, ","))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[MODE] = Clamp( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
|
m_Data[MODE] = CLIP( ucMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
|
||||||
// stato (se SEL è convertito in ON)
|
// stato (se SEL è convertito in ON)
|
||||||
unsigned char ucStat ;
|
unsigned char ucStat ;
|
||||||
if ( ! ngeIn.ReadUchar( ucStat, ","))
|
if ( ! ngeIn.ReadUchar( ucStat, ","))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[STATUS] = Clamp( ucStat, GDB_ST_OFF, GDB_ST_ON) ;
|
m_Data[STATUS] = CLIP( ucStat, GDB_ST_OFF, GDB_ST_ON) ;
|
||||||
// marcatura (sempre OFF)
|
// marcatura (sempre OFF)
|
||||||
unsigned char ucMark ;
|
unsigned char ucMark ;
|
||||||
if ( ! ngeIn.ReadUchar( ucMark, ";"))
|
if ( ! ngeIn.ReadUchar( ucMark, ";"))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[MARK] = Clamp( ucMark, GDB_MK_OFF, GDB_MK_OFF) ;
|
m_Data[MARK] = CLIP( ucMark, GDB_MK_OFF, GDB_MK_OFF) ;
|
||||||
// materiale
|
// materiale
|
||||||
if ( ! ngeIn.ReadInt( m_Material, ";"))
|
if ( ! ngeIn.ReadInt( m_Material, ";"))
|
||||||
return false ;
|
return false ;
|
||||||
@@ -185,22 +185,22 @@ Attribs::DataFromString( const string& sParam)
|
|||||||
int nLev ;
|
int nLev ;
|
||||||
if ( ! FromString( vsParams[0], nLev))
|
if ( ! FromString( vsParams[0], nLev))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[LEVEL] = Clamp( nLev, GDB_LV_USER, GDB_LV_TEMP) ;
|
m_Data[LEVEL] = CLIP( nLev, GDB_LV_USER, GDB_LV_TEMP) ;
|
||||||
// modo
|
// modo
|
||||||
int nMode ;
|
int nMode ;
|
||||||
if ( ! FromString( vsParams[1], nMode))
|
if ( ! FromString( vsParams[1], nMode))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[MODE] = Clamp( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
|
m_Data[MODE] = CLIP( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ;
|
||||||
// stato (ammessi solo OFF e ON)
|
// stato (ammessi solo OFF e ON)
|
||||||
int nStat ;
|
int nStat ;
|
||||||
if ( ! FromString( vsParams[2], nStat))
|
if ( ! FromString( vsParams[2], nStat))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[STATUS] = Clamp( nStat, GDB_ST_OFF, GDB_ST_ON) ;
|
m_Data[STATUS] = CLIP( nStat, GDB_ST_OFF, GDB_ST_ON) ;
|
||||||
// marcatura (ammesso solo OFF)
|
// marcatura (ammesso solo OFF)
|
||||||
int nMark ;
|
int nMark ;
|
||||||
if ( ! FromString( vsParams[3], nMark))
|
if ( ! FromString( vsParams[3], nMark))
|
||||||
return false ;
|
return false ;
|
||||||
m_Data[MARK] = Clamp( nMark, GDB_MK_OFF, GDB_MK_OFF) ;
|
m_Data[MARK] = CLIP( nMark, GDB_MK_OFF, GDB_MK_OFF) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,14 @@
|
|||||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||||
#include "/EgtDev/Include/EGkColor.h"
|
#include "/EgtDev/Include/EGkColor.h"
|
||||||
#include "/EgtDev/Include/EgtStringBase.h"
|
#include "/EgtDev/Include/EgtStringBase.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
|
||||||
|
|
||||||
class NgeWriter ;
|
class NgeWriter ;
|
||||||
class NgeReader ;
|
class NgeReader ;
|
||||||
class GeomDB ;
|
class GeomDB ;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
#define CLIP( nV, nMIN, nMAX) (( nV < nMIN) ? nMIN : (( nV > nMAX) ? nMAX : nV))
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
class Attribs
|
class Attribs
|
||||||
{
|
{
|
||||||
@@ -44,14 +46,14 @@ class Attribs
|
|||||||
bool Load( NgeReader& ngeIn) ;
|
bool Load( NgeReader& ngeIn) ;
|
||||||
void SetLevel( int nLev)
|
void SetLevel( int nLev)
|
||||||
{ m_OldData[LEVEL] = m_Data[LEVEL] ;
|
{ m_OldData[LEVEL] = m_Data[LEVEL] ;
|
||||||
m_Data[LEVEL] = Clamp( nLev, GDB_LV_USER, GDB_LV_TEMP) ; }
|
m_Data[LEVEL] = CLIP( nLev, GDB_LV_USER, GDB_LV_TEMP) ; }
|
||||||
void RevertLevel( void)
|
void RevertLevel( void)
|
||||||
{ std::swap( m_Data[LEVEL], m_OldData[LEVEL]) ; }
|
{ std::swap( m_Data[LEVEL], m_OldData[LEVEL]) ; }
|
||||||
int GetLevel( void) const
|
int GetLevel( void) const
|
||||||
{ return m_Data[LEVEL] ; }
|
{ return m_Data[LEVEL] ; }
|
||||||
void SetMode( int nMode)
|
void SetMode( int nMode)
|
||||||
{ m_OldData[MODE] = m_Data[MODE] ;
|
{ m_OldData[MODE] = m_Data[MODE] ;
|
||||||
m_Data[MODE] = Clamp( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ; }
|
m_Data[MODE] = CLIP( nMode, GDB_MD_STD, GDB_MD_HIDDEN) ; }
|
||||||
void RevertMode( void)
|
void RevertMode( void)
|
||||||
{ std::swap( m_Data[MODE], m_OldData[MODE]) ; }
|
{ std::swap( m_Data[MODE], m_OldData[MODE]) ; }
|
||||||
int GetMode( void) const
|
int GetMode( void) const
|
||||||
@@ -59,13 +61,13 @@ class Attribs
|
|||||||
void SetStatus( int nStat)
|
void SetStatus( int nStat)
|
||||||
{ if ( m_Data[STATUS] != GDB_ST_SEL)
|
{ if ( m_Data[STATUS] != GDB_ST_SEL)
|
||||||
m_OldData[STATUS] = m_Data[STATUS] ;
|
m_OldData[STATUS] = m_Data[STATUS] ;
|
||||||
m_Data[STATUS] = Clamp( nStat, GDB_ST_OFF, GDB_ST_SEL) ; }
|
m_Data[STATUS] = CLIP( nStat, GDB_ST_OFF, GDB_ST_SEL) ; }
|
||||||
void RevertStatus( void)
|
void RevertStatus( void)
|
||||||
{ SetStatus( m_OldData[STATUS]) ; }
|
{ SetStatus( m_OldData[STATUS]) ; }
|
||||||
int GetStatus( void) const
|
int GetStatus( void) const
|
||||||
{ return m_Data[STATUS] ; }
|
{ return m_Data[STATUS] ; }
|
||||||
void SetMark( int nMark)
|
void SetMark( void)
|
||||||
{ m_Data[MARK] = Clamp( nMark, GDB_MK_OFF, GDB_MK_ON_2) ; }
|
{ m_Data[MARK] = GDB_MK_ON ; }
|
||||||
void ResetMark( void)
|
void ResetMark( void)
|
||||||
{ m_Data[MARK] = GDB_MK_OFF ; }
|
{ m_Data[MARK] = GDB_MK_OFF ; }
|
||||||
int GetMark( void) const
|
int GetMark( void) const
|
||||||
|
|||||||
+6
-9
@@ -83,7 +83,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
ICurve*
|
ICurve*
|
||||||
GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
|
GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
|
||||||
const PolyLine& PL, double& dDist, double dTol)
|
const PolyLine& PL, double& dDist)
|
||||||
{
|
{
|
||||||
// calcolo la curva dove giacciono i punti di giunzione tra i due archi del biarco
|
// calcolo la curva dove giacciono i punti di giunzione tra i due archi del biarco
|
||||||
PtrOwner<ICurve> pJCrv( CalcJCurve( ptP0, dDir0Deg, ptP1, dDir1Deg)) ;
|
PtrOwner<ICurve> pJCrv( CalcJCurve( ptP0, dDir0Deg, ptP1, dDir1Deg)) ;
|
||||||
@@ -122,7 +122,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// non c'è intersezione, assegno valore medio
|
// non c'è intersezione, assegno valore medio
|
||||||
if ( dU < -0.5)
|
if ( dU < -0.5)
|
||||||
dU = 0.5 ;
|
dU = 0.5 ;
|
||||||
// elimino casi vicino agli estremi, danno solo problemi
|
// elimino casi vicino agli estremi, danno solo problemi
|
||||||
@@ -142,10 +142,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
|||||||
Point3d ptPrev = ptCurr ;
|
Point3d ptPrev = ptCurr ;
|
||||||
while ( bPnt) {
|
while ( bPnt) {
|
||||||
double dLen = Dist( ptCurr, ptPrev) ;
|
double dLen = Dist( ptCurr, ptPrev) ;
|
||||||
int nStep = int( dLen / STEP) + 1 ;
|
int nStep = ( dLen < STEP ? 2 : 1) * int( dLen / STEP) + 1 ;
|
||||||
int nMinStep = ( dLen > 50 * dTol ? 3 : ( dLen > 10 * dTol ? 2 : 1)) ;
|
|
||||||
int nMaxStep = 10 ;
|
|
||||||
nStep = Clamp( nStep, nMinStep, nMaxStep) ;
|
|
||||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||||
double dCoeff = double( i) / nStep ;
|
double dCoeff = double( i) / nStep ;
|
||||||
Point3d ptP = Media( ptPrev, ptCurr, dCoeff) ;
|
Point3d ptP = Media( ptPrev, ptCurr, dCoeff) ;
|
||||||
@@ -166,7 +163,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
|
|||||||
static ICurve*
|
static ICurve*
|
||||||
CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg)
|
CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg)
|
||||||
{
|
{
|
||||||
// se i due punti coincidono, non si può fare alcunché
|
// se i due punti coincidono, non si può fare alcunché
|
||||||
if ( AreSamePointApprox( ptP0, ptP1))
|
if ( AreSamePointApprox( ptP0, ptP1))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
|
|
||||||
@@ -208,14 +205,14 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD
|
|||||||
double dDir0RelDeg = DiffAngle( dDir0Deg, dDirDiffDeg) ;
|
double dDir0RelDeg = DiffAngle( dDir0Deg, dDirDiffDeg) ;
|
||||||
// direzione iniziale secondo arco limite rispetto a direzione P0->P1 (dalla finale simmetrico e invert)
|
// direzione iniziale secondo arco limite rispetto a direzione P0->P1 (dalla finale simmetrico e invert)
|
||||||
double dDir1RelDeg = - DiffAngle( dDir1Deg, dDirDiffDeg) ;
|
double dDir1RelDeg = - DiffAngle( dDir1Deg, dDirDiffDeg) ;
|
||||||
// nel caso di direzioni a 180deg si sceglie la più compatta
|
// nel caso di direzioni a 180deg si sceglie la più compatta
|
||||||
if ( abs( abs( dDir1RelDeg) - ANG_STRAIGHT) < EPS_SMALL)
|
if ( abs( abs( dDir1RelDeg) - ANG_STRAIGHT) < EPS_SMALL)
|
||||||
dDir1RelDeg = ( dDir0RelDeg > 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ;
|
dDir1RelDeg = ( dDir0RelDeg > 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ;
|
||||||
else if ( abs( abs( dDir0RelDeg) - ANG_STRAIGHT) < EPS_SMALL)
|
else if ( abs( abs( dDir0RelDeg) - ANG_STRAIGHT) < EPS_SMALL)
|
||||||
dDir0RelDeg = ( dDir1RelDeg > 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ;
|
dDir0RelDeg = ( dDir1RelDeg > 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ;
|
||||||
// intervallo angolare ammissibile a partire da direzione iniziale primo arco ammissibile ( == Dir0)
|
// intervallo angolare ammissibile a partire da direzione iniziale primo arco ammissibile ( == Dir0)
|
||||||
double dDeltaAngDeg = - dDir0RelDeg + dDir1RelDeg ;
|
double dDeltaAngDeg = - dDir0RelDeg + dDir1RelDeg ;
|
||||||
// se non è nella regione, prendo l'altra parte di arco
|
// se non è nella regione, prendo l'altra parte di arco
|
||||||
if ( ! AngleInSpan( dDirStartRelDeg, dDir0RelDeg, dDeltaAngDeg))
|
if ( ! AngleInSpan( dDirStartRelDeg, dDir0RelDeg, dDeltaAngDeg))
|
||||||
pArc->ToExplementary() ;
|
pArc->ToExplementary() ;
|
||||||
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1
|
// inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1
|
||||||
|
|||||||
@@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
|
ICurve* GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir1Deg,
|
||||||
const PolyLine& PL, double& dDist, double dTol) ;
|
const PolyLine& PL, double& dDist) ;
|
||||||
|
|
||||||
|
|||||||
@@ -1,513 +0,0 @@
|
|||||||
//----------------------------------------------------------------------------
|
|
||||||
// EgalTech 2024-2024
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// File : CAvSilhouetteSurfTm.cpp Data : 08.06.24 Versione : 2.6f2
|
|
||||||
// Contenuto : Implementazione della funzione CAvSilhouetteSurfTm.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Modifiche : 08.06.24 DS Creazione modulo.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "CAvSilhouetteSurfTm.h"
|
|
||||||
#include "GeoConst.h"
|
|
||||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
|
||||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
|
||||||
#include <thread>
|
|
||||||
#include <future>
|
|
||||||
|
|
||||||
using namespace std ;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Funzioni locali per calcolo isolinee con metodo Marching Squares
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Quadrato (C=corner E=edge) :
|
|
||||||
//
|
|
||||||
// C3 - E2 - C2
|
|
||||||
// | |
|
|
||||||
// E3 E1
|
|
||||||
// | |
|
|
||||||
// C0 - E0 - C1
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static Point3d
|
|
||||||
CalcPoint( const Point3d& ptS, const Point3d& ptE, double dLevel,
|
|
||||||
const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid)
|
|
||||||
{
|
|
||||||
// Distanza tra gli estremi iniziali
|
|
||||||
double dDist = max( abs( ptS.x - ptE.x), abs( ptS.y - ptE.y)) ;
|
|
||||||
|
|
||||||
// Ricerca con metodo di bisezione (si arresta quando il medio è allineato agli estremi)
|
|
||||||
const int MAX_ITER = 10 ;
|
|
||||||
int nCount = 0 ;
|
|
||||||
Point3d ptP1 = ptS ;
|
|
||||||
Point3d ptP2 = ptE ;
|
|
||||||
Point3d ptMid = Media( ptP1, ptP2) ;
|
|
||||||
while ( nCount < MAX_ITER) {
|
|
||||||
// verifica del punto medio
|
|
||||||
ptMid.z = 0 ;
|
|
||||||
Point3d ptTest = GetToGlob( ptMid + cavTstm.GetToolHeight() * Z_AX, frGrid) ;
|
|
||||||
double dMove ;
|
|
||||||
cavTstm.TestPosition( ptTest, frGrid.VersZ(), frGrid.VersZ(), dMove) ;
|
|
||||||
ptMid.z = dMove ;
|
|
||||||
// se sta sulla linea che unisce gli estremi, basta interpolazione lineare
|
|
||||||
if ( abs( ptMid.z - ( ptP1.z + ptP2.z) / 2) < EPS_SMALL / 2)
|
|
||||||
return Media( ptP1, ptP2, ( ptP1.z - dLevel) / ( ptP1.z - ptP2.z)) ;
|
|
||||||
// altrimenti nuova suddivisione della parte con estremi da parte opposta rispetto al livello
|
|
||||||
bool b1On = ( ptP1.z > dLevel) ;
|
|
||||||
bool bMidOn = ( ptMid.z > dLevel) ;
|
|
||||||
if ( b1On != bMidOn)
|
|
||||||
ptP2 = ptMid ;
|
|
||||||
else
|
|
||||||
ptP1 = ptMid ;
|
|
||||||
ptMid = Media( ptP1, ptP2) ;
|
|
||||||
++ nCount ;
|
|
||||||
}
|
|
||||||
ptMid.z = dLevel ;
|
|
||||||
return ptMid ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static int
|
|
||||||
ProcessSquare( int nFlag, int& nI1s, int& nI1e, int& nI2s, int& nI2e)
|
|
||||||
{
|
|
||||||
static int LineTable[16][5] = { { 0, -1, -1, -1, -1},
|
|
||||||
{ 1, 0, 3, -1, -1},
|
|
||||||
{ 1, 1, 0, -1, -1},
|
|
||||||
{ 1, 1, 3, -1, -1},
|
|
||||||
{ 1, 2, 1, -1, -1},
|
|
||||||
{ 2, 0, 1, 2, 3},
|
|
||||||
{ 1, 2, 0, -1, -1},
|
|
||||||
{ 1, 2, 3, -1, -1},
|
|
||||||
{ 1, 3, 2, -1, -1},
|
|
||||||
{ 1, 0, 2, -1, -1},
|
|
||||||
{ 2, 1, 2, 3, 0},
|
|
||||||
{ 1, 1, 2, -1, -1},
|
|
||||||
{ 1, 3, 1, -1, -1},
|
|
||||||
{ 1, 0, 1, -1, -1},
|
|
||||||
{ 1, 3, 0, -1, -1},
|
|
||||||
{ 0, -1, -1, -1, -1}} ;
|
|
||||||
// flag fuori dai limiti
|
|
||||||
if ( nFlag < 0 || nFlag > 15)
|
|
||||||
return -1 ;
|
|
||||||
// nessuna linea
|
|
||||||
if ( LineTable[nFlag][0] == 0)
|
|
||||||
return 0 ;
|
|
||||||
// una linea
|
|
||||||
else if ( LineTable[nFlag][0] == 1) {
|
|
||||||
nI1s = LineTable[nFlag][1] ;
|
|
||||||
nI1e = LineTable[nFlag][2] ;
|
|
||||||
return 1 ;
|
|
||||||
}
|
|
||||||
// due linee
|
|
||||||
else if ( LineTable[nFlag][0] == 2) {
|
|
||||||
nI1s = LineTable[nFlag][1] ;
|
|
||||||
nI1e = LineTable[nFlag][2] ;
|
|
||||||
nI2s = LineTable[nFlag][3] ;
|
|
||||||
nI2e = LineTable[nFlag][4] ;
|
|
||||||
return 2 ;
|
|
||||||
}
|
|
||||||
return -1 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool
|
|
||||||
TestSubEdges( unordered_map<int, Point3d>& umEdgePnt, const INTVECTOR& vEdgeInd, int nFirst, int nLast,
|
|
||||||
const DBLVECTOR& vdGrid, int nStepX, double dStep,
|
|
||||||
double dLevel, const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid)
|
|
||||||
{
|
|
||||||
for ( int k = nFirst ; k <= nLast ; ++ k) {
|
|
||||||
// recupero i differenti indici
|
|
||||||
int nKey = vEdgeInd[k] ;
|
|
||||||
int nInd = nKey / 2 ;
|
|
||||||
bool bOnX = ( ( nKey % 2) == 0) ;
|
|
||||||
int j = nInd / ( nStepX + 1) ;
|
|
||||||
int i = nInd % ( nStepX + 1) ;
|
|
||||||
// determino i punti estremi dell'edge
|
|
||||||
Point3d ptS{ i * dStep, j * dStep, vdGrid[nInd]} ;
|
|
||||||
Point3d ptE{ ptS.x + ( bOnX ? dStep : 0), ptS.y + ( bOnX ? 0 : dStep), vdGrid[nInd + ( bOnX ? 1 : nStepX + 1)]} ;
|
|
||||||
// calcolo il punto
|
|
||||||
Point3d ptQ = CalcPoint( ptS, ptE, dLevel, cavTstm, frGrid) ;
|
|
||||||
umEdgePnt[ nKey] = ptQ ;
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool
|
|
||||||
MarchingSquares( const DBLVECTOR& vdGrid, int nStepX, int nStepY, double dStep, double dRad,
|
|
||||||
double dLevel, const ICAvToolSurfTm& cavTstm, const Frame3d &frGrid, POLYLINEVECTOR& vPL)
|
|
||||||
{
|
|
||||||
// Analizzo gli edge da cui passano le curve cercate
|
|
||||||
unordered_map<int, Point3d> umEdgePnt( 4 * ( nStepX + nStepY)) ;
|
|
||||||
INTVECTOR vEdgeInd ;
|
|
||||||
vEdgeInd.reserve( 4 * ( nStepX + nStepY)) ;
|
|
||||||
for ( int j = 0 ; j < nStepY ; ++ j) {
|
|
||||||
for ( int i = 0 ; i < nStepX ; ++ i) {
|
|
||||||
// indici dei vertici nella griglia
|
|
||||||
int nInd0 = i + j * ( nStepX + 1) ;
|
|
||||||
int nInd1 = ( i + 1) + j * ( nStepX + 1) ;
|
|
||||||
int nInd2 = ( i + 1) + ( j + 1) * ( nStepX + 1) ;
|
|
||||||
int nInd3 = i + ( j + 1) * ( nStepX + 1) ;
|
|
||||||
// flag del quadrato
|
|
||||||
bool bUp0 = ( vdGrid[nInd0] > dLevel) ;
|
|
||||||
bool bUp1 = ( vdGrid[nInd1] > dLevel) ;
|
|
||||||
bool bUp2 = ( vdGrid[nInd2] > dLevel) ;
|
|
||||||
bool bUp3 = ( vdGrid[nInd3] > dLevel) ;
|
|
||||||
// se tutti uguali, passo al successivo
|
|
||||||
if ( bUp0 == bUp1 && bUp0 == bUp2 && bUp0 == bUp3)
|
|
||||||
continue ;
|
|
||||||
// verifico quali calcolare
|
|
||||||
if ( bUp0 != bUp1) {
|
|
||||||
int nKey = 2 * nInd0 ;
|
|
||||||
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
|
|
||||||
umEdgePnt[ nKey] = P_INVALID ;
|
|
||||||
vEdgeInd.emplace_back( nKey) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bUp3 != bUp2) {
|
|
||||||
int nKey = 2 * nInd3 ;
|
|
||||||
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
|
|
||||||
umEdgePnt[ nKey] = P_INVALID ;
|
|
||||||
vEdgeInd.emplace_back( nKey) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bUp0 != bUp3) {
|
|
||||||
int nKey = 2 * nInd0 + 1 ;
|
|
||||||
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
|
|
||||||
umEdgePnt[ nKey] = P_INVALID ;
|
|
||||||
vEdgeInd.emplace_back( nKey) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bUp1 != bUp2) {
|
|
||||||
int nKey = 2 * nInd1 + 1 ;
|
|
||||||
if ( umEdgePnt.find( nKey) == umEdgePnt.end()) {
|
|
||||||
umEdgePnt[ nKey] = P_INVALID ;
|
|
||||||
vEdgeInd.emplace_back( nKey) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Numero di edge da valutare
|
|
||||||
int nEdgeCnt = int( vEdgeInd.size()) ;
|
|
||||||
// Recupero il numero massimo di thread concorrenti
|
|
||||||
int nThreadMax = thread::hardware_concurrency() ;
|
|
||||||
bool bOk = true ;
|
|
||||||
// Se un solo thread o pochi punti
|
|
||||||
if ( nThreadMax <= 1 || nEdgeCnt < 50) {
|
|
||||||
TestSubEdges( umEdgePnt, vEdgeInd, 0, nEdgeCnt - 1, vdGrid, nStepX, dStep, dLevel, cavTstm, frGrid) ;
|
|
||||||
}
|
|
||||||
// altrimenti
|
|
||||||
else {
|
|
||||||
const int MAX_PARTS = 32 ;
|
|
||||||
INTINTVECTOR vFstLst( MAX_PARTS) ;
|
|
||||||
// calcolo le parti del vettore
|
|
||||||
int nPartCnt = min( nThreadMax, MAX_PARTS) ;
|
|
||||||
int nPartDim = nEdgeCnt / nPartCnt + 1 ;
|
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i) {
|
|
||||||
vFstLst[i].first = i * nPartDim ;
|
|
||||||
vFstLst[i].second = min( ( i + 1) * nPartDim, nEdgeCnt) - 1 ;
|
|
||||||
}
|
|
||||||
// processo le parti
|
|
||||||
future<bool> vRes[MAX_PARTS] ;
|
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i)
|
|
||||||
vRes[i] = async( launch::async, &TestSubEdges, ref( umEdgePnt), cref( vEdgeInd), vFstLst[i].first, vFstLst[i].second,
|
|
||||||
cref( vdGrid), nStepX, dStep, dLevel, cref( cavTstm), cref( frGrid)) ;
|
|
||||||
// attendo i risultati
|
|
||||||
int nFin = 0 ;
|
|
||||||
while ( nFin < nPartCnt) {
|
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i) {
|
|
||||||
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
|
||||||
bOk = vRes[i].get() && bOk ;
|
|
||||||
++ nFin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Predispongo il concatenamento
|
|
||||||
BIPNTVECTOR vBiPnt ;
|
|
||||||
vBiPnt.reserve( 2 * ( nStepX + nStepY)) ;
|
|
||||||
ChainCurves chainC ;
|
|
||||||
chainC.Init( false, EPS_SMALL, 2 * ( nStepX + nStepY)) ;
|
|
||||||
// Ciclo sui quadrati da analizzare
|
|
||||||
for ( int j = 0 ; j < nStepY ; ++ j) {
|
|
||||||
for ( int i = 0 ; i < nStepX ; ++ i) {
|
|
||||||
// indici dei vertici nella griglia
|
|
||||||
int nInd0 = i + j * ( nStepX + 1) ;
|
|
||||||
int nInd1 = ( i + 1) + j * ( nStepX + 1) ;
|
|
||||||
int nInd2 = ( i + 1) + ( j + 1) * ( nStepX + 1) ;
|
|
||||||
int nInd3 = i + ( j + 1) * ( nStepX + 1) ;
|
|
||||||
// flag del quadrato
|
|
||||||
int nFlag = ( vdGrid[nInd0] > dLevel ? 1 : 0) +
|
|
||||||
( vdGrid[nInd1] > dLevel ? 2 : 0) +
|
|
||||||
( vdGrid[nInd2] > dLevel ? 4 : 0) +
|
|
||||||
( vdGrid[nInd3] > dLevel ? 8 : 0) ;
|
|
||||||
// se quadrato con vertici tutti dello stesso tipo, passo al successivo
|
|
||||||
if ( nFlag == 0 || nFlag == 15)
|
|
||||||
continue ;
|
|
||||||
// chiavi
|
|
||||||
int vKey[4] = { 2 * nInd0, 2 * nInd1 + 1, 2 * nInd3, 2 * nInd0 + 1} ;
|
|
||||||
// calcolo segmenti da inserire
|
|
||||||
int nI1s, nI1e, nI2s, nI2e ;
|
|
||||||
int nSegCnt = ProcessSquare( nFlag, nI1s, nI1e, nI2s, nI2e) ;
|
|
||||||
if ( nSegCnt == -1)
|
|
||||||
return false ;
|
|
||||||
else if ( nSegCnt == 1) {
|
|
||||||
Point3d ptL1s = umEdgePnt.find( vKey[nI1s])->second ;
|
|
||||||
Point3d ptL1e = umEdgePnt.find( vKey[nI1e])->second ;
|
|
||||||
vBiPnt.emplace_back( ptL1s, ptL1e) ;
|
|
||||||
Vector3d vtDir1 = ptL1e - ptL1s ; vtDir1.Normalize() ;
|
|
||||||
chainC.AddCurve( int( vBiPnt.size()), ptL1s, vtDir1, ptL1e, vtDir1) ;
|
|
||||||
}
|
|
||||||
else if ( nSegCnt == 2) {
|
|
||||||
Point3d ptL1s = umEdgePnt.find( vKey[nI1s])->second ;
|
|
||||||
Point3d ptL1e = umEdgePnt.find( vKey[nI1e])->second ;
|
|
||||||
vBiPnt.emplace_back( ptL1s, ptL1e) ;
|
|
||||||
Vector3d vtDir1 = ptL1e - ptL1s ; vtDir1.Normalize() ;
|
|
||||||
chainC.AddCurve( int( vBiPnt.size()), ptL1s, vtDir1, ptL1e, vtDir1) ;
|
|
||||||
Point3d ptL2s = umEdgePnt.find( vKey[nI2s])->second ;
|
|
||||||
Point3d ptL2e = umEdgePnt.find( vKey[nI2e])->second ;
|
|
||||||
vBiPnt.emplace_back( ptL2s, ptL2e) ;
|
|
||||||
Vector3d vtDir2 = ptL2e - ptL2s ; vtDir2.Normalize() ;
|
|
||||||
chainC.AddCurve( int( vBiPnt.size()), ptL2s, vtDir2, ptL2e, vtDir2) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recupero i contorni
|
|
||||||
INTVECTOR vnId ;
|
|
||||||
while ( chainC.GetChainFromNear( ORIG, false, vnId)) {
|
|
||||||
// creo una composita
|
|
||||||
CurveComposite crvCompo ;
|
|
||||||
crvCompo.AddPoint( vBiPnt[vnId[0]-1].first) ;
|
|
||||||
for ( int i = 0 ; i < int( vnId.size()) ; ++ i) {
|
|
||||||
Point3d ptCurr = vBiPnt[vnId[i]-1].second ;
|
|
||||||
crvCompo.AddLine( ptCurr) ;
|
|
||||||
}
|
|
||||||
// la chiudo
|
|
||||||
crvCompo.Close() ;
|
|
||||||
// elimino le parti allineate
|
|
||||||
crvCompo.MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG) ;
|
|
||||||
// salto i contorni orari con area inferiore al doppio del quadrato
|
|
||||||
double dCmpArea ;
|
|
||||||
if ( ! crvCompo.GetAreaXY( dCmpArea) || ( dCmpArea < 0 && abs( dCmpArea) < 2 * dStep * dStep))
|
|
||||||
continue ;
|
|
||||||
// per test mettere a 1
|
|
||||||
#if 0
|
|
||||||
vPL.emplace_back( PolyLine()) ;
|
|
||||||
crvCompo.ApproxWithLines( 0, 0, ICurve::APL_SPECIAL, vPL.back()) ;
|
|
||||||
#else
|
|
||||||
// eseguo offset a sinistra pari allo step
|
|
||||||
OffsetCurve offsCompo ;
|
|
||||||
offsCompo.Make( &crvCompo, -( dRad - 2 * EPS_SMALL), ICurve::OFF_CHAMFER) ;
|
|
||||||
PtrOwner<ICurve> pCrvOffset( offsCompo.GetLongerCurve()) ;
|
|
||||||
if ( ! IsNull( pCrvOffset)) {
|
|
||||||
vPL.emplace_back( PolyLine()) ;
|
|
||||||
pCrvOffset->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, vPL.back()) ;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Silhouette rispetto ad una direzione e sopra una quota di una superficie TriMesh
|
|
||||||
// ( dTol è il passo della griglia di campionamento e il raggio del cilindro di prova)
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvSilhouetteSurfTm( const ISurfTriMesh& Stm, const Plane3d& plPlane, double dTol, POLYLINEVECTOR& vPL)
|
|
||||||
{
|
|
||||||
// verifico superficie
|
|
||||||
if ( &Stm == nullptr || ! Stm.IsValid())
|
|
||||||
return false ;
|
|
||||||
// verifico piano
|
|
||||||
if ( &plPlane == nullptr || plPlane.GetVersN().IsSmall())
|
|
||||||
return false ;
|
|
||||||
// verifico tolleranza
|
|
||||||
dTol = max( dTol, 100 * EPS_SMALL) ;
|
|
||||||
// verifico parametri di ritorno
|
|
||||||
if ( &vPL == nullptr)
|
|
||||||
return false ;
|
|
||||||
vPL.clear() ;
|
|
||||||
|
|
||||||
// sistema di riferimento nel piano
|
|
||||||
Frame3d frGrid ;
|
|
||||||
if ( ! frGrid.Set( plPlane.GetPoint(), plPlane.GetVersN()))
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// bounding box della superficie nel riferimento del piano
|
|
||||||
BBox3d b3Surf ;
|
|
||||||
if ( ! Stm.GetBBox( GetInvert( frGrid), b3Surf, BBF_STANDARD))
|
|
||||||
return false ;
|
|
||||||
// calcolo dati della griglia
|
|
||||||
const double EXTRA_XY = 1.5 * dTol ;
|
|
||||||
const double EXTRA_Z = 10 * dTol ;
|
|
||||||
b3Surf.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
|
|
||||||
int nStepX = int( ceil( b3Surf.GetDimX() / dTol)) ;
|
|
||||||
int nStepY = int( ceil( b3Surf.GetDimY() / dTol)) ;
|
|
||||||
frGrid.ChangeOrig( GetToGlob( b3Surf.GetMin(), frGrid)) ;
|
|
||||||
double dDimZ = b3Surf.GetDimZ() ;
|
|
||||||
double dLevelOffs = - b3Surf.GetMin().z ;
|
|
||||||
|
|
||||||
// calcolo dei punti della griglia (sul top del cilindro)
|
|
||||||
PNTUVECTOR vPntM( ( nStepX + 1) * ( nStepY + 1)) ;
|
|
||||||
for ( int j = 0 ; j <= nStepY ; ++ j) {
|
|
||||||
for ( int i = 0 ; i <= nStepX ; ++ i) {
|
|
||||||
int nInd = i + j * ( nStepX + 1) ;
|
|
||||||
Point3d ptP = GetToGlob( Point3d( i * dTol, j * dTol, dDimZ), frGrid) ;
|
|
||||||
vPntM[nInd] = { ptP, 0.} ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// esecuzione della verifica
|
|
||||||
double dRad = SQRT1_2 * dTol ;
|
|
||||||
CAvToolSurfTm cavTstm ;
|
|
||||||
cavTstm.SetStdTool( dDimZ, dRad, 0) ;
|
|
||||||
cavTstm.SetSurfTm( Stm) ;
|
|
||||||
if ( ! cavTstm.TestSeries( vPntM, frGrid.VersZ(), frGrid.VersZ(), -1))
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// griglia degli spostamenti
|
|
||||||
DBLVECTOR vdGrid( ( nStepX + 1) * ( nStepY + 1)) ;
|
|
||||||
for ( int j = 0 ; j <= nStepY ; ++ j) {
|
|
||||||
for ( int i = 0 ; i <= nStepX ; ++ i) {
|
|
||||||
int nInd = i + j * ( nStepX + 1) ;
|
|
||||||
vdGrid[nInd] = vPntM[nInd].second ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// calcolo della silhouette con il metodo MarchingSquares
|
|
||||||
double dLevel = dLevelOffs ;
|
|
||||||
if ( ! MarchingSquares( vdGrid, nStepX, nStepY, dTol, dRad, dLevel, cavTstm, frGrid, vPL))
|
|
||||||
return false ;
|
|
||||||
// riporto nella corretta posizione le curve trovate
|
|
||||||
for ( auto& PL : vPL)
|
|
||||||
PL.ToGlob( frGrid) ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Silhouette rispetto ad una direzione e sopra diverse quote di una superficie TriMesh
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
ICAvParSilhouettesSurfTm*
|
|
||||||
CreateCAvParSilhouettesSurfTm( void)
|
|
||||||
{
|
|
||||||
return static_cast<ICAvParSilhouettesSurfTm*> ( new(nothrow) CAvParSilhouettesSurfTm) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
CAvParSilhouettesSurfTm::CAvParSilhouettesSurfTm( void)
|
|
||||||
: m_dTol( 100 * EPS_SMALL), m_nStepX( 0), m_nStepY( 0), m_dRad( m_dTol), m_dLevelOffs( 0), m_bGridOk( false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvParSilhouettesSurfTm::SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol)
|
|
||||||
{
|
|
||||||
m_vpStm = vpStm ;
|
|
||||||
m_frGrid = frPlanes ;
|
|
||||||
m_dTol = max( dTol, 100 * EPS_SMALL) ;
|
|
||||||
m_dRad = SQRT1_2 * m_dTol ;
|
|
||||||
m_nStepX = 0 ;
|
|
||||||
m_nStepY = 0 ;
|
|
||||||
m_dDimZ = 0 ;
|
|
||||||
m_dLevelOffs = 0 ;
|
|
||||||
m_bGridOk = false ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvParSilhouettesSurfTm::Prepare( void)
|
|
||||||
{
|
|
||||||
// ingombro delle superfici nel riferimento dei piani
|
|
||||||
BBox3d b3All ;
|
|
||||||
Frame3d frInv = GetInvert( m_frGrid) ;
|
|
||||||
for ( auto pStm : m_vpStm) {
|
|
||||||
BBox3d b3Surf ;
|
|
||||||
if ( ! pStm->GetBBox( frInv, b3Surf, BBF_STANDARD))
|
|
||||||
return false ;
|
|
||||||
b3All.Add( b3Surf) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calcolo dati della griglia
|
|
||||||
const double EXTRA_XY = 1.5 * m_dTol ;
|
|
||||||
const double EXTRA_Z = 10 * m_dTol ;
|
|
||||||
b3All.Expand( EXTRA_XY, EXTRA_XY, EXTRA_Z) ;
|
|
||||||
m_nStepX = int( ceil( b3All.GetDimX() / m_dTol)) ;
|
|
||||||
m_nStepY = int( ceil( b3All.GetDimY() / m_dTol)) ;
|
|
||||||
m_frGrid.ChangeOrig( GetToGlob( b3All.GetMin(), m_frGrid)) ;
|
|
||||||
m_dDimZ = b3All.GetDimZ() ;
|
|
||||||
m_dLevelOffs = - b3All.GetMin().z ;
|
|
||||||
|
|
||||||
// calcolo dei punti della griglia (sul top del cilindro)
|
|
||||||
PNTUVECTOR vPntM( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
|
|
||||||
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
|
|
||||||
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
|
|
||||||
int nInd = i + j * ( m_nStepX + 1) ;
|
|
||||||
Point3d ptP = GetToGlob( Point3d( i * m_dTol, j * m_dTol, m_dDimZ), m_frGrid) ;
|
|
||||||
vPntM[nInd] = { ptP, 0.} ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// esecuzione della verifica
|
|
||||||
if ( ! m_cavTstm.SetStdTool( m_dDimZ, m_dRad, 0))
|
|
||||||
return false ;
|
|
||||||
if ( m_vpStm.empty() || ! m_cavTstm.SetSurfTm( *( m_vpStm[0])))
|
|
||||||
return false ;
|
|
||||||
for ( int k = 1 ; k < int( m_vpStm.size()) ; ++ k)
|
|
||||||
m_cavTstm.AddSurfTm( *( m_vpStm[k])) ;
|
|
||||||
if ( ! m_cavTstm.TestSeries( vPntM, m_frGrid.VersZ(), m_frGrid.VersZ(), -1))
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// griglia degli spostamenti
|
|
||||||
m_vdGrid.clear() ;
|
|
||||||
m_vdGrid.resize( ( m_nStepX + 1) * ( m_nStepY + 1)) ;
|
|
||||||
for ( int j = 0 ; j <= m_nStepY ; ++ j) {
|
|
||||||
for ( int i = 0 ; i <= m_nStepX ; ++ i) {
|
|
||||||
int nInd = i + j * ( m_nStepX + 1) ;
|
|
||||||
m_vdGrid[nInd] = vPntM[nInd].second ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvParSilhouettesSurfTm::GetSilhouette( double dLevel, POLYLINEVECTOR& vPL)
|
|
||||||
{
|
|
||||||
// reset risultato
|
|
||||||
vPL.clear() ;
|
|
||||||
|
|
||||||
// se necessario eseguo i calcoli preparatori
|
|
||||||
if ( ! m_bGridOk && ! Prepare())
|
|
||||||
return false ;
|
|
||||||
m_bGridOk = true ;
|
|
||||||
|
|
||||||
// calcolo della silhouette con il metodo MarchingSquares
|
|
||||||
dLevel += m_dLevelOffs ;
|
|
||||||
double dCalcLevel = max( dLevel, 0.) ;
|
|
||||||
if ( ! MarchingSquares( m_vdGrid, m_nStepX, m_nStepY, m_dTol, m_dRad, dCalcLevel, m_cavTstm, m_frGrid, vPL))
|
|
||||||
return false ;
|
|
||||||
// riporto nella corretta posizione le curve trovate
|
|
||||||
for ( auto& PL : vPL) {
|
|
||||||
if ( dLevel < dCalcLevel - EPS_SMALL)
|
|
||||||
PL.Translate( Vector3d{ 0, 0, dLevel - dCalcLevel}) ;
|
|
||||||
PL.ToGlob( m_frGrid) ;
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
//----------------------------------------------------------------------------
|
|
||||||
// EgalTech 2024-2024
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// File : CAvSilhouetteSurfTm.h Data : 16.06.24 Versione : 2.6f2
|
|
||||||
// Contenuto : Dichiarazione della classe calcolo multi-silhouette.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Modifiche : 10.06.24 DS Creazione modulo.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CAvToolSurfTm.h"
|
|
||||||
#include "/EgtDev/Include/EGkCAvSilhouetteSurfTm.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CAvParSilhouettesSurfTm : public ICAvParSilhouettesSurfTm
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
bool SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol) override ;
|
|
||||||
bool GetSilhouette( double dLevel, POLYLINEVECTOR& vPL) override ;
|
|
||||||
|
|
||||||
public :
|
|
||||||
CAvParSilhouettesSurfTm( void) ;
|
|
||||||
|
|
||||||
private :
|
|
||||||
bool Prepare( void) ;
|
|
||||||
|
|
||||||
private :
|
|
||||||
CISURFTMPVECTOR m_vpStm ;
|
|
||||||
CAvToolSurfTm m_cavTstm ;
|
|
||||||
Frame3d m_frGrid ;
|
|
||||||
double m_dTol ;
|
|
||||||
int m_nStepX ;
|
|
||||||
int m_nStepY ;
|
|
||||||
double m_dRad ;
|
|
||||||
double m_dDimZ ;
|
|
||||||
double m_dLevelOffs ;
|
|
||||||
bool m_bGridOk ;
|
|
||||||
DBLVECTOR m_vdGrid ;
|
|
||||||
} ;
|
|
||||||
+41
-209
@@ -1,21 +1,21 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2018-2024
|
// EgalTech 2018-2018
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : CAvToolSurfTm.cpp Data : 07.06.24 Versione : 2.6f2
|
// File : CAvToolSurfTm.cpp Data : 08.05.18 Versione : 1.9e2
|
||||||
// Contenuto : Implementazione della classe CAvToolSurfTm.
|
// Contenuto : Implementazione della classe CAvToolSurfTm.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Modifiche : 27.04.18 DS Creazione modulo.
|
// Modifiche : 27.04.18 DS Creazione modulo.
|
||||||
// 07.06.24 DS Con tolleranza lineare negativa non si controlla il punto medio.
|
//
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CAvToolTriangle.h"
|
#include "CAvToolTriangle.h"
|
||||||
#include "CAvToolSurfTm.h"
|
#include "CAvToolSurfTm.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "DllMain.h"
|
#include "DllMain.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <future>
|
#include <future>
|
||||||
@@ -37,29 +37,10 @@ CreateCAvToolSurfTm( void)
|
|||||||
// CAvToolSurfTm
|
// CAvToolSurfTm
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
CAvToolSurfTm::CAvToolSurfTm( void)
|
CAvToolSurfTm::CAvToolSurfTm( void)
|
||||||
: m_frMove( false), m_Tool( false)
|
: m_Tool( false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvToolSurfTm::Clear( void)
|
|
||||||
{
|
|
||||||
// pulisco la lista dei puntatori a Stm
|
|
||||||
m_vSTM.clear() ;
|
|
||||||
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
|
|
||||||
m_vBaseInd.clear() ;
|
|
||||||
m_vBaseInd.emplace_back( 0) ;
|
|
||||||
// pulisco HashGrid 2d
|
|
||||||
m_HGrids.Clear() ;
|
|
||||||
// reset utensile
|
|
||||||
m_Tool.Clear() ;
|
|
||||||
// reset riferimento
|
|
||||||
m_frMove.Reset( false) ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
|
CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
|
||||||
@@ -69,9 +50,6 @@ CAvToolSurfTm::SetSurfTm( const ISurfTriMesh& Stm)
|
|||||||
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
|
// pulisco e inizializzo la prima posizione della lista delle basi per gli indici dei triangoli
|
||||||
m_vBaseInd.clear() ;
|
m_vBaseInd.clear() ;
|
||||||
m_vBaseInd.emplace_back( 0) ;
|
m_vBaseInd.emplace_back( 0) ;
|
||||||
// pulisco HashGrid 2d
|
|
||||||
m_HGrids.Clear() ;
|
|
||||||
// non tocco l'utensile
|
|
||||||
// aggiungo la superficie
|
// aggiungo la superficie
|
||||||
return AddSurfTm( Stm) ;
|
return AddSurfTm( Stm) ;
|
||||||
}
|
}
|
||||||
@@ -121,8 +99,7 @@ CAvToolSurfTm::SetGenTool( const ICurveComposite* pToolOutline)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove,
|
CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist)
|
||||||
double& dTotDist, Vector3d* pvtTriaN) const
|
|
||||||
{
|
{
|
||||||
// Se utensile non definito, errore
|
// Se utensile non definito, errore
|
||||||
if ( m_Tool.GetType() == Tool::UNDEF)
|
if ( m_Tool.GetType() == Tool::UNDEF)
|
||||||
@@ -130,148 +107,20 @@ CAvToolSurfTm::TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Ve
|
|||||||
// Se direzioni non definite, errore
|
// Se direzioni non definite, errore
|
||||||
if ( vtDir.IsSmall() || vtMove.IsSmall())
|
if ( vtDir.IsSmall() || vtMove.IsSmall())
|
||||||
return false ;
|
return false ;
|
||||||
// Se riferimento di movimento già presente
|
// Imposto il riferimento di movimento
|
||||||
if ( m_frMove.IsValid()) {
|
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
||||||
// Calcolo nuovo riferimento di movimento
|
m_frMove.Set( ORIG, vtMove, vtDir) ;
|
||||||
Frame3d frMove ;
|
else
|
||||||
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
m_frMove.Set( ORIG, vtMove) ;
|
||||||
frMove.Set( ORIG, vtMove, vtDir) ;
|
// Eseguo controllo
|
||||||
else
|
|
||||||
frMove.Set( ORIG, vtMove) ;
|
|
||||||
// Se riferimenti di movimento uguali, sfrutto HashGrid 2d
|
|
||||||
if ( AreSameFrame( frMove, m_frMove)) {
|
|
||||||
// Eseguo controllo
|
|
||||||
Point3d ptCurr = ptT ;
|
|
||||||
Vector3d vtTriaN ;
|
|
||||||
dTotDist = MyTestPositionHG( ptCurr, vtDir, vtTriaN) ;
|
|
||||||
if ( pvtTriaN != nullptr)
|
|
||||||
*pvtTriaN = vtTriaN ;
|
|
||||||
return ( dTotDist > - EPS_SMALL) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Altrimenti eseguo controllo diretto
|
|
||||||
Point3d ptCurr = ptT ;
|
Point3d ptCurr = ptT ;
|
||||||
Vector3d vtTriaN ;
|
dTotDist = MyTestPosition( ptCurr, vtDir) ;
|
||||||
dTotDist = MyTestPosition( ptCurr, vtDir, vtMove, vtTriaN) ;
|
|
||||||
if ( pvtTriaN != nullptr)
|
|
||||||
*pvtTriaN = vtTriaN ;
|
|
||||||
return ( dTotDist > - EPS_SMALL) ;
|
return ( dTotDist > - EPS_SMALL) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CAvToolSurfTm::TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dProgCoeff)
|
CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol)
|
||||||
{
|
|
||||||
// Se utensile non definito, errore
|
|
||||||
if ( m_Tool.GetType() == Tool::UNDEF)
|
|
||||||
return false ;
|
|
||||||
// Se direzioni non definite, errore
|
|
||||||
if ( vtDir.IsSmall() || vtMove.IsSmall())
|
|
||||||
return false ;
|
|
||||||
// Se vettore vuoto, non devo fare alcunché
|
|
||||||
if ( vPntM.empty())
|
|
||||||
return true ;
|
|
||||||
// Calcolo nuovo riferimento di movimento
|
|
||||||
Frame3d frMove ;
|
|
||||||
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
|
||||||
frMove.Set( ORIG, vtMove, vtDir) ;
|
|
||||||
else
|
|
||||||
frMove.Set( ORIG, vtMove) ;
|
|
||||||
// Se riferimento di movimento non presente o diverso dal calcolato
|
|
||||||
if ( ! m_frMove.IsValid() || ! AreSameFrame( frMove, m_frMove)) {
|
|
||||||
// Salvo nuovo riferimento
|
|
||||||
m_frMove = frMove ;
|
|
||||||
// Ricalcolo HashGrid
|
|
||||||
if ( ! PrepareHashGrid())
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
// Determino il numero di punti dell'insieme
|
|
||||||
m_nTotPnt = int( vPntM.size()) ;
|
|
||||||
// Recupero il numero massimo di thread concorrenti
|
|
||||||
int nThreadMax = thread::hardware_concurrency() ;
|
|
||||||
bool bOk = true ;
|
|
||||||
// Se un solo thread o pochi punti
|
|
||||||
if ( nThreadMax <= 1 || m_nTotPnt < 500) {
|
|
||||||
m_nCurrPnt = 0 ;
|
|
||||||
bOk = TestSubSeries( -1, vPntM, vtDir, 0, m_nTotPnt - 1, dProgCoeff) ;
|
|
||||||
ProcessEvents( int( 100 * dProgCoeff), 0) ;
|
|
||||||
}
|
|
||||||
// altrimenti
|
|
||||||
else {
|
|
||||||
const int MAX_PARTS = 32 ;
|
|
||||||
INTINTVECTOR vFstLst( MAX_PARTS) ;
|
|
||||||
// calcolo le parti del vettore
|
|
||||||
int nPartCnt = min( nThreadMax, MAX_PARTS) ;
|
|
||||||
int nPartDim = m_nTotPnt / nPartCnt + 1 ;
|
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i) {
|
|
||||||
vFstLst[i].first = i * nPartDim ;
|
|
||||||
vFstLst[i].second = min( ( i + 1) * nPartDim, m_nTotPnt) - 1 ;
|
|
||||||
}
|
|
||||||
// processo le parti
|
|
||||||
m_nCurrPnt = 0 ;
|
|
||||||
m_bBreak = false ;
|
|
||||||
future<bool> vRes[MAX_PARTS] ;
|
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i)
|
|
||||||
vRes[i] = async( launch::async, &CAvToolSurfTm::TestSubSeries, this, i, ref( vPntM), cref( vtDir), vFstLst[i].first, vFstLst[i].second, dProgCoeff) ;
|
|
||||||
// attendo i risultati
|
|
||||||
int nFin = 0 ;
|
|
||||||
int nNextPE = 0 ;
|
|
||||||
while ( nFin < nPartCnt) {
|
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i) {
|
|
||||||
if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
|
||||||
bOk = vRes[i].get() && bOk ;
|
|
||||||
++ nFin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( m_nCurrPnt > nNextPE) {
|
|
||||||
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 10) ;
|
|
||||||
nNextPE += STEP_PE ;
|
|
||||||
if ( nRes == 1)
|
|
||||||
m_bBreak = true ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ProcessEvents( int( 100 * dProgCoeff), 0) ;
|
|
||||||
}
|
|
||||||
return bOk ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvToolSurfTm::TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir, int nFirst, int nLast, double dProgCoeff)
|
|
||||||
{
|
|
||||||
// Se vettore vuoto, non devo fare alcunché
|
|
||||||
if ( vPntM.empty())
|
|
||||||
return true ;
|
|
||||||
// Ciclo sui punti da verificare
|
|
||||||
for ( int i = nFirst ; i <= nLast ; ++ i) {
|
|
||||||
// verifico il punto
|
|
||||||
Vector3d vtTriaN ;
|
|
||||||
double dMove = MyTestPositionHG( vPntM[i].first, vtDir, vtTriaN) ;
|
|
||||||
vPntM[i].second = dMove ;
|
|
||||||
if ( dMove < - EPS_SMALL)
|
|
||||||
return false ;
|
|
||||||
++ m_nCurrPnt ;
|
|
||||||
// se singolo thread
|
|
||||||
if ( nId == -1) {
|
|
||||||
// gestione eventi (ogni STEP_PE punti)
|
|
||||||
if (( m_nCurrPnt % STEP_PE) == 0) {
|
|
||||||
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 0) ;
|
|
||||||
if ( nRes == 1)
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// altrimenti multithread
|
|
||||||
else {
|
|
||||||
if ( m_bBreak)
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol, double dProgCoeff)
|
|
||||||
{
|
{
|
||||||
// Se utensile non definito, errore
|
// Se utensile non definito, errore
|
||||||
if ( m_Tool.GetType() == Tool::UNDEF)
|
if ( m_Tool.GetType() == Tool::UNDEF)
|
||||||
@@ -282,25 +131,14 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
|||||||
// Se lista vuota, non devo fare alcunché
|
// Se lista vuota, non devo fare alcunché
|
||||||
if ( lPntM.empty())
|
if ( lPntM.empty())
|
||||||
return true ;
|
return true ;
|
||||||
// Controllo la tolleranza lineare (se negativa non vanno fatti controlli sui punti medi)
|
// Imposto il riferimento di movimento
|
||||||
if ( dLinTol > -EPS_ZERO)
|
|
||||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
|
||||||
else
|
|
||||||
dLinTol = -1 ;
|
|
||||||
// Calcolo nuovo riferimento di movimento
|
|
||||||
Frame3d frMove ;
|
|
||||||
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
if ( ! AreSameOrOppositeVectorApprox( vtDir, vtMove))
|
||||||
frMove.Set( ORIG, vtMove, vtDir) ;
|
m_frMove.Set( ORIG, vtMove, vtDir) ;
|
||||||
else
|
else
|
||||||
frMove.Set( ORIG, vtMove) ;
|
m_frMove.Set( ORIG, vtMove) ;
|
||||||
// Se riferimento di movimento non presente o diverso dal calcolato
|
// Predispongo Hash Grid
|
||||||
if ( ! m_frMove.IsValid() || ! AreSameFrame( frMove, m_frMove)) {
|
if ( ! PrepareHashGrid())
|
||||||
// Salvo nuovo riferimento
|
return false ;
|
||||||
m_frMove = frMove ;
|
|
||||||
// Ricalcolo HashGrid
|
|
||||||
if ( ! PrepareHashGrid())
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
// Determino il numero di punti del path
|
// Determino il numero di punti del path
|
||||||
m_nTotPnt = int( lPntM.size()) ;
|
m_nTotPnt = int( lPntM.size()) ;
|
||||||
// Recupero il numero massimo di thread concorrenti
|
// Recupero il numero massimo di thread concorrenti
|
||||||
@@ -308,9 +146,8 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
|||||||
bool bOk = true ;
|
bool bOk = true ;
|
||||||
// Se un solo thread o pochi punti
|
// Se un solo thread o pochi punti
|
||||||
if ( nThreadMax <= 1 || m_nTotPnt < 500) {
|
if ( nThreadMax <= 1 || m_nTotPnt < 500) {
|
||||||
m_nCurrPnt = 0 ;
|
bOk = TestSubPath( -1, lPntM, vtDir, dLinTol) ;
|
||||||
bOk = TestSubPath( -1, lPntM, vtDir, dLinTol, dProgCoeff) ;
|
ProcessEvents( 100, 0) ;
|
||||||
ProcessEvents( int( 100 * dProgCoeff), 0) ;
|
|
||||||
}
|
}
|
||||||
// altrimenti
|
// altrimenti
|
||||||
else {
|
else {
|
||||||
@@ -330,7 +167,7 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
|||||||
m_bBreak = false ;
|
m_bBreak = false ;
|
||||||
future<bool> vRes[MAX_PARTS] ;
|
future<bool> vRes[MAX_PARTS] ;
|
||||||
for ( int i = 0 ; i < nPartCnt ; ++ i)
|
for ( int i = 0 ; i < nPartCnt ; ++ i)
|
||||||
vRes[i] = async( launch::async, &CAvToolSurfTm::TestSubPath, this, i, ref( vlPntM[i]), cref( vtDir), dLinTol, dProgCoeff) ;
|
vRes[i] = async( launch::async, &CAvToolSurfTm::TestSubPath, this, i, ref( vlPntM[i]), cref( vtDir), dLinTol) ;
|
||||||
// attendo i risultati
|
// attendo i risultati
|
||||||
int nFin = 0 ;
|
int nFin = 0 ;
|
||||||
int nNextPE = 0 ;
|
int nNextPE = 0 ;
|
||||||
@@ -342,7 +179,7 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( m_nCurrPnt > nNextPE) {
|
if ( m_nCurrPnt > nNextPE) {
|
||||||
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 10) ;
|
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt), 10) ;
|
||||||
nNextPE += STEP_PE ;
|
nNextPE += STEP_PE ;
|
||||||
if ( nRes == 1)
|
if ( nRes == 1)
|
||||||
m_bBreak = true ;
|
m_bBreak = true ;
|
||||||
@@ -354,14 +191,16 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d&
|
|||||||
lPntM.pop_back() ;
|
lPntM.pop_back() ;
|
||||||
lPntM.splice( lPntM.end(), vlPntM[i]) ;
|
lPntM.splice( lPntM.end(), vlPntM[i]) ;
|
||||||
}
|
}
|
||||||
ProcessEvents( int( 100 * dProgCoeff), 0) ;
|
ProcessEvents( 100, 0) ;
|
||||||
}
|
}
|
||||||
|
// pulisco HashGrid 2d
|
||||||
|
m_HGrids.Clear() ;
|
||||||
return bOk ;
|
return bOk ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol, double dProgCoeff)
|
CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol)
|
||||||
{
|
{
|
||||||
// Se lista vuota, non devo fare alcunché
|
// Se lista vuota, non devo fare alcunché
|
||||||
if ( lPntM.empty())
|
if ( lPntM.empty())
|
||||||
@@ -373,13 +212,11 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
|
|||||||
while ( itPntMCurr != lPntM.end()) {
|
while ( itPntMCurr != lPntM.end()) {
|
||||||
// verifico il punto
|
// verifico il punto
|
||||||
ptCurr = itPntMCurr->first ;
|
ptCurr = itPntMCurr->first ;
|
||||||
Vector3d vtTriaN ;
|
itPntMCurr->second = MyTestPositionHG( itPntMCurr->first, vtDir) ;
|
||||||
double dMove = MyTestPositionHG( itPntMCurr->first, vtDir, vtTriaN) ;
|
if ( itPntMCurr->second < - EPS_SMALL)
|
||||||
itPntMCurr->second = dMove ;
|
|
||||||
if ( dMove < - EPS_SMALL)
|
|
||||||
return false ;
|
return false ;
|
||||||
// se esiste il punto precedente e richiesto devo verificare il medio
|
// se esiste il punto precedente devo verificare il medio
|
||||||
if ( itPntMPrev != lPntM.end() && dLinTol > 0) {
|
if ( itPntMPrev != lPntM.end()) {
|
||||||
MyTestMidPointHG( lPntM, itPntMPrev, itPntMCurr, ptPrev, ptCurr, vtDir, dLinTol, 1) ;
|
MyTestMidPointHG( lPntM, itPntMPrev, itPntMCurr, ptPrev, ptCurr, vtDir, dLinTol, 1) ;
|
||||||
}
|
}
|
||||||
// passo al successivo
|
// passo al successivo
|
||||||
@@ -391,7 +228,7 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
|
|||||||
if ( nId == -1) {
|
if ( nId == -1) {
|
||||||
// gestione eventi (ogni STEP_PE punti)
|
// gestione eventi (ogni STEP_PE punti)
|
||||||
if (( m_nCurrPnt % STEP_PE) == 0) {
|
if (( m_nCurrPnt % STEP_PE) == 0) {
|
||||||
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt * dProgCoeff), 0) ;
|
int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt), 0) ;
|
||||||
if ( nRes == 1)
|
if ( nRes == 1)
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
@@ -408,7 +245,7 @@ CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, dou
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
|
CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
|
||||||
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) const
|
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev)
|
||||||
{
|
{
|
||||||
// se superato limite di ricursione, esco
|
// se superato limite di ricursione, esco
|
||||||
const int MAX_LEV = 10 ;
|
const int MAX_LEV = 10 ;
|
||||||
@@ -418,8 +255,7 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
|
|||||||
Point3d ptMid = Media( ptPrev, ptCurr, 0.5) ;
|
Point3d ptMid = Media( ptPrev, ptCurr, 0.5) ;
|
||||||
// ne effettuo la correzione per evitare la collisione
|
// ne effettuo la correzione per evitare la collisione
|
||||||
Point3d ptNewMid = ptMid ;
|
Point3d ptNewMid = ptMid ;
|
||||||
Vector3d vtTriaN ;
|
double dMidMove = MyTestPositionHG( ptNewMid, vtDir) ;
|
||||||
double dMidMove = MyTestPositionHG( ptNewMid, vtDir, vtTriaN) ;
|
|
||||||
if ( dMidMove < - EPS_SMALL)
|
if ( dMidMove < - EPS_SMALL)
|
||||||
return false ;
|
return false ;
|
||||||
// massima distanza ammissibile
|
// massima distanza ammissibile
|
||||||
@@ -428,7 +264,7 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
|
|||||||
if ( abs(( Media( itPntMPrev->first, itPntMCurr->first, 0.5) - ptNewMid) * m_frMove.VersZ()) > 0.5 * dLinTol ||
|
if ( abs(( Media( itPntMPrev->first, itPntMCurr->first, 0.5) - ptNewMid) * m_frMove.VersZ()) > 0.5 * dLinTol ||
|
||||||
SqDist( itPntMPrev->first, itPntMCurr->first) > dMaxSqDist) {
|
SqDist( itPntMPrev->first, itPntMCurr->first) > dMaxSqDist) {
|
||||||
// aggiungo
|
// aggiungo
|
||||||
lPntM.emplace( itPntMCurr, ptNewMid, dMidMove) ;
|
lPntM.emplace( itPntMCurr, ptNewMid, - dMidMove) ;
|
||||||
auto itPntMMid = itPntMCurr ;
|
auto itPntMMid = itPntMCurr ;
|
||||||
-- itPntMMid ;
|
-- itPntMMid ;
|
||||||
// verifico intervallo precedente
|
// verifico intervallo precedente
|
||||||
@@ -441,22 +277,20 @@ CAvToolSurfTm::MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPn
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, Vector3d& vtTriaN) const
|
CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir)
|
||||||
{
|
{
|
||||||
double dTotDist = 0 ;
|
double dTotDist = 0 ;
|
||||||
vtTriaN = V_NULL ;
|
|
||||||
for ( auto pStm : m_vSTM) {
|
for ( auto pStm : m_vSTM) {
|
||||||
Triangle3d Tria ;
|
Triangle3d Tria ;
|
||||||
for ( int nTria = pStm->GetFirstTriangle( Tria) ;
|
for ( int nTria = pStm->GetFirstTriangle( Tria) ;
|
||||||
nTria != SVT_NULL ;
|
nTria != SVT_NULL ;
|
||||||
nTria = pStm->GetNextTriangle( nTria, Tria)) {
|
nTria = pStm->GetNextTriangle( nTria, Tria)) {
|
||||||
double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, vtMove) ;
|
double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, m_frMove.VersZ()) ;
|
||||||
if ( dDist < - EPS_SMALL)
|
if ( dDist < - EPS_SMALL)
|
||||||
return -1 ;
|
return -1 ;
|
||||||
if ( dDist > EPS_SMALL) {
|
if ( dDist > EPS_SMALL) {
|
||||||
dTotDist += dDist ;
|
dTotDist += dDist ;
|
||||||
ptT += dDist * vtMove ;
|
ptT += dDist * m_frMove.VersZ() ;
|
||||||
vtTriaN = Tria.GetN() ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,7 +299,7 @@ CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
double
|
double
|
||||||
CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d& vtTriaN) const
|
CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir)
|
||||||
{
|
{
|
||||||
// calcolo box utensile nel riferimento di movimento
|
// calcolo box utensile nel riferimento di movimento
|
||||||
BBox3d b3Tool ;
|
BBox3d b3Tool ;
|
||||||
@@ -487,7 +321,6 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d&
|
|||||||
}
|
}
|
||||||
// ciclo sui triangoli che intersecano box in 2d
|
// ciclo sui triangoli che intersecano box in 2d
|
||||||
double dTotDist = 0 ;
|
double dTotDist = 0 ;
|
||||||
vtTriaN = V_NULL ;
|
|
||||||
INTVECTOR vnIds ;
|
INTVECTOR vnIds ;
|
||||||
if ( m_HGrids.Find( b3Tool, vnIds)) {
|
if ( m_HGrids.Find( b3Tool, vnIds)) {
|
||||||
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( vnIds.size()) ; ++ i) {
|
||||||
@@ -503,7 +336,6 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d&
|
|||||||
if ( dDist > EPS_SMALL) {
|
if ( dDist > EPS_SMALL) {
|
||||||
dTotDist += dDist ;
|
dTotDist += dDist ;
|
||||||
ptT += dDist * m_frMove.VersZ() ;
|
ptT += dDist * m_frMove.VersZ() ;
|
||||||
vtTriaN = Tria.GetN() ;
|
|
||||||
}
|
}
|
||||||
else if ( dDist < -EPS_SMALL)
|
else if ( dDist < -EPS_SMALL)
|
||||||
return -1 ;
|
return -1 ;
|
||||||
@@ -546,7 +378,7 @@ CAvToolSurfTm::PrepareHashGrid( void)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int
|
int
|
||||||
CAvToolSurfTm::GetSurfInd( int nT) const
|
CAvToolSurfTm::GetSurfInd( int nT)
|
||||||
{
|
{
|
||||||
// verifico la presenza di almeno un intervallo
|
// verifico la presenza di almeno un intervallo
|
||||||
if ( m_vBaseInd.size() < 2)
|
if ( m_vBaseInd.size() < 2)
|
||||||
|
|||||||
+7
-11
@@ -36,24 +36,20 @@ class CAvToolSurfTm : public ICAvToolSurfTm
|
|||||||
{ return m_Tool.GetHeigth() ; }
|
{ return m_Tool.GetHeigth() ; }
|
||||||
const ICurveComposite& GetToolOutline( bool bApprox = false) const override
|
const ICurveComposite& GetToolOutline( bool bApprox = false) const override
|
||||||
{ return ( bApprox ? m_Tool.GetApproxOutline() : m_Tool.GetOutline()) ;}
|
{ return ( bApprox ? m_Tool.GetApproxOutline() : m_Tool.GetOutline()) ;}
|
||||||
bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove,
|
bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist) override ;
|
||||||
double& dTotDist, Vector3d* pvtTriaN = nullptr) const override ;
|
bool TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol) override ;
|
||||||
bool TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dProgCoeff = 1) override ;
|
|
||||||
bool TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol, double dProgCoeff = 1) override ;
|
|
||||||
|
|
||||||
public :
|
public :
|
||||||
CAvToolSurfTm( void) ;
|
CAvToolSurfTm( void) ;
|
||||||
bool Clear( void) ;
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
bool TestSubSeries( int nId, PNTUVECTOR& vPntM, const Vector3d& vtDir, int nFirst, int nLast, double dProgCoeff) ;
|
bool TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) ;
|
||||||
bool TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol, double dProgCoeff) ;
|
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir) ;
|
||||||
double MyTestPosition( Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, Vector3d& vtTriaN) const ;
|
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) ;
|
||||||
double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir, Vector3d& vtTriaN) const ;
|
|
||||||
bool MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
|
bool MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr,
|
||||||
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) const ;
|
const Point3d& ptPrev, const Point3d& ptCurr, const Vector3d& vtDir, double dLinTol, int nLev) ;
|
||||||
bool PrepareHashGrid( void) ;
|
bool PrepareHashGrid( void) ;
|
||||||
int GetSurfInd( int nT) const ;
|
int GetSurfInd( int nT) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
typedef std::vector<const SurfTriMesh*> CSURFTMPVECTOR ; // vettore di puntatori a const SurfTriMesh
|
typedef std::vector<const SurfTriMesh*> CSURFTMPVECTOR ; // vettore di puntatori a const SurfTriMesh
|
||||||
|
|||||||
+2
-2
@@ -17,8 +17,8 @@
|
|||||||
#include "CAvToolTriangle.h"
|
#include "CAvToolTriangle.h"
|
||||||
#include "IntersLineSurfStd.h"
|
#include "IntersLineSurfStd.h"
|
||||||
#include "IntersLineTria.h"
|
#include "IntersLineTria.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "CDeUtility.h"
|
#include "CDeUtility.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntervals.h"
|
#include "/EgtDev/Include/EGkIntervals.h"
|
||||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
@@ -2503,7 +2503,7 @@ DiskSegmentEscapeDistLongMot( const Point3d& ptDiskCen, double dDiskRad,
|
|||||||
double dSegDist = 0. ;
|
double dSegDist = 0. ;
|
||||||
for ( int nSol = 0 ; nSol < nRoot ; ++ nSol) {
|
for ( int nSol = 0 ; nSol < nRoot ; ++ nSol) {
|
||||||
// Soluzione interna al segmento
|
// Soluzione interna al segmento
|
||||||
if ( vdRoots[nSol] > 0. && vdRoots[nSol] < dSegLen + EPS_ZERO) {
|
if ( vdRoots[nSol] > 0. && vdRoots[nSol] < dSegLen) {
|
||||||
Point3d ptC = ptSeg + vdRoots[nSol] * vtSeg ;
|
Point3d ptC = ptSeg + vdRoots[nSol] * vtSeg ;
|
||||||
// Distanza del punto soluzione dal piano del disco nella posizione iniziale
|
// Distanza del punto soluzione dal piano del disco nella posizione iniziale
|
||||||
double dCurDist = PointPlaneSignedDist( ptC, ptDiskCen, vtMove) ;
|
double dCurDist = PointPlaneSignedDist( ptC, ptDiskCen, vtMove) ;
|
||||||
|
|||||||
+1
-1
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "CDeCylTria.h"
|
#include "CDeCylTria.h"
|
||||||
#include "CDeConvexTorusTria.h"
|
#include "CDeConvexTorusTria.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|||||||
+2
-1
@@ -12,10 +12,11 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "DistLineLine.h"
|
||||||
#include "CDeTriaTria.h"
|
#include "CDeTriaTria.h"
|
||||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
|
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CDeUtility.h"
|
#include "CDeUtility.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
#include "/EgtDev/Include/ENkPolynomialRoots.h"
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|||||||
+1545
-6916
File diff suppressed because it is too large
Load Diff
@@ -16,8 +16,8 @@
|
|||||||
#include "CurveBezier.h"
|
#include "CurveBezier.h"
|
||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
#include "CreateCurveAux.h"
|
#include "CreateCurveAux.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
|
|||||||
+25
-882
File diff suppressed because it is too large
Load Diff
@@ -33,5 +33,4 @@ bool CurveGetArea( const ICurve& crvC, Plane3d& plPlane, double& dArea) ;
|
|||||||
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
bool CurveDump( const ICurve& crvC, std::string& sOut, bool bMM, const char* szNewLine) ;
|
||||||
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||||
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ;
|
||||||
ICurveBezier* ApproxCurveBezierWithSingleCubic( const ICurveBezier* pCrvBez) ;
|
|
||||||
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
Voronoi* GetCurveVoronoi( const ICurve& crvC) ;
|
||||||
|
|||||||
+6
-237
@@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CurveAux.h"
|
|
||||||
#include "CurveBezier.h"
|
#include "CurveBezier.h"
|
||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
#include "DistPointCrvBezier.h"
|
#include "DistPointCrvBezier.h"
|
||||||
#include "BiArcs.h"
|
#include "BiArcs.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "PolygonPlane.h"
|
#include "PolygonPlane.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoObjFactory.h"
|
#include "GeoObjFactory.h"
|
||||||
#include "NgeWriter.h"
|
#include "NgeWriter.h"
|
||||||
#include "NgeReader.h"
|
#include "NgeReader.h"
|
||||||
@@ -27,16 +27,12 @@
|
|||||||
#include "Bernstein.h"
|
#include "Bernstein.h"
|
||||||
#include "deCasteljau.h"
|
#include "deCasteljau.h"
|
||||||
#include "Voronoi.h"
|
#include "Voronoi.h"
|
||||||
#include "IntersLineLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||||
#include "/EgtDev/Include/ENkPolynomial.h"
|
#include "/EgtDev/Include/ENkPolynomial.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
|
||||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
@@ -142,32 +138,6 @@ CurveBezier::SetControlPoint( int nInd, const Point3d& ptCtrl, double dW)
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CurveBezier::SetControlWeight( int nInd, double dW)
|
|
||||||
{
|
|
||||||
// verifico validità, razionalità e indice
|
|
||||||
if ( m_nStatus != OK || ! m_bRat || nInd < 0 || nInd > m_nDeg)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// verifico che il peso non sia nullo o negativo
|
|
||||||
if ( dW < EPS_SMALL)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// assegno il valore e il peso
|
|
||||||
m_vWeCtrl[nInd] = dW ;
|
|
||||||
|
|
||||||
// annullo analisi presenza singolarità
|
|
||||||
m_dParSing = - 2 ;
|
|
||||||
|
|
||||||
// imposto ricalcolo Voronoi
|
|
||||||
ResetVoronoiObject() ;
|
|
||||||
// imposto ricalcolo della grafica
|
|
||||||
m_OGrMgr.Reset() ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CurveBezier::FromArc( const ICurveArc& crArc)
|
CurveBezier::FromArc( const ICurveArc& crArc)
|
||||||
@@ -225,35 +195,6 @@ CurveBezier::FromArc( const ICurveArc& crArc)
|
|||||||
SetControlPoint( 1, ptNew1, dW) ;
|
SetControlPoint( 1, ptNew1, dW) ;
|
||||||
SetControlPoint( 2, ptNew2, dW) ;
|
SetControlPoint( 2, ptNew2, dW) ;
|
||||||
SetControlPoint( 3, ptEnd, 1) ;
|
SetControlPoint( 3, ptEnd, 1) ;
|
||||||
|
|
||||||
//// anziché usare una bezier cubica approssimo le eliche con più bezier quadratiche razionali.
|
|
||||||
//// più è grande l'angolo al centro dell'arco e maggiore sarà l'errore di approssimazione
|
|
||||||
//
|
|
||||||
// // quadratica razionale
|
|
||||||
// // peso del punto di controllo intermedio
|
|
||||||
// double dW = dCosAhalf ;
|
|
||||||
// // calcolo dei punti di controllo
|
|
||||||
// Point3d ptStart ;
|
|
||||||
// crArc.GetStartPoint( ptStart) ;
|
|
||||||
// Point3d ptEnd ;
|
|
||||||
// crArc.GetEndPoint( ptEnd) ;
|
|
||||||
// // Point3d ptMed = Media( ptStart, ptEnd, 0.5) ;
|
|
||||||
// //Vector3d vtDir = ptMed - crArc.GetCenter() ;
|
|
||||||
// // Point3d ptNew = crArc.GetCenter() + vtDir / ( dCosAhalf * dCosAhalf) ;
|
|
||||||
// Vector3d vtStart ; crArc.GetStartDir( vtStart) ;
|
|
||||||
// Vector3d vtEnd ; crArc.GetEndDir( vtEnd) ;
|
|
||||||
// PtrOwner<CurveLine> pCrvLine1( CreateBasicCurveLine()) ;
|
|
||||||
// pCrvLine1->SetPVL( ptStart, vtStart, 10) ;
|
|
||||||
// PtrOwner<CurveLine> pCrvLine2( CreateBasicCurveLine()) ;
|
|
||||||
// pCrvLine2->SetPVL( ptEnd, vtEnd, 10) ;
|
|
||||||
// IntersLineLine ill( *pCrvLine1, *pCrvLine2, false) ;
|
|
||||||
// IntCrvCrvInfo iccInfo ; ill.GetIntCrvCrvInfo( iccInfo) ;
|
|
||||||
// Point3d ptNew = 0.5 * (iccInfo.IciA->ptI + iccInfo.IciB->ptI) ;
|
|
||||||
// // inserimento nella curva dei punti di controllo con i pesi
|
|
||||||
// Init( 2, true) ;
|
|
||||||
// SetControlPoint( 0, ptStart, 1) ;
|
|
||||||
// SetControlPoint( 1, ptNew, dW) ;
|
|
||||||
// SetControlPoint( 2, ptEnd, 1) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// copio estrusione e spessore
|
// copio estrusione e spessore
|
||||||
@@ -263,30 +204,6 @@ CurveBezier::FromArc( const ICurveArc& crArc)
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CurveBezier::FromLine( const ICurveLine& crLine)
|
|
||||||
{
|
|
||||||
if ( ! crLine.IsValid())
|
|
||||||
return false ;
|
|
||||||
double dWeight = 1 ;
|
|
||||||
int nCount = 0 ;
|
|
||||||
Point3d ptStart ; crLine.GetStartPoint( ptStart) ;
|
|
||||||
SetControlPoint( nCount, ptStart, dWeight) ;
|
|
||||||
++nCount ;
|
|
||||||
double dPart = 1. / m_nDeg ;
|
|
||||||
for ( int i = 1 ; i < m_nDeg ; ++i) {
|
|
||||||
double dU = i * dPart ;
|
|
||||||
Point3d ptMid ; crLine.GetPointD1D2( dU, ICurve::FROM_MINUS, ptMid) ;
|
|
||||||
SetControlPoint( nCount, ptMid, dWeight) ;
|
|
||||||
++nCount ;
|
|
||||||
}
|
|
||||||
Point3d ptEnd ; crLine.GetEndPoint( ptEnd) ;
|
|
||||||
SetControlPoint( nCount, ptEnd, dWeight) ;
|
|
||||||
++nCount ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
CurveBezier::IsAPoint( void) const
|
CurveBezier::IsAPoint( void) const
|
||||||
@@ -1569,7 +1486,7 @@ CurveBezier::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAngTo
|
|||||||
return false ;
|
return false ;
|
||||||
vtDir.ToSpherical( nullptr, nullptr, &dDir1Deg) ;
|
vtDir.ToSpherical( nullptr, nullptr, &dDir1Deg) ;
|
||||||
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
|
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
|
||||||
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist, dLinTol)) ;
|
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist)) ;
|
||||||
if ( IsNull( pCrv))
|
if ( IsNull( pCrv))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
@@ -1806,24 +1723,12 @@ CurveBezier::TrimStartEndAtParam( double dUStartTrim, double dUEndTrim)
|
|||||||
// verifico che i trim non cancellino interamente la curva
|
// verifico che i trim non cancellino interamente la curva
|
||||||
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
|
if ( dUStartTrim > dUEndTrim - EPS_PARAM)
|
||||||
return false ;
|
return false ;
|
||||||
// se razionale devo trovare il punto di trim iniziale per ricalcolare il parametro di trim
|
|
||||||
Point3d ptStart ;
|
|
||||||
if( m_bRat)
|
|
||||||
GetPointD1D2( dUStartTrim, ptStart) ;
|
|
||||||
// trim finale
|
// trim finale
|
||||||
if ( ! TrimEndAtParam( dUEndTrim))
|
if ( ! TrimEndAtParam( dUEndTrim))
|
||||||
return false ;
|
return false ;
|
||||||
// trim iniziale con il parametro opportunamente ricalcolato
|
// trim iniziale con il parametro opportunamente ricalcolato
|
||||||
double dNewUStartTrim ;
|
double dNewUStartTrim = dUStartTrim / dUEndTrim ;
|
||||||
if( m_bRat)
|
return TrimStartAtParam( dNewUStartTrim) ;
|
||||||
GetParamAtPoint( ptStart, dNewUStartTrim) ;
|
|
||||||
else
|
|
||||||
dNewUStartTrim = dUStartTrim / dUEndTrim ;
|
|
||||||
//trim iniziale
|
|
||||||
if( ! TrimStartAtParam( dNewUStartTrim))
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -1839,10 +1744,7 @@ CurveBezier::TrimStartAtLen( double dLenTrim)
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// utilizzo il trim sui parametri
|
// utilizzo il trim sui parametri
|
||||||
if( ! TrimStartAtParam( dUTrim))
|
return TrimStartAtParam( dUTrim) ;
|
||||||
return false ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -1858,10 +1760,7 @@ CurveBezier::TrimEndAtLen( double dLenTrim)
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// utilizzo il trim sui parametri
|
// utilizzo il trim sui parametri
|
||||||
if( ! TrimEndAtParam( dUTrim))
|
return TrimEndAtParam( dUTrim) ;
|
||||||
return false ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -2253,133 +2152,3 @@ CurveBezier::ResetVoronoiObject() const
|
|||||||
delete m_pVoronoiObj ;
|
delete m_pVoronoiObj ;
|
||||||
m_pVoronoiObj = nullptr ;
|
m_pVoronoiObj = nullptr ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CurveBezier::MakeRational( void)
|
|
||||||
{
|
|
||||||
if ( m_bRat)
|
|
||||||
return true ;
|
|
||||||
// creo il vettore dei pesi e li setto tutti a 1
|
|
||||||
m_vWeCtrl.assign( m_nDeg + 1, 1) ;
|
|
||||||
// aggiorno il flag rational
|
|
||||||
m_bRat = true ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CurveBezier::MakeRationalStandardForm( void)
|
|
||||||
{
|
|
||||||
if ( ! m_bRat)
|
|
||||||
return false ;
|
|
||||||
double dW0 = m_vWeCtrl[0] ;
|
|
||||||
double dWn = m_vWeCtrl.back() ;
|
|
||||||
if( dW0 > 1- EPS_ZERO && dWn > 1 - EPS_ZERO)
|
|
||||||
return true ;
|
|
||||||
if( dW0 < EPS_ZERO || dWn < EPS_ZERO)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// formula del Farin
|
|
||||||
double dCoeff = pow( dW0 / dWn, 1. / m_nDeg) ;
|
|
||||||
for ( int i = 0 ; i < m_nDeg + 1 ; ++i)
|
|
||||||
m_vWeCtrl[i] *= pow( dCoeff, i) / dW0 ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CurveBezier::MakeNonRational( double dTol)
|
|
||||||
{
|
|
||||||
if( ! m_bRat)
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
// controllo se i pesi sono tutti == 1 allora è una finta razionale e mi basta fare una copia dei punti di controllo
|
|
||||||
bool bIsActualRat = false ;
|
|
||||||
for ( int i = 0 ; i < m_nDeg ; ++i) {
|
|
||||||
if ( abs(m_vWeCtrl[i] - 1) > EPS_SMALL) {
|
|
||||||
bIsActualRat = true ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bOk = true ;
|
|
||||||
if ( ! bIsActualRat) {
|
|
||||||
PtrOwner<CurveBezier> pNewBez( CreateBasicCurveBezier()) ;
|
|
||||||
for ( int p = 0 ; p < m_nDeg ; ++p) {
|
|
||||||
Point3d pt = GetControlPoint( p) ;
|
|
||||||
pNewBez->SetControlPoint( p, pt) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// provo ad approssimare la curva di bezier con una controparte non razionale
|
|
||||||
int nDeg = m_nDeg ;
|
|
||||||
// punto di rientro in caso fallisca il primo tentativo
|
|
||||||
retry :
|
|
||||||
nDeg += 2 ;
|
|
||||||
PtrOwner<CurveBezier> pNewBez( CreateBasicCurveBezier()) ;
|
|
||||||
pNewBez->Init( nDeg, false) ;
|
|
||||||
PNTVECTOR vPntCtrl ;
|
|
||||||
PNTVECTOR vPntSampling ;
|
|
||||||
for ( int p = 0 ; p < nDeg + 1; ++p) {
|
|
||||||
Point3d pt ; GetPointD1D2( double(p) / nDeg, pt) ;
|
|
||||||
pNewBez->SetControlPoint( p, pt) ;
|
|
||||||
vPntCtrl.push_back( pt) ;
|
|
||||||
}
|
|
||||||
vPntSampling = vPntCtrl ;
|
|
||||||
int c = 0 ;
|
|
||||||
double dErr = INFINITO ;
|
|
||||||
while ( dErr > dTol && c < 100) {
|
|
||||||
double dErrMax = 0 ;
|
|
||||||
// calcolo le differenze tra i punti di sampling sulla nuova curva e quelli sulla curva originale
|
|
||||||
for ( int p = 0 ; p < nDeg + 1; ++p) {
|
|
||||||
Point3d pt ; pNewBez->GetPointD1D2( double(p) / nDeg, pt) ;
|
|
||||||
Vector3d vDiff = vPntSampling[p] - pt ;
|
|
||||||
double dErrLoc = vDiff.Len() ;
|
|
||||||
if( dErrLoc > dErrMax)
|
|
||||||
dErrMax = dErrLoc ;
|
|
||||||
// aggiorno il vettore dei punti di controllo della nuova curva
|
|
||||||
vPntCtrl[p] += vDiff ;
|
|
||||||
}
|
|
||||||
dErr = dErrMax ;
|
|
||||||
// aggiorno i punti di controllo della nuova curva
|
|
||||||
for ( int i = 0 ; i < nDeg + 1 ; ++i)
|
|
||||||
pNewBez->SetControlPoint( i, vPntCtrl[i]) ;
|
|
||||||
++c ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calcolo l'errore di approssimazione sulla curva
|
|
||||||
CalcBezierApproxError( this, pNewBez, dErr) ;
|
|
||||||
bOk = dErr < dTol ;
|
|
||||||
if( bOk) {
|
|
||||||
// aggiorno la curva di bezier originale con quella approssimata
|
|
||||||
Init( nDeg, false) ;
|
|
||||||
for( int i = 0 ; i < nDeg + 1 ; ++i) {
|
|
||||||
SetControlPoint( i, pNewBez->GetControlPoint( i)) ;
|
|
||||||
SetControlWeight( i, pNewBez->GetControlWeight( i)) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( nDeg < m_nDeg + 4)
|
|
||||||
goto retry ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bOk ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CurveBezier::IsALine( void) const
|
|
||||||
{
|
|
||||||
Point3d ptStart ; GetStartPoint( ptStart) ;
|
|
||||||
Point3d ptEnd ; GetEndPoint( ptEnd) ;
|
|
||||||
for ( int i = 1 ; i < m_nDeg ; ++i) {
|
|
||||||
Point3d ptCtrl = GetControlPoint( i) ;
|
|
||||||
DistPointLine dpl( ptCtrl, ptStart, ptEnd) ;
|
|
||||||
double dDist = 0 ; dpl.GetDist( dDist) ;
|
|
||||||
if( dDist > EPS_SMALL)
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-7
@@ -137,9 +137,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
|||||||
bool Init( int nDeg, bool bIsRational) override ;
|
bool Init( int nDeg, bool bIsRational) override ;
|
||||||
bool SetControlPoint( int nInd, const Point3d& ptCtrl) override ;
|
bool SetControlPoint( int nInd, const Point3d& ptCtrl) override ;
|
||||||
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
|
bool SetControlPoint( int nInd, const Point3d& ptCtrl, double dW) override ;
|
||||||
bool SetControlWeight( int nInd, double dW) override ;
|
|
||||||
bool FromArc( const ICurveArc& crArc) override ;
|
bool FromArc( const ICurveArc& crArc) override ;
|
||||||
bool FromLine( const ICurveLine& crLine) override ;
|
|
||||||
int GetDegree( void) const override
|
int GetDegree( void) const override
|
||||||
{ return m_nDeg ; }
|
{ return m_nDeg ; }
|
||||||
bool IsRational( void) const override
|
bool IsRational( void) const override
|
||||||
@@ -149,10 +147,6 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
|||||||
double GetControlWeight( int nInd, bool* pbOk = NULL) const override ;
|
double GetControlWeight( int nInd, bool* pbOk = NULL) const override ;
|
||||||
bool GetControlPolygonLength( double& dLen) const override ;
|
bool GetControlPolygonLength( double& dLen) const override ;
|
||||||
int GetSingularParam( double& dPar) const override ;
|
int GetSingularParam( double& dPar) const override ;
|
||||||
bool MakeRational( void) override ;
|
|
||||||
bool MakeRationalStandardForm( void) override ;
|
|
||||||
bool MakeNonRational( double dTol) override ;
|
|
||||||
bool IsALine( void) const override ;
|
|
||||||
|
|
||||||
public : // IGeoObjRW
|
public : // IGeoObjRW
|
||||||
int GetNgeId( void) const override ;
|
int GetNgeId( void) const override ;
|
||||||
@@ -196,7 +190,7 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
|||||||
|
|
||||||
private :
|
private :
|
||||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||||
static const int MAXDEG = 21 ;
|
static const int MAXDEG = 11 ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||||
|
|||||||
+9
-9
@@ -16,8 +16,8 @@
|
|||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
#include "CalcDerivate.h"
|
#include "CalcDerivate.h"
|
||||||
#include "BiArcs.h"
|
#include "BiArcs.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "RemoveCurveDefects.h"
|
#include "RemoveCurveDefects.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||||
#include "/EgtDev/Include/EGkPolyArc.h"
|
#include "/EgtDev/Include/EGkPolyArc.h"
|
||||||
@@ -439,12 +439,12 @@ CurveByApprox::CalcSplitPoints( double dLinTol, double dAngTolDeg, double dLinFe
|
|||||||
m_vSplits.push_back(i) ;
|
m_vSplits.push_back(i) ;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
// verifico linearità del tratto precedente
|
// verifico linearità del tratto precedente
|
||||||
bool bPrevLin = vtPrev.SqLen() > dSqLinFea &&
|
bool bPrevLin = vtPrev.SqLen() > dSqLinFea &&
|
||||||
( m_vNextDer[i-1] * m_vPrevDer[i]) > dAngTolCos &&
|
( m_vNextDer[i-1] * m_vPrevDer[i]) > dAngTolCos &&
|
||||||
( vtPrev ^ m_vNextDer[i-1]).SqLen() < dSqLinTol &&
|
( vtPrev ^ m_vNextDer[i-1]).SqLen() < dSqLinTol &&
|
||||||
( vtPrev ^ m_vPrevDer[i]).SqLen() < dSqLinTol ;
|
( vtPrev ^ m_vPrevDer[i]).SqLen() < dSqLinTol ;
|
||||||
// verifico linearità del tratto successivo
|
// verifico linearità del tratto successivo
|
||||||
bool bNextLin = vtNext.SqLen() > dSqLinFea &&
|
bool bNextLin = vtNext.SqLen() > dSqLinFea &&
|
||||||
( m_vNextDer[i] * m_vPrevDer[i+1]) > dAngTolCos &&
|
( m_vNextDer[i] * m_vPrevDer[i+1]) > dAngTolCos &&
|
||||||
( vtNext ^ m_vNextDer[i]).SqLen() < dSqLinTol &&
|
( vtNext ^ m_vNextDer[i]).SqLen() < dSqLinTol &&
|
||||||
@@ -483,7 +483,7 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
|||||||
PtrOwner<ICurve> pCrv ;
|
PtrOwner<ICurve> pCrv ;
|
||||||
double dMaxDist ;
|
double dMaxDist ;
|
||||||
|
|
||||||
// se la polilinea ha più di 2 punti
|
// se la polilinea ha più di 2 punti
|
||||||
if ( PL.GetPointNbr() > 2) {
|
if ( PL.GetPointNbr() > 2) {
|
||||||
// calcolo punti e direzioni agli estremi della polilinea usando la curva di Bezier
|
// calcolo punti e direzioni agli estremi della polilinea usando la curva di Bezier
|
||||||
int nI ;
|
int nI ;
|
||||||
@@ -501,11 +501,11 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
|||||||
ptP1 = m_vPnt[nI] ;
|
ptP1 = m_vPnt[nI] ;
|
||||||
m_vPrevDer[nI].ToSpherical( nullptr, nullptr, &dDir1Deg) ;
|
m_vPrevDer[nI].ToSpherical( nullptr, nullptr, &dDir1Deg) ;
|
||||||
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
|
// costruisco un biarco sulla polilinea (secondo metodo di Z. Sir)
|
||||||
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist, dLinTol)) ;
|
pCrv.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, PL, dMaxDist)) ;
|
||||||
if ( IsNull( pCrv))
|
if ( IsNull( pCrv))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// se la polilinea è formata da 2 punti
|
// se la polilinea è formata da 2 punti
|
||||||
else if ( PL.GetPointNbr() == 2) {
|
else if ( PL.GetPointNbr() == 2) {
|
||||||
// se molto vicini, esco
|
// se molto vicini, esco
|
||||||
double dLen ;
|
double dLen ;
|
||||||
@@ -561,7 +561,7 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// spezzo l'intervallo in due parti a metà
|
// spezzo l'intervallo in due parti a metà
|
||||||
double dParStart, dParEnd ;
|
double dParStart, dParEnd ;
|
||||||
if ( ! PL.GetFirstU( dParStart) || ! PL.GetLastU( dParEnd))
|
if ( ! PL.GetFirstU( dParStart) || ! PL.GetLastU( dParEnd))
|
||||||
return false ;
|
return false ;
|
||||||
@@ -569,9 +569,9 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
|||||||
PolyLine PL2 ;
|
PolyLine PL2 ;
|
||||||
if ( ! PL.Split( dParMid, PL2))
|
if ( ! PL.Split( dParMid, PL2))
|
||||||
return false ;
|
return false ;
|
||||||
// prima metà
|
// prima metà
|
||||||
if ( ! BiArcOrSplit( nLev + 1, PL, dLinTol, dAngTolDeg, PA))
|
if ( ! BiArcOrSplit( nLev + 1, PL, dLinTol, dAngTolDeg, PA))
|
||||||
return false ;
|
return false ;
|
||||||
// seconda metà
|
// seconda metà
|
||||||
return BiArcOrSplit( nLev + 1, PL2, dLinTol, dAngTolDeg, PA) ;
|
return BiArcOrSplit( nLev + 1, PL2, dLinTol, dAngTolDeg, PA) ;
|
||||||
}
|
}
|
||||||
|
|||||||
+59
-79
@@ -14,6 +14,7 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "DistPointCrvComposite.h"
|
#include "DistPointCrvComposite.h"
|
||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
#include "CurveArc.h"
|
#include "CurveArc.h"
|
||||||
@@ -26,7 +27,6 @@
|
|||||||
#include "NgeWriter.h"
|
#include "NgeWriter.h"
|
||||||
#include "NgeReader.h"
|
#include "NgeReader.h"
|
||||||
#include "Voronoi.h"
|
#include "Voronoi.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||||
@@ -291,15 +291,9 @@ CurveComposite::Close( void)
|
|||||||
return true ;
|
return true ;
|
||||||
// se molto vicini li modifico
|
// se molto vicini li modifico
|
||||||
if ( AreSamePointEpsilon( ptStart, ptEnd, 10 * EPS_SMALL)) {
|
if ( AreSamePointEpsilon( ptStart, ptEnd, 10 * EPS_SMALL)) {
|
||||||
// se un solo arco
|
|
||||||
if ( m_CrvSmplS.size() == 1 && m_CrvSmplS.front()->GetType() == CRV_ARC) {
|
|
||||||
CurveArc* pArc = GetBasicCurveArc( m_CrvSmplS.front()) ;
|
|
||||||
return pArc->ChangeAngCenter( pArc->GetAngCenter() > 0 ? ANG_FULL : -ANG_FULL) ;
|
|
||||||
}
|
|
||||||
// caso generale
|
|
||||||
Point3d ptMid = Media( ptStart, ptEnd) ;
|
Point3d ptMid = Media( ptStart, ptEnd) ;
|
||||||
if ( ! m_CrvSmplS.front()->ModifyStart( ptMid) ||
|
if ( ! ModifyStart( ptMid) ||
|
||||||
! m_CrvSmplS.back()->ModifyEnd( ptMid))
|
! ModifyEnd( ptMid))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// altrimenti aggiungo la linea di chiusura
|
// altrimenti aggiungo la linea di chiusura
|
||||||
@@ -604,10 +598,6 @@ CurveComposite::CopyFrom( const CurveComposite& ccSrc)
|
|||||||
if ( ! AddCurve( *pCrv))
|
if ( ! AddCurve( *pCrv))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
if ( ccSrc.m_nStatus == IS_A_POINT) {
|
|
||||||
m_ptStart = ccSrc.m_ptStart ;
|
|
||||||
m_nStatus = IS_A_POINT ;
|
|
||||||
}
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,7 +656,7 @@ CurveComposite::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
|||||||
while ( pCrvSmpl != nullptr && i < MAX_CRV) {
|
while ( pCrvSmpl != nullptr && i < MAX_CRV) {
|
||||||
// assegno ed emetto nome e tipo della curva semplice
|
// assegno ed emetto nome e tipo della curva semplice
|
||||||
sOut += "#" + ToString( i) + " " + pCrvSmpl->GetTitle() + szNewLine ;
|
sOut += "#" + ToString( i) + " " + pCrvSmpl->GetTitle() + szNewLine ;
|
||||||
// dati della curva semplice
|
// salvataggio della curva semplice
|
||||||
if ( ! pCrvSmpl->Dump( sOut, bMM, szNewLine))
|
if ( ! pCrvSmpl->Dump( sOut, bMM, szNewLine))
|
||||||
return false ;
|
return false ;
|
||||||
// passo alla successiva
|
// passo alla successiva
|
||||||
@@ -755,7 +745,7 @@ CurveComposite::Load( NgeReader& ngeIn)
|
|||||||
ICurve* pCrv = ::GetCurve( pGeoO) ;
|
ICurve* pCrv = ::GetCurve( pGeoO) ;
|
||||||
bOk = bOk && ( pCrv != nullptr && pCrv->IsSimple()) ;
|
bOk = bOk && ( pCrv != nullptr && pCrv->IsSimple()) ;
|
||||||
// aggiungo questa curva (sicuramente semplice)
|
// aggiungo questa curva (sicuramente semplice)
|
||||||
bOk = bOk && AddSimpleCurve( pCrv, true, 10 * EPS_SMALL) ;
|
bOk = bOk && AddSimpleCurve( pCrv) ;
|
||||||
// se errore
|
// se errore
|
||||||
if ( ! bOk)
|
if ( ! bOk)
|
||||||
return false ;
|
return false ;
|
||||||
@@ -888,15 +878,10 @@ CurveComposite::TestClosure( void)
|
|||||||
Point3d ptEnd ; m_CrvSmplS.back()->GetEndPoint( ptEnd) ;
|
Point3d ptEnd ; m_CrvSmplS.back()->GetEndPoint( ptEnd) ;
|
||||||
// se distanza superiore al limite ridotto forzo i punti a coincidere
|
// se distanza superiore al limite ridotto forzo i punti a coincidere
|
||||||
if ( ! AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT)) {
|
if ( ! AreSamePointEpsilon( ptStart, ptEnd, EPS_CONNECT)) {
|
||||||
// se un solo arco
|
|
||||||
if ( m_CrvSmplS.size() == 1 && m_CrvSmplS.front()->GetType() == CRV_ARC) {
|
|
||||||
CurveArc* pArc = GetBasicCurveArc( m_CrvSmplS.front()) ;
|
|
||||||
return pArc->ChangeAngCenter( pArc->GetAngCenter() > 0 ? ANG_FULL : -ANG_FULL) ;
|
|
||||||
}
|
|
||||||
// caso generale
|
|
||||||
Point3d ptM = Media( ptStart, ptEnd) ;
|
Point3d ptM = Media( ptStart, ptEnd) ;
|
||||||
return ( m_CrvSmplS.front()->ModifyStart( ptM) &&
|
if ( ! m_CrvSmplS.front()->ModifyStart( ptM) ||
|
||||||
m_CrvSmplS.back()->ModifyEnd( ptM)) ;
|
! m_CrvSmplS.back()->ModifyEnd( ptM))
|
||||||
|
return false ;
|
||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -952,8 +937,6 @@ CurveComposite::IsFlat( Plane3d& plPlane, bool bUseExtrusion, double dToler) con
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
} break ;
|
} break ;
|
||||||
default :
|
|
||||||
return false ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// recupero dati sulla planarità della polilinea
|
// recupero dati sulla planarità della polilinea
|
||||||
@@ -3239,64 +3222,61 @@ MergeTwoCurves( ICurve* pCrvP, ICurve* pCrvC, double& dCurrLinTol, double dCosAn
|
|||||||
// verifico di non superare l'angolo giro al centro
|
// verifico di non superare l'angolo giro al centro
|
||||||
if ( abs( pArcP->GetAngCenter() + pArcC->GetAngCenter()) > ANG_FULL + EPS_ANG_SMALL)
|
if ( abs( pArcP->GetAngCenter() + pArcC->GetAngCenter()) > ANG_FULL + EPS_ANG_SMALL)
|
||||||
return 0 ;
|
return 0 ;
|
||||||
// verifico se archi piatti
|
// se archi piatti
|
||||||
bool bPlaneArcs = pArcP->IsPlane() && pArcC->IsPlane() ;
|
if ( pArcP->IsPlane() && pArcC->IsPlane()) {
|
||||||
// se archi non piatti verifico coincidenza pendenza sulla normale
|
// se calcolo nuovo arco ok, procedo con l'unione
|
||||||
if ( ! bPlaneArcs) {
|
Point3d ptP1 ;
|
||||||
double dN = pArcP->GetNormVersor() * pArcC->GetNormVersor() ;
|
pArcP->GetStartPoint( ptP1) ;
|
||||||
if ( abs(( pArcC->GetDeltaN() * pArcP->GetAngCenter() - dN * pArcP->GetDeltaN() * pArcC->GetAngCenter()) /
|
Point3d ptP2 ;
|
||||||
( pArcP->GetAngCenter() + pArcC->GetAngCenter())) > dCurrLinTol)
|
pArcP->GetEndPoint( ptP2) ;
|
||||||
|
Point3d ptP3 ;
|
||||||
|
pArcC->GetEndPoint( ptP3) ;
|
||||||
|
// verifico se circonferenza completa
|
||||||
|
bool bCirc = ( AreSamePointApprox( ptP1, ptP3)) ;
|
||||||
|
if ( bCirc)
|
||||||
|
pArcC->GetMidPoint( ptP3) ;
|
||||||
|
CurveArc NewArc ;
|
||||||
|
if ( NewArc.Set3P( ptP1, ptP2, ptP3, bCirc)) {
|
||||||
|
// verifico normale al piano dell'arco
|
||||||
|
if ( NewArc.GetNormVersor() * pArcC->GetNormVersor() < 0)
|
||||||
|
NewArc.InvertN() ;
|
||||||
|
// se curve originali con la stessa proprietà, la riporto
|
||||||
|
if ( nTpr0P == nTpr0C)
|
||||||
|
NewArc.SetTempProp( nTpr0C, 0) ;
|
||||||
|
if ( nTpr1P == nTpr1C)
|
||||||
|
NewArc.SetTempProp( nTpr1C, 1) ;
|
||||||
|
// aggiorno l'arco corrente e torno flag modifica
|
||||||
|
*pArcC = NewArc ;
|
||||||
|
return -1 ;
|
||||||
|
}
|
||||||
|
else
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
// verifico coincidenza pendenza sulla normale
|
||||||
// se calcolo nuovo arco ok, procedo con l'unione
|
double dN = pArcP->GetNormVersor() * pArcC->GetNormVersor() ;
|
||||||
Point3d ptP1 ;
|
if ( abs(( pArcC->GetDeltaN() * pArcP->GetAngCenter() - dN * pArcP->GetDeltaN() * pArcC->GetAngCenter()) /
|
||||||
pArcP->GetStartPoint( ptP1) ;
|
( pArcP->GetAngCenter() + pArcC->GetAngCenter())) < dCurrLinTol) {
|
||||||
Point3d ptP2 ;
|
// se calcolo nuovo arco ok, procedo con l'unione
|
||||||
pArcP->GetEndPoint( ptP2) ;
|
Point3d ptP1 ;
|
||||||
Point3d ptP3 ;
|
pArcP->GetStartPoint( ptP1) ;
|
||||||
pArcC->GetEndPoint( ptP3) ;
|
Vector3d vtDir1 ;
|
||||||
|
pArcP->GetStartDir( vtDir1) ;
|
||||||
// se archi non piani costruisco arco sul piano definito dalla normale e dal punto di partenza del primo arco
|
Point3d ptP3 ;
|
||||||
Frame3d frRef ;
|
pArcC->GetEndPoint( ptP3) ;
|
||||||
if ( ! frRef.Set( ptP1, pArcP->GetNormVersor()))
|
CurveArc NewArc ;
|
||||||
return 0 ;
|
if ( NewArc.Set2PVN( ptP1, ptP3, vtDir1, pArcC->GetNormVersor())) {
|
||||||
if ( ! bPlaneArcs) {
|
// se curve originali con la stessa proprietà, la riporto
|
||||||
ptP1.Scale( frRef, 1, 1, 0) ;
|
if ( nTpr0P == nTpr0C)
|
||||||
ptP2.Scale( frRef, 1, 1, 0) ;
|
NewArc.SetTempProp( nTpr0C, 0) ;
|
||||||
ptP3.Scale( frRef, 1, 1, 0) ;
|
if ( nTpr1P == nTpr1C)
|
||||||
}
|
NewArc.SetTempProp( nTpr1C, 1) ;
|
||||||
|
// aggiorno l'arco corrente e torno flag modifica
|
||||||
// verifico se circonferenza completa
|
*pArcC = NewArc ;
|
||||||
bool bCirc = ( AreSamePointApprox( ptP1, ptP3)) ;
|
return -1 ;
|
||||||
if ( bCirc) {
|
|
||||||
pArcC->GetMidPoint( ptP3) ;
|
|
||||||
if ( ! bPlaneArcs)
|
|
||||||
ptP3.Scale( frRef, 1, 1, 0) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurveArc NewArc ;
|
|
||||||
if ( NewArc.Set3P( ptP1, ptP2, ptP3, bCirc)) {
|
|
||||||
// verifico normale al piano dell'arco
|
|
||||||
if ( NewArc.GetNormVersor() * pArcC->GetNormVersor() < 0)
|
|
||||||
NewArc.InvertN() ;
|
|
||||||
// se archi non piani ripristino il deltaN
|
|
||||||
if ( ! bPlaneArcs) {
|
|
||||||
double dDeltaN1 = pArcP->GetDeltaN() ;
|
|
||||||
double dDeltaN2 = pArcC->GetDeltaN() ;
|
|
||||||
NewArc.ChangeDeltaN( dDeltaN1 + dDeltaN2) ;
|
|
||||||
}
|
}
|
||||||
// se curve originali con la stessa proprietà, la riporto
|
else
|
||||||
if ( nTpr0P == nTpr0C)
|
return 0 ;
|
||||||
NewArc.SetTempProp( nTpr0C, 0) ;
|
|
||||||
if ( nTpr1P == nTpr1C)
|
|
||||||
NewArc.SetTempProp( nTpr1C, 1) ;
|
|
||||||
// aggiorno l'arco corrente e torno flag modifica
|
|
||||||
*pArcC = NewArc ;
|
|
||||||
return -1 ;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return 0 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// nessuna fusione
|
// nessuna fusione
|
||||||
|
|||||||
+1
-1
@@ -14,11 +14,11 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoObjFactory.h"
|
#include "GeoObjFactory.h"
|
||||||
#include "NgeWriter.h"
|
#include "NgeWriter.h"
|
||||||
#include "NgeReader.h"
|
#include "NgeReader.h"
|
||||||
#include "Voronoi.h"
|
#include "Voronoi.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
|
|||||||
+4
-3
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2020-2024
|
// EgalTech 2020-2022
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : DistLineLine.cpp Data : 10.05.24 Versione : 2.6e3
|
// File : DistLineLine.h Data : 12.08.22 Versione : 2.4h1
|
||||||
// Contenuto : Implementazione della classe distanza fra elementi lineari.
|
// Contenuto : Implementazione della classe distanza fra elementi lineari.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -12,10 +12,11 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
#include "DistLineLine.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
#include "/EgtDev/Include/EGkGeoCollection.h"
|
#include "/EgtDev/Include/EGkGeoCollection.h"
|
||||||
#include "/EgtDev/Include/EGkGeoConst.h"
|
#include "/EgtDev/Include/EGkGeoConst.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// EgalTech 2020-2020
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// File : DistLineLine.h Data : 06.11.20 Versione : 2.2k1
|
||||||
|
// Contenuto : Dichiarazione della classe distanza fra elementi lineari.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Modifiche : 06.11.20 LM Creazione modulo.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "/EgtDev/Include/EGkVector3d.h"
|
||||||
|
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
class DistLineLine
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1,
|
||||||
|
const Point3d& ptSt2, const Point3d& ptEn2,
|
||||||
|
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||||
|
DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||||
|
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||||
|
bool bIsSegment1 = true, bool bIsSegment2 = true) ;
|
||||||
|
|
||||||
|
public :
|
||||||
|
bool GetSqDist( double& dSqDist) const ;
|
||||||
|
bool GetDist( double& dDist) const ;
|
||||||
|
bool IsEpsilon( double dTol) const
|
||||||
|
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||||
|
bool IsSmall( void) const
|
||||||
|
{ return IsEpsilon( EPS_SMALL) ; }
|
||||||
|
bool IsZero( void) const
|
||||||
|
{ return IsEpsilon( EPS_ZERO) ; }
|
||||||
|
bool GetMinDistPoints( Point3d& ptMinDist1, Point3d& ptMinDist2) const ;
|
||||||
|
bool GetPositionsAtMinDistPoints( double& dPos1, double& dPos2) const ;
|
||||||
|
|
||||||
|
private :
|
||||||
|
void Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen1,
|
||||||
|
const Point3d& ptSt2, const Vector3d& vtD2, double dLen2,
|
||||||
|
bool bIsSegment1, bool bIsSegment2) ;
|
||||||
|
private:
|
||||||
|
double m_dSqDist ;
|
||||||
|
mutable double m_dDist ;
|
||||||
|
double m_dPos1 ;
|
||||||
|
double m_dPos2 ;
|
||||||
|
Point3d m_ptMinDist1 ;
|
||||||
|
Point3d m_ptMinDist2 ;
|
||||||
|
} ;
|
||||||
+2
-2
@@ -14,9 +14,9 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "DllMain.h"
|
#include "DllMain.h"
|
||||||
#include "GeoConst.h"
|
|
||||||
#include "DistPointCrvAux.h"
|
#include "DistPointCrvAux.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
|
#include "GeoConst.h"
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
|
|||||||
}
|
}
|
||||||
// altrimenti, per curve successive
|
// altrimenti, per curve successive
|
||||||
else {
|
else {
|
||||||
// verifico se la distanza minima dal box è superiore al minimo già trovato
|
// verifico se la distanza minima dal box è superiore al minimo già trovato
|
||||||
BBox3d b3B ;
|
BBox3d b3B ;
|
||||||
if ( pCrvSmpl->GetLocalBBox( b3B) &&
|
if ( pCrvSmpl->GetLocalBBox( b3B) &&
|
||||||
b3B.SqDistFromPoint( ptP) <= m_dDist * m_dDist) {
|
b3B.SqDistFromPoint( ptP) <= m_dDist * m_dDist) {
|
||||||
@@ -105,7 +105,7 @@ DistPointCrvComposite::DistPointCrvComposite( const Point3d& ptP, const ICurveCo
|
|||||||
++ i ;
|
++ i ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// con minima distanza più bassa
|
// con minima distanza più bassa
|
||||||
else if ( dCurrDist < m_dDist) {
|
else if ( dCurrDist < m_dDist) {
|
||||||
// aggiorno i minimi
|
// aggiorno i minimi
|
||||||
m_dDist = dCurrDist ;
|
m_dDist = dCurrDist ;
|
||||||
|
|||||||
+1
-3
@@ -13,10 +13,10 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "DistPointArc.h"
|
#include "DistPointArc.h"
|
||||||
#include "DistPointCrvBezier.h"
|
#include "DistPointCrvBezier.h"
|
||||||
#include "DistPointCrvComposite.h"
|
#include "DistPointCrvComposite.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -47,8 +47,6 @@ DistPointCurve::DistPointCurve( const Point3d& ptP, const ICurve& Curve, bool bI
|
|||||||
case CRV_COMPO :
|
case CRV_COMPO :
|
||||||
CrvCompositeCalculate( ptP, Curve) ;
|
CrvCompositeCalculate( ptP, Curve) ;
|
||||||
break ;
|
break ;
|
||||||
default :
|
|
||||||
break ;
|
|
||||||
}
|
}
|
||||||
// salvo il punto
|
// salvo il punto
|
||||||
m_ptP = ptP ;
|
m_ptP = ptP ;
|
||||||
|
|||||||
+4
-4
@@ -1,19 +1,19 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2013-2024
|
// EgalTech 2013-2013
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : DistPointLine.cpp Data : 20.05.24 Versione : 2.6e5
|
// File : DistPointLine.cpp Data : 17.12.13 Versione : 1.4l1
|
||||||
// Contenuto : Implementazione della classe distanza punto da linea/segmento.
|
// Contenuto : Implementazione della classe distanza punto da linea/segmento.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Modifiche : 17.12.13 DS Creazione modulo.
|
// Modifiche : 17.12.13 DS Creazione modulo.
|
||||||
// 20.05.24 DS Reso pubblico in Include.
|
//
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// EgalTech 2013-2014
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// File : DistPointLine.h Data : 02.01.14 Versione : 1.5a1
|
||||||
|
// Contenuto : Dichiarazione della classe distanza punto da linea/segmento.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Modifiche : 30.12.12 DS Creazione modulo.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||||
|
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class DistPointLine
|
||||||
|
{
|
||||||
|
friend class DistPointCurve ;
|
||||||
|
|
||||||
|
public :
|
||||||
|
DistPointLine( const Point3d& ptP,
|
||||||
|
const ICurveLine& crvLine, bool bIsSegment = true) ;
|
||||||
|
DistPointLine( const Point3d& ptP,
|
||||||
|
const Point3d& ptIni, const Point3d& ptFin, bool bIsSegment = true) ;
|
||||||
|
DistPointLine( const Point3d& ptP,
|
||||||
|
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment = true) ;
|
||||||
|
|
||||||
|
public :
|
||||||
|
bool GetSqDist( double& dSqDist) const ;
|
||||||
|
bool GetDist( double& dDist) const ;
|
||||||
|
bool IsEpsilon( double dTol) const
|
||||||
|
{ double dSqDist ; return ( GetSqDist( dSqDist) && ( dSqDist < SQ_EPS_ZERO || dSqDist < dTol * dTol)) ; }
|
||||||
|
bool IsSmall( void) const
|
||||||
|
{ return IsEpsilon( EPS_SMALL) ; }
|
||||||
|
bool IsZero( void) const
|
||||||
|
{ return IsEpsilon( EPS_ZERO) ; }
|
||||||
|
int GetNbrMinDist( void) const
|
||||||
|
{ return (( m_dSqDist < 0) ? 0 : 1) ; }
|
||||||
|
bool GetMinDistPoint( Point3d& ptMinDist) const ;
|
||||||
|
bool GetParamAtMinDistPoint( double& dParam) const ;
|
||||||
|
|
||||||
|
private :
|
||||||
|
DistPointLine( void) ;
|
||||||
|
void Calculate( const Point3d& ptP,
|
||||||
|
const Point3d& ptIni, const Vector3d& vtDir, double dLen, bool bIsSegment) ;
|
||||||
|
|
||||||
|
private :
|
||||||
|
double m_dSqDist ;
|
||||||
|
mutable double m_dDist ;
|
||||||
|
double m_dParam ;
|
||||||
|
Point3d m_ptMinDist ;
|
||||||
|
} ;
|
||||||
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
//----------------------------------------------------------------------------
|
|
||||||
// EgalTech 2018-2020
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// File : DistPointSurfTm.cpp Data : 19.12.20 Versione : 2.2l3
|
|
||||||
// Contenuto : Implementazione della classe distanza Punto da Trimesh.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Modifiche : 07.12.18 LM Creazione modulo.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "SurfFlatRegion.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointSurfFr.h"
|
|
||||||
|
|
||||||
using namespace std ;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
DistPointSurfFr::DistPointSurfFr( const Point3d& ptP, const ISurfFlatRegion& frSurf)
|
|
||||||
: m_dDist( -1)
|
|
||||||
{
|
|
||||||
// FlatRegion non valida
|
|
||||||
if ( &frSurf == nullptr || ! frSurf.IsValid())
|
|
||||||
return ;
|
|
||||||
// Calcolo la distanza
|
|
||||||
Calculate( ptP, frSurf) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void
|
|
||||||
DistPointSurfFr::Calculate( const Point3d& ptP, const ISurfFlatRegion& frSurf)
|
|
||||||
{
|
|
||||||
// Inizializzo distanza non calcolata
|
|
||||||
m_dDist = -1 ;
|
|
||||||
|
|
||||||
// Converto regione in classe base
|
|
||||||
const SurfFlatRegion* pSfr = GetBasicSurfFlatRegion( &frSurf) ;
|
|
||||||
if ( pSfr == nullptr)
|
|
||||||
return ;
|
|
||||||
|
|
||||||
// ciclo sulle parti della regione
|
|
||||||
for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; nC ++) {
|
|
||||||
// ciclo sui loop della parte di regione
|
|
||||||
for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; nL ++) {
|
|
||||||
PtrOwner<ICurve> pLoop( pSfr->GetLoop( nC, nL)) ;
|
|
||||||
if ( IsNull( pLoop)) {
|
|
||||||
m_dDist = -1 ;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
DistPointCurve DPL( ptP, *pLoop) ;
|
|
||||||
double dDist ;
|
|
||||||
if ( DPL.GetDist( dDist) && ( m_dDist < -EPS_SMALL || dDist < m_dDist)) {
|
|
||||||
m_dDist = dDist ;
|
|
||||||
int nFlag ;
|
|
||||||
m_nMinChunk = nC ;
|
|
||||||
m_nMinLoop = nL ;
|
|
||||||
DPL.GetParamAtMinDistPoint( 0, m_dMinPar, nFlag) ;
|
|
||||||
DPL.GetMinDistPoint( 0, m_ptMinDistPoint, nFlag) ;
|
|
||||||
DPL.GetSideAtMinDistPoint( 0, pSfr->GetNormVersor(), m_nSide) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// se trovata, aggiorno minima distanza sul piano
|
|
||||||
if ( m_dDist > - EPS_SMALL) {
|
|
||||||
Point3d ptOn = ptP - ( ptP - pSfr->GetPlanePoint()) * pSfr->GetNormVersor() * pSfr->GetNormVersor() ;
|
|
||||||
m_dDistOnPlane = min( Dist( ptOn, m_ptMinDistPoint), m_dDist) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
DistPointSurfFr::GetDist( double& dDist) const
|
|
||||||
{
|
|
||||||
if ( m_dDist < 0)
|
|
||||||
return false ;
|
|
||||||
dDist = m_dDist ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
DistPointSurfFr::GetDistOnRegionPlane( double& dDist) const
|
|
||||||
{
|
|
||||||
if ( m_dDist < 0)
|
|
||||||
return false ;
|
|
||||||
dDist = m_dDistOnPlane ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
DistPointSurfFr::GetPointAtMinDist( Point3d& ptMinDist) const
|
|
||||||
{
|
|
||||||
if ( m_dDist < 0)
|
|
||||||
return false ;
|
|
||||||
ptMinDist = m_ptMinDistPoint ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
DistPointSurfFr::GetParamAtMinDist( int& nMinChunk, int& nMinLoop, double& dMinPar) const
|
|
||||||
{
|
|
||||||
if ( m_dDist < 0)
|
|
||||||
return false ;
|
|
||||||
nMinChunk = m_nMinChunk ;
|
|
||||||
nMinLoop = m_nMinLoop ;
|
|
||||||
dMinPar = m_dMinPar ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
DistPointSurfFr::GetSideAtMinDist( int& nSide) const
|
|
||||||
{
|
|
||||||
if ( m_dDist < 0)
|
|
||||||
return false ;
|
|
||||||
nSide = m_nSide ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
IsPointInsideSurfFr( const Point3d& ptP, const ISurfFlatRegion* pSfr, double dMinDist, bool& bInside, int& nChunk)
|
|
||||||
{
|
|
||||||
// default non include
|
|
||||||
bInside = false ;
|
|
||||||
nChunk = -1 ;
|
|
||||||
// verifica regione
|
|
||||||
if ( pSfr == nullptr || ! pSfr->IsValid())
|
|
||||||
return false ;
|
|
||||||
// verifico se la proiezione del punto sul piano della regione sta nel suo box
|
|
||||||
Point3d ptOn = ptP - ( ptP - pSfr->GetPlanePoint()) * pSfr->GetNormVersor() * pSfr->GetNormVersor() ;
|
|
||||||
BBox3d b3Box ;
|
|
||||||
pSfr->GetLocalBBox( b3Box) ;
|
|
||||||
b3Box.Expand( dMinDist) ;
|
|
||||||
if ( ! b3Box.Encloses( ptOn))
|
|
||||||
return true ;
|
|
||||||
// determino dove sta il punto
|
|
||||||
DistPointSurfFr DPR( ptP, *pSfr) ;
|
|
||||||
double dDist ; int nMinCh, nMinL; double dMinPar ; int nSide ;
|
|
||||||
if ( DPR.GetDistOnRegionPlane( dDist) && DPR.GetParamAtMinDist( nMinCh, nMinL, dMinPar) && DPR.GetSideAtMinDist( nSide)) {
|
|
||||||
if ( abs( dMinDist) < EPS_SMALL)
|
|
||||||
bInside = ( nSide != PRS_OUT) ;
|
|
||||||
else if ( dMinDist < 0)
|
|
||||||
bInside = ( nSide == PRS_IN && dDist > abs( dMinDist) - EPS_SMALL) ;
|
|
||||||
else
|
|
||||||
bInside = ( nSide != PRS_OUT || dDist < dMinDist + EPS_SMALL) ;
|
|
||||||
if ( bInside)
|
|
||||||
nChunk = nMinCh ;
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
+28
-97
@@ -15,16 +15,15 @@
|
|||||||
#include "SurfTriMesh.h"
|
#include "SurfTriMesh.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// Calcola la differenza fra i bounding-box A e B.
|
// Calcola la differenza fra i bounding-box A e B.
|
||||||
// L'insieme differenza non è un bounding-box, ma è esprimibile come unione di al più sei bounding-box.
|
// L'insieme differenza non è un bounding-box, ma è esprimibile come unione di al più sei bounding-box.
|
||||||
// Se l'insieme differenza fra i box non ha misura nulla viene restituito true, false altrimenti.
|
// Se l'insieme differenza fra i box non ha misura nulla viene restituito true, false altrimenti.
|
||||||
// I casi in cui non vengono trovati box di misura positiva sono quelli in cui o il box A è contenuto
|
// I casi in cui non vengono trovati box di misura positiva sono quelli in cui o il box A è contenuto
|
||||||
// nel box B; uno di questi si verifica se il box A è vuoto.
|
// nel box B; uno di questi si verifica se il box A è vuoto.
|
||||||
// Nel vettore vBoxDiff vengono restituiti i box la cui unione costituisce la differenza fra A e B.
|
// Nel vettore vBoxDiff vengono restituiti i box la cui unione costituisce la differenza fra A e B.
|
||||||
static bool
|
static bool
|
||||||
BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDiff)
|
BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDiff)
|
||||||
@@ -34,7 +33,7 @@ BoundingBoxDifference( const BBox3d& boxA, const BBox3d& boxB, BOXVECTOR& vBoxDi
|
|||||||
// Se box A vuoto, risultato vuoto
|
// Se box A vuoto, risultato vuoto
|
||||||
if ( boxA.IsEmpty())
|
if ( boxA.IsEmpty())
|
||||||
return false ;
|
return false ;
|
||||||
// Se box B vuoto o i box non si intersecano, risultato è ancora A
|
// Se box B vuoto o i box non si intersecano, risultato è ancora A
|
||||||
BBox3d boxInt ;
|
BBox3d boxInt ;
|
||||||
if ( boxB.IsSmall() || ! boxA.FindIntersection( boxB, boxInt)) {
|
if ( boxB.IsSmall() || ! boxA.FindIntersection( boxB, boxInt)) {
|
||||||
vBoxDiff.emplace_back( boxA) ;
|
vBoxDiff.emplace_back( boxA) ;
|
||||||
@@ -94,8 +93,6 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
{
|
{
|
||||||
// Inizializzo distanza non calcolata
|
// Inizializzo distanza non calcolata
|
||||||
m_dDist = - 1. ;
|
m_dDist = - 1. ;
|
||||||
// Controllo se la superficie è chiusa
|
|
||||||
m_bIsSurfClosed = tmSurf.IsClosed() ;
|
|
||||||
|
|
||||||
// Lavoro con l'oggetto superficie trimesh di base
|
// Lavoro con l'oggetto superficie trimesh di base
|
||||||
const SurfTriMesh* pStm = GetBasicSurfTriMesh( &tmSurf) ;
|
const SurfTriMesh* pStm = GetBasicSurfTriMesh( &tmSurf) ;
|
||||||
@@ -107,8 +104,8 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
if ( b3Stm.IsEmpty())
|
if ( b3Stm.IsEmpty())
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
|
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
|
||||||
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
|
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
|
||||||
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
|
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
|
||||||
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
|
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
|
||||||
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
|
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
|
||||||
@@ -118,17 +115,14 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
BBox3d boxPPrev( ptP) ;
|
BBox3d boxPPrev( ptP) ;
|
||||||
BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ;
|
BBox3d boxP( ptP, dBoxHalfLenX, dBoxHalfLenY, dBoxHalfLenZ) ;
|
||||||
// Variabili distanza minima, indice del triangolo di distanza minima, punto di distanza minima
|
// Variabili distanza minima, indice del triangolo di distanza minima, punto di distanza minima
|
||||||
double dMinDist = DBL_MAX ;
|
double dMinSqDist = DBL_MAX ;
|
||||||
int nMinDistTriaIndex = SVT_NULL ;
|
int nMinDistTriaIndex = SVT_NULL ;
|
||||||
Point3d ptMinDistPoint ;
|
Point3d ptMinDistPoint ;
|
||||||
// Finché non si verifica la condizione di terminazione ingrandisco il box.
|
// Finché non si verifica la condizione di terminazione ingrandisco il box.
|
||||||
pStm->ResetTempInts() ;
|
pStm->ResetTempInts() ;
|
||||||
bool bContinue = true ;
|
bool bContinue = true ;
|
||||||
|
|
||||||
// creazione del vettore dei triangoli più vicini a ptP
|
|
||||||
vector<pair<int, Triangle3d>> vTria ; // <indice triangolo, Triangolo>
|
|
||||||
while ( bContinue) {
|
while ( bContinue) {
|
||||||
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
|
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
|
||||||
BOXVECTOR vBox ;
|
BOXVECTOR vBox ;
|
||||||
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
|
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
|
||||||
// Ciclo sui box differenza
|
// Ciclo sui box differenza
|
||||||
@@ -136,7 +130,7 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
for ( const auto& b3Box : vBox) {
|
for ( const auto& b3Box : vBox) {
|
||||||
// interseco il box con quello della superficie e ne verifico la distanza minima dal punto
|
// interseco il box con quello della superficie e ne verifico la distanza minima dal punto
|
||||||
BBox3d b3Int ;
|
BBox3d b3Int ;
|
||||||
if ( ! b3Box.FindIntersection( b3Stm, b3Int) || b3Int.DistFromPoint( ptP) > dMinDist)
|
if ( ! b3Box.FindIntersection( b3Stm, b3Int) || b3Int.SqDistFromPoint( ptP) > dMinSqDist)
|
||||||
continue ;
|
continue ;
|
||||||
// ricerca sui triangoli nel box
|
// ricerca sui triangoli nel box
|
||||||
bCollide = true ;
|
bCollide = true ;
|
||||||
@@ -149,30 +143,19 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
if ( pStm->GetTempInt( nT, nTriaTemp) && nTriaTemp == 0 && pStm->GetTriangle( nT, trCurTria)) {
|
if ( pStm->GetTempInt( nT, nTriaTemp) && nTriaTemp == 0 && pStm->GetTriangle( nT, trCurTria)) {
|
||||||
pStm->SetTempInt( nT, 1) ;
|
pStm->SetTempInt( nT, 1) ;
|
||||||
DistPointTriangle distPT( ptP, trCurTria) ;
|
DistPointTriangle distPT( ptP, trCurTria) ;
|
||||||
double dCurrDist ;
|
double dCurSqDist ;
|
||||||
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno
|
// Se la distanza del triangolo è valida e minore di quella attuale aggiorno
|
||||||
if ( distPT.GetDist( dCurrDist)) {
|
if ( distPT.GetSqDist( dCurSqDist) && dCurSqDist < dMinSqDist) {
|
||||||
// se distanze uguali...
|
dMinSqDist = dCurSqDist ;
|
||||||
if ( abs( dCurrDist - dMinDist) < EPS_SMALL)
|
nMinDistTriaIndex = nT ;
|
||||||
// aggiungo il triangolo
|
distPT.GetMinDistPoint( ptMinDistPoint) ;
|
||||||
vTria.emplace_back( make_pair( nT, trCurTria)) ;
|
|
||||||
// se minore...
|
|
||||||
else if ( dCurrDist < dMinDist) {
|
|
||||||
// pulisco il vettore
|
|
||||||
vTria.clear() ;
|
|
||||||
dMinDist = dCurrDist ;
|
|
||||||
nMinDistTriaIndex = nT ;
|
|
||||||
distPT.GetMinDistPoint( ptMinDistPoint) ;
|
|
||||||
// aggiungo il triangolo
|
|
||||||
vTria.emplace_back( make_pair( nT, trCurTria)) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Se si verifica la condizione di terminazione arresto il ciclo altrimenti aggiorno i box
|
// Se si verifica la condizione di terminazione arresto il ciclo altrimenti aggiorno i box
|
||||||
if ( ! bCollide || dMinDist < EPS_SMALL)
|
if ( ! bCollide || dMinSqDist < EPS_SMALL * EPS_SMALL)
|
||||||
bContinue = false ;
|
bContinue = false ;
|
||||||
else {
|
else {
|
||||||
boxPPrev = boxP ;
|
boxPPrev = boxP ;
|
||||||
@@ -180,67 +163,15 @@ DistPointSurfTm::Calculate( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// se non ho trovato nessun triangolo, esco
|
if ( nMinDistTriaIndex != SVT_NULL) {
|
||||||
if ( nMinDistTriaIndex == SVT_NULL)
|
m_dDist = sqrt( max( dMinSqDist, 0.)) ;
|
||||||
return ;
|
|
||||||
|
|
||||||
// salvo la distanza minima
|
|
||||||
m_dDist = dMinDist ;
|
|
||||||
// salvo il punto a distanza minima
|
|
||||||
m_ptMinDistPoint = ptMinDistPoint ;
|
|
||||||
// se il punto è sulla TriMesh...
|
|
||||||
if ( m_dDist < EPS_SMALL) {
|
|
||||||
m_nMinDistTriaIndex = nMinDistTriaIndex ;
|
m_nMinDistTriaIndex = nMinDistTriaIndex ;
|
||||||
m_bIsInside = false ;
|
m_ptMinDistPoint = ptMinDistPoint ;
|
||||||
return ;
|
Triangle3d trMinDistTria ;
|
||||||
|
pStm->GetTriangle( m_nMinDistTriaIndex, trMinDistTria) ;
|
||||||
|
trMinDistTria.Validate() ;
|
||||||
|
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * trMinDistTria.GetN() < - EPS_SMALL) && pStm->IsClosed() ;
|
||||||
}
|
}
|
||||||
// se ho un solo triangolo, allora deduco le informazioni da lui
|
|
||||||
else if ( int( vTria.size()) == 1) {
|
|
||||||
m_nMinDistTriaIndex = vTria.back().first ;
|
|
||||||
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * vTria.back().second.GetN() < - EPS_SMALL) ;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// controllo se tutti i triangoli a minima distanza forniscono la stessa informazione
|
|
||||||
// ( il punto potrebbe essere esterno a tutti, interno a tutti o indefinito )
|
|
||||||
bool bInside = false ;
|
|
||||||
bool bOutside = false ;
|
|
||||||
for ( int i = 0 ; i < int( vTria.size()) ; ++ i) { // scorro i triangoli a minima distanza
|
|
||||||
if ( ( ptP - vTria[i].second.GetP( 0)) * vTria[i].second.GetN() < - EPS_SMALL)
|
|
||||||
bInside = true ;
|
|
||||||
else
|
|
||||||
bOutside = true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// inizializzo le variabili membro
|
|
||||||
m_nMinDistTriaIndex = nMinDistTriaIndex ;
|
|
||||||
m_bIsInside = false ;
|
|
||||||
|
|
||||||
// se le informazioni non sono coerenti, allora :
|
|
||||||
// 1) calcolo i centroidi dei triangoli in questione
|
|
||||||
// 2) ottengo il punto medio di questi centroidi
|
|
||||||
// 3) controllo quale triangolo interseca il segmento che parte da ptP e arriva a tale punto
|
|
||||||
// 4) userò questo triangolo per classificare ptP
|
|
||||||
if ( bOutside == bInside) {
|
|
||||||
// calcolo il baricentro complessivo
|
|
||||||
Point3d ptBar_tot ;
|
|
||||||
for ( auto& Tria : vTria)
|
|
||||||
ptBar_tot += Tria.second.GetCentroid() ;
|
|
||||||
ptBar_tot /= int( vTria.size()) ;
|
|
||||||
// per ogni triangolo, cerco quello che interseca il segmento
|
|
||||||
for ( auto& Tria : vTria) {
|
|
||||||
Point3d ptInters1, ptInters2 ;
|
|
||||||
int nType = IntersLineTria( ptP, ptBar_tot, Tria.second, ptInters1, ptInters2) ;
|
|
||||||
if ( nType == ILTT_IN) { // se intersezione ho finito
|
|
||||||
DistPointTriangle( ptP, Tria.second).GetMinDistPoint( m_ptMinDistPoint) ;
|
|
||||||
m_bIsInside = ( ( ptP - m_ptMinDistPoint) * Tria.second.GetN() < - EPS_SMALL) ;
|
|
||||||
m_nMinDistTriaIndex = Tria.first ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // se informazioni coerenti
|
|
||||||
m_bIsInside = bInside ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -293,8 +224,8 @@ GetSurfTmNearestVertex( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
if ( b3Stm.IsEmpty())
|
if ( b3Stm.IsEmpty())
|
||||||
return SVT_NULL ;
|
return SVT_NULL ;
|
||||||
|
|
||||||
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
|
// Cerco triangoli in box centrati sul punto dato di ampiezza crescente ed escludendo le parti già verificate.
|
||||||
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
|
// Termino quando non trovo più triangoli che possano soddisfare la richiesta.
|
||||||
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
|
Point3d ptMin, ptMax ; b3Stm.GetMinMax( ptMin, ptMax) ;
|
||||||
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
|
double dDeltaLen = max( min( min( b3Stm.GetDimX(), b3Stm.GetDimY()), b3Stm.GetDimZ()) / 40., 20.) ;
|
||||||
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
|
double dBoxHalfLenX = max( max( ptMin.x - ptP.x, ptP.x - ptMax.x), 0.) + dDeltaLen ;
|
||||||
@@ -306,11 +237,11 @@ GetSurfTmNearestVertex( const Point3d& ptP, const ISurfTriMesh& tmSurf)
|
|||||||
// Variabili distanza minima
|
// Variabili distanza minima
|
||||||
int nVert = SVT_NULL ;
|
int nVert = SVT_NULL ;
|
||||||
double dMinSqDist = DBL_MAX ;
|
double dMinSqDist = DBL_MAX ;
|
||||||
// Finché non si verifica la condizione di terminazione ingrandisco il box.
|
// Finché non si verifica la condizione di terminazione ingrandisco il box.
|
||||||
pStm->ResetTempInts() ;
|
pStm->ResetTempInts() ;
|
||||||
bool bContinue = true ;
|
bool bContinue = true ;
|
||||||
while ( bContinue) {
|
while ( bContinue) {
|
||||||
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
|
// Calcolo il box differenza con il precedente per non esplorare parti già considerate
|
||||||
BOXVECTOR vBox ;
|
BOXVECTOR vBox ;
|
||||||
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
|
BoundingBoxDifference( boxP, boxPPrev, vBox) ;
|
||||||
// Ciclo sui box differenza
|
// Ciclo sui box differenza
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "ProjPlane.h"
|
#include "ProjPlane.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -281,7 +281,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
|||||||
<ClCompile Include="BBox3d.cpp" />
|
<ClCompile Include="BBox3d.cpp" />
|
||||||
<ClCompile Include="BiArcs.cpp" />
|
<ClCompile Include="BiArcs.cpp" />
|
||||||
<ClCompile Include="CalcPocketing.cpp" />
|
<ClCompile Include="CalcPocketing.cpp" />
|
||||||
<ClCompile Include="CAvSilhouetteSurfTm.cpp" />
|
|
||||||
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
|
<ClCompile Include="CAvSimpleSurfFrMove.cpp" />
|
||||||
<ClCompile Include="CAvToolSurfTm.cpp" />
|
<ClCompile Include="CAvToolSurfTm.cpp" />
|
||||||
<ClCompile Include="CAvToolTriangle.cpp" />
|
<ClCompile Include="CAvToolTriangle.cpp" />
|
||||||
@@ -310,7 +309,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
|||||||
<ClCompile Include="CurveByApprox.cpp" />
|
<ClCompile Include="CurveByApprox.cpp" />
|
||||||
<ClCompile Include="CurveByInterp.cpp" />
|
<ClCompile Include="CurveByInterp.cpp" />
|
||||||
<ClCompile Include="CurveCompositeOffset.cpp" />
|
<ClCompile Include="CurveCompositeOffset.cpp" />
|
||||||
<ClCompile Include="DistPointSurfFr.cpp" />
|
|
||||||
<ClCompile Include="IntersCurveSurfTm.cpp">
|
<ClCompile Include="IntersCurveSurfTm.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||||
@@ -321,19 +319,15 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
|||||||
<ClCompile Include="IntersPlaneVolZmap.cpp" />
|
<ClCompile Include="IntersPlaneVolZmap.cpp" />
|
||||||
<ClCompile Include="IntersLineSurfBez.cpp" />
|
<ClCompile Include="IntersLineSurfBez.cpp" />
|
||||||
<ClCompile Include="PolygonElevation.cpp" />
|
<ClCompile Include="PolygonElevation.cpp" />
|
||||||
<ClCompile Include="ProjectCurveSurfBez.cpp" />
|
|
||||||
<ClCompile Include="Quaternion.cpp" />
|
<ClCompile Include="Quaternion.cpp" />
|
||||||
<ClCompile Include="RotationMinimizingFrame.cpp" />
|
<ClCompile Include="RotationMinimizingFrame.cpp" />
|
||||||
<ClCompile Include="RotationXplaneFrame.cpp" />
|
<ClCompile Include="RotationXplaneFrame.cpp" />
|
||||||
<ClCompile Include="SbzFromCurves.cpp" />
|
|
||||||
<ClCompile Include="SbzStandard.cpp" />
|
<ClCompile Include="SbzStandard.cpp" />
|
||||||
<ClCompile Include="Voronoi.cpp" />
|
<ClCompile Include="Voronoi.cpp" />
|
||||||
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
|
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
|
||||||
<ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" />
|
<ClInclude Include="..\Include\EGkCDeConeFrustumClosedSurfTm.h" />
|
||||||
<ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" />
|
<ClInclude Include="..\Include\EGkCDeConvexTorusClosedSurfTm.h" />
|
||||||
<ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" />
|
<ClInclude Include="..\Include\EGkCDeRectPrismoidClosedSurfTm.h" />
|
||||||
<ClInclude Include="..\Include\EGkDistLineLine.h" />
|
|
||||||
<ClInclude Include="..\Include\EGkDistPointLine.h" />
|
|
||||||
<ClInclude Include="..\Include\EGkIntersCurveSurfTm.h" />
|
<ClInclude Include="..\Include\EGkIntersCurveSurfTm.h" />
|
||||||
<ClInclude Include="..\Include\EGkIntersLineBox.h" />
|
<ClInclude Include="..\Include\EGkIntersLineBox.h" />
|
||||||
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h" />
|
<ClInclude Include="..\Include\EGkIntersLineVolZmap.h" />
|
||||||
@@ -344,7 +338,6 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
|||||||
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
|
<ClInclude Include="..\Include\EGkRotationMinimizingFrame.h" />
|
||||||
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h" />
|
<ClInclude Include="..\Include\EGkRotationXplaneFrame.h" />
|
||||||
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
<ClInclude Include="..\Include\EGkSubtractProjectedFacesOnStmFace.h" />
|
||||||
<ClInclude Include="CAvSilhouetteSurfTm.h" />
|
|
||||||
<ClInclude Include="CDeBoxTria.h" />
|
<ClInclude Include="CDeBoxTria.h" />
|
||||||
<ClInclude Include="CDeCapsTria.h" />
|
<ClInclude Include="CDeCapsTria.h" />
|
||||||
<ClInclude Include="CDeConeFrustumTria.h" />
|
<ClInclude Include="CDeConeFrustumTria.h" />
|
||||||
@@ -602,10 +595,12 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
|||||||
<ClInclude Include="CAvSimpleSurfFrMove.h" />
|
<ClInclude Include="CAvSimpleSurfFrMove.h" />
|
||||||
<ClInclude Include="CAvToolSurfTm.h" />
|
<ClInclude Include="CAvToolSurfTm.h" />
|
||||||
<ClInclude Include="CreateCurveAux.h" />
|
<ClInclude Include="CreateCurveAux.h" />
|
||||||
|
<ClInclude Include="DistLineLine.h" />
|
||||||
<ClInclude Include="DistPointArc.h" />
|
<ClInclude Include="DistPointArc.h" />
|
||||||
<ClInclude Include="DistPointCrvAux.h" />
|
<ClInclude Include="DistPointCrvAux.h" />
|
||||||
<ClInclude Include="DistPointCrvBezier.h" />
|
<ClInclude Include="DistPointCrvBezier.h" />
|
||||||
<ClInclude Include="DistPointCrvComposite.h" />
|
<ClInclude Include="DistPointCrvComposite.h" />
|
||||||
|
<ClInclude Include="DistPointLine.h" />
|
||||||
<ClInclude Include="DllMain.h" />
|
<ClInclude Include="DllMain.h" />
|
||||||
<ClInclude Include="earcut.hpp" />
|
<ClInclude Include="earcut.hpp" />
|
||||||
<ClInclude Include="ExtDimension.h" />
|
<ClInclude Include="ExtDimension.h" />
|
||||||
|
|||||||
@@ -537,18 +537,6 @@
|
|||||||
<ClCompile Include="Quaternion.cpp">
|
<ClCompile Include="Quaternion.cpp">
|
||||||
<Filter>File di origine\Base</Filter>
|
<Filter>File di origine\Base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="CAvSilhouetteSurfTm.cpp">
|
|
||||||
<Filter>File di origine\GeoCollisionAvoid</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ProjectCurveSurfBez.cpp">
|
|
||||||
<Filter>File di origine\GeoProject</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SbzFromCurves.cpp">
|
|
||||||
<Filter>File di origine\GeoCreate</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="DistPointSurfFr.cpp">
|
|
||||||
<Filter>File di origine\GeoDist</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="stdafx.h">
|
<ClInclude Include="stdafx.h">
|
||||||
@@ -605,6 +593,9 @@
|
|||||||
<ClInclude Include="DistPointArc.h">
|
<ClInclude Include="DistPointArc.h">
|
||||||
<Filter>File di intestazione</Filter>
|
<Filter>File di intestazione</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="DistPointLine.h">
|
||||||
|
<Filter>File di intestazione</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="DistPointCrvBezier.h">
|
<ClInclude Include="DistPointCrvBezier.h">
|
||||||
<Filter>File di intestazione</Filter>
|
<Filter>File di intestazione</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -1127,6 +1118,9 @@
|
|||||||
<ClInclude Include="..\Include\EGkIntersPlaneBox.h">
|
<ClInclude Include="..\Include\EGkIntersPlaneBox.h">
|
||||||
<Filter>File di intestazione\Include</Filter>
|
<Filter>File di intestazione\Include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="DistLineLine.h">
|
||||||
|
<Filter>File di intestazione</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="CDeUtility.h">
|
<ClInclude Include="CDeUtility.h">
|
||||||
<Filter>File di intestazione</Filter>
|
<Filter>File di intestazione</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -1220,15 +1214,6 @@
|
|||||||
<ClInclude Include="..\Include\EGkQuaternion.h">
|
<ClInclude Include="..\Include\EGkQuaternion.h">
|
||||||
<Filter>File di intestazione\Include</Filter>
|
<Filter>File di intestazione\Include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\Include\EGkDistLineLine.h">
|
|
||||||
<Filter>File di intestazione\Include</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\Include\EGkDistPointLine.h">
|
|
||||||
<Filter>File di intestazione\Include</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="CAvSilhouetteSurfTm.h">
|
|
||||||
<Filter>File di intestazione</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||||
|
|||||||
-17
@@ -37,23 +37,6 @@ Frame3d::Set( const Point3d& ptOrig, const Vector3d& vtDirX,
|
|||||||
! m_vtVersZ.Normalize())
|
! m_vtVersZ.Normalize())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// se ci sono errori molto piccoli di ortogonalità, li correggo
|
|
||||||
double dOrtXZ = m_vtVersX * m_vtVersZ ;
|
|
||||||
if ( dOrtXZ > EPS_ZERO && dOrtXZ < 10 * EPS_ZERO) {
|
|
||||||
m_vtVersX = OrthoCompo( m_vtVersX, m_vtVersZ) ;
|
|
||||||
m_vtVersX.Normalize() ;
|
|
||||||
}
|
|
||||||
double dOrtYX = m_vtVersY * m_vtVersX ;
|
|
||||||
if ( dOrtYX > EPS_ZERO && dOrtYX < 10 * EPS_ZERO) {
|
|
||||||
m_vtVersY = OrthoCompo( m_vtVersY, m_vtVersX) ;
|
|
||||||
m_vtVersY.Normalize() ;
|
|
||||||
}
|
|
||||||
double dOrtYZ = m_vtVersY * m_vtVersZ ;
|
|
||||||
if ( dOrtYZ > EPS_ZERO && dOrtYZ < 10 * EPS_ZERO) {
|
|
||||||
m_vtVersY = OrthoCompo( m_vtVersY, m_vtVersZ) ;
|
|
||||||
m_vtVersY.Normalize() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// verifica della ortogonalità dei versori e del senso destrorso
|
// verifica della ortogonalità dei versori e del senso destrorso
|
||||||
if ( ! Verify())
|
if ( ! Verify())
|
||||||
return false ;
|
return false ;
|
||||||
|
|||||||
+2
-2
@@ -1254,13 +1254,13 @@ GdbIterator::GetCalcStatus( int& nStat) const
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
GdbIterator::SetMark( int nMark)
|
GdbIterator::SetMark( void)
|
||||||
{
|
{
|
||||||
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
if ( m_pGDB == nullptr || m_pCurrObj == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// imposto la marcatura
|
// imposto la marcatura
|
||||||
return m_pCurrObj->SetMark( nMark) ;
|
return m_pCurrObj->SetMark() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -103,7 +103,7 @@ class GdbIterator : public IGdbIterator
|
|||||||
bool RevertStatus( void) override ;
|
bool RevertStatus( void) override ;
|
||||||
bool GetStatus( int& nStat) const override ;
|
bool GetStatus( int& nStat) const override ;
|
||||||
bool GetCalcStatus( int& nStat) const override ;
|
bool GetCalcStatus( int& nStat) const override ;
|
||||||
bool SetMark( int nMark = GDB_MK_ON) override ;
|
bool SetMark( void) override ;
|
||||||
bool ResetMark( void) override ;
|
bool ResetMark( void) override ;
|
||||||
bool GetMark( int& nMark) const override ;
|
bool GetMark( int& nMark) const override ;
|
||||||
bool GetCalcMark( int& nMark) const override ;
|
bool GetCalcMark( int& nMark) const override ;
|
||||||
|
|||||||
+4
-4
@@ -612,14 +612,14 @@ GdbObj::GetCalcStatus( int& nStat, int nLev) const
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
GdbObj::SetMark( int nMark)
|
GdbObj::SetMark( void)
|
||||||
{
|
{
|
||||||
// verifico esistenza (con eventuale creazione) degli attributi
|
// verifico esistenza (con eventuale creazione) degli attributi
|
||||||
if ( GetSafeAttribs() == nullptr)
|
if ( GetSafeAttribs() == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// assegno la marcatura
|
// assegno la marcatura
|
||||||
m_pAttribs->SetMark( nMark) ;
|
m_pAttribs->SetMark() ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,8 +659,8 @@ GdbObj::GetCalcMark( int& nMark) const
|
|||||||
nObjMark = m_pAttribs->GetMark() ;
|
nObjMark = m_pAttribs->GetMark() ;
|
||||||
|
|
||||||
// se la marcatura è ON, non ho bisogno di sapere altro
|
// se la marcatura è ON, non ho bisogno di sapere altro
|
||||||
if ( nObjMark == GDB_MK_ON || nObjMark == GDB_MK_ON_2) {
|
if ( nObjMark == GDB_MK_ON) {
|
||||||
nMark = nObjMark ;
|
nMark = GDB_MK_ON ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class GdbObj
|
|||||||
bool IsSelected( void) const ;
|
bool IsSelected( void) const ;
|
||||||
bool GetStatus( int& nStat) const ;
|
bool GetStatus( int& nStat) const ;
|
||||||
bool GetCalcStatus( int& nStat, int nLev = 0) const ;
|
bool GetCalcStatus( int& nStat, int nLev = 0) const ;
|
||||||
bool SetMark( int nMark) ;
|
bool SetMark( void) ;
|
||||||
bool ResetMark( void) ;
|
bool ResetMark( void) ;
|
||||||
bool GetMark( int& nMark) const ;
|
bool GetMark( int& nMark) const ;
|
||||||
bool GetCalcMark( int& nMark) const ;
|
bool GetCalcMark( int& nMark) const ;
|
||||||
|
|||||||
+2
-2
@@ -2310,7 +2310,7 @@ GeomDB::GetCalcStatus( int nId, int& nStat) const
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
GeomDB::SetMark( int nId, int nMark)
|
GeomDB::SetMark( int nId)
|
||||||
{
|
{
|
||||||
// recupero l'oggetto
|
// recupero l'oggetto
|
||||||
GdbObj* pGdbObj = GetGdbObj( nId) ;
|
GdbObj* pGdbObj = GetGdbObj( nId) ;
|
||||||
@@ -2318,7 +2318,7 @@ GeomDB::SetMark( int nId, int nMark)
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// imposto la marcatura
|
// imposto la marcatura
|
||||||
return pGdbObj->SetMark( nMark) ;
|
return pGdbObj->SetMark() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class GeomDB : public IGeomDB
|
|||||||
bool RevertStatus( int nId) override ;
|
bool RevertStatus( int nId) override ;
|
||||||
bool GetStatus( int nId, int& nStat) const override ;
|
bool GetStatus( int nId, int& nStat) const override ;
|
||||||
bool GetCalcStatus( int nId, int& nStat) const override ;
|
bool GetCalcStatus( int nId, int& nStat) const override ;
|
||||||
bool SetMark( int nId, int nMark = GDB_MK_ON) override ;
|
bool SetMark( int nId) override ;
|
||||||
bool ResetMark( int nId) override ;
|
bool ResetMark( int nId) override ;
|
||||||
bool GetMark( int nId, int& nMark) const override ;
|
bool GetMark( int nId, int& nMark) const override ;
|
||||||
bool GetCalcMark( int nId, int& nMark) const override ;
|
bool GetCalcMark( int nId, int& nMark) const override ;
|
||||||
|
|||||||
+9
-9
@@ -116,7 +116,7 @@ HashGrid1d::~HashGrid1d( void)
|
|||||||
{
|
{
|
||||||
Clear() ;
|
Clear() ;
|
||||||
|
|
||||||
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_CellCount ; ++ pCell) {
|
for ( Cell* pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
|
||||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||||
delete[] pCell->m_neighborOffset ;
|
delete[] pCell->m_neighborOffset ;
|
||||||
}
|
}
|
||||||
@@ -396,10 +396,8 @@ HashGrid1d::Enlarge( void)
|
|||||||
for ( auto pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
|
for ( auto pCell = m_cell ; pCell < m_cell + m_CellCount ; ++ pCell) {
|
||||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||||
delete[] pCell->m_neighborOffset ;
|
delete[] pCell->m_neighborOffset ;
|
||||||
pCell->m_neighborOffset = nullptr ;
|
|
||||||
}
|
}
|
||||||
delete[] m_cell ;
|
delete[] m_cell ;
|
||||||
m_cell = nullptr ;
|
|
||||||
|
|
||||||
// ... the number of cells is doubled in each coordinate direction, ...
|
// ... the number of cells is doubled in each coordinate direction, ...
|
||||||
m_CellCount *= 2 ;
|
m_CellCount *= 2 ;
|
||||||
@@ -643,15 +641,17 @@ HashGrids1d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
|
|||||||
void
|
void
|
||||||
HashGrids1d::Clear( void)
|
HashGrids1d::Clear( void)
|
||||||
{
|
{
|
||||||
m_ObjsList.clear() ;
|
for ( auto pGrid : m_GridList) {
|
||||||
m_ObjsMap.clear() ;
|
|
||||||
m_objsToAdd.clear() ;
|
|
||||||
m_nonGridObjs.clear() ;
|
|
||||||
for ( auto pGrid : m_GridList)
|
|
||||||
delete pGrid ;
|
delete pGrid ;
|
||||||
|
}
|
||||||
m_GridList.clear() ;
|
m_GridList.clear() ;
|
||||||
m_bActivate = true ;
|
|
||||||
m_bGridActive = false ;
|
m_bGridActive = false ;
|
||||||
|
|
||||||
|
m_nonGridObjs.clear() ;
|
||||||
|
|
||||||
|
m_objsToAdd.clear() ;
|
||||||
|
|
||||||
m_b3Objs.Reset() ;
|
m_b3Objs.Reset() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -125,7 +125,7 @@ HashGrid2d::~HashGrid2d( void)
|
|||||||
{
|
{
|
||||||
Clear() ;
|
Clear() ;
|
||||||
|
|
||||||
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_xyCellCount ; ++ pCell) {
|
for ( Cell* pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
|
||||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||||
delete[] pCell->m_neighborOffset ;
|
delete[] pCell->m_neighborOffset ;
|
||||||
}
|
}
|
||||||
@@ -445,10 +445,8 @@ HashGrid2d::Enlarge( void)
|
|||||||
for ( auto pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
|
for ( auto pCell = m_cell ; pCell < m_cell + m_xyCellCount ; ++ pCell) {
|
||||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||||
delete[] pCell->m_neighborOffset ;
|
delete[] pCell->m_neighborOffset ;
|
||||||
pCell->m_neighborOffset = nullptr ;
|
|
||||||
}
|
}
|
||||||
delete[] m_cell ;
|
delete[] m_cell ;
|
||||||
m_cell = nullptr ;
|
|
||||||
|
|
||||||
// ... the number of cells is doubled in each coordinate direction, ...
|
// ... the number of cells is doubled in each coordinate direction, ...
|
||||||
m_xCellCount *= 2 ;
|
m_xCellCount *= 2 ;
|
||||||
@@ -697,15 +695,17 @@ HashGrids2d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
|
|||||||
void
|
void
|
||||||
HashGrids2d::Clear( void)
|
HashGrids2d::Clear( void)
|
||||||
{
|
{
|
||||||
m_ObjsList.clear() ;
|
for ( auto pGrid : m_GridList) {
|
||||||
m_ObjsMap.clear() ;
|
|
||||||
m_objsToAdd.clear() ;
|
|
||||||
m_nonGridObjs.clear() ;
|
|
||||||
for ( auto pGrid : m_GridList)
|
|
||||||
delete pGrid ;
|
delete pGrid ;
|
||||||
|
}
|
||||||
m_GridList.clear() ;
|
m_GridList.clear() ;
|
||||||
m_bActivate = true ;
|
|
||||||
m_bGridActive = false ;
|
m_bGridActive = false ;
|
||||||
|
|
||||||
|
m_nonGridObjs.clear() ;
|
||||||
|
|
||||||
|
m_objsToAdd.clear() ;
|
||||||
|
|
||||||
m_b3Objs.Reset() ;
|
m_b3Objs.Reset() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -132,7 +132,7 @@ HashGrid3d::~HashGrid3d( void)
|
|||||||
{
|
{
|
||||||
Clear() ;
|
Clear() ;
|
||||||
|
|
||||||
for ( Cell* pCell = m_cell ; pCell != nullptr && pCell < m_cell + m_xyzCellCount ; ++ pCell) {
|
for ( Cell* pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
|
||||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||||
delete[] pCell->m_neighborOffset ;
|
delete[] pCell->m_neighborOffset ;
|
||||||
}
|
}
|
||||||
@@ -486,10 +486,8 @@ HashGrid3d::Enlarge( void)
|
|||||||
for ( auto pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
|
for ( auto pCell = m_cell ; pCell < m_cell + m_xyzCellCount ; ++ pCell) {
|
||||||
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
if ( pCell->m_neighborOffset != m_stdNeighborOffset)
|
||||||
delete[] pCell->m_neighborOffset ;
|
delete[] pCell->m_neighborOffset ;
|
||||||
pCell->m_neighborOffset = nullptr ;
|
|
||||||
}
|
}
|
||||||
delete[] m_cell ;
|
delete[] m_cell ;
|
||||||
m_cell = nullptr ;
|
|
||||||
|
|
||||||
// ... the number of cells is doubled in each coordinate direction, ...
|
// ... the number of cells is doubled in each coordinate direction, ...
|
||||||
m_xCellCount *= 2 ;
|
m_xCellCount *= 2 ;
|
||||||
@@ -741,15 +739,17 @@ HashGrids3d::Find( const BBox3d& b3Test, INTVECTOR& vnIds) const
|
|||||||
void
|
void
|
||||||
HashGrids3d::Clear( void)
|
HashGrids3d::Clear( void)
|
||||||
{
|
{
|
||||||
m_ObjsList.clear() ;
|
for ( auto pGrid : m_GridList) {
|
||||||
m_ObjsMap.clear() ;
|
|
||||||
m_objsToAdd.clear() ;
|
|
||||||
m_nonGridObjs.clear() ;
|
|
||||||
for ( auto pGrid : m_GridList)
|
|
||||||
delete pGrid ;
|
delete pGrid ;
|
||||||
|
}
|
||||||
m_GridList.clear() ;
|
m_GridList.clear() ;
|
||||||
m_bActivate = true ;
|
|
||||||
m_bGridActive = false ;
|
m_bGridActive = false ;
|
||||||
|
|
||||||
|
m_nonGridObjs.clear() ;
|
||||||
|
|
||||||
|
m_objsToAdd.clear() ;
|
||||||
|
|
||||||
m_b3Objs.Reset() ;
|
m_b3Objs.Reset() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -17,9 +17,6 @@
|
|||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static const double EPS_INTER_ARC = 0.1 * EPS_SMALL ;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
|
IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
|
||||||
{
|
{
|
||||||
@@ -63,15 +60,15 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
|
|||||||
vtDir /= dDist ;
|
vtDir /= dDist ;
|
||||||
|
|
||||||
// cerchi esterni -> nessuna intersezione
|
// cerchi esterni -> nessuna intersezione
|
||||||
if ( dDist > m_Arc1.GetRadius() + m_Arc2.GetRadius() + EPS_INTER_ARC)
|
if ( dDist > m_Arc1.GetRadius() + m_Arc2.GetRadius() + EPS_SMALL)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
// cerchi interni -> nessuna intersezione
|
// cerchi interni -> nessuna intersezione
|
||||||
if ( dDist < abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) - EPS_INTER_ARC)
|
if ( dDist < abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) - EPS_SMALL)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
// cerchi coincidenti -> sovrapposizioni e/o intersezioni agli estremi
|
// cerchi coincidenti -> sovrapposizioni e/o intersezioni agli estremi
|
||||||
if ( dDist < EPS_SMALL && abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) < EPS_INTER_ARC) {
|
if ( dDist < EPS_SMALL && abs( m_Arc1.GetRadius() - m_Arc2.GetRadius()) < EPS_SMALL) {
|
||||||
// coefficiente da parametro dell'arco 1 a lunghezza
|
// coefficiente da parametro dell'arco 1 a lunghezza
|
||||||
double dU2L = abs( m_Arc1.GetAngCenter()) * DEGTORAD * m_Arc1.GetRadius() ;
|
double dU2L = abs( m_Arc1.GetAngCenter()) * DEGTORAD * m_Arc1.GetRadius() ;
|
||||||
// determino se sono equiversi o controversi
|
// determino se sono equiversi o controversi
|
||||||
@@ -239,7 +236,7 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
|
|||||||
double dSqH = m_Arc1.GetRadius() * m_Arc1.GetRadius() - dA * dA ;
|
double dSqH = m_Arc1.GetRadius() * m_Arc1.GetRadius() - dA * dA ;
|
||||||
|
|
||||||
// cerchi tangenti esterni -> una intersezione
|
// cerchi tangenti esterni -> una intersezione
|
||||||
if ( abs( dDist - ( m_Arc1.GetRadius() + m_Arc2.GetRadius())) < EPS_INTER_ARC) {
|
if ( abs( dDist - ( m_Arc1.GetRadius() + m_Arc2.GetRadius())) < EPS_SMALL) {
|
||||||
// tolleranza tangenziale sull'intersezione
|
// tolleranza tangenziale sull'intersezione
|
||||||
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
|
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
|
||||||
// calcolo il punto di intersezione
|
// calcolo il punto di intersezione
|
||||||
@@ -361,7 +358,7 @@ IntersArcArc::IntersArcArc( const CurveArc& Arc1, const CurveArc& Arc2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cerchi tangenti interni -> una intersezione
|
// cerchi tangenti interni -> una intersezione
|
||||||
if ( abs( dDist - abs( m_Arc1.GetRadius() - m_Arc2.GetRadius())) < EPS_INTER_ARC) {
|
if ( abs( dDist - abs( m_Arc1.GetRadius() - m_Arc2.GetRadius())) < EPS_SMALL) {
|
||||||
// tolleranza tangenziale sull'intersezione
|
// tolleranza tangenziale sull'intersezione
|
||||||
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
|
double dTgTol = ( dSqH > SQ_EPS_SMALL ? sqrt( dSqH) : EPS_SMALL) ;
|
||||||
// determino quale dei due contiene l'altro
|
// determino quale dei due contiene l'altro
|
||||||
|
|||||||
@@ -78,8 +78,6 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB,
|
|||||||
case CRV_COMPO :
|
case CRV_COMPO :
|
||||||
LineCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
|
LineCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
|
||||||
break ;
|
break ;
|
||||||
default :
|
|
||||||
break ;
|
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case CRV_ARC :
|
case CRV_ARC :
|
||||||
@@ -93,8 +91,6 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB,
|
|||||||
case CRV_COMPO :
|
case CRV_COMPO :
|
||||||
ArcCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
|
ArcCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
|
||||||
break ;
|
break ;
|
||||||
default :
|
|
||||||
break ;
|
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case CRV_COMPO :
|
case CRV_COMPO :
|
||||||
@@ -108,12 +104,8 @@ IntersCurveCurve::IntersCurveCurve( const ICurve& CurveA, const ICurve& CurveB,
|
|||||||
case CRV_COMPO :
|
case CRV_COMPO :
|
||||||
CrvCompoCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
|
CrvCompoCrvCompoCalculate( *pCalcCrv[0], *pCalcCrv[1]) ;
|
||||||
break ;
|
break ;
|
||||||
default :
|
|
||||||
break ;
|
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
default :
|
|
||||||
break ;
|
|
||||||
}
|
}
|
||||||
// per curve approssimate, sistemo...
|
// per curve approssimate, sistemo...
|
||||||
AdjustIntersParams( ( pCalcCrv[0] != m_pCurve[0]), ( pCalcCrv[1] != m_pCurve[1])) ;
|
AdjustIntersParams( ( pCalcCrv[0] != m_pCurve[0]), ( pCalcCrv[1] != m_pCurve[1])) ;
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "IntersLineCaps.h"
|
#include "IntersLineCaps.h"
|
||||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
#include "DistLineLine.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSphere.h"
|
#include "/EgtDev/Include/EGkIntersLineSphere.h"
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CurveLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSurfBez.h"
|
#include "/EgtDev/Include/EGkIntersLineSurfBez.h"
|
||||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
|
#include "CurveLine.h"
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ OrderInfoIntersLineSurfTm( ILSIVECTOR& vInfo)
|
|||||||
[]( const IntLinStmInfo& a, const IntLinStmInfo& b)
|
[]( const IntLinStmInfo& a, const IntLinStmInfo& b)
|
||||||
{ double dUa = ( ( a.nILTT == ILTT_SEGM || a.nILTT == ILTT_SEGM_ON_EDGE) ? ( a.dU + a.dU2) / 2 : a.dU) ;
|
{ 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 dUb = ( ( b.nILTT == ILTT_SEGM || b.nILTT == ILTT_SEGM_ON_EDGE) ? ( b.dU + b.dU2) / 2 : b.dU) ;
|
||||||
if ( abs( dUa - dUb) < EPS_SMALL)
|
|
||||||
return ( a.dCosDN < b.dCosDN) ;
|
|
||||||
return ( dUa < dUb) ; }) ;
|
return ( dUa < dUb) ; }) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -17,8 +17,8 @@
|
|||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
#include "IntersLineLine.h"
|
#include "IntersLineLine.h"
|
||||||
#include "IntersLineTria.h"
|
#include "IntersLineTria.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
#include "DistLineLine.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "ProjPlane.h"
|
#include "ProjPlane.h"
|
||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h"
|
#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h"
|
||||||
#include "/EgtDev/Include/EGkIntersPlaneTria.h"
|
#include "/EgtDev/Include/EGkIntersPlaneTria.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "IntersLineTria.h"
|
#include "IntersLineTria.h"
|
||||||
#include "DllMain.h"
|
#include "DllMain.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h"
|
#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h"
|
||||||
#include "/EgtDev/Include/EGkIntersTriaTria.h"
|
#include "/EgtDev/Include/EGkIntersTriaTria.h"
|
||||||
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CreateCurveAux.h"
|
#include "CreateCurveAux.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h"
|
#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h"
|
||||||
#include "/EgtDev/Include/EGkLinePntTgCurve.h"
|
#include "/EgtDev/Include/EGkLinePntTgCurve.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CreateCurveAux.h"
|
#include "CreateCurveAux.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/EGkLineTgTwoCurves.h"
|
#include "/EgtDev/Include/EGkLineTgTwoCurves.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -2,7 +2,7 @@
|
|||||||
// EgalTech 2013-2013
|
// EgalTech 2013-2013
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : OffsetAux.cpp Data : 23.11.23 Versione : 2.5k5
|
// File : OffsetAux.cpp Data : 23.11.23 Versione : 2.5k5
|
||||||
// Contenuto : Implementazione di alcune funzioni di utilità per gli offset delle curve.
|
// Contenuto : Implementazione di alcune funzioni di utilità per gli offset delle curve.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -25,7 +25,11 @@ IdentifyFillets( ICurveComposite* pCrvCo, double dDist)
|
|||||||
{
|
{
|
||||||
// identifico le sottocurve di tipo fillet e assegno loro temp param 1.0 per riconoscerle nella funzione AdjustCurveFillets
|
// identifico le sottocurve di tipo fillet e assegno loro temp param 1.0 per riconoscerle nella funzione AdjustCurveFillets
|
||||||
for ( int i = 0 ; i < pCrvCo->GetCurveCount() ; i ++) {
|
for ( int i = 0 ; i < pCrvCo->GetCurveCount() ; i ++) {
|
||||||
if ( IsFillet( pCrvCo->GetCurve( i), dDist))
|
// recupero la curva
|
||||||
|
PtrOwner<ICurve> pCrv( pCrvCo->GetCurve(i)->Clone()) ;
|
||||||
|
if ( IsNull( pCrv))
|
||||||
|
return false ;
|
||||||
|
if ( IsFillet( pCrv, dDist))
|
||||||
pCrvCo->SetCurveTempParam( i, 1.0) ;
|
pCrvCo->SetCurveTempParam( i, 1.0) ;
|
||||||
else
|
else
|
||||||
pCrvCo->SetCurveTempParam( i, 0.0) ;
|
pCrvCo->SetCurveTempParam( i, 0.0) ;
|
||||||
@@ -35,14 +39,12 @@ IdentifyFillets( ICurveComposite* pCrvCo, double dDist)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
IsFillet( const ICurve* pCrv, double dDist)
|
IsFillet( ICurve* pCrv, double dDist)
|
||||||
{
|
{
|
||||||
if ( pCrv == nullptr)
|
|
||||||
return false ;
|
|
||||||
// deve essere un arco
|
// deve essere un arco
|
||||||
if ( pCrv->GetType() != CRV_ARC)
|
if ( pCrv->GetType() != CRV_ARC)
|
||||||
return false ;
|
return false ;
|
||||||
const CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
CurveArc* pArc = GetBasicCurveArc( pCrv) ;
|
||||||
// deve avere raggio uguale alla distanza di offset
|
// deve avere raggio uguale alla distanza di offset
|
||||||
if ( abs( pArc->GetRadius() - abs( dDist)) > EPS_SMALL)
|
if ( abs( pArc->GetRadius() - abs( dDist)) > EPS_SMALL)
|
||||||
return false ;
|
return false ;
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
// EgalTech 2013-2013
|
// EgalTech 2013-2013
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : OffsetAux.h Data : 23.11.23 Versione : 2.5k5
|
// File : OffsetAux.h Data : 23.11.23 Versione : 2.5k5
|
||||||
// Contenuto : Dichiarazione di alcune funzioni di utilità per gli offset delle curve.
|
// Contenuto : Dichiarazione di alcune funzioni di utilità per gli offset delle curve.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -16,6 +16,6 @@
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool IdentifyFillets( ICurveComposite* pCrvCo, double dDist) ;
|
bool IdentifyFillets( ICurveComposite* pCrvCo, double dDist) ;
|
||||||
bool IsFillet( const ICurve* pCrv, double dDist) ;
|
bool IsFillet( ICurve* pCrv, double dDist) ;
|
||||||
bool AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType) ;
|
bool AdjustCurveFillets( ICurveComposite* pCrvCo, double dDist, int nType) ;
|
||||||
bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
|
bool ModifyFillet( ICurve* pCrv, double dDist, int nType, ICurveComposite& ccAux) ;
|
||||||
|
|||||||
+23
-29
@@ -74,7 +74,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
// verifico che la curva esista
|
// verifico che la curva esista
|
||||||
if ( pCrv == nullptr)
|
if ( pCrv == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
// verifico se la curva è un segmento di retta
|
// verifico se la curva è un segmento di retta
|
||||||
bool bIsLine = false ;
|
bool bIsLine = false ;
|
||||||
const CurveLine* pLine = GetBasicCurveLine( pCrv) ;
|
const CurveLine* pLine = GetBasicCurveLine( pCrv) ;
|
||||||
if ( pLine != nullptr)
|
if ( pLine != nullptr)
|
||||||
@@ -85,7 +85,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
if ( pCompo != nullptr && pCompo->IsALine( m_dLinTol, ptStart, ptEnd))
|
if ( pCompo != nullptr && pCompo->IsALine( m_dLinTol, ptStart, ptEnd))
|
||||||
bIsLine = true ;
|
bIsLine = true ;
|
||||||
}
|
}
|
||||||
// verifico che la curva sia piana (per le linee è comunque sempre vero)
|
// verifico che la curva sia piana (per le linee è comunque sempre vero)
|
||||||
Plane3d plPlane ;
|
Plane3d plPlane ;
|
||||||
if ( ! pCrv->IsFlat( plPlane, bIsLine, 10 * EPS_SMALL) && ! bIsLine)
|
if ( ! pCrv->IsFlat( plPlane, bIsLine, 10 * EPS_SMALL) && ! bIsLine)
|
||||||
return false ;
|
return false ;
|
||||||
@@ -167,7 +167,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
// -------------------- OFFSET STANDARD ---------------------------------
|
// -------------------- OFFSET STANDARD ---------------------------------
|
||||||
if ( ! USE_VORONOI) {
|
if ( ! USE_VORONOI) {
|
||||||
|
|
||||||
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+)
|
// verifico che la curva sia fatta solo da rette e archi che giacciono nel piano XY (VtExtr è ora Z+)
|
||||||
if ( ! ccCopy.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, ANG_TOL_STD_DEG))
|
if ( ! ccCopy.ArcsBezierCurvesToArcsPerpExtr( m_dLinTol, ANG_TOL_STD_DEG))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
@@ -187,11 +187,11 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
if ( ! ccCopy.MergeCurves( m_dLinTol, ANG_TOL_STD_DEG, bClosed, true))
|
if ( ! ccCopy.MergeCurves( m_dLinTol, ANG_TOL_STD_DEG, bClosed, true))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// verifico se il punto iniziale è stato modificato
|
// verifico se il punto iniziale è stato modificato
|
||||||
Point3d ptNewStart ; ccCopy.GetStartPoint( ptNewStart) ;
|
Point3d ptNewStart ; ccCopy.GetStartPoint( ptNewStart) ;
|
||||||
bChangeStart = ( ! AreSamePointApprox( ptNewStart, ptStart)) ;
|
bChangeStart = ( ! AreSamePointApprox( ptNewStart, ptStart)) ;
|
||||||
|
|
||||||
// calcolo le lunghezze delle diverse entità
|
// calcolo le lunghezze delle diverse entità
|
||||||
DBLVECTOR vLens ;
|
DBLVECTOR vLens ;
|
||||||
{
|
{
|
||||||
const ICurve* pCrv1 = ccCopy.GetFirstCurve() ;
|
const ICurve* pCrv1 = ccCopy.GetFirstCurve() ;
|
||||||
@@ -203,7 +203,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
pCrv1 = ccCopy.GetNextCurve() ;
|
pCrv1 = ccCopy.GetNextCurve() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// calcolo gli angoli tra le diverse entità
|
// calcolo gli angoli tra le diverse entità
|
||||||
DBLVECTOR vAngs ;
|
DBLVECTOR vAngs ;
|
||||||
{
|
{
|
||||||
vAngs.push_back( 0) ;
|
vAngs.push_back( 0) ;
|
||||||
@@ -230,7 +230,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
vAngs.push_back( 0) ;
|
vAngs.push_back( 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// primo passo : estraggo entità dalla copia, loro offset elementare e aggiunta raccordi esterni (sempre fillet)
|
// primo passo : estraggo entità dalla copia, loro offset elementare e aggiunta raccordi esterni (sempre fillet)
|
||||||
CurveComposite ccCopy2 ;
|
CurveComposite ccCopy2 ;
|
||||||
if ( ! ccCopy2.CopyFrom( &ccCopy))
|
if ( ! ccCopy2.CopyFrom( &ccCopy))
|
||||||
return false ;
|
return false ;
|
||||||
@@ -285,9 +285,9 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
|
|
||||||
// se originale chiuso, devo confrontare anche ultima e prima curva
|
// se originale chiuso, devo confrontare anche ultima e prima curva
|
||||||
if ( bClosed && m_CrvLst.size() >= 2) {
|
if ( bClosed && m_CrvLst.size() >= 2) {
|
||||||
// la curva precedente è l'ultima dell'offset
|
// la curva precedente è l'ultima dell'offset
|
||||||
ICurve* pCrv1 = m_CrvLst.back() ;
|
ICurve* pCrv1 = m_CrvLst.back() ;
|
||||||
// la curva successiva ora è la prima dell'offset
|
// la curva successiva ora è la prima dell'offset
|
||||||
ICurve* pCrv2 = m_CrvLst.front() ;
|
ICurve* pCrv2 = m_CrvLst.front() ;
|
||||||
// verifico relazione con la curva precedente e aggiungo eventuali curve intermedie
|
// verifico relazione con la curva precedente e aggiungo eventuali curve intermedie
|
||||||
CurveComposite ccTemp ;
|
CurveComposite ccTemp ;
|
||||||
@@ -334,7 +334,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
bool bNextInt = NextIsLine( iIter, m_CrvLst, bClosed) &&
|
bool bNextInt = NextIsLine( iIter, m_CrvLst, bClosed) &&
|
||||||
NextIsLonger( nInd1, vLens, bClosed) &&
|
NextIsLonger( nInd1, vLens, bClosed) &&
|
||||||
( ( dDist < 0 && vAngs[nInd1] > 0) || ( dDist > 0 && vAngs[nInd1] < 0)) ;
|
( ( dDist < 0 && vAngs[nInd1] > 0) || ( dDist > 0 && vAngs[nInd1] < 0)) ;
|
||||||
// calcolo la massima estensione di offset (Voronoi con entità adiacenti)
|
// calcolo la massima estensione di offset (Voronoi con entità adiacenti)
|
||||||
double dMaxDist = INFINITO ;
|
double dMaxDist = INFINITO ;
|
||||||
if ( bPrevInt && bNextInt) {
|
if ( bPrevInt && bNextInt) {
|
||||||
double dTgA = tan( 0.5 * ( ANG_STRAIGHT - abs( vAngs[nInd1-1])) * DEGTORAD) ;
|
double dTgA = tan( 0.5 * ( ANG_STRAIGHT - abs( vAngs[nInd1-1])) * DEGTORAD) ;
|
||||||
@@ -502,7 +502,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
|
|
||||||
// sesto passo : se curva aperta, elimino i tratti che stanno nella circonferenza di offset dei punti estremi
|
// sesto passo : se curva aperta, elimino i tratti che stanno nella circonferenza di offset dei punti estremi
|
||||||
if ( ! bClosed) {
|
if ( ! bClosed) {
|
||||||
// ciconferenza sull'estremità iniziale
|
// ciconferenza sull'estremità iniziale
|
||||||
Point3d ptStart ; ccCopy.GetStartPoint( ptStart) ;
|
Point3d ptStart ; ccCopy.GetStartPoint( ptStart) ;
|
||||||
PtrOwner<CurveArc> pCircS( CreateBasicCurveArc()) ;
|
PtrOwner<CurveArc> pCircS( CreateBasicCurveArc()) ;
|
||||||
if ( IsNull( pCircS) || ! pCircS->Set( ptStart, Z_AX, abs( dDist)))
|
if ( IsNull( pCircS) || ! pCircS->Set( ptStart, Z_AX, abs( dDist)))
|
||||||
@@ -551,7 +551,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
// passo alla successiva
|
// passo alla successiva
|
||||||
++ iIter ;
|
++ iIter ;
|
||||||
}
|
}
|
||||||
// circonferenza sull'estremità finale
|
// circonferenza sull'estremità finale
|
||||||
Point3d ptEnd ; ccCopy.GetEndPoint( ptEnd) ;
|
Point3d ptEnd ; ccCopy.GetEndPoint( ptEnd) ;
|
||||||
PtrOwner<CurveArc> pCircE( CreateBasicCurveArc()) ;
|
PtrOwner<CurveArc> pCircE( CreateBasicCurveArc()) ;
|
||||||
if ( IsNull( pCircE) || ! pCircE->Set( ptEnd, Z_AX, abs( dDist)))
|
if ( IsNull( pCircE) || ! pCircE->Set( ptEnd, Z_AX, abs( dDist)))
|
||||||
@@ -697,12 +697,6 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType)
|
|||||||
// calcolo offset con Voronoi
|
// calcolo offset con Voronoi
|
||||||
ICURVEPOVECTOR vOffs ;
|
ICURVEPOVECTOR vOffs ;
|
||||||
voronoiObj->CalcOffset( vOffs, dDist, nType) ;
|
voronoiObj->CalcOffset( vOffs, dDist, nType) ;
|
||||||
if ( vOffs.size() == 0) {
|
|
||||||
// se non ho ottenuto offset ritento con valore leggermente diverso per le tolleranze di vroni
|
|
||||||
double dCorr = ( dDist > 0 ? - VRONI_OFFS_TOL : VRONI_OFFS_TOL) ;
|
|
||||||
voronoiObj->CalcOffset( vOffs, dDist + dCorr, nType) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int i = 0 ; i < ( int)vOffs.size() ; i ++)
|
for ( int i = 0 ; i < ( int)vOffs.size() ; i ++)
|
||||||
m_CrvLst.emplace_back( Release( vOffs[i])) ;
|
m_CrvLst.emplace_back( Release( vOffs[i])) ;
|
||||||
|
|
||||||
@@ -823,7 +817,7 @@ PreviousIsLine( ICURVEPLIST::const_iterator iIter, const ICURVEPLIST& CrvLst, bo
|
|||||||
// se non esiste e curva chiusa prendo l'ultimo
|
// se non esiste e curva chiusa prendo l'ultimo
|
||||||
if ( iPrev == CrvLst.end() && bClosed)
|
if ( iPrev == CrvLst.end() && bClosed)
|
||||||
-- iPrev ;
|
-- iPrev ;
|
||||||
// se non esiste o non è una linea, test fallito
|
// se non esiste o non è una linea, test fallito
|
||||||
if ( iPrev == CrvLst.end() || (*iPrev)->GetType() != CRV_LINE )
|
if ( iPrev == CrvLst.end() || (*iPrev)->GetType() != CRV_LINE )
|
||||||
return false ;
|
return false ;
|
||||||
// test superato
|
// test superato
|
||||||
@@ -836,7 +830,7 @@ PreviousIsLonger( int nInd1, const DBLVECTOR& vLens, bool bClosed)
|
|||||||
{
|
{
|
||||||
// massimo indice nel vettore
|
// massimo indice nel vettore
|
||||||
int nMax = int( vLens.size()) - 1 ;
|
int nMax = int( vLens.size()) - 1 ;
|
||||||
// verifico validità indice (questo indice è incrementato di 1)
|
// verifico validità indice (questo indice è incrementato di 1)
|
||||||
if ( nInd1 < 1 || nInd1 > nMax + 1)
|
if ( nInd1 < 1 || nInd1 > nMax + 1)
|
||||||
return false ;
|
return false ;
|
||||||
// indice del precedente nel vettore di lunghezze
|
// indice del precedente nel vettore di lunghezze
|
||||||
@@ -860,7 +854,7 @@ NextIsLine( ICURVEPLIST::const_iterator iIter, const ICURVEPLIST& CrvLst, bool b
|
|||||||
// se non esiste e curva chiusa prendo il primo
|
// se non esiste e curva chiusa prendo il primo
|
||||||
if ( iNext == CrvLst.end() && bClosed)
|
if ( iNext == CrvLst.end() && bClosed)
|
||||||
iNext = CrvLst.begin() ;
|
iNext = CrvLst.begin() ;
|
||||||
// se non esiste o non è una linea, test fallito
|
// se non esiste o non è una linea, test fallito
|
||||||
if ( iNext == CrvLst.end() || (*iNext)->GetType() != CRV_LINE )
|
if ( iNext == CrvLst.end() || (*iNext)->GetType() != CRV_LINE )
|
||||||
return false ;
|
return false ;
|
||||||
// test superato
|
// test superato
|
||||||
@@ -873,7 +867,7 @@ NextIsLonger( int nInd1, const DBLVECTOR& vLens, bool bClosed)
|
|||||||
{
|
{
|
||||||
// massimo indice nel vettore
|
// massimo indice nel vettore
|
||||||
int nMax = int( vLens.size()) - 1 ;
|
int nMax = int( vLens.size()) - 1 ;
|
||||||
// verifico validità indice (questo indice è incrementato di 1)
|
// verifico validità indice (questo indice è incrementato di 1)
|
||||||
if ( nInd1 < 1 || nInd1 > nMax + 1)
|
if ( nInd1 < 1 || nInd1 > nMax + 1)
|
||||||
return false ;
|
return false ;
|
||||||
// indice del successivo nel vettore di lunghezze
|
// indice del successivo nel vettore di lunghezze
|
||||||
@@ -952,7 +946,7 @@ VerifyAndAdjustSamePoint( ICurve* pCrv1, ICurve* pCrv2, int& nRes)
|
|||||||
nRes = 4 ;
|
nRes = 4 ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
// se coincidono esattamente, va bene così
|
// se coincidono esattamente, va bene così
|
||||||
if ( AreSamePointExact( ptP1, ptP2)) {
|
if ( AreSamePointExact( ptP1, ptP2)) {
|
||||||
nRes = 0 ;
|
nRes = 0 ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -982,7 +976,7 @@ VerifyAndAdjustInternalAngle( ICurve* pCrv1, ICurve* pCrv2, int& nRes)
|
|||||||
IntersCurveCurve intCC( *pCrv1, *pCrv2) ;
|
IntersCurveCurve intCC( *pCrv1, *pCrv2) ;
|
||||||
if ( intCC.GetIntersCount() == 0)
|
if ( intCC.GetIntersCount() == 0)
|
||||||
return false ;
|
return false ;
|
||||||
// prendo l'intersezione più vicina al punto medio tra gli estremi delle curve
|
// prendo l'intersezione più vicina al punto medio tra gli estremi delle curve
|
||||||
Point3d ptP1, ptP2 ;
|
Point3d ptP1, ptP2 ;
|
||||||
if ( ! pCrv1->GetEndPoint( ptP1) || ! pCrv2->GetStartPoint( ptP2))
|
if ( ! pCrv1->GetEndPoint( ptP1) || ! pCrv2->GetStartPoint( ptP2))
|
||||||
return false ;
|
return false ;
|
||||||
@@ -1030,7 +1024,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
|
|||||||
vtDir2.Invert() ;
|
vtDir2.Invert() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifico sia angolo esterno (accetto se entità quasi esattamente sovrapposte)
|
// verifico sia angolo esterno (accetto se entità quasi esattamente sovrapposte)
|
||||||
if ( abs( dAngDeg) < ( ANG_STRAIGHT - 10 * EPS_ANG_ZERO) &&
|
if ( abs( dAngDeg) < ( ANG_STRAIGHT - 10 * EPS_ANG_ZERO) &&
|
||||||
( ( dDist < 0 && dAngDeg > 0) ||
|
( ( dDist < 0 && dAngDeg > 0) ||
|
||||||
( dDist > 0 && dAngDeg < 0)))
|
( dDist > 0 && dAngDeg < 0)))
|
||||||
@@ -1072,7 +1066,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
|
|||||||
return false ;
|
return false ;
|
||||||
ptP1a = ptP1 + vtDir1 * dLen ;
|
ptP1a = ptP1 + vtDir1 * dLen ;
|
||||||
ptP2a = ptP2 - vtDir2 * dLen ;
|
ptP2a = ptP2 - vtDir2 * dLen ;
|
||||||
// se prima c'è linea posso allungarla
|
// se prima c'è linea posso allungarla
|
||||||
if ( pCrv1->GetType() == CRV_LINE)
|
if ( pCrv1->GetType() == CRV_LINE)
|
||||||
pCrv1->ModifyEnd( ptP1a) ;
|
pCrv1->ModifyEnd( ptP1a) ;
|
||||||
// altrimenti, devo aggiungere una nuova linea
|
// altrimenti, devo aggiungere una nuova linea
|
||||||
@@ -1091,7 +1085,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
|
|||||||
if ( ! ccAux.AddCurve( Release( pCrv)))
|
if ( ! ccAux.AddCurve( Release( pCrv)))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// se dopo c'è linea posso allungarla
|
// se dopo c'è linea posso allungarla
|
||||||
if ( pCrv2->GetType() == CRV_LINE)
|
if ( pCrv2->GetType() == CRV_LINE)
|
||||||
pCrv2->ModifyStart( ptP2a) ;
|
pCrv2->ModifyStart( ptP2a) ;
|
||||||
// altrimenti, devo aggiungere una nuova linea
|
// altrimenti, devo aggiungere una nuova linea
|
||||||
@@ -1114,7 +1108,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
|
|||||||
if ( ! pCrv1->GetEndPoint( ptP1) || ! pCrv2->GetStartPoint( ptP2))
|
if ( ! pCrv1->GetEndPoint( ptP1) || ! pCrv2->GetStartPoint( ptP2))
|
||||||
return false ;
|
return false ;
|
||||||
ptPc = ptP1 + vtDir1 * dLen ;
|
ptPc = ptP1 + vtDir1 * dLen ;
|
||||||
// se prima c'è linea o angolo molto piccolo posso allungarla
|
// se prima c'è linea o angolo molto piccolo posso allungarla
|
||||||
if ( ( pCrv1->GetType() == CRV_LINE) || bAngSmall)
|
if ( ( pCrv1->GetType() == CRV_LINE) || bAngSmall)
|
||||||
pCrv1->ModifyEnd( ptPc) ;
|
pCrv1->ModifyEnd( ptPc) ;
|
||||||
// altrimenti, devo aggiungere una nuova linea
|
// altrimenti, devo aggiungere una nuova linea
|
||||||
@@ -1125,7 +1119,7 @@ VerifyAndAdjustExternalAngle( ICurve* pCrv1, ICurve* pCrv2, double dAngDeg, doub
|
|||||||
if ( ! ccAux.AddCurve( Release( pCrv)))
|
if ( ! ccAux.AddCurve( Release( pCrv)))
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// se dopo c'è linea o angolo molto piccolo posso allungarla
|
// se dopo c'è linea o angolo molto piccolo posso allungarla
|
||||||
if ( ( pCrv2->GetType() == CRV_LINE) || bAngSmall)
|
if ( ( pCrv2->GetType() == CRV_LINE) || bAngSmall)
|
||||||
pCrv2->ModifyStart( ptPc) ;
|
pCrv2->ModifyStart( ptPc) ;
|
||||||
// altrimenti, devo aggiungere una nuova linea
|
// altrimenti, devo aggiungere una nuova linea
|
||||||
|
|||||||
+1
-1
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "CurveArc.h"
|
#include "CurveArc.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkPolyArc.h"
|
#include "/EgtDev/Include/EGkPolyArc.h"
|
||||||
#include "/EgtDev/Include/EGkFrame3d.h"
|
#include "/EgtDev/Include/EGkFrame3d.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
+51
-54
@@ -1,4 +1,4 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2013-2013
|
// EgalTech 2013-2013
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : PolyLine.cpp Data : 22.12.13 Versione : 1.4l3
|
// File : PolyLine.cpp Data : 22.12.13 Versione : 1.4l3
|
||||||
@@ -14,13 +14,13 @@
|
|||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "IntersLineLine.h"
|
#include "IntersLineLine.h"
|
||||||
#include "PolygonPlane.h"
|
#include "PolygonPlane.h"
|
||||||
#include "PointsPCA.h"
|
#include "PointsPCA.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ PolyLine::AddUPoint( double dPar, const Point3d& ptP, bool bEndOrStart)
|
|||||||
{
|
{
|
||||||
// se da aggiungere in coda
|
// se da aggiungere in coda
|
||||||
if ( bEndOrStart) {
|
if ( bEndOrStart) {
|
||||||
// se il punto è uguale all'ultimo (ignoro parametro), non lo inserisco ma ok
|
// se il punto è uguale all'ultimo (ignoro parametro), non lo inserisco ma ok
|
||||||
if ( m_lUPoints.size() > 0 && AreSamePointApprox( ptP, m_lUPoints.back().first)) {
|
if ( m_lUPoints.size() > 0 && AreSamePointApprox( ptP, m_lUPoints.back().first)) {
|
||||||
++ m_nRejected ;
|
++ m_nRejected ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -68,7 +68,7 @@ PolyLine::AddUPoint( double dPar, const Point3d& ptP, bool bEndOrStart)
|
|||||||
}
|
}
|
||||||
// altrimenti si aggiunge in testa
|
// altrimenti si aggiunge in testa
|
||||||
else {
|
else {
|
||||||
// se il punto è uguale al primo (ignoro parametro), non lo inserisco ma ok
|
// se il punto è uguale al primo (ignoro parametro), non lo inserisco ma ok
|
||||||
if ( m_lUPoints.size() > 0 && AreSamePointApprox( ptP, m_lUPoints.front().first)) {
|
if ( m_lUPoints.size() > 0 && AreSamePointApprox( ptP, m_lUPoints.front().first)) {
|
||||||
++ m_nRejected ;
|
++ m_nRejected ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -92,7 +92,7 @@ PolyLine::Close( void)
|
|||||||
// ci devono essere almeno 2 punti
|
// ci devono essere almeno 2 punti
|
||||||
if ( m_lUPoints.size() < 2)
|
if ( m_lUPoints.size() < 2)
|
||||||
return false ;
|
return false ;
|
||||||
// verifico non sia già chiuso
|
// verifico non sia già chiuso
|
||||||
if ( AreSamePointApprox( m_lUPoints.front().first, m_lUPoints.back().first))
|
if ( AreSamePointApprox( m_lUPoints.front().first, m_lUPoints.back().first))
|
||||||
return false ;
|
return false ;
|
||||||
// aggiungo un punto uguale al primo in coda
|
// aggiungo un punto uguale al primo in coda
|
||||||
@@ -219,7 +219,7 @@ PolyLine::ToLoc( const Frame3d& frRef)
|
|||||||
bool
|
bool
|
||||||
PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||||
{
|
{
|
||||||
// se i due riferimenti coincidono, non devo fare alcunché
|
// se i due riferimenti coincidono, non devo fare alcunché
|
||||||
if ( AreSameFrame( frOri, frDest))
|
if ( AreSameFrame( frOri, frDest))
|
||||||
return true ;
|
return true ;
|
||||||
// ciclo sui punti
|
// ciclo sui punti
|
||||||
@@ -233,7 +233,7 @@ PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
|||||||
bool
|
bool
|
||||||
PolyLine::Join( PolyLine& PL, double dOffsetPar)
|
PolyLine::Join( PolyLine& PL, double dOffsetPar)
|
||||||
{
|
{
|
||||||
// se l'altra polilinea non contiene alcunchè, esco con ok
|
// se l'altra polilinea non contiene alcunchè, esco con ok
|
||||||
if ( PL.m_lUPoints.size() == 0)
|
if ( PL.m_lUPoints.size() == 0)
|
||||||
return true ;
|
return true ;
|
||||||
// verifico che l'ultimo punto di questa polilinea coincida con il primo dell'altra
|
// verifico che l'ultimo punto di questa polilinea coincida con il primo dell'altra
|
||||||
@@ -385,7 +385,7 @@ PolyLine::GetPrevUPoint( double* pdPar, Point3d* pptP, bool bNotFirst) const
|
|||||||
bool
|
bool
|
||||||
PolyLine::GetCurrUPoint( double* pdPar, Point3d* pptP) const
|
PolyLine::GetCurrUPoint( double* pdPar, Point3d* pptP) const
|
||||||
{
|
{
|
||||||
// verifico validità punto corrente
|
// verifico validità punto corrente
|
||||||
if ( m_iter == m_lUPoints.end())
|
if ( m_iter == m_lUPoints.end())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ PolyLine::GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d*
|
|||||||
bool
|
bool
|
||||||
PolyLine::GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const
|
PolyLine::GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const
|
||||||
{
|
{
|
||||||
// parametro e punto iniziali (è il precedente finale)
|
// parametro e punto iniziali (è il precedente finale)
|
||||||
if ( m_iter == m_lUPoints.end())
|
if ( m_iter == m_lUPoints.end())
|
||||||
return false ;
|
return false ;
|
||||||
if ( pdIni != nullptr)
|
if ( pdIni != nullptr)
|
||||||
@@ -510,19 +510,19 @@ PolyLine::IsFlat( int& nRank, Point3d& ptCen, Vector3d& vtDir, double dToler) co
|
|||||||
ptsPCA.AddPoint( Media( ptP1, ptP2, 0.25), dLen / 2) ;
|
ptsPCA.AddPoint( Media( ptP1, ptP2, 0.25), dLen / 2) ;
|
||||||
ptsPCA.AddPoint( Media( ptP1, ptP2, 0.75), dLen / 2) ;
|
ptsPCA.AddPoint( Media( ptP1, ptP2, 0.75), dLen / 2) ;
|
||||||
}
|
}
|
||||||
// recupero il rango, ovvero la dimensionalità dell'insieme di punti
|
// recupero il rango, ovvero la dimensionalità dell'insieme di punti
|
||||||
nRank = ptsPCA.GetRank() ;
|
nRank = ptsPCA.GetRank() ;
|
||||||
// se dimensione nulla, o non ci sono punti o sono tutti praticamente coincidenti
|
// se dimensione nulla, o non ci sono punti o sono tutti praticamente coincidenti
|
||||||
if ( nRank == 0)
|
if ( nRank == 0)
|
||||||
return ptsPCA.GetCenter( ptCen) ;
|
return ptsPCA.GetCenter( ptCen) ;
|
||||||
// se dimensione 1, allora i punti sono distribuiti su una linea
|
// se dimensione 1, allora i punti sono distribuiti su una linea
|
||||||
if ( nRank == 1) {
|
if ( nRank == 1) {
|
||||||
// assegno il centro e la direzione della linea (il verso è indifferente)
|
// assegno il centro e la direzione della linea (il verso è indifferente)
|
||||||
ptsPCA.GetCenter( ptCen) ;
|
ptsPCA.GetCenter( ptCen) ;
|
||||||
ptsPCA.GetPrincipalComponent( 0, vtDir) ;
|
ptsPCA.GetPrincipalComponent( 0, vtDir) ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
// altrimenti dimensione 2 o 3, allora è determinato un piano principale, verifico se tutti i punti vi giacciono
|
// altrimenti dimensione 2 o 3, allora è determinato un piano principale, verifico se tutti i punti vi giacciono
|
||||||
// Center and normal vector
|
// Center and normal vector
|
||||||
ptsPCA.GetCenter( ptCen) ;
|
ptsPCA.GetCenter( ptCen) ;
|
||||||
Vector3d vtX, vtY ;
|
Vector3d vtX, vtY ;
|
||||||
@@ -530,9 +530,9 @@ PolyLine::IsFlat( int& nRank, Point3d& ptCen, Vector3d& vtDir, double dToler) co
|
|||||||
ptsPCA.GetPrincipalComponent( 1, vtY) ;
|
ptsPCA.GetPrincipalComponent( 1, vtY) ;
|
||||||
vtDir = vtX ^ vtY ;
|
vtDir = vtX ^ vtY ;
|
||||||
if ( ! vtDir.Normalize()) {
|
if ( ! vtDir.Normalize()) {
|
||||||
// riduco la dimensionalità a lineare
|
// riduco la dimensionalità a lineare
|
||||||
nRank = 1 ;
|
nRank = 1 ;
|
||||||
// assegno il centro e la direzione della linea (il verso è indifferente)
|
// assegno il centro e la direzione della linea (il verso è indifferente)
|
||||||
ptsPCA.GetCenter( ptCen) ;
|
ptsPCA.GetCenter( ptCen) ;
|
||||||
vtDir = vtX ;
|
vtDir = vtX ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -561,12 +561,12 @@ PolyLine::IsFlat( Plane3d& plPlane, double dToler) const
|
|||||||
plPlane.Reset() ;
|
plPlane.Reset() ;
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
// recupero dati sulla planarità della polilinea
|
// recupero dati sulla planarità della polilinea
|
||||||
int nRank ;
|
int nRank ;
|
||||||
Point3d ptCen ;
|
Point3d ptCen ;
|
||||||
Vector3d vtDir ;
|
Vector3d vtDir ;
|
||||||
bool bFlat = IsFlat( nRank, ptCen, vtDir, dToler) ;
|
bool bFlat = IsFlat( nRank, ptCen, vtDir, dToler) ;
|
||||||
// imposto il piano a seconda della dimensionalità
|
// imposto il piano a seconda della dimensionalità
|
||||||
switch ( nRank) {
|
switch ( nRank) {
|
||||||
case 0 : // punto
|
case 0 : // punto
|
||||||
plPlane.Set( ptCen, Z_AX) ;
|
plPlane.Set( ptCen, Z_AX) ;
|
||||||
@@ -587,29 +587,18 @@ PolyLine::IsClosedAndFlat( Plane3d& plPlane, double& dArea, double dToler) const
|
|||||||
// Test if closed
|
// Test if closed
|
||||||
if ( ! IsClosed())
|
if ( ! IsClosed())
|
||||||
return false ;
|
return false ;
|
||||||
|
// Compute a representative plane for the polygon
|
||||||
Point3d ptP ;
|
Point3d ptP ;
|
||||||
// Calcolo il centro (per minimizzare gli errori nelle successive operazioni)
|
|
||||||
Point3d ptCen = ORIG ;
|
|
||||||
int nCount = 0 ;
|
|
||||||
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) {
|
|
||||||
ptCen += ptP ;
|
|
||||||
++ nCount ;
|
|
||||||
}
|
|
||||||
ptCen /= nCount ;
|
|
||||||
Vector3d vtMove = ptCen - ORIG ;
|
|
||||||
// Compute a representative plane for the polygon (faccio il calcolo nel centro e poi traslo al contrario il piano)
|
|
||||||
PolygonPlane PolyPlane ;
|
PolygonPlane PolyPlane ;
|
||||||
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP))
|
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP))
|
||||||
PolyPlane.AddPoint( ptP - vtMove) ;
|
PolyPlane.AddPoint( ptP) ;
|
||||||
if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea)) {
|
if ( ! PolyPlane.GetPlane( plPlane) || ! PolyPlane.GetArea( dArea)) {
|
||||||
dArea = 0 ;
|
dArea = 0 ;
|
||||||
return IsFlat( plPlane, dToler) ;
|
return IsFlat( plPlane, dToler) ;
|
||||||
}
|
}
|
||||||
plPlane.Translate( vtMove) ;
|
|
||||||
// Sistemo il piano per l'offset utilizzato
|
|
||||||
// Test each vertex to see if it is farther from plane than allowed max distance
|
// Test each vertex to see if it is farther from plane than allowed max distance
|
||||||
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) {
|
for ( bool bFound = GetFirstPoint( ptP) ; bFound ; bFound = GetNextPoint( ptP)) {
|
||||||
double dDist = DistPointPlane( ptP, plPlane) ;
|
double dDist = ( ( ptP - ORIG) * plPlane.GetVersN()) - plPlane.GetDist() ;
|
||||||
if ( abs( dDist) > dToler)
|
if ( abs( dDist) > dToler)
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
@@ -650,13 +639,13 @@ PolyLine::GetAreaXY( double& dArea) const
|
|||||||
// verifico sia chiusa
|
// verifico sia chiusa
|
||||||
if ( ! IsClosed())
|
if ( ! IsClosed())
|
||||||
return false ;
|
return false ;
|
||||||
// calcolo l'area considerando solo XY (è la Z di Newell)
|
// calcolo l'area considerando solo XY (è la Z di Newell)
|
||||||
dArea = 0 ;
|
dArea = 0 ;
|
||||||
Point3d ptIni, ptFin ;
|
Point3d ptIni, ptFin ;
|
||||||
for ( bool bFound = GetFirstLine( ptIni, ptFin) ; bFound ; bFound = GetNextLine( ptIni, ptFin)) {
|
for ( bool bFound = GetFirstLine( ptIni, ptFin) ; bFound ; bFound = GetNextLine( ptIni, ptFin)) {
|
||||||
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ; // projection on xy
|
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ; // projection on xy
|
||||||
}
|
}
|
||||||
// considero anche la linea tra l'ultimo e il primo punto perchè in alcuni casi potrebbero definire area
|
// considero anche la linea tra l'ultimo e il primo punto perchè in alcuni casi potrebbero definire area
|
||||||
// significativa anche se sono coincidenti per le nostre tolleranze
|
// significativa anche se sono coincidenti per le nostre tolleranze
|
||||||
ptIni = ptFin ;
|
ptIni = ptFin ;
|
||||||
GetFirstPoint( ptFin) ;
|
GetFirstPoint( ptFin) ;
|
||||||
@@ -757,7 +746,7 @@ DouglasPeuckerSimplification( const PNTUVECTOR& vPtU, const double dSqTol, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// se la distanza massima trovata è sopra la tolleranza, allora controllo la parte di PolyLine tra
|
// se la distanza massima trovata è sopra la tolleranza, allora controllo la parte di PolyLine tra
|
||||||
// (nIndStart, nMaxInd) e quella tra (nMaxInd, nIndEnd)
|
// (nIndStart, nMaxInd) e quella tra (nMaxInd, nIndEnd)
|
||||||
if ( dMaxSqDist > dSqTol) {
|
if ( dMaxSqDist > dSqTol) {
|
||||||
// inserisco il punto
|
// inserisco il punto
|
||||||
@@ -800,7 +789,7 @@ PolyLine::RemoveAlignedPoints( double dToler)
|
|||||||
}
|
}
|
||||||
// altrimenti chiusa
|
// altrimenti chiusa
|
||||||
else {
|
else {
|
||||||
// cerco il punto più distante dal primo
|
// cerco il punto più distante dal primo
|
||||||
double dMaxDist = 0. ;
|
double dMaxDist = 0. ;
|
||||||
int nMaxInd = 0 ;
|
int nMaxInd = 0 ;
|
||||||
for ( int i = 1 ; i < int( vPtU.size()) ; ++ i) {
|
for ( int i = 1 ; i < int( vPtU.size()) ; ++ i) {
|
||||||
@@ -823,14 +812,6 @@ PolyLine::RemoveAlignedPoints( double dToler)
|
|||||||
// ordino in senso crescente
|
// ordino in senso crescente
|
||||||
sort( vInd.begin(), vInd.end()) ;
|
sort( vInd.begin(), vInd.end()) ;
|
||||||
|
|
||||||
// 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)) {
|
|
||||||
vInd.erase( vInd.begin()) ;
|
|
||||||
vInd.back() = vInd.front() ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rimetto in lista i soli punti rimasti
|
// rimetto in lista i soli punti rimasti
|
||||||
m_lUPoints.clear() ;
|
m_lUPoints.clear() ;
|
||||||
for ( auto Ind : vInd)
|
for ( auto Ind : vInd)
|
||||||
@@ -977,7 +958,7 @@ PolyLine::MyApproxOnSide( const Vector3d& vtN, bool bLeftSide, double dToler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// non è stato eliminato alcunché
|
// non è stato eliminato alcunché
|
||||||
// ripristino la tolleranza corrente
|
// ripristino la tolleranza corrente
|
||||||
dCurrToler = dToler ;
|
dCurrToler = dToler ;
|
||||||
// avanzo il terzetto di uno step
|
// avanzo il terzetto di uno step
|
||||||
@@ -1018,7 +999,7 @@ PolyLine::MakeConvex( const Vector3d& vtN, bool bLeftSide)
|
|||||||
bool
|
bool
|
||||||
PolyLine::MyMakeConvex( const Vector3d& vtN, bool bLeftSide)
|
PolyLine::MyMakeConvex( const Vector3d& vtN, bool bLeftSide)
|
||||||
{
|
{
|
||||||
// ciclo i controlli finchè non ci sono rimozioni
|
// ciclo i controlli finchè non ci sono rimozioni
|
||||||
bool bRemoved = true ;
|
bool bRemoved = true ;
|
||||||
while ( bRemoved) {
|
while ( bRemoved) {
|
||||||
bRemoved = false ;
|
bRemoved = false ;
|
||||||
@@ -1046,7 +1027,7 @@ PolyLine::MyMakeConvex( const Vector3d& vtN, bool bLeftSide)
|
|||||||
bRemoved = true ;
|
bRemoved = true ;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
// non è stato eliminato alcunché : avanzo il terzetto di uno step
|
// non è stato eliminato alcunché : avanzo il terzetto di uno step
|
||||||
precP = currP ;
|
precP = currP ;
|
||||||
currP = nextP ;
|
currP = nextP ;
|
||||||
++ nextP ;
|
++ nextP ;
|
||||||
@@ -1073,7 +1054,7 @@ PolyLine::Invert( bool bInvertU)
|
|||||||
m_lUPoints.reverse() ;
|
m_lUPoints.reverse() ;
|
||||||
// se richiesto, inverto anche il parametro U
|
// se richiesto, inverto anche il parametro U
|
||||||
if ( bInvertU) {
|
if ( bInvertU) {
|
||||||
// recupero il primo valore di U che è il vecchio finale ed è il riferimento di inversione
|
// recupero il primo valore di U che è il vecchio finale ed è il riferimento di inversione
|
||||||
double dUfin = m_lUPoints.front().second ;
|
double dUfin = m_lUPoints.front().second ;
|
||||||
// ciclo su tutti gli elementi
|
// ciclo su tutti gli elementi
|
||||||
for ( auto& UPoint : m_lUPoints) {
|
for ( auto& UPoint : m_lUPoints) {
|
||||||
@@ -1288,7 +1269,7 @@ PolyLine::GetMinAreaRectangleXY( Point3d& ptCen, Vector3d& vtAx, double& dLen, d
|
|||||||
bool
|
bool
|
||||||
PolyLine::Trim( const Plane3d& plPlane, bool bInVsOut)
|
PolyLine::Trim( const Plane3d& plPlane, bool bInVsOut)
|
||||||
{
|
{
|
||||||
// se vuota non faccio alcunché
|
// se vuota non faccio alcunché
|
||||||
if ( m_lUPoints.size() == 0)
|
if ( m_lUPoints.size() == 0)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
@@ -1390,7 +1371,7 @@ IsPointInsidePolyLine( const Point3d& ptP, const PolyLine& plPoly, double dToler
|
|||||||
return false ;
|
return false ;
|
||||||
// Riferimento alla lista dei punti
|
// Riferimento alla lista dei punti
|
||||||
PNTULIST& List = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
PNTULIST& List = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||||
double dMinSqDist = SQ_INFINITO ;
|
double dMinSqDist = SQ_INFINITO ;
|
||||||
Point3d ptMinDist ;
|
Point3d ptMinDist ;
|
||||||
auto itMinDistEnd = List.end() ;
|
auto itMinDistEnd = List.end() ;
|
||||||
@@ -1479,7 +1460,7 @@ GetPointParamOnPolyLine( const Point3d& ptP, const PolyLine& plPoly, double dTol
|
|||||||
// assegno nuovo inizio
|
// assegno nuovo inizio
|
||||||
ptStart = ptEnd ;
|
ptStart = ptEnd ;
|
||||||
}
|
}
|
||||||
// Il punto è sulla linea se la sua distanza rispetta la tolleranza
|
// Il punto è sulla linea se la sua distanza rispetta la tolleranza
|
||||||
return ( dMinSqDist < dToler * dToler) ;
|
return ( dMinSqDist < dToler * dToler) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1492,7 +1473,7 @@ ChangePolyLineStart( PolyLine& plPoly, const Point3d& ptNewStart, double dToler)
|
|||||||
return false ;
|
return false ;
|
||||||
// Riferimento alla lista dei punti
|
// Riferimento alla lista dei punti
|
||||||
PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||||
double dMinSqDist = SQ_INFINITO ;
|
double dMinSqDist = SQ_INFINITO ;
|
||||||
auto itMinDistEnd = LoopList.end() ;
|
auto itMinDistEnd = LoopList.end() ;
|
||||||
auto itStart = LoopList.begin() ;
|
auto itStart = LoopList.begin() ;
|
||||||
@@ -1536,7 +1517,7 @@ SplitPolyLineAtPoint( const PolyLine& plPoly, const Point3d& ptP, double dToler,
|
|||||||
return false ;
|
return false ;
|
||||||
// Riferimento alla lista dei punti
|
// Riferimento alla lista dei punti
|
||||||
const PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
const PNTULIST& LoopList = const_cast<PolyLine&>( plPoly).GetUPointList() ;
|
||||||
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
// Ciclo sui segmenti della polilinea per cercare il segmento più vicino al punto
|
||||||
double dMinSqDist = SQ_INFINITO ;
|
double dMinSqDist = SQ_INFINITO ;
|
||||||
auto itMinDistEnd = LoopList.end() ;
|
auto itMinDistEnd = LoopList.end() ;
|
||||||
auto itStart = LoopList.begin() ;
|
auto itStart = LoopList.begin() ;
|
||||||
@@ -1600,6 +1581,10 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
|||||||
int nLastJ = 0 ;
|
int nLastJ = 0 ;
|
||||||
vPnt1[0].second = 0 ;
|
vPnt1[0].second = 0 ;
|
||||||
|
|
||||||
|
double dFirstDist, dFirstParMinDist ;
|
||||||
|
DistPointPolyLine( vPnt1[0].first, PL2, dFirstDist, dFirstParMinDist) ;
|
||||||
|
int nFirstMinJ = ( int)( dFirstParMinDist + 0.5) ;
|
||||||
|
|
||||||
for ( int i = 1 ; i < nTotP1 ; ++ i) {
|
for ( int i = 1 ; i < nTotP1 ; ++ i) {
|
||||||
|
|
||||||
double dDist = INFINITO ;
|
double dDist = INFINITO ;
|
||||||
@@ -1608,7 +1593,7 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
|||||||
// distanza del punto dal segmento della polilinea
|
// distanza del punto dal segmento della polilinea
|
||||||
DistPointLine PointLineDistCalc( vPnt1[i].first, vPnt2[j-1].first, vPnt2[j].first) ;
|
DistPointLine PointLineDistCalc( vPnt1[i].first, vPnt2[j-1].first, vPnt2[j].first) ;
|
||||||
double dPlDist ;
|
double dPlDist ;
|
||||||
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist - EPS_SMALL) {
|
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist) {
|
||||||
dDist = dPlDist ;
|
dDist = dPlDist ;
|
||||||
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
||||||
dMinDistPar += j - 1 ;
|
dMinDistPar += j - 1 ;
|
||||||
@@ -1616,10 +1601,14 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
|||||||
}
|
}
|
||||||
int nMinJ = ( int)( dMinDistPar + 0.5) ;
|
int nMinJ = ( int)( dMinDistPar + 0.5) ;
|
||||||
|
|
||||||
|
// eventuale correzione per i primi punti ( da forzare nel vertice 0)
|
||||||
|
if ( nLastJ == 0 && nFirstMinJ > 0.5 * nTotP2 && nMinJ >= nFirstMinJ)
|
||||||
|
nMinJ = 0 ;
|
||||||
|
|
||||||
if ( nMinJ < nLastJ)
|
if ( nMinJ < nLastJ)
|
||||||
nMinJ = nLastJ ;
|
nMinJ = nLastJ ;
|
||||||
|
|
||||||
// verifica se è un punto interno in comune con l'altra polyline
|
// 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 ;
|
bCommonInternalPoints = true ;
|
||||||
|
|
||||||
@@ -1631,6 +1620,9 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
|||||||
int nLastI = 0 ;
|
int nLastI = 0 ;
|
||||||
vPnt2[0].second = 0 ;
|
vPnt2[0].second = 0 ;
|
||||||
|
|
||||||
|
DistPointPolyLine( vPnt2[0].first, PL1, dFirstDist, dFirstParMinDist) ;
|
||||||
|
int nFirstMinI = ( int)( dFirstParMinDist + 0.5) ;
|
||||||
|
|
||||||
for ( int j = 1 ; j < nTotP2 ; ++ j) {
|
for ( int j = 1 ; j < nTotP2 ; ++ j) {
|
||||||
|
|
||||||
double dDist = INFINITO ;
|
double dDist = INFINITO ;
|
||||||
@@ -1639,7 +1631,8 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
|||||||
// distanza del punto dal segmento della polilinea
|
// distanza del punto dal segmento della polilinea
|
||||||
DistPointLine PointLineDistCalc( vPnt2[j].first, vPnt1[i-1].first, vPnt1[i].first) ;
|
DistPointLine PointLineDistCalc( vPnt2[j].first, vPnt1[i-1].first, vPnt1[i].first) ;
|
||||||
double dPlDist ;
|
double dPlDist ;
|
||||||
if ( PointLineDistCalc.GetDist( dPlDist) && dPlDist < dDist - EPS_SMALL) {
|
PointLineDistCalc.GetDist( dPlDist) ;
|
||||||
|
if ( dPlDist < dDist) {
|
||||||
dDist = dPlDist ;
|
dDist = dPlDist ;
|
||||||
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
PointLineDistCalc.GetParamAtMinDistPoint( dMinDistPar) ;
|
||||||
dMinDistPar += i - 1 ;
|
dMinDistPar += i - 1 ;
|
||||||
@@ -1647,6 +1640,10 @@ AssociatePolyLinesMinDistPoints( const PolyLine& PL1, const PolyLine& PL2, PNTIV
|
|||||||
}
|
}
|
||||||
int nMinI = ( int)( dMinDistPar + 0.5) ;
|
int nMinI = ( int)( dMinDistPar + 0.5) ;
|
||||||
|
|
||||||
|
// eventuale correzione per primi punti
|
||||||
|
if ( nLastI == 0 && nFirstMinI > 0.5 * nTotP1 && nMinI >= nFirstMinI)
|
||||||
|
nMinI = 0 ;
|
||||||
|
|
||||||
if ( nMinI < nLastI)
|
if ( nMinI < nLastI)
|
||||||
nMinI = nLastI ;
|
nMinI = nLastI ;
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
//----------------------------------------------------------------------------
|
|
||||||
// EgalTech 2024-2024
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// File : ProjectCurveSurfBez.cpp Data : 07.05.24 Versione : 2.6e3
|
|
||||||
// Contenuto : Implementazione funzioni proiezione curve su superficie Bezier.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Modifiche : 07.05.24 DB Creazione modulo.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "/EgtDev/Include/EGkProjectCurveSurfTm.h"
|
|
||||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
|
||||||
|
|
||||||
using namespace std ;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const Vector3d& vtDir, double dLinTol, double dMaxSegmLen,
|
|
||||||
PNT5AXVECTOR& vPt5ax)
|
|
||||||
{
|
|
||||||
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
|
|
||||||
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, vtDir, dLinTol, dMaxSegmLen, vPt5ax) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const IGeoPoint3d& gpRef,
|
|
||||||
double dLinTol, double dMaxSegmLen, PNT5AXVECTOR& vPt5ax)
|
|
||||||
{
|
|
||||||
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
|
|
||||||
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, gpRef, dLinTol, dMaxSegmLen, vPt5ax) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const ICurve& crRef,
|
|
||||||
double dLinTol, double dMaxSegmLen, PNT5AXVECTOR& vPt5ax)
|
|
||||||
{
|
|
||||||
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
|
|
||||||
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, crRef, dLinTol, dMaxSegmLen, vPt5ax) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
ProjectCurveOnSurfBez( const ICurve& crCrv, const ISurfBezier& surfBez, const ISurfTriMesh& tmRef,
|
|
||||||
double dLinTol, double dMaxSegmLen, PNT5AXVECTOR& vPt5ax)
|
|
||||||
{
|
|
||||||
const ISurfTriMesh* pAuxSurf = surfBez.GetAuxSurf() ;
|
|
||||||
return ProjectCurveOnSurfTm( crCrv, *pAuxSurf, tmRef, dLinTol, dMaxSegmLen, vPt5ax) ;
|
|
||||||
}
|
|
||||||
+13
-34
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
//--------------------------- Include ----------------------------------------
|
//--------------------------- Include ----------------------------------------
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||||
@@ -22,10 +22,6 @@
|
|||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Angolo limite tra normale al triangolo e direzione di proiezione 89°
|
|
||||||
const double COS_ANG_LIM = 0.0175 ;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static bool
|
static bool
|
||||||
PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext, double dSqTol)
|
PointsInTolerance( const PNT5AXVECTOR& vPt5ax, int nPrec, int nCurr, int nNext, double dSqTol)
|
||||||
@@ -93,9 +89,9 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vec
|
|||||||
// controllo le tolleranze
|
// controllo le tolleranze
|
||||||
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
||||||
dMaxSegmLen = max( dMaxSegmLen, 10 * EPS_SMALL) ;
|
dMaxSegmLen = max( dMaxSegmLen, 10 * EPS_SMALL) ;
|
||||||
// approssimo la curva con una polilinea alla massima risoluzione
|
// approssimo la curva con una polilinea entro la metà della tolleranza
|
||||||
PolyLine PL ;
|
PolyLine PL ;
|
||||||
if ( ! crCrv.ApproxWithLines( EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
if ( ! crCrv.ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||||
return false ;
|
return false ;
|
||||||
const double MAX_SEG_LEN = min( dMaxSegmLen, 1.) ;
|
const double MAX_SEG_LEN = min( dMaxSegmLen, 1.) ;
|
||||||
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
|
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
|
||||||
@@ -116,17 +112,12 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const Vec
|
|||||||
Point3d ptP ;
|
Point3d ptP ;
|
||||||
bool bFound = PL.GetFirstUPoint( &dPar, &ptP) ;
|
bool bFound = PL.GetFirstUPoint( &dPar, &ptP) ;
|
||||||
while ( bFound) {
|
while ( bFound) {
|
||||||
// intersezione retta di proiezione con superficie
|
|
||||||
Point3d ptL = GetToLoc( ptP, frRefLine) ;
|
Point3d ptL = GetToLoc( ptP, frRefLine) ;
|
||||||
ILSIVECTOR vIntRes ;
|
ILSIVECTOR vIntRes ;
|
||||||
intPLSTM.GetInters( ptL, 1, vIntRes, false) ;
|
intPLSTM.GetInters( ptL, 1, vIntRes, false) ;
|
||||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
if ( ! vIntRes.empty()) {
|
||||||
int nI = int( vIntRes.size()) - 1 ;
|
|
||||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
|
||||||
--nI ;
|
|
||||||
// se trovata
|
|
||||||
if ( nI >= 0) {
|
|
||||||
// calcolo il punto
|
// calcolo il punto
|
||||||
|
int nI = int( vIntRes.size()) - 1 ;
|
||||||
Point3d ptInt ;
|
Point3d ptInt ;
|
||||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||||
ptInt = vIntRes[nI].ptI2 ;
|
ptInt = vIntRes[nI].ptI2 ;
|
||||||
@@ -196,13 +187,9 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const IGe
|
|||||||
vtLine /= dLineLen ;
|
vtLine /= dLineLen ;
|
||||||
ILSIVECTOR vIntRes ;
|
ILSIVECTOR vIntRes ;
|
||||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, tmSurf, vIntRes, false)) {
|
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, tmSurf, vIntRes, false)) {
|
||||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
if ( vIntRes.size() > 0) {
|
||||||
int nI = int( vIntRes.size()) - 1 ;
|
|
||||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
|
||||||
--nI ;
|
|
||||||
// se trovata
|
|
||||||
if ( nI >= 0) {
|
|
||||||
// calcolo il punto
|
// calcolo il punto
|
||||||
|
int nI = int( vIntRes.size()) - 1 ;
|
||||||
Point3d ptInt ;
|
Point3d ptInt ;
|
||||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||||
ptInt = vIntRes[nI].ptI2 ;
|
ptInt = vIntRes[nI].ptI2 ;
|
||||||
@@ -248,9 +235,9 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const ICu
|
|||||||
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
||||||
dMaxSegmLen = max( dMaxSegmLen, 10 * EPS_SMALL) ;
|
dMaxSegmLen = max( dMaxSegmLen, 10 * EPS_SMALL) ;
|
||||||
|
|
||||||
// approssimo la curva con una polilinea alla massima risoluzione
|
// approssimo la curva con una polilinea entro la metà della tolleranza
|
||||||
PolyLine PL ;
|
PolyLine PL ;
|
||||||
if ( ! crCrv.ApproxWithLines( EPS_SMALL, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
if ( ! crCrv.ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
||||||
return false ;
|
return false ;
|
||||||
const double MAX_SEG_LEN = min( dMaxSegmLen, 1.) ;
|
const double MAX_SEG_LEN = min( dMaxSegmLen, 1.) ;
|
||||||
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
|
if ( ! PL.AdjustForMaxSegmentLen( MAX_SEG_LEN))
|
||||||
@@ -277,13 +264,9 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const ICu
|
|||||||
vtLine /= dLineLen ;
|
vtLine /= dLineLen ;
|
||||||
ILSIVECTOR vIntRes ;
|
ILSIVECTOR vIntRes ;
|
||||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, tmSurf, vIntRes, false)) {
|
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, tmSurf, vIntRes, false)) {
|
||||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
if ( vIntRes.size() > 0) {
|
||||||
int nI = int( vIntRes.size()) - 1 ;
|
|
||||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
|
||||||
--nI ;
|
|
||||||
// se trovata
|
|
||||||
if ( nI >= 0) {
|
|
||||||
// calcolo il punto
|
// calcolo il punto
|
||||||
|
int nI = int( vIntRes.size()) - 1 ;
|
||||||
Point3d ptInt ;
|
Point3d ptInt ;
|
||||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||||
ptInt = vIntRes[nI].ptI2 ;
|
ptInt = vIntRes[nI].ptI2 ;
|
||||||
@@ -359,13 +342,9 @@ ProjectCurveOnSurfTm( const ICurve& crCrv, const ISurfTriMesh& tmSurf, const ISu
|
|||||||
vtLine /= dLineLen ;
|
vtLine /= dLineLen ;
|
||||||
ILSIVECTOR vIntRes ;
|
ILSIVECTOR vIntRes ;
|
||||||
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, tmSurf, vIntRes, false)) {
|
if ( IntersLineSurfTm( ptP, vtLine, dLineLen, tmSurf, vIntRes, false)) {
|
||||||
// cerco la prima intersezione valida a partire dall'ultima (è la più alta)
|
if ( vIntRes.size() > 0) {
|
||||||
int nI = int( vIntRes.size()) - 1 ;
|
|
||||||
while ( nI >= 0 && abs( vIntRes[nI].dCosDN) < COS_ANG_LIM)
|
|
||||||
--nI ;
|
|
||||||
// se trovata
|
|
||||||
if ( nI >= 0) {
|
|
||||||
// calcolo il punto
|
// calcolo il punto
|
||||||
|
int nI = int( vIntRes.size()) - 1 ;
|
||||||
Point3d ptInt ;
|
Point3d ptInt ;
|
||||||
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
if ( vIntRes[nI].nILTT == ILTT_SEGM || vIntRes[nI].nILTT == ILTT_SEGM_ON_EDGE)
|
||||||
ptInt = vIntRes[nI].ptI2 ;
|
ptInt = vIntRes[nI].ptI2 ;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "RemoveCurveDefects.h"
|
#include "RemoveCurveDefects.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|||||||
-1407
File diff suppressed because it is too large
Load Diff
+1
-34
@@ -17,13 +17,12 @@
|
|||||||
#include "SurfTriMesh.h"
|
#include "SurfTriMesh.h"
|
||||||
#include "SurfBezier.h"
|
#include "SurfBezier.h"
|
||||||
#include "/EgtDev/Include/EGkSbzStandard.h"
|
#include "/EgtDev/Include/EGkSbzStandard.h"
|
||||||
#include "/EgtDev/Include/EGkSbzFromCurves.h"
|
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
ISurfBezier*
|
ISurfBezier*
|
||||||
GetSurfBezierSphere( const Point3d& ptCenter, double dR)
|
CreateBezierSphere( const Point3d& ptCenter, double dR)
|
||||||
{
|
{
|
||||||
// creo una superficie di Bezier di grado 2 con 45 punti di controllo
|
// creo una superficie di Bezier di grado 2 con 45 punti di controllo
|
||||||
PtrOwner<ISurfBezier> pSrfBez( CreateSurfBezier()) ;
|
PtrOwner<ISurfBezier> pSrfBez( CreateSurfBezier()) ;
|
||||||
@@ -79,35 +78,3 @@ GetSurfBezierSphere( const Point3d& ptCenter, double dR)
|
|||||||
|
|
||||||
return Release( pSrfBez) ;
|
return Release( pSrfBez) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////-------------------------------------------------------------------------------
|
|
||||||
//ISurfBezier*
|
|
||||||
//GetSurfBezierCone( const Point3d& ptCenter, double dRadius, const Vector3d& dHeight)
|
|
||||||
//{
|
|
||||||
// // le dimensioni devono essere significative
|
|
||||||
// if ( dRadius < EPS_SMALL || abs( dHeight) < EPS_SMALL)
|
|
||||||
// return nullptr ;
|
|
||||||
// // creo la circonferenza di base
|
|
||||||
// CurveArc cArc ;
|
|
||||||
// cArc.Set( ORIG, Z_AX, dRadius) ;
|
|
||||||
// if ( dHeight < 0)
|
|
||||||
// cArc.Invert() ;
|
|
||||||
// // punto di vertice
|
|
||||||
// Point3d ptTip( 0, 0, dHeight) ;
|
|
||||||
// // creo la superficie laterale del cono
|
|
||||||
// PtrOwner<ISurfBezier> pSbz( GetSurfBezierRuled( ptTip, &cArc)) ;
|
|
||||||
// if ( IsNull( pSbz))
|
|
||||||
// return nullptr ;
|
|
||||||
//
|
|
||||||
// //// creo la superficie di base e la inverto
|
|
||||||
// //PtrOwner<ISurfTriMesh> pSTM1( GetSurfTriMeshByFlatContour( &cArc, dLinTol)) ;
|
|
||||||
// //if ( IsNull( pSTM1))
|
|
||||||
// // return nullptr ;
|
|
||||||
// //pSTM1->Invert() ;
|
|
||||||
// //// la unisco alla superficie del fianco
|
|
||||||
// //if ( ! pSTM->DoSewing( *pSTM1))
|
|
||||||
// // return nullptr ;
|
|
||||||
//
|
|
||||||
// // restituisco la superficie
|
|
||||||
// return Release( pSbz) ;
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -88,8 +88,6 @@ SelfIntersCurve::SelfIntersCurve( const ICurve& Curve)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
default :
|
|
||||||
break ;
|
|
||||||
}
|
}
|
||||||
// per curva approssimata, sistemo...
|
// per curva approssimata, sistemo...
|
||||||
AdjustIntersParams( ( pCalcCrv != m_pCurve), pCalcCrv, vTmpPar) ;
|
AdjustIntersParams( ( pCalcCrv != m_pCurve), pCalcCrv, vTmpPar) ;
|
||||||
|
|||||||
+29
-142
@@ -367,14 +367,25 @@ GetSurfFlatRegionFromTriangle( const Triangle3d& Tria)
|
|||||||
ISurfFlatRegion*
|
ISurfFlatRegion*
|
||||||
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
|
||||||
{
|
{
|
||||||
// Creo curva composita.
|
|
||||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
|
||||||
if ( IsNull( pLoop) || ! pLoop->FromPolyLine( ContourPolyLine))
|
|
||||||
return nullptr ;
|
|
||||||
// Creo la regione.
|
// Creo la regione.
|
||||||
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
|
||||||
if ( IsNull( pSfr) || ! pSfr->AddExtLoop( Release( pLoop)))
|
if ( IsNull( pSfr))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
|
// Creo curva composita.
|
||||||
|
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||||
|
if ( IsNull( pLoop))
|
||||||
|
return nullptr ;
|
||||||
|
Point3d ptSt, ptEn ;
|
||||||
|
bool bContinue = ContourPolyLine.GetFirstPoint( ptSt) &&
|
||||||
|
ContourPolyLine.GetNextPoint( ptEn) ;
|
||||||
|
while ( bContinue) {
|
||||||
|
CurveLine cvLine ;
|
||||||
|
cvLine.Set( ptSt, ptEn) ;
|
||||||
|
pLoop->AddCurve( cvLine) ;
|
||||||
|
ptSt = ptEn ;
|
||||||
|
bContinue = ContourPolyLine.GetNextPoint( ptEn) ;
|
||||||
|
}
|
||||||
|
pSfr->AddExtLoop( Release( pLoop)) ;
|
||||||
return Release( pSfr) ;
|
return Release( pSfr) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,17 +401,25 @@ GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
|
|||||||
for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) {
|
for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) {
|
||||||
// Creo curva composita.
|
// Creo curva composita.
|
||||||
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
|
||||||
if ( IsNull( pLoop) || ! pLoop->FromPolyLine( vContoursPolyLineVec[nL]))
|
if ( IsNull( pLoop))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
|
Point3d ptSt, ptEn ;
|
||||||
|
bool bContinue = vContoursPolyLineVec[nL].GetFirstPoint( ptSt) &&
|
||||||
|
vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
|
||||||
|
while ( bContinue) {
|
||||||
|
CurveLine cvLine ;
|
||||||
|
cvLine.Set( ptSt, ptEn) ;
|
||||||
|
pLoop->AddCurve( cvLine) ;
|
||||||
|
ptSt = ptEn ;
|
||||||
|
bContinue = vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
|
||||||
|
}
|
||||||
// Loop esterno
|
// Loop esterno
|
||||||
if ( nL == 0) {
|
if ( nL == 0) {
|
||||||
if ( ! pSfr->AddExtLoop( Release( pLoop)))
|
pSfr->AddExtLoop( Release( pLoop)) ;
|
||||||
return nullptr ;
|
|
||||||
}
|
}
|
||||||
// Loop interno
|
// Loop interno
|
||||||
else {
|
else {
|
||||||
if ( ! pSfr->AddIntLoop( Release( pLoop)))
|
pSfr->AddIntLoop( Release( pLoop)) ;
|
||||||
return nullptr ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Release( pSfr) ;
|
return Release( pSfr) ;
|
||||||
@@ -572,135 +591,3 @@ SurfFlatRegionByContours::GetUnusedCurveTempProps( INTVECTOR& vId)
|
|||||||
}
|
}
|
||||||
return ( ! vId.empty()) ;
|
return ( ! vId.empty()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
CalcRegionPolyLines( const POLYLINEVECTOR& vPL, Vector3d& vtN, INTMATRIX& vnPLIndMat, BOOLVECTOR& vbInvert)
|
|
||||||
{
|
|
||||||
// matrice di interi : ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle
|
|
||||||
// successive i loop interni
|
|
||||||
//INTMATRIX vnPLIndMat ;
|
|
||||||
// vettore di bool : riferito al vettore originale delle polyline, riporta true se la polyline è stata invertita
|
|
||||||
|
|
||||||
// ricavo versore normale
|
|
||||||
Plane3d plPlane ; double dArea ;
|
|
||||||
if ( ! vPL[0].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
|
|
||||||
return false ;
|
|
||||||
vtN = plPlane.GetVersN() ;
|
|
||||||
|
|
||||||
typedef std::pair<int,double> INDAREA ;
|
|
||||||
std::vector<INDAREA> m_vArea ;
|
|
||||||
// calcolo piano medio e area delle curve
|
|
||||||
m_vArea.reserve( vPL.size()) ;
|
|
||||||
VCT3DVECTOR vvtN ;
|
|
||||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
|
||||||
// calcolo piano medio e area
|
|
||||||
Plane3d plPlane ;
|
|
||||||
double dArea ;
|
|
||||||
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea))
|
|
||||||
return false ;
|
|
||||||
// verifico che le normali siano molto vicine
|
|
||||||
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN))
|
|
||||||
return false ;
|
|
||||||
// salvo la normale
|
|
||||||
vvtN.push_back( plPlane.GetVersN()) ;
|
|
||||||
// assegno il segno all'area secondo il verso della normale
|
|
||||||
if ( ( plPlane.GetVersN() * vtN) > 0)
|
|
||||||
m_vArea.emplace_back( i, dArea) ;
|
|
||||||
else
|
|
||||||
m_vArea.emplace_back( i, - dArea) ;
|
|
||||||
}
|
|
||||||
// ordino in senso decrescente sull'area
|
|
||||||
sort( m_vArea.begin(), m_vArea.end(),
|
|
||||||
[]( const INDAREA& a, const INDAREA& b) { return ( abs( a.second) > abs( b.second)) ; }) ;
|
|
||||||
|
|
||||||
// dalle PolyLine passo alle curve nel piano XY ( prendo la prima come riferimento, trascuro le Z delle successive)
|
|
||||||
Frame3d frRef ; frRef.Set( ORIG, vtN) ;
|
|
||||||
if ( ! frRef.IsValid())
|
|
||||||
return false ;
|
|
||||||
ICRVCOMPOPOVECTOR vCrvCompo( int( vPL.size())) ;
|
|
||||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
|
||||||
vCrvCompo[i].Set( CreateCurveComposite()) ;
|
|
||||||
vCrvCompo[i]->FromPolyLine( vPL[i]) ;
|
|
||||||
vCrvCompo[i]->ToLoc( frRef) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// restituisco la normale del loop più grande
|
|
||||||
bool bInvertAll = vvtN[m_vArea[0].first] * vtN < 0 ;
|
|
||||||
vtN = vvtN[m_vArea[0].first] ;
|
|
||||||
|
|
||||||
//// vettore di indici per ordinare le PolyLine
|
|
||||||
INTVECTOR vPL_IndOrder ; vPL_IndOrder.resize( int( vPL.size())) ;
|
|
||||||
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i)
|
|
||||||
vPL_IndOrder[i] = m_vArea[i].first ;
|
|
||||||
|
|
||||||
// aggiungo le diverse curve
|
|
||||||
bool bFirstCrv ;
|
|
||||||
Plane3d plExtLoop ;
|
|
||||||
double dAreaExtLoop = 0. ;
|
|
||||||
vbInvert.resize( vPL.size()) ;
|
|
||||||
fill( vbInvert.begin(), vbInvert.end(), false) ;
|
|
||||||
do {
|
|
||||||
bFirstCrv = true ;
|
|
||||||
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i) {
|
|
||||||
// recupero indice di percorso e verifico sia valido
|
|
||||||
int j = m_vArea[i].first ;
|
|
||||||
if ( j < 0)
|
|
||||||
continue ;
|
|
||||||
// lo inserisco come esterno...
|
|
||||||
if ( bFirstCrv) {
|
|
||||||
vnPLIndMat.push_back({ j}) ;
|
|
||||||
m_vArea[i].first = -1 ;
|
|
||||||
dAreaExtLoop = m_vArea[i].second ;
|
|
||||||
// inverto se necessario
|
|
||||||
if ( m_vArea[i].second < EPS_SMALL) {
|
|
||||||
vCrvCompo[j]->Invert() ;
|
|
||||||
dAreaExtLoop *= -1 ;
|
|
||||||
vbInvert[j] = true ;
|
|
||||||
}
|
|
||||||
bFirstCrv = false ;
|
|
||||||
}
|
|
||||||
// ... altrimenti verifico se il loop è interno o no
|
|
||||||
else {
|
|
||||||
// il loop è interno se è sia interno al loop esterno della riga di vnPLIndMat e allo stesso tempo
|
|
||||||
// esterno a tutti i loop già inseriti nella riga attuale.
|
|
||||||
// verifica rispetto loop esterno
|
|
||||||
IntersCurveCurve ccInt( *vCrvCompo[vnPLIndMat.back().front()], *vCrvCompo[j]) ;
|
|
||||||
CRVCVECTOR ccClass ;
|
|
||||||
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
|
||||||
! ccInt.GetCurveClassification( 1, EPS_SMALL, ccClass) ||
|
|
||||||
ccClass.empty() || ccClass[0].nClass != CRVC_IN)
|
|
||||||
continue ;
|
|
||||||
// verifica rispetto ai loop interni
|
|
||||||
bool bOk = true ;
|
|
||||||
for ( int k = 1 ; k < int( vnPLIndMat.back().size()) ; ++ k) {
|
|
||||||
IntersCurveCurve ccInt2( *vCrvCompo[vnPLIndMat.back()[k]], *vCrvCompo[j]) ;
|
|
||||||
CRVCVECTOR ccClass2 ;
|
|
||||||
if ( ccInt2.GetCrossOrOverlapIntersCount() > 0 ||
|
|
||||||
! ccInt2.GetCurveClassification( 1, EPS_SMALL, ccClass2) ||
|
|
||||||
ccClass2.empty() || ccClass2[0].nClass != CRVC_IN) {
|
|
||||||
bOk = false ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bOk) {
|
|
||||||
// inserisco nella matrice
|
|
||||||
vnPLIndMat.back().push_back( j) ;
|
|
||||||
m_vArea[i].first = -1 ;
|
|
||||||
// inverto se necessario
|
|
||||||
if ( m_vArea[i].second * dAreaExtLoop > 0.) {
|
|
||||||
vCrvCompo[j]->Invert() ;
|
|
||||||
vbInvert[j] = true ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while ( ! bFirstCrv) ;
|
|
||||||
|
|
||||||
if ( bInvertAll) {
|
|
||||||
for ( int i = 0 ; i < int( vPL.size()) ; ++i)
|
|
||||||
vbInvert[i] = ! vbInvert[i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|||||||
+236
-430
@@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
static bool CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
|
||||||
|
POLYLINEVECTOR& vPL, Vector3d& vtN) ;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
ISurfTriMesh*
|
ISurfTriMesh*
|
||||||
GetSurfTriMeshByFlatContour( const ICurve* pCurve, double dLinTol)
|
GetSurfTriMeshByFlatContour( const ICurve* pCurve, double dLinTol)
|
||||||
@@ -61,25 +65,12 @@ GetSurfTriMeshByRegion( const CICURVEPVECTOR& vpCurve, double dLinTol)
|
|||||||
return nullptr ;
|
return nullptr ;
|
||||||
// calcolo le polilinee che approssimano le curve della regione
|
// calcolo le polilinee che approssimano le curve della regione
|
||||||
POLYLINEVECTOR vPL ;
|
POLYLINEVECTOR vPL ;
|
||||||
vPL.resize( vpCurve.size()) ;
|
|
||||||
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
|
|
||||||
if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPL[i]))
|
|
||||||
return nullptr ;
|
|
||||||
}
|
|
||||||
Vector3d vtN ;
|
Vector3d vtN ;
|
||||||
INTMATRIX vnPLIndMat ;
|
if ( ! CalcRegionPolyLines( vpCurve, dLinTol, vPL, vtN))
|
||||||
BOOLVECTOR vbInvert ;
|
|
||||||
if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert))
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) {
|
|
||||||
for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){
|
|
||||||
if( vbInvert[vnPLIndMat[i][j]])
|
|
||||||
vPL[vnPLIndMat[i][j]].Invert() ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// creo e setto la superficie trimesh
|
// creo e setto la superficie trimesh
|
||||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||||
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL, vnPLIndMat))
|
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
// salvo tolleranza lineare usata
|
// salvo tolleranza lineare usata
|
||||||
pSTM->SetLinearTolerance( dLinTol) ;
|
pSTM->SetLinearTolerance( dLinTol) ;
|
||||||
@@ -154,20 +145,9 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d&
|
|||||||
return GetSurfTriMeshByExtrusion( vpCurve[0], vtExtr, true, dLinTol) ;
|
return GetSurfTriMeshByExtrusion( vpCurve[0], vtExtr, true, dLinTol) ;
|
||||||
// calcolo le polilinee che approssimano le curve della regione
|
// calcolo le polilinee che approssimano le curve della regione
|
||||||
POLYLINEVECTOR vPL ;
|
POLYLINEVECTOR vPL ;
|
||||||
vPL.resize( vpCurve.size()) ;
|
|
||||||
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
|
|
||||||
if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPL[i]))
|
|
||||||
return nullptr ;
|
|
||||||
}
|
|
||||||
Vector3d vtN ;
|
Vector3d vtN ;
|
||||||
INTMATRIX vnPLIndMat ;
|
if ( ! CalcRegionPolyLines( vpCurve, dLinTol, vPL, vtN))
|
||||||
BOOLVECTOR vbInvert ;
|
|
||||||
if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert))
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
for ( int i = 0 ; i < int( vPL.size()) ; ++i) {
|
|
||||||
if( vbInvert[i])
|
|
||||||
vPL[i].Invert() ;
|
|
||||||
}
|
|
||||||
// verifico la direzione di estrusione
|
// verifico la direzione di estrusione
|
||||||
double dOrthoExtr = vtN * vtExtr ;
|
double dOrthoExtr = vtN * vtExtr ;
|
||||||
if ( ( abs( dOrthoExtr) < EPS_SMALL))
|
if ( ( abs( dOrthoExtr) < EPS_SMALL))
|
||||||
@@ -179,8 +159,7 @@ GetSurfTriMeshByRegionExtrusion( const CICURVEPVECTOR& vpCurve, const Vector3d&
|
|||||||
}
|
}
|
||||||
// creo la prima superficie di estremità
|
// creo la prima superficie di estremità
|
||||||
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||||
// alla funzione CreateByRegion passo anche la matrice che contiene la struttura dei chunk. Le polyline hanno già il verso giusto
|
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL))
|
||||||
if ( IsNull( pSTM) || ! pSTM->CreateByRegion( vPL, vnPLIndMat))
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
// creo la seconda superficie e la unisco alla prima
|
// creo la seconda superficie e la unisco alla prima
|
||||||
{ // copio la prima superficie
|
{ // copio la prima superficie
|
||||||
@@ -351,11 +330,9 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
|||||||
{
|
{
|
||||||
// verifico che la linea guida sia piana
|
// verifico che la linea guida sia piana
|
||||||
Plane3d plGuide ;
|
Plane3d plGuide ;
|
||||||
if ( ! pGuide->IsFlat( plGuide, true, 10 * EPS_SMALL))
|
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
Vector3d vtNorm ; pGuide->GetExtrusion( vtNorm) ;
|
Vector3d vtNorm = plGuide.GetVersN() ;
|
||||||
if ( vtNorm.IsSmall())
|
|
||||||
vtNorm = Z_AX ;
|
|
||||||
// determino se la guida è chiusa
|
// determino se la guida è chiusa
|
||||||
bool bGuideClosed = pGuide->IsClosed() ;
|
bool bGuideClosed = pGuide->IsClosed() ;
|
||||||
// curve di offset
|
// curve di offset
|
||||||
@@ -378,7 +355,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
|||||||
PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||||
if ( IsNull( pSrfBot))
|
if ( IsNull( pSrfBot))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pSrfBot->Translate( - dDimV * vtNorm) ;
|
pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||||
pSrfBot->Invert() ;
|
pSrfBot->Invert() ;
|
||||||
PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvR, -dDimV * vtNorm, false, dLinTol)) ;
|
PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvR, -dDimV * vtNorm, false, dLinTol)) ;
|
||||||
if ( IsNull( pSrfRgt))
|
if ( IsNull( pSrfRgt))
|
||||||
@@ -388,188 +365,74 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide,
|
|||||||
if ( IsNull( pSrfLft))
|
if ( IsNull( pSrfLft))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
// unisco le parti
|
// unisco le parti
|
||||||
int nBuckets = max( 2 * ( pSrfRgt->GetVertexSize() + pSrfLft->GetVertexSize()), 1000) ;
|
PtrOwner<ISurfTriMesh> pSTM( Release( pSrfTop)) ;
|
||||||
StmFromTriangleSoup stmSoup ;
|
pSTM->DoSewing( *pSrfRgt) ;
|
||||||
if ( ! stmSoup.Start( nBuckets))
|
pSTM->DoSewing( *pSrfLft) ;
|
||||||
return nullptr ;
|
pSTM->DoSewing( *pSrfBot) ;
|
||||||
stmSoup.AddSurfTriMesh( *pSrfTop) ;
|
// salvo tolleranza lineare usata e imposto angolo per smooth
|
||||||
stmSoup.AddSurfTriMesh( *pSrfRgt) ;
|
pSTM->SetLinearTolerance( dLinTol) ;
|
||||||
stmSoup.AddSurfTriMesh( *pSrfLft) ;
|
pSTM->SetSmoothAngle( 20) ;
|
||||||
stmSoup.AddSurfTriMesh( *pSrfBot) ;
|
|
||||||
PtrOwner<ISurfTriMesh> pSTM ;
|
|
||||||
// se guida aperta e tappi piatti
|
// se guida aperta e tappi piatti
|
||||||
if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||||
// completo unione e recupero la superficie risultante
|
|
||||||
if ( ! stmSoup.End())
|
|
||||||
return nullptr ;
|
|
||||||
pSTM.Set( stmSoup.GetSurf()) ;
|
|
||||||
// verifico che le due estremità siano chiuse e piatte
|
// verifico che le due estremità siano chiuse e piatte
|
||||||
POLYLINEVECTOR vPL ;
|
POLYLINEVECTOR vPL ;
|
||||||
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
Plane3d plEnds ; double dArea ;
|
Plane3d plEnds ; double dArea ;
|
||||||
if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
// calcolo il cap sull'inizio
|
// aggiungo il cap sull'inizio
|
||||||
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||||
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pSci->Invert() ;
|
pSci->Invert() ;
|
||||||
// calcolo il cap sulla fine
|
pSTM->DoSewing( *pSci) ;
|
||||||
|
// aggiungo il cap sulla fine
|
||||||
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||||
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pSce->Invert() ;
|
pSce->Invert() ;
|
||||||
// cucio i tappi all'estrusione
|
pSTM->DoSewing( *pSce) ;
|
||||||
if ( ! pSTM->DoSewing( *pSci) || ! pSTM->DoSewing( *pSce))
|
|
||||||
return nullptr ;
|
|
||||||
}
|
}
|
||||||
// se altrimenti guida aperta e tappi arrotondati
|
// se altrimenti guida aperta e tappi arrotondati
|
||||||
if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||||
// step di rotazione per rispettare la tolleranza
|
// step di rotazione per rispettare la tolleranza
|
||||||
double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||||
// se l'offset interno alla guida è chiuso
|
// aggiungo il cap sull'inizio
|
||||||
if ( pCrvL->IsClosed()) {
|
Point3d ptStart ;
|
||||||
// calcolo l'angolo di rotazione per screwing faccia Top e Bottom
|
pGuide->GetStartPoint( ptStart) ;
|
||||||
Point3d ptRight ; pCrvR->GetEndPoint( ptRight) ;
|
Vector3d vtStart ;
|
||||||
Point3d ptLeft ; pCrvR->GetStartPoint( ptLeft) ;
|
pGuide->GetStartDir( vtStart) ;
|
||||||
Point3d ptJunction ; pCrvL->GetStartPoint( ptJunction) ;
|
vtStart.Rotate( vtNorm, 0, 1) ;
|
||||||
Point3d ptCenter = Media( ptRight, ptLeft) ;
|
PolyLine PLStart ;
|
||||||
Vector3d vtRight = ptRight - ptCenter ;
|
PLStart.AddUPoint( 0, ptStart) ;
|
||||||
Vector3d vtLeft = ptLeft - ptCenter ;
|
PLStart.AddUPoint( 1, ptStart + dDimH / 2 * vtStart) ;
|
||||||
double dAng = ANG_STRAIGHT ;
|
PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dDimV * vtNorm) ;
|
||||||
vtRight.GetAngle( vtLeft, dAng) ;
|
PLStart.AddUPoint( 3, ptStart - dDimV * vtNorm) ;
|
||||||
vtRight.Normalize() ;
|
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||||
PolyLine plLoop ;
|
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||||
// creo il loop defininendo i punti
|
|
||||||
plLoop.AddUPoint( 0, ptRight) ; // primo punto
|
|
||||||
double dAngStep = ceil( dAng / dStepRotDeg) ; // aggiusto lo step
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptRight ;
|
|
||||||
ptRot.Rotate( ptCenter, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoop.AddUPoint( i, ptRot) ; // punto intermedio sulla circonferenza
|
|
||||||
}
|
|
||||||
plLoop.AddUPoint( dAngStep ++, ptLeft) ; // ultimo punto
|
|
||||||
plLoop.AddUPoint( dAngStep ++, ptJunction) ; // punto centrale sull'offset chiuso
|
|
||||||
plLoop.AddUPoint( dAngStep, ptRight) ; // polyLine chiusa
|
|
||||||
// superificie Top
|
|
||||||
PtrOwner<ISurfTriMesh> pStmTop( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmTop) || ! pStmTop->CreateByFlatContour( plLoop))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmTop) ;
|
|
||||||
// superificie Bottom
|
|
||||||
PtrOwner<ISurfTriMesh> pStmBottom( CloneSurfTriMesh( pStmTop)) ;
|
|
||||||
pStmBottom->Translate( - dDimV * vtNorm) ;
|
|
||||||
pStmBottom->Invert() ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmBottom) ;
|
|
||||||
// superificie perpendicolare
|
|
||||||
// la PolyLine che utilizzo la posso ricavare da quella calcolata sopra
|
|
||||||
plLoop.EraseLastUPoint() ; // apro il loop
|
|
||||||
plLoop.EraseLastUPoint() ; // tolgo il punto di contatto sull'offset
|
|
||||||
PtrOwner<ISurfTriMesh> pStmPerp( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmPerp) || ! pStmPerp->CreateByExtrusion( plLoop, - vtNorm * dDimV) ||
|
|
||||||
! pStmPerp->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmPerp) ;
|
|
||||||
}
|
|
||||||
// se l'offset interno della guida è aperto...
|
|
||||||
else {
|
|
||||||
// aggiungo il cap sull'inizio
|
|
||||||
Point3d ptStart ;
|
|
||||||
pGuide->GetStartPoint( ptStart) ;
|
|
||||||
// calcolo l'angolo di rotazione per screwing faccia Top e Bottom
|
|
||||||
Point3d ptSLeft ; pCrvL->GetStartPoint( ptSLeft) ;
|
|
||||||
Point3d ptSRight ; pCrvR->GetStartPoint( ptSRight) ;
|
|
||||||
Vector3d vtLeft = ptSLeft - ptStart ;
|
|
||||||
Vector3d vtRight = ptSRight - ptStart ;
|
|
||||||
double dAng = ANG_STRAIGHT ;
|
|
||||||
vtLeft.GetAngle( vtRight, dAng) ;
|
|
||||||
vtLeft.Normalize() ;
|
|
||||||
PolyLine plLoop ;
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
plLoop.AddUPoint( 0, ptSLeft) ; // primo punto
|
|
||||||
double dAngStep = ceil( dAng / dStepRotDeg) ;
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptSLeft ;
|
|
||||||
ptRot.Rotate( ptStart, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoop.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoop.AddUPoint( dAngStep, ptSRight) ; // ultimo punto
|
|
||||||
plLoop.AddUPoint( dAngStep + 1, ptSLeft) ; // polyline chiusa
|
|
||||||
// creo la superficie Top
|
|
||||||
PtrOwner<ISurfTriMesh> pStmTop_start( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmTop_start) || ! pStmTop_start->CreateByFlatContour( plLoop))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmTop_start) ;
|
|
||||||
// superificie Bottom
|
|
||||||
PtrOwner<ISurfTriMesh> pStmBottom_start( CloneSurfTriMesh( pStmTop_start)) ;
|
|
||||||
pStmBottom_start->Translate( - dDimV * vtNorm) ;
|
|
||||||
pStmBottom_start->Invert() ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmBottom_start) ;
|
|
||||||
// superificie perpendicolare
|
|
||||||
// la PolyLine che utilizzo la posso ricavare da quella calcolata sopra
|
|
||||||
plLoop.EraseLastUPoint() ; // apro il loop
|
|
||||||
PtrOwner<ISurfTriMesh> pStmPerp_start( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmPerp_start) || ! pStmPerp_start->CreateByExtrusion( plLoop, - vtNorm * dDimV) ||
|
|
||||||
! pStmPerp_start->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmPerp_start) ;
|
|
||||||
// aggiungo il cap sulla fine
|
|
||||||
Point3d ptEnd ;
|
|
||||||
pGuide->GetEndPoint( ptEnd) ;
|
|
||||||
// calcolo l'angolo di rotazione per screwing faccia Top e Bottom
|
|
||||||
pCrvL->GetEndPoint( ptSLeft) ;
|
|
||||||
pCrvR->GetEndPoint( ptSRight) ;
|
|
||||||
vtLeft = ptSLeft - ptEnd ;
|
|
||||||
vtRight = ptSRight - ptEnd ;
|
|
||||||
dAng = ANG_STRAIGHT ;
|
|
||||||
vtRight.GetAngle( vtLeft, dAng) ;
|
|
||||||
vtRight.Normalize() ;
|
|
||||||
plLoop.Clear() ;
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
plLoop.AddUPoint( 0, ptSRight) ;
|
|
||||||
dAngStep = ceil( dAng / dStepRotDeg) ; // primo punto
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptSRight ;
|
|
||||||
ptRot.Rotate( ptEnd, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoop.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoop.AddUPoint( dAngStep, ptSLeft) ; // ultimo punto
|
|
||||||
plLoop.AddUPoint( dAngStep + 1, ptSRight) ; // polyline chiusa
|
|
||||||
// creo la superficie Top
|
|
||||||
PtrOwner<ISurfTriMesh> pStmTop_end( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmTop_end) || ! pStmTop_end->CreateByFlatContour( plLoop))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmTop_end) ;
|
|
||||||
// creo la superificie Bottom
|
|
||||||
PtrOwner<ISurfTriMesh> pStmBottom_end( CloneSurfTriMesh( pStmTop_end)) ;
|
|
||||||
pStmBottom_end->Translate( - dDimV * vtNorm) ;
|
|
||||||
pStmBottom_end->Invert() ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmBottom_end) ;
|
|
||||||
// creo la superificie perpendicolare alla guida
|
|
||||||
plLoop.EraseLastUPoint() ; // apro il loop
|
|
||||||
PtrOwner<ISurfTriMesh> pStmPerp_end( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmPerp_end) || ! pStmPerp_end->CreateByExtrusion( plLoop, - vtNorm * dDimV) ||
|
|
||||||
! pStmPerp_end->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmPerp_end) ;
|
|
||||||
}
|
|
||||||
// completo unione e recupero la superficie risultante
|
|
||||||
if ( ! stmSoup.End())
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pSTM.Set( stmSoup.GetSurf()) ;
|
pSci->Invert() ;
|
||||||
}
|
pSTM->DoSewing( *pSci) ;
|
||||||
else {
|
// aggiungo il cap sulla fine
|
||||||
// completo unione e recupero la superficie risultante
|
Point3d ptEnd ;
|
||||||
if ( ! stmSoup.End())
|
pGuide->GetEndPoint( ptEnd) ;
|
||||||
|
Vector3d vtEnd ;
|
||||||
|
pGuide->GetEndDir( vtEnd) ;
|
||||||
|
vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||||
|
PolyLine PLEnd ;
|
||||||
|
PLEnd.AddUPoint( 0, ptEnd) ;
|
||||||
|
PLEnd.AddUPoint( 1, ptEnd + dDimH / 2 * vtEnd) ;
|
||||||
|
PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dDimV * vtNorm) ;
|
||||||
|
PLEnd.AddUPoint( 3, ptEnd - dDimV * vtNorm) ;
|
||||||
|
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||||
|
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pSTM.Set( stmSoup.GetSurf()) ;
|
pSce->Invert() ;
|
||||||
|
pSTM->DoSewing( *pSce) ;
|
||||||
}
|
}
|
||||||
// salvo tolleranza lineare usata e imposto angolo per smooth
|
|
||||||
pSTM->SetLinearTolerance( dLinTol) ;
|
|
||||||
pSTM->SetSmoothAngle( 20) ;
|
|
||||||
// restituisco la superficie
|
// restituisco la superficie
|
||||||
return Release( pSTM) ;
|
return Release( pSTM) ;
|
||||||
}
|
}
|
||||||
@@ -582,13 +445,13 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
|||||||
|
|
||||||
// verifico che la linea guida sia piana
|
// verifico che la linea guida sia piana
|
||||||
Plane3d plGuide ;
|
Plane3d plGuide ;
|
||||||
if ( ! pGuide->IsFlat( plGuide, true, 10 * EPS_SMALL))
|
if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
Vector3d vtNorm ; pGuide->GetExtrusion( vtNorm) ;
|
// assegno la normale del piano
|
||||||
if ( vtNorm.IsSmall())
|
Vector3d vtNorm = plGuide.GetVersN() ;
|
||||||
vtNorm = Z_AX ;
|
|
||||||
// determino il punto centrale della sezione
|
// determino il punto centrale della sezione
|
||||||
Point3d ptCen ; pGuide->GetStartPoint( ptCen) ;
|
Point3d ptCen ;
|
||||||
|
pGuide->GetStartPoint( ptCen) ;
|
||||||
ptCen -= dDimV / 2 * vtNorm ;
|
ptCen -= dDimV / 2 * vtNorm ;
|
||||||
// determino se la guida è chiusa
|
// determino se la guida è chiusa
|
||||||
bool bGuideClosed = pGuide->IsClosed() ;
|
bool bGuideClosed = pGuide->IsClosed() ;
|
||||||
@@ -617,6 +480,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
|||||||
for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i)
|
for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i)
|
||||||
bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! bOk ||
|
if ( ! bOk ||
|
||||||
vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 ||
|
vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 ||
|
||||||
vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0)
|
vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0)
|
||||||
@@ -685,6 +549,10 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
|||||||
if ( ! stmSoup.End())
|
if ( ! stmSoup.End())
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pSTM.Set( stmSoup.GetSurf()) ;
|
pSTM.Set( stmSoup.GetSurf()) ;
|
||||||
|
// preparo seconda zuppa di triangoli per inserire i tappi
|
||||||
|
StmFromTriangleSoup stmCapSoup ;
|
||||||
|
if ( ! stmCapSoup.Start( nBuckets))
|
||||||
|
return nullptr ;
|
||||||
// verifico che le due estremità siano chiuse e piatte
|
// verifico che le due estremità siano chiuse e piatte
|
||||||
POLYLINEVECTOR vPL ;
|
POLYLINEVECTOR vPL ;
|
||||||
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||||
@@ -712,236 +580,42 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
|||||||
else if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
else if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||||
// step di rotazione per rispettare il tipo o la tolleranza
|
// step di rotazione per rispettare il tipo o la tolleranza
|
||||||
double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||||
// se l'offset interno della guida è chiuso...
|
// aggiungo il cap sull'inizio
|
||||||
if ( pCrvL->IsClosed()) {
|
Point3d ptStart ;
|
||||||
// calcolo l'angolo di rotazione per screwing faccia Top e Bottom
|
pGuide->GetStartPoint( ptStart) ;
|
||||||
Point3d ptRight ; pCrvR->GetEndPoint( ptRight) ;
|
Vector3d vtStart ;
|
||||||
Point3d ptLeft ; pCrvR->GetStartPoint( ptLeft) ;
|
pGuide->GetStartDir( vtStart) ;
|
||||||
Point3d ptJunction ; pCrvL->GetStartPoint( ptJunction) ;
|
vtStart.Rotate( vtNorm, 0, 1) ;
|
||||||
Point3d ptCenter = Media( ptRight, ptLeft) ;
|
PolyLine PLStart ;
|
||||||
Vector3d vtRight = ptRight - ptCenter ;
|
PLStart.AddUPoint( 0, ptStart) ;
|
||||||
Vector3d vtLeft = ptLeft - ptCenter ;
|
PLStart.AddUPoint( 1, ptStart + ( dDimH / 2 - dBevelH) * vtStart) ;
|
||||||
double dAng = ANG_STRAIGHT ;
|
PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dBevelV * vtNorm) ;
|
||||||
vtRight.GetAngle( vtLeft, dAng) ;
|
PLStart.AddUPoint( 3, ptStart + dDimH / 2 * vtStart - ( dDimV - dBevelV) * vtNorm) ;
|
||||||
vtRight.Normalize() ;
|
PLStart.AddUPoint( 4, ptStart + ( dDimH / 2 - dBevelH) * vtStart - dDimV * vtNorm) ;
|
||||||
PolyLine plLoop ;
|
PLStart.AddUPoint( 5, ptStart - dDimV * vtNorm) ;
|
||||||
// creo il loop defininendo i punti
|
PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||||
plLoop.AddUPoint( 0, ptRight) ; // primo punto
|
if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||||
double dAngStep = ceil( dAng / dStepRotDeg) ; // aggiusto lo step
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptRight ;
|
|
||||||
ptRot.Rotate( ptCenter, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoop.AddUPoint( i, ptRot) ; // punto intermedio sulla circonferenza
|
|
||||||
}
|
|
||||||
plLoop.AddUPoint( dAngStep ++, ptLeft) ; // ultimo punto
|
|
||||||
plLoop.AddUPoint( dAngStep ++, ptJunction) ; // punto centrale sull'offset chiuso
|
|
||||||
plLoop.AddUPoint( dAngStep, ptRight) ; // polyLine chiusa
|
|
||||||
// superificie Top
|
|
||||||
PtrOwner<ISurfTriMesh> pStmTop( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmTop) || ! pStmTop->CreateByFlatContour( plLoop))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmTop) ;
|
|
||||||
// superificie Bottom
|
|
||||||
PtrOwner<ISurfTriMesh> pStmBottom( CloneSurfTriMesh( pStmTop)) ;
|
|
||||||
if ( IsNull( pStmBottom) || ! pStmBottom->Mirror( ptCen, vtNorm))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmBottom) ;
|
|
||||||
// calcolo l'angolo di rotazione per la faccia Top del bevel
|
|
||||||
// NB. Questo angolo va ricalcolato, il bevel è inclinato rispetto alla normale della guida
|
|
||||||
ptCenter.Translate( - dBevelV * vtNorm) ;
|
|
||||||
Point3d ptbRight ; pCrvRb->GetEndPoint( ptbRight) ;
|
|
||||||
Point3d ptbLeft ; pCrvRb->GetStartPoint( ptbLeft) ;
|
|
||||||
Vector3d vtbLeft = ptbLeft - ptCenter ;
|
|
||||||
Vector3d vtbRight = ptbRight - ptCenter ;
|
|
||||||
dAng = ANG_STRAIGHT ;
|
|
||||||
vtbRight.GetAngle( vtbLeft, dAng) ;
|
|
||||||
vtbRight.Normalize() ;
|
|
||||||
// la PolyLine che utilizzo la posso ricavare da quella calcolata sopra
|
|
||||||
plLoop.EraseLastUPoint() ; // apro il loop
|
|
||||||
plLoop.EraseLastUPoint() ; // tolgo il punto di contatto sull'offset
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
PolyLine plLoopB ;
|
|
||||||
plLoopB.AddUPoint( 0, ptbRight) ;
|
|
||||||
dAngStep = ceil( dAng / dStepRotDeg) ;
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptbRight ;
|
|
||||||
ptRot.Rotate( ptCenter, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoopB.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoopB.AddUPoint( dAngStep, ptbLeft) ;
|
|
||||||
// creo la superficie Top Bevel
|
|
||||||
PtrOwner<ISurfTriMesh> pStmbTop_start( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmbTop_start) ||
|
|
||||||
! pStmbTop_start->CreateByTwoCurves( plLoop, plLoopB, ISurfTriMesh::RLT_MINDIST) ||
|
|
||||||
! pStmbTop_start->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmbTop_start) ;
|
|
||||||
// creo la superificie Bottom Bevel
|
|
||||||
PtrOwner<ISurfTriMesh> pStmbBottom_start( CloneSurfTriMesh( pStmbTop_start)) ;
|
|
||||||
if ( IsNull( pStmbBottom_start) || ! pStmbBottom_start->Mirror( ptCen, vtNorm))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmbBottom_start) ;
|
|
||||||
// creo la superficie perpendicolare alla guida
|
|
||||||
PolyLine plLoopB1 = plLoopB ;
|
|
||||||
plLoopB1.Mirror( ptCen, vtNorm) ;
|
|
||||||
PtrOwner<ISurfTriMesh> pStmPerp( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmPerp) ||
|
|
||||||
! pStmPerp->CreateByTwoCurves( plLoopB, plLoopB1, ISurfTriMesh::RLT_MINDIST) ||
|
|
||||||
! pStmPerp->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmPerp) ;
|
|
||||||
}
|
|
||||||
// se l'offset interno della guida è aperto...
|
|
||||||
else {
|
|
||||||
// aggiungo il cap sull'inizio
|
|
||||||
Point3d ptStart ;
|
|
||||||
pGuide->GetStartPoint( ptStart) ;
|
|
||||||
// calcolo l'angolo di rotazione per screwing faccia Top e Bottom
|
|
||||||
Point3d ptSLeft ; pCrvL->GetStartPoint( ptSLeft) ;
|
|
||||||
Point3d ptSRight ; pCrvR->GetStartPoint( ptSRight) ;
|
|
||||||
Vector3d vtLeft = ptSLeft - ptStart ;
|
|
||||||
Vector3d vtRight = ptSRight - ptStart ;
|
|
||||||
double dAng = ANG_STRAIGHT ;
|
|
||||||
vtLeft.GetAngle( vtRight, dAng) ;
|
|
||||||
vtLeft.Normalize() ;
|
|
||||||
PolyLine plLoop ;
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
plLoop.AddUPoint( 0, ptSLeft) ; // primo punto
|
|
||||||
double dAngStep = ceil( dAng / dStepRotDeg) ;
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptSLeft ;
|
|
||||||
ptRot.Rotate( ptStart, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoop.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoop.AddUPoint( dAngStep, ptSRight) ; // ultimo punto
|
|
||||||
plLoop.AddUPoint( dAngStep + 1, ptSLeft) ; // polyline chiusa
|
|
||||||
// creo la superficie Top
|
|
||||||
PtrOwner<ISurfTriMesh> pStmTop_start( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmTop_start) || ! pStmTop_start->CreateByFlatContour( plLoop))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmTop_start) ;
|
|
||||||
// creo la superificie Bottom
|
|
||||||
PtrOwner<ISurfTriMesh> pStmBottom_start( CloneSurfTriMesh( pStmTop_start)) ;
|
|
||||||
if ( IsNull( pStmBottom_start) || ! pStmBottom_start->Mirror( ptCen, vtNorm))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmBottom_start) ;
|
|
||||||
// calcolo l'angolo di rotazione per la faccia Top del bevel
|
|
||||||
ptStart.Translate( - dBevelV * vtNorm) ;
|
|
||||||
Point3d ptSbLeft ; pCrvLb->GetStartPoint( ptSbLeft) ;
|
|
||||||
Point3d ptSbRight ; pCrvRb->GetStartPoint( ptSbRight) ;
|
|
||||||
Vector3d vtbLeft = ptSbLeft - ptStart ;
|
|
||||||
Vector3d vtbRight = ptSbRight - ptStart ;
|
|
||||||
dAng = ANG_STRAIGHT ;
|
|
||||||
vtbLeft.GetAngle( vtbRight, dAng) ;
|
|
||||||
vtbLeft.Normalize() ;
|
|
||||||
plLoop.EraseLastUPoint() ; // apro il loop
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
PolyLine plLoopB ;
|
|
||||||
plLoopB.AddUPoint( 0, ptSbLeft) ;
|
|
||||||
dAngStep = ceil( dAng / dStepRotDeg) ; // primo punto
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptSbLeft ;
|
|
||||||
ptRot.Rotate( ptStart, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoopB.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoopB.AddUPoint( dAngStep, ptSbRight) ; // ultimo punto
|
|
||||||
// creo la superficie Top Bevel
|
|
||||||
PtrOwner<ISurfTriMesh> pStmbTop_start( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmbTop_start) ||
|
|
||||||
! pStmbTop_start->CreateByTwoCurves( plLoop, plLoopB, ISurfTriMesh::RLT_MINDIST) ||
|
|
||||||
! pStmbTop_start->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmbTop_start) ;
|
|
||||||
// creo la superificie Bottom Bevel
|
|
||||||
PtrOwner<ISurfTriMesh> pStmbBottom_start( CloneSurfTriMesh( pStmbTop_start)) ;
|
|
||||||
if ( IsNull( pStmbBottom_start) || ! pStmbBottom_start->Mirror( ptCen, vtNorm))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmbBottom_start) ;
|
|
||||||
// creo la superficie perpendicolare alla guida
|
|
||||||
PolyLine plLoopB1 = plLoopB ;
|
|
||||||
plLoopB1.Mirror( ptCen, vtNorm) ;
|
|
||||||
PtrOwner<ISurfTriMesh> pStmPerp_start( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmPerp_start) ||
|
|
||||||
! pStmPerp_start->CreateByTwoCurves( plLoopB, plLoopB1, ISurfTriMesh::RLT_MINDIST) ||
|
|
||||||
! pStmPerp_start->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmPerp_start) ;
|
|
||||||
// aggiungo il cap sulla fine
|
|
||||||
Point3d ptEnd ;
|
|
||||||
pGuide->GetEndPoint( ptEnd) ;
|
|
||||||
// calcolo l'angolo di rotazione per screwing faccia Top e Bottom
|
|
||||||
pCrvL->GetEndPoint( ptSLeft) ;
|
|
||||||
pCrvR->GetEndPoint( ptSRight) ;
|
|
||||||
vtLeft = ptSLeft - ptEnd ;
|
|
||||||
vtRight = ptSRight - ptEnd ;
|
|
||||||
dAng = ANG_STRAIGHT ;
|
|
||||||
vtRight.GetAngle( vtLeft, dAng) ;
|
|
||||||
vtRight.Normalize() ;
|
|
||||||
plLoop.Clear() ;
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
plLoop.AddUPoint( 0, ptSRight) ;
|
|
||||||
dAngStep = ceil( dAng / dStepRotDeg) ; // primo punto
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptSRight ;
|
|
||||||
ptRot.Rotate( ptEnd, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoop.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoop.AddUPoint( dAngStep, ptSLeft) ; // ultimo punto
|
|
||||||
plLoop.AddUPoint( dAngStep + 1, ptSRight) ; // polyline chiusa
|
|
||||||
// creo la superficie Top
|
|
||||||
PtrOwner<ISurfTriMesh> pStmTop_end( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmTop_end) || ! pStmTop_end->CreateByFlatContour( plLoop))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmTop_end) ;
|
|
||||||
// creo la superificie Bottom
|
|
||||||
PtrOwner<ISurfTriMesh> pStmBottom_end( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmBottom_end) ||
|
|
||||||
! pStmBottom_end->CopyFrom( pStmTop_end) ||
|
|
||||||
! pStmBottom_end->Mirror( ptCen, vtNorm))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmBottom_end) ;
|
|
||||||
// calcolo l'angolo di rotazione per la faccia Top del bevel
|
|
||||||
ptEnd.Translate( - dBevelV * vtNorm) ;
|
|
||||||
pCrvLb->GetEndPoint( ptSbLeft) ;
|
|
||||||
pCrvRb->GetEndPoint( ptSbRight) ;
|
|
||||||
vtbLeft = ptSbLeft - ptEnd ;
|
|
||||||
vtbRight = ptSbRight - ptEnd ;
|
|
||||||
dAng = ANG_STRAIGHT ;
|
|
||||||
vtbRight.GetAngle( vtbLeft, dAng) ;
|
|
||||||
vtbRight.Normalize() ;
|
|
||||||
plLoop.EraseLastUPoint() ; // apro il loop
|
|
||||||
// creo il loop defininendo i punti
|
|
||||||
plLoopB.Clear() ;
|
|
||||||
plLoopB.AddUPoint( 0, ptSbRight) ;
|
|
||||||
dAngStep = ceil( dAng / dStepRotDeg) ; // primo punto
|
|
||||||
for ( int i = 1 ; i < dAngStep ; ++ i) {
|
|
||||||
Point3d ptRot = ptSbRight ;
|
|
||||||
ptRot.Rotate( ptEnd, vtNorm, i * ( dAng / dAngStep)) ;
|
|
||||||
plLoopB.AddUPoint( i, ptRot) ;
|
|
||||||
}
|
|
||||||
plLoopB.AddUPoint( dAngStep, ptSbLeft) ; // ultimo punto
|
|
||||||
// creo la superficie Top Bevel
|
|
||||||
PtrOwner<ISurfTriMesh> pStmbTop_end( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmbTop_end) ||
|
|
||||||
! pStmbTop_end->CreateByTwoCurves( plLoop, plLoopB, ISurfTriMesh::RLT_MINDIST) ||
|
|
||||||
! pStmbTop_end->Invert())
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmbTop_end) ;
|
|
||||||
// creo la superificie Bottom Bevel
|
|
||||||
PtrOwner<ISurfTriMesh> pStmbBottom_end( CloneSurfTriMesh( pStmbTop_end)) ;
|
|
||||||
if ( IsNull( pStmbBottom_end) || ! pStmbBottom_end->Mirror( ptCen, vtNorm))
|
|
||||||
return nullptr ;
|
|
||||||
stmSoup.AddSurfTriMesh( *pStmbBottom_end) ;
|
|
||||||
// creo la superficie perpendicolare alla guida
|
|
||||||
plLoopB1 = plLoopB ;
|
|
||||||
plLoopB1.Mirror( ptCen, vtNorm) ;
|
|
||||||
PtrOwner<ISurfTriMesh> pStmPerp_end( CreateSurfTriMesh()) ;
|
|
||||||
if ( IsNull( pStmPerp_end) ||
|
|
||||||
! pStmPerp_end->CreateByTwoCurves( plLoopB, plLoopB1, ISurfTriMesh::RLT_MINDIST) ||
|
|
||||||
! pStmPerp_end->Invert())
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
stmSoup.AddSurfTriMesh( *pStmPerp_end) ;
|
pSci->Invert() ;
|
||||||
}
|
stmSoup.AddSurfTriMesh( *pSci) ;
|
||||||
|
// aggiungo il cap sulla fine
|
||||||
|
Point3d ptEnd ;
|
||||||
|
pGuide->GetEndPoint( ptEnd) ;
|
||||||
|
Vector3d vtEnd ;
|
||||||
|
pGuide->GetEndDir( vtEnd) ;
|
||||||
|
vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||||
|
PolyLine PLEnd ;
|
||||||
|
PLEnd.AddUPoint( 0, ptEnd) ;
|
||||||
|
PLEnd.AddUPoint( 1, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd) ;
|
||||||
|
PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dBevelV * vtNorm) ;
|
||||||
|
PLEnd.AddUPoint( 3, ptEnd + dDimH / 2 * vtEnd - ( dDimV - dBevelV) * vtNorm) ;
|
||||||
|
PLEnd.AddUPoint( 4, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd - dDimV * vtNorm) ;
|
||||||
|
PLEnd.AddUPoint( 5, ptEnd - dDimV * vtNorm) ;
|
||||||
|
PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||||
|
if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||||
|
return nullptr ;
|
||||||
|
pSce->Invert() ;
|
||||||
|
stmSoup.AddSurfTriMesh( *pSce) ;
|
||||||
// completo unione e recupero la superficie risultante
|
// completo unione e recupero la superficie risultante
|
||||||
if ( ! stmSoup.End())
|
if ( ! stmSoup.End())
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
@@ -960,7 +634,6 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub
|
|||||||
return Release( pSTM) ;
|
return Release( pSTM) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
ISurfTriMesh*
|
ISurfTriMesh*
|
||||||
GetSurfTriMeshRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol)
|
GetSurfTriMeshRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol)
|
||||||
@@ -1301,8 +974,7 @@ GetSurfTriMeshSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, cons
|
|||||||
}
|
}
|
||||||
// creo il cap sull'inizio e lo attacco alla swept ( è già in posizione giusta)
|
// creo il cap sull'inizio e lo attacco alla swept ( è già in posizione giusta)
|
||||||
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||||
INTMATRIX vnPLIndMat ;
|
if ( ! pSci->CreateByRegion( vPLi))
|
||||||
if ( ! pSci->CreateByRegion( vPLi, vnPLIndMat))
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
pStmSwept->DoSewing( *pSci) ;
|
pStmSwept->DoSewing( *pSci) ;
|
||||||
// recupero i loops alla fine
|
// recupero i loops alla fine
|
||||||
@@ -1311,8 +983,7 @@ GetSurfTriMeshSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, cons
|
|||||||
return nullptr ;
|
return nullptr ;
|
||||||
// creo la superficie alla fine e la attacco
|
// creo la superficie alla fine e la attacco
|
||||||
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||||
vnPLIndMat.clear() ;
|
if ( ! pSce->CreateByRegion( vPLe))
|
||||||
if ( ! pSce->CreateByRegion( vPLe, vnPLIndMat))
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
// attacco la superficie finale alla swept
|
// attacco la superficie finale alla swept
|
||||||
pSce->Invert() ;
|
pSce->Invert() ;
|
||||||
@@ -1456,3 +1127,138 @@ GetSurfTriMeshRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, do
|
|||||||
// restituisco la superficie
|
// restituisco la superficie
|
||||||
return Release( pSTM) ;
|
return Release( pSTM) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol,
|
||||||
|
POLYLINEVECTOR& vPL, Vector3d& vtN)
|
||||||
|
{
|
||||||
|
// se non ho curve, non faccio nulla
|
||||||
|
if ( int( vpCurve.size()) == 0)
|
||||||
|
return true ;
|
||||||
|
|
||||||
|
// calcolo le polilinee che approssimano le curve
|
||||||
|
vPL.resize( vpCurve.size()) ;
|
||||||
|
for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) {
|
||||||
|
if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPL[i]))
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ricavo versore normale
|
||||||
|
Plane3d plPlane ; double dArea ;
|
||||||
|
if ( ! vPL[0].IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
|
||||||
|
return false ;
|
||||||
|
vtN = plPlane.GetVersN() ;
|
||||||
|
|
||||||
|
typedef std::pair<int,double> INDAREA ;
|
||||||
|
std::vector<INDAREA> m_vArea ;
|
||||||
|
// calcolo piano medio e area delle curve
|
||||||
|
m_vArea.reserve( vPL.size()) ;
|
||||||
|
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||||
|
// calcolo piano medio e area
|
||||||
|
Plane3d plPlane ;
|
||||||
|
double dArea ;
|
||||||
|
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea))
|
||||||
|
return false ;
|
||||||
|
// verifico che le normali siano molto vicine
|
||||||
|
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN))
|
||||||
|
return false ;
|
||||||
|
// assegno il segno all'area secondo il verso della normale
|
||||||
|
if ( ( plPlane.GetVersN() * vtN) > 0)
|
||||||
|
m_vArea.emplace_back( i, dArea) ;
|
||||||
|
else
|
||||||
|
m_vArea.emplace_back( i, - dArea) ;
|
||||||
|
}
|
||||||
|
// ordino in senso decrescente sull'area
|
||||||
|
sort( m_vArea.begin(), m_vArea.end(),
|
||||||
|
[]( const INDAREA& a, const INDAREA& b) { return ( abs( a.second) > abs( b.second)) ; }) ;
|
||||||
|
|
||||||
|
// dalle PolyLine passo alle curve nel piano XY ( prendo la prima come riferimento, trascuro le Z delle successive)
|
||||||
|
Frame3d frRef ; frRef.Set( ORIG, vtN) ;
|
||||||
|
if ( ! frRef.IsValid())
|
||||||
|
return false ;
|
||||||
|
ICRVCOMPOPOVECTOR vCrvCompo( int( vPL.size())) ;
|
||||||
|
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||||
|
vCrvCompo[i].Set( CreateCurveComposite()) ;
|
||||||
|
vCrvCompo[i]->FromPolyLine( vPL[i]) ;
|
||||||
|
vCrvCompo[i]->ToLoc( frRef) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// creo una matrice di interi ; ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle
|
||||||
|
// successive i loop interni
|
||||||
|
INTMATRIX vnPLIndMat ;
|
||||||
|
|
||||||
|
// vettore di indici per ordinare le PolyLine
|
||||||
|
INTVECTOR vPL_IndOrder ; vPL_IndOrder.resize( int( vPL.size())) ;
|
||||||
|
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i)
|
||||||
|
vPL_IndOrder[i] = m_vArea[i].first ;
|
||||||
|
|
||||||
|
// aggiungo le diverse curve
|
||||||
|
bool bFirstCrv ;
|
||||||
|
Plane3d plExtLoop ;
|
||||||
|
double dAreaExtLoop = 0. ;
|
||||||
|
do {
|
||||||
|
bFirstCrv = true ;
|
||||||
|
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i) {
|
||||||
|
// recupero indice di percorso e verifico sia valido
|
||||||
|
int j = m_vArea[i].first ;
|
||||||
|
if ( j < 0)
|
||||||
|
continue ;
|
||||||
|
// lo inserisco come esterno...
|
||||||
|
if ( bFirstCrv) {
|
||||||
|
vnPLIndMat.push_back({ j}) ;
|
||||||
|
m_vArea[i].first = -1 ;
|
||||||
|
dAreaExtLoop = m_vArea[i].second ;
|
||||||
|
// inverto se necessario
|
||||||
|
if ( m_vArea[i].second < EPS_SMALL) {
|
||||||
|
vPL[j].Invert() ;
|
||||||
|
vCrvCompo[j]->Invert() ;
|
||||||
|
dAreaExtLoop *= -1 ;
|
||||||
|
}
|
||||||
|
bFirstCrv = false ;
|
||||||
|
}
|
||||||
|
// ... altrimenti verifico se il loop è interno o no
|
||||||
|
else {
|
||||||
|
// il loop è interno se è sia interno al loop esterno della riga di vnPLIndMat e allo stesso tempo
|
||||||
|
// esterno a tutti i loop già inseriti nella riga attuale.
|
||||||
|
// verifica rispetto loop esterno
|
||||||
|
IntersCurveCurve ccInt( *vCrvCompo[vnPLIndMat.back().front()], *vCrvCompo[j]) ;
|
||||||
|
CRVCVECTOR ccClass ;
|
||||||
|
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
||||||
|
! ccInt.GetCurveClassification( 1, EPS_SMALL, ccClass) ||
|
||||||
|
ccClass.empty() || ccClass[0].nClass != CRVC_IN)
|
||||||
|
continue ;
|
||||||
|
// verifica rispetto ai loop interni
|
||||||
|
bool bOk = true ;
|
||||||
|
for ( int k = 1 ; k < int( vnPLIndMat.back().size()) ; ++ k) {
|
||||||
|
IntersCurveCurve ccInt2( *vCrvCompo[vnPLIndMat.back()[k]], *vCrvCompo[j]) ;
|
||||||
|
CRVCVECTOR ccClass2 ;
|
||||||
|
if ( ccInt2.GetCrossOrOverlapIntersCount() > 0 ||
|
||||||
|
! ccInt2.GetCurveClassification( 1, EPS_SMALL, ccClass2) ||
|
||||||
|
ccClass2.empty() || ccClass2[0].nClass != CRVC_IN) {
|
||||||
|
bOk = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( bOk) {
|
||||||
|
// inserisco nella matrice
|
||||||
|
vnPLIndMat.back().push_back( j) ;
|
||||||
|
m_vArea[i].first = -1 ;
|
||||||
|
// inverto se necessario
|
||||||
|
if ( m_vArea[i].second * dAreaExtLoop > 0.) {
|
||||||
|
vPL[j].Invert() ;
|
||||||
|
vCrvCompo[j]->Invert() ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while ( ! bFirstCrv) ;
|
||||||
|
|
||||||
|
// ordino le PolyLine per area
|
||||||
|
POLYLINEVECTOR vPL_tmp ;
|
||||||
|
for ( int i = 0 ; i < int( vPL_IndOrder.size()) ; ++ i)
|
||||||
|
vPL_tmp.push_back( vPL[ vPL_IndOrder[i]]) ;
|
||||||
|
swap( vPL, vPL_tmp) ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|||||||
+2
-27
@@ -45,7 +45,6 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
|||||||
for( int j = 0 ; j < snData.nCPV ; ++j) {
|
for( int j = 0 ; j < snData.nCPV ; ++j) {
|
||||||
CNurbsData nuCurve ;
|
CNurbsData nuCurve ;
|
||||||
nuCurve.bPeriodic = true ;
|
nuCurve.bPeriodic = true ;
|
||||||
nuCurve.bRat = snData.bRat ;
|
|
||||||
nuCurve.nDeg = snData.nDegU ;
|
nuCurve.nDeg = snData.nDegU ;
|
||||||
nuCurve.vU = vU ;
|
nuCurve.vU = vU ;
|
||||||
// vettore dei punti di controllo
|
// vettore dei punti di controllo
|
||||||
@@ -64,23 +63,13 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
|||||||
nuCurve.vW = vWeCtrl ;
|
nuCurve.vW = vWeCtrl ;
|
||||||
// i punti dell' oggetto nuCurve devono essere in forma non omogenea
|
// i punti dell' oggetto nuCurve devono essere in forma non omogenea
|
||||||
if ( NurbsCurveCanonicalize( nuCurve)) { // se NurbsCurveCanonicalize ha restituito false (la curva potrebbe esserre un punto di polo) allora non modifico i punti e il vettore dei nodi della superficie
|
if ( NurbsCurveCanonicalize( nuCurve)) { // se NurbsCurveCanonicalize ha restituito false (la curva potrebbe esserre un punto di polo) allora non modifico i punti e il vettore dei nodi della superficie
|
||||||
if ( snData.mCP.size() != nuCurve.vCP.size() ) {
|
|
||||||
snData.mCP.resize( nuCurve.vCP.size()) ;
|
|
||||||
if( snData.bRat)
|
|
||||||
snData.mW.resize( nuCurve.vW.size()) ;
|
|
||||||
}
|
|
||||||
for ( int i = 0 ; i < snData.nCPU ; ++i) {
|
for ( int i = 0 ; i < snData.nCPU ; ++i) {
|
||||||
snData.mCP[i][j] = nuCurve.vCP[i] ;
|
snData.mCP[i][j] = nuCurve.vCP[i] ;
|
||||||
if( snData.bRat) {
|
|
||||||
snData.mW[i][j] = nuCurve.vW[i] ;
|
|
||||||
snData.mCP[i][j] *= nuCurve.vW[i] ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
snData.vU = nuCurve.vU ;
|
snData.vU = nuCurve.vU ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snData.bPeriodicU = false ;
|
snData.bPeriodicU = false ;
|
||||||
snData.nCPU = int( snData.mCP.size()) ;
|
|
||||||
}
|
}
|
||||||
if ( snData.bPeriodicV || ! snData.bClampedV) {
|
if ( snData.bPeriodicV || ! snData.bClampedV) {
|
||||||
bool bIsRational = snData.bRat ;
|
bool bIsRational = snData.bRat ;
|
||||||
@@ -94,7 +83,6 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
|||||||
for( int i = 0 ; i < snData.nCPU ; ++i) {
|
for( int i = 0 ; i < snData.nCPU ; ++i) {
|
||||||
CNurbsData nuCurve ;
|
CNurbsData nuCurve ;
|
||||||
nuCurve.bPeriodic = true ;
|
nuCurve.bPeriodic = true ;
|
||||||
nuCurve.bRat = snData.bRat ;
|
|
||||||
nuCurve.nDeg = snData.nDegV ;
|
nuCurve.nDeg = snData.nDegV ;
|
||||||
nuCurve.vU = vV ;
|
nuCurve.vU = vV ;
|
||||||
// vettore dei punti di controllo
|
// vettore dei punti di controllo
|
||||||
@@ -113,28 +101,15 @@ NurbsSurfaceCanonicalize( SNurbsSurfData& snData)
|
|||||||
nuCurve.vW = vWeCtrl ;
|
nuCurve.vW = vWeCtrl ;
|
||||||
// i punti dell' oggetto nuCurve devono essere in forma non omogenea
|
// i punti dell' oggetto nuCurve devono essere in forma non omogenea
|
||||||
if ( NurbsCurveCanonicalize( nuCurve)) { // se NurbsCurveCanonicalize ha restituito false (la curva potrebbe esserre un punto di polo) allora non modifico i punti e il vettore dei nodi della superficie
|
if ( NurbsCurveCanonicalize( nuCurve)) { // se NurbsCurveCanonicalize ha restituito false (la curva potrebbe esserre un punto di polo) allora non modifico i punti e il vettore dei nodi della superficie
|
||||||
if ( snData.mCP[i].size() != nuCurve.vCP.size()){
|
for ( int j = 0 ; j < snData.nCPV ; ++j ) {
|
||||||
snData.mCP[i].clear() ;
|
|
||||||
snData.mCP[i].resize( nuCurve.vCP.size()) ;
|
|
||||||
if ( snData.bRat ) {
|
|
||||||
snData.mW[i].clear() ;
|
|
||||||
snData.mW[i].resize( nuCurve.vW.size()) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ( int j = 0 ; j < int( nuCurve.vCP.size()) ; ++j ) {
|
|
||||||
snData.mCP[i][j] = nuCurve.vCP[j] ;
|
snData.mCP[i][j] = nuCurve.vCP[j] ;
|
||||||
if ( snData.bRat ) {
|
|
||||||
snData.mW[i][j] = nuCurve.vW[j] ;
|
|
||||||
snData.mCP[i][j] *= nuCurve.vW[j] ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
snData.vV = nuCurve.vU ;
|
snData.vV = nuCurve.vU ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snData.bPeriodicV = false ;
|
snData.bPeriodicV = false ;
|
||||||
snData.nCPV = int( snData.mCP[0].size()) ;
|
|
||||||
}
|
}
|
||||||
return true ;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|||||||
+221
-2080
File diff suppressed because it is too large
Load Diff
+3
-19
@@ -75,11 +75,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
|||||||
bool GetVolume( double& dVolume) const override
|
bool GetVolume( double& dVolume) const override
|
||||||
{ if ( &dVolume == nullptr)
|
{ if ( &dVolume == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
if( m_pSTM == nullptr)
|
|
||||||
GetAuxSurf() ;
|
|
||||||
dVolume = 0 ;
|
dVolume = 0 ;
|
||||||
if( m_pSTM != nullptr)
|
|
||||||
m_pSTM->GetVolume( dVolume) ;
|
|
||||||
return true ; }
|
return true ; }
|
||||||
bool GetCentroid( Point3d& ptCen) const override ;
|
bool GetCentroid( Point3d& ptCen) const override ;
|
||||||
bool Invert( void) override ;
|
bool Invert( void) override ;
|
||||||
@@ -139,15 +135,8 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
|||||||
bool IncreaseUV( Point3d& ptUV, Vector3d vtH , Point3d* ptUVCopy, bool bModifyOrig) const override ;
|
bool IncreaseUV( Point3d& ptUV, Vector3d vtH , Point3d* ptUVCopy, bool bModifyOrig) const override ;
|
||||||
// funzione che restituisce gli edge della superficie o in forma di linea spezzata o in forma di curva di Bezier
|
// funzione che restituisce gli edge della superficie o in forma di linea spezzata o in forma di curva di Bezier
|
||||||
// se la superficie è trimmata restituisce i loop dello spazio parametrico in forma di linee spezzate
|
// se la superficie è trimmata restituisce i loop dello spazio parametrico in forma di linee spezzate
|
||||||
bool GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge = -1) const override ; // se la superficie non è trimmata restituisce un vettore di 4 elementi. Se la superficie è chiusa lungo un parametro i lati algi estremi di quel parametro saranno null.
|
bool GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge = -1) const override ;
|
||||||
bool IsPlanar( void) const override ;
|
bool IsPlanar( void) const override ;
|
||||||
bool CreateByFlatContour( const PolyLine& PL) override ;
|
|
||||||
bool CreateByRegion( const POLYLINEVECTOR& vPL) override ;
|
|
||||||
bool CreateByExtrusion( const ICurve* pCurve, const Vector3d& vtExtr, bool bDeg3OrDeg2 = false) override ;
|
|
||||||
bool CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, double dMove) override ;
|
|
||||||
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 ;
|
|
||||||
|
|
||||||
public : // IGeoObjRW
|
public : // IGeoObjRW
|
||||||
int GetNgeId( void) const override ;
|
int GetNgeId( void) const override ;
|
||||||
@@ -170,7 +159,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
|||||||
private :
|
private :
|
||||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||||
enum ParDir { ON_U = 1, ON_V = 2} ;
|
enum ParDir { ON_U = 1, ON_V = 2} ;
|
||||||
static const int MAXDEG = 21 ;
|
static const int MAXDEG = 11 ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
bool CopyFrom( const SurfBezier& sbSrc) ;
|
bool CopyFrom( const SurfBezier& sbSrc) ;
|
||||||
@@ -200,15 +189,11 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
|||||||
double GetCurveOnVApproxLen( double dU) const ;
|
double GetCurveOnVApproxLen( double dU) const ;
|
||||||
// funzione che proietta nello spazio parametrico un trim derivante da un taglio con un piano, categorizzandolo come aperto o chiuso ( nel parametrico)
|
// funzione che proietta nello spazio parametrico un trim derivante da un taglio con un piano, categorizzandolo come aperto o chiuso ( nel parametrico)
|
||||||
bool AddCurveCompoToCuts( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCCOpen, ICRVCOMPOPOVECTOR& vpCCClosed, double dToler = EPS_SMALL, const Plane3d* pPlCut = nullptr) const ;
|
bool AddCurveCompoToCuts( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vpCCOpen, ICRVCOMPOPOVECTOR& vpCCClosed, double dToler = EPS_SMALL, const Plane3d* pPlCut = nullptr) const ;
|
||||||
ISurfFlatRegion* CreateTrimRegionFromCuts( ICRVCOMPOPOVECTOR& vpCCOpen, ICRVCOMPOPOVECTOR& vpCCClosed) const ;
|
|
||||||
// restituisce il singolo edge della superficie non trimmata
|
// restituisce il singolo edge della superficie non trimmata
|
||||||
ICurveComposite* GetSingleEdge3D( bool bLineOrBezier, int nEdge) const ;
|
ICurveComposite* GetSingleEdge3D( bool bLineOrBezier, int nEdge) const ;
|
||||||
bool UpdateEdgesFromTree( Tree& tr) const ;
|
bool UpdateEdgesFromTree( Tree& tr) const ;
|
||||||
// funzione che calcola se gli edge sono collassati in poli
|
// funzione che calcola se gli edge sono collassati in poli
|
||||||
bool CalcPoles( void) const ;
|
bool CalcPoles( void) ;
|
||||||
bool FindMatchByParam( const PolyLine& pl0, const PolyLine& pl1, INTVECTOR& vMatch, int& nLong) const ;
|
|
||||||
bool ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ;
|
|
||||||
bool ReorderPntEnhancedVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ;
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||||
@@ -230,7 +215,6 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
|||||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
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 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 ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
|
||||||
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
+24
-290
@@ -109,25 +109,18 @@ SurfFlatRegion::AddExtLoop( ICurve* pCrv)
|
|||||||
if ( ! AdjustLoops( Release( pMyCrv), CrvLst, true))
|
if ( ! AdjustLoops( Release( pMyCrv), CrvLst, true))
|
||||||
return false ;
|
return false ;
|
||||||
// aggiungo le singole curve
|
// aggiungo le singole curve
|
||||||
int nExtAdded = 0 ;
|
|
||||||
bool bOk = true ;
|
bool bOk = true ;
|
||||||
for ( auto& pSingCrv : CrvLst) {
|
for ( auto& pSingCrv : CrvLst) {
|
||||||
bool bAdded = false ;
|
if ( ! AddSimpleExtLoop( pSingCrv))
|
||||||
if ( AddSimpleExtLoop( pSingCrv, bAdded))
|
|
||||||
++ nExtAdded ;
|
|
||||||
else
|
|
||||||
bOk = false ;
|
bOk = false ;
|
||||||
|
|
||||||
}
|
}
|
||||||
return ( bOk && nExtAdded > 0) ;
|
return bOk ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv, bool& bAdded)
|
SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv)
|
||||||
{
|
{
|
||||||
// default
|
|
||||||
bAdded = false ;
|
|
||||||
// acquisisco la curva
|
// acquisisco la curva
|
||||||
PtrOwner<ICurve> pMyCrv( pCrv) ;
|
PtrOwner<ICurve> pMyCrv( pCrv) ;
|
||||||
if ( IsNull( pMyCrv))
|
if ( IsNull( pMyCrv))
|
||||||
@@ -140,8 +133,6 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv, bool& bAdded)
|
|||||||
Plane3d plPlane ;
|
Plane3d plPlane ;
|
||||||
if ( ! pMyCrv->GetArea( plPlane, dArea))
|
if ( ! pMyCrv->GetArea( plPlane, dArea))
|
||||||
return false ;
|
return false ;
|
||||||
if ( dArea < SQ_EPS_SMALL)
|
|
||||||
return true ;
|
|
||||||
// se sto costruendo il primo chunk
|
// se sto costruendo il primo chunk
|
||||||
if ( m_vExtInd.size() == 0) {
|
if ( m_vExtInd.size() == 0) {
|
||||||
// assegno il riferimento intrinseco
|
// assegno il riferimento intrinseco
|
||||||
@@ -207,7 +198,6 @@ SurfFlatRegion::AddSimpleExtLoop( ICurve* pCrv, bool& bAdded)
|
|||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
// imposto ricalcolo Voronoi
|
// imposto ricalcolo Voronoi
|
||||||
ResetVoronoiObject() ;
|
ResetVoronoiObject() ;
|
||||||
bAdded = true ;
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,6 +912,9 @@ SurfFlatRegion::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
|||||||
bool
|
bool
|
||||||
SurfFlatRegion::GetArea( double& dArea) const
|
SurfFlatRegion::GetArea( double& dArea) const
|
||||||
{
|
{
|
||||||
|
// controllo parametro di ritorno
|
||||||
|
if ( &dArea == nullptr)
|
||||||
|
return false ;
|
||||||
// inizio con area nulla
|
// inizio con area nulla
|
||||||
dArea = 0 ;
|
dArea = 0 ;
|
||||||
// la regione deve essere validata
|
// la regione deve essere validata
|
||||||
@@ -944,6 +937,9 @@ SurfFlatRegion::GetArea( double& dArea) const
|
|||||||
bool
|
bool
|
||||||
SurfFlatRegion::GetGrossArea( double& dArea) const
|
SurfFlatRegion::GetGrossArea( double& dArea) const
|
||||||
{
|
{
|
||||||
|
// controllo parametro di ritorno
|
||||||
|
if ( &dArea == nullptr)
|
||||||
|
return false ;
|
||||||
// inizio con area nulla
|
// inizio con area nulla
|
||||||
dArea = 0 ;
|
dArea = 0 ;
|
||||||
// la regione deve essere validata
|
// la regione deve essere validata
|
||||||
@@ -967,6 +963,9 @@ SurfFlatRegion::GetGrossArea( double& dArea) const
|
|||||||
bool
|
bool
|
||||||
SurfFlatRegion::GetCentroid( Point3d& ptCen) const
|
SurfFlatRegion::GetCentroid( Point3d& ptCen) const
|
||||||
{
|
{
|
||||||
|
// controllo parametro di ritorno
|
||||||
|
if ( &ptCen == nullptr)
|
||||||
|
return false ;
|
||||||
// la regione deve essere validata
|
// la regione deve essere validata
|
||||||
if ( m_nStatus != OK || m_vpLoop.empty())
|
if ( m_nStatus != OK || m_vpLoop.empty())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -992,20 +991,13 @@ SurfFlatRegion::GetCentroid( Point3d& ptCen) const
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int
|
|
||||||
SurfFlatRegion::GetChunkCount( void) const
|
|
||||||
{
|
|
||||||
// la regione deve essere validata
|
|
||||||
if ( m_nStatus != OK)
|
|
||||||
return 0 ;
|
|
||||||
return int( m_vExtInd.size()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfFlatRegion::GetChunkCentroid( int nChunk, Point3d& ptCen) const
|
SurfFlatRegion::GetChunkCentroid( int nChunk, Point3d& ptCen) const
|
||||||
{
|
{
|
||||||
|
// controllo parametro di ritorno
|
||||||
|
if ( &ptCen == nullptr)
|
||||||
|
return false ;
|
||||||
// la regione deve essere validata
|
// la regione deve essere validata
|
||||||
if ( m_nStatus != OK || m_vpLoop.empty())
|
if ( m_nStatus != OK || m_vpLoop.empty())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -1019,53 +1011,13 @@ SurfFlatRegion::GetChunkCentroid( int nChunk, Point3d& ptCen) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
int
|
||||||
SurfFlatRegion::GetChunkArea( int nChunk, double& dArea) const
|
SurfFlatRegion::GetChunkCount( void) const
|
||||||
{
|
{
|
||||||
// default, area nulla
|
|
||||||
dArea = 0 ;
|
|
||||||
// la regione deve essere validata
|
// la regione deve essere validata
|
||||||
if ( m_nStatus != OK || m_vpLoop.empty())
|
if ( m_nStatus != OK)
|
||||||
return false ;
|
return 0 ;
|
||||||
// il chunk deve esistere
|
return int( m_vExtInd.size()) ;
|
||||||
if ( nChunk < 0 || nChunk >= GetChunkCount())
|
|
||||||
return false ;
|
|
||||||
// calcolo l'area
|
|
||||||
bool bOk = true ;
|
|
||||||
for ( int nL = 0 ; nL < GetLoopCount( nChunk) ; ++ nL) {
|
|
||||||
const ICurve* pLoop = GetMyLoop( nChunk, nL) ;
|
|
||||||
double dLoopArea ;
|
|
||||||
if ( pLoop != nullptr && pLoop->GetAreaXY( dLoopArea))
|
|
||||||
dArea += dLoopArea ;
|
|
||||||
else
|
|
||||||
bOk = false ;
|
|
||||||
}
|
|
||||||
return bOk ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::GetChunkPerimeter( int nChunk, double& dLen) const
|
|
||||||
{
|
|
||||||
// default, perimetro nullo
|
|
||||||
dLen = 0 ;
|
|
||||||
// la regione deve essere validata
|
|
||||||
if ( m_nStatus != OK || m_vpLoop.empty())
|
|
||||||
return false ;
|
|
||||||
// il chunk deve esistere
|
|
||||||
if ( nChunk < 0 || nChunk >= GetChunkCount())
|
|
||||||
return false ;
|
|
||||||
// calcolo il perimetro
|
|
||||||
bool bOk = true ;
|
|
||||||
for ( int nL = 0 ; nL < GetLoopCount( nChunk) ; ++ nL) {
|
|
||||||
const ICurve* pLoop = GetMyLoop( nChunk, nL) ;
|
|
||||||
double dLoopLen ;
|
|
||||||
if ( pLoop != nullptr && pLoop->GetLength( dLoopLen))
|
|
||||||
dLen += dLoopLen ;
|
|
||||||
else
|
|
||||||
bOk = false ;
|
|
||||||
}
|
|
||||||
return bOk ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -1166,19 +1118,6 @@ SurfFlatRegion::GetLoop( int nChunk, int nLoop) const
|
|||||||
return pCrv ;
|
return pCrv ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int
|
|
||||||
SurfFlatRegion::GetLoopCurveCount( int nChunk, int nLoop) const
|
|
||||||
{
|
|
||||||
// recupero il loop nel riferimento intrinseco
|
|
||||||
const ICurve* pMyCrv = GetMyLoop( nChunk, nLoop) ;
|
|
||||||
if ( pMyCrv == nullptr)
|
|
||||||
return 0 ;
|
|
||||||
// restituisco il numero di curve di cui è composto
|
|
||||||
const ICurveComposite* pMyCompo = GetCurveComposite( pMyCrv) ;
|
|
||||||
return ( pMyCompo == nullptr ? 1 : pMyCompo->GetCurveCount()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfFlatRegion::ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const
|
SurfFlatRegion::ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const
|
||||||
@@ -1212,7 +1151,7 @@ SurfFlatRegion::CalcAuxSurf( double dLinTol, double dAngTolDeg) const
|
|||||||
POLYLINEVECTOR vPL ;
|
POLYLINEVECTOR vPL ;
|
||||||
vPL.resize( GetLoopCount( i)) ;
|
vPL.resize( GetLoopCount( i)) ;
|
||||||
int j = 0 ;
|
int j = 0 ;
|
||||||
ICurve* pLoop = GetMyLoop( i, j) ;
|
ICurve* pLoop = GetMyLoop( i, j) ;
|
||||||
while ( pLoop != nullptr) {
|
while ( pLoop != nullptr) {
|
||||||
// approssimo con linee a destra per non avere problemi in punti di contatto tra esterni e interni
|
// approssimo con linee a destra per non avere problemi in punti di contatto tra esterni e interni
|
||||||
if ( ! pLoop->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_RIGHT, vPL[j]))
|
if ( ! pLoop->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_RIGHT, vPL[j]))
|
||||||
@@ -1221,11 +1160,10 @@ SurfFlatRegion::CalcAuxSurf( double dLinTol, double dAngTolDeg) const
|
|||||||
}
|
}
|
||||||
// se chunk abbastanza grande, creo la superficie trimesh relativa
|
// se chunk abbastanza grande, creo la superficie trimesh relativa
|
||||||
double dArea ;
|
double dArea ;
|
||||||
if ( vPL[0].GetAreaXY( dArea) && dArea > 25 * SQ_EPS_SMALL) {
|
if ( vPL[0].GetAreaXY( dArea) && dArea > 100 * SQ_EPS_SMALL) {
|
||||||
// creo, setto la superficie trimesh ed elimino punti ripetuti
|
// creo, setto la superficie trimesh ed elimino punti ripetuti
|
||||||
PtrOwner<SurfTriMesh> pChSTM( CreateBasicSurfTriMesh()) ;
|
PtrOwner<SurfTriMesh> pChSTM( CreateBasicSurfTriMesh()) ;
|
||||||
INTMATRIX vnPLIndMat ;
|
if ( IsNull( pChSTM) || ! pChSTM->CreateByRegion( vPL) || ! pChSTM->DoCompacting())
|
||||||
if ( IsNull( pChSTM) || ! pChSTM->CreateByRegion( vPL, vnPLIndMat) || ! pChSTM->DoCompacting())
|
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
// porto la trimesh in globale al riferimento intrinseco
|
// porto la trimesh in globale al riferimento intrinseco
|
||||||
pChSTM->ToGlob( m_frF) ;
|
pChSTM->ToGlob( m_frF) ;
|
||||||
@@ -1233,10 +1171,7 @@ SurfFlatRegion::CalcAuxSurf( double dLinTol, double dAngTolDeg) const
|
|||||||
pSTM->DoSewing( *pChSTM) ;
|
pSTM->DoSewing( *pChSTM) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// se vuota
|
// la restituisco
|
||||||
if ( pSTM->IsEmpty())
|
|
||||||
pSTM->AdjustTopology() ;
|
|
||||||
// la restituisco
|
|
||||||
return Release( pSTM) ;
|
return Release( pSTM) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1291,56 +1226,6 @@ SurfFlatRegion::CloneChunk( int nChunk) const
|
|||||||
return Release( pSfr) ;
|
return Release( pSfr) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::EraseChunk(int nChunk)
|
|
||||||
{
|
|
||||||
// la regione deve essere validata
|
|
||||||
if ( m_nStatus != OK || m_vpLoop.empty())
|
|
||||||
return false ;
|
|
||||||
// il chunk deve esistere
|
|
||||||
if ( nChunk < 0 || nChunk >= GetChunkCount())
|
|
||||||
return false ;
|
|
||||||
// se un solo chunk, resetto la regione
|
|
||||||
if ( GetChunkCount() == 1) {
|
|
||||||
Clear() ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
// se ultimo chunk
|
|
||||||
if ( nChunk == m_vExtInd.size() - 1) {
|
|
||||||
// elimino i loop
|
|
||||||
for ( int i = m_vExtInd[nChunk] ; i < int( m_vpLoop.size()) ; ++ i) {
|
|
||||||
delete m_vpLoop[i] ;
|
|
||||||
m_vpLoop[i] = nullptr ;
|
|
||||||
}
|
|
||||||
m_vpLoop.erase( m_vpLoop.begin() + m_vExtInd[nChunk], m_vpLoop.end()) ;
|
|
||||||
// elimino indice di loop esterno
|
|
||||||
m_vExtInd.pop_back() ;
|
|
||||||
}
|
|
||||||
// altrimenti
|
|
||||||
else {
|
|
||||||
// numero di loop da eliminare
|
|
||||||
int nLoopCnt = m_vExtInd[nChunk+1] - m_vExtInd[nChunk] ;
|
|
||||||
// elimino i loop
|
|
||||||
for ( int i = m_vExtInd[nChunk] ; i < m_vExtInd[nChunk+1] ; ++ i) {
|
|
||||||
delete m_vpLoop[i] ;
|
|
||||||
m_vpLoop[i] = nullptr ;
|
|
||||||
}
|
|
||||||
m_vpLoop.erase( m_vpLoop.begin() + m_vExtInd[nChunk], m_vpLoop.begin() + m_vExtInd[nChunk+1]) ;
|
|
||||||
// elimino indice di loop esterno
|
|
||||||
m_vExtInd.erase( m_vExtInd.begin() + nChunk) ;
|
|
||||||
// aggiorno indice inizio chunk successivi
|
|
||||||
for ( int i = nChunk ; i < int( m_vExtInd.size()) ; ++i)
|
|
||||||
m_vExtInd[i] -= nLoopCnt ;
|
|
||||||
}
|
|
||||||
// imposto ricalcolo della grafica
|
|
||||||
m_OGrMgr.Reset() ;
|
|
||||||
ResetAuxSurf() ;
|
|
||||||
// imposto ricalcolo Voronoi
|
|
||||||
ResetVoronoiObject() ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const
|
SurfFlatRegion::MyGetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const
|
||||||
@@ -1595,154 +1480,3 @@ SurfFlatRegion::CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const
|
|||||||
|
|
||||||
return m_pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
|
return m_pVoronoiObj->CalcMedialAxis( vCrvs, nSide) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::GetChunkMaxOffset( int nChunk, double& dOffs) const
|
|
||||||
{
|
|
||||||
// verifico se è stato calcolato Voronoi
|
|
||||||
if ( m_pVoronoiObj == nullptr)
|
|
||||||
if ( ! CalcVoronoiObject())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// il massimo offset per il chunk è il massimo offset del suo loop esterno
|
|
||||||
// ( il diagramma di Voronoi tiene già conto della limitazione con i loop interni)
|
|
||||||
int nInd = GetIndFromChunkLoop( nChunk, 0) ;
|
|
||||||
return m_pVoronoiObj->CalcLimitOffset( nInd, true, dOffs) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::GetMaxOffset( double& dOffs) const
|
|
||||||
{
|
|
||||||
int nChunks = GetChunkCount() ;
|
|
||||||
if ( nChunks == 0)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// calcolo il massimo fra gli offset limite di tutti i suoi chunks
|
|
||||||
if ( ! GetChunkMaxOffset( 0, dOffs))
|
|
||||||
return false ;
|
|
||||||
for ( int i = 1 ; i < nChunks ; i++) {
|
|
||||||
double dCurrOffs ;
|
|
||||||
if ( ! GetChunkMaxOffset( i, dCurrOffs))
|
|
||||||
return false ;
|
|
||||||
if ( dCurrOffs > dOffs)
|
|
||||||
dOffs = dCurrOffs ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::SetCurveTempProp( int nChunk, int nLoop, int nCrv, int nProp, int nPropInd)
|
|
||||||
{
|
|
||||||
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
|
|
||||||
if ( pLoop == nullptr)
|
|
||||||
return false ;
|
|
||||||
if ( pLoop->GetType() != CRV_COMPO) {
|
|
||||||
if ( nCrv != 0)
|
|
||||||
return false ;
|
|
||||||
pLoop->SetTempProp( nProp, nPropInd) ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
return GetBasicCurveComposite( pLoop)->SetCurveTempProp( nCrv, nProp, nPropInd) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::GetCurveTempProp( int nChunk, int nLoop, int nCrv, int& nProp, int nPropInd) const
|
|
||||||
{
|
|
||||||
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
|
|
||||||
if ( pLoop == nullptr)
|
|
||||||
return false ;
|
|
||||||
if ( pLoop->GetType() != CRV_COMPO) {
|
|
||||||
if ( nCrv != 0)
|
|
||||||
return false ;
|
|
||||||
nProp = pLoop->GetTempProp( nPropInd) ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
return GetBasicCurveComposite( pLoop)->GetCurveTempProp( nCrv, nProp, nPropInd) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::ResetAllCurveTempProps( void)
|
|
||||||
{
|
|
||||||
for ( int nC = 0 ; nC < GetChunkCount() ; ++ nC) {
|
|
||||||
for ( int nL = 0 ; nL < GetLoopCount( nC) ; ++ nL) {
|
|
||||||
ICurve* pLoop = GetMyLoop( nC, nL) ;
|
|
||||||
if ( pLoop != nullptr) {
|
|
||||||
if ( pLoop->GetType() != CRV_COMPO) {
|
|
||||||
pLoop->SetTempProp( 0, 0) ;
|
|
||||||
pLoop->SetTempProp( 0, 1) ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CurveComposite* pCompoLoop = GetBasicCurveComposite( pLoop) ;
|
|
||||||
for ( int nI = 0 ; nI < pCompoLoop->GetCurveCount() ; ++ nI) {
|
|
||||||
pCompoLoop->SetCurveTempProp( nI, 0, 0) ;
|
|
||||||
pCompoLoop->SetCurveTempProp( nI, 0, 1) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::SetCurveTempParam( int nChunk, int nLoop, int nCrv, double dParam, int nParamInd)
|
|
||||||
{
|
|
||||||
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
|
|
||||||
if ( pLoop == nullptr)
|
|
||||||
return false ;
|
|
||||||
if ( pLoop->GetType() != CRV_COMPO) {
|
|
||||||
if ( nCrv != 0)
|
|
||||||
return false ;
|
|
||||||
pLoop->SetTempParam( dParam, nParamInd) ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
return GetBasicCurveComposite( pLoop)->SetCurveTempParam( nCrv, dParam, nParamInd) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::GetCurveTempParam( int nChunk, int nLoop, int nCrv, double& dParam, int nParamInd) const
|
|
||||||
{
|
|
||||||
ICurve* pLoop = GetMyLoop( nChunk, nLoop) ;
|
|
||||||
if ( pLoop == nullptr)
|
|
||||||
return false ;
|
|
||||||
if ( pLoop->GetType() != CRV_COMPO) {
|
|
||||||
if ( nCrv != 0)
|
|
||||||
return false ;
|
|
||||||
dParam = pLoop->GetTempParam( nParamInd) ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
return GetBasicCurveComposite( pLoop)->GetCurveTempParam( nCrv, dParam, nParamInd) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfFlatRegion::ResetAllCurveTempParams( void)
|
|
||||||
{
|
|
||||||
for ( int nC = 0 ; nC < GetChunkCount() ; ++ nC) {
|
|
||||||
for ( int nL = 0 ; nL < GetLoopCount( nC) ; ++ nL) {
|
|
||||||
ICurve* pLoop = GetMyLoop( nC, nL) ;
|
|
||||||
if ( pLoop != nullptr) {
|
|
||||||
if ( pLoop->GetType() != CRV_COMPO) {
|
|
||||||
pLoop->SetTempParam( 0, 0) ;
|
|
||||||
pLoop->SetTempParam( 0, 1) ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CurveComposite* pCompoLoop = GetBasicCurveComposite( pLoop) ;
|
|
||||||
for ( int nI = 0 ; nI < pCompoLoop->GetCurveCount() ; ++ nI) {
|
|
||||||
pCompoLoop->SetCurveTempParam( nI, 0, 0) ;
|
|
||||||
pCompoLoop->SetCurveTempParam( nI, 0, 1) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|||||||
+9
-21
@@ -94,30 +94,18 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
|||||||
{ return m_frF.Orig() ; }
|
{ return m_frF.Orig() ; }
|
||||||
const Vector3d& GetNormVersor( void) const override
|
const Vector3d& GetNormVersor( void) const override
|
||||||
{ return m_frF.VersZ() ; }
|
{ return m_frF.VersZ() ; }
|
||||||
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
|
|
||||||
void ResetVoronoiObject( void) const override ;
|
|
||||||
bool GetMaxOffset( double& dOffs) const override ;
|
|
||||||
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
|
|
||||||
const SurfTriMesh* GetAuxSurf( void) const override ;
|
|
||||||
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
|
|
||||||
int GetChunkCount( void) const override ;
|
int GetChunkCount( void) const override ;
|
||||||
SurfFlatRegion* CloneChunk( int nChunk) const override ;
|
|
||||||
bool EraseChunk(int nChunk) override ;
|
|
||||||
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
|
|
||||||
bool GetChunkArea( int nChunk, double& dArea) const override ;
|
|
||||||
bool GetChunkPerimeter( int nChunk, double& dLen) const override ;
|
|
||||||
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
|
|
||||||
bool GetChunkMaxOffset( int nChunk, double& dOffs) const override ;
|
|
||||||
int GetLoopCount( int nChunk) const override ;
|
int GetLoopCount( int nChunk) const override ;
|
||||||
int GetLoopCurveCount( int nChunk, int nLoop) const override ;
|
|
||||||
ICurve* GetLoop( int nChunk, int nLoop) const override ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni)
|
ICurve* GetLoop( int nChunk, int nLoop) const override ; // nChunk 0-based, nLoop 0-based (1°esterno, successivi interni)
|
||||||
bool ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const override ;
|
bool ApproxLoopWithLines( int nChunk, int nLoop, double dLinTol, double dAngTolDeg, int nType, PolyLine& PL) const override ;
|
||||||
bool SetCurveTempProp( int nChunk, int nLoop, int nCrv, int nProp, int nPropInd = 0) override ;
|
const SurfTriMesh* GetAuxSurf( void) const override ;
|
||||||
bool GetCurveTempProp( int nChunk, int nLoop, int nCrv, int& nProp, int nPropInd = 0) const override ;
|
SurfFlatRegion* CloneChunk( int nChunk) const override ;
|
||||||
bool ResetAllCurveTempProps( void) override ;
|
bool GetChunkCentroid( int nChunk, Point3d& ptCen) const override ;
|
||||||
bool SetCurveTempParam( int nChunk, int nLoop, int nCrv, double dParam, int nParamInd = 0) override ;
|
bool GetCurveClassification( const ICurve& Crv, double dLenMin, CRVCVECTOR& ccClass) const override ;
|
||||||
bool GetCurveTempParam( int nChunk, int nLoop, int nCrv, double& dParam, int nParamInd = 0) const override ;
|
int GetChunkSimpleClassification( int nChunk, const ISurfFlatRegion& Other, int nOthChunk) const override ; // compare only outsides
|
||||||
bool ResetAllCurveTempParams( void) override ;
|
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const override ;
|
||||||
|
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) const override ;
|
||||||
|
void ResetVoronoiObject( void) const override ;
|
||||||
|
|
||||||
public : // IGeoObjRW
|
public : // IGeoObjRW
|
||||||
int GetNgeId( void) const override ;
|
int GetNgeId( void) const override ;
|
||||||
@@ -148,7 +136,7 @@ class SurfFlatRegion : public ISurfFlatRegion, public IGeoObjRW
|
|||||||
|
|
||||||
private :
|
private :
|
||||||
bool CopyFrom( const SurfFlatRegion& clSrc) ;
|
bool CopyFrom( const SurfFlatRegion& clSrc) ;
|
||||||
bool AddSimpleExtLoop( ICurve* pCrv, bool& bAdded) ;
|
bool AddSimpleExtLoop( ICurve* pCrv) ;
|
||||||
bool MyAddExtLoop( ICurve* pCrv) ;
|
bool MyAddExtLoop( ICurve* pCrv) ;
|
||||||
bool AddSimpleIntLoop( ICurve* pCrv) ;
|
bool AddSimpleIntLoop( ICurve* pCrv) ;
|
||||||
bool MyAddIntLoop( ICurve* pCrv, int nChunk) ;
|
bool MyAddIntLoop( ICurve* pCrv, int nChunk) ;
|
||||||
|
|||||||
+68
-529
@@ -20,21 +20,19 @@
|
|||||||
#include "NgeWriter.h"
|
#include "NgeWriter.h"
|
||||||
#include "NgeReader.h"
|
#include "NgeReader.h"
|
||||||
#include "SurfFlatRegion.h"
|
#include "SurfFlatRegion.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
|
#include "DistLineLine.h"
|
||||||
#include "Triangulate.h"
|
#include "Triangulate.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||||
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
#include "/EgtDev/Include/EGkPointGrid3d.h"
|
||||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
|
||||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||||
|
#include <new>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
@@ -46,7 +44,7 @@ SurfTriMesh::SurfTriMesh( void)
|
|||||||
: m_nStatus( TO_VERIFY), m_dLinTol( STM_STD_LIN_TOL), m_dBoundaryAng( STM_STD_BOUNDARY_ANG),
|
: m_nStatus( TO_VERIFY), m_dLinTol( STM_STD_LIN_TOL), m_dBoundaryAng( STM_STD_BOUNDARY_ANG),
|
||||||
m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bShowEdges( false), m_bOriented( false), m_bClosed( false),
|
m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bShowEdges( false), m_bOriented( false), m_bClosed( false),
|
||||||
m_bFaceted( false), m_bFacEdged( false), m_nTimeStamp( 0), m_nTempProp{0,0}, m_dTempParam{0,0},
|
m_bFaceted( false), m_bFacEdged( false), m_nTimeStamp( 0), m_nTempProp{0,0}, m_dTempParam{0,0},
|
||||||
m_nMaxTFlag( 0), m_nShells( -1), m_pHGrd3d( nullptr)
|
m_nMaxTFlag( 0), m_nParts( -1), m_pHGrd3d( nullptr)
|
||||||
{
|
{
|
||||||
m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ;
|
m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ;
|
||||||
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
|
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
|
||||||
@@ -85,8 +83,7 @@ SurfTriMesh::Init( int nNumVert, int nNumTria, int nNumFacet)
|
|||||||
m_nStatus = OK ;
|
m_nStatus = OK ;
|
||||||
m_bClosed = false ;
|
m_bClosed = false ;
|
||||||
m_nMaxTFlag = 0 ;
|
m_nMaxTFlag = 0 ;
|
||||||
m_nShells = -1 ;
|
m_nParts = -1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -117,8 +114,7 @@ SurfTriMesh::Clear( void)
|
|||||||
m_dTempParam[0] = 0 ;
|
m_dTempParam[0] = 0 ;
|
||||||
m_dTempParam[1] = 0 ;
|
m_dTempParam[1] = 0 ;
|
||||||
m_nMaxTFlag = 0 ;
|
m_nMaxTFlag = 0 ;
|
||||||
m_nShells = -1 ;
|
m_nParts = -1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,8 +124,7 @@ SurfTriMesh::AddVertex( const Point3d& ptVert, double dU, double dV)
|
|||||||
{
|
{
|
||||||
// imposto ricalcolo
|
// imposto ricalcolo
|
||||||
m_nStatus = TO_VERIFY ;
|
m_nStatus = TO_VERIFY ;
|
||||||
m_nShells = -1 ;
|
m_nParts = - 1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
ResetHashGrids3d() ;
|
ResetHashGrids3d() ;
|
||||||
// inserisco il vertice
|
// inserisco il vertice
|
||||||
@@ -160,8 +155,7 @@ SurfTriMesh::MoveVertex( int nInd, const Point3d& ptNewVert)
|
|||||||
m_vVert[nInd].ptP = ptNewVert ;
|
m_vVert[nInd].ptP = ptNewVert ;
|
||||||
// imposto ricalcolo
|
// imposto ricalcolo
|
||||||
m_nStatus = TO_VERIFY ;
|
m_nStatus = TO_VERIFY ;
|
||||||
m_nShells = - 1 ;
|
m_nParts = - 1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
m_bFaceted = false ;
|
m_bFaceted = false ;
|
||||||
m_bFacEdged = false ;
|
m_bFacEdged = false ;
|
||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
@@ -230,8 +224,7 @@ SurfTriMesh::AddTriangle( const int nIdVert[3], int nTFlag)
|
|||||||
return SVT_DEL ;
|
return SVT_DEL ;
|
||||||
// imposto ricalcolo
|
// imposto ricalcolo
|
||||||
m_nStatus = TO_VERIFY ;
|
m_nStatus = TO_VERIFY ;
|
||||||
m_nShells = -1 ;
|
m_nParts = - 1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
ResetHashGrids3d() ;
|
ResetHashGrids3d() ;
|
||||||
// inserisco il triangolo
|
// inserisco il triangolo
|
||||||
@@ -322,8 +315,7 @@ SurfTriMesh::RemoveTriangle( int nId)
|
|||||||
m_bFaceted = false ;
|
m_bFaceted = false ;
|
||||||
m_bFacEdged = false ;
|
m_bFacEdged = false ;
|
||||||
// invalido calcolo connettività
|
// invalido calcolo connettività
|
||||||
m_nShells = -1 ;
|
m_nParts = - 1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,6 +904,7 @@ SurfTriMesh::CloneTriangle( int nT) const
|
|||||||
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
|
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
|
||||||
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
|
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
|
||||||
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
|
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
|
||||||
|
pSurfTM->m_nParts = 1 ;
|
||||||
|
|
||||||
// Copio il triangolo
|
// Copio il triangolo
|
||||||
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[nT].nIdVert[0]].ptP),
|
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[nT].nIdVert[0]].ptP),
|
||||||
@@ -1055,16 +1048,10 @@ bool
|
|||||||
SurfTriMesh::MarchAlongLoop( int nT, int nV, int nTimeStamp, PolyLine& PL) const
|
SurfTriMesh::MarchAlongLoop( int nT, int nV, int nTimeStamp, PolyLine& PL) const
|
||||||
{
|
{
|
||||||
// mi muovo lungo il loop, un triangolo alla volta
|
// mi muovo lungo il loop, un triangolo alla volta
|
||||||
int nCount = 0 ;
|
|
||||||
bool bEnd = false ;
|
bool bEnd = false ;
|
||||||
while ( ! bEnd) {
|
while ( ! bEnd) {
|
||||||
// altro triangolo
|
|
||||||
if ( ! MarchOneTria( nT, nV, nTimeStamp, PL, bEnd))
|
if ( ! MarchOneTria( nT, nV, nTimeStamp, PL, bEnd))
|
||||||
return false ;
|
return false ;
|
||||||
// per evitare loop infiniti
|
|
||||||
++ nCount ;
|
|
||||||
if ( nCount > 3 * int( m_vTria.size()) + 10)
|
|
||||||
return true ;
|
|
||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -1154,7 +1141,7 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
|||||||
if ( ! IsNull( pSfrTria)) {
|
if ( ! IsNull( pSfrTria)) {
|
||||||
if ( bAllTria && Tria.GetN() * vtVers < 0)
|
if ( bAllTria && Tria.GetN() * vtVers < 0)
|
||||||
pSfrTria->Invert() ;
|
pSfrTria->Invert() ;
|
||||||
pSfrTria->Offset( dTol, ICurve::OFF_CHAMFER) ;
|
pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ;
|
||||||
if ( IsNull( pSfr))
|
if ( IsNull( pSfr))
|
||||||
pSfr.Set( pSfrTria) ;
|
pSfr.Set( pSfrTria) ;
|
||||||
else
|
else
|
||||||
@@ -1170,79 +1157,7 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR&
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Effettuo contro-offset
|
// Effettuo contro-offset
|
||||||
pSfr->Offset( -dTol, ICurve::OFF_CHAMFER) ;
|
pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ;
|
||||||
|
|
||||||
// Recupero i contorni della regione
|
|
||||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
|
||||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
|
||||||
PolyLine PL ;
|
|
||||||
if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL))
|
|
||||||
vPL.emplace_back( PL) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfTriMesh::GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR& vPL, bool bAllTria) const
|
|
||||||
{
|
|
||||||
// Verifico lo stato
|
|
||||||
if ( m_nStatus != OK)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Verifico la direzione
|
|
||||||
Vector3d vtVers = plPlane.GetVersN() ;
|
|
||||||
if ( ! vtVers.Normalize())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Controlli su tolleranza
|
|
||||||
dTol = max( dTol, 100 * EPS_SMALL) ;
|
|
||||||
|
|
||||||
// Determino il riferimento di proiezione
|
|
||||||
Frame3d frOCS ; frOCS.Set( plPlane.GetPoint(), vtVers) ;
|
|
||||||
|
|
||||||
// Ottengo la Silhouette come unione delle regioni dei triangoli proiettati (solo parti sopra il piano)
|
|
||||||
// calcolo la regione dei triangoli proiettati
|
|
||||||
PtrOwner<SurfFlatRegion> pSfr ;
|
|
||||||
Triangle3d Tria ;
|
|
||||||
int nT = GetFirstTriangle( Tria) ;
|
|
||||||
while ( nT != SVT_NULL) {
|
|
||||||
// verifico la normale
|
|
||||||
if ( ( bAllTria && abs( Tria.GetN() * vtVers) > EPS_ZERO) ||
|
|
||||||
( ! bAllTria && Tria.GetN() * vtVers > EPS_ZERO)) {
|
|
||||||
// ricavo il poligono equivalente al triangolo
|
|
||||||
Polygon3d pgTria ;
|
|
||||||
pgTria.FromTriangle( Tria) ;
|
|
||||||
// taglio il poligono con il piano
|
|
||||||
pgTria.Trim( plPlane, false, true, bAllTria) ;
|
|
||||||
// se rimasto qualcosa
|
|
||||||
if ( pgTria.GetSideCount() > 0) {
|
|
||||||
// lo proietto sul piano e creo la regione
|
|
||||||
pgTria.Scale( frOCS, 1, 1, 0) ;
|
|
||||||
PtrOwner<SurfFlatRegion> pSfrTria( GetBasicSurfFlatRegion( GetSurfFlatRegionFromPolyLine( pgTria.GetPolyLine()))) ;
|
|
||||||
if ( ! IsNull( pSfrTria)) {
|
|
||||||
if ( bAllTria && Tria.GetN() * vtVers < 0)
|
|
||||||
pSfrTria->Invert() ;
|
|
||||||
pSfrTria->Offset( dTol, ICurve::OFF_CHAMFER) ;
|
|
||||||
if ( IsNull( pSfr))
|
|
||||||
pSfr.Set( pSfrTria) ;
|
|
||||||
else
|
|
||||||
pSfr->Add( *pSfrTria) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// passo al successivo
|
|
||||||
nT = GetNextTriangle( nT, Tria) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Se non esiste la regione
|
|
||||||
if ( IsNull( pSfr))
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
// Effettuo contro-offset
|
|
||||||
pSfr->Offset( -dTol, ICurve::OFF_CHAMFER) ;
|
|
||||||
|
|
||||||
// Recupero i contorni della regione
|
// Recupero i contorni della regione
|
||||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||||
@@ -1309,8 +1224,7 @@ SurfTriMesh::CopyFrom( const SurfTriMesh& stmSrc)
|
|||||||
m_nTempProp[0] = stmSrc.m_nTempProp[0] ;
|
m_nTempProp[0] = stmSrc.m_nTempProp[0] ;
|
||||||
m_nTempProp[1] = stmSrc.m_nTempProp[1] ;
|
m_nTempProp[1] = stmSrc.m_nTempProp[1] ;
|
||||||
m_nMaxTFlag = stmSrc.m_nMaxTFlag ;
|
m_nMaxTFlag = stmSrc.m_nMaxTFlag ;
|
||||||
m_nShells = stmSrc.m_nShells ;
|
m_nParts = stmSrc.m_nParts ;
|
||||||
m_vPart = stmSrc.m_vPart ;
|
|
||||||
m_dTempParam[0] = stmSrc.m_dTempParam[0] ;
|
m_dTempParam[0] = stmSrc.m_dTempParam[0] ;
|
||||||
m_dTempParam[1] = stmSrc.m_dTempParam[1] ;
|
m_dTempParam[1] = stmSrc.m_dTempParam[1] ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -1348,10 +1262,10 @@ SurfTriMesh::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
|||||||
// segnalo eventuale incongruenza di orientamento
|
// segnalo eventuale incongruenza di orientamento
|
||||||
if ( ! m_bOriented)
|
if ( ! m_bOriented)
|
||||||
sOut += string( "Inconsistent Orientation") + szNewLine ;
|
sOut += string( "Inconsistent Orientation") + szNewLine ;
|
||||||
// segnalo numero di parti e di gusci
|
// segnalo numero di parti se più di una
|
||||||
int nParts = GetPartCount() ;
|
int nParts = GetPartCount() ;
|
||||||
int nShells = GetShellCount() ;
|
if ( nParts > 1)
|
||||||
sOut += string( "Parts=") + ToString( nParts) + string( " Shells=") + ToString( nShells) + szNewLine ;
|
sOut += string( "Parts =") + ToString( nParts) + szNewLine ;
|
||||||
// numero di vertici
|
// numero di vertici
|
||||||
sOut += "Vert : Nbr=" + ToString( GetVertexCount()) +
|
sOut += "Vert : Nbr=" + ToString( GetVertexCount()) +
|
||||||
" Size=" + ToString( GetVertexSize()) + szNewLine ;
|
" Size=" + ToString( GetVertexSize()) + szNewLine ;
|
||||||
@@ -1461,8 +1375,7 @@ SurfTriMesh::Load( NgeReader& ngeIn)
|
|||||||
// imposto ricalcolo della grafica, della connessione e di hashgrids3d
|
// imposto ricalcolo della grafica, della connessione e di hashgrids3d
|
||||||
m_OGrMgr.Clear() ;
|
m_OGrMgr.Clear() ;
|
||||||
m_nMaxTFlag = 0 ;
|
m_nMaxTFlag = 0 ;
|
||||||
m_nShells = -1 ;
|
m_nParts = -1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
ResetHashGrids3d() ;
|
ResetHashGrids3d() ;
|
||||||
// leggo la prossima linea ( 2 parametri : dLinTol e dSmoothAng)
|
// leggo la prossima linea ( 2 parametri : dLinTol e dSmoothAng)
|
||||||
// tolleranza lineare di costruzione
|
// tolleranza lineare di costruzione
|
||||||
@@ -1622,8 +1535,7 @@ SurfTriMesh::Validate( bool bCorrect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// invalido calcolo connessione
|
// invalido calcolo connessione
|
||||||
m_nShells = -1 ;
|
m_nParts = - 1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
|
|
||||||
return ( m_nStatus == OK) ;
|
return ( m_nStatus == OK) ;
|
||||||
}
|
}
|
||||||
@@ -1898,8 +1810,7 @@ SurfTriMesh::AdjustTopology( void)
|
|||||||
m_bFaceted = false ;
|
m_bFaceted = false ;
|
||||||
m_bFacEdged = false ;
|
m_bFacEdged = false ;
|
||||||
// invalido calcolo connessione
|
// invalido calcolo connessione
|
||||||
m_nShells = - 1 ;
|
m_nParts = - 1 ;
|
||||||
m_vPart.clear() ;
|
|
||||||
// verifica indici
|
// verifica indici
|
||||||
if ( ! Validate( true))
|
if ( ! Validate( true))
|
||||||
return false ;
|
return false ;
|
||||||
@@ -2093,13 +2004,13 @@ SurfTriMesh::CreateByFlatContour( const PolyLine& PL)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfTriMesh::CreateByRegion( const POLYLINEVECTOR& vPL, const INTMATRIX& vnPLIndMat)
|
SurfTriMesh::CreateByRegion( const POLYLINEVECTOR& vPL)
|
||||||
{
|
{
|
||||||
// eseguo la triangolazione, dopo aver verificato che l'insieme di contorni costituisca una regione
|
// eseguo la triangolazione, dopo aver verificato che l'insieme di contorni costituisca una regione
|
||||||
PNTVECTOR vPnt ;
|
PNTVECTOR vPnt ;
|
||||||
INTVECTOR vTria ;
|
INTVECTOR vTria ;
|
||||||
Triangulate Tri ;
|
Triangulate Tri ;
|
||||||
if ( ! Tri.MakeAdvanced( vPL, vPnt, vTria, vnPLIndMat))
|
if ( ! Tri.MakeAdvanced( vPL, vPnt, vTria))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// inizializzo la superficie
|
// inizializzo la superficie
|
||||||
@@ -2715,8 +2626,6 @@ VeryfyPolylineForRevolution( const PolyLine& PL, const Point3d& ptAx, const Vect
|
|||||||
ptPc.z = 0 ;
|
ptPc.z = 0 ;
|
||||||
++ nSeg ;
|
++ nSeg ;
|
||||||
// verifico distanza
|
// verifico distanza
|
||||||
// se la curva è chiusa oppure è vicina all'asse ( entro EPS_SMALL), ma non ho che sono start o end ad essere sull'asse
|
|
||||||
// allora dovrò rimaneggiare la polyline
|
|
||||||
if ( DistPointLine( ORIG, ptPp, ptPc).IsSmall()) {
|
if ( DistPointLine( ORIG, ptPp, ptPc).IsSmall()) {
|
||||||
if ( bClosed ||
|
if ( bClosed ||
|
||||||
( ! ( nSeg == 1 && AreSamePointApprox( ORIG, ptPp)) &&
|
( ! ( nSeg == 1 && AreSamePointApprox( ORIG, ptPp)) &&
|
||||||
@@ -3570,10 +3479,7 @@ SurfTriMesh::Invert( void)
|
|||||||
if ( m_nStatus != OK)
|
if ( m_nStatus != OK)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// imposto ricalcolo numero delle parti (le shell non cambiano)
|
// imposto ricalcolo della grafica e di hashgrids3d
|
||||||
m_vPart.clear() ;
|
|
||||||
|
|
||||||
// imposto ricalcolo della grafica e di hashgrids3d
|
|
||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
ResetHashGrids3d() ;
|
ResetHashGrids3d() ;
|
||||||
|
|
||||||
@@ -3645,421 +3551,56 @@ SurfTriMesh::GetAllTriaBox( void) const
|
|||||||
return m_b3HGrd3d ;
|
return m_b3HGrd3d ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfTriMesh::VerifyConnection( bool bShellsAndParts) const
|
|
||||||
{
|
|
||||||
if ( ! IsValid())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// se non sono già note le shell
|
|
||||||
if ( m_nShells == -1) {
|
|
||||||
// reset connessione
|
|
||||||
for ( auto& Tria : m_vTria)
|
|
||||||
Tria.nShell = SVT_NULL ;
|
|
||||||
// ciclo sui triangoli per determinare le shells
|
|
||||||
m_nShells = 0 ;
|
|
||||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
|
||||||
// salto triangoli cancellati o già assegnati
|
|
||||||
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
|
|
||||||
m_vTria[i].nShell != SVT_NULL)
|
|
||||||
continue ;
|
|
||||||
// assegno indice di shell connessa al triangolo
|
|
||||||
m_vTria[i].nShell = m_nShells ;
|
|
||||||
++ m_nShells ;
|
|
||||||
// set di triangoli da aggiornare
|
|
||||||
set<int> stTria ;
|
|
||||||
stTria.insert( i) ;
|
|
||||||
while ( ! stTria.empty()) {
|
|
||||||
// tolgo un triangolo dal set
|
|
||||||
const auto iIt = stTria.begin() ;
|
|
||||||
int nT = *iIt ;
|
|
||||||
stTria.erase( iIt) ;
|
|
||||||
// aggiorno i triangoli adiacenti
|
|
||||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
|
||||||
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
|
|
||||||
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nShell == SVT_NULL) {
|
|
||||||
m_vTria[nAdjT].nShell = m_vTria[nT].nShell ;
|
|
||||||
stTria.insert( nAdjT) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset delle parti
|
|
||||||
m_vPart.clear() ;
|
|
||||||
|
|
||||||
// se richiesta solo la determinazione delle shell, esco
|
|
||||||
if ( ! bShellsAndParts)
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
// Se superficie vuota, allora non ho parti
|
|
||||||
if ( m_nShells == 0)
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
// Se ho solo una shell, allora ho una sola parte
|
|
||||||
if ( m_nShells == 1) {
|
|
||||||
m_vPart.emplace_back( m_bClosed, INTVECTOR{ 0}) ;
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ho più shell devo controllare la loro posizione relativa
|
|
||||||
struct SHELLINFO {
|
|
||||||
SHELLINFO( int nI, double dVol, const BBox3d& b3B, ISurfTriMesh* pStm)
|
|
||||||
: nInd( nI), dVolume( dVol), b3Box( b3B), pStmShell( pStm) {}
|
|
||||||
int nInd ;
|
|
||||||
double dVolume ;
|
|
||||||
BBox3d b3Box ;
|
|
||||||
PtrOwner<ISurfTriMesh> pStmShell ;
|
|
||||||
} ;
|
|
||||||
vector<SHELLINFO> vOuterShells ;
|
|
||||||
vector<SHELLINFO> vInnerShells ;
|
|
||||||
INTVECTOR vOpenShells ;
|
|
||||||
for ( int nSh = 0 ; nSh < m_nShells ; ++ nSh) {
|
|
||||||
// se la shell è chiusa
|
|
||||||
if ( IsShellClosed( nSh)) {
|
|
||||||
// creo una superficie clonata dalla shell
|
|
||||||
PtrOwner<ISurfTriMesh> pStmShell( CloneShell( nSh)) ;
|
|
||||||
if ( IsNull( pStmShell) || ! pStmShell->IsValid())
|
|
||||||
return false ;
|
|
||||||
// ne calcolo il volume (con segno)
|
|
||||||
double dVol = 0. ;
|
|
||||||
pStmShell->GetVolume( dVol) ;
|
|
||||||
// ne calcolo il bounding box
|
|
||||||
BBox3d b3Box ;
|
|
||||||
pStmShell->GetLocalBBox( b3Box, BBF_STANDARD) ;
|
|
||||||
// la inserisco nel vettore opportuno
|
|
||||||
if ( dVol > 0)
|
|
||||||
vOuterShells.emplace_back( nSh, dVol, b3Box, Release( pStmShell)) ;
|
|
||||||
else
|
|
||||||
vInnerShells.emplace_back( nSh, dVol, b3Box, Release( pStmShell)) ;
|
|
||||||
}
|
|
||||||
// altrimenti aperta
|
|
||||||
else {
|
|
||||||
// la inserisco nel vettore delle shell aperte
|
|
||||||
vOpenShells.push_back( nSh) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ordino il vettore delle shell esterne in senso crescente di volume (crescenti anche in valore assoluto)
|
|
||||||
sort( vOuterShells.begin(), vOuterShells.end(),
|
|
||||||
[]( const SHELLINFO& a, const SHELLINFO& b) {
|
|
||||||
return ( a.dVolume < b.dVolume) ;
|
|
||||||
}) ;
|
|
||||||
// ordino il vettore delle shell interne in senso crescente di volume (decrescenti in valore assoluto)
|
|
||||||
sort( vInnerShells.begin(), vInnerShells.end(),
|
|
||||||
[]( const SHELLINFO& a, const SHELLINFO& b) {
|
|
||||||
return ( a.dVolume < b.dVolume) ;
|
|
||||||
}) ;
|
|
||||||
|
|
||||||
// classifico le shell esterne
|
|
||||||
for ( int i = 0 ; i < int( vOuterShells.size()) ; ++ i) {
|
|
||||||
// inserisco nel vettore delle parti
|
|
||||||
m_vPart.emplace_back( true, INTVECTOR{ vOuterShells[i].nInd}) ;
|
|
||||||
// cerco eventuali interne che vi appartengono
|
|
||||||
CISURFTMPVECTOR vStmTest{ vOuterShells[i].pStmShell} ;
|
|
||||||
for ( int j = 0 ; j < int( vInnerShells.size()) ; ++ j) {
|
|
||||||
// se libera e il box è incluso, verifico se realmente interna
|
|
||||||
if ( vInnerShells[j].nInd >= 0 && vOuterShells[i].b3Box.Encloses( vInnerShells[j].b3Box)) {
|
|
||||||
Point3d ptCheck ;
|
|
||||||
vInnerShells[j].pStmShell->GetFirstVertex( ptCheck) ;
|
|
||||||
bool bIsInside = true ;
|
|
||||||
for ( const auto& pStmTest : vStmTest) {
|
|
||||||
BBox3d b3Test = pStmTest->GetAllTriaBox() ;
|
|
||||||
if ( b3Test.Overlaps( vInnerShells[j].b3Box)) {
|
|
||||||
DistPointSurfTm distCalculator( ptCheck, *pStmTest) ;
|
|
||||||
if ( ! distCalculator.IsPointInside()) {
|
|
||||||
bIsInside = false ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bIsInside) {
|
|
||||||
m_vPart.back().vShell.push_back( vInnerShells[j].nInd) ;
|
|
||||||
vInnerShells[j].nInd = -1 ;
|
|
||||||
vStmTest.push_back( vInnerShells[j].pStmShell) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// classifico le shell interne rimaste libere
|
|
||||||
bool bNewInner = true ;
|
|
||||||
CISURFTMPVECTOR vStmTest ;
|
|
||||||
for ( int i = 0 ; i < int( vInnerShells.size()) ; ++ i) {
|
|
||||||
if ( vInnerShells[i].nInd >= 0) {
|
|
||||||
// se non è nuova interna verifico sia interna alle altre correnti
|
|
||||||
if ( ! bNewInner) {
|
|
||||||
bool bIsInside = true ;
|
|
||||||
Point3d ptCheck ;
|
|
||||||
vInnerShells[i].pStmShell->GetFirstVertex( ptCheck) ;
|
|
||||||
// se il box interferisce con altri, verifico se realmente interna
|
|
||||||
for ( const auto& pStmTest : vStmTest) {
|
|
||||||
BBox3d b3Test = pStmTest->GetAllTriaBox() ;
|
|
||||||
if ( b3Test.Overlaps( vInnerShells[i].b3Box)) {
|
|
||||||
DistPointSurfTm distCalculator( ptCheck, *pStmTest) ;
|
|
||||||
if ( ! distCalculator.IsPointInside()) {
|
|
||||||
bIsInside = false ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bIsInside)
|
|
||||||
m_vPart.back().vShell.push_back( vInnerShells[i].nInd) ;
|
|
||||||
else
|
|
||||||
bNewInner = true ;
|
|
||||||
}
|
|
||||||
// se nuova interna
|
|
||||||
if ( bNewInner) {
|
|
||||||
bNewInner = false ;
|
|
||||||
m_vPart.emplace_back( true, INTVECTOR{ -1, vInnerShells[i].nInd}) ;
|
|
||||||
vStmTest.clear() ;
|
|
||||||
}
|
|
||||||
vInnerShells[i].nInd = -1 ;
|
|
||||||
vStmTest.push_back( vInnerShells[i].pStmShell) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// aggiungo all'elenco delle parti le shell aperte
|
|
||||||
for ( int i = 0 ; i < int( vOpenShells.size()) ; ++ i) {
|
|
||||||
m_vPart.emplace_back( false, INTVECTOR{ vOpenShells[i]}) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
int
|
|
||||||
SurfTriMesh::GetShellCount( void) const
|
|
||||||
{
|
|
||||||
if ( ! IsValid())
|
|
||||||
return 0 ;
|
|
||||||
if ( m_nShells == -1 && ! VerifyConnection())
|
|
||||||
return 0 ;
|
|
||||||
return m_nShells ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfTriMesh::GetShellArea( int nShell, double& dArea) const
|
|
||||||
{
|
|
||||||
// Controllo parametro di ritorno
|
|
||||||
if ( &dArea == nullptr)
|
|
||||||
return false ;
|
|
||||||
// Imposto area nulla
|
|
||||||
dArea = 0 ;
|
|
||||||
// Verifiche sull'oggetto
|
|
||||||
if ( ! IsValid())
|
|
||||||
return false ;
|
|
||||||
if ( m_nShells == -1 && ! VerifyConnection())
|
|
||||||
return false ;
|
|
||||||
// Se la componente non esiste, errore
|
|
||||||
if ( nShell < 0 || nShell >= m_nShells)
|
|
||||||
return false ;
|
|
||||||
// sommo l'area di tutti i triangoli della shell
|
|
||||||
Triangle3d Tria ;
|
|
||||||
int nId = GetFirstTriangle( Tria) ;
|
|
||||||
while ( nId != SVT_NULL) {
|
|
||||||
if ( m_vTria[nId].nShell == nShell)
|
|
||||||
dArea += Tria.GetArea() ;
|
|
||||||
nId = GetNextTriangle( nId, Tria) ;
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfTriMesh::IsShellClosed( int nShell) const
|
|
||||||
{
|
|
||||||
// Verifiche sull'oggetto
|
|
||||||
if ( ! IsValid())
|
|
||||||
return false ;
|
|
||||||
if ( m_nShells == -1 && ! VerifyConnection( false))
|
|
||||||
return false ;
|
|
||||||
// Se la componente non esiste, errore
|
|
||||||
if ( nShell < 0 || nShell >= m_nShells)
|
|
||||||
return false ;
|
|
||||||
// ciclo sui triangoli della shell
|
|
||||||
bool bClosed = true ;
|
|
||||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
|
||||||
// se triangolo non cancellato e della shell
|
|
||||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nShell == nShell) {
|
|
||||||
// verifico le adiacenze
|
|
||||||
if ( m_vTria[i].nIdAdjac[0] == SVT_NULL ||
|
|
||||||
m_vTria[i].nIdAdjac[1] == SVT_NULL ||
|
|
||||||
m_vTria[i].nIdAdjac[2] == SVT_NULL) {
|
|
||||||
bClosed = false ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// restituisco il risultato
|
|
||||||
return bClosed ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
SurfTriMesh::RemoveShell( int nShell)
|
|
||||||
{
|
|
||||||
if ( ! IsValid())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Il numero delle componenti deve essere maggiore di zero o calcolabile
|
|
||||||
if ( m_nShells == -1 && ! VerifyConnection())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Se la componente non esiste, errore
|
|
||||||
if ( nShell < 0 || nShell >= m_nShells)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Rimuovo i triangoli della componente nShell
|
|
||||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
|
||||||
if ( m_vTria[i].nShell == nShell)
|
|
||||||
RemoveTriangle( i) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// I dati di Shells e Parts sono stati resettati da RemoveTriangle
|
|
||||||
|
|
||||||
// imposto ricalcolo della grafica e di hashgrids3d
|
|
||||||
m_OGrMgr.Reset() ;
|
|
||||||
ResetHashGrids3d() ;
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
SurfTriMesh*
|
|
||||||
SurfTriMesh::CloneShell( int nShell) const
|
|
||||||
{
|
|
||||||
if ( ! IsValid())
|
|
||||||
return nullptr ;
|
|
||||||
|
|
||||||
// Il numero delle componenti deve essere maggiore di zero o calcolabile
|
|
||||||
if ( m_nShells == -1 && ! VerifyConnection())
|
|
||||||
return nullptr ;
|
|
||||||
|
|
||||||
// Se la componente non esiste, errore
|
|
||||||
if ( nShell < 0 || nShell >= m_nShells)
|
|
||||||
return nullptr ;
|
|
||||||
|
|
||||||
// Creo nuovo oggetto SurfTriMesh
|
|
||||||
PtrOwner<SurfTriMesh> pSurfTM( new( nothrow) SurfTriMesh) ;
|
|
||||||
if ( IsNull( pSurfTM))
|
|
||||||
return nullptr ;
|
|
||||||
|
|
||||||
// Copio il valore dei membri
|
|
||||||
pSurfTM->m_dLinTol = m_dLinTol ;
|
|
||||||
pSurfTM->m_dBoundaryAng = m_dBoundaryAng ;
|
|
||||||
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
|
|
||||||
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
|
|
||||||
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
|
|
||||||
|
|
||||||
// Copio i triangoli
|
|
||||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
|
||||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nShell == nShell) {
|
|
||||||
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[0]].ptP),
|
|
||||||
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[1]].ptP),
|
|
||||||
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[2]].ptP)} ;
|
|
||||||
if ( pSurfTM->AddTriangle( nNewInd, m_vTria[i].nTFlag) == SVT_NULL)
|
|
||||||
return nullptr ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aggiusto la superficie
|
|
||||||
pSurfTM->DoCompacting() ;
|
|
||||||
|
|
||||||
// Restituisco la nuova superficie
|
|
||||||
return Release( pSurfTM) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int
|
int
|
||||||
SurfTriMesh::GetPartCount( void) const
|
SurfTriMesh::GetPartCount( void) const
|
||||||
{
|
{
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return 0 ;
|
return 0 ;
|
||||||
if ( m_vPart.empty() && ! VerifyConnection())
|
if ( m_nParts == - 1 && ! VerifyConnection())
|
||||||
return 0 ;
|
return 0 ;
|
||||||
return int( m_vPart.size()) ;
|
return m_nParts ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfTriMesh::GetPartArea( int nPart, double& dArea) const
|
SurfTriMesh::VerifyConnection( void) const
|
||||||
{
|
{
|
||||||
// Controllo parametro di ritorno
|
|
||||||
if ( &dArea == nullptr)
|
|
||||||
return false ;
|
|
||||||
// Imposto area nulla
|
|
||||||
dArea = 0 ;
|
|
||||||
// Verifiche sull'oggetto
|
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
if ( m_vPart.empty() && ! VerifyConnection())
|
|
||||||
return false ;
|
|
||||||
// Se la componente non esiste, errore
|
|
||||||
if ( nPart < 0 || nPart >= int( m_vPart.size()))
|
|
||||||
return false ;
|
|
||||||
// sommo l'area di tutti i triangoli della parte
|
|
||||||
Triangle3d Tria ;
|
|
||||||
int nId = GetFirstTriangle( Tria) ;
|
|
||||||
while ( nId != SVT_NULL) {
|
|
||||||
const auto& vShell = m_vPart[nPart].vShell ;
|
|
||||||
if ( find( vShell.begin(), vShell.end(), m_vTria[nId].nShell) != vShell.end())
|
|
||||||
dArea += Tria.GetArea() ;
|
|
||||||
nId = GetNextTriangle( nId, Tria) ;
|
|
||||||
}
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
// reset connessione
|
||||||
bool
|
for ( auto Tria : m_vTria)
|
||||||
SurfTriMesh::IsPartClosed( int nPart) const
|
Tria.nPart = SVT_NULL ;
|
||||||
{
|
|
||||||
// Verifiche sull'oggetto
|
|
||||||
if ( ! IsValid())
|
|
||||||
return false ;
|
|
||||||
if ( m_vPart.empty() && ! VerifyConnection())
|
|
||||||
return false ;
|
|
||||||
// Se la componente non esiste, errore
|
|
||||||
if ( nPart < 0 || nPart >= int( m_vPart.size()))
|
|
||||||
return false ;
|
|
||||||
return m_vPart[nPart].bClosed ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
// ciclo sui triangoli
|
||||||
bool
|
m_nParts = 0 ;
|
||||||
SurfTriMesh::GetPartVolume( int nPart, double& dVolume) const
|
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||||
{
|
// salto triangoli cancellati o gi� assegnati
|
||||||
// Controllo parametro di ritorno
|
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
|
||||||
if ( &dVolume == nullptr)
|
m_vTria[i].nPart != SVT_NULL)
|
||||||
return false ;
|
continue ;
|
||||||
// Imposto volume nullo
|
// assegno indice di parte connessa al triangolo
|
||||||
dVolume = 0 ;
|
m_vTria[i].nPart = m_nParts ;
|
||||||
// Verifiche sull'oggetto
|
++ m_nParts ;
|
||||||
if ( ! IsValid())
|
// set di triangoli da aggiornare
|
||||||
return false ;
|
set<int> stTria ;
|
||||||
if ( m_vPart.empty() && ! VerifyConnection())
|
stTria.insert( i) ;
|
||||||
return false ;
|
while ( ! stTria.empty()) {
|
||||||
// Se la componente non esiste, errore
|
// tolgo un triangolo dal set
|
||||||
if ( nPart < 0 || nPart >= int( m_vPart.size()))
|
const auto iIt = stTria.begin() ;
|
||||||
return false ;
|
int nT = *iIt ;
|
||||||
// la parte deve essere chiusa
|
stTria.erase( iIt) ;
|
||||||
if ( ! m_vPart[nPart].bClosed)
|
// aggiorno i triangoli adiacenti
|
||||||
return true ;
|
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||||
// sommo il volume con segno di tutte le piramidi della parte dall'origine ad ogni faccia
|
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
|
||||||
Triangle3d Tria ;
|
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nPart == SVT_NULL) {
|
||||||
int nId = GetFirstTriangle( Tria) ;
|
m_vTria[nAdjT].nPart = m_vTria[nT].nPart ;
|
||||||
while ( nId != SVT_NULL) {
|
stTria.insert( nAdjT) ;
|
||||||
const auto& vShell = m_vPart[nPart].vShell ;
|
}
|
||||||
if ( find( vShell.begin(), vShell.end(), m_vTria[nId].nShell) != vShell.end()) {
|
}
|
||||||
Vector3d vtA = ( Tria.GetP( 1) - Tria.GetP( 0)) ^ ( Tria.GetP( 2) - Tria.GetP( 0)) ;
|
|
||||||
dVolume += ( Tria.GetP( 0) - ORIG) * vtA ;
|
|
||||||
}
|
}
|
||||||
nId = GetNextTriangle( nId, Tria) ;
|
|
||||||
}
|
}
|
||||||
dVolume /= 6 ;
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4071,21 +3612,22 @@ SurfTriMesh::RemovePart( int nPart)
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Il numero delle componenti deve essere maggiore di zero o calcolabile
|
// Il numero delle componenti deve essere maggiore di zero o calcolabile
|
||||||
if ( m_vPart.empty() && ! VerifyConnection())
|
if ( m_nParts == -1 && ! VerifyConnection())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Se la componente non esiste, errore
|
// Se la componente non esiste, errore
|
||||||
if ( nPart < 0 || nPart >= int( m_vPart.size()))
|
if ( m_nParts <= 0 || nPart < 0 || nPart >= m_nParts)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Rimuovo i triangoli della componente nPart (ovvero delle sue shell)
|
int nPartsOld = m_nParts ;
|
||||||
const auto vShell = m_vPart[nPart].vShell ;
|
// Rimuovo i triangoli della componente nPart
|
||||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||||
if ( find( vShell.begin(), vShell.end(), m_vTria[i].nShell) != vShell.end())
|
if ( m_vTria[i].nPart == nPart)
|
||||||
RemoveTriangle( i) ;
|
RemoveTriangle( i) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// I dati di Shells e Parts sono stati resettati da RemoveTriangle
|
// Aggiorno il numero di componenti
|
||||||
|
m_nParts = nPartsOld - 1 ;
|
||||||
|
|
||||||
// imposto ricalcolo della grafica e di hashgrids3d
|
// imposto ricalcolo della grafica e di hashgrids3d
|
||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
@@ -4101,12 +3643,12 @@ SurfTriMesh::ClonePart( int nPart) const
|
|||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
|
|
||||||
// Il numero delle parti deve essere maggiore di zero o calcolabile
|
// Il numero delle componenti deve essere maggiore di zero o calcolabile
|
||||||
if ( m_vPart.empty() && ! VerifyConnection())
|
if ( m_nParts == -1 && ! VerifyConnection())
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
|
|
||||||
// Se la parte non esiste, errore
|
// Se la componente non esiste, errore
|
||||||
if ( nPart < 0 || nPart >= int( m_vPart.size()))
|
if ( m_nParts <= 0 || nPart < 0 || nPart >= m_nParts)
|
||||||
return nullptr ;
|
return nullptr ;
|
||||||
|
|
||||||
// Creo nuovo oggetto SurfTriMesh
|
// Creo nuovo oggetto SurfTriMesh
|
||||||
@@ -4120,12 +3662,11 @@ SurfTriMesh::ClonePart( int nPart) const
|
|||||||
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
|
pSurfTM->m_dCosBndAng = m_dCosBndAng ;
|
||||||
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
|
pSurfTM->m_dSmoothAng = m_dSmoothAng ;
|
||||||
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
|
pSurfTM->m_dCosSmAng = m_dCosSmAng ;
|
||||||
|
pSurfTM->m_nParts = 1 ;
|
||||||
|
|
||||||
// Copio i triangoli
|
// Copio i triangoli
|
||||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||||
const auto& vShell = m_vPart[nPart].vShell ;
|
if ( m_vTria[i].nIdVert[0] != SVT_DEL && m_vTria[i].nPart == nPart) {
|
||||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL &&
|
|
||||||
find( vShell.begin(), vShell.end(), m_vTria[i].nShell) != vShell.end()) {
|
|
||||||
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[0]].ptP),
|
int nNewInd[3] = { pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[0]].ptP),
|
||||||
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[1]].ptP),
|
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[1]].ptP),
|
||||||
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[2]].ptP)} ;
|
pSurfTM->AddVertex( m_vVert[m_vTria[i].nIdVert[2]].ptP)} ;
|
||||||
@@ -4169,8 +3710,6 @@ SurfTriMesh::SetTFlag( int nId, int nTFlag)
|
|||||||
if ( nId < 0 || nId >= GetTriangleSize() || m_vTria[nId].nIdVert[0] == SVT_DEL)
|
if ( nId < 0 || nId >= GetTriangleSize() || m_vTria[nId].nIdVert[0] == SVT_DEL)
|
||||||
return false ;
|
return false ;
|
||||||
m_vTria[nId].nTFlag = nTFlag ;
|
m_vTria[nId].nTFlag = nTFlag ;
|
||||||
m_nMaxTFlag = max( m_nMaxTFlag, abs( nTFlag)) ;
|
|
||||||
m_OGrMgr.Clear() ;
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-40
@@ -52,16 +52,16 @@ class StmTria
|
|||||||
public :
|
public :
|
||||||
StmTria( void)
|
StmTria( void)
|
||||||
: nIdVert{ SVT_NULL, SVT_NULL, SVT_NULL}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
: nIdVert{ SVT_NULL, SVT_NULL, SVT_NULL}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
||||||
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
|
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||||
StmTria( const int nIdV[3])
|
StmTria( const int nIdV[3])
|
||||||
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
||||||
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
|
vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||||
StmTria( const int nIdV[3], int nTF)
|
StmTria( const int nIdV[3], int nTF)
|
||||||
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0},
|
||||||
vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
|
vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||||
StmTria( const int nIdV[3], const int nIdA[3], const Vector3d& vtV, int nTF, int nEF)
|
StmTria( const int nIdV[3], const int nIdA[3], const Vector3d& vtV, int nTF, int nEF)
|
||||||
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ nIdA[0], nIdA[1], nIdA[2]}, nETempFlag{ 0, 0, 0},
|
: nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ nIdA[0], nIdA[1], nIdA[2]}, nETempFlag{ 0, 0, 0},
|
||||||
vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nShell( SVT_NULL), nTemp( 0), nTempShell{ 0} {}
|
vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {}
|
||||||
public :
|
public :
|
||||||
int nIdVert[3] ;
|
int nIdVert[3] ;
|
||||||
int nIdAdjac[3] ;
|
int nIdAdjac[3] ;
|
||||||
@@ -70,25 +70,9 @@ class StmTria
|
|||||||
int nIdFacet ;
|
int nIdFacet ;
|
||||||
int nTFlag ;
|
int nTFlag ;
|
||||||
int nEFlag ;
|
int nEFlag ;
|
||||||
mutable int nShell ;
|
mutable int nPart ;
|
||||||
mutable int nTemp ;
|
mutable int nTemp ;
|
||||||
mutable int nTempShell ;
|
mutable int nTempPart ;
|
||||||
} ;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
// Classe Part
|
|
||||||
class StmPart
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
StmPart( void)
|
|
||||||
: bClosed( false) {}
|
|
||||||
StmPart( bool bClo, const INTVECTOR& vSh)
|
|
||||||
: bClosed( bClo), vShell( vSh) {}
|
|
||||||
int GetShellCount( void)
|
|
||||||
{ return ( vShell.empty() ? 0 : int( vShell.size()) - ( vShell[0] == -1 ? 1 : 0)) ; }
|
|
||||||
public :
|
|
||||||
bool bClosed ;
|
|
||||||
INTVECTOR vShell ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -251,7 +235,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
|||||||
bool RemoveTriangle( int nId) override ;
|
bool RemoveTriangle( int nId) override ;
|
||||||
bool AdjustTopology( void) override ;
|
bool AdjustTopology( void) override ;
|
||||||
bool CreateByFlatContour( const PolyLine& PL) override ;
|
bool CreateByFlatContour( const PolyLine& PL) override ;
|
||||||
bool CreateByRegion( const POLYLINEVECTOR& vPL, const INTMATRIX& vnPLIndMat) override ;
|
bool CreateByRegion( const POLYLINEVECTOR& vPL) override ;
|
||||||
bool CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) override ;
|
bool CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) override ;
|
||||||
bool CreateByPointCurve( const Point3d& ptP, const PolyLine& PL) override ;
|
bool CreateByPointCurve( const Point3d& ptP, const PolyLine& PL) override ;
|
||||||
bool CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nRuledType) override ;
|
bool CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nRuledType) override ;
|
||||||
@@ -295,7 +279,6 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
|||||||
SurfTriMesh* CloneTriangle( int nT) const override ;
|
SurfTriMesh* CloneTriangle( int nT) const override ;
|
||||||
bool GetLoops( POLYLINEVECTOR& vPL) const override ;
|
bool GetLoops( POLYLINEVECTOR& vPL) const override ;
|
||||||
bool GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL, bool bAllTria = false) const override ;
|
bool GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL, bool bAllTria = false) const override ;
|
||||||
bool GetSilhouette( const Plane3d& plPlane, double dTol, POLYLINEVECTOR& vPL, bool bAllTria = false) const override ;
|
|
||||||
int GetFacetCount( void) const override ;
|
int GetFacetCount( void) const override ;
|
||||||
int GetFacetSize( void) const override
|
int GetFacetSize( void) const override
|
||||||
{ return int( m_vFacet.size()) ; }
|
{ return int( m_vFacet.size()) ; }
|
||||||
@@ -332,17 +315,9 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
|||||||
bool Repair( double dMaxEdgeLen = MAX_EDGE_LEN_STD) override ;
|
bool Repair( double dMaxEdgeLen = MAX_EDGE_LEN_STD) override ;
|
||||||
bool GetAllTriaOverlapBox( const BBox3d& b3Box, INTVECTOR& vT) const override ;
|
bool GetAllTriaOverlapBox( const BBox3d& b3Box, INTVECTOR& vT) const override ;
|
||||||
const BBox3d& GetAllTriaBox( void) const override ;
|
const BBox3d& GetAllTriaBox( void) const override ;
|
||||||
int GetShellCount( void) const override ;
|
int GetPartCount( void) const override ;
|
||||||
bool GetShellArea( int nShell, double& dArea) const override ;
|
|
||||||
bool RemoveShell( int nShell) override ;
|
|
||||||
SurfTriMesh* CloneShell( int nShell) const override ;
|
|
||||||
int GetPartCount( void) const override ;
|
|
||||||
bool RemovePart( int nPart) override ;
|
bool RemovePart( int nPart) override ;
|
||||||
bool GetPartArea( int nPart, double& dArea) const override ;
|
|
||||||
bool GetPartVolume( int nPart, double& dVolume) const override ;
|
|
||||||
SurfTriMesh* ClonePart( int nPart) const override ;
|
SurfTriMesh* ClonePart( int nPart) const override ;
|
||||||
bool SetTFlag( int nId, int nTFlag) override ;
|
|
||||||
bool GetTFlag( int nId, int& nFlag) const override ;
|
|
||||||
int GetMaxTFlag( void) const override
|
int GetMaxTFlag( void) const override
|
||||||
{ return m_nMaxTFlag ; }
|
{ return m_nMaxTFlag ; }
|
||||||
bool ResetTFlags( void) override ;
|
bool ResetTFlags( void) override ;
|
||||||
@@ -368,14 +343,15 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
|||||||
bool ExistsTriangle( int nT) const
|
bool ExistsTriangle( int nT) const
|
||||||
{ return ( nT >= 0 && nT < GetTriangleSize() && m_vTria[nT].nIdVert[0] != SVT_DEL) ; }
|
{ return ( nT >= 0 && nT < GetTriangleSize() && m_vTria[nT].nIdVert[0] != SVT_DEL) ; }
|
||||||
bool GetTriangleAdjacencies( int nId, int nIdAdjTriaId[3]) const ;
|
bool GetTriangleAdjacencies( int nId, int nIdAdjTriaId[3]) const ;
|
||||||
|
bool GetTFlag( int nId, int& nFlag) const ;
|
||||||
bool GetTempInt( int nId, int& nTempInt) const ;
|
bool GetTempInt( int nId, int& nTempInt) const ;
|
||||||
bool ResetTempInts( void) const ;
|
bool ResetTempInts( void) const ;
|
||||||
|
bool SetTFlag( int nId, int nTFlag) ;
|
||||||
bool SetTempInt( int nId, int nTempInt) const ;
|
bool SetTempInt( int nId, int nTempInt) const ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
typedef std::vector<StmVert> VERTVECTOR ;
|
typedef std::vector<StmVert> VERTVECTOR ;
|
||||||
typedef std::vector<StmTria> TRIAVECTOR ;
|
typedef std::vector<StmTria> TRIAVECTOR ;
|
||||||
typedef std::vector<StmPart> PARTVECTOR ;
|
|
||||||
typedef std::vector<StmFacEdge> FACEDGEVECTOR ;
|
typedef std::vector<StmFacEdge> FACEDGEVECTOR ;
|
||||||
typedef std::deque<Stm3Int> TRINTDEQUE ;
|
typedef std::deque<Stm3Int> TRINTDEQUE ;
|
||||||
|
|
||||||
@@ -420,16 +396,14 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
|||||||
bool UpdateFacetEdging( void) ;
|
bool UpdateFacetEdging( void) ;
|
||||||
void ResetHashGrids3d( void) const ;
|
void ResetHashGrids3d( void) const ;
|
||||||
bool VerifyHashGrids3d( void) const ;
|
bool VerifyHashGrids3d( void) const ;
|
||||||
bool VerifyConnection( bool bShellsAndParts = true) const ;
|
bool VerifyConnection( void) const ;
|
||||||
bool IsShellClosed( int nShell) const ;
|
|
||||||
bool IsPartClosed( int nPart) const ;
|
|
||||||
bool CutTriangleByPlane( int nTriaId, const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
|
bool CutTriangleByPlane( int nTriaId, const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
|
||||||
bool CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
|
bool CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModif) ;
|
||||||
bool DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMATRIX& cvBoundClosedLoopVec, BOOLVECTOR& vbInOut) ;
|
bool DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMATRIX& cvBoundClosedLoopVec, BOOLVECTOR& vbInOut) ;
|
||||||
bool RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf, bool& bModif) ;
|
bool RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf, bool& bModif) ;
|
||||||
bool AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf) ;
|
bool AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Surf) ;
|
||||||
bool IntersectTriMeshTriangle( SurfTriMesh& Other) ;
|
bool IntersectTriMeshTriangle( SurfTriMesh& Other) ;
|
||||||
bool IdentifyShells( void) const ;
|
bool IdentifyParts( void) const ;
|
||||||
bool RemoveDoubleTriangles( bool& bModified) ;
|
bool RemoveDoubleTriangles( bool& bModified) ;
|
||||||
bool RemoveTJunctions( bool& bModified) ;
|
bool RemoveTJunctions( bool& bModified) ;
|
||||||
bool FlipTriangles( int nTA, int nTB) ;
|
bool FlipTriangles( int nTA, int nTB) ;
|
||||||
@@ -460,8 +434,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
|||||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||||
int m_nMaxTFlag ; // massimo valore dei TFlag dei triangoli
|
int m_nMaxTFlag ; // massimo valore dei TFlag dei triangoli
|
||||||
mutable int m_nShells ; // numero di gusci connessi (-1 se da calcolare)
|
mutable int m_nParts ; // numero di parti connesse (-1 se da calcolare)
|
||||||
mutable PARTVECTOR m_vPart ; // vettore delle parti (flag chiusura e elenco shell, prima sempre esterna o infinita)
|
|
||||||
mutable HashGrids3d* m_pHGrd3d ; // Hash Grid 3d nel suo riferimento
|
mutable HashGrids3d* m_pHGrd3d ; // Hash Grid 3d nel suo riferimento
|
||||||
mutable BBox3d m_b3HGrd3d ; // Box3d collegato a Hash Grid 3d
|
mutable BBox3d m_b3HGrd3d ; // Box3d collegato a Hash Grid 3d
|
||||||
} ;
|
} ;
|
||||||
|
|||||||
+254
-179
@@ -17,14 +17,13 @@
|
|||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
#include "SurfFlatRegion.h"
|
#include "SurfFlatRegion.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "Triangulate.h"
|
#include "Triangulate.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
#include "/EgtDev/Include/EGkCurve.h"
|
#include "/EgtDev/Include/EGkCurve.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointTria.h"
|
#include "/EgtDev/Include/EGkDistPointTria.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
||||||
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
|
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
|
||||||
@@ -73,7 +72,8 @@ SurfTriMesh::DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMA
|
|||||||
bool bChangedStart = ChangeStart( ptOpenLoopStP, cvBoundClosedLoopVec[nLoop]) ;
|
bool bChangedStart = ChangeStart( ptOpenLoopStP, cvBoundClosedLoopVec[nLoop]) ;
|
||||||
// splitto
|
// splitto
|
||||||
bool bSplitted = SplitAtPoint( ptOpenLoopEnP, cvBoundClosedLoopVec[nLoop], Loop1, Loop2) ;
|
bool bSplitted = SplitAtPoint( ptOpenLoopEnP, cvBoundClosedLoopVec[nLoop], Loop1, Loop2) ;
|
||||||
if ( ! ( bChangedStart && bSplitted))
|
if ( ! ( bChangedStart && bSplitted) ||
|
||||||
|
( nLastOpenLoopPoint == 0 && ( Loop1.size() == 2 || Loop2.size() == 2)))
|
||||||
continue ; // la catena aperta non è interna al loop chiuso attuale
|
continue ; // la catena aperta non è interna al loop chiuso attuale
|
||||||
|
|
||||||
// il loop 2 segue sempre la direzione della catena, il loop 1 ha dentro la catena invertita
|
// il loop 2 segue sempre la direzione della catena, il loop 1 ha dentro la catena invertita
|
||||||
@@ -432,9 +432,9 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
int nSameSeg = 0 ;
|
int nSameSeg = 0 ;
|
||||||
for ( int nSeg1 = 0 ; nSeg1 < nChainSize1 ; ++ nSeg1) {
|
for ( int nSeg1 = 0 ; nSeg1 < nChainSize1 ; ++ nSeg1) {
|
||||||
for ( int nSeg2 = 0 ; nSeg2 < nChainSize2 ; ++ nSeg2) {
|
for ( int nSeg2 = 0 ; nSeg2 < nChainSize2 ; ++ nSeg2) {
|
||||||
if ( AreSamePointEpsilon( cvOpenChain[nCh1][nSeg1].ptSt, cvOpenChain[nCh2][nSeg2].ptSt, 100 * EPS_ZERO) &&
|
if ( AreSamePointExact( cvOpenChain[nCh1][nSeg1].ptSt, cvOpenChain[nCh2][nSeg2].ptSt) &&
|
||||||
AreSamePointEpsilon( cvOpenChain[nCh1][nSeg1].ptEn, cvOpenChain[nCh2][nSeg2].ptEn, 100 * EPS_ZERO) &&
|
AreSamePointExact( cvOpenChain[nCh1][nSeg1].ptEn, cvOpenChain[nCh2][nSeg2].ptEn) &&
|
||||||
AreSameVectorEpsilon( cvOpenChain[nCh1][nSeg1].vtOuter, cvOpenChain[nCh2][nSeg2].vtOuter, 100 * EPS_ZERO)) {
|
AreSameVectorExact( cvOpenChain[nCh1][nSeg1].vtOuter, cvOpenChain[nCh2][nSeg2].vtOuter)) {
|
||||||
++ nSameSeg ;
|
++ nSameSeg ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,7 +477,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
Surf.m_vTria[nNewAloneTriaNum].nETempFlag[0] = 0 ;
|
Surf.m_vTria[nNewAloneTriaNum].nETempFlag[0] = 0 ;
|
||||||
Surf.m_vTria[nNewAloneTriaNum].nETempFlag[1] = 0 ;
|
Surf.m_vTria[nNewAloneTriaNum].nETempFlag[1] = 0 ;
|
||||||
Surf.m_vTria[nNewAloneTriaNum].nETempFlag[2] = 0 ;
|
Surf.m_vTria[nNewAloneTriaNum].nETempFlag[2] = 0 ;
|
||||||
Surf.m_vTria[nNewAloneTriaNum].nTempShell = nDist[nAloneVert] ;
|
Surf.m_vTria[nNewAloneTriaNum].nTempPart = nDist[nAloneVert] ;
|
||||||
bModif = true ;
|
bModif = true ;
|
||||||
}
|
}
|
||||||
int nNewCoupleId1[3] = { Surf.AddVertex( ptIntSt), Surf.AddVertex( trTria.GetP( ( nAloneVert + 1) % 3)), Surf.AddVertex( trTria.GetP( ( nAloneVert + 2) % 3)) } ;
|
int nNewCoupleId1[3] = { Surf.AddVertex( ptIntSt), Surf.AddVertex( trTria.GetP( ( nAloneVert + 1) % 3)), Surf.AddVertex( trTria.GetP( ( nAloneVert + 2) % 3)) } ;
|
||||||
@@ -486,7 +486,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
Surf.m_vTria[nNewCoupleTriaNum1].nETempFlag[0] = 0 ;
|
Surf.m_vTria[nNewCoupleTriaNum1].nETempFlag[0] = 0 ;
|
||||||
Surf.m_vTria[nNewCoupleTriaNum1].nETempFlag[1] = 0 ;
|
Surf.m_vTria[nNewCoupleTriaNum1].nETempFlag[1] = 0 ;
|
||||||
Surf.m_vTria[nNewCoupleTriaNum1].nETempFlag[2] = 0 ;
|
Surf.m_vTria[nNewCoupleTriaNum1].nETempFlag[2] = 0 ;
|
||||||
Surf.m_vTria[nNewCoupleTriaNum1].nTempShell = - nDist[nAloneVert] ;
|
Surf.m_vTria[nNewCoupleTriaNum1].nTempPart = - nDist[nAloneVert] ;
|
||||||
bModif = true ;
|
bModif = true ;
|
||||||
}
|
}
|
||||||
int nNewCoupleId2[3] = { Surf.AddVertex( ptIntSt), Surf.AddVertex( trTria.GetP( ( nAloneVert + 2) % 3)), Surf.AddVertex( ptIntEn) } ;
|
int nNewCoupleId2[3] = { Surf.AddVertex( ptIntSt), Surf.AddVertex( trTria.GetP( ( nAloneVert + 2) % 3)), Surf.AddVertex( ptIntEn) } ;
|
||||||
@@ -495,7 +495,7 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
Surf.m_vTria[nNewCoupleTriaNum2].nETempFlag[0] = 0 ;
|
Surf.m_vTria[nNewCoupleTriaNum2].nETempFlag[0] = 0 ;
|
||||||
Surf.m_vTria[nNewCoupleTriaNum2].nETempFlag[1] = 0 ;
|
Surf.m_vTria[nNewCoupleTriaNum2].nETempFlag[1] = 0 ;
|
||||||
Surf.m_vTria[nNewCoupleTriaNum2].nETempFlag[2] = 0 ;
|
Surf.m_vTria[nNewCoupleTriaNum2].nETempFlag[2] = 0 ;
|
||||||
Surf.m_vTria[nNewCoupleTriaNum2].nTempShell = - nDist[nAloneVert] ;
|
Surf.m_vTria[nNewCoupleTriaNum2].nTempPart = - nDist[nAloneVert] ;
|
||||||
bModif = true ;
|
bModif = true ;
|
||||||
}
|
}
|
||||||
continue ;
|
continue ;
|
||||||
@@ -561,18 +561,18 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
vnDegVec.resize( 1) ;
|
vnDegVec.resize( 1) ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Surf.m_vTria[it->first].nTempShell = 0 ;
|
Surf.m_vTria[it->first].nTempPart = 0 ;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
vbInOut.resize( 1) ;
|
vbInOut.resize( 1) ;
|
||||||
vbInOut[0] = true ;
|
vbInOut[0] = true ;
|
||||||
if ( ! DecomposeLoop( cvOpenChain, vnDegVec, cvBoundClosedLoopVec, vbInOut)) {
|
if ( ! DecomposeLoop( cvOpenChain, vnDegVec, cvBoundClosedLoopVec, vbInOut)) {
|
||||||
Surf.m_vTria[it->first].nTempShell = 0 ;
|
Surf.m_vTria[it->first].nTempPart = 0 ;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Surf.m_vTria[it->first].nTempShell = 0 ;
|
Surf.m_vTria[it->first].nTempPart = 0 ;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -730,9 +730,9 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
||||||
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
||||||
if ( vbInOut[nLoop])
|
if ( vbInOut[nLoop])
|
||||||
Surf.m_vTria[nNewTriaNum].nTempShell = 1 ;
|
Surf.m_vTria[nNewTriaNum].nTempPart = 1 ;
|
||||||
else
|
else
|
||||||
Surf.m_vTria[nNewTriaNum].nTempShell = - 1 ;
|
Surf.m_vTria[nNewTriaNum].nTempPart = - 1 ;
|
||||||
bModif = true ;
|
bModif = true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -827,9 +827,9 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
||||||
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
||||||
if ( bCodirectedNormals)
|
if ( bCodirectedNormals)
|
||||||
Surf.m_vTria[nNewTriaNum].nTempShell = -1 ;
|
Surf.m_vTria[nNewTriaNum].nTempPart = -1 ;
|
||||||
else
|
else
|
||||||
Surf.m_vTria[nNewTriaNum].nTempShell = 1 ;
|
Surf.m_vTria[nNewTriaNum].nTempPart = 1 ;
|
||||||
bModif = true ;
|
bModif = true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -982,9 +982,9 @@ SurfTriMesh::RetriangulationForBooleanOperation( CHAINMAP& LoopLines, TRIA3DVECT
|
|||||||
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
Surf.m_vTria[nNewTriaNum].nETempFlag[1] = 0 ;
|
||||||
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
Surf.m_vTria[nNewTriaNum].nETempFlag[2] = 0 ;
|
||||||
if ( bCordirectedNormals_intLoop)
|
if ( bCordirectedNormals_intLoop)
|
||||||
Surf.m_vTria[nNewTriaNum].nTempShell = 1 ;
|
Surf.m_vTria[nNewTriaNum].nTempPart = 1 ;
|
||||||
else
|
else
|
||||||
Surf.m_vTria[nNewTriaNum].nTempShell = -1 ;
|
Surf.m_vTria[nNewTriaNum].nTempPart = -1 ;
|
||||||
bModif = true ;
|
bModif = true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1037,7 +1037,7 @@ SurfTriMesh::AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Su
|
|||||||
for ( auto it = Ambiguos.begin() ; it != Ambiguos.end() ; ++ it) {
|
for ( auto it = Ambiguos.begin() ; it != Ambiguos.end() ; ++ it) {
|
||||||
// Se il triangolo ha l'indice diverso da zero vuol dire che oltre a un
|
// Se il triangolo ha l'indice diverso da zero vuol dire che oltre a un
|
||||||
// contatto edge-edge ha avuto dei contatti che lo hanno già classificato.
|
// contatto edge-edge ha avuto dei contatti che lo hanno già classificato.
|
||||||
if ( Surf.m_vTria[it->first].nTempShell != 0)
|
if ( Surf.m_vTria[it->first].nTempPart != 0)
|
||||||
continue ;
|
continue ;
|
||||||
// Recupero il triangolo corrente
|
// Recupero il triangolo corrente
|
||||||
Triangle3d trTria ;
|
Triangle3d trTria ;
|
||||||
@@ -1101,11 +1101,11 @@ SurfTriMesh::AmbiguosTriangleManager( TRIA3DVECTORMAP& Ambiguos, SurfTriMesh& Su
|
|||||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||||
if ( nTriaClassificationByEdges[i] == 0)
|
if ( nTriaClassificationByEdges[i] == 0)
|
||||||
continue ;
|
continue ;
|
||||||
Surf.m_vTria[it->first].nTempShell = nTriaClassificationByEdges[i] ;
|
Surf.m_vTria[it->first].nTempPart = nTriaClassificationByEdges[i] ;
|
||||||
int j ;
|
int j ;
|
||||||
for ( j = i + 1 ; j < 3 ; ++ j) {
|
for ( j = i + 1 ; j < 3 ; ++ j) {
|
||||||
if ( nTriaClassificationByEdges[j] != 0 && nTriaClassificationByEdges[i] != nTriaClassificationByEdges[j]) {
|
if ( nTriaClassificationByEdges[j] != 0 && nTriaClassificationByEdges[i] != nTriaClassificationByEdges[j]) {
|
||||||
Surf.m_vTria[it->first].nTempShell = 0 ;
|
Surf.m_vTria[it->first].nTempPart = 0 ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1145,13 +1145,13 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
|||||||
|
|
||||||
// Setto il triangolo come né fuori né dentro
|
// Setto il triangolo come né fuori né dentro
|
||||||
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
||||||
m_vTria[nTA].nTempShell = 0 ;
|
m_vTria[nTA].nTempPart = 0 ;
|
||||||
m_vTria[nTA].nETempFlag[0] = 0 ;
|
m_vTria[nTA].nETempFlag[0] = 0 ;
|
||||||
m_vTria[nTA].nETempFlag[1] = 0 ;
|
m_vTria[nTA].nETempFlag[1] = 0 ;
|
||||||
m_vTria[nTA].nETempFlag[2] = 0 ;
|
m_vTria[nTA].nETempFlag[2] = 0 ;
|
||||||
}
|
}
|
||||||
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
||||||
SurfB.m_vTria[nTB].nTempShell = 0 ;
|
SurfB.m_vTria[nTB].nTempPart = 0 ;
|
||||||
SurfB.m_vTria[nTB].nETempFlag[0] = 0 ;
|
SurfB.m_vTria[nTB].nETempFlag[0] = 0 ;
|
||||||
SurfB.m_vTria[nTB].nETempFlag[1] = 0 ;
|
SurfB.m_vTria[nTB].nETempFlag[1] = 0 ;
|
||||||
SurfB.m_vTria[nTB].nETempFlag[2] = 0 ;
|
SurfB.m_vTria[nTB].nETempFlag[2] = 0 ;
|
||||||
@@ -1259,9 +1259,9 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
|||||||
abs( ( trTriaA.GetP( ( nVA + 1) % 3) - trTriaB.GetP( 0)) * trTriaB.GetN()) < EPS_SMALL)
|
abs( ( trTriaA.GetP( ( nVA + 1) % 3) - trTriaB.GetP( 0)) * trTriaB.GetN()) < EPS_SMALL)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
m_vTria[nTA].nTempShell = ( ( trTriaA.GetP( nSegMaxDist) - trTriaB.GetP( 0)) * trTriaB.GetN() < - EPS_SMALL ? 1 : - 1) ;
|
m_vTria[nTA].nTempPart = ( ( trTriaA.GetP( nSegMaxDist) - trTriaB.GetP( 0)) * trTriaB.GetN() < - EPS_SMALL ? 1 : - 1) ;
|
||||||
if ( nVA >= 0 && nVA <= 2)
|
if ( nVA >= 0 && nVA <= 2)
|
||||||
m_vTria[nTA].nETempFlag[nVA] = m_vTria[nTA].nTempShell ;
|
m_vTria[nTA].nETempFlag[nVA] = m_vTria[nTA].nTempPart ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// caso di Intersezione interno-edge ( per superficie A con B)
|
// caso di Intersezione interno-edge ( per superficie A con B)
|
||||||
@@ -1284,9 +1284,9 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
|||||||
abs( ( trTriaB.GetP( ( nVB + 1) % 3) - trTriaA.GetP( 0)) * trTriaA.GetN()) < EPS_SMALL)
|
abs( ( trTriaB.GetP( ( nVB + 1) % 3) - trTriaA.GetP( 0)) * trTriaA.GetN()) < EPS_SMALL)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
SurfB.m_vTria[vNearTria[nTB]].nTempShell = ( ( trTriaB.GetP( nSegMaxDist) - trTriaA.GetP( 0)) * trTriaA.GetN() < - EPS_SMALL ? 1 : - 1) ;
|
SurfB.m_vTria[vNearTria[nTB]].nTempPart = ( ( trTriaB.GetP( nSegMaxDist) - trTriaA.GetP( 0)) * trTriaA.GetN() < - EPS_SMALL ? 1 : - 1) ;
|
||||||
if ( nVB >= 0 && nVB <= 2)
|
if ( nVB >= 0 && nVB <= 2)
|
||||||
SurfB.m_vTria[vNearTria[nTB]].nETempFlag[nVB] = SurfB.m_vTria[vNearTria[nTB]].nTempShell ;
|
SurfB.m_vTria[vNearTria[nTB]].nETempFlag[nVB] = SurfB.m_vTria[vNearTria[nTB]].nTempPart ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Intersezione edge-edge: salvo indice e vettore triangoli
|
// Intersezione edge-edge: salvo indice e vettore triangoli
|
||||||
@@ -1326,28 +1326,171 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
|||||||
bool bRetriangulated = true ;
|
bool bRetriangulated = true ;
|
||||||
if ( ! bModif && ( int( AmbiguosA.size()) == 0 || int( AmbiguosB.size()) == 0)) {
|
if ( ! bModif && ( int( AmbiguosA.size()) == 0 || int( AmbiguosB.size()) == 0)) {
|
||||||
bRetriangulated = false ;
|
bRetriangulated = false ;
|
||||||
// devo assegnare a tutti i triangoli della superficie la medesima proprietà ( definita da nInOutNum)
|
int nVertNum = 0 ;
|
||||||
// ( -1 -> esterno | 0 -> indefinito | +1 -> interno )
|
Point3d ptFirstV ;
|
||||||
// devo farlo sia per la SurfA( *this) che per la SurfB
|
int nCurVert = GetFirstVertex( ptFirstV) ;
|
||||||
int nInOutNum = 0 ;
|
int nInOutNum = 0 ;
|
||||||
for ( int v = 0 ; v < int( m_vVert.size()) && nInOutNum == 0 ; ++ v) {
|
while ( nInOutNum == 0 && nCurVert != SVT_NULL) {
|
||||||
double dDist = 0. ;
|
INTVECTOR vnTriaNum ;
|
||||||
DistPointSurfTm distCalculator( m_vVert[v].ptP, SurfB) ;
|
double dMinDist = DBL_MAX ;
|
||||||
if ( distCalculator.GetDist( dDist) && dDist > EPS_SMALL)
|
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
||||||
nInOutNum = ( distCalculator.IsPointOnLeftSide() ? 1 : -1) ;
|
// Se il triangolo B non è valido, continuo
|
||||||
|
Triangle3d trTriaB ;
|
||||||
|
if ( ! SurfB.GetTriangle( nTB, trTriaB) || ! trTriaB.Validate( true))
|
||||||
|
continue ;
|
||||||
|
double dDist ;
|
||||||
|
// potrei trovare più triangolo equidistanti, li salvo tutti
|
||||||
|
if ( DistPointTriangle( ptFirstV, trTriaB).GetDist( dDist)) {
|
||||||
|
if ( abs(dDist - dMinDist) < EPS_SMALL)
|
||||||
|
vnTriaNum.push_back( nTB) ;
|
||||||
|
else if ( dDist < dMinDist){
|
||||||
|
vnTriaNum.clear() ;
|
||||||
|
vnTriaNum.push_back( nTB) ;
|
||||||
|
dMinDist = dDist ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ! vnTriaNum.empty()) {
|
||||||
|
Triangle3d trTriaB ;
|
||||||
|
bool bSame = true ;
|
||||||
|
// controllo se rispetto a questi triangoli il punto risulta sempre fuori o sempre dentro
|
||||||
|
for ( int nTriaNum : vnTriaNum) {
|
||||||
|
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||||
|
if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() < - EPS_SMALL) {
|
||||||
|
if ( nInOutNum == 0)
|
||||||
|
nInOutNum = 1 ;
|
||||||
|
else if ( nInOutNum == -1) {
|
||||||
|
bSame = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( ( ptFirstV - trTriaB.GetP(0)) * trTriaB.GetN() > EPS_SMALL) {
|
||||||
|
if ( nInOutNum == 0)
|
||||||
|
nInOutNum = -1 ;
|
||||||
|
else if ( nInOutNum == 1) {
|
||||||
|
bSame = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// se le informazioni date dalle normali dei triangoli non sono concordi valuto il triangolo più vicino
|
||||||
|
// e ricalcolo l'informazione che mi dà la sua normale
|
||||||
|
if ( ! bSame) {
|
||||||
|
Point3d ptBar_tot ;
|
||||||
|
for (int nTriaNum : vnTriaNum) {
|
||||||
|
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||||
|
ptBar_tot += trTriaB.GetCentroid();
|
||||||
|
}
|
||||||
|
ptBar_tot /= int( vnTriaNum.size()) ;
|
||||||
|
for ( int nTriaNum : vnTriaNum) {
|
||||||
|
SurfB.GetTriangle( nTriaNum, trTriaB) ;
|
||||||
|
Point3d ptInters1, ptInters2 ;
|
||||||
|
int nInters = IntersLineTria( ptFirstV, ptBar_tot, trTriaB, ptInters1, ptInters2, true) ;
|
||||||
|
if ( nInters == ILTT_NO)
|
||||||
|
continue ;
|
||||||
|
else if ( nInters == ILTT_IN) {
|
||||||
|
if ( ( ptFirstV - trTriaB.GetP( 0)) * trTriaB.GetN() < - EPS_SMALL)
|
||||||
|
nInOutNum = 1 ;
|
||||||
|
else if ( ( ptFirstV - trTriaB.GetP( 0)) * trTriaB.GetN() > EPS_SMALL)
|
||||||
|
nInOutNum = -1 ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nInOutNum = 0 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( nInOutNum == 0) {
|
||||||
|
nCurVert = GetNextVertex( nVertNum, ptFirstV) ;
|
||||||
|
++ nVertNum ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA)
|
|
||||||
m_vTria[nTA].nTempShell = nInOutNum ;
|
|
||||||
|
|
||||||
|
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA)
|
||||||
|
m_vTria[nTA].nTempPart = nInOutNum ;
|
||||||
|
|
||||||
|
nVertNum = 0 ;
|
||||||
|
nCurVert = SurfB.GetFirstVertex( ptFirstV) ;
|
||||||
nInOutNum = 0 ;
|
nInOutNum = 0 ;
|
||||||
for ( int v = 0 ; v < int( SurfB.m_vVert.size()) && nInOutNum == 0 ; ++ v) {
|
while ( nInOutNum == 0 && nCurVert != SVT_NULL) {
|
||||||
double dDist = 0. ;
|
INTVECTOR vnTriaNum ;
|
||||||
DistPointSurfTm distCalculator( SurfB.m_vVert[v].ptP, *this) ;
|
double dMinDist = DBL_MAX ;
|
||||||
if ( distCalculator.GetDist( dDist) && dDist > EPS_SMALL)
|
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
||||||
nInOutNum = ( distCalculator.IsPointOnLeftSide() ? 1 : -1) ;
|
// Se il triangolo A non è valido, continuo
|
||||||
|
Triangle3d trTriaA ;
|
||||||
|
if ( ! ( GetTriangle( nTA, trTriaA) && trTriaA.Validate( true)))
|
||||||
|
continue ;
|
||||||
|
DistPointTriangle DistCalculator( ptFirstV, trTriaA) ;
|
||||||
|
double dDist ;
|
||||||
|
DistCalculator.GetDist( dDist) ;
|
||||||
|
// potrei trovare più triangolo equidistanti, li salvo tutti
|
||||||
|
if ( DistPointTriangle( ptFirstV, trTriaA).GetDist( dDist)) {
|
||||||
|
if ( abs( dDist - dMinDist) < EPS_SMALL)
|
||||||
|
vnTriaNum.push_back( nTA) ;
|
||||||
|
else if ( dDist < dMinDist){
|
||||||
|
vnTriaNum.clear() ;
|
||||||
|
vnTriaNum.push_back( nTA) ;
|
||||||
|
dMinDist = dDist ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ! vnTriaNum.empty()) {
|
||||||
|
Triangle3d trTriaA ;
|
||||||
|
bool bSame = true ;
|
||||||
|
// controllo se rispetto a questi triangoli il punto risulta sempre fuori o sempre dentro
|
||||||
|
for ( int nTriaNum : vnTriaNum) {
|
||||||
|
GetTriangle( nTriaNum, trTriaA) ;
|
||||||
|
if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() < - EPS_SMALL) {
|
||||||
|
if ( nInOutNum == 0)
|
||||||
|
nInOutNum = 1 ;
|
||||||
|
else if ( nInOutNum == -1) {
|
||||||
|
bSame = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( ( ptFirstV - trTriaA.GetP(0)) * trTriaA.GetN() > EPS_SMALL) {
|
||||||
|
if ( nInOutNum == 0)
|
||||||
|
nInOutNum = -1 ;
|
||||||
|
else if ( nInOutNum == 1) {
|
||||||
|
bSame = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// se le informazioni date dalle normali dei triangoli non sono concordi valuto il triangolo più vicino
|
||||||
|
// e ricalcolo l'informazione che mi dà la sua normale
|
||||||
|
if ( ! bSame) {
|
||||||
|
Point3d ptBar_tot ;
|
||||||
|
for ( int nTriaNum : vnTriaNum) {
|
||||||
|
GetTriangle( nTriaNum, trTriaA) ;
|
||||||
|
ptBar_tot += trTriaA.GetCentroid();
|
||||||
|
}
|
||||||
|
ptBar_tot /= int( vnTriaNum.size()) ;
|
||||||
|
for ( int nTriaNum : vnTriaNum) {
|
||||||
|
GetTriangle( nTriaNum, trTriaA) ;
|
||||||
|
Point3d ptInters1, ptInters2 ;
|
||||||
|
int nInters = IntersLineTria( ptFirstV, ptBar_tot, trTriaA, ptInters1, ptInters2, true) ;
|
||||||
|
if ( nInters == ILTT_NO)
|
||||||
|
continue ;
|
||||||
|
else if ( nInters == ILTT_IN) {
|
||||||
|
if ( ( ptFirstV - trTriaA.GetP( 0)) * trTriaA.GetN() < - EPS_SMALL)
|
||||||
|
nInOutNum = 1 ;
|
||||||
|
else if ( ( ptFirstV - trTriaA.GetP( 0)) * trTriaA.GetN() > EPS_SMALL)
|
||||||
|
nInOutNum = -1 ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nInOutNum = 0 ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( nInOutNum == 0) {
|
||||||
|
nCurVert = SurfB.GetNextVertex( nVertNum, ptFirstV) ;
|
||||||
|
++ nVertNum ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB)
|
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB)
|
||||||
SurfB.m_vTria[nTB].nTempShell = nInOutNum ;
|
SurfB.m_vTria[nTB].nTempPart = nInOutNum ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Se c'è stata una ritriangolazione di almeno un triangolo, NON siamo nel caso di tutto dentro o tutto fuori.
|
// Se c'è stata una ritriangolazione di almeno un triangolo, NON siamo nel caso di tutto dentro o tutto fuori.
|
||||||
@@ -1388,12 +1531,12 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
|||||||
Point3d ptTempA, ptTempB ;
|
Point3d ptTempA, ptTempB ;
|
||||||
int nIntTypeAB = IntersTriaTria( trTriaA, trTriaB, ptTempA, ptTempB, vTriaAB) ;
|
int nIntTypeAB = IntersTriaTria( trTriaA, trTriaB, ptTempA, ptTempB, vTriaAB) ;
|
||||||
if ( nIntTypeAB == ITTT_OVERLAPS) {
|
if ( nIntTypeAB == ITTT_OVERLAPS) {
|
||||||
m_vTria[nTA].nTempShell = 2 ;
|
m_vTria[nTA].nTempPart = 2 ;
|
||||||
SurfB.m_vTria[vNearTria[nTB]].nTempShell = 2 ;
|
SurfB.m_vTria[vNearTria[nTB]].nTempPart = 2 ;
|
||||||
}
|
}
|
||||||
else if ( nIntTypeAB == ITTT_COUNTER_OVERLAPS) {
|
else if ( nIntTypeAB == ITTT_COUNTER_OVERLAPS) {
|
||||||
m_vTria[nTA].nTempShell = -2 ;
|
m_vTria[nTA].nTempPart = -2 ;
|
||||||
SurfB.m_vTria[vNearTria[nTB]].nTempShell = -2 ;
|
SurfB.m_vTria[vNearTria[nTB]].nTempPart = -2 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1405,12 +1548,12 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
SurfTriMesh::IdentifyShells( void) const
|
SurfTriMesh::IdentifyParts( void) const
|
||||||
{
|
{
|
||||||
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) {
|
||||||
// salto triangoli cancellati o già assegnati
|
// salto triangoli cancellati o già assegnati
|
||||||
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
|
if ( m_vTria[i].nIdVert[0] == SVT_DEL ||
|
||||||
abs( m_vTria[i].nTempShell) != 1)
|
abs( m_vTria[i].nTempPart) != 1)
|
||||||
continue ;
|
continue ;
|
||||||
// set di triangoli da aggiornare
|
// set di triangoli da aggiornare
|
||||||
set<int> stTria ;
|
set<int> stTria ;
|
||||||
@@ -1425,8 +1568,8 @@ SurfTriMesh::IdentifyShells( void) const
|
|||||||
if ( m_vTria[nT].nETempFlag[j] != 0)
|
if ( m_vTria[nT].nETempFlag[j] != 0)
|
||||||
continue ;
|
continue ;
|
||||||
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
|
int nAdjT = m_vTria[nT].nIdAdjac[j] ;
|
||||||
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nTempShell == 0) {
|
if ( nAdjT != SVT_NULL && m_vTria[nAdjT].nTempPart == 0) {
|
||||||
m_vTria[nAdjT].nTempShell = m_vTria[nT].nTempShell ;
|
m_vTria[nAdjT].nTempPart = m_vTria[nT].nTempPart ;
|
||||||
stTria.insert( nAdjT) ;
|
stTria.insert( nAdjT) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1440,102 +1583,66 @@ SurfTriMesh::IdentifyShells( void) const
|
|||||||
bool
|
bool
|
||||||
SurfTriMesh::Add( const ISurfTriMesh& Other)
|
SurfTriMesh::Add( const ISurfTriMesh& Other)
|
||||||
{
|
{
|
||||||
|
// Le superfici devono essere valide
|
||||||
// le superfici devono essere valide
|
|
||||||
if ( ! IsValid() || ! Other.IsValid())
|
if ( ! IsValid() || ! Other.IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// se la seconda è vuota non devo fare alcunchè
|
// Se la seconda è vuota non devo fare alcunchè
|
||||||
if ( Other.IsEmpty())
|
if ( Other.IsEmpty())
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
m_OGrMgr.Clear() ;
|
m_OGrMgr.Clear() ;
|
||||||
|
|
||||||
// se la prima è vuota, copio la seconda nella prima
|
// Se la prima è vuota, copio la seconda nella prima
|
||||||
if ( IsEmpty()) {
|
if ( IsEmpty()) {
|
||||||
CopyFrom( &Other) ;
|
CopyFrom( &Other) ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clono la superficie B
|
|
||||||
SurfTriMesh SurfB ;
|
SurfTriMesh SurfB ;
|
||||||
SurfB.CopyFrom( &Other) ;
|
SurfB.CopyFrom( &Other) ;
|
||||||
|
|
||||||
// creazione del frame per scalare A e B
|
|
||||||
Frame3d frScalingRef ;
|
Frame3d frScalingRef ;
|
||||||
frScalingRef.Set( m_vVert[0].ptP, X_AX, Y_AX, Z_AX) ;
|
frScalingRef.Set( m_vVert[0].ptP, X_AX, Y_AX, Z_AX) ;
|
||||||
// scalo A e B
|
|
||||||
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
SurfB.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
SurfB.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
|
||||||
SurfTriMesh SurfB_cl ;
|
|
||||||
SurfB_cl.CopyFrom( &SurfB) ;
|
|
||||||
|
|
||||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
|
||||||
SurfTriMesh SurfA_cl ;
|
|
||||||
SurfA_cl.CopyFrom( this) ;
|
|
||||||
|
|
||||||
// ritriangolo le due superfici mediante ogni intersezione Triangolo-Triangolo
|
|
||||||
IntersectTriMeshTriangle( SurfB) ;
|
IntersectTriMeshTriangle( SurfB) ;
|
||||||
|
IdentifyParts() ;
|
||||||
|
SurfB.IdentifyParts() ;
|
||||||
|
|
||||||
// assegno un medesimo indice ai triangoli che non interferiscono con altri
|
|
||||||
IdentifyShells() ;
|
|
||||||
SurfB.IdentifyShells() ;
|
|
||||||
|
|
||||||
// rimozione dei triangoli di A con proprietà 1 e -2 ( e gestione dei triangoli ambigui, 0)
|
|
||||||
int nTriaNumA = GetTriangleSize() ;
|
int nTriaNumA = GetTriangleSize() ;
|
||||||
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
||||||
if ( m_vTria[nTA].nTempShell == 1 || m_vTria[nTA].nTempShell == - 2)
|
if ( m_vTria[nTA].nTempPart == 1 || m_vTria[nTA].nTempPart == - 2)
|
||||||
RemoveTriangle( nTA) ;
|
RemoveTriangle( nTA) ;
|
||||||
// se triangolo ambiguo
|
|
||||||
if ( m_vTria[nTA].nTempShell == 0) {
|
|
||||||
Triangle3d TriaA ;
|
|
||||||
GetTriangle( nTA, TriaA) ;
|
|
||||||
// rimuovo il triangolo se interno a surfB ( basta controllare un solo vertice(?) )
|
|
||||||
DistPointSurfTm distCalculator( TriaA.GetP( 0), SurfB_cl) ;
|
|
||||||
if ( distCalculator.IsPointOnLeftSide())
|
|
||||||
RemoveTriangle( nTA) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggiunta di tutti i triangoli di B con proprietà -1 ( e gestione dei triangoli ambigui, 0)
|
|
||||||
int nPrevMaxTFlag = m_nMaxTFlag ;
|
int nPrevMaxTFlag = m_nMaxTFlag ;
|
||||||
int nTriaNumB = SurfB.GetTriangleSize() ;
|
int nTriaNumB = SurfB.GetTriangleSize() ;
|
||||||
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
||||||
bool bAdd = ( SurfB.m_vTria[nTB].nTempShell == - 1) ;
|
if ( SurfB.m_vTria[nTB].nTempPart == - 1) {
|
||||||
if ( ! bAdd) {
|
|
||||||
// se ambiguo
|
|
||||||
if ( SurfB.m_vTria[nTB].nTempShell == 0) {
|
|
||||||
// aggiungo se il triangolo è a surfA ( basta controllare un solo vertice(?) )
|
|
||||||
DistPointSurfTm distCalculator( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[0]].ptP, SurfA_cl) ;
|
|
||||||
bAdd = ! distCalculator.IsPointOnLeftSide() ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bAdd) {
|
|
||||||
int nNewVert[3] ;
|
int nNewVert[3] ;
|
||||||
for ( int nV = 0 ; nV < 3 ; ++ nV)
|
for ( int nV = 0 ; nV < 3 ; ++ nV) {
|
||||||
nNewVert[nV] = AddVertex( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[nV]].ptP) ;
|
nNewVert[nV] = AddVertex( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[nV]].ptP) ;
|
||||||
|
}
|
||||||
if ( nPrevMaxTFlag == m_nMaxTFlag)
|
if ( nPrevMaxTFlag == m_nMaxTFlag)
|
||||||
++ m_nMaxTFlag ;
|
++ m_nMaxTFlag ;
|
||||||
AddTriangle( nNewVert, m_nMaxTFlag) ;
|
AddTriangle( nNewVert, m_nMaxTFlag) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sistemazioni varie
|
|
||||||
bool bOk = ( AdjustVertices() && DoCompacting()) ;
|
bool bOk = ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
bool bModified = false ;
|
bool bModified = false ;
|
||||||
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
||||||
if ( bModified)
|
if ( bModified)
|
||||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
bOk = bOk && RemoveTJunctions( bModified) ;
|
bOk = bOk && RemoveTJunctions( bModified) ;
|
||||||
if ( bModified)
|
if ( bModified)
|
||||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
// scalo alla dimensioni originali
|
|
||||||
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
// semplifico eventuale geometria delle facce
|
|
||||||
if ( ! SimplifyFacets())
|
if ( ! SimplifyFacets())
|
||||||
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Add")
|
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Add")
|
||||||
|
|
||||||
@@ -1546,7 +1653,6 @@ SurfTriMesh::Add( const ISurfTriMesh& Other)
|
|||||||
bool
|
bool
|
||||||
SurfTriMesh::Intersect( const ISurfTriMesh& Other)
|
SurfTriMesh::Intersect( const ISurfTriMesh& Other)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Le superfici devono essere valide
|
// Le superfici devono essere valide
|
||||||
if ( ! IsValid() || ! Other.IsValid())
|
if ( ! IsValid() || ! Other.IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -1575,51 +1681,29 @@ SurfTriMesh::Intersect( const ISurfTriMesh& Other)
|
|||||||
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
SurfB.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
SurfB.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
|
||||||
SurfTriMesh SurfB_cl ;
|
|
||||||
SurfB_cl.CopyFrom( &SurfB) ;
|
|
||||||
|
|
||||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
|
||||||
SurfTriMesh SurfA_cl ;
|
|
||||||
SurfA_cl.CopyFrom( this) ;
|
|
||||||
|
|
||||||
// ritriangolo le due superfici mediante ogni intersezione Triangolo-Triangolo
|
// ritriangolo le due superfici mediante ogni intersezione Triangolo-Triangolo
|
||||||
IntersectTriMeshTriangle( SurfB) ;
|
IntersectTriMeshTriangle( SurfB) ;
|
||||||
|
|
||||||
// assegno un medesimo indice ai triangoli che non interferiscono con altri
|
// assegno un medesimo indice ai triangoli che non interferiscono con altri
|
||||||
IdentifyShells() ;
|
IdentifyParts() ;
|
||||||
SurfB.IdentifyShells() ;
|
SurfB.IdentifyParts() ;
|
||||||
|
|
||||||
// rimozione dei triangoli di A con proprietà -1 e -2 (e gestione dei triangoli ambigui, 0)
|
// rimozione dei triangoli di A con proprietà -1 e -2
|
||||||
int nTriaNumA = GetTriangleSize() ;
|
int nTriaNumA = GetTriangleSize() ;
|
||||||
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
||||||
if ( m_vTria[nTA].nTempShell == - 1 || m_vTria[nTA].nTempShell == - 2)
|
if ( m_vTria[nTA].nTempPart == - 1 || m_vTria[nTA].nTempPart == - 2)
|
||||||
RemoveTriangle( nTA) ;
|
RemoveTriangle( nTA) ;
|
||||||
// se triangolo ambiguo
|
|
||||||
else if ( m_vTria[nTA].nTempShell == 0) {
|
|
||||||
Triangle3d TriaA ;
|
|
||||||
GetTriangle( nTA, TriaA) ;
|
|
||||||
// rimuovo il triangolo se fuori a surfB ( basta controllare un solo vertice(?) )
|
|
||||||
DistPointSurfTm distCalculator( TriaA.GetP( 0), SurfB_cl) ;
|
|
||||||
if ( ! distCalculator.IsPointOnLeftSide())
|
|
||||||
RemoveTriangle( nTA) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggiunta dei triangoli di B con proprietà +1 ( e gestione dei triangoli ambigui, 0)
|
// aggiunta dei triangoli di B con proprietà +1
|
||||||
int nPrevMaxTFlag = m_nMaxTFlag ;
|
int nPrevMaxTFlag = m_nMaxTFlag ;
|
||||||
int nTriaNumB = SurfB.GetTriangleSize() ;
|
int nTriaNumB = SurfB.GetTriangleSize() ;
|
||||||
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
||||||
bool bAdd = ( SurfB.m_vTria[nTB].nTempShell == 1) ;
|
if ( SurfB.m_vTria[nTB].nTempPart == 1) {
|
||||||
if ( ! bAdd && SurfB.m_vTria[nTB].nTempShell == 0) {
|
|
||||||
// aggiungo se il triangolo è interno a surfA ( basta controllare un solo vertice(?) )
|
|
||||||
DistPointSurfTm distCalculator( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[0]].ptP, SurfA_cl) ;
|
|
||||||
bAdd = distCalculator.IsPointOnLeftSide() ;
|
|
||||||
}
|
|
||||||
if ( bAdd) {
|
|
||||||
int nNewVert[3] ;
|
int nNewVert[3] ;
|
||||||
for ( int nV = 0 ; nV < 3 ; ++ nV)
|
for ( int nV = 0 ; nV < 3 ; ++ nV)
|
||||||
nNewVert[nV] = AddVertex( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[nV]].ptP) ;
|
nNewVert[nV] = AddVertex( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[nV]].ptP) ;
|
||||||
|
|
||||||
if ( nPrevMaxTFlag == m_nMaxTFlag)
|
if ( nPrevMaxTFlag == m_nMaxTFlag)
|
||||||
++ m_nMaxTFlag ;
|
++ m_nMaxTFlag ;
|
||||||
AddTriangle( nNewVert, m_nMaxTFlag) ;
|
AddTriangle( nNewVert, m_nMaxTFlag) ;
|
||||||
@@ -1636,6 +1720,33 @@ SurfTriMesh::Intersect( const ISurfTriMesh& Other)
|
|||||||
if ( bModified)
|
if ( bModified)
|
||||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
|
// rimuovo tutte le parti esterne all'intersezione
|
||||||
|
int nParts = GetPartCount() ;
|
||||||
|
if ( nParts > 1) {
|
||||||
|
for ( int i = 0 ; i < nParts ; ++ i) {
|
||||||
|
// recupero i triangoli della stessa Part
|
||||||
|
INTVECTOR vTriaPart ;
|
||||||
|
for ( int j = 0 ; j < int( m_vTria.size()) ; ++ j)
|
||||||
|
if ( m_vTria[j].nPart == i)
|
||||||
|
vTriaPart.push_back( j) ;
|
||||||
|
// controllo se il loro box interferisce con il box della superficie B
|
||||||
|
bool bErasePart = true ;
|
||||||
|
for ( int j = 0 ; j < int( vTriaPart.size()) && bErasePart ; ++ j) {
|
||||||
|
// Se il triangolo A non è valido, continuo
|
||||||
|
Triangle3d Tria ;
|
||||||
|
if ( ! GetTriangle( j, Tria) || ! Tria.Validate( true))
|
||||||
|
continue ;
|
||||||
|
// Box del triangolo A
|
||||||
|
BBox3d b3dTriaA ; Tria.GetLocalBBox( b3dTriaA) ;
|
||||||
|
// Recupero i triangoli di B che interferiscono col box del triangolo di A
|
||||||
|
INTVECTOR vNearTria ; SurfB.GetAllTriaOverlapBox( b3dTriaA, vNearTria) ;
|
||||||
|
bErasePart = int( vNearTria.size() == 0) ;
|
||||||
|
}
|
||||||
|
if ( bErasePart)
|
||||||
|
RemovePart( i) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// scalo alle dimensioni originali
|
// scalo alle dimensioni originali
|
||||||
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
@@ -1649,77 +1760,42 @@ SurfTriMesh::Intersect( const ISurfTriMesh& Other)
|
|||||||
bool
|
bool
|
||||||
SurfTriMesh::Subtract( const ISurfTriMesh& Other)
|
SurfTriMesh::Subtract( const ISurfTriMesh& Other)
|
||||||
{
|
{
|
||||||
|
// Le superfici devono essere valide
|
||||||
// le superfici devono essere valide
|
|
||||||
if ( ! IsValid() || ! Other.IsValid())
|
if ( ! IsValid() || ! Other.IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// se una delle due è vuota non devo fare alcunchè
|
// Se una delle due è vuota non devo fare alcunchè
|
||||||
if ( IsEmpty() || Other.IsEmpty())
|
if ( IsEmpty() || Other.IsEmpty())
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
// pulisco grafica
|
|
||||||
m_OGrMgr.Clear() ;
|
m_OGrMgr.Clear() ;
|
||||||
|
|
||||||
// clono superficie B
|
|
||||||
SurfTriMesh SurfB ;
|
SurfTriMesh SurfB ;
|
||||||
SurfB.CopyFrom( &Other) ;
|
SurfB.CopyFrom( &Other) ;
|
||||||
|
|
||||||
// creazione del frame per scalare A e B
|
Frame3d frScalingRef;
|
||||||
Frame3d frScalingRef ;
|
|
||||||
frScalingRef.Set( m_vVert[0].ptP, X_AX, Y_AX, Z_AX) ;
|
frScalingRef.Set( m_vVert[0].ptP, X_AX, Y_AX, Z_AX) ;
|
||||||
// scalo A e B
|
|
||||||
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
SurfB.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
SurfB.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
|
||||||
SurfTriMesh SurfB_cl ;
|
|
||||||
SurfB_cl.CopyFrom( &SurfB) ;
|
|
||||||
|
|
||||||
// tengo una copia di B ( la superficie B viene modificata durante la ritriangolazione )
|
|
||||||
SurfTriMesh SurfA_cl ;
|
|
||||||
SurfA_cl.CopyFrom( this) ;
|
|
||||||
|
|
||||||
// ritriangolo le due superfici mediante ogni intersezione Triangolo-Triangolo
|
|
||||||
IntersectTriMeshTriangle( SurfB) ;
|
IntersectTriMeshTriangle( SurfB) ;
|
||||||
|
|
||||||
// assegno un medesimo indice ai triangoli che non interferiscono con altri
|
IdentifyParts() ;
|
||||||
IdentifyShells() ;
|
SurfB.IdentifyParts() ;
|
||||||
SurfB.IdentifyShells() ;
|
|
||||||
|
|
||||||
// rimozione dei triangoli di A con proprietà 1 e 2 ( e gestione triangoli ambigui, 0)
|
|
||||||
int nTriaNumA = GetTriangleSize() ;
|
int nTriaNumA = GetTriangleSize() ;
|
||||||
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
for ( int nTA = 0 ; nTA < nTriaNumA ; ++ nTA) {
|
||||||
if ( m_vTria[nTA].nTempShell == 1 || m_vTria[nTA].nTempShell == 2)
|
if ( m_vTria[nTA].nTempPart == 1 || m_vTria[nTA].nTempPart == 2)
|
||||||
RemoveTriangle( nTA) ;
|
RemoveTriangle( nTA) ;
|
||||||
// se triangolo ambiguo...
|
|
||||||
if ( m_vTria[nTA].nTempShell == 0) {
|
|
||||||
Triangle3d TriaA ;
|
|
||||||
GetTriangle( nTA, TriaA) ;
|
|
||||||
// rimuovo il triangolo se interno a SurfB ( basta controllare un solo vertice(?) )
|
|
||||||
DistPointSurfTm distCalculator( TriaA.GetP( 0), SurfB_cl) ;
|
|
||||||
if ( distCalculator.IsPointOnLeftSide())
|
|
||||||
RemoveTriangle( nTA) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggiunta dei triangoli di B con proprietà +1 ( e gestione triangoli ambigui, 0)
|
|
||||||
int nPrevMaxTFlag = m_nMaxTFlag ;
|
int nPrevMaxTFlag = m_nMaxTFlag ;
|
||||||
int nTriaNumB = SurfB.GetTriangleSize() ;
|
int nTriaNumB = SurfB.GetTriangleSize() ;
|
||||||
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
for ( int nTB = 0 ; nTB < nTriaNumB ; ++ nTB) {
|
||||||
bool bAdd = SurfB.m_vTria[nTB].nTempShell == 1 ;
|
if ( SurfB.m_vTria[nTB].nTempPart == 1) {
|
||||||
if ( ! bAdd) {
|
|
||||||
// se ambiguo
|
|
||||||
if ( SurfB.m_vTria[nTB].nTempShell == 0) {
|
|
||||||
// aggiungo il triangolo se interno alla SurfA ( basta controllare un solo vertice(?) )
|
|
||||||
DistPointSurfTm distCalculator( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[0]].ptP, SurfA_cl) ;
|
|
||||||
bAdd = distCalculator.IsPointOnLeftSide() ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( bAdd) {
|
|
||||||
int nNewVert[3] ;
|
int nNewVert[3] ;
|
||||||
for ( int nV = 0 ; nV < 3 ; ++ nV)
|
for ( int nV = 0 ; nV < 3 ; ++ nV) {
|
||||||
nNewVert[nV] = AddVertex( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[nV]].ptP) ;
|
nNewVert[nV] = AddVertex( SurfB.m_vVert[SurfB.m_vTria[nTB].nIdVert[nV]].ptP) ;
|
||||||
|
}
|
||||||
swap( nNewVert[1], nNewVert[2]) ;
|
swap( nNewVert[1], nNewVert[2]) ;
|
||||||
if ( nPrevMaxTFlag == m_nMaxTFlag)
|
if ( nPrevMaxTFlag == m_nMaxTFlag)
|
||||||
++ m_nMaxTFlag ;
|
++ m_nMaxTFlag ;
|
||||||
@@ -1727,20 +1803,19 @@ SurfTriMesh::Subtract( const ISurfTriMesh& Other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// sistemazioni varie
|
|
||||||
bool bOk = ( AdjustVertices() && DoCompacting()) ;
|
bool bOk = ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
bool bModified = false ;
|
bool bModified = false ;
|
||||||
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
bOk = bOk && RemoveDoubleTriangles( bModified) ;
|
||||||
if ( bModified)
|
if ( bModified)
|
||||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
bOk = bOk && RemoveTJunctions( bModified) ;
|
bOk = bOk && RemoveTJunctions( bModified) ;
|
||||||
if ( bModified)
|
if ( bModified)
|
||||||
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
|
||||||
|
|
||||||
// scalo alle dimensioni originali
|
|
||||||
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
// semplifico le facce
|
|
||||||
if ( ! SimplifyFacets())
|
if ( ! SimplifyFacets())
|
||||||
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Subtract")
|
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Subtract")
|
||||||
|
|
||||||
@@ -1767,14 +1842,14 @@ SurfTriMesh::GetSurfClassification( const ISurfTriMesh& ClassifierSurf,
|
|||||||
SurfC.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
SurfC.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
IntersectTriMeshTriangle( SurfC) ;
|
IntersectTriMeshTriangle( SurfC) ;
|
||||||
IdentifyShells() ;
|
IdentifyParts() ;
|
||||||
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
int nTriaNum = GetTriangleSize() ;
|
int nTriaNum = GetTriangleSize() ;
|
||||||
for ( int nT = 0 ; nT < nTriaNum ; ++ nT) {
|
for ( int nT = 0 ; nT < nTriaNum ; ++ nT) {
|
||||||
if ( m_vTria[nT].nIdVert[0] == SVT_DEL)
|
if ( m_vTria[nT].nIdVert[0] == SVT_DEL)
|
||||||
continue ;
|
continue ;
|
||||||
switch ( m_vTria[nT].nTempShell) {
|
switch ( m_vTria[nT].nTempPart) {
|
||||||
case -2 :
|
case -2 :
|
||||||
vTriaOnM.push_back( nT) ;
|
vTriaOnM.push_back( nT) ;
|
||||||
break ;
|
break ;
|
||||||
@@ -1819,13 +1894,13 @@ SurfTriMesh::CutWithOtherSurf( const ISurfTriMesh& CutterSurf, bool bInVsOut, bo
|
|||||||
SurfC.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
SurfC.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
|
||||||
|
|
||||||
IntersectTriMeshTriangle( SurfC) ;
|
IntersectTriMeshTriangle( SurfC) ;
|
||||||
IdentifyShells() ;
|
IdentifyParts() ;
|
||||||
|
|
||||||
int nPartToRemove = ( bInVsOut ? -1 : 1) ;
|
int nPartToRemove = ( bInVsOut ? -1 : 1) ;
|
||||||
int nCoplanarPartToRemove = ( bSaveOnEq ? ( nPartToRemove ? -2 : 2) : 5) ;
|
int nCoplanarPartToRemove = ( bSaveOnEq ? ( nPartToRemove ? -2 : 2) : 5) ;
|
||||||
int nTriaNum = GetTriangleSize() ;
|
int nTriaNum = GetTriangleSize() ;
|
||||||
for ( int nT = 0 ; nT < nTriaNum ; ++ nT) {
|
for ( int nT = 0 ; nT < nTriaNum ; ++ nT) {
|
||||||
if ( m_vTria[nT].nTempShell == nPartToRemove || m_vTria[nT].nTempShell == nCoplanarPartToRemove)
|
if ( m_vTria[nT].nTempPart == nPartToRemove || m_vTria[nT].nTempPart == nCoplanarPartToRemove)
|
||||||
RemoveTriangle( nT) ;
|
RemoveTriangle( nT) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -15,10 +15,10 @@
|
|||||||
#include "CurveComposite.h"
|
#include "CurveComposite.h"
|
||||||
#include "SurfTriMesh.h"
|
#include "SurfTriMesh.h"
|
||||||
#include "SurfFlatRegion.h"
|
#include "SurfFlatRegion.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "Triangulate.h"
|
#include "Triangulate.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||||
#include "/EgtDev/Include/EGkIntersPlaneTria.h"
|
#include "/EgtDev/Include/EGkIntersPlaneTria.h"
|
||||||
@@ -79,7 +79,7 @@ SurfTriMesh::CutByTriangles( const Plane3d& plPlane, bool bSaveOnEq, bool& bModi
|
|||||||
if ( m_vVert[i].nIdTria == SVT_DEL)
|
if ( m_vVert[i].nIdTria == SVT_DEL)
|
||||||
continue ;
|
continue ;
|
||||||
double dDist = DistPointPlane( m_vVert[i].ptP, plPlane) ;
|
double dDist = DistPointPlane( m_vVert[i].ptP, plPlane) ;
|
||||||
if ( abs( dDist) < 1.1 * EPS_SMALL)
|
if ( abs( dDist) < EPS_SMALL)
|
||||||
m_vVert[i].nTemp = 0 ;
|
m_vVert[i].nTemp = 0 ;
|
||||||
else if ( dDist > 0)
|
else if ( dDist > 0)
|
||||||
m_vVert[i].nTemp = +1 ;
|
m_vVert[i].nTemp = +1 ;
|
||||||
@@ -781,14 +781,14 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// se superficie originale a facce, cerco di semplificarle in ogni caso
|
|
||||||
if ( nFacetOriCnt < 200 || double( nTriaOriCnt) / nFacetOriCnt > 4) {
|
|
||||||
if ( ! SimplifyFacets( CUT_SCALE * MAX_EDGE_LEN_STD))
|
|
||||||
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::GeneralizedCut")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ripristino scala originale
|
// Ripristino scala originale
|
||||||
Scale( frScalingRef, 1. / CUT_SCALE, 1. / CUT_SCALE, 1. / CUT_SCALE) ;
|
Scale( frScalingRef, 1. / CUT_SCALE, 1. / CUT_SCALE, 1. / CUT_SCALE) ;
|
||||||
|
|
||||||
|
// se superficie originale a facce, cerco di semplificarle in ogni caso
|
||||||
|
if ( nFacetOriCnt < 200 || double( nTriaOriCnt) / nFacetOriCnt > 4) {
|
||||||
|
if ( ! SimplifyFacets())
|
||||||
|
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::GeneralizedCut")
|
||||||
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
#include "SurfTriMesh.h"
|
#include "SurfTriMesh.h"
|
||||||
#include "CurveLine.h"
|
#include "CurveLine.h"
|
||||||
#include "Triangulate.h"
|
#include "Triangulate.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
#include "DistPointLine.h"
|
||||||
#include "/EgtDev/Include/EGkDistLineLine.h"
|
#include "DistLineLine.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|||||||
@@ -583,78 +583,34 @@ Tool::SetChiselTool( const string& sToolName, double dH, double dW, double dTh,
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Tool::SetAdditiveTool( const std::string& sToolName, double dH, double dR, double dRc, int nToolNum)
|
Tool::SetAdditiveTool( const std::string& sToolName, double dH, double dR, double dRC, int nToolNum)
|
||||||
{
|
{
|
||||||
// Impostazioni generali
|
// Impostazioni generali
|
||||||
m_sName = sToolName ;
|
m_sName = sToolName ;
|
||||||
m_nCurrentNum = nToolNum ;
|
m_nCurrentNum = nToolNum ;
|
||||||
m_nType = UNDEF ;
|
m_nType = UNDEF ;
|
||||||
m_Outline.Clear() ;
|
m_Outline.Clear() ;
|
||||||
m_ArcLineApprox.Clear() ;
|
m_ArcLineApprox.Clear() ;
|
||||||
|
|
||||||
// Verifica sulle dimensioni
|
// verifica sulle minime dimensioni globali
|
||||||
if ( dH < 10 * EPS_SMALL || dR < 10 * EPS_SMALL || dRc < - EPS_SMALL || dR < dRc - EPS_SMALL)
|
if ( dH < EPS_SMALL || dR < EPS_SMALL || dRC < - EPS_SMALL)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Assegnazione dati geometrici principali
|
|
||||||
m_dHeight = dH ;
|
m_dHeight = dH ;
|
||||||
m_dRadius = dR ;
|
m_dRadius = dR ;
|
||||||
m_dRCorner = min( dRc, dR) ;
|
m_dRCorner = dRC ;
|
||||||
if ( m_dRCorner < 10 * EPS_SMALL)
|
|
||||||
m_dRCorner = 0 ;
|
|
||||||
m_dTipHeight = 0 ;
|
m_dTipHeight = 0 ;
|
||||||
m_dTipRadius = 0 ;
|
m_dTipRadius = 0 ;
|
||||||
m_dRefRadius = 0 ;
|
m_dRefRadius = 0 ;
|
||||||
m_dCutterHeight = dH ;
|
m_dCutterHeight = dH ;
|
||||||
|
|
||||||
// Utensile cilindrico con eventuale raggio corner (al limite sferico)
|
bool bToolDefined = true ;
|
||||||
if ( m_dRCorner <= m_dHeight / 2) {
|
|
||||||
// Se Cilindrico
|
double dSquareCornerRadProj = m_dRCorner * m_dRCorner - 0.25 * m_dHeight * m_dHeight ;
|
||||||
if ( m_dRCorner < EPS_SMALL) {
|
// Utensile sfiancato
|
||||||
// inizio
|
if ( dSquareCornerRadProj > 0) {
|
||||||
m_Outline.AddPoint( Point3d( 0, 0, 0)) ;
|
|
||||||
// segmento orizzontale in alto
|
|
||||||
m_Outline.AddLine( Point3d( m_dRadius, 0, 0)) ;
|
|
||||||
m_Outline.SetCurveTempProp( 0, 1, 1) ;
|
|
||||||
// segmento verticale
|
|
||||||
m_Outline.AddLine( Point3d( m_dRadius, -m_dHeight, 0)) ;
|
|
||||||
m_Outline.SetCurveTempProp( 1, 1, 1) ;
|
|
||||||
// segmento orizzontale in basso
|
|
||||||
m_Outline.AddLine( Point3d( 0, -m_dHeight, 0)) ;
|
|
||||||
m_Outline.SetCurveTempProp( 2, 1, 1) ;
|
|
||||||
}
|
|
||||||
// Generico
|
|
||||||
else {
|
|
||||||
// inizio
|
|
||||||
m_Outline.AddPoint( Point3d( 0, 0, 0)) ;
|
|
||||||
int nInd = -1 ;
|
|
||||||
// eventuale segmento orizzontale in alto
|
|
||||||
if ( m_Outline.AddLine( Point3d( m_dRadius - m_dRCorner, 0, 0)))
|
|
||||||
m_Outline.SetCurveTempProp( ++ nInd, 1, 1) ;
|
|
||||||
// raggio corner in alto
|
|
||||||
CurveArc cvArc ;
|
|
||||||
cvArc.SetC2P( Point3d( m_dRadius - m_dRCorner, -m_dRCorner, 0), Point3d( m_dRadius - m_dRCorner, 0, 0), Point3d( m_dRadius, -m_dRCorner, 0)) ;
|
|
||||||
m_Outline.AddCurve( cvArc, true, 2 * EPS_SMALL) ;
|
|
||||||
m_Outline.SetCurveTempProp( ++ nInd, 1, 1) ;
|
|
||||||
// eventuale segmento verticale
|
|
||||||
if ( m_Outline.AddLine( Point3d( m_dRadius, -m_dHeight + m_dRCorner, 0)))
|
|
||||||
m_Outline.SetCurveTempProp( ++ nInd, 1, 1) ;
|
|
||||||
// raggio corner in basso
|
|
||||||
cvArc.SetC2P( Point3d( m_dRadius - m_dRCorner, -m_dHeight + m_dRCorner, 0), Point3d( m_dRadius, -m_dHeight + m_dRCorner, 0), Point3d( m_dRadius - m_dRCorner, -m_dHeight, 0)) ;
|
|
||||||
m_Outline.AddCurve( cvArc, true, 2 * EPS_SMALL) ;
|
|
||||||
m_Outline.SetCurveTempProp( ++ nInd, 1, 1) ;
|
|
||||||
// eventuale segmento orizzontale in basso
|
|
||||||
if ( m_Outline.AddLine( Point3d( 0, -m_dHeight, 0)))
|
|
||||||
m_Outline.SetCurveTempProp( ++ nInd, 1, 1) ;
|
|
||||||
}
|
|
||||||
m_Outline.SetTempProp( 1, 1) ;
|
|
||||||
if ( ! SetGenTool( sToolName, &m_Outline, nToolNum))
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
// Utensile sfiancato
|
|
||||||
else {
|
|
||||||
double dCenX = m_dRadius - m_dRCorner ;
|
double dCenX = m_dRadius - m_dRCorner ;
|
||||||
double dCylRad = dCenX + sqrt( m_dRCorner * m_dRCorner - m_dHeight * m_dHeight / 4) ;
|
double dCylRad = dCenX + sqrt( dSquareCornerRadProj) ;
|
||||||
// Utensile mal definito
|
// Utensile mal definito
|
||||||
if ( dCylRad < EPS_SMALL)
|
if ( dCylRad < EPS_SMALL)
|
||||||
return false ;
|
return false ;
|
||||||
@@ -669,10 +625,41 @@ Tool::SetAdditiveTool( const std::string& sToolName, double dH, double dR, doubl
|
|||||||
m_Outline.AddLine( Point3d( 0, - m_dHeight, 0)) ;
|
m_Outline.AddLine( Point3d( 0, - m_dHeight, 0)) ;
|
||||||
m_Outline.SetCurveTempProp( 2, 1, 1) ;
|
m_Outline.SetCurveTempProp( 2, 1, 1) ;
|
||||||
m_Outline.SetTempProp( 1, 1) ;
|
m_Outline.SetTempProp( 1, 1) ;
|
||||||
if ( ! SetGenTool( sToolName, &m_Outline, nToolNum))
|
bToolDefined = SetGenTool( sToolName, &m_Outline, nToolNum) ;
|
||||||
|
}
|
||||||
|
// Utensile cilindrico con eventuale raggio corner
|
||||||
|
else {
|
||||||
|
// Utensile mal definito
|
||||||
|
if ( m_dRadius - m_dRCorner < 0)
|
||||||
return false ;
|
return false ;
|
||||||
|
// Utensile sferico
|
||||||
|
else if ( m_dRadius - m_dRCorner < EPS_SMALL)
|
||||||
|
;
|
||||||
|
// Raggio corner nullo: cilindro
|
||||||
|
else if ( m_dRCorner < EPS_SMALL) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Profilo
|
||||||
|
m_Outline.AddPoint( Point3d( 0, 0, 0)) ;
|
||||||
|
m_Outline.AddLine( Point3d( m_dRadius - m_dRCorner, 0, 0)) ;
|
||||||
|
m_Outline.SetCurveTempProp( 0, 1, 1) ;
|
||||||
|
CurveArc cvArc ;
|
||||||
|
cvArc.SetC2P( Point3d( m_dRadius - m_dRCorner, - m_dRCorner, 0), Point3d( m_dRadius - m_dRCorner, 0, 0), Point3d( m_dRadius, - m_dRCorner, 0)) ;
|
||||||
|
m_Outline.AddCurve( cvArc) ;
|
||||||
|
m_Outline.SetCurveTempProp( 1, 1, 1) ;
|
||||||
|
m_Outline.AddLine( Point3d( m_dRadius, - m_dHeight + m_dRCorner, 0)) ;
|
||||||
|
m_Outline.SetCurveTempProp( 2, 1, 1) ;
|
||||||
|
cvArc.SetC2P( Point3d( m_dRadius - m_dRCorner, - m_dHeight + m_dRCorner, 0), Point3d( m_dRadius, - m_dHeight + m_dRCorner, 0), Point3d( m_dRadius - m_dRCorner, - m_dHeight, 0)) ;
|
||||||
|
m_Outline.AddCurve( cvArc) ;
|
||||||
|
m_Outline.SetCurveTempProp( 3, 1, 1) ;
|
||||||
|
m_Outline.AddLine( Point3d( 0, - m_dHeight, 0)) ;
|
||||||
|
m_Outline.SetCurveTempProp( 4, 1, 1) ;
|
||||||
|
m_Outline.SetTempProp( 1, 1) ;
|
||||||
|
bToolDefined = SetGenTool( sToolName, &m_Outline, nToolNum) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nType = ADDITIVE ;
|
m_nType = ADDITIVE ;
|
||||||
return true ;
|
return bToolDefined ;
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ class Tool
|
|||||||
bool SetGenTool( const std::string& sToolName, const ICurveComposite* pToolOutline, int nToolNum) ;
|
bool SetGenTool( const std::string& sToolName, const ICurveComposite* pToolOutline, int nToolNum) ;
|
||||||
bool SetMortiserTool( const std::string& sToolName, double dH, double dW, double dTh, double dRc, int nToolNum) ;
|
bool SetMortiserTool( const std::string& sToolName, double dH, double dW, double dTh, double dRc, int nToolNum) ;
|
||||||
bool SetChiselTool( const std::string& sToolName, double dH, double dW, double dTh, int nToolNum) ;
|
bool SetChiselTool( const std::string& sToolName, double dH, double dW, double dTh, int nToolNum) ;
|
||||||
bool SetAdditiveTool( const std::string& sToolName, double dH, double dR, double dRc, int nToolNum) ;
|
bool SetAdditiveTool( const std::string& sToolName, double dH, double dR, double dRC, int nToolNum) ;
|
||||||
bool SetToolNum( int nToolNum)
|
bool SetToolNum( int nToolNum)
|
||||||
{ m_nCurrentNum = nToolNum ; return true ; }
|
{ m_nCurrentNum = nToolNum ; return true ; }
|
||||||
int GetType() const
|
int GetType() const
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class Cell
|
|||||||
~Cell( void) {}
|
~Cell( void) {}
|
||||||
Cell( void)
|
Cell( void)
|
||||||
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
|
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
|
||||||
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), m_nVertToErase( -1),
|
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false),
|
||||||
m_ptPbl( ORIG), m_ptPtr( SBZ_TREG_COEFF, SBZ_TREG_COEFF, 0), m_bProcessed( false), m_bSplitVert( true)
|
m_ptPbl( ORIG), m_ptPtr( SBZ_TREG_COEFF, SBZ_TREG_COEFF, 0), m_bProcessed( false), m_bSplitVert( true)
|
||||||
{
|
{
|
||||||
Point3d ptTr ( 1 * SBZ_TREG_COEFF, 1 * SBZ_TREG_COEFF) ;
|
Point3d ptTr ( 1 * SBZ_TREG_COEFF, 1 * SBZ_TREG_COEFF) ;
|
||||||
@@ -163,7 +163,7 @@ class Cell
|
|||||||
}
|
}
|
||||||
Cell( const Point3d& ptBL, const Point3d& ptTR)
|
Cell( const Point3d& ptBL, const Point3d& ptTR)
|
||||||
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
|
: m_nId( -1),m_nTop ( -2), m_nBottom( -2), m_nLeft( -2), m_nRight ( -2), m_nParent( -2), m_nDepth( 0),
|
||||||
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false), m_nVertToErase( -1),
|
m_nChild1( -2), m_nChild2( -2), m_nFlag( -1), m_nFlag2( 0), m_nRightEdgeIn( -1), m_bOnLeftEdge( false), m_bOnTopEdge( false),
|
||||||
m_ptPbl( ptBL), m_ptPtr( ptTR), m_bProcessed( false), m_bSplitVert( true) {}
|
m_ptPbl( ptBL), m_ptPtr( ptTR), m_bProcessed( false), m_bSplitVert( true) {}
|
||||||
bool IsSame( const Cell& cOtherCell) const
|
bool IsSame( const Cell& cOtherCell) const
|
||||||
{ return ( m_nId == cOtherCell.m_nId) ; }
|
{ return ( m_nId == cOtherCell.m_nId) ; }
|
||||||
@@ -185,9 +185,9 @@ class Cell
|
|||||||
{ return Point3d( m_ptPtr.x, m_ptPbl.y); }
|
{ return Point3d( m_ptPtr.x, m_ptPbl.y); }
|
||||||
double GetSplitValue( void) const
|
double GetSplitValue( void) const
|
||||||
{ return m_dSplit ; }
|
{ return m_dSplit ; }
|
||||||
bool IsSplitVert( void) const // se true la cella verrebbe splittata verticalmente, sennò orizzontalmente
|
bool IsSplitVert( void) const // se true la cella verrebbe splittata verticalmente, senn� orizzontalmente
|
||||||
{ return m_bSplitVert ; }
|
{ return m_bSplitVert ; }
|
||||||
bool IsLeaf( void) const // flag che indica se la cella ha figli o se è una foglia
|
bool IsLeaf( void) const // flag che indica se la cella ha figli o se � una foglia
|
||||||
{ return ( m_nChild1 == -2 && m_nChild2 == -2) ; }
|
{ return ( m_nChild1 == -2 && m_nChild2 == -2) ; }
|
||||||
bool IsProcessed( void) const // flag che indica se tutti i figli della cella, se ce ne sono, sono stati processati
|
bool IsProcessed( void) const // flag che indica se tutti i figli della cella, se ce ne sono, sono stati processati
|
||||||
{ return m_bProcessed ; }
|
{ return m_bProcessed ; }
|
||||||
@@ -217,8 +217,6 @@ class Cell
|
|||||||
bool m_bOnTopEdge ; // flag che indica se la cella è sul lato top ( per superfici chiuse sul parametro V)
|
bool m_bOnTopEdge ; // flag che indica se la cella è sul lato top ( per superfici chiuse sul parametro V)
|
||||||
std::vector<Inters> m_vInters ; // vettore delle intersezioni della cella con i loop di trim
|
std::vector<Inters> m_vInters ; // vettore delle intersezioni della cella con i loop di trim
|
||||||
// ogni elemento del vettore è l'insieme dei punti che caratterizza un attraversamento della cella
|
// ogni elemento del vettore è l'insieme dei punti che caratterizza un attraversamento della cella
|
||||||
int m_nVertToErase ; // vertice da eliminare dal poligono della cella, in caso di lato sovrapposto ad un lato di polo
|
|
||||||
// contati in senso CCW a partire dal bottom left
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
Point3d m_ptPbl ; // punto bottom left
|
Point3d m_ptPbl ; // punto bottom left
|
||||||
@@ -237,17 +235,12 @@ class Tree
|
|||||||
Tree( const Point3d ptBl, const Point3d ptTr) ; // creatore da usare solo nel caso in cui si voglia aggiungere tagli ad un'unica cella e del risultato ottenere il contorno
|
Tree( const Point3d ptBl, const Point3d ptTr) ; // creatore da usare solo nel caso in cui si voglia aggiungere tagli ad un'unica cella e del risultato ottenere il contorno
|
||||||
bool SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ;
|
bool SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches = true, const Point3d& ptMin = ORIG, const Point3d& ptMax = ORIG) ;
|
||||||
bool GetIndependentTrees( BIPNTVECTOR& vTrees) ; // calcolo la suddivisione della superficie solo sulle singole bbox dei loop di trim ( unendo quelli vicini)
|
bool GetIndependentTrees( BIPNTVECTOR& vTrees) ; // calcolo la suddivisione della superficie solo sulle singole bbox dei loop di trim ( unendo quelli vicini)
|
||||||
bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax è il massimo per la dimensione maggiore di un triangolo della trimesh
|
bool BuildTree( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ; // dSideMax � il massimo per la dimensione maggiore di un triangolo della trimesh
|
||||||
// dSideMin è lunghezza minima del lato di una cella nello spazio reale
|
// dSideMin � lunghezza minima del lato di una cella nello spazio reale
|
||||||
bool BuildTree_test( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ;
|
bool BuildTree_test( double dLinTol = LIN_TOL_STD, double dSideMin = 1, double dSideMax = INFINITO) ;
|
||||||
bool GetPolygons( POLYLINEMATRIX& vvPolygons) ;
|
bool GetPolygons( POLYLINEMATRIX& vPolygons) ;
|
||||||
bool GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d) ;
|
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, INTVECTOR vCells = {}) ; // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
|
||||||
bool GetPolygons( POLYLINEMATRIX& vPolygons, bool bForTriangulation, POLYLINEMATRIX& vvPolygons3d) ;
|
// ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
|
||||||
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, POLYLINEVECTOR& vPolygonsCorrected, // restituisce il poligono corrispondente ad ogni cella foglia dell'albero
|
|
||||||
bool bForTriangulation, POLYLINEVECTOR& vPolygons3d, INTVECTOR vCells = {}) ; // ad ogni poligono sono stati aggiunti tutti i vertici dei vicini posizionati sui suoi lati
|
|
||||||
// se richiesti per la triangolazione ad alcuni poligoni potrebbero venire tolti dei punti per evitare errori dovuti ad eventuali poli sui bordi del parametrico
|
|
||||||
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, POLYLINEVECTOR& vPolygonsCorrected, POLYLINEVECTOR& vPolygons3d) ;
|
|
||||||
bool GetPolygonsBasic( POLYLINEVECTOR& vPolygons, INTVECTOR vCells = {}) ;
|
|
||||||
bool GetLeaves ( std::vector<Cell>& vLeaves) const ; // restituisce gli indici delle foglie nell'albero
|
bool GetLeaves ( std::vector<Cell>& vLeaves) const ; // restituisce gli indici delle foglie nell'albero
|
||||||
bool GetEdges3D ( POLYLINEMATRIX& mPLEdges) ; // restituisce gli edge 3D come polyline
|
bool GetEdges3D ( POLYLINEMATRIX& mPLEdges) ; // restituisce gli edge 3D come polyline
|
||||||
bool GetSplitLoops( POLYLINEVECTOR& vPl) const // funzione che restituisce i loop splitatti ai confini delle celle
|
bool GetSplitLoops( POLYLINEVECTOR& vPl) const // funzione che restituisce i loop splitatti ai confini delle celle
|
||||||
@@ -263,8 +256,8 @@ class Tree
|
|||||||
private :
|
private :
|
||||||
bool LimitLoop( PolyLine& pl, POLYLINEVECTOR& vPl, BOOLVECTOR& vbOrientation) const ; // funzione che limita i loop di trim allo spazio parametrico
|
bool LimitLoop( PolyLine& pl, POLYLINEVECTOR& vPl, BOOLVECTOR& vbOrientation) const ; // funzione che limita i loop di trim allo spazio parametrico
|
||||||
bool Split( int nId, double dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert
|
bool Split( int nId, double dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert
|
||||||
bool Split( int nId) ; // funzione di split di una cella dell'albero a metà nella direzione data da bVert
|
bool Split( int nId) ; // funzione di split di una cella dell'albero a met� nella direzione data da bVert
|
||||||
void Balance( void) ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profondità di +- 1
|
void Balance( void) ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profondit� di +- 1
|
||||||
int GetHeightLeaves( int nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId
|
int GetHeightLeaves( int nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId
|
||||||
int GetDepth( int nId, int nRef) const ; // livello del nodo nId
|
int GetDepth( int nId, int nRef) const ; // livello del nodo nId
|
||||||
void GetTopNeigh( int nId, INTVECTOR& vTopNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato top
|
void GetTopNeigh( int nId, INTVECTOR& vTopNeighs) const ; // restituisce le celle foglie che sono adiacenti al lato top
|
||||||
@@ -275,20 +268,17 @@ class Tree
|
|||||||
void ResetTree( void) ; // resetto m_bProcessed a false per tutti i nodi dell'albero
|
void ResetTree( void) ; // resetto m_bProcessed a false per tutti i nodi dell'albero
|
||||||
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
|
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
|
||||||
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
|
INTVECTOR FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells, bool bRecurs = false) const ; // dato un punto, trova la cella foglia a cui appartiene
|
||||||
bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle
|
bool TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons) ; // tracing dei loop e labelling delle celle
|
||||||
bool FindInters( int& nId, const CurveLine& clTrim, const PolyLine& plPolygon, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim
|
bool FindInters( int& nId, const CurveLine& clTrim, PNTVECTOR& vptInters, bool bFirstInters = true) ; // trova le intersezioni tra una cella e una linea di trim
|
||||||
// resituisce l'id della cella verso cui la curva di trim esce e il vettore delle intersezioni per la cella successiva con il primo punto
|
// resituisce l'id della cella verso cui la curva di trim esce e il vettore delle intersezioni per la cella successiva con il primo punto
|
||||||
bool CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX& vPolygons3d, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell, const PolyLine& plCell3d) ; // crea i poligoni della cella passata. richiede anche la funzione CreateIslandAndHoles per completare i poligoni.
|
bool CreateCellPolygons( int nLeafId, POLYLINEMATRIX& vPolygons, INTVECTOR& vToCheck, int& nPoly, INTVECTOR& vnParentChunk, const PolyLine& plCell) ; // crea i poligoni della cella passata. richiede anche la funzione CreateIslandAndHoles per completare i poligoni.
|
||||||
bool CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, POLYLINEMATRIX& vvPolygons3d, int& nPoly, INTVECTOR& vnParentChunk, bool bForTriangulation,
|
bool CreateIslandAndHoles( int nLeafId, POLYLINEMATRIX& vPolygons, int& nPoly, INTVECTOR& vnParentChunk) ; // ai poligoni generati da CreatePolygonsCell aggiunge i loop che creano isole o buchi all'interno della singola cella
|
||||||
const PolyLine& plPolygonsBasic, const PolyLine& plPolygonsBasic3d) ; // ai poligoni generati da CreatePolygonsCell aggiunge i loop che creano isole o buchi all'interno della singola cella
|
|
||||||
bool CheckIfBefore( const PolyLine& pl, int nEdge) const ; // controllo se ptEnd è prima di ptStart sul lato nEdge rispetto al senso antiorario
|
bool CheckIfBefore( const PolyLine& pl, int nEdge) const ; // controllo se ptEnd è prima di ptStart sul lato nEdge rispetto al senso antiorario
|
||||||
bool CheckIfBefore( const Inters& inA) const ; // controlla se l'ingresso è prima dell'uscita in senso antiorario a partire da ptTR.
|
bool CheckIfBefore( const Inters& inA) const ; // controlla se l'ingresso è prima dell'uscita in senso antiorario a partire da ptTR.
|
||||||
bool CheckIfBefore( int nEdge1, const Point3d& ptP1, int nEdge2, const Point3d& ptP2) const ; // verifico quale punto viene prima tra pt1 e pt2 a partire da ptTR girando in senso CCW (punto 1 su edge 1 e punto 2 su edge 2, rispetto al lato 3)
|
bool CheckIfBefore( int nEdge1, const Point3d& ptP1, int nEdge2, const Point3d& ptP2) const ; // verifico quale punto viene prima tra pt1 e pt2 a partire da ptTR girando in senso CCW (punto 1 su edge 1 e punto 2 su edge 2, rispetto al lato 3)
|
||||||
bool CheckIfBefore( int nEdge, const Point3d& ptP1, const Point3d& ptP2, int nEdge2 = -1) const ; // sul lato nEdge controllo se ptP1 viene prima di ptP2.
|
bool CheckIfBefore( int nEdge, const Point3d& ptP1, const Point3d& ptP2, int nEdge2 = -1) const ; // sul lato nEdge controllo se ptP1 viene prima di ptP2.
|
||||||
bool AreSameEdge( int nEdge1, int nEdge2) const ; // indica se i due edge sono lo stesso. Un vertice adiacente ad un edge viene considerato uguale a questo edge
|
bool AreSameEdge( int nEdge1, int nEdge2) const ; // indica se i due edge sono lo stesso. Un vertice adiacente ad un edge viene considerato uguale a questo edge
|
||||||
bool CheckIfBefore( int nEdgeA, int nEdgeB) const ; // per due edge uguali per la funzione AreSameEdge chiedo se EdgeA viene prima di EdgeB
|
bool AddVertex( int nId, const PNTMATRIX& vEdgeVertex, PolyLine& plTrimmedPoly, int& c, const Point3d& ptToAdd) const ; // aggiunge un punto ad un poligono in una cella, premurandosi di aggiungere eventualmente vertici o punti di celle vicine di cui tenere conto
|
||||||
bool AddVertex( int nId, const PNTMATRIX& vEdgeVertex, const PNTMATRIX& vEdgeVertex3d, PolyLine& plTrimmedPoly, int& c,
|
|
||||||
const Point3d& ptToAdd, PolyLine& plTrimmedPoly3d, bool ForTriangulation, Point3d& ptLast) const ; // aggiunge un punto ad un poligono in una cella, premurandosi di aggiungere eventualmente vertici o punti di celle vicine di cui tenere conto
|
|
||||||
bool SetRightEdgeIn( int nId) ; // categorizza la cella in base all'edge destro per poter poi definire m_nFlag
|
bool SetRightEdgeIn( int nId) ; // categorizza la cella in base all'edge destro per poter poi definire m_nFlag
|
||||||
bool CategorizeCell( int nId) ; // categorizza la cella in base al flag m_nFlag (dentro, fuori, intersecata)
|
bool CategorizeCell( int nId) ; // categorizza la cella in base al flag m_nFlag (dentro, fuori, intersecata)
|
||||||
bool CheckIfBetween( const Inters& inA, const Inters& inB) const ; // / controllo se inB è compreso tra l'end e lo start di inA (in senso CCW)
|
bool CheckIfBetween( const Inters& inA, const Inters& inB) const ; // / controllo se inB è compreso tra l'end e lo start di inA (in senso CCW)
|
||||||
@@ -306,7 +296,7 @@ class Tree
|
|||||||
DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00
|
DBLVECTOR m_vDim ; // distanze tra i vertici della superficie di bezier in 3d in ordine antiorario a partire da ptP00
|
||||||
bool m_bTrimmed ; // superficie trimmata
|
bool m_bTrimmed ; // superficie trimmata
|
||||||
//INTMATRIX m_vChunk ; // elenco dei loop divisi per chunk
|
//INTMATRIX m_vChunk ; // elenco dei loop divisi per chunk
|
||||||
std::unordered_map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
|
std::map<int,int> m_mChunk ; // mappa in cui vengono salvati chunk di appartenza per ogni loop di trim
|
||||||
//ICURVEPOVECTOR m_vLoop ; // curve di loop
|
//ICURVEPOVECTOR m_vLoop ; // curve di loop
|
||||||
std::vector<std::tuple<PolyLine,bool>> m_vPlApprox ; // vettore contenente le approssimazioni dei loop // il bool indica se la curva è CCW
|
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_bBilinear ; // superficie bilineare
|
||||||
@@ -320,10 +310,8 @@ class Tree
|
|||||||
int m_nSpanU ; // numero di span lungo il parametro U
|
int m_nSpanU ; // numero di span lungo il parametro U
|
||||||
int m_nSpanV ; // numero di span lungo il parametro V
|
int m_nSpanV ; // numero di span lungo il parametro V
|
||||||
POLYLINEMATRIX m_vPolygons ; // matrice dei poligoni del tree
|
POLYLINEMATRIX m_vPolygons ; // matrice dei poligoni del tree
|
||||||
POLYLINEMATRIX m_vPolygonsCorr ; // matrice dei poligoni del tree, corretti per i punti che sono nei poli
|
std::map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 � puntatore Null e -1 � root
|
||||||
POLYLINEMATRIX m_vPolygons3d ; // matrice dei poligoni3d del tree
|
std::map<int,PNTVECTOR> m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id � lo stesso che la cella ha in m_mTree
|
||||||
std::unordered_map<int,Cell> m_mTree ; // mappa che contiene tutti i nodi e le foglie dell'albero. -2 è puntatore Null e -1 è root
|
|
||||||
std::unordered_map<int,PNTVECTOR> m_mVert ; // mappa che contiene tutti i vertici 3d delle celle del tree. L'Id è lo stesso che la cella ha in m_mTree. I punti sono nell'ordine P00, P10, P11, P01
|
|
||||||
INTVECTOR m_vnLeaves ; // vettore delle foglie
|
INTVECTOR m_vnLeaves ; // vettore delle foglie
|
||||||
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
|
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
|
||||||
bool m_bTestMode ; // bool che indica se la test mode è attiva
|
bool m_bTestMode ; // bool che indica se la test mode è attiva
|
||||||
|
|||||||
+113
-37
@@ -17,7 +17,6 @@
|
|||||||
#include "Triangulate.h"
|
#include "Triangulate.h"
|
||||||
#include "ProjPlane.h"
|
#include "ProjPlane.h"
|
||||||
#include "earcut.hpp"
|
#include "earcut.hpp"
|
||||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
|
||||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||||
@@ -224,14 +223,6 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVECTOR& vTr)
|
Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||||
{
|
|
||||||
INTMATRIX vnPLIndMat ;
|
|
||||||
return MakeAdvanced( vPLORIG, vPt, vTr, vnPLIndMat) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVECTOR& vTr, const INTMATRIX& vnPLIndMatPre)
|
|
||||||
{
|
{
|
||||||
vPt.clear() ;
|
vPt.clear() ;
|
||||||
vTr.clear() ;
|
vTr.clear() ;
|
||||||
@@ -239,28 +230,113 @@ Triangulate::MakeAdvanced( const POLYLINEVECTOR& vPLORIG, PNTVECTOR& vPt, INTVEC
|
|||||||
if ( int( vPLORIG.size()) == 0)
|
if ( int( vPLORIG.size()) == 0)
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
|
// copio il vettore di PolyLine
|
||||||
POLYLINEVECTOR vPL ;
|
POLYLINEVECTOR vPL ;
|
||||||
Vector3d vtN ;
|
for ( int i = 0 ; i < int( vPLORIG.size()) ; ++ i)
|
||||||
// se non sono stati passate le info per ordinare le polyline allora le ordino
|
vPL.push_back( vPLORIG[i]) ;
|
||||||
INTMATRIX vnPLIndMat ;
|
|
||||||
BOOLVECTOR vbInvert ;
|
typedef std::pair<int,double> INDAREA ;
|
||||||
if( vnPLIndMatPre.size() == 0){
|
std::vector<INDAREA> m_vArea ;
|
||||||
if ( ! CalcRegionPolyLines( vPLORIG, vtN, vnPLIndMat, vbInvert))
|
// calcolo piano medio e area delle curve
|
||||||
|
m_vArea.reserve( vPL.size()) ;
|
||||||
|
Vector3d vtN0 ;
|
||||||
|
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||||
|
// calcolo piano medio e area
|
||||||
|
Plane3d plPlane ;
|
||||||
|
double dArea ;
|
||||||
|
if ( ! vPL[i].IsClosedAndFlat( plPlane, dArea))
|
||||||
return false ;
|
return false ;
|
||||||
vPL = vPLORIG ;
|
// imposto la normale del primo contorno come riferimento
|
||||||
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) {
|
if ( i == 0)
|
||||||
for ( int j = 0 ; j < int( vnPLIndMat[i].size()) ; ++j){
|
vtN0 = plPlane.GetVersN() ;
|
||||||
if( vbInvert[vnPLIndMat[i][j]])
|
// verifico che le normali siano molto vicine
|
||||||
vPL.back().Invert() ;
|
if ( ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), vtN0))
|
||||||
|
return false ;
|
||||||
|
// assegno il segno all'area secondo il verso della normale
|
||||||
|
if ( ( plPlane.GetVersN() * vtN0) > 0)
|
||||||
|
m_vArea.emplace_back( i, dArea) ;
|
||||||
|
else
|
||||||
|
m_vArea.emplace_back( i, - dArea) ;
|
||||||
|
}
|
||||||
|
// ordino in senso decrescente sull'area
|
||||||
|
sort( m_vArea.begin(), m_vArea.end(),
|
||||||
|
[]( const INDAREA& a, const INDAREA& b) { return ( abs( a.second) > abs( b.second)) ; }) ;
|
||||||
|
|
||||||
|
// dalle PolyLine passo alle curve nel piano XY ( prendo la prima come riferimento, trascuro le Z delle successive)
|
||||||
|
Frame3d frRef ; frRef.Set( ORIG, vtN0) ;
|
||||||
|
if ( ! frRef.IsValid())
|
||||||
|
return false ;
|
||||||
|
ICRVCOMPOPOVECTOR vCrvCompo( int( vPL.size())) ;
|
||||||
|
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||||
|
vCrvCompo[i].Set( CreateCurveComposite()) ;
|
||||||
|
vCrvCompo[i]->FromPolyLine( vPL[i]) ;
|
||||||
|
vCrvCompo[i]->ToLoc( frRef) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// creo una matrice di interi ; ogni riga corrisponde ad un chunk, dove in posizione 0 c'è il loop esterno e nelle
|
||||||
|
// successive i loop interni
|
||||||
|
INTMATRIX vnPLIndMat ;
|
||||||
|
|
||||||
|
// aggiungo le diverse curve
|
||||||
|
bool bFirstCrv ;
|
||||||
|
Plane3d plExtLoop ;
|
||||||
|
double dAreaExtLoop = 0. ;
|
||||||
|
do {
|
||||||
|
bFirstCrv = true ;
|
||||||
|
for ( int i = 0 ; i < int( m_vArea.size()) ; ++ i) {
|
||||||
|
// recupero indice di percorso e verifico sia valido
|
||||||
|
int j = m_vArea[i].first ;
|
||||||
|
if ( j < 0)
|
||||||
|
continue ;
|
||||||
|
// lo inserisco come esterno...
|
||||||
|
if ( bFirstCrv) {
|
||||||
|
vnPLIndMat.push_back({ j}) ;
|
||||||
|
m_vArea[i].first = -1 ;
|
||||||
|
dAreaExtLoop = m_vArea[i].second ;
|
||||||
|
// inverto se necessario
|
||||||
|
if ( m_vArea[i].second < EPS_SMALL) {
|
||||||
|
vPL[j].Invert() ;
|
||||||
|
vCrvCompo[j]->Invert() ;
|
||||||
|
dAreaExtLoop *= -1 ;
|
||||||
|
}
|
||||||
|
bFirstCrv = false ;
|
||||||
|
}
|
||||||
|
// ... altrimenti verifico se il loop è interno o no
|
||||||
|
else {
|
||||||
|
// il loop è interno se è sia interno al loop esterno della riga di vnPLIndMat e allo stesso tempo
|
||||||
|
// esterno a tutti i loop già inseriti nella riga attuale.
|
||||||
|
// verifica rispetto loop esterno
|
||||||
|
IntersCurveCurve ccInt( *vCrvCompo[vnPLIndMat.back().front()], *vCrvCompo[j]) ;
|
||||||
|
CRVCVECTOR ccClass ;
|
||||||
|
if ( ccInt.GetCrossOrOverlapIntersCount() > 0 ||
|
||||||
|
! ccInt.GetCurveClassification( 1, EPS_SMALL, ccClass) ||
|
||||||
|
ccClass.empty() || ccClass[0].nClass != CRVC_IN)
|
||||||
|
continue ;
|
||||||
|
// verifica rispetto ai loop interni
|
||||||
|
bool bOk = true ;
|
||||||
|
for ( int k = 1 ; k < int( vnPLIndMat.back().size()) ; ++ k) {
|
||||||
|
IntersCurveCurve ccInt2( *vCrvCompo[vnPLIndMat.back()[k]], *vCrvCompo[j]) ;
|
||||||
|
CRVCVECTOR ccClass2 ;
|
||||||
|
if ( ccInt2.GetCrossOrOverlapIntersCount() > 0 ||
|
||||||
|
! ccInt2.GetCurveClassification( 1, EPS_SMALL, ccClass2) ||
|
||||||
|
ccClass2.empty() || ccClass2[0].nClass != CRVC_IN) {
|
||||||
|
bOk = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( bOk) {
|
||||||
|
// inserisco nella matrice
|
||||||
|
vnPLIndMat.back().push_back( j) ;
|
||||||
|
m_vArea[i].first = -1 ;
|
||||||
|
// inverto se necessario
|
||||||
|
if ( m_vArea[i].second * dAreaExtLoop > 0.) {
|
||||||
|
vPL[j].Invert() ;
|
||||||
|
vCrvCompo[j]->Invert() ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while ( ! bFirstCrv) ;
|
||||||
else {
|
|
||||||
// ho già calcolato e riordinato tutto, devo solo fare una copia delle polyline
|
|
||||||
// non serve fare le eventuali inversioni delle polyline, perché se è già stata calcolata la matrice dei chunck allora sono GIà state invertire
|
|
||||||
vPL = vPLORIG ;
|
|
||||||
vnPLIndMat = vnPLIndMatPre ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// chiamo la Triangolazione per ogni riga della matrice ( quindi su ogni "Chunk")
|
// chiamo la Triangolazione per ogni riga della matrice ( quindi su ogni "Chunk")
|
||||||
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++ i) {
|
for ( int i = 0 ; i < int( vnPLIndMat.size()) ; ++ i) {
|
||||||
@@ -449,7 +525,7 @@ Triangulate::MakeByEC( const PNTVECTOR& vPt, INTVECTOR& vTr)
|
|||||||
vTr.push_back( vPol[i]) ;
|
vTr.push_back( vPol[i]) ;
|
||||||
vTr.push_back( vPol[vNext[i]]) ;
|
vTr.push_back( vPol[vNext[i]]) ;
|
||||||
}
|
}
|
||||||
// �Delete� vertex v[i] by redirecting next and previous links
|
// ‘Delete’ vertex v[i] by redirecting next and previous links
|
||||||
// of neighboring verts past it. Decrement vertex count
|
// of neighboring verts past it. Decrement vertex count
|
||||||
vNext[vPrev[i]] = vNext[i] ;
|
vNext[vPrev[i]] = vNext[i] ;
|
||||||
vPrev[vNext[i]] = vPrev[i] ;
|
vPrev[vNext[i]] = vPrev[i] ;
|
||||||
@@ -578,7 +654,7 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, INTVECTOR& vTr, double& dMinMinAng
|
|||||||
// Reset earity of diagonal endpoints
|
// Reset earity of diagonal endpoints
|
||||||
vEar[vPrev[i]] = EAS_NULL ;
|
vEar[vPrev[i]] = EAS_NULL ;
|
||||||
vEar[vNext[i]] = EAS_NULL ;
|
vEar[vNext[i]] = EAS_NULL ;
|
||||||
// �Delete� vertex v[i] by redirecting next and previous links
|
// ‘Delete’ vertex v[i] by redirecting next and previous links
|
||||||
// of neighboring verts past it. Decrement vertex count
|
// of neighboring verts past it. Decrement vertex count
|
||||||
vNext[vPrev[i]] = vNext[i] ;
|
vNext[vPrev[i]] = vNext[i] ;
|
||||||
vPrev[vNext[i]] = vPrev[i] ;
|
vPrev[vNext[i]] = vPrev[i] ;
|
||||||
@@ -716,7 +792,7 @@ Triangulate::MakeByEC3( const PNTVECTOR& vPt, INTVECTOR& vTr, double& dMinMinAng
|
|||||||
// Reset earity of diagonal endpoints
|
// Reset earity of diagonal endpoints
|
||||||
vEar[vPrev[i]] = EAS_NULL ;
|
vEar[vPrev[i]] = EAS_NULL ;
|
||||||
vEar[vNext[i]] = EAS_NULL ;
|
vEar[vNext[i]] = EAS_NULL ;
|
||||||
// �Delete� vertex v[i] by redirecting next and previous links
|
// ‘Delete’ vertex v[i] by redirecting next and previous links
|
||||||
// of neighboring verts past it. Decrement vertex count
|
// of neighboring verts past it. Decrement vertex count
|
||||||
vNext[vPrev[i]] = vNext[i] ;
|
vNext[vPrev[i]] = vNext[i] ;
|
||||||
vPrev[vNext[i]] = vPrev[i] ;
|
vPrev[vNext[i]] = vPrev[i] ;
|
||||||
@@ -810,7 +886,7 @@ Triangulate::TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// The �ear� triangle is clockwise so v[i] is not an ear
|
// The ‘ear’ triangle is clockwise so v[i] is not an ear
|
||||||
bIsEar = false ;
|
bIsEar = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1155,14 +1231,14 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
|||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// non ho trovato alcunch�, errore
|
// non ho trovato alcunché, errore
|
||||||
if ( nI == - 1)
|
if ( nI == - 1)
|
||||||
return false ;
|
return false ;
|
||||||
// se ho trovato un punto esatto del contorno, non devo fare altri controlli
|
// se ho trovato un punto esatto del contorno, non devo fare altri controlli
|
||||||
if ( AreSamePointApprox( ptInt, vPt[nI]))
|
if ( AreSamePointApprox( ptInt, vPt[nI]))
|
||||||
return true ;
|
return true ;
|
||||||
// devo ora verificare che il segmento che unisce i punti non intersechi altri lati del contorno esterno
|
// devo ora verificare che il segmento che unisce i punti non intersechi altri lati del contorno esterno
|
||||||
// altrimenti tengo il punto con raggio pi� vicino a X_AX o Y_AX o Z_AX secondo m_nPlane
|
// altrimenti tengo il punto con raggio più vicino a X_AX o Y_AX o Z_AX secondo m_nPlane
|
||||||
int nJ = nI ;
|
int nJ = nI ;
|
||||||
Point3d ptPa = ptP ;
|
Point3d ptPa = ptP ;
|
||||||
Point3d ptPb = vPt[nI] ;
|
Point3d ptPb = vPt[nI] ;
|
||||||
@@ -1178,7 +1254,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
|||||||
double dMinTan = INFINITO ;
|
double dMinTan = INFINITO ;
|
||||||
double dMinSqDist = SQ_INFINITO ;
|
double dMinSqDist = SQ_INFINITO ;
|
||||||
for ( int i = 0 ; i < nNumPt ; ++ i) {
|
for ( int i = 0 ; i < nNumPt ; ++ i) {
|
||||||
// salto il punto gi� trovato
|
// salto il punto già trovato
|
||||||
if ( i == nJ)
|
if ( i == nJ)
|
||||||
continue ;
|
continue ;
|
||||||
// verifico se sta nel triangolo
|
// verifico se sta nel triangolo
|
||||||
@@ -1214,7 +1290,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
|||||||
bool
|
bool
|
||||||
Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const Point3d& ptCorn, const Point3d& ptNext)
|
Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const Point3d& ptCorn, const Point3d& ptNext)
|
||||||
{
|
{
|
||||||
// la parte valida del settore � a sinistra dei segmenti ptPrev --> ptCorn --> ptNext
|
// la parte valida del settore è a sinistra dei segmenti ptPrev --> ptCorn --> ptNext
|
||||||
// se corner convesso
|
// se corner convesso
|
||||||
if ( TriangleIsCCW( ptPrev, ptCorn, ptNext, 0))
|
if ( TriangleIsCCW( ptPrev, ptCorn, ptNext, 0))
|
||||||
return ( TriangleIsCCW( ptPrev, ptCorn, ptTest) &&
|
return ( TriangleIsCCW( ptPrev, ptCorn, ptTest) &&
|
||||||
@@ -1229,10 +1305,10 @@ Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const
|
|||||||
bool
|
bool
|
||||||
ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi)
|
ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi)
|
||||||
{
|
{
|
||||||
// se il nuovo inizio coincide col vecchio, non devo fare alcunch�
|
// se il nuovo inizio coincide col vecchio, non devo fare alcunché
|
||||||
if ( nNewStart == 0)
|
if ( nNewStart == 0)
|
||||||
return true ;
|
return true ;
|
||||||
// se il nuovo indice � oltre la dimensione del vettore, errore
|
// se il nuovo indice è oltre la dimensione del vettore, errore
|
||||||
if ( nNewStart >= int( vPi.size()))
|
if ( nNewStart >= int( vPi.size()))
|
||||||
return false ;
|
return false ;
|
||||||
// ciclo di aggiustamento
|
// ciclo di aggiustamento
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class Triangulate
|
|||||||
bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||||
bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||||
bool MakeAdvanced( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
bool MakeAdvanced( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||||
bool MakeAdvanced( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, const INTMATRIX& vnPLIndMat) ;
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
bool MakeByEC_HPP( const PolyLine& PL, bool bCCW, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
bool MakeByEC_HPP( const PolyLine& PL, bool bCCW, PNTVECTOR& vPt, INTVECTOR& vTr) ;
|
||||||
|
|||||||
+5
-184
@@ -18,14 +18,13 @@
|
|||||||
#include "GdbGeo.h"
|
#include "GdbGeo.h"
|
||||||
#include "NgeWriter.h"
|
#include "NgeWriter.h"
|
||||||
#include "NgeReader.h"
|
#include "NgeReader.h"
|
||||||
|
#include "DistPointLine.h"
|
||||||
#include "GeoConst.h"
|
#include "GeoConst.h"
|
||||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
|
||||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||||
#include "/EgtDev/Include/EGkIntervals.h"
|
#include "/EgtDev/Include/EGkIntervals.h"
|
||||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <future>
|
#include <future>
|
||||||
|
|
||||||
@@ -50,6 +49,7 @@ VolZmap::VolZmap(void)
|
|||||||
m_nFracLin[i] = 0 ;
|
m_nFracLin[i] = 0 ;
|
||||||
}
|
}
|
||||||
m_vTool.resize( 1) ;
|
m_vTool.resize( 1) ;
|
||||||
|
m_nCurrTool = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -1499,186 +1499,6 @@ VolZmap::GetPartMinDistFromPoint( const Point3d& ptP) const
|
|||||||
return ( nMinDistPart - 1) ;
|
return ( nMinDistPart - 1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
VolZmap::AddSurfTm( const ISurfTriMesh* pStm)
|
|
||||||
{
|
|
||||||
// controllo sulla superficie
|
|
||||||
double dVol ;
|
|
||||||
if ( pStm == nullptr || ! pStm->IsValid() || ! pStm->IsClosed() ||
|
|
||||||
! pStm->GetVolume( dVol) || dVol < 0)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// controllo se il Box3d della superficie si interseca con il Box3d dello Zmap corrente
|
|
||||||
BBox3d BBox_stm, BBox_curr ;
|
|
||||||
if ( ! pStm->GetLocalBBox( BBox_stm) || ! GetLocalBBox( BBox_curr))
|
|
||||||
return false ;
|
|
||||||
BBox3d BBox_inters ;
|
|
||||||
if ( BBox_stm.FindIntersection( BBox_curr, BBox_inters) && BBox_inters.IsEmpty())
|
|
||||||
return true ; // se non ci sono intersezioni, la superficie non influenza lo Zmap
|
|
||||||
Vector3d vtLen = BBox_curr.GetMax() - BBox_curr.GetMin() ; // dimensione massima dello spillone
|
|
||||||
|
|
||||||
// ciclo sulle griglie
|
|
||||||
bool bCompleted = true ;
|
|
||||||
for ( int g = 0 ; g < m_nMapNum ; ++ g) {
|
|
||||||
// definisco dei sistemi di riferimento ausiliari
|
|
||||||
Frame3d frMapFrame ;
|
|
||||||
if ( g == 0)
|
|
||||||
frMapFrame = m_MapFrame ;
|
|
||||||
else if ( g == 1)
|
|
||||||
frMapFrame.Set( m_MapFrame.Orig(), Y_AX, Z_AX, X_AX) ;
|
|
||||||
else if ( g == 2)
|
|
||||||
frMapFrame.Set( m_MapFrame.Orig(), Z_AX, X_AX, Y_AX) ;
|
|
||||||
|
|
||||||
// oggetto per calcolo massivo intersezioni
|
|
||||||
IntersParLinesSurfTm intPLSTM( frMapFrame, *pStm) ;
|
|
||||||
|
|
||||||
// numero massimo di thread
|
|
||||||
int nThreadMax = max( 1, int( thread::hardware_concurrency()) - 1) ;
|
|
||||||
vector<future<bool>> vRes ;
|
|
||||||
vRes.resize( nThreadMax) ;
|
|
||||||
// se dimensione griglia in X maggiore di dimensione Y
|
|
||||||
if ( m_nNx[g] > m_nNy[g]) {
|
|
||||||
int nDexNum = m_nNx[g] / nThreadMax ;
|
|
||||||
int nRemainder = m_nNx[g] % nThreadMax ;
|
|
||||||
int nInfI = 0 ;
|
|
||||||
int nSupI = 0 ;
|
|
||||||
// aggiungo le parti interessate alla mappa
|
|
||||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
|
||||||
nInfI = nSupI ;
|
|
||||||
nSupI = nInfI + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
|
||||||
vRes[nThread] = async( launch::async, &VolZmap::AddMapPart, this, g,
|
|
||||||
nInfI, nSupI, 0, m_nNy[g], ref( vtLen), ref( m_MapFrame.Orig()),
|
|
||||||
ref( *pStm), ref( intPLSTM)) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// se dimensione griglia in Y maggiore di dimensione X
|
|
||||||
else {
|
|
||||||
int nDexNum = m_nNy[g] / nThreadMax ;
|
|
||||||
int nRemainder = m_nNy[g] % nThreadMax ;
|
|
||||||
int nInfJ = 0 ;
|
|
||||||
int nSupJ = 0 ;
|
|
||||||
// aggiungo le parti interessate alla mappa
|
|
||||||
for ( int nThread = 0 ; nThread < nThreadMax ; ++ nThread) {
|
|
||||||
nInfJ = nSupJ ;
|
|
||||||
nSupJ = nInfJ + ( nThread < nRemainder ? nDexNum + 1 : nDexNum) ;
|
|
||||||
vRes[nThread] = async( launch::async, &VolZmap::AddMapPart, this, g,
|
|
||||||
0, m_nNx[g], nInfJ, nSupJ, ref( vtLen), ref( m_MapFrame.Orig()),
|
|
||||||
ref( *pStm), 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() ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! bCompleted)
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
VolZmap::MakeUniform( double dToler)
|
|
||||||
{
|
|
||||||
// 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))
|
|
||||||
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))
|
|
||||||
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)
|
|
||||||
continue ;
|
|
||||||
// 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) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::SetToModifyDexelBlocks( int nGrid, int nDex, int nInt)
|
VolZmap::SetToModifyDexelBlocks( int nGrid, int nDex, int nInt)
|
||||||
@@ -2355,7 +2175,7 @@ VolZmap::SetChiselTool( const string& sToolName, double dH, double dW, double dT
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::SetAdditiveTool( const std::string& sToolName,
|
VolZmap::SetAdditiveTool( const std::string& sToolName,
|
||||||
double dH, double dR, double dRc, int nFlag, bool bFirst)
|
double dH, double dR, double dRC, int nFlag, bool bFirst)
|
||||||
{
|
{
|
||||||
if ( bFirst) {
|
if ( bFirst) {
|
||||||
m_vTool.resize( 1) ;
|
m_vTool.resize( 1) ;
|
||||||
@@ -2367,9 +2187,10 @@ VolZmap::SetAdditiveTool( const std::string& sToolName,
|
|||||||
if ( m_nCurrTool < 0)
|
if ( m_nCurrTool < 0)
|
||||||
return false ;
|
return false ;
|
||||||
m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ;
|
m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ;
|
||||||
return m_vTool[m_nCurrTool].SetAdditiveTool( sToolName, dH, dR, dRc, nFlag) ;
|
return m_vTool[m_nCurrTool].SetAdditiveTool( sToolName, dH, dR, dRC, nFlag) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
int
|
int
|
||||||
VolZmap::GetToolCount( void) const
|
VolZmap::GetToolCount( void) const
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2015-2024
|
// EgalTech 2015-2023
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : VolZmap.h Data : 22.04.24 Versione : 2.6d4
|
// File : VolZmap.h Data : 12.09.23 Versione : 2.5i1
|
||||||
// Contenuto : Dichiarazione della classe Volume Zmap.
|
// Contenuto : Dichiarazione della classe Volume Zmap.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -78,7 +78,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
|||||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||||
bool Clear( void) override ;
|
bool Clear( void) override ;
|
||||||
bool Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
bool Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
||||||
bool CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex) override ;
|
bool CreateEmptyMap( const Point3d& ptO, double dLengthX, double dLengthY, double dLengthZ, double dStep, bool bTriDex) override ;
|
||||||
bool CreateFromFlatRegion( const ISurfFlatRegion& Surf, 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) override ;
|
bool CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex) override ;
|
||||||
int GetBlockCount( void) const override ;
|
int GetBlockCount( void) const override ;
|
||||||
@@ -111,7 +111,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
|||||||
bool SetChiselTool( const std::string& sToolName,
|
bool SetChiselTool( const std::string& sToolName,
|
||||||
double dH, double dW, double dTh, int nFlag, bool bFirst) override ;
|
double dH, double dW, double dTh, int nFlag, bool bFirst) override ;
|
||||||
bool SetAdditiveTool( const std::string& sToolName,
|
bool SetAdditiveTool( const std::string& sToolName,
|
||||||
double dH, double dR, double dRc, int nFlag, bool bFirst) override ;
|
double dH, double dR, double dRC, int nFlag, bool bFirst) override ;
|
||||||
int GetToolCount( void) const override ;
|
int GetToolCount( void) const override ;
|
||||||
bool SetCurrTool( int nCurrTool) override ;
|
bool SetCurrTool( int nCurrTool) override ;
|
||||||
bool ResetTools( void) override ;
|
bool ResetTools( void) override ;
|
||||||
@@ -143,8 +143,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
|||||||
VolZmap* ClonePart( int nPart) const override ;
|
VolZmap* ClonePart( int nPart) const override ;
|
||||||
bool RemovePart( int nPart) override ;
|
bool RemovePart( int nPart) override ;
|
||||||
int GetPartMinDistFromPoint( const Point3d& ptP) const override ;
|
int GetPartMinDistFromPoint( const Point3d& ptP) const override ;
|
||||||
bool AddSurfTm( const ISurfTriMesh* pStm) override ;
|
|
||||||
bool MakeUniform( double dToler) override ;
|
|
||||||
|
|
||||||
public : // IGeoObjRW
|
public : // IGeoObjRW
|
||||||
int GetNgeId( void) const override ;
|
int GetNgeId( void) const override ;
|
||||||
@@ -245,15 +243,9 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
|||||||
INTVECTOR& vAdjBlockVoxComp, INTVECTOR& vAdjBordBlockVoxComp) const ;
|
INTVECTOR& vAdjBlockVoxComp, INTVECTOR& vAdjBordBlockVoxComp) const ;
|
||||||
// OPERAZIONI SU INTERVALLI
|
// OPERAZIONI SU INTERVALLI
|
||||||
bool SubtractIntervals( int nGrid, int nI, int nJ,
|
bool SubtractIntervals( int nGrid, int nI, int nJ,
|
||||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum) ;
|
||||||
int nToolNum, bool bSkipSwap = false) ;
|
|
||||||
bool AddIntervals( int nGrid, int nI, int nJ,
|
bool AddIntervals( int nGrid, int nI, int nJ,
|
||||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum) ;
|
||||||
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) ;
|
|
||||||
// Spostamenti utensile
|
// Spostamenti utensile
|
||||||
bool MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtD, const Vector3d& vtA) ;
|
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,
|
bool MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs,
|
||||||
@@ -430,8 +422,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
|||||||
// Funzione per crezione solido in parallelo
|
// Funzione per crezione solido in parallelo
|
||||||
bool CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
bool CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
||||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
||||||
bool AddMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
|
||||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM) ;
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
|
||||||
@@ -465,7 +455,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW
|
|||||||
} ;
|
} ;
|
||||||
std::vector<std::vector<Data>> m_Values[N_MAPS] ; // dexel delle 3 griglie
|
std::vector<std::vector<Data>> m_Values[N_MAPS] ; // dexel delle 3 griglie
|
||||||
|
|
||||||
|
|
||||||
int m_nShape ; // Forma : 0 generica, 1 box, 2 estrusione
|
int m_nShape ; // Forma : 0 generica, 1 box, 2 estrusione
|
||||||
|
|
||||||
int m_nVoxNumPerBlock ; // Numero di voxel per blocco
|
int m_nVoxNumPerBlock ; // Numero di voxel per blocco
|
||||||
|
|||||||
+22
-114
@@ -1,4 +1,4 @@
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// EgalTech 2015-2016
|
// EgalTech 2015-2016
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// File : VolZmap.cpp Data : 22.01.15 Versione : 1.6a4
|
// File : VolZmap.cpp Data : 22.01.15 Versione : 1.6a4
|
||||||
@@ -27,10 +27,10 @@ using namespace std ;
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex)
|
VolZmap::Create( const Point3d& ptO, double dLengthX, double dLengthY, double dLengthZ, double dStep, bool bTriDex)
|
||||||
{
|
{
|
||||||
// Controlli sull'ammissibilità delle dimensioni lineari del grezzo e del passo
|
// Controlli sull'ammissibilità delle dimensioni lineari del grezzo e del passo
|
||||||
if ( dStep < EPS_SMALL || dDimX < EPS_SMALL || dDimY < EPS_SMALL || dDimZ < EPS_SMALL)
|
if ( dStep < EPS_SMALL || dLengthX < EPS_SMALL || dLengthY < EPS_SMALL || dLengthZ < EPS_SMALL)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Il passo di discretizzazione non può essere inferiore a 100 * EPS_SMALL
|
// Il passo di discretizzazione non può essere inferiore a 100 * EPS_SMALL
|
||||||
@@ -47,8 +47,8 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
|||||||
m_MapFrame.Set( ptO, X_AX, Y_AX, Z_AX) ;
|
m_MapFrame.Set( ptO, X_AX, Y_AX, Z_AX) ;
|
||||||
|
|
||||||
// Definisco i vettori dei limiti su indici
|
// Definisco i vettori dei limiti su indici
|
||||||
m_nNx[0] = max( int( ( dDimX + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
m_nNx[0] = max( int( ( dLengthX + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||||
m_nNy[0] = max( int( ( dDimY + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
m_nNy[0] = max( int( ( dLengthY + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||||
|
|
||||||
// Numero di componenti connesse
|
// Numero di componenti connesse
|
||||||
m_nConnectedCompoCount = 1 ;
|
m_nConnectedCompoCount = 1 ;
|
||||||
@@ -56,7 +56,7 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
|||||||
// Se tridexel
|
// Se tridexel
|
||||||
if ( bTriDex) {
|
if ( bTriDex) {
|
||||||
m_nNx[1] = m_nNy[0] ;
|
m_nNx[1] = m_nNy[0] ;
|
||||||
m_nNy[1] = max( int( ( dDimZ + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
m_nNy[1] = max( int( ( dLengthZ + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||||
m_nNx[2] = m_nNy[1] ;
|
m_nNx[2] = m_nNy[1] ;
|
||||||
m_nNy[2] = m_nNx[0] ;
|
m_nNy[2] = m_nNx[0] ;
|
||||||
}
|
}
|
||||||
@@ -97,19 +97,19 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
|||||||
switch ( i) {
|
switch ( i) {
|
||||||
case 0 :
|
case 0 :
|
||||||
m_Values[i][j][0].vtMinN = - Z_AX ;
|
m_Values[i][j][0].vtMinN = - Z_AX ;
|
||||||
m_Values[i][j][0].dMax = dDimZ ;
|
m_Values[i][j][0].dMax = dLengthZ ;
|
||||||
m_Values[i][j][0].vtMaxN = Z_AX ;
|
m_Values[i][j][0].vtMaxN = Z_AX ;
|
||||||
m_Values[i][j][0].nToolMax = 0 ;
|
m_Values[i][j][0].nToolMax = 0 ;
|
||||||
break ;
|
break ;
|
||||||
case 1 :
|
case 1 :
|
||||||
m_Values[i][j][0].vtMinN = - X_AX ;
|
m_Values[i][j][0].vtMinN = - X_AX ;
|
||||||
m_Values[i][j][0].dMax = dDimX ;
|
m_Values[i][j][0].dMax = dLengthX ;
|
||||||
m_Values[i][j][0].vtMaxN = X_AX ;
|
m_Values[i][j][0].vtMaxN = X_AX ;
|
||||||
m_Values[i][j][0].nToolMax = 0 ;
|
m_Values[i][j][0].nToolMax = 0 ;
|
||||||
break ;
|
break ;
|
||||||
case 2 :
|
case 2 :
|
||||||
m_Values[i][j][0].vtMinN = - Y_AX ;
|
m_Values[i][j][0].vtMinN = - Y_AX ;
|
||||||
m_Values[i][j][0].dMax = dDimY ;
|
m_Values[i][j][0].dMax = dLengthY ;
|
||||||
m_Values[i][j][0].vtMaxN = Y_AX ;
|
m_Values[i][j][0].vtMaxN = Y_AX ;
|
||||||
m_Values[i][j][0].nToolMax = 0 ;
|
m_Values[i][j][0].nToolMax = 0 ;
|
||||||
break ;
|
break ;
|
||||||
@@ -118,11 +118,11 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
|||||||
|
|
||||||
// Definizione delle limitazioni iniziali in Z per ogni mappa
|
// Definizione delle limitazioni iniziali in Z per ogni mappa
|
||||||
m_dMinZ[0] = 0 ;
|
m_dMinZ[0] = 0 ;
|
||||||
m_dMaxZ[0] = dDimZ ;
|
m_dMaxZ[0] = dLengthZ ;
|
||||||
m_dMinZ[1] = 0 ;
|
m_dMinZ[1] = 0 ;
|
||||||
m_dMaxZ[1] = ( bTriDex ? dDimX : 0) ;
|
m_dMaxZ[1] = ( bTriDex ? dLengthX : 0) ;
|
||||||
m_dMinZ[2] = 0 ;
|
m_dMinZ[2] = 0 ;
|
||||||
m_dMaxZ[2] = ( bTriDex ? dDimY : 0) ;
|
m_dMaxZ[2] = ( bTriDex ? dLengthY : 0) ;
|
||||||
|
|
||||||
// Tipologia
|
// Tipologia
|
||||||
m_nShape = BOX ;
|
m_nShape = BOX ;
|
||||||
@@ -135,13 +135,13 @@ VolZmap::Create( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, d
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDimZ, double dStep, bool bTriDex)
|
VolZmap::CreateEmptyMap( const Point3d& ptO, double dLengthX, double dLengthY, double dLengthZ, double dStep, bool bTriDex)
|
||||||
{
|
{
|
||||||
// Controlli sull'ammissibilità delle dimensioni lineari del grezzo e del passo
|
// Controlli sull'ammissibilit� delle dimensioni lineari del grezzo e del passo
|
||||||
if ( dStep < EPS_SMALL || dDimX < EPS_SMALL || dDimY < EPS_SMALL || dDimZ < EPS_SMALL)
|
if ( dStep < EPS_SMALL || dLengthX < EPS_SMALL || dLengthY < EPS_SMALL || dLengthZ < EPS_SMALL)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Il passo di discretizzazione non può essere inferiore a 100 * EPS_SMALL
|
// Il passo di discretizzazione non pu� essere inferiore a 100 * EPS_SMALL
|
||||||
m_dStep = max( dStep, 100 * EPS_SMALL) ;
|
m_dStep = max( dStep, 100 * EPS_SMALL) ;
|
||||||
|
|
||||||
// Aggiorno la dimensione della mappa 1 o 3
|
// Aggiorno la dimensione della mappa 1 o 3
|
||||||
@@ -155,8 +155,8 @@ VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDi
|
|||||||
m_MapFrame.Set( ptO, X_AX, Y_AX, Z_AX) ;
|
m_MapFrame.Set( ptO, X_AX, Y_AX, Z_AX) ;
|
||||||
|
|
||||||
// Definisco i vettori dei limiti su indici
|
// Definisco i vettori dei limiti su indici
|
||||||
m_nNx[0] = max( int( ( dDimX + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
m_nNx[0] = max( int( ( dLengthX + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||||
m_nNy[0] = max( int( ( dDimY + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
m_nNy[0] = max( int( ( dLengthY + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||||
|
|
||||||
// Numero di componenti connesse
|
// Numero di componenti connesse
|
||||||
m_nConnectedCompoCount = 1 ;
|
m_nConnectedCompoCount = 1 ;
|
||||||
@@ -164,7 +164,7 @@ VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDi
|
|||||||
// Se tridexel
|
// Se tridexel
|
||||||
if ( bTriDex) {
|
if ( bTriDex) {
|
||||||
m_nNx[1] = m_nNy[0] ;
|
m_nNx[1] = m_nNy[0] ;
|
||||||
m_nNy[1] = max( int( ( dDimZ + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
m_nNy[1] = max( int( ( dLengthZ + EPS_SMALL) / m_dStep + 0.5), 1) ;
|
||||||
m_nNx[2] = m_nNy[1] ;
|
m_nNx[2] = m_nNy[1] ;
|
||||||
m_nNy[2] = m_nNx[0] ;
|
m_nNy[2] = m_nNx[0] ;
|
||||||
}
|
}
|
||||||
@@ -192,11 +192,11 @@ VolZmap::CreateEmpty( const Point3d& ptO, double dDimX, double dDimY, double dDi
|
|||||||
|
|
||||||
// Definizione delle limitazioni iniziali in Z per ogni mappa
|
// Definizione delle limitazioni iniziali in Z per ogni mappa
|
||||||
m_dMinZ[0] = 0 ;
|
m_dMinZ[0] = 0 ;
|
||||||
m_dMaxZ[0] = dDimZ ;
|
m_dMaxZ[0] = dLengthZ ;
|
||||||
m_dMinZ[1] = 0 ;
|
m_dMinZ[1] = 0 ;
|
||||||
m_dMaxZ[1] = ( bTriDex ? dDimX : 0) ;
|
m_dMaxZ[1] = ( bTriDex ? dLengthX : 0) ;
|
||||||
m_dMinZ[2] = 0 ;
|
m_dMinZ[2] = 0 ;
|
||||||
m_dMaxZ[2] = ( bTriDex ? dDimY : 0) ;
|
m_dMaxZ[2] = ( bTriDex ? dLengthY : 0) ;
|
||||||
|
|
||||||
// Tipologia
|
// Tipologia
|
||||||
m_nShape = GENERIC ;
|
m_nShape = GENERIC ;
|
||||||
@@ -597,98 +597,6 @@ VolZmap::CreateMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, co
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
VolZmap::AddMapPart( int nMap, int nInfI, int nSupI, int nInfJ, int nSupJ, const Vector3d& vtLen, const Point3d& ptMapOrig,
|
|
||||||
const ISurfTriMesh& Surf, IntersParLinesSurfTm& intPLSTM)
|
|
||||||
{
|
|
||||||
// controllo sui parametri
|
|
||||||
if ( nMap < 0 || nMap > 2 ||
|
|
||||||
nInfI < 0 || nInfI > m_nNx[nMap] ||
|
|
||||||
nSupI < 0 || nSupI > m_nNx[nMap] ||
|
|
||||||
nInfJ < 0 || nInfJ > m_nNy[nMap] ||
|
|
||||||
nSupJ < 0 || nSupJ > m_nNy[nMap])
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// determinazione e ridimensionamento dei dexel interni alla trimesh
|
|
||||||
for ( int i = nInfI ; i < nSupI ; ++ i) {
|
|
||||||
for ( int j = nInfJ ; j < nSupJ ; ++ j) {
|
|
||||||
|
|
||||||
// definisco la retta da intersecare con la trimesh
|
|
||||||
double dX = ( i + 0.5) * m_dStep ;
|
|
||||||
double dY = ( j + 0.5) * m_dStep ;
|
|
||||||
Point3d ptP0( dX, dY, 0) ;
|
|
||||||
|
|
||||||
// intersezioni della retta con la TriMesh
|
|
||||||
ILSIVECTOR IntersectionResults ;
|
|
||||||
intPLSTM.GetInters( ptP0, vtLen.v[(nMap+2)%3], IntersectionResults) ;
|
|
||||||
|
|
||||||
// rimuovo le intersezioni in eccesso
|
|
||||||
for ( int nI = 0 ; nI < int( IntersectionResults.size()) - 3 ; ++ nI) {
|
|
||||||
int nJ = nI + 1 ; // prima successiva
|
|
||||||
int nK = nJ + 1 ; // seconda successiva
|
|
||||||
int nT = nK + 1 ; // terza successiva
|
|
||||||
// determino i segni delle 4 intersezioni tra la linea e il trangolo della TriMesh
|
|
||||||
int nSgnI = IntersectionResults[nI].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nI].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
|
||||||
int nSgnJ = IntersectionResults[nJ].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nJ].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
|
||||||
int nSgnK = IntersectionResults[nK].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nK].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
|
||||||
int nSgnT = IntersectionResults[nT].dCosDN > EPS_SMALL ? 1 : IntersectionResults[nT].dCosDN > -EPS_SMALL ? 0 : - 1 ;
|
|
||||||
// parametri dell'intersezione sulla linea
|
|
||||||
double dUJ = IntersectionResults[nJ].dU ;
|
|
||||||
double dUK = IntersectionResults[nK].dU ;
|
|
||||||
// controllo coerenza con segni...
|
|
||||||
if ( nSgnI != 0 && nSgnI == nSgnJ &&
|
|
||||||
nSgnK != 0 && nSgnK == nSgnT &&
|
|
||||||
nSgnI == - nSgnT &&
|
|
||||||
abs( dUJ - dUK) < EPS_SMALL) {
|
|
||||||
// ... ed elimino le intersezioni in eccesso...
|
|
||||||
IntersectionResults.erase( IntersectionResults.begin() + nK) ;
|
|
||||||
IntersectionResults.erase( IntersectionResults.begin() + nJ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int nInt = int( IntersectionResults.size()) ; // numero di intersezioni valide
|
|
||||||
bool bInside = false ; // Flag entrata/uscita per tratto di retta
|
|
||||||
Point3d ptIn ; Vector3d vtInN ;
|
|
||||||
|
|
||||||
// per ogni intersezione valida trovata...
|
|
||||||
for ( int k = 0 ; k < nInt ; ++ k) {
|
|
||||||
// ricavo il tipo di intersezione
|
|
||||||
int nIntType = IntersectionResults[k].nILTT ;
|
|
||||||
// se c'è intersezione
|
|
||||||
if ( nIntType != ILTT_NO) {
|
|
||||||
// ricavo il cos tra i vettori ( normale del triangolo e tangente alla retta)
|
|
||||||
double dCos = IntersectionResults[k].dCosDN ;
|
|
||||||
|
|
||||||
// se entro nella superficie trimesh...
|
|
||||||
if ( dCos < - EPS_SMALL) {
|
|
||||||
ptIn = IntersectionResults[k].ptI ; // punto di intersezione
|
|
||||||
int nT = IntersectionResults[k].nT ; // triangolo di interesse
|
|
||||||
int nF = Surf.GetFacetFromTria( nT) ; // faccia di interesse
|
|
||||||
Surf.GetFacetNormal( nF, vtInN) ;
|
|
||||||
bInside = true ; // entrata
|
|
||||||
}
|
|
||||||
// ...se esco dalla superficie trimesh ( prima sono per forza entrato)
|
|
||||||
else if ( dCos > EPS_SMALL && bInside) {
|
|
||||||
Point3d ptOut = IntersectionResults[k].ptI ; // punto di intersezione
|
|
||||||
int nT = IntersectionResults[k].nT ; // triangolo di interesse
|
|
||||||
int nF = Surf.GetFacetFromTria( nT) ; // faccia di interesse
|
|
||||||
Vector3d vtOutN ; Surf.GetFacetNormal( nF, vtOutN) ; // vettore d'uscita
|
|
||||||
|
|
||||||
// Aggiungo un tratto al dexel
|
|
||||||
AddIntervals( nMap, i, j,
|
|
||||||
ptIn.v[(nMap+2)%3] - ptMapOrig.v[(nMap+2)%3],
|
|
||||||
ptOut.v[(nMap+2)%3] - ptMapOrig.v[(nMap+2)%3],
|
|
||||||
vtInN, vtOutN, 0, true) ;
|
|
||||||
bInside = false ; // uscita
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex)
|
VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dStep, bool bTriDex)
|
||||||
|
|||||||
+6
-16
@@ -3364,19 +3364,15 @@ VolZmap::IsThereMat( int nI, int nJ, int nK) const
|
|||||||
int nIndex = 0 ;
|
int nIndex = 0 ;
|
||||||
int nPos = nGrJ * m_nNx[nGrid] + nGrI ;
|
int nPos = nGrJ * m_nNx[nGrid] + nGrI ;
|
||||||
nDexSize[nGrid] = int( m_Values[nGrid][nPos].size()) ;
|
nDexSize[nGrid] = int( m_Values[nGrid][nPos].size()) ;
|
||||||
// scorro i sotto-interalli dello spillone
|
|
||||||
while ( nIndex < nDexSize[nGrid]) {
|
while ( nIndex < nDexSize[nGrid]) {
|
||||||
// distanza tra la "Z" attuale e il parametro minimo e massimo dell'intervallo nIndex-esimo
|
|
||||||
double dDistInf = dZ[nGrid] - m_Values[nGrid][nPos][nIndex].dMin + 2 * EPS_SMALL ;
|
double dDistInf = dZ[nGrid] - m_Values[nGrid][nPos][nIndex].dMin + 2 * EPS_SMALL ;
|
||||||
double dDistSup = dZ[nGrid] - m_Values[nGrid][nPos][nIndex].dMax - 2 * EPS_SMALL ;
|
double dDistSup = dZ[nGrid] - m_Values[nGrid][nPos][nIndex].dMax - 2 * EPS_SMALL ;
|
||||||
// se "Z" attuale a cavallo tra queste due distanze...
|
|
||||||
if ( dDistInf > 0. && dDistSup < 0.) {
|
if ( dDistInf > 0. && dDistSup < 0.) {
|
||||||
nMinIndex[nGrid] = nIndex ; // aggiorno l'indice
|
nMinIndex[nGrid] = nIndex ;
|
||||||
++ nCount ;
|
++ nCount ;
|
||||||
bInterOnNode[nGrid] = true ; // flag T per griglia zero
|
bInterOnNode[nGrid] = true ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
// se "Z" attuale tutta sopra o tutta sotto
|
|
||||||
else {
|
else {
|
||||||
double dDist = min( abs( dDistInf), abs( dDistSup)) ;
|
double dDist = min( abs( dDistInf), abs( dDistSup)) ;
|
||||||
if ( dDist < dMinDist) {
|
if ( dDist < dMinDist) {
|
||||||
@@ -3385,21 +3381,15 @@ VolZmap::IsThereMat( int nI, int nJ, int nK) const
|
|||||||
dMinDist = dDist ;
|
dMinDist = dDist ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sotto-intervallo successivo
|
|
||||||
nIndex += 1 ;
|
nIndex += 1 ;
|
||||||
}
|
}
|
||||||
} // fine ciclo sulle griglie
|
}
|
||||||
|
if ( nCount == 3)
|
||||||
if ( nCount == 3) // ... se interno a tutte e 3 le griglie, allora c'è materiale ...
|
|
||||||
return true ;
|
return true ;
|
||||||
else if ( nCount == 2) { // ... se interno solo a 2 griglie ...
|
else if ( nCount == 2) {
|
||||||
// recupero la griglia sulla quale è esterno
|
|
||||||
int nGrid = ( bInterOnNode[0] ? ( bInterOnNode[1] ? 2 : 1) : 0) ;
|
int nGrid = ( bInterOnNode[0] ? ( bInterOnNode[1] ? 2 : 1) : 0) ;
|
||||||
// se tale griglia non ha sotto-intervalli allora non c'è materiale
|
|
||||||
if ( nDexSize[nGrid] == 0)
|
if ( nDexSize[nGrid] == 0)
|
||||||
return false ;
|
return false ;
|
||||||
// se il valore in "Z" dello spillone è vicino al punto ( 1/10 dello step), aggiorno il
|
|
||||||
// parametro minimo e massimo e considero la presenza di materiale
|
|
||||||
if ( dZ[nGrid] > m_Values[nGrid][nMinPos[nGrid]][nMinIndex[nGrid]].dMin - 0.1 * m_dStep &&
|
if ( dZ[nGrid] > m_Values[nGrid][nMinPos[nGrid]][nMinIndex[nGrid]].dMin - 0.1 * m_dStep &&
|
||||||
dZ[nGrid] < m_Values[nGrid][nMinPos[nGrid]][nMinIndex[nGrid]].dMax + 0.1 * m_dStep) {
|
dZ[nGrid] < m_Values[nGrid][nMinPos[nGrid]][nMinIndex[nGrid]].dMax + 0.1 * m_dStep) {
|
||||||
double dDistInf = abs( dZ[nGrid] - m_Values[nGrid][nMinPos[nGrid]][nMinIndex[nGrid]].dMin) ;
|
double dDistInf = abs( dZ[nGrid] - m_Values[nGrid][nMinPos[nGrid]][nMinIndex[nGrid]].dMin) ;
|
||||||
@@ -3413,7 +3403,7 @@ VolZmap::IsThereMat( int nI, int nJ, int nK) const
|
|||||||
else
|
else
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
else // ... se invece interno a 1 o a nessuna delle griglie, allora non c'è materiale
|
else
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+121
-319
@@ -30,8 +30,7 @@ using namespace std ;
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::SubtractIntervals( int nGrid, int nI, int nJ,
|
VolZmap::SubtractIntervals( int nGrid, int nI, int nJ,
|
||||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum)
|
||||||
int nToolNum, bool bSkipSwap)
|
|
||||||
{
|
{
|
||||||
// Controllo che dMin e dMax non siano quasi coincidenti
|
// Controllo che dMin e dMax non siano quasi coincidenti
|
||||||
if ( abs( dMax - dMin) < EPS_ZERO)
|
if ( abs( dMax - dMin) < EPS_ZERO)
|
||||||
@@ -55,13 +54,13 @@ VolZmap::SubtractIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Riporto le coordinate cicliche delle normali nell'ordine di partenza (da griglia a sistema intrinseco)
|
// Riporto le coordinate cicliche delle normali nell'ordine di partenza (da griglia a sistema intrinseco)
|
||||||
if ( !bSkipSwap && nGrid == 1) {
|
if ( nGrid == 1) {
|
||||||
swap( vtNmi.x, vtNmi.z) ;
|
swap( vtNmi.x, vtNmi.z) ;
|
||||||
swap( vtNmi.y, vtNmi.z) ;
|
swap( vtNmi.y, vtNmi.z) ;
|
||||||
swap( vtNma.x, vtNma.z) ;
|
swap( vtNma.x, vtNma.z) ;
|
||||||
swap( vtNma.y, vtNma.z) ;
|
swap( vtNma.y, vtNma.z) ;
|
||||||
}
|
}
|
||||||
else if ( !bSkipSwap && nGrid == 2) {
|
else if ( nGrid == 2) {
|
||||||
swap( vtNmi.y, vtNmi.z) ;
|
swap( vtNmi.y, vtNmi.z) ;
|
||||||
swap( vtNmi.x, vtNmi.z) ;
|
swap( vtNmi.x, vtNmi.z) ;
|
||||||
swap( vtNma.y, vtNma.z) ;
|
swap( vtNma.y, vtNma.z) ;
|
||||||
@@ -251,16 +250,15 @@ VolZmap::SubtractIntervals( int nGrid, int nI, int nJ,
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
||||||
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax,
|
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum)
|
||||||
int nToolNum, bool bSkipSwap)
|
|
||||||
{
|
{
|
||||||
// Controllo che il numero di griglia sia entro i limiti
|
// Controllo che il numero di griglia sia entro i limiti
|
||||||
if ( nGrid < 0 || nGrid > 2)
|
if ( nGrid < 0 || nGrid > 2)
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Controllo che indici nI, nJ siano entro i limiti
|
// Controllo che indici nI, nJ siano entro i limiti
|
||||||
if ( nI < 0 && nI >= m_nNx[nGrid] &&
|
if ( nI < 0 && nI >= m_nNx[nGrid] &&
|
||||||
nJ < 0 && nJ >= m_nNy[nGrid])
|
nJ < 0 && nJ >= m_nNy[nGrid])
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// Controllo che dMin < dMax
|
// Controllo che dMin < dMax
|
||||||
@@ -274,37 +272,33 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
// Restringo minimo e massimo entro i limiti della mappa
|
// Restringo minimo e massimo entro i limiti della mappa
|
||||||
if ( dMin < m_dMinZ[nGrid]) {
|
if ( dMin < m_dMinZ[nGrid]) {
|
||||||
dMin = m_dMinZ[nGrid] ;
|
dMin = m_dMinZ[nGrid] ;
|
||||||
if ( ! bSkipSwap)
|
vtNmi = - Z_AX ;
|
||||||
vtNmi = - Z_AX ;
|
|
||||||
}
|
}
|
||||||
else if ( dMin > m_dMaxZ[nGrid]) {
|
else if ( dMin > m_dMaxZ[nGrid]) {
|
||||||
dMin = m_dMaxZ[nGrid] ;
|
dMin = m_dMaxZ[nGrid] ;
|
||||||
if ( ! bSkipSwap)
|
vtNmi = - Z_AX ;
|
||||||
vtNmi = - Z_AX ;
|
|
||||||
}
|
}
|
||||||
if ( dMax < m_dMinZ[nGrid]) {
|
if ( dMax < m_dMinZ[nGrid]) {
|
||||||
dMax = m_dMinZ[nGrid] ;
|
dMax = m_dMinZ[nGrid] ;
|
||||||
if ( ! bSkipSwap)
|
vtNma = Z_AX ;
|
||||||
vtNma = Z_AX ;
|
|
||||||
}
|
}
|
||||||
else if ( dMax > m_dMaxZ[nGrid]) {
|
else if ( dMax > m_dMaxZ[nGrid]) {
|
||||||
dMax = m_dMaxZ[nGrid] ;
|
dMax = m_dMaxZ[nGrid] ;
|
||||||
if ( ! bSkipSwap)
|
vtNma = Z_AX ;
|
||||||
vtNma = Z_AX ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controllo che dMin e dMax non siano quasi coincidenti
|
// Controllo che dMin e dMax non siano quasi coincidenti
|
||||||
if ( abs( dMax - dMin) < EPS_SMALL)
|
if ( abs( dMax - dMin) < EPS_SMALL)
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
// Riporto le coordinate cicliche nell'ordine di partenza
|
// Riporto le coordinate cicliche nell'ordine di partenza
|
||||||
if ( !bSkipSwap && nGrid == 1) {
|
if ( nGrid == 1) {
|
||||||
swap( vtNmi.x, vtNmi.z) ;
|
swap( vtNmi.x, vtNmi.z) ;
|
||||||
swap( vtNmi.y, vtNmi.z) ;
|
swap( vtNmi.y, vtNmi.z) ;
|
||||||
swap( vtNma.x, vtNma.z) ;
|
swap( vtNma.x, vtNma.z) ;
|
||||||
swap( vtNma.y, vtNma.z) ;
|
swap( vtNma.y, vtNma.z) ;
|
||||||
}
|
}
|
||||||
else if ( !bSkipSwap && nGrid == 2) {
|
else if ( nGrid == 2) {
|
||||||
swap( vtNmi.y, vtNmi.z) ;
|
swap( vtNmi.y, vtNmi.z) ;
|
||||||
swap( vtNmi.x, vtNmi.z) ;
|
swap( vtNmi.x, vtNmi.z) ;
|
||||||
swap( vtNma.y, vtNma.z) ;
|
swap( vtNma.y, vtNma.z) ;
|
||||||
@@ -312,13 +306,13 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcolo nPos
|
// Calcolo nPos
|
||||||
int nPos = nJ * m_nNx[nGrid] + nI ;
|
unsigned int nPos = nJ * m_nNx[nGrid] + nI ;
|
||||||
vector<Data>& vDexel = m_Values[nGrid][nPos] ;
|
vector<Data>& vDexel = m_Values[nGrid][nPos] ;
|
||||||
|
|
||||||
bool bModified = false ;
|
bool bModified = false ;
|
||||||
|
|
||||||
// Non esistono segmenti
|
// Non esistono segmenti
|
||||||
if ( vDexel.empty()) {
|
if ( int( vDexel.size()) == 0) {
|
||||||
|
|
||||||
vDexel.emplace_back() ;
|
vDexel.emplace_back() ;
|
||||||
vDexel.back().dMin = dMin ;
|
vDexel.back().dMin = dMin ;
|
||||||
@@ -332,10 +326,10 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
|
|
||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
// Esiste almeno un segmento
|
// Esiste almeno un segmento
|
||||||
else {
|
else {
|
||||||
// Cerco l'ultimo intervallo a sinistra e l'ultimo intervallo a destra
|
// Cerco l'ultimo intervallo a sinistra e l'ultimo intervallo a destra
|
||||||
// di quello da aggiungere, che non interferiscono con quest'ultimo.
|
// di quello da aggiungere, che non interferiscono con quest'ultimo.
|
||||||
auto itLastLeft = vDexel.end() ;
|
auto itLastLeft = vDexel.end() ;
|
||||||
auto itFirstRight = vDexel.end() ;
|
auto itFirstRight = vDexel.end() ;
|
||||||
for ( auto it = vDexel.begin() ; it != vDexel.end() ; ++ it) {
|
for ( auto it = vDexel.begin() ; it != vDexel.end() ; ++ it) {
|
||||||
@@ -344,12 +338,12 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
if ( dMax < it->dMin - EPS_SMALL && itFirstRight == vDexel.end())
|
if ( dMax < it->dMin - EPS_SMALL && itFirstRight == vDexel.end())
|
||||||
itFirstRight = it ;
|
itFirstRight = it ;
|
||||||
}
|
}
|
||||||
// Esistono intervalli a sinistra.
|
// Esistono intervalli a sinistra.
|
||||||
if ( itLastLeft != vDexel.end()) {
|
if ( itLastLeft != vDexel.end()) {
|
||||||
// Intervallo successivo all'ultimo a sinistra
|
// Intervallo successivo all'ultimo a sinistra
|
||||||
auto itNextToLastLeft = itLastLeft ;
|
auto itNextToLastLeft = itLastLeft ;
|
||||||
++ itNextToLastLeft ;
|
++ itNextToLastLeft ;
|
||||||
// Il successivo non esiste.
|
// Il successivo non esiste.
|
||||||
if ( itNextToLastLeft == vDexel.end()) {
|
if ( itNextToLastLeft == vDexel.end()) {
|
||||||
// Aggiungo il nuovo semgento
|
// Aggiungo il nuovo semgento
|
||||||
vDexel.emplace_back() ;
|
vDexel.emplace_back() ;
|
||||||
@@ -362,11 +356,11 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
//m_Values[nGrid][nPos].back().nCompo = ;
|
//m_Values[nGrid][nPos].back().nCompo = ;
|
||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
// Il successivo esiste.
|
// Il successivo esiste.
|
||||||
else {
|
else {
|
||||||
// Il successivo è il primo a destra.
|
// Il successivo è il primo a destra.
|
||||||
if ( itNextToLastLeft == itFirstRight) {
|
if ( itNextToLastLeft == itFirstRight) {
|
||||||
// Inserisco nuovo segmento-
|
// Inserisco nuovo segmento-
|
||||||
Data NewSegment ;
|
Data NewSegment ;
|
||||||
NewSegment.dMin = dMin ;
|
NewSegment.dMin = dMin ;
|
||||||
NewSegment.dMax = dMax ;
|
NewSegment.dMax = dMax ;
|
||||||
@@ -379,18 +373,18 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Il successivo non esce a sinistra da quello da aggiungere.
|
// Il successivo non esce a sinistra da quello da aggiungere.
|
||||||
if ( itNextToLastLeft->dMin > dMin + EPS_SMALL) {
|
if ( itNextToLastLeft->dMin > dMin + EPS_SMALL) {
|
||||||
itNextToLastLeft->dMin = dMin ;
|
itNextToLastLeft->dMin = dMin ;
|
||||||
itNextToLastLeft->vtMinN = vtNmi ;
|
itNextToLastLeft->vtMinN = vtNmi ;
|
||||||
itNextToLastLeft->nToolMin = nToolNum ;
|
itNextToLastLeft->nToolMin = nToolNum ;
|
||||||
}
|
}
|
||||||
// Cerco l'ultimo segmento che interferisce con quello da aggiungere.
|
// Cerco l'ultimo segmento che interferisce con quello da aggiungere.
|
||||||
auto itPrevToFirstRight = vDexel.end() ;
|
auto itPrevToFirstRight = vDexel.end() ;
|
||||||
for ( auto it = itNextToLastLeft ; it != itFirstRight ; ++ it) {
|
for ( auto it = itNextToLastLeft ; it != itFirstRight ; ++ it) {
|
||||||
itPrevToFirstRight = it ;
|
itPrevToFirstRight = it ;
|
||||||
}
|
}
|
||||||
// L'ultimo che interferisce non esce a destra da quello da aggiungere.
|
// L'ultimo che interferisce non esce a destra da quello da aggiungere.
|
||||||
if ( itPrevToFirstRight->dMax < dMax - EPS_SMALL) {
|
if ( itPrevToFirstRight->dMax < dMax - EPS_SMALL) {
|
||||||
itNextToLastLeft->dMax = dMax ;
|
itNextToLastLeft->dMax = dMax ;
|
||||||
itNextToLastLeft->vtMaxN = vtNma ;
|
itNextToLastLeft->vtMaxN = vtNma ;
|
||||||
@@ -409,18 +403,18 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Non esistono neanche a destra.
|
// Non esistono neanche a destra.
|
||||||
else if ( itFirstRight == m_Values[nGrid][nPos].end()) {
|
else if ( itFirstRight == m_Values[nGrid][nPos].end()) {
|
||||||
// Il primo intervallo non sporge a sinistra
|
// Il primo intervallo non sporge a sinistra
|
||||||
if ( vDexel.begin()->dMin > dMin + EPS_SMALL) {
|
if ( vDexel.begin()->dMin > dMin + EPS_SMALL) {
|
||||||
vDexel.begin()->dMin = dMin ;
|
vDexel.begin()->dMin = dMin ;
|
||||||
vDexel.begin()->vtMinN = vtNmi ;
|
vDexel.begin()->vtMinN = vtNmi ;
|
||||||
vDexel.begin()->nToolMin = nToolNum ;
|
vDexel.begin()->nToolMin = nToolNum ;
|
||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
// L'ultimo intervallo sporge a destra.
|
// L'ultimo intervallo sporge a destra.
|
||||||
if ( m_Values[nGrid][nPos].back().dMax > dMax + EPS_SMALL) {
|
if ( m_Values[nGrid][nPos].back().dMax > dMax + EPS_SMALL) {
|
||||||
// Ci sono più segmenti, inglobo tutti nel primo.
|
// Ci sono più segmenti, inglobo tutti nel primo.
|
||||||
if ( vDexel.back().dMax > vDexel.begin()->dMax + EPS_SMALL) {
|
if ( vDexel.back().dMax > vDexel.begin()->dMax + EPS_SMALL) {
|
||||||
vDexel.begin()->dMax = vDexel.back().dMax ;
|
vDexel.begin()->dMax = vDexel.back().dMax ;
|
||||||
vDexel.begin()->vtMaxN = vDexel.back().vtMaxN ;
|
vDexel.begin()->vtMaxN = vDexel.back().vtMaxN ;
|
||||||
@@ -428,7 +422,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// L'ultimo intervallo non sporge a destra.
|
// L'ultimo intervallo non sporge a destra.
|
||||||
else {
|
else {
|
||||||
vDexel.begin()->dMax = dMax ;
|
vDexel.begin()->dMax = dMax ;
|
||||||
vDexel.begin()->vtMaxN = vtNma ;
|
vDexel.begin()->vtMaxN = vtNma ;
|
||||||
@@ -437,11 +431,11 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
vDexel.erase( vDexel.begin() + 1, vDexel.end()) ;
|
vDexel.erase( vDexel.begin() + 1, vDexel.end()) ;
|
||||||
}
|
}
|
||||||
// A destra esistono.
|
// A destra esistono.
|
||||||
else {
|
else {
|
||||||
// Tutti i segmenti sono a destra di qullo da aggiungere.
|
// Tutti i segmenti sono a destra di qullo da aggiungere.
|
||||||
if ( itFirstRight == vDexel.begin()) {
|
if ( itFirstRight == vDexel.begin()) {
|
||||||
// Inserisco nuovo segmento-
|
// Inserisco nuovo segmento-
|
||||||
Data NewSegment ;
|
Data NewSegment ;
|
||||||
NewSegment.dMin = dMin ;
|
NewSegment.dMin = dMin ;
|
||||||
NewSegment.dMax = dMax ;
|
NewSegment.dMax = dMax ;
|
||||||
@@ -453,19 +447,19 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Se il primo segmento non esce a sinistra da quello da aggiungere, cambio l'inizio.
|
// Se il primo segmento non esce a sinistra da quello da aggiungere, cambio l'inizio.
|
||||||
if ( vDexel.begin()->dMin > dMin + EPS_SMALL) {
|
if ( vDexel.begin()->dMin > dMin + EPS_SMALL) {
|
||||||
vDexel.begin()->dMin = dMin ;
|
vDexel.begin()->dMin = dMin ;
|
||||||
vDexel.begin()->vtMinN = vtNmi ;
|
vDexel.begin()->vtMinN = vtNmi ;
|
||||||
vDexel.begin()->nToolMin = nToolNum ;
|
vDexel.begin()->nToolMin = nToolNum ;
|
||||||
bModified = true ;
|
bModified = true ;
|
||||||
}
|
}
|
||||||
// Cerco l'ultimo segmento che interferisce con quello da aggiungere.
|
// Cerco l'ultimo segmento che interferisce con quello da aggiungere.
|
||||||
auto itPrevToFirstRight = vDexel.begin() ;
|
auto itPrevToFirstRight = vDexel.begin() ;
|
||||||
for ( auto it = m_Values[nGrid][nPos].begin() ; it != itFirstRight ; ++ it) {
|
for ( auto it = m_Values[nGrid][nPos].begin() ; it != itFirstRight ; ++ it) {
|
||||||
itPrevToFirstRight = it ;
|
itPrevToFirstRight = it ;
|
||||||
}
|
}
|
||||||
// L'ultimo che interferisce non esce a destra da quello da aggiungere.
|
// L'ultimo che interferisce non esce a destra da quello da aggiungere.
|
||||||
if ( itPrevToFirstRight->dMax < dMax - EPS_SMALL) {
|
if ( itPrevToFirstRight->dMax < dMax - EPS_SMALL) {
|
||||||
vDexel.begin()->dMax = dMax ;
|
vDexel.begin()->dMax = dMax ;
|
||||||
vDexel.begin()->vtMaxN = vtNma ;
|
vDexel.begin()->vtMaxN = vtNma ;
|
||||||
@@ -485,24 +479,24 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Se nessuna modifica, esco
|
// Se nessuna modifica, esco
|
||||||
if ( ! bModified)
|
if ( ! bModified)
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
// Imposto ricalcolo della grafica
|
// Imposto ricalcolo della grafica
|
||||||
m_OGrMgr.Reset() ;
|
m_OGrMgr.Reset() ;
|
||||||
// Imposto forma generica
|
// Imposto forma generica
|
||||||
m_nShape = GENERIC ;
|
m_nShape = GENERIC ;
|
||||||
// Imposto ricalcolo numero di componenti connesse
|
// Imposto ricalcolo numero di componenti connesse
|
||||||
m_nConnectedCompoCount = - 1 ;
|
m_nConnectedCompoCount = - 1 ;
|
||||||
|
|
||||||
// Passo da indici di dexel a indici di voxel
|
// Passo da indici di dexel a indici di voxel
|
||||||
nI /= m_nDexVoxRatio ;
|
nI /= m_nDexVoxRatio ;
|
||||||
nJ /= m_nDexVoxRatio ;
|
nJ /= m_nDexVoxRatio ;
|
||||||
|
|
||||||
// Determino quali blocchi sono stati modificati
|
// Determino quali blocchi sono stati modificati
|
||||||
if ( nGrid == 0) {
|
if ( nGrid == 0) {
|
||||||
// Voxel lungo X
|
// Voxel lungo X
|
||||||
int nXStop = 1 ;
|
int nXStop = 1 ;
|
||||||
int nXBlock[2] ;
|
int nXBlock[2] ;
|
||||||
nXBlock[0] = min( nI / m_nVoxNumPerBlock, m_nFracLin[0] - 1) ;
|
nXBlock[0] = min( nI / m_nVoxNumPerBlock, m_nFracLin[0] - 1) ;
|
||||||
@@ -510,7 +504,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
nXBlock[1] = nXBlock[0] - 1 ;
|
nXBlock[1] = nXBlock[0] - 1 ;
|
||||||
++ nXStop ;
|
++ nXStop ;
|
||||||
}
|
}
|
||||||
// Voxel lungo Y
|
// Voxel lungo Y
|
||||||
int nYStop = 1 ;
|
int nYStop = 1 ;
|
||||||
int nYBlock[2] ;
|
int nYBlock[2] ;
|
||||||
nYBlock[0] = min( nJ / m_nVoxNumPerBlock, m_nFracLin[1] - 1) ;
|
nYBlock[0] = min( nJ / m_nVoxNumPerBlock, m_nFracLin[1] - 1) ;
|
||||||
@@ -518,13 +512,13 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
nYBlock[1] = nYBlock[0] - 1 ;
|
nYBlock[1] = nYBlock[0] - 1 ;
|
||||||
++ nYStop ;
|
++ nYStop ;
|
||||||
}
|
}
|
||||||
// Voxel lungo Z
|
// Voxel lungo Z
|
||||||
int nVoxNumZ = int( m_nNy[1] / m_nDexVoxRatio + ( m_nNy[1] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
int nVoxNumZ = int( m_nNy[1] / m_nDexVoxRatio + ( m_nNy[1] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
||||||
int nMinK = Clamp( int( floor( ( ( dMin - 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) - EPS_SMALL))), 0, nVoxNumZ - 2) ;
|
int nMinK = Clamp( int( floor( ( ( dMin - 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) - EPS_SMALL))), 0, nVoxNumZ - 2) ;
|
||||||
int nMaxK = Clamp( int( floor( ( ( dMax + 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) + EPS_SMALL))), 0, nVoxNumZ - 2) ;
|
int nMaxK = Clamp( int( floor( ( ( dMax + 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) + EPS_SMALL))), 0, nVoxNumZ - 2) ;
|
||||||
int nMinZBlock = ( m_nMapNum == 1 ? 0 : Clamp( nMinK / int( m_nVoxNumPerBlock), 0, int( m_nFracLin[2] - 1))) ;
|
int nMinZBlock = ( m_nMapNum == 1 ? 0 : Clamp( nMinK / int( m_nVoxNumPerBlock), 0, int( m_nFracLin[2] - 1))) ;
|
||||||
int nMaxZBlock = min( int( m_nFracLin[2] - 1), nMaxK / int( m_nVoxNumPerBlock)) ;
|
int nMaxZBlock = min( int( m_nFracLin[2] - 1), nMaxK / int( m_nVoxNumPerBlock)) ;
|
||||||
// Assegno flag ai voxel
|
// Assegno flag ai voxel
|
||||||
for ( int tI = 0 ; tI < nXStop ; ++ tI) {
|
for ( int tI = 0 ; tI < nXStop ; ++ tI) {
|
||||||
for ( int tJ = 0 ; tJ < nYStop ; ++ tJ) {
|
for ( int tJ = 0 ; tJ < nYStop ; ++ tJ) {
|
||||||
for ( int k = nMinZBlock ; k <= nMaxZBlock ; ++ k) {
|
for ( int k = nMinZBlock ; k <= nMaxZBlock ; ++ k) {
|
||||||
@@ -536,7 +530,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if ( nGrid == 1) {
|
else if ( nGrid == 1) {
|
||||||
// Voxel lungo Y
|
// Voxel lungo Y
|
||||||
int nYStop = 1 ;
|
int nYStop = 1 ;
|
||||||
int nYBlock[2] ;
|
int nYBlock[2] ;
|
||||||
nYBlock[0] = min( nI / m_nVoxNumPerBlock, m_nFracLin[1] - 1) ;
|
nYBlock[0] = min( nI / m_nVoxNumPerBlock, m_nFracLin[1] - 1) ;
|
||||||
@@ -544,7 +538,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
nYBlock[1] = nYBlock[0] - 1 ;
|
nYBlock[1] = nYBlock[0] - 1 ;
|
||||||
++ nYStop ;
|
++ nYStop ;
|
||||||
}
|
}
|
||||||
// Voxel lungo Z
|
// Voxel lungo Z
|
||||||
int nZStop = 1 ;
|
int nZStop = 1 ;
|
||||||
int nZBlock[2] ;
|
int nZBlock[2] ;
|
||||||
nZBlock[0] = min( nJ / m_nVoxNumPerBlock, m_nFracLin[2] - 1) ;
|
nZBlock[0] = min( nJ / m_nVoxNumPerBlock, m_nFracLin[2] - 1) ;
|
||||||
@@ -552,13 +546,13 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
nZBlock[1] = nZBlock[0] - 1 ;
|
nZBlock[1] = nZBlock[0] - 1 ;
|
||||||
++ nZStop ;
|
++ nZStop ;
|
||||||
}
|
}
|
||||||
// Voxel lungo X
|
// Voxel lungo X
|
||||||
int nVoxNumX = int( m_nNx[0] / m_nDexVoxRatio + ( m_nNx[0] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
int nVoxNumX = int( m_nNx[0] / m_nDexVoxRatio + ( m_nNx[0] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
||||||
int nMinI = Clamp( int( floor( ( ( dMin - 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) - EPS_SMALL))), 0, nVoxNumX - 2) ;
|
int nMinI = Clamp( int( floor( ( ( dMin - 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) - EPS_SMALL))), 0, nVoxNumX - 2) ;
|
||||||
int nMaxI = Clamp( int( floor( ( ( dMax + 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) + EPS_SMALL))), 0, nVoxNumX - 2) ;
|
int nMaxI = Clamp( int( floor( ( ( dMax + 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) + EPS_SMALL))), 0, nVoxNumX - 2) ;
|
||||||
int nMinXBlock = Clamp( nMinI / int( m_nVoxNumPerBlock), 0, int( m_nFracLin[0] - 1)) ;
|
int nMinXBlock = Clamp( nMinI / int( m_nVoxNumPerBlock), 0, int( m_nFracLin[0] - 1)) ;
|
||||||
int nMaxXBlock = min( int( m_nFracLin[0] - 1), nMaxI / int( m_nVoxNumPerBlock)) ;
|
int nMaxXBlock = min( int( m_nFracLin[0] - 1), nMaxI / int( m_nVoxNumPerBlock)) ;
|
||||||
// Assegno flag ai voxel
|
// Assegno flag ai voxel
|
||||||
for ( int tI = 0 ; tI < nYStop ; ++ tI) {
|
for ( int tI = 0 ; tI < nYStop ; ++ tI) {
|
||||||
for ( int tJ = 0 ; tJ < nZStop ; ++ tJ) {
|
for ( int tJ = 0 ; tJ < nZStop ; ++ tJ) {
|
||||||
for ( int k = nMinXBlock ; k <= nMaxXBlock ; ++ k) {
|
for ( int k = nMinXBlock ; k <= nMaxXBlock ; ++ k) {
|
||||||
@@ -570,7 +564,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if ( nGrid == 2) {
|
else if ( nGrid == 2) {
|
||||||
// Voxel lungo X
|
// Voxel lungo X
|
||||||
int nXStop = 1 ;
|
int nXStop = 1 ;
|
||||||
int nXBlock[2] ;
|
int nXBlock[2] ;
|
||||||
nXBlock[0] = min( nJ / m_nVoxNumPerBlock, m_nFracLin[0] - 1) ;
|
nXBlock[0] = min( nJ / m_nVoxNumPerBlock, m_nFracLin[0] - 1) ;
|
||||||
@@ -578,7 +572,7 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
nXBlock[1] = nXBlock[0] - 1 ;
|
nXBlock[1] = nXBlock[0] - 1 ;
|
||||||
++ nXStop ;
|
++ nXStop ;
|
||||||
}
|
}
|
||||||
// Voxel lungo Z
|
// Voxel lungo Z
|
||||||
int nZStop = 1 ;
|
int nZStop = 1 ;
|
||||||
int nZBlock[2] ;
|
int nZBlock[2] ;
|
||||||
nZBlock[0] = min( nI / m_nVoxNumPerBlock, m_nFracLin[2] - 1) ;
|
nZBlock[0] = min( nI / m_nVoxNumPerBlock, m_nFracLin[2] - 1) ;
|
||||||
@@ -586,13 +580,13 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
nZBlock[1] = nZBlock[0] - 1 ;
|
nZBlock[1] = nZBlock[0] - 1 ;
|
||||||
++ nZStop ;
|
++ nZStop ;
|
||||||
}
|
}
|
||||||
// Voxel lungo Y
|
// Voxel lungo Y
|
||||||
int nVoxNumY = int( m_nNy[0] / m_nDexVoxRatio + ( m_nNy[0] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
int nVoxNumY = int( m_nNy[0] / m_nDexVoxRatio + ( m_nNy[0] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
||||||
int nMinJ = Clamp( int( floor( ( ( dMin - 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) - EPS_SMALL))), 0, nVoxNumY - 2) ;
|
int nMinJ = Clamp( int( floor( ( ( dMin - 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) - EPS_SMALL))), 0, nVoxNumY - 2) ;
|
||||||
int nMaxJ = Clamp( int( floor( ( ( dMax + 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) + EPS_SMALL))), 0, nVoxNumY - 2) ;
|
int nMaxJ = Clamp( int( floor( ( ( dMax + 0.5 * m_dStep) / ( m_nDexVoxRatio * m_dStep) + EPS_SMALL))), 0, nVoxNumY - 2) ;
|
||||||
int nMinYBlock = Clamp( nMinJ / int( m_nVoxNumPerBlock), 0, int( m_nFracLin[1] - 1)) ;
|
int nMinYBlock = Clamp( nMinJ / int( m_nVoxNumPerBlock), 0, int( m_nFracLin[1] - 1)) ;
|
||||||
int nMaxYBlock = min( int( m_nFracLin[1] - 1), nMaxJ / int( m_nVoxNumPerBlock)) ;
|
int nMaxYBlock = min( int( m_nFracLin[1] - 1), nMaxJ / int( m_nVoxNumPerBlock)) ;
|
||||||
// Assegno flag ai voxel
|
// Assegno flag ai voxel
|
||||||
for ( int tI = 0 ; tI < nZStop ; ++ tI) {
|
for ( int tI = 0 ; tI < nZStop ; ++ tI) {
|
||||||
for ( int tJ = 0 ; tJ < nXStop ; ++ tJ) {
|
for ( int tJ = 0 ; tJ < nXStop ; ++ tJ) {
|
||||||
for ( int k = nMinYBlock ; k <= nMaxYBlock ; ++ k) {
|
for ( int k = nMinYBlock ; k <= nMaxYBlock ; ++ k) {
|
||||||
@@ -606,213 +600,6 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ,
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
VolZmap::AddSubIntervalInVoxel( VolZmap* VolZmapRef, int nGrid, int nI, int nJ, int nK,
|
|
||||||
double& dMin, double& dMax, Vector3d& vtMin, Vector3d& vtMax)
|
|
||||||
{
|
|
||||||
// se non Tridex, esco
|
|
||||||
if ( ! IsTriDexel())
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
// Controllo che il numero di griglia sia entro i limiti
|
|
||||||
if ( nGrid < 0 || nGrid > 2)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Controllo che indici nI, nJ siano entro i limiti
|
|
||||||
if ( nI < 0 && nI >= m_nNx[nGrid] &&
|
|
||||||
nJ < 0 && nJ >= m_nNy[nGrid])
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// valori di default
|
|
||||||
vector<double> vTdMin = { -1., -1., -1., -1.} ;
|
|
||||||
vector<double> vTdMax = { -1., -1., -1., -1.} ;
|
|
||||||
VCT3DVECTOR vtNMin = { V_INVALID, V_INVALID, V_INVALID, V_INVALID} ;
|
|
||||||
VCT3DVECTOR vtNMax = { V_INVALID, V_INVALID, V_INVALID, V_INVALID} ;
|
|
||||||
|
|
||||||
// se esiste un precedente lungo x-locale
|
|
||||||
if ( nI != 0) {
|
|
||||||
int nPos = nJ * m_nNx[nGrid] + ( nI - 1) ; // recupero posizione dexel
|
|
||||||
// cerco l'intervallo corretto sullo Zmap di riferimento
|
|
||||||
for ( int it = 0 ; it < int( VolZmapRef->m_Values[nGrid][nPos].size()) ; ++ it) {
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMax + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMax - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMax[0] = VolZmapRef->m_Values[nGrid][nPos][it].vtMaxN ;
|
|
||||||
vTdMax[0] = VolZmapRef->m_Values[nGrid][nPos][it].dMax ;
|
|
||||||
}
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMin + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMin - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMin[0] = VolZmapRef->m_Values[nGrid][nPos][it].vtMinN ;
|
|
||||||
vTdMin[0] = VolZmapRef->m_Values[nGrid][nPos][it].dMin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// se esiste il successivo lungo x-locale
|
|
||||||
if ( nI != m_dMaxZ[( nGrid + 2) % 3]) {
|
|
||||||
int nPos = nJ * m_nNx[nGrid] + ( nI + 1) ; // recupero posizione dexel
|
|
||||||
for ( int it = 0 ; it < int( VolZmapRef->m_Values[nGrid][nPos].size()) ; ++ it) {
|
|
||||||
// cerco l'intervallo corretto sullo Zmap di riferimento
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMax + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMax - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMax[1] = VolZmapRef->m_Values[nGrid][nPos][it].vtMaxN ;
|
|
||||||
vTdMax[1] = VolZmapRef->m_Values[nGrid][nPos][it].dMax ;
|
|
||||||
}
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMin + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMin - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMin[1] = VolZmapRef->m_Values[nGrid][nPos][it].vtMinN ;
|
|
||||||
vTdMin[1] = VolZmapRef->m_Values[nGrid][nPos][it].dMin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// se esiste il precedente lungo y-locale
|
|
||||||
if ( nJ != 0) {
|
|
||||||
int nPos = ( nJ - 1) * m_nNx[nGrid] + nI ; // recupero posizione dexel
|
|
||||||
for ( int it = 0 ; it < int( VolZmapRef->m_Values[nGrid][nPos].size()) ; ++ it) {
|
|
||||||
// cerco l'intervallo corretto sullo Zmap di riferimento
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMax + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMax - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMax[2] = VolZmapRef->m_Values[nGrid][nPos][it].vtMaxN ;
|
|
||||||
vTdMax[2] = VolZmapRef->m_Values[nGrid][nPos][it].dMax ;
|
|
||||||
}
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMin + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMin - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMin[2] = VolZmapRef->m_Values[nGrid][nPos][it].vtMinN ;
|
|
||||||
vTdMin[2] = VolZmapRef->m_Values[nGrid][nPos][it].dMin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// se esiste il successivo lungo y-locale
|
|
||||||
if ( nJ != m_dMaxZ[( nGrid + 1) % 3]) {
|
|
||||||
int nPos = ( nJ + 1) * m_nNx[nGrid] + nI ; // recupero posizione dexel
|
|
||||||
// cerco l'intervallo corretto sullo Zmap di riferimento
|
|
||||||
for ( int it = 0 ; it < int( VolZmapRef->m_Values[nGrid][nPos].size()) ; ++ it) {
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMax + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMax - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMax[3] = VolZmapRef->m_Values[nGrid][nPos][it].vtMaxN ;
|
|
||||||
vTdMax[3] = VolZmapRef->m_Values[nGrid][nPos][it].dMax ;
|
|
||||||
}
|
|
||||||
if ( VolZmapRef->m_Values[nGrid][nPos][it].dMin + EPS_SMALL > nK * m_dStep &&
|
|
||||||
VolZmapRef->m_Values[nGrid][nPos][it].dMin - EPS_SMALL < ( nK + 1) * m_dStep) {
|
|
||||||
vtNMin[3] = VolZmapRef->m_Values[nGrid][nPos][it].vtMinN ;
|
|
||||||
vTdMin[3] = VolZmapRef->m_Values[nGrid][nPos][it].dMin ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// scelgo le normali che si discostano il meno possibile dalla normale della faccia del voxel
|
|
||||||
|
|
||||||
// analisi dei massimi e delle normali ---------------------------
|
|
||||||
// 1) angolo minimo tra la normale trovata la faccia del voxel
|
|
||||||
double dMinAngle = ANG_FULL ;
|
|
||||||
// 2) vettore di riferimento per la direzione della normale
|
|
||||||
vtMax = ( nGrid == 0 ? m_MapFrame.VersZ() :
|
|
||||||
( nGrid == 1 ? m_MapFrame.VersX() : m_MapFrame.VersY())) ;
|
|
||||||
Vector3d vtRef = vtMax ;
|
|
||||||
// 3) determino il massimo per questo intervallo
|
|
||||||
dMax = ( nK + 1) * m_dStep ;
|
|
||||||
for ( int i = 0 ; i < 4 ; ++ i) { // scorro le normali
|
|
||||||
if ( vtNMax[i].IsValid()) { // se normale trovata, quindi valida...
|
|
||||||
double dCurrAngle ; // angolo corrente tra la normale della TriMesh e quella della faccia del voxel
|
|
||||||
vtNMax[i].GetAngle( vtRef, dCurrAngle) ;
|
|
||||||
if ( abs( dCurrAngle) < dMinAngle) { // se angolo minore del minimo trovato...
|
|
||||||
// aggiorno i parametri
|
|
||||||
dMinAngle = dCurrAngle ;
|
|
||||||
vtMax = vtNMax[i] ;
|
|
||||||
dMax = vTdMax[i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// analisi dei minimi e delle normali ---------------------------
|
|
||||||
dMinAngle = ANG_FULL ;
|
|
||||||
vtRef.Invert() ;
|
|
||||||
dMin = nK * m_dStep ;
|
|
||||||
vtMin = vtRef ;
|
|
||||||
for ( int i = 0 ; i < 4 ; ++ i) {
|
|
||||||
if ( vtNMin[i].IsValid()) {
|
|
||||||
double dCurrAngle ;
|
|
||||||
vtNMin[i].GetAngle( vtRef, dCurrAngle) ;
|
|
||||||
if ( abs( dCurrAngle) < dMinAngle) {
|
|
||||||
dMinAngle = dCurrAngle ;
|
|
||||||
vtMin = vtNMin[i] ;
|
|
||||||
dMin = vTdMin[i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
VolZmap::AddMissingIntervalsInVoxel( VolZmap* VolZmapRef, int nGrid, int nI, int nJ, double dZ, double dToler,
|
|
||||||
Vector3d vtToolMin, Vector3d vtToolMax, int nToolNum)
|
|
||||||
{
|
|
||||||
|
|
||||||
// se non Tridex, esco
|
|
||||||
if ( ! IsTriDexel())
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
// Controllo che il numero di griglia sia entro i limiti
|
|
||||||
if ( nGrid < 0 || nGrid > 2)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Controllo che indici nI, nJ siano entro i limiti
|
|
||||||
if ( nI < 0 && nI >= m_nNx[nGrid] &&
|
|
||||||
nJ < 0 && nJ >= m_nNy[nGrid])
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// passo da indici di dexel a indici di voxel
|
|
||||||
nI /= m_nDexVoxRatio ;
|
|
||||||
nJ /= m_nDexVoxRatio ;
|
|
||||||
|
|
||||||
// numero di voxel nel dexel corrente
|
|
||||||
int nVoxNum = int( m_nNy[(( nGrid+1) % 3)] / m_nDexVoxRatio +
|
|
||||||
( m_nNy[(( nGrid+1) % 3)] % m_nDexVoxRatio == 0 ? 1 : 2)) ;
|
|
||||||
|
|
||||||
int nK = 0 ;
|
|
||||||
for ( int i = 0 ; i < nVoxNum ; ++ i) {
|
|
||||||
// controllo se sono nel voxel corrente
|
|
||||||
if ( i * m_dStep < dZ && ( i + 1) * m_dStep > dZ) {
|
|
||||||
nK = i ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------- griglia successiva -----------
|
|
||||||
{
|
|
||||||
int nMyGrid = ( nGrid + 1) % 3 ;
|
|
||||||
int nMyI = nJ ;
|
|
||||||
int nMyJ = nK ;
|
|
||||||
int nMyK = nI ;
|
|
||||||
double dMyMin ;
|
|
||||||
double dMyMax ;
|
|
||||||
Vector3d vtMyMin ;
|
|
||||||
Vector3d vtMyMax ;
|
|
||||||
AddSubIntervalInVoxel( VolZmapRef, nMyGrid, nMyI, nMyJ, nMyK, dMyMin, dMyMax, vtMyMin, vtMyMax) ;
|
|
||||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMin - EPS_SMALL, dMyMax + EPS_SMALL, vtMyMin, vtMyMax,
|
|
||||||
nToolNum, true) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------- griglia precedente -----------
|
|
||||||
{
|
|
||||||
int nMyGrid = ( nGrid + 2) % 3 ;
|
|
||||||
int nMyI = nK ;
|
|
||||||
int nMyJ = nI ;
|
|
||||||
int nMyK = nJ ;
|
|
||||||
double dMyMin ;
|
|
||||||
double dMyMax ;
|
|
||||||
Vector3d vtMyMin ;
|
|
||||||
Vector3d vtMyMax ;
|
|
||||||
AddSubIntervalInVoxel( VolZmapRef, nMyGrid, nMyI, nMyJ, nMyK, dMyMin, dMyMax, vtMyMin, vtMyMax) ;
|
|
||||||
AddIntervals( nMyGrid, nMyI, nMyJ, dMyMin - EPS_SMALL, dMyMax + EPS_SMALL, vtMyMin, vtMyMax,
|
|
||||||
nToolNum, true) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------- LAVORAZIONI --------------------------------------------------------------------------------------
|
// ------------------------- LAVORAZIONI --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -851,6 +638,9 @@ VolZmap::MillingStep( int nCurrTool,
|
|||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset numero di parti
|
||||||
|
m_nConnectedCompoCount = - 1 ;
|
||||||
|
|
||||||
// Punti e vettori descriventi il moto nel sistema intrinseco dello Zmap
|
// Punti e vettori descriventi il moto nel sistema intrinseco dello Zmap
|
||||||
Point3d ptPLs = GetToLoc( ptPs, m_MapFrame) ;
|
Point3d ptPLs = GetToLoc( ptPs, m_MapFrame) ;
|
||||||
Point3d ptPLe = GetToLoc( ptPe, m_MapFrame) ;
|
Point3d ptPLe = GetToLoc( ptPe, m_MapFrame) ;
|
||||||
@@ -892,7 +682,7 @@ VolZmap::MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, co
|
|||||||
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe)
|
const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe)
|
||||||
{
|
{
|
||||||
// Divido il movimento in tratti con direzione utensile costante
|
// Divido il movimento in tratti con direzione utensile costante
|
||||||
const double ANG_STEP = 0.04 ;
|
const double ANG_STEP = 0.02 ;
|
||||||
double dAngDeg ; vtDs.GetAngle( vtDe, dAngDeg) ;
|
double dAngDeg ; vtDs.GetAngle( vtDe, dAngDeg) ;
|
||||||
int nStepCnt = int( abs( dAngDeg) / ANG_STEP) + 1 ;
|
int nStepCnt = int( abs( dAngDeg) / ANG_STEP) + 1 ;
|
||||||
bool bOk = true ;
|
bool bOk = true ;
|
||||||
@@ -1047,8 +837,6 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
|||||||
return Conus_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
return Conus_ZMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||||
case Tool::MORTISER :
|
case Tool::MORTISER :
|
||||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||||
case Tool::ADDITIVE :
|
|
||||||
return AddingMotion( nGrid, ptLs, ptLe, vtL) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1111,8 +899,6 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
|||||||
return Conus_XYMilling( nGrid, ptLs, ptLe, vtL) ;
|
return Conus_XYMilling( nGrid, ptLs, ptLe, vtL) ;
|
||||||
case Tool::MORTISER :
|
case Tool::MORTISER :
|
||||||
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
return Mrt_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||||
case Tool::ADDITIVE :
|
|
||||||
return AddingMotion( nGrid, ptLs, ptLe, vtL) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1159,8 +945,6 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons
|
|||||||
if ( dSqLLong < EPS_SMALL * EPS_SMALL)
|
if ( dSqLLong < EPS_SMALL * EPS_SMALL)
|
||||||
return Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
return Chs_Milling( nGrid, ptLs, ptLe, vtL, vtAL) ;
|
||||||
break ;
|
break ;
|
||||||
case Tool::ADDITIVE :
|
|
||||||
return AddingMotion( nGrid, ptLs, ptLe, vtL) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5090,7 +4874,7 @@ VolZmap::CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ,
|
|||||||
|
|
||||||
// ---------- SFERA ----------------------------------------------------------
|
// ---------- SFERA ----------------------------------------------------------
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//---------------------------------------------------------------------------- pizza
|
||||||
bool
|
bool
|
||||||
VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dRad, int nToolNum)
|
VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dRad, int nToolNum)
|
||||||
{
|
{
|
||||||
@@ -5158,27 +4942,29 @@ VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe,
|
|||||||
bool
|
bool
|
||||||
VolZmap::AddingMotion( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtAx)
|
VolZmap::AddingMotion( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtAx)
|
||||||
{
|
{
|
||||||
// Dimensioni lineari dell'utensile
|
// Dimensioni lineari dell'utensile
|
||||||
double dHei = m_vTool[m_nCurrTool].GetHeigth() ;
|
double dHei = m_vTool[m_nCurrTool].GetHeigth() ;
|
||||||
double dRad = m_vTool[m_nCurrTool].GetRadius() ;
|
double dRad = m_vTool[m_nCurrTool].GetRadius() ;
|
||||||
double dCornerRad = m_vTool[m_nCurrTool].GetCornRadius() ;
|
double dCornerRad = m_vTool[m_nCurrTool].GetCornRadius() ;
|
||||||
|
|
||||||
// Utensile sfiancato
|
// Utensile sfiancato
|
||||||
if ( dCornerRad * dCornerRad - 0.25 * dHei * dHei > 0) {
|
if ( dCornerRad * dCornerRad - 0.25 * dHei * dHei > 0) {
|
||||||
return AddingGeneral( nGrid, ptS, ptE, vtAx) ;
|
AddingGeneral( nGrid, ptS, ptE, vtAx) ;
|
||||||
}
|
}
|
||||||
// Utensile sferico
|
// Utensile sferico
|
||||||
else if ( dRad - dCornerRad < EPS_SMALL) {
|
else if ( dRad - dCornerRad < EPS_SMALL) {
|
||||||
return AddingSphere( nGrid, ptS - dRad * vtAx, ptE - dRad * vtAx, dRad) ;
|
AddingSphere( nGrid, ptS - dRad * vtAx, ptE - dRad * vtAx, dRad) ;
|
||||||
}
|
}
|
||||||
// Utensile cilindro
|
// Utensile cilindro
|
||||||
else if ( dCornerRad < EPS_SMALL) {
|
else if ( dCornerRad < EPS_SMALL) {
|
||||||
return AddingCylinder( nGrid, ptS, ptE, vtAx, dHei, dRad) ;
|
AddingCylinder( nGrid, ptS, ptE, vtAx, dHei, dRad) ;
|
||||||
}
|
}
|
||||||
// Utensile naso di toro
|
// Utensile naso di toro
|
||||||
else {
|
else {
|
||||||
return AddingGeneral( nGrid, ptS, ptE, vtAx) ;
|
AddingGeneral( nGrid, ptS, ptE, vtAx) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -5278,37 +5064,57 @@ VolZmap::AddingCylinder( int nGrid, const Point3d& ptS, const Point3d& ptE, cons
|
|||||||
double dLen1 = vtV1.Len() ;
|
double dLen1 = vtV1.Len() ;
|
||||||
vtV1 /= dLen1 ;
|
vtV1 /= dLen1 ;
|
||||||
|
|
||||||
double dMyTol = 0 ;
|
if ( nGrid == 0) {
|
||||||
Frame3d CylFrame, PolyFrame ;
|
|
||||||
if ( ! CylFrame.Set( ptS - dHei * vtAx, vtAx))
|
|
||||||
return false ;
|
|
||||||
if ( ! PolyFrame.Set( ptS - ( dHei + dMyTol) * vtAx, vtAx, vtV1))
|
|
||||||
return false ;
|
|
||||||
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
|
||||||
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
|
||||||
|
|
||||||
Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ;
|
Vector3d vtV2 = Z_AX ^ vtV1 ;
|
||||||
|
|
||||||
Point3d ptInt1, ptInt2 ;
|
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||||
Vector3d vtN1, vtN2 ;
|
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||||
|
|
||||||
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, true, true,
|
Vector3d vtStC( ( i + 0.5) * m_dStep - ptS.x, ( j + 0.5) * m_dStep - ptS.y, 0) ;
|
||||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
Vector3d vtEnC = vtStC - dLen1 * vtV1 ;
|
||||||
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IntersLineCylinder( ptC - dLen1 * vtV1, Z_AX, CylFrame, dHei, dRad, true, true,
|
double dX1 = vtStC * vtV1 ;
|
||||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
double dX2 = vtStC * vtV2 ;
|
||||||
AddIntervals( nGrid, i, j, ptInt1.z + dLen1 * vtV1.z, ptInt2.z + dLen1 * vtV1.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( IntersLineMyPolyhedron( ptC, Z_AX, PolyFrame, dLen1, 2 * ( dRad + dMyTol), dHei + 2 * dMyTol, 0,
|
if ( ( dX1 > 0 && dX1 < dLen1 && abs( dX2) < dRad + EPS_SMALL) ||
|
||||||
ptInt1, vtN1, ptInt2, vtN2)) {
|
vtStC.SqLen() < dRad * dRad + 2 * dRad * EPS_SMALL ||
|
||||||
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
vtEnC.SqLen() < dRad * dRad + 2 * dRad * EPS_SMALL) {
|
||||||
|
AddIntervals( nGrid, i, j, ptS.z - dHei, ptS.z, - Z_AX, Z_AX, CurrTool.GetToolNum()) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
double dMyTol = 0 ;
|
||||||
|
Frame3d CylFrame, PolyFrame ;
|
||||||
|
CylFrame.Set( ptS - dHei * vtAx, vtAx) ;
|
||||||
|
PolyFrame.Set( ptS - ( dHei + dMyTol) * vtAx, vtV1, vtAx ^ vtV1, vtAx) ;
|
||||||
|
for ( int i = nStartI ; i <= nEndI ; ++ i) {
|
||||||
|
for ( int j = nStartJ ; j <= nEndJ ; ++ j) {
|
||||||
|
|
||||||
|
Point3d ptC( ( i + 0.5) * m_dStep, ( j + 0.5) * m_dStep, 0) ;
|
||||||
|
|
||||||
|
Point3d ptInt1, ptInt2 ;
|
||||||
|
Vector3d vtN1, vtN2 ;
|
||||||
|
|
||||||
|
if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, true, true,
|
||||||
|
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||||
|
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IntersLineCylinder( ptC - dLen1 * vtV1, Z_AX, CylFrame, dHei, dRad, true, true,
|
||||||
|
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||||
|
AddIntervals( nGrid, i, j, ptInt1.z + dLen1 * vtV1.z, ptInt2.z + dLen1 * vtV1.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( IntersLineMyPolyhedron( ptC, Z_AX, PolyFrame, dLen1, 2 * ( dRad + dMyTol), dHei + 2 * dMyTol, 0,
|
||||||
|
ptInt1, vtN1, ptInt2, vtN2)) {
|
||||||
|
AddIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, - vtN1, - vtN2, CurrTool.GetToolNum()) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5352,9 +5158,7 @@ VolZmap::AddingTruncatedCone( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
|||||||
Vector3d vtV3 = vtV1 ^ vtV2 ;
|
Vector3d vtV3 = vtV1 ^ vtV2 ;
|
||||||
|
|
||||||
// Sistema di riferimento intrinseco del movimento
|
// Sistema di riferimento intrinseco del movimento
|
||||||
Frame3d ConusFrame ;
|
Frame3d ConusFrame ; ConusFrame.Set( ptV, vtV2, vtV3, vtV1) ;
|
||||||
if ( ! ConusFrame.Set( ptV, vtV1, vtV2, vtV3))
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Dimensioni lineari movimento
|
// Dimensioni lineari movimento
|
||||||
double dLongLen = 0 ;
|
double dLongLen = 0 ;
|
||||||
@@ -5379,8 +5183,7 @@ VolZmap::AddingTruncatedCone( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
|||||||
// Sistema di riferimento poliedro
|
// Sistema di riferimento poliedro
|
||||||
Point3d ptO = ptV + vtV1 * dl + vtV2 * ( dCos * dMinRad) ;
|
Point3d ptO = ptV + vtV1 * dl + vtV2 * ( dCos * dMinRad) ;
|
||||||
Frame3d PolyFrame ;
|
Frame3d PolyFrame ;
|
||||||
if ( ! PolyFrame.Set( ptO, vtV1, vtV2, vtV3))
|
PolyFrame.Set( ptO, vtV1, vtV2, vtV3) ;
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Versori piani nel riferimento poliedro ( riferiti al sistema di riferimento) :
|
// Versori piani nel riferimento poliedro ( riferiti al sistema di riferimento) :
|
||||||
// Sx, Dx
|
// Sx, Dx
|
||||||
@@ -5620,7 +5423,7 @@ VolZmap::AddingTruncatedCone( int nGrid, const Point3d& ptS, const Point3d& ptE,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Se il poliedro è attraversato, aggiungo
|
// Se il poliedro � attraversato, aggiungo
|
||||||
if ( nIntNum == 2) {
|
if ( nIntNum == 2) {
|
||||||
|
|
||||||
// Riporto le intersezioni nel sistema griglia
|
// Riporto le intersezioni nel sistema griglia
|
||||||
@@ -5656,8 +5459,7 @@ VolZmap::AddingSphere( int nGrid, const Point3d& ptS, const Point3d& ptE, double
|
|||||||
vtV /= dLengthPath ;
|
vtV /= dLengthPath ;
|
||||||
// Riferimento per cilindro inviluppo della sfera lungo il movimento
|
// Riferimento per cilindro inviluppo della sfera lungo il movimento
|
||||||
Frame3d CylFrame ;
|
Frame3d CylFrame ;
|
||||||
if ( ! CylFrame.Set( ptS, vtV))
|
CylFrame.Set( ptS, vtV) ;
|
||||||
return false ;
|
|
||||||
|
|
||||||
double dSqRad = dRad * dRad ;
|
double dSqRad = dRad * dRad ;
|
||||||
|
|
||||||
|
|||||||
+204
-159
@@ -371,16 +371,6 @@ Voronoi::GetCurve( int nId) const
|
|||||||
return pCrv ;
|
return pCrv ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
Voronoi::GetVroniPlane( Plane3d& plPlane) const
|
|
||||||
{
|
|
||||||
if ( ! IsValid())
|
|
||||||
return false ;
|
|
||||||
plPlane.Set( m_Frame.Orig(), m_Frame.VersZ()) ;
|
|
||||||
return plPlane.IsValid() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Voronoi::CalcVoronoi( int nBound)
|
Voronoi::CalcVoronoi( int nBound)
|
||||||
@@ -594,48 +584,65 @@ Voronoi::CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType)
|
|||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
|
// verifico se curve sono coerenti per calcolo dell'offset
|
||||||
|
if ( ! VerifyCurvesValidityForOffset())
|
||||||
|
return false ;
|
||||||
|
|
||||||
// se offset nullo restituisco direttamente le curve
|
// se offset nullo restituisco direttamente le curve
|
||||||
if ( abs( dOffs) < EPS_SMALL) {
|
if ( abs( dOffs) < EPS_SMALL) {
|
||||||
for ( auto pCrv : m_vpCrvs)
|
for ( auto pCrv : m_vpCrvs)
|
||||||
vOffs.emplace_back( pCrv->Clone()) ;
|
vOffs.emplace_back( pCrv->Clone()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bClosed = m_vpCrvs[0]->IsClosed() ;
|
||||||
|
|
||||||
|
// stabilisco lato offset
|
||||||
|
bool bRightOffs = true ;
|
||||||
|
bool bLeftOffs = true ;
|
||||||
|
if ( bClosed) {
|
||||||
|
bRightOffs = ( dOffs > EPS_SMALL ? true : false) ;
|
||||||
|
bLeftOffs = ( dOffs < - EPS_SMALL ? true : false) ;
|
||||||
|
}
|
||||||
|
|
||||||
// calcolo offset
|
// calcolo offset
|
||||||
ICRVCOMPOPLIST OffsList ;
|
ICRVCOMPOPLIST OffsList ;
|
||||||
if ( ! CalcVroniOffset( OffsList, abs( dOffs)))
|
if ( ! CalcVroniOffset( OffsList, abs( dOffs), bRightOffs, bLeftOffs))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// sistemo le curve di offset calcolate con vroni
|
// sistemo le curve di offset calcolate con vroni
|
||||||
for ( auto pCrv : OffsList) {
|
for ( auto pCrv : OffsList) {
|
||||||
|
|
||||||
// seleziono le porzioni dell'offset che si trovano dal lato richiesto
|
// aggiustamento per curva aperta
|
||||||
ICRVCOMPOPOVECTOR vResult = AdjustOffsetCurves( pCrv, dOffs) ;
|
if ( ! bClosed)
|
||||||
|
AdjustOpenOffsetCurve( *pCrv, dOffs) ;
|
||||||
for ( int i = 0 ; i < int( vResult.size()) ; ++ i) {
|
|
||||||
|
|
||||||
|
if ( pCrv->IsValid()) {
|
||||||
// eventuale inversione
|
// eventuale inversione
|
||||||
if ( dOffs > EPS_SMALL)
|
if ( dOffs > EPS_SMALL)
|
||||||
vResult[i]->Invert() ;
|
pCrv->Invert() ;
|
||||||
|
|
||||||
// sistemo il punto di inizio
|
|
||||||
if ( vResult[i]->IsClosed())
|
|
||||||
AdjustOffsetStart( vResult[i]) ;
|
|
||||||
|
|
||||||
// sistemo i raccordi
|
// sistemo i raccordi
|
||||||
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0) {
|
if ( ( nType & ICurve::OFF_CHAMFER) != 0 || ( nType & ICurve::OFF_EXTEND) != 0) {
|
||||||
IdentifyFillets( vResult[i], dOffs) ;
|
IdentifyFillets( pCrv, dOffs) ;
|
||||||
AdjustCurveFillets( vResult[i], dOffs, nType) ;
|
AdjustCurveFillets( pCrv, dOffs, nType) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( bClosed) {
|
||||||
|
// forzo chiusura della curva per evitare piccole imprecisioni
|
||||||
|
pCrv->Close() ;
|
||||||
|
// sistemo il punto di inizio
|
||||||
|
AdjustOffsetStart( *pCrv) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// porto nel frame globale
|
// porto nel frame globale
|
||||||
vResult[i]->ToGlob( m_Frame) ;
|
pCrv->ToGlob( m_Frame) ;
|
||||||
// unisco le parti allineate
|
// unisco le parti allineate
|
||||||
vResult[i]->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
pCrv->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG, true, true) ;
|
||||||
// aggiungo al vettore finale
|
// aggiungo al vettore finale
|
||||||
vOffs.emplace_back( Release( vResult[i])) ;
|
vOffs.emplace_back( pCrv) ;
|
||||||
}
|
}
|
||||||
// dealloco curva
|
else
|
||||||
delete( pCrv) ;
|
delete pCrv ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
@@ -655,7 +662,7 @@ Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bo
|
|||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
ICRVCOMPOPLIST OffsList ;
|
ICRVCOMPOPLIST OffsList ;
|
||||||
if ( ! CalcVroniOffset( OffsList, abs( dOffs)))
|
if ( ! CalcVroniOffset( OffsList, abs( dOffs), true, true))
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
// sistemo le curve di offset calcolate con vroni
|
// sistemo le curve di offset calcolate con vroni
|
||||||
@@ -699,13 +706,21 @@ Voronoi::CalcFatCurve( ICURVEPOVECTOR& vCrvs, double dOffs, bool bSquareEnds, bo
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs, bool bRightOffs, bool bLeftOffs)
|
||||||
{
|
{
|
||||||
OffsList.clear() ;
|
OffsList.clear() ;
|
||||||
|
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
|
int nOrigCrvCnt = 1 ;
|
||||||
|
if ( m_vpCrvs[0]->GetType() == CRV_COMPO) {
|
||||||
|
const CurveComposite * pOrigCompo = GetBasicCurveComposite( m_vpCrvs[0]) ;
|
||||||
|
if ( pOrigCompo == nullptr)
|
||||||
|
return false ;
|
||||||
|
nOrigCrvCnt = pOrigCompo->GetCurveCount() ;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// reset di eventuali offset precedenti
|
// reset di eventuali offset precedenti
|
||||||
m_vroni->apiResetOffsetData() ;
|
m_vroni->apiResetOffsetData() ;
|
||||||
@@ -714,12 +729,16 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
|||||||
UpdateVoronoi( dOffs) ;
|
UpdateVoronoi( dOffs) ;
|
||||||
|
|
||||||
string sTmp = "" ;
|
string sTmp = "" ;
|
||||||
// viene sempre calcolato sia right_offset sia left_offset anche nel caso di curve chiuse per evitare problemi di identificazione
|
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs, 0.0, false, bLeftOffs, bRightOffs) ;
|
||||||
// di vroni nel caso di piccole autointersezioni
|
int nOffsCnt = m_vroni->GetOffsetCount() ;
|
||||||
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs, 0.0, false, true, true) ;
|
if ( nOffsCnt == 0) {
|
||||||
|
// se non ho ottenuto offset ritento con valore leggermente diverso per le tolleranze di vroni
|
||||||
|
m_vroni->apiResetOffsetData() ;
|
||||||
|
m_vroni->apiComputeOff( false, &sTmp[0], false, false, dOffs - VRONI_OFFS_TOL, 0.0, false, bLeftOffs, bRightOffs) ;
|
||||||
|
nOffsCnt = m_vroni->GetOffsetCount() ;
|
||||||
|
}
|
||||||
|
|
||||||
// recupero le curve di offset da vroni
|
// recupero le curve di offset da vroni
|
||||||
int nOffsCnt = m_vroni->GetOffsetCount() ;
|
|
||||||
for ( int i = 0 ; i < nOffsCnt ; i++) {
|
for ( int i = 0 ; i < nOffsCnt ; i++) {
|
||||||
PtrOwner<CurveComposite> pCrvOffs ( CreateBasicCurveComposite()) ;
|
PtrOwner<CurveComposite> pCrvOffs ( CreateBasicCurveComposite()) ;
|
||||||
int nCrvCnt = m_vroni->GetOffsetCurveCount( i) ; // numero di sottocurve
|
int nCrvCnt = m_vroni->GetOffsetCurveCount( i) ; // numero di sottocurve
|
||||||
@@ -738,9 +757,6 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
|||||||
if ( nType == t_site::SEG)
|
if ( nType == t_site::SEG)
|
||||||
bOk = pCrvOffs->AddLine( ptE) ;
|
bOk = pCrvOffs->AddLine( ptE) ;
|
||||||
else {
|
else {
|
||||||
// se estremi coincidenti passo alla curva successiva ( da vroni non possono arrivare circonferenze)
|
|
||||||
if ( AreSamePointApprox( ptS, ptE))
|
|
||||||
continue ;
|
|
||||||
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
PtrOwner<CurveArc> pArc( CreateBasicCurveArc()) ;
|
||||||
pArc->Set2PRS( ptS, ptE, Dist( ptC, ptS), nType == CCW) ;
|
pArc->Set2PRS( ptS, ptE, Dist( ptC, ptS), nType == CCW) ;
|
||||||
bOk = pCrvOffs->AddCurve( Release( pArc)) ;
|
bOk = pCrvOffs->AddCurve( Release( pArc)) ;
|
||||||
@@ -752,17 +768,9 @@ Voronoi::CalcVroniOffset( ICRVCOMPOPLIST& OffsList, double dOffs)
|
|||||||
int nCurrCrvId = pCrvOffs->GetCurveCount() - 1 ;
|
int nCurrCrvId = pCrvOffs->GetCurveCount() - 1 ;
|
||||||
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigCrv + 1, 0) ;
|
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigCrv + 1, 0) ;
|
||||||
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigLoop, 1) ;
|
pCrvOffs->SetCurveTempProp( nCurrCrvId, nOrigLoop, 1) ;
|
||||||
// verifico se è una giunzione, ovvero un raccordo relativo agli estremi di una curva ( con distinzione fra curva
|
// verifico se è raccordo relativo agli estremi della curva
|
||||||
// aperta e chiusa)
|
if ( nOrigCrv == -1 && ( nOrigPnt == 0 || nOrigPnt == nOrigCrvCnt))
|
||||||
if ( nOrigCrv == -1) {
|
pCrvOffs->SetCurveTempParam( nCurrCrvId, 1.0, 0) ;
|
||||||
int nOrigCrvCnt = 1 ;
|
|
||||||
if ( m_vpCrvs[nOrigLoop]->GetType() == CRV_COMPO)
|
|
||||||
nOrigCrvCnt = GetBasicCurveComposite( m_vpCrvs[nOrigLoop])->GetCurveCount() ;
|
|
||||||
if ( nOrigPnt == 0 || nOrigPnt == nOrigCrvCnt) {
|
|
||||||
double dParam = m_vpCrvs[nOrigLoop]->IsClosed() ? VRONI_JUNCTION_CLOSED : VRONI_JUNCTION_OPEN ;
|
|
||||||
pCrvOffs->SetCurveTempParam( nCurrCrvId, dParam, 0) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,81 +810,160 @@ Voronoi::UpdateVoronoi( double dOffs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
ICRVCOMPOPOVECTOR
|
bool
|
||||||
Voronoi::AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const
|
Voronoi::VerifyCurvesValidityForOffset()
|
||||||
{
|
{
|
||||||
ICRVCOMPOPOVECTOR vResult ;
|
if ( m_vpCrvs.size() == 1)
|
||||||
int nSideRef = dOffs < EPS_SMALL ? MDS_LEFT : MDS_RIGHT ;
|
return true ;
|
||||||
|
|
||||||
// verifico se presenti giunzioni
|
// se ho più curve, devono essere tutte chiuse
|
||||||
bool bJunctions = false ;
|
for ( auto pCrv : m_vpCrvs) {
|
||||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i ++) {
|
if ( ! pCrv->IsClosed())
|
||||||
double dParam ; pCompo->GetCurveTempParam( i, dParam) ;
|
return false ;
|
||||||
if ( abs( dParam - VRONI_JUNCTION_OPEN) < EPS_SMALL) {
|
|
||||||
bJunctions = true ;
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! bJunctions) {
|
// verifico se gli orientamenti delle curve sono coerenti
|
||||||
// controllo la curva complessiva
|
DBLVECTOR vArea( m_vpCrvs.size()) ;
|
||||||
int nSide = GetOffsetCurveSide( pCompo, 0) ;
|
double dRefArea = 0.0 ;
|
||||||
if ( nSide == nSideRef)
|
for ( int i = 0 ; i < ( int)m_vpCrvs.size() ; i ++) {
|
||||||
vResult.emplace_back( pCompo->Clone()) ;
|
m_vpCrvs[i]->GetAreaXY( vArea[i]) ;
|
||||||
|
if ( abs( vArea[i]) > abs( dRefArea))
|
||||||
|
dRefArea = vArea[i] ;
|
||||||
}
|
}
|
||||||
else {
|
bool bRefCCW = ( dRefArea > EPS_SMALL) ;
|
||||||
// scorro la curva eliminando le giunzioni relative a curve aperte e le sottocurve che si trovano dal lato sbagliato
|
|
||||||
PtrOwner<CurveComposite> pCompoCurr( CreateBasicCurveComposite()) ;
|
|
||||||
for ( int i = 0 ; i < pCompo->GetCurveCount() ; i ++) {
|
|
||||||
bool bKeep = true ;
|
|
||||||
double dParTmp ; pCompo->GetCurveTempParam( i, dParTmp) ;
|
|
||||||
if ( abs( dParTmp - VRONI_JUNCTION_OPEN) < EPS_SMALL)
|
|
||||||
bKeep = false ;
|
|
||||||
else {
|
|
||||||
int nSide = GetOffsetCurveSide( pCompo, i) ;
|
|
||||||
bKeep = ( nSide == nSideRef) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bKeep)
|
for ( int i = 0 ; i < ( int)vArea.size() ; i++) {
|
||||||
pCompoCurr->AddCurve( pCompo->GetCurve( i)->Clone()) ;
|
|
||||||
else {
|
// se curva con orientamento principale verifico sia esterna a tutte le altre curve con orientamento principale
|
||||||
// salvo la curva ottenuta fino ad ora e resetto per i prossimi tratti validi
|
if ( vArea[i] * dRefArea > EPS_SMALL) {
|
||||||
if ( pCompoCurr->IsValid()) {
|
for ( int j = 0 ; j < ( int)vArea.size() ; j++) {
|
||||||
vResult.emplace_back( Release( pCompoCurr)) ;
|
if ( j != i && vArea[i] * vArea[j] > EPS_SMALL) {
|
||||||
pCompoCurr.Set( CreateBasicCurveComposite()) ;
|
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[j]) ;
|
||||||
|
int nRes = ccInt.GetRegionCurveClassification() ;
|
||||||
|
if ( nRes == CCREGC_NULL || nRes == CCREGC_SAME || nRes == CCREGC_INTERS)
|
||||||
|
return false ;
|
||||||
|
if ( ( bRefCCW && nRes == CCREGC_IN1) || ( ! bRefCCW && nRes == CCREGC_IN2)) {
|
||||||
|
// se è interna ad una curva con orientamento principale, verifico sia esterna ad almeno una curva con orientamento
|
||||||
|
// diverso dal principale
|
||||||
|
bool bFound = false ;
|
||||||
|
for ( int k = 0 ; k < ( int)vArea.size() ; k++) {
|
||||||
|
if ( k != i && vArea[i] * vArea[k] < EPS_SMALL) {
|
||||||
|
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[k]) ;
|
||||||
|
int nRes = ccInt.GetRegionCurveClassification() ;
|
||||||
|
if ( ( bRefCCW && nRes == CCREGC_OUT) || ( ! bRefCCW && nRes == CCREGC_IN1)) {
|
||||||
|
bFound = true ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ! bFound)
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// salvo eventuale ultima curva
|
|
||||||
if ( pCompoCurr->IsValid())
|
|
||||||
vResult.emplace_back( Release( pCompoCurr)) ;
|
|
||||||
|
|
||||||
// verifico se posso concatenare prima e ultima curva
|
// se curva con orientamento diverso dal principale verifico sia contenuta in una curva con orientamento principale
|
||||||
if ( vResult.size() > 1) {
|
else if ( vArea[i] * dRefArea < - EPS_SMALL) {
|
||||||
Point3d ptStart ; vResult.front()->GetStartPoint( ptStart) ;
|
bool bInside = false ;
|
||||||
Point3d ptEnd ; vResult.back()->GetEndPoint( ptEnd) ;
|
for ( int j = 0 ; j < ( int)vArea.size() ; j++) {
|
||||||
if ( AreSamePointApprox( ptStart, ptEnd) && vResult.front()->AddCurve( vResult.back()->Clone(), false))
|
if ( j != i && vArea[j] * dRefArea > EPS_SMALL) {
|
||||||
vResult.pop_back() ;
|
IntersCurveCurve ccInt( *m_vpCrvs[i], *m_vpCrvs[j]) ;
|
||||||
|
int nRes = ccInt.GetRegionCurveClassification() ;
|
||||||
|
if ( ( bRefCCW && nRes == CCREGC_IN1) || ( ! bRefCCW && nRes == CCREGC_OUT)) {
|
||||||
|
bInside = true ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( ! bInside)
|
||||||
|
return false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return vResult ;
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
Voronoi::AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs)
|
||||||
|
{
|
||||||
|
int nSideRef = dOffs < EPS_SMALL ? MDS_LEFT : MDS_RIGHT ;
|
||||||
|
|
||||||
|
// recupero i raccordi relativi agli estremi della curva aperta
|
||||||
|
INTVECTOR vJunctions ;
|
||||||
|
for ( int i = 0 ; i < pCompo.GetCurveCount() ; i++) {
|
||||||
|
double dParTmp ;
|
||||||
|
pCompo.GetCurveTempParam( i, dParTmp) ;
|
||||||
|
if ( dParTmp > EPS_SMALL)
|
||||||
|
vJunctions.push_back( i) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( vJunctions.size() == 0) {
|
||||||
|
// verifico se si trova dal lato corretto
|
||||||
|
int nSide = GetOffsetCurveSide( pCompo, 0) ;
|
||||||
|
if ( nSide != nSideRef)
|
||||||
|
// se lato errato, tutta la curva va cancellata
|
||||||
|
pCompo.Clear() ;
|
||||||
|
}
|
||||||
|
else if ( vJunctions.size() == 2) {
|
||||||
|
// recupero i due tratti di curva
|
||||||
|
PtrOwner<CurveComposite> pCompo1( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[0] + 1, vJunctions[1]))) ;
|
||||||
|
PtrOwner<CurveComposite> pCompo2( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[1] + 1, vJunctions[0]))) ;
|
||||||
|
pCompo.Clear() ;
|
||||||
|
if ( ! IsNull( pCompo1) && pCompo1->IsValid()) {
|
||||||
|
int nSide = GetOffsetCurveSide( *pCompo1, 0) ;
|
||||||
|
if ( nSide == nSideRef)
|
||||||
|
pCompo.CopyFrom( pCompo1) ;
|
||||||
|
else if ( ! IsNull( pCompo2) && pCompo2->IsValid())
|
||||||
|
pCompo.CopyFrom( pCompo2) ;
|
||||||
|
}
|
||||||
|
else if ( ! IsNull( pCompo2) && pCompo2->IsValid()) {
|
||||||
|
int nSide = GetOffsetCurveSide( *pCompo2, 0) ;
|
||||||
|
if ( nSide == nSideRef)
|
||||||
|
pCompo.CopyFrom( pCompo2) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// mi posiziono dopo la junction
|
||||||
|
pCompo.ChangeStartPoint( vJunctions[0] + 1) ;
|
||||||
|
delete( pCompo.RemoveFirstOrLastCurve()) ;
|
||||||
|
// verifico validità della curva
|
||||||
|
int nSide = GetOffsetCurveSide( pCompo, 0) ;
|
||||||
|
if ( nSide == nSideRef) {
|
||||||
|
// scorro fino alla prima curva non valida ed elimino la curva da quel punto fino alla fine
|
||||||
|
for ( int i = 1 ; i < pCompo.GetCurveCount() ; i++) {
|
||||||
|
int nSide = GetOffsetCurveSide( pCompo, i) ;
|
||||||
|
if ( nSide != nSideRef)
|
||||||
|
pCompo.TrimEndAtParam( i) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// elimino finchè non trovo una curva valida
|
||||||
|
while( nSide != nSideRef && pCompo.IsValid()) {
|
||||||
|
delete( pCompo.RemoveFirstOrLastCurve( false)) ;
|
||||||
|
if ( pCompo.IsValid())
|
||||||
|
nSide = GetOffsetCurveSide( pCompo, 0) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
int
|
int
|
||||||
Voronoi::GetOffsetCurveSide( const ICurveComposite* pOffs, int nCrv) const
|
Voronoi::GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv)
|
||||||
{
|
{
|
||||||
Point3d ptM ; pOffs->GetCurve( nCrv)->GetMidPoint( ptM) ;
|
Point3d ptM ; pOffs.GetCurve( nCrv)->GetMidPoint(ptM) ;
|
||||||
|
int nOrigCrv ; pOffs.GetCurveTempProp( nCrv, nOrigCrv) ;
|
||||||
|
|
||||||
// recupero curva e sottocurva di riferimento
|
const ICurve* pCrvRef = m_vpCrvs[0] ;
|
||||||
int nOrigSubCrv ; pOffs->GetCurveTempProp( nCrv, nOrigSubCrv) ;
|
// se ha una sottocurva di riferimento
|
||||||
int nOrigCrv ; pOffs->GetCurveTempProp( nCrv, nOrigCrv, 1) ;
|
if ( nOrigCrv != 0 && m_vpCrvs[0]->GetType() == CRV_COMPO) {
|
||||||
const ICurve* pCrvRef = m_vpCrvs[nOrigCrv] ;
|
const CurveComposite* pCompoOrig = GetBasicCurveComposite( m_vpCrvs[0]) ;
|
||||||
if ( nOrigSubCrv != 0 && m_vpCrvs[nOrigCrv]->GetType() == CRV_COMPO) {
|
|
||||||
const CurveComposite* pCompoOrig = GetBasicCurveComposite( m_vpCrvs[nOrigCrv]) ;
|
|
||||||
if ( pCompoOrig != nullptr)
|
if ( pCompoOrig != nullptr)
|
||||||
pCrvRef = pCompoOrig->GetCurve( nOrigSubCrv - 1) ;
|
pCrvRef = pCompoOrig->GetCurve( nOrigCrv - 1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
DistPointCurve distPC( ptM, *pCrvRef) ;
|
DistPointCurve distPC( ptM, *pCrvRef) ;
|
||||||
@@ -887,19 +974,19 @@ Voronoi::GetOffsetCurveSide( const ICurveComposite* pOffs, int nCrv) const
|
|||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
Voronoi::AdjustOffsetStart( ICurveComposite* pCrv) const
|
Voronoi::AdjustOffsetStart( ICurveComposite& pCrv)
|
||||||
{
|
{
|
||||||
for ( int i = 0 ; i < pCrv->GetCurveCount() ; i++) {
|
for ( int i = 0 ; i < pCrv.GetCurveCount() ; i++) {
|
||||||
// cerco il tratto associato alla prima sottocurva originale
|
// cerco il tratto associato alla prima curva originale
|
||||||
int nOrigCrv ; pCrv->GetCurveTempProp( i, nOrigCrv) ;
|
int nProp ; pCrv.GetCurveTempProp( i, nProp) ;
|
||||||
if ( nOrigCrv == 1) {
|
if ( nProp == 1) {
|
||||||
pCrv->ChangeStartPoint( i) ;
|
pCrv.ChangeStartPoint( i) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
// oppure associato ad una giunzione
|
// oppure un raccordo di junction
|
||||||
double dParam ; pCrv->GetCurveTempParam( i, dParam) ;
|
double dParam ; pCrv.GetCurveTempParam( i, dParam) ;
|
||||||
if ( abs( dParam - VRONI_JUNCTION_CLOSED) < EPS_SMALL) {
|
if ( abs( dParam - 1) < EPS_SMALL) {
|
||||||
pCrv->ChangeStartPoint( i + 1) ;
|
pCrv.ChangeStartPoint( i + 1) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -916,8 +1003,7 @@ Voronoi::Translate( const Vector3d & vtMove)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||||
Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
|
||||||
{
|
{
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -925,8 +1011,7 @@ Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||||
Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
|
||||||
{
|
{
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -934,8 +1019,7 @@ Voronoi::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, doub
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool Voronoi::ToGlob( const Frame3d& frRef)
|
||||||
Voronoi::ToGlob( const Frame3d& frRef)
|
|
||||||
{
|
{
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -943,8 +1027,7 @@ Voronoi::ToGlob( const Frame3d& frRef)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool Voronoi::ToLoc( const Frame3d& frRef)
|
||||||
Voronoi::ToLoc( const Frame3d& frRef)
|
|
||||||
{
|
{
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
@@ -952,47 +1035,9 @@ Voronoi::ToLoc( const Frame3d& frRef)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool
|
bool Voronoi::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||||
Voronoi::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
|
||||||
{
|
{
|
||||||
if ( ! IsValid())
|
if ( ! IsValid())
|
||||||
return false ;
|
return false ;
|
||||||
return m_Frame.LocToLoc( frOri, frDest) ;
|
return m_Frame.LocToLoc( frOri, frDest) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
bool
|
|
||||||
Voronoi::CalcLimitOffset( int nCrv, bool bLeft, double& dOffs)
|
|
||||||
{
|
|
||||||
if ( nCrv < 0 || nCrv > int( m_vpCrvs.size()) - 1)
|
|
||||||
return false ;
|
|
||||||
// se curva aperta errore
|
|
||||||
if ( ! m_vpCrvs[nCrv]->IsClosed())
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
dOffs = - INFINITO ;
|
|
||||||
try {
|
|
||||||
// verifico se necessario calcolo Voronoi
|
|
||||||
if ( ! m_bVDComputed)
|
|
||||||
CalcVoronoi() ;
|
|
||||||
|
|
||||||
for ( int i = 4 ; i < m_vroni->GetNumberOfEdges() ; i ++) {
|
|
||||||
// verifico se è un bisettore relativo alla curva richiesta e dal lato opportuno
|
|
||||||
if ( m_vroni->IsRelatedEdge( i, nCrv, bLeft)) {
|
|
||||||
// calcolo i parametri del bisettore
|
|
||||||
double dParS, dParE ;
|
|
||||||
m_vroni->GetBisectorParams( i, dParS, dParE) ;
|
|
||||||
dOffs = max( { dParS, dParE, dOffs}) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// libero la memoria di vroni dedicata agli offset
|
|
||||||
m_vroni->apiFreeOffsetData() ;
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
LOG_ERROR( GetEGkLogger(), m_vroni->GetExceptionMessage()) ;
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true ;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
static const bool USE_VORONOI = true ;
|
static const bool USE_VORONOI = true ;
|
||||||
static const int VORONOI_STD_BOUND = 3 ;
|
static const int VORONOI_STD_BOUND = 3 ;
|
||||||
static const double VRONI_OFFS_TOL = 1e-9 ;
|
static const double VRONI_OFFS_TOL = 1e-9 ;
|
||||||
static const double VRONI_JUNCTION_OPEN = 1.0 ;
|
|
||||||
static const double VRONI_JUNCTION_CLOSED = 2.0 ;
|
|
||||||
|
|
||||||
//-------------------------- Forward Definitions -------------------------------
|
//-------------------------- Forward Definitions -------------------------------
|
||||||
class ISurfFlatRegion ;
|
class ISurfFlatRegion ;
|
||||||
@@ -52,12 +50,10 @@ class Voronoi
|
|||||||
ICurve* GetCurve( int nId) const ;
|
ICurve* GetCurve( int nId) const ;
|
||||||
int GetCurveCount( void) const
|
int GetCurveCount( void) const
|
||||||
{ return m_vpCrvs.size() ; } ;
|
{ return m_vpCrvs.size() ; } ;
|
||||||
bool GetVroniPlane( Plane3d& plPlane) const ;
|
|
||||||
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = VORONOI_STD_BOUND) ;
|
bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = VORONOI_STD_BOUND) ;
|
||||||
bool CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType) ;
|
bool CalcOffset( ICURVEPOVECTOR& vOffs, double dOffs, int nType) ;
|
||||||
bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids) ;
|
bool CalcFatCurve( ICURVEPOVECTOR& vOffs, double dOffs, bool bSquareEnds, bool bSquareMids) ;
|
||||||
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) ;
|
bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide) ;
|
||||||
bool CalcLimitOffset( int nCrv, bool bLeft, double& dOffs) ;
|
|
||||||
|
|
||||||
bool Translate( const Vector3d& vtMove) ;
|
bool Translate( const Vector3d& vtMove) ;
|
||||||
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) ;
|
bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) ;
|
||||||
@@ -77,11 +73,12 @@ class Voronoi
|
|||||||
bool AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoopId) ;
|
bool AddBezierToVroni( const ICurveBezier* pBezier, int& nVroniCrv, int nLoopId) ;
|
||||||
|
|
||||||
bool CalcVoronoi( int nBound = VORONOI_STD_BOUND) ;
|
bool CalcVoronoi( int nBound = VORONOI_STD_BOUND) ;
|
||||||
bool CalcVroniOffset( ICRVCOMPOPLIST& vOffs, double dOffs) ;
|
bool CalcVroniOffset( ICRVCOMPOPLIST& vOffs, double dOffs, bool bRightOffs, bool bLeftOffs) ;
|
||||||
bool UpdateVoronoi( double dOffs) ;
|
bool UpdateVoronoi( double dOffs) ;
|
||||||
ICRVCOMPOPOVECTOR AdjustOffsetCurves( const ICurveComposite* pCompo, double dOffs) const ;
|
bool VerifyCurvesValidityForOffset( void) ;
|
||||||
bool AdjustOffsetStart( ICurveComposite* pCompo) const ;
|
bool AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs) ;
|
||||||
int GetOffsetCurveSide( const ICurveComposite* pOffs, int nCrv) const ;
|
bool AdjustOffsetStart( ICurveComposite& pCompo) ;
|
||||||
|
int GetOffsetCurveSide( const ICurveComposite& pOffs, int nCrv) ;
|
||||||
ICurve* GetBisectorCurve( int i) ;
|
ICurve* GetBisectorCurve( int i) ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|||||||
Reference in New Issue
Block a user