EgtGeomKernel 1.8k3 :

- miglioramenti a Zmap.
This commit is contained in:
Dario Sassi
2017-11-25 18:50:54 +00:00
parent 33d2690ec8
commit 4252497bb3
7 changed files with 702 additions and 711 deletions
BIN
View File
Binary file not shown.
+161 -88
View File
@@ -25,6 +25,9 @@
using namespace std ;
//----------------------------------------------------------------------------
// Punti e vettore devono esse espressi nel medesimo sistema di riferimento.
// Il box è allineato con gli assi di tale sistema di riferimento.
// Viene restituito true in caso di intersezione, false altrimenti.
bool
VolZmap::IntersLineBox( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptMin, const Point3d& ptMax) const
{
@@ -34,6 +37,10 @@ VolZmap::IntersLineBox( const Point3d& ptP, const Vector3d& vtV, const Point3d&
}
//----------------------------------------------------------------------------
// Punti e vettore devono esse espressi nel medesimo sistema di riferimento.
// Il box è allineato con gli assi di tale sistema di riferimento.
// In dU1, dU2 vengono restituiti i parametri a cui si trovano le intersezioni.
// Viene restituito true in caso di intersezione, false altrimenti.
bool
VolZmap::IntersLineBox( const Point3d& ptP, const Vector3d& vtV,
const Point3d& ptMin, const Point3d& ptMax, double& dU1, double& dU2) const
@@ -95,17 +102,25 @@ VolZmap::IntersLineZMapLattice( const Point3d& ptP, const Vector3d& vtV, double&
}
//----------------------------------------------------------------------------
// Trova le intersezioni di una retta, definita tramite un suo punto e il vettore della direzione,
// e il bounding box dello Zmap. Punto e vettore devono essere espressi nel sistema di riferimento
// intrinseco dello Zmap. Se vi è intersezione viene restitutito true, false altrimenti.
// Se vi è intersezione in dU1 e dU2 vengono restituiti i parametri a cui avvengono le intersezioni.
bool
VolZmap::IntersLineZMapBBox( const Point3d& ptP, const Vector3d& vtV, unsigned int nGrid, double& dU1, double& dU2) const
VolZmap::IntersLineZMapBBox( const Point3d& ptP, const Vector3d& vtV, double& dU1, double& dU2) const
{
// Punti estremi del box dello Zmap
Point3d ptMin = ORIG ;
Point3d ptMax = ptMin + Vector3d( m_nNx[nGrid] * m_dStep, m_nNy[nGrid] * m_dStep, m_dMaxZ[nGrid]) ;
Point3d ptMax = ptMin + Vector3d( m_nNx[0] * m_dStep, m_nNy[0] * m_dStep, m_dMaxZ[0]) ;
return IntersLineBox( ptP, vtV, ptMin, ptMax, dU1, dU2) ;
}
//----------------------------------------------------------------------------
// Trova le intersezioni fra una retta e un dexel parallelepipedale (gli intervalli sono
// parallelepipdi). Punto e vettore devono essere espressi nel sistema grilgia che coincide
// con quello intrinseco dello Zmap solo nel caso della prima griglia. Per le altre griglie
// è necessario permutare ciclicamente le coordinate.
bool
VolZmap::IntersLineDexel( const Point3d& ptP, const Vector3d& vtV, unsigned int nGrid, unsigned int nI, unsigned int nJ,
double& dU1, double& dU2) const
@@ -144,6 +159,10 @@ VolZmap::IntersLineDexel( const Point3d& ptP, const Vector3d& vtV, unsigned int
}
//----------------------------------------------------------------------------
// Trova le intersezioni fra una semi-retta e un dexel parallelepipedale (gli intervalli sono
// parallelepipdi). Punto e vettore devono essere espressi nel sistema grilgia che coincide
// con quello intrinseco dello Zmap solo nel caso della prima griglia. Per le altre griglie
// è necessario permutare ciclicamente le coordinate.
bool
VolZmap::IntersRayDexel( const Point3d& ptP, const Vector3d& vtV, unsigned int nGrid, unsigned int nI, unsigned int nJ,
double& dU1, double& dU2) const
@@ -196,8 +215,8 @@ VolZmap::GetDepth( const Point3d& ptPLoc, const Vector3d& vtDLoc, double& dInLen
{
Point3d ptP = ptPLoc ;
Vector3d vtD = vtDLoc ;
ptP.ToLoc( m_MapFrame[0]) ;
vtD.ToLoc( m_MapFrame[0]) ;
ptP.ToLoc( m_MapFrame) ;
vtD.ToLoc( m_MapFrame) ;
if ( bExact)
return GetDepthWithVoxel( ptP, vtD, dInLength, dOutLength, true) ;
@@ -212,12 +231,10 @@ VolZmap::GetDepth( const Point3d& ptPLoc, const Vector3d& vtDLoc, double& dInLen
// OutLength = distanza di uscita
bool
VolZmap::GetDepthWithDexel( const Point3d& ptP, const Vector3d& vtV, double& dInLength, double& dOutLength) const
{
int nGrid = 0 ;
{
// Intersezione fra semiretta e BBox dello Zmap
double dU1, dU2 ;
bool bTest = IntersLineZMapBBox( ptP, vtV, nGrid, dU1, dU2) && ( dU1 > 0 || dU2 > 0) ;
bool bTest = IntersLineZMapBBox( ptP, vtV, dU1, dU2) && ( dU1 > 0 || dU2 > 0) ;
// Semiretta esterna al box dello Zmap quindi esterna anche allo Zmap
if ( ! bTest) {
@@ -226,88 +243,144 @@ VolZmap::GetDepthWithDexel( const Point3d& ptP, const Vector3d& vtV, double& dIn
return true ;
}
Point3d ptI, ptF ;
// Una sola intersezione valida ( punto interno, intersezione valida 2)
if ( dU1 < 0 && dU2 > 0) {
ptI = ptP ;
ptF = ptP + dU2 * vtV ;
}
// due soluzioni valide ( punto esterno)
else {
ptI = ptP + dU1 * vtV ;
ptF = ptP + dU2 * vtV ;
}
// Inizializzo distanze
dInLength = INFINITO ;
dOutLength = - INFINITO ;
double dInLen[3] ;
double dOutLen[3] ;
// Determino asse di spostamento maggiore
bool bOnX = ( abs( ptF.y - ptI.y) <= abs( ptF.x - ptI.x)) ;
// Ciclo sulle griglie
for ( int nGrid = 0 ; nGrid < int( m_nMapNum) ; ++ nGrid) {
// Movimento crescente su asse di movimento principale
if ( ( bOnX && ptF.x < ptI.x) || ( ! bOnX && ptF.y < ptI.y) )
swap( ptI, ptF) ;
Point3d ptP0 = ptP ;
Vector3d vtV0 = vtV ;
// Pendenza
double dDeltaX = ( ptF.x - ptI.x) ;
double dDeltaY = ( ptF.y - ptI.y) ;
double dM = 0 ;
if ( bOnX && abs( dDeltaX) > EPS_SMALL)
dM = dDeltaY / dDeltaX ;
else if ( ! bOnX && abs( dDeltaY) > EPS_SMALL)
dM = dDeltaX / dDeltaY ;
// Determinazione degli indici i j dei punti ptI e ptF
int nIi = Clamp( int( floor( ptI.x / m_dStep)), 0, m_nNx[nGrid] - 1) ;
int nIj = Clamp( int( floor( ptI.y / m_dStep)), 0, m_nNy[nGrid] - 1) ;
int nFi = Clamp( int( floor( ptF.x / m_dStep)), 0, m_nNx[nGrid] - 1) ;
int nFj = Clamp( int( floor( ptF.y / m_dStep)), 0, m_nNy[nGrid] - 1) ;
// mi muovo
int i = nIi ; int j = nIj ;
while ( ( bOnX && i <= nFi) || ( ! bOnX && j <= nFj)) {
// Eseguo controllo
double dU1, dU2 ;
if ( IntersRayDexel( ptP, vtV, nGrid, i, j, dU1, dU2)) {
dInLength = min( dInLength, dU1) ;
dOutLength = max( dOutLength, dU2) ;
}
// Calcolo spostamento (a destra o sopra)
if ( bOnX) {
double dMoveX = ( ( i + 1) * m_dStep - ptI.x) ;
double dMoveY = dMoveX * dM ;
double dY = ptI.y + dMoveY ;
int nNewJ = Clamp( int( floor( dY / m_dStep)), 0, m_nNy[nGrid] - 1) ;
if ( nNewJ != j)
j = nNewJ ;
else
++ i ;
Point3d ptI, ptF ;
// Una sola intersezione valida ( punto interno, intersezione valida 2)
if ( dU1 < 0 && dU2 > 0) {
ptI = ptP ;
ptF = ptP + dU2 * vtV ;
}
// due soluzioni valide ( punto esterno)
else {
double dMoveY = ( ( j + 1) * m_dStep - ptI.y) ;
double dMoveX = dMoveY * dM ;
double dX = ptI.x + dMoveX ;
int nNewI = Clamp( int( floor( dX / m_dStep)), 0, m_nNx[nGrid] - 1) ;
if ( nNewI != i)
i = nNewI ;
else
++ j ;
ptI = ptP + dU1 * vtV ;
ptF = ptP + dU2 * vtV ;
}
// Passo dal sistema intrinseco alla griglia
if ( nGrid == 1) {
swap( ptP0.y, ptP0.z) ;
swap( ptP0.x, ptP0.z) ;
swap( vtV0.y, vtV0.z) ;
swap( vtV0.x, vtV0.z) ;
swap( ptI.y, ptI.z) ;
swap( ptI.x, ptI.z) ;
swap( ptF.y, ptF.z) ;
swap( ptF.x, ptF.z) ;
}
else if ( nGrid == 2) {
swap( ptP0.x, ptP0.z) ;
swap( ptP0.y, ptP0.z) ;
swap( vtV0.x, vtV0.z) ;
swap( vtV0.y, vtV0.z) ;
swap( ptI.x, ptI.z) ;
swap( ptI.y, ptI.z) ;
swap( ptF.x, ptF.z) ;
swap( ptF.y, ptF.z) ;
}
// Inizializzo distanze
dInLen[nGrid] = INFINITO ;
dOutLen[nGrid] = - INFINITO ;
// Determino asse di spostamento maggiore
bool bOnX = ( abs( ptF.y - ptI.y) <= abs( ptF.x - ptI.x)) ;
// Movimento crescente su asse di movimento principale
if ( ( bOnX && ptF.x < ptI.x) || ( ! bOnX && ptF.y < ptI.y) )
swap( ptI, ptF) ;
// Pendenza
double dDeltaX = ( ptF.x - ptI.x) ;
double dDeltaY = ( ptF.y - ptI.y) ;
double dM = 0 ;
if ( bOnX && abs( dDeltaX) > EPS_SMALL)
dM = dDeltaY / dDeltaX ;
else if ( ! bOnX && abs( dDeltaY) > EPS_SMALL)
dM = dDeltaX / dDeltaY ;
// Determinazione degli indici i j dei punti ptI e ptF
int nIi = Clamp( int( floor( ptI.x / m_dStep)), 0, m_nNx[nGrid] - 1) ;
int nIj = Clamp( int( floor( ptI.y / m_dStep)), 0, m_nNy[nGrid] - 1) ;
int nFi = Clamp( int( floor( ptF.x / m_dStep)), 0, m_nNx[nGrid] - 1) ;
int nFj = Clamp( int( floor( ptF.y / m_dStep)), 0, m_nNy[nGrid] - 1) ;
// mi muovo
int i = nIi ; int j = nIj ;
while ( ( bOnX && i <= nFi) || ( ! bOnX && j <= nFj)) {
// Eseguo controllo
double dU1, dU2 ;
if ( IntersRayDexel( ptP0, vtV0, nGrid, i, j, dU1, dU2)) {
dInLen[nGrid] = min( dInLen[nGrid], dU1) ;
dOutLen[nGrid] = max( dOutLen[nGrid], dU2) ;
}
// Calcolo spostamento (a destra o sopra)
if ( bOnX) {
double dMoveX = ( ( i + 1) * m_dStep - ptI.x) ;
double dMoveY = dMoveX * dM ;
double dY = ptI.y + dMoveY ;
int nNewJ = Clamp( int( floor( dY / m_dStep)), 0, m_nNy[nGrid] - 1) ;
if ( nNewJ != j)
j = nNewJ ;
else
++ i ;
}
else {
double dMoveY = ( ( j + 1) * m_dStep - ptI.y) ;
double dMoveX = dMoveY * dM ;
double dX = ptI.x + dMoveX ;
int nNewI = Clamp( int( floor( dX / m_dStep)), 0, m_nNx[nGrid] - 1) ;
if ( nNewI != i)
i = nNewI ;
else
++ j ;
}
}
// Se non abbiamo incontrato materiale
if ( dInLen[nGrid] > dOutLen[nGrid] - EPS_SMALL) {
dInLen[nGrid] = - 2 ;
dOutLen[nGrid] = - 2 ;
}
// Se parto dall'interno
else if ( dInLen[nGrid] < - EPS_SMALL)
dInLen[nGrid] = - 1 ;
}
// Se non abbiamo incontrato materiale
if ( dInLength > dOutLength - EPS_SMALL) {
if ( m_nMapNum == 1) {
dInLength = dInLen[0] ;
dOutLength = dOutLen[0] ;
return true ;
}
if ( abs( dInLen[0] + 2) < EPS_SMALL &&
abs( dInLen[1] + 2) < EPS_SMALL &&
abs( dInLen[2] + 2) < EPS_SMALL) {
dInLength = - 2 ;
dOutLength = - 2 ;
return true ;
}
// Se parto dall'interno
if ( dInLength < - EPS_SMALL)
dInLength = - 1 ;
else {
dInLength = INFINITO ;
dOutLength = - INFINITO ;
for ( int nGr = 0 ; nGr < 3 ; ++ nGr) {
if ( dInLen[nGr] > - 2 && dInLen[nGr] < dInLength)
dInLength = dInLen[nGr] ;
if ( dOutLen[nGr] > - 2 && dOutLen[nGr] > dOutLength)
dOutLength = dOutLen[nGr] ;
}
}
return true ;
}
@@ -325,7 +398,7 @@ VolZmap::GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtD, double& dIn
double dU1, dU2 ;
// Intersezione fra semiretta e BBox dello Zmap
bool bLineBBoxInters = IntersLineZMapBBox( ptP, vtD, 0, dU1, dU2) && ( dU1 > 0 || dU2 > 0) ;
bool bLineBBoxInters = IntersLineZMapBBox( ptP, vtD, dU1, dU2) && ( dU1 > 0 || dU2 > 0) ;
// Semiretta esterna al box dello Zmap quindi esterna anche allo Zmap
if ( ! bLineBBoxInters) {
dInLength = - 2 ;
@@ -415,8 +488,8 @@ VolZmap::GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtD, double& dIn
continue ;
// se altrimenti c'è una sola intersezione
else if ( nIntType == ILTT_VERT ||
nIntType == ILTT_EDGE ||
nIntType == ILTT_IN) {
nIntType == ILTT_EDGE ||
nIntType == ILTT_IN) {
LineTriaInt NewInt ;
NewInt.dPar = ( ptLineTria1 - ptP) * vtD ;
NewInt.dDot = vtD * CurrTria.GetN() ;
@@ -521,7 +594,7 @@ VolZmap::AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag) const
BBox3d b3Box( ORIG, ORIG + vtDiag) ;
// lo porto nel riferimento intrinseco dello Zmap
b3Box.LocToLoc( frBox, m_MapFrame[0]) ;
b3Box.LocToLoc( frBox, m_MapFrame) ;
// BBox dello Zmap nel suo riferimento intrinseco
BBox3d b3Zmap( ORIG, Point3d( m_nNx[0] * m_dStep, m_nNy[0] * m_dStep, m_dMaxZ[0])) ;
@@ -538,12 +611,12 @@ VolZmap::AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag) const
int nEnJ = Clamp( int( b3Int.GetMax().y / m_dStep), 0, m_nNy[0] -1) ;
// Vettore direzione dei dexel nel riferimento del Box
Vector3d vtK = Z_AX ; vtK.LocToLoc( m_MapFrame[0], frBox) ;
Vector3d vtK = Z_AX ; vtK.LocToLoc( m_MapFrame, frBox) ;
// Riferimento intrinseco dei dexel nel riferimento del box
Point3d ptO = ORIG ; ptO.LocToLoc( m_MapFrame[0], frBox) ;
Vector3d vtX = X_AX ; vtX.LocToLoc( m_MapFrame[0], frBox) ;
Vector3d vtY = Y_AX ; vtY.LocToLoc( m_MapFrame[0], frBox) ;
Point3d ptO = ORIG ; ptO.LocToLoc( m_MapFrame, frBox) ;
Vector3d vtX = X_AX ; vtX.LocToLoc( m_MapFrame, frBox) ;
Vector3d vtY = Y_AX ; vtY.LocToLoc( m_MapFrame, frBox) ;
// Ciclo di intersezione dei dexel con il BBox
for ( int i = nStI ; i <= nEnI ; ++ i) {
@@ -1414,7 +1487,7 @@ VolZmap::GetPlaneIntersection( const Plane3d& plPlane, POCRVVECTOR& vpLoop) cons
return false ;
// Porto il piano nel sistema Zmap
Plane3d plPlaneL = plPlane ;
plPlaneL.ToLoc( m_MapFrame[0]) ;
plPlaneL.ToLoc( m_MapFrame) ;
// Vettore del piano
Vector3d vtNL = plPlaneL.GetVersN() ;
@@ -1466,7 +1539,7 @@ VolZmap::GetPlaneIntersection( const Plane3d& plPlane, POCRVVECTOR& vpLoop) cons
return false ;
}
pLoop->SetExtrusion( vtNL) ;
pLoop->ToGlob( m_MapFrame[0]) ;
pLoop->ToGlob( m_MapFrame) ;
// Se normali controverse, devo invertire il verso del loop.
if ( nSign < 0)
pLoop->Invert() ;
+21 -25
View File
@@ -42,8 +42,8 @@ VolZmap::Create( const Point3d& ptO, double dLengthX, double dLengthY, double dL
// di uno si ottengono da una permutazione ciclica di quelle del precedente sistema.
// es: X(n) = Z(n-1), Y(n) = X(n-1), Z(n) = Y(n-1)
// Definisco i sistemi di riferimento
m_MapFrame[0].Set( ptO, X_AX, Y_AX, Z_AX) ;
// Definisco il sistema di riferimento intrinseco
m_MapFrame.Set( ptO, X_AX, Y_AX, Z_AX) ;
// Definisco i vettori dei limiti su indici
m_nNx[0] = static_cast <unsigned int> ( floor( ( dLengthX + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
@@ -64,8 +64,6 @@ VolZmap::Create( const Point3d& ptO, double dLengthX, double dLengthY, double dL
// Se tridexel
if ( bTriDex) {
m_MapFrame[1].Set( ptO, Y_AX, Z_AX, X_AX) ;
m_MapFrame[2].Set( ptO, Z_AX, X_AX, Y_AX) ;
m_nNx[1] = static_cast <unsigned int> ( floor( ( dLengthY + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
m_nNy[1] = static_cast <unsigned int> ( floor( ( dLengthZ + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
@@ -83,9 +81,7 @@ VolZmap::Create( const Point3d& ptO, double dLengthX, double dLengthY, double dL
// altrimenti mono dexel
else {
m_MapFrame[1].Set( ptO, Y_AX, Z_AX, X_AX) ;
m_MapFrame[2].Set( ptO, Z_AX, X_AX, Y_AX) ;
m_nNx[1] = 0 ;
m_nNy[1] = 0 ;
@@ -183,8 +179,8 @@ VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double
SurfBBox.GetMinMax( ptMapOrig, ptMapEnd) ;
SurfBBox.Expand( 100 * EPS_SMALL, 100 * EPS_SMALL, 0) ;
// Sistema di riferimento mappa
m_MapFrame[0].Set( ptMapOrig, X_AX, Y_AX, Z_AX) ;
// Sistema di riferimento intrinseco dello Zmap
m_MapFrame.Set( ptMapOrig, X_AX, Y_AX, Z_AX) ;
// Determino le dimensioni lineari X Y della griglia
double dLengthX = ptMapEnd.x - ptMapOrig.x ;
@@ -215,10 +211,7 @@ VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double
// Se Tridexel ridimensiono anche gli altri vettori
if ( bTriDex) {
m_MapFrame[1].Set( ptMapOrig, Y_AX, Z_AX, X_AX) ;
m_MapFrame[2].Set( ptMapOrig, Z_AX, X_AX, Y_AX) ;
m_nNx[1] = static_cast <unsigned int> ( floor( ( dLengthY + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
m_nNy[1] = static_cast <unsigned int> ( floor( ( dDimZ + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
@@ -241,9 +234,7 @@ VolZmap::CreateFromFlatRegion( const ISurfFlatRegion& Surf, double dDimZ, double
}
else {
m_MapFrame[1].Set( ptMapOrig, Y_AX, Z_AX, X_AX) ;
m_MapFrame[2].Set( ptMapOrig, Z_AX, X_AX, Y_AX) ;
m_nNx[1] = 0 ;
m_nNy[1] = 0 ;
@@ -510,8 +501,8 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dPrec, bool bTriDex
// quindi espandiamo il bounding box per ovviare al problema.
SurfBBox.Expand( 100 * EPS_SMALL, 100 * EPS_SMALL, 100 * EPS_SMALL) ;
// Sistema di riferimento mappa
m_MapFrame[0].Set( ptMapOrig, Frame3d::TOP) ;
// Sistema di riferimento intrinseco dello Zmap
m_MapFrame.Set( ptMapOrig, Frame3d::TOP) ;
// Il passo di discretizzazione non può essere inferiore a 100 * EPS_SMALL
m_dStep = max( dPrec, 100 * EPS_SMALL) ;
@@ -544,9 +535,7 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dPrec, bool bTriDex
// Se Tridexel ridimensiono anche gli altri vettori
if ( bTriDex) {
m_MapFrame[1].Set( ptMapOrig, Y_AX, Z_AX, X_AX) ; // Sarà Front Left
m_MapFrame[2].Set( ptMapOrig, Z_AX, X_AX, Y_AX) ;
m_nNx[1] = static_cast <unsigned int> ( floor( ( vtLen.y + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
m_nNy[1] = static_cast <unsigned int> ( floor( ( vtLen.z + 0.5 * m_dStep + EPS_SMALL) / m_dStep)) ;
@@ -569,9 +558,7 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dPrec, bool bTriDex
}
else {
m_MapFrame[1].Set( ptMapOrig, Y_AX, Z_AX, X_AX) ;
m_MapFrame[2].Set( ptMapOrig, Z_AX, X_AX, Y_AX) ;
m_nNx[1] = 0 ;
m_nNy[1] = 0 ;
m_nDim[1] = 0 ;
@@ -587,8 +574,17 @@ VolZmap::CreateFromTriMesh( const ISurfTriMesh& Surf, double dPrec, bool bTriDex
// ciclo sulle griglie
for ( unsigned 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( ptMapOrig, Y_AX, Z_AX, X_AX) ;
else if ( g == 2)
frMapFrame.Set( ptMapOrig, Z_AX, X_AX, Y_AX) ;
// Oggetto per calcolo massivo intersezioni
IntersParLinesSurfTm intPLSTM( m_MapFrame[g], Surf) ;
IntersParLinesSurfTm intPLSTM( frMapFrame, Surf) ;
// Determinazione e ridimensionamento dei dexel interni alla trimesh
for ( unsigned int i = 0 ; i < m_nNx[g] ; ++ i) {
+469 -476
View File
File diff suppressed because it is too large Load Diff
+7 -78
View File
@@ -52,6 +52,7 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
// Riporto le coordinate cicliche nell'ordine di partenza
Vector3d vtNmi = vtNMin ;
Vector3d vtNma = vtNMax ;
// Passo dalla grilgia al sistema intrinseco
if ( nGrid == 1) {
swap( vtNmi.x, vtNmi.z) ;
swap( vtNmi.y, vtNmi.z) ;
@@ -318,41 +319,7 @@ VolZmap::SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::SubtractIntervals( unsigned int nGrid, const Point3d & ptP,
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax)
{
// Controllo che il numero di griglia sia entro i limiti.
if ( nGrid < 0 || nGrid > 2)
return false ;
// ptP è espresso nel sistema locale e viene convertito in quello intrinseco (localFrame)
Point3d ptPL = ptP ;
ptPL.ToLoc( m_MapFrame[nGrid]) ;
double dX, dY, dZ ; // Coordinate di ptPL nel sistema intrinseco
double dhMin, dhMax ; // Altezze dMin e dMax RIESPRESSE nel sistema intrinseco (dMin e dMax sono altezze rispetto a ptP)
dX = ptPL.x ; dY = ptPL.y ; dZ = ptPL.z ;
dhMin = dZ + dMin ; dhMax = dZ + dMax ;
// Cerco il punto della griglia più vicino
double integerPartX = floor( dX / m_dStep) ;
double integerPartY = floor( dY / m_dStep) ;
unsigned int i = static_cast <unsigned int> (integerPartX) ; // Indici del punto di griglia più vicino.
unsigned int j = static_cast <unsigned int> (integerPartY) ; // i = 0, 1, ..., m_Nx - 1 ; j = 0, 1, ..., m_Ny - 1 ;
// Controllo che gli indici ottenuti siano nella griglia:
// se sono dentro la griglia chiamo l'altra subtract
if ( i >= 0 && i < m_nNx[nGrid] &&
j >= 0 && j < m_nNy[nGrid])
return SubtractIntervals( nGrid, i, j, dhMin, dhMax, vtNMin, vtNMax) ;
// altrimenti non succede niente
else
return true ;
}
//----------------------------------------------------------------------------
bool
@@ -585,46 +552,8 @@ VolZmap::AddIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ,
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::AddIntervals( unsigned int nGrid, const Point3d & ptP,
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax)
{
// // Controllo che il numero di griglia sia entro i limiti.
// if ( nGrid < 0 || nGrid > 2)
// return false ;
//
// // ptP è espresso nel sistema locale e viene convertito in quello intrinseco (localFrame)
// Point3d ptPL = ptP ;
// ptPL.ToLoc( m_MapFrame[nGrid]) ;
//
// double dX, dY, dZ ; // Coordinate di ptPL nel sistema intrinseco
// double dhMin, dhMax ; // Altezze dMin e dMax RIESPRESSE nel sistema intrinseco (dMin e dMax sono altezze rispetto a ptP)
//
// dX = ptPL.x ; dY = ptPL.y ; dZ = ptPL.z ;
// dhMin = dZ + dMin ; dhMax = dZ + dMax ;
//
// // Cerco il punto della griglia più vicino
// double integerPartX = floor( dX / m_dStep) ;
// double integerPartY = floor( dY / m_dStep) ;
//
// unsigned int i = static_cast <unsigned int> (integerPartX) ; // Indici del punto di griglia più vicino.
// unsigned int j = static_cast <unsigned int> (integerPartY) ; // i = 0, 1, ..., m_Nx - 1 ; j = 0, 1, ..., m_Ny - 1
//
// // Controllo che gli indici ottenuti siano nella griglia:
// // se sono dentro la griglia chiamo l'altra add
// if ( i >= 0 && i < m_nNx[nGrid] &&
// j >= 0 && j < m_nNy[nGrid])
//
// return AddIntervals( nGrid, i, j, dhMin, dhMax, vtNMin, vtNMax) ;
// else
// // altrimenti non succede niente
return false ;
}
// ------------------------- LAVORAZIONI --------------------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool
VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d& ptPe, const Vector3d& vtDe)
@@ -645,10 +574,10 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
Point3d ptLe[3] ;
ptLs[0] = ptPs ;
ptLs[0].ToLoc( m_MapFrame[0]) ;
ptLs[0].ToLoc( m_MapFrame) ;
ptLe[0] = ptPe ;
ptLe[0].ToLoc( m_MapFrame[0]) ;
ptLe[0].ToLoc( m_MapFrame) ;
if ( m_nMapNum > 1) {
ptLs[1].x = ptLs[0].y ; ptLs[1].y = ptLs[0].z ; ptLs[1].z = ptLs[0].x ;
@@ -671,11 +600,11 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
Vector3d vtLe[3] ;
vtLs[0] = vtDs ;
vtLs[0].ToLoc( m_MapFrame[0]) ;
vtLs[0].ToLoc( m_MapFrame) ;
vtLs[0].Normalize() ;
vtLe[0] = vtDe ;
vtLe[0].ToLoc( m_MapFrame[0]) ;
vtLe[0].ToLoc( m_MapFrame) ;
vtLe[0].Normalize() ;
if ( m_nMapNum > 1) {
@@ -691,11 +620,11 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d&
Vector3d vtALe[3] ;
vtALs[0] = vtAs ;
vtALs[0].ToLoc( m_MapFrame[0]) ;
vtALs[0].ToLoc( m_MapFrame) ;
vtALs[0].Normalize() ;
vtALe[0] = vtAe ;
vtALe[0].ToLoc( m_MapFrame[0]) ;
vtALe[0].ToLoc( m_MapFrame) ;
vtALe[0].Normalize() ;
if ( m_nMapNum > 1) {
+33 -38
View File
@@ -58,8 +58,8 @@ VolZmap::Clear( void)
m_nMapNum = 0 ;
m_nNumBlock = 0 ;
m_nConnectedCompoCount = 0 ;
for ( int i = 0 ; i < N_MAPS ; ++ i) {
m_MapFrame[i].Reset() ;
m_MapFrame.Reset() ;
for ( int i = 0 ; i < N_MAPS ; ++ i) {
m_nNx[i] = 0 ;
m_nNy[i] = 0 ;
m_nDim[i] = 0 ;
@@ -119,11 +119,11 @@ VolZmap::CopyFrom( const VolZmap& vzmSrc)
m_nFracLin[1] = vzmSrc.m_nFracLin[1] ;
m_nFracLin[2] = vzmSrc.m_nFracLin[2] ;
m_nConnectedCompoCount = vzmSrc.m_nConnectedCompoCount ;
m_MapFrame = vzmSrc.m_MapFrame ;
for ( int i = 0 ; i < int ( m_nMapNum) ; ++ i) {
m_MapFrame[i] = vzmSrc.m_MapFrame[i] ;
m_nNx[i] = vzmSrc.m_nNx[i] ;
m_nNy[i] = vzmSrc.m_nNy[i] ;
m_nDim[i] = vzmSrc.m_nDim[i] ;
@@ -228,10 +228,11 @@ VolZmap::Save( NgeWriter& ngeOut) const
// passo di campionamento (distanza tra spilloni)
if ( ! ngeOut.WriteDouble( m_dStep, ";", true))
return false ;
// per ogni mappa : sistema di riferimento, numero di passi in X e Y intrinseci
for ( unsigned int i = 0 ; i < m_nMapNum ; ++ i) {
if ( ! ngeOut.WriteFrame( m_MapFrame[i], ";", true))
return false ;
// sistema di riferimento
if ( ! ngeOut.WriteFrame( m_MapFrame, ";", true))
return false ;
// per ogni mappa : numero di passi in X e Y e quote z estremali
for ( unsigned int i = 0 ; i < m_nMapNum ; ++ i) {
if ( ! ngeOut.WriteInt( m_nNx[i], ",", false))
return false ;
if ( ! ngeOut.WriteInt( m_nNy[i], ",", false))
@@ -304,10 +305,11 @@ VolZmap::Load( NgeReader& ngeIn)
// passo di campionamento (distanza tra spilloni)
if ( ! ngeIn.ReadDouble( m_dStep, ";", true))
return false ;
// per ogni mappa : sistema di riferimento, numero di passi in X e Y intrinseci
for ( unsigned int i = 0 ; i < m_nMapNum ; ++ i) {
if ( ! ngeIn.ReadFrame( m_MapFrame[i], ";", true))
// sistema di riferimento
if ( ! ngeIn.ReadFrame( m_MapFrame, ";", true))
return false ;
// per ogni mappa : numero di passi in X e Y e quote z estremali
for ( unsigned int i = 0 ; i < m_nMapNum ; ++ i) {
if ( ! ngeIn.ReadInt( m_nNx[i], ",", false))
return false ;
if ( ! ngeIn.ReadInt( m_nNy[i], ",", false))
@@ -385,23 +387,23 @@ VolZmap::GetLocalBBox( BBox3d& b3Loc, int nFlag) const
if ( ( nFlag & BBF_EXACT) == 0) {
b3Loc.Add( ORIG) ;
b3Loc.Add( Point3d( m_nNx[0] * m_dStep, m_nNy[0] * m_dStep, m_dMaxZ[0])) ;
b3Loc.ToGlob( m_MapFrame[0]) ;
b3Loc.ToGlob( m_MapFrame) ;
return true ;
}
// calcolo preciso
// ciclo sui dexel (punti in basso con ciclo aggiunto per punti in alto di ultima riga)
double dY = 0 ;
for ( size_t j = 0 ; j <= m_nNy[0] ; ++ j) {
size_t jc = ( ( j != m_nNy[0]) ? j : m_nNy[0] -1) ;
size_t jc = ( ( j != m_nNy[0]) ? j : m_nNy[0] - 1) ;
double dX = 0 ;
// punto a sinistra di ogni dexel (aggiungo un ciclo per fare punto a destra di ultimo)
for ( size_t i = 0 ; i <= m_nNx[0] ; ++ i) {
size_t ic = ( ( i != m_nNx[0]) ? i : m_nNx[0] -1) ;
size_t ic = ( ( i != m_nNx[0]) ? i : m_nNx[0] - 1) ;
size_t nPos = ic + jc * m_nNx[0] ;
if ( m_Values[0][nPos].size() > 0) {
Point3d ptP = m_MapFrame[0].Orig() + dX * m_MapFrame[0].VersX() + dY * m_MapFrame[0].VersY() ;
b3Loc.Add( ptP + m_Values[0][nPos][0].dMin * m_MapFrame[0].VersZ()) ;
b3Loc.Add( ptP + m_Values[0][nPos][m_Values[0][nPos].size()-1].dMax * m_MapFrame[0].VersZ()) ;
Point3d ptP = m_MapFrame.Orig() + dX * m_MapFrame.VersX() + dY * m_MapFrame.VersY() ;
b3Loc.Add( ptP + m_Values[0][nPos][0].dMin * m_MapFrame.VersZ()) ;
b3Loc.Add( ptP + m_Values[0][nPos][m_Values[0][nPos].size()-1].dMax * m_MapFrame.VersZ()) ;
}
// passo al punto successivo
dX += m_dStep ;
@@ -423,7 +425,7 @@ VolZmap::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
// reset box
b3Ref.Reset() ;
// trasformo il riferimento locale tramite quello passato
Frame3d frUse = m_MapFrame[0] ;
Frame3d frUse = m_MapFrame ;
frUse.ToGlob( frRef) ;
// se richiesto approssimato
if ( ( nFlag & BBF_EXACT) == 0) {
@@ -466,9 +468,8 @@ VolZmap::Translate( const Vector3d& vtMove)
return false ;
// imposto ricalcolo della grafica
ResetGraphics() ;
// traslo i riferimenti
for ( int i = 0 ; i < int( m_nMapNum) ; ++ i)
m_MapFrame[i].Translate( vtMove) ;
// traslo il riferimento
m_MapFrame.Translate( vtMove) ;
return true ;
}
@@ -481,9 +482,8 @@ VolZmap::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, doub
return false ;
// imposto ricalcolo della grafica
ResetGraphics() ;
// ruoto i riferimenti
for ( int i = 0 ; i < int( m_nMapNum) ; ++ i)
m_MapFrame[i].Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
// ruoto il riferimento
m_MapFrame.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
return true ;
}
@@ -526,9 +526,8 @@ VolZmap::ToGlob( const Frame3d& frRef)
return false ;
// imposto ricalcolo della grafica
ResetGraphics() ;
// trasformo il riferimento
for ( int i = 0 ; i < int ( m_nMapNum) ; ++ i)
m_MapFrame[i].ToGlob( frRef) ;
// trasformo il riferimento
m_MapFrame.ToGlob( frRef) ;
return true ;
}
@@ -541,9 +540,8 @@ VolZmap::ToLoc( const Frame3d& frRef)
return false ;
// imposto ricalcolo della grafica
ResetGraphics() ;
// trasformo il riferimento
for ( int i = 0 ; i < int( m_nMapNum) ; ++ i)
m_MapFrame[i].ToLoc( frRef) ;
// trasformo il riferimento
m_MapFrame.ToLoc( frRef) ;
return true ;
}
@@ -556,9 +554,8 @@ VolZmap::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
return false ;
// imposto ricalcolo della grafica
ResetGraphics() ;
// trasformo il riferimento
for ( int i = 0 ; i < int( m_nMapNum) ; ++ i)
m_MapFrame[i].LocToLoc( frOri, frDest) ;
// trasformo il riferimento
m_MapFrame.LocToLoc( frOri, frDest) ;
return true ;
}
@@ -1090,12 +1087,10 @@ VolZmap::ClonePart( int nPart) const
// Dimensiono raccolta triangoli di feature tra blocchi
pVolume->m_InterBlockTria.resize( pVolume->m_nNumBlock) ;
// Sistemi di riferimento delle griglie del nuovo solido
// Sistema di riferimento intrinseco del nuovo solido
Point3d ptNewO( dNewOx, dNewOy, dNewOz) ;
pVolume->m_MapFrame[0].Set( ptNewO, X_AX, Y_AX, Z_AX) ;
pVolume->m_MapFrame[1].Set( ptNewO, Y_AX, Z_AX, X_AX) ;
pVolume->m_MapFrame[2].Set( ptNewO, Z_AX, X_AX, Y_AX) ;
pVolume->m_MapFrame.Set( ptNewO, X_AX, Y_AX, Z_AX) ;
// Setto lo stato del nuovo Solido
pVolume->m_nStatus = m_nStatus ;
+11 -6
View File
@@ -40,6 +40,12 @@ typedef std::vector<TriaStruct> TriHolder ;
// il primo indice individua il blocco, il secondo il voxel
typedef std::vector<TriHolder> TriaMatrix ;
// ------------------------- STRUTTURA VERTICE TRIANGOLO - NORMALE ALLA SUPERFICIE ------------------------------------------------
struct VectorField {
Point3d ptInt ;
Vector3d vtNorm ;
} ;
//----------------------------------------------------------------------------
class VolZmap : public IVolZmap, public IGeoObjRW
{
@@ -161,15 +167,14 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP, double dPrec = EPS_SMALL) const ;
bool GetPointVoxel( const Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) const ;
bool IsZInsideInterval( int nGrid, int nDex, double dZ) const ;
bool GridControl( VectorField VecField[], VectorField CompoVert[][12],
int nIndArrey[][4], int nVertComp[], int nCompCount, bool& bGridControl) const ;
// OPERAZIONI SU INTERVALLI
bool SubtractIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ,
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) ;
bool SubtractIntervals( unsigned int nGrid, const Point3d& ptP,
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) ;
bool AddIntervals( unsigned int nGrid, unsigned int nI, unsigned int nJ,
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) ;
bool AddIntervals( unsigned int nGrid, const Point3d& ptP,
double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) ;
// SOTTRAZIONI
// UTENSILI
@@ -252,7 +257,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
bool IntersLineBox( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptMin, const Point3d& ptMax,
double& dU1, double& dU2) const ;
bool IntersLineZMapLattice( const Point3d& ptP, const Vector3d& vtV, double& dU1, double& dU2) const ;
bool IntersLineZMapBBox( const Point3d& ptP, const Vector3d& vtV, unsigned int nGrid, double& dU1, double& dU2) const ;
bool IntersLineZMapBBox( const Point3d& ptP, const Vector3d& vtV, double& dU1, double& dU2) const ;
bool IntersLineDexel( const Point3d& ptP, const Vector3d& vtV, unsigned int nGrid, unsigned int nI, unsigned int nJ,
double& dU1, double& dU2) const ;
bool IntersRayDexel( const Point3d& ptP, const Vector3d& vtV, unsigned int nGrid, unsigned int nI, unsigned int nJ,
@@ -323,7 +328,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW
int m_nTempProp ; // proprietà temporanea
double m_dStep ; // passo delle griglie
unsigned int m_nMapNum ; // numero di griglie ( 1 o 3)
Frame3d m_MapFrame[N_MAPS] ; // riferimenti delle griglie
Frame3d m_MapFrame ; // riferimento intrinseco dello Zmap
unsigned int m_nNx[N_MAPS] ; // dimensione di ciascuna griglia in X
unsigned int m_nNy[N_MAPS] ; // dimensione di ciascuna griglia in Y
unsigned int m_nDim[N_MAPS] ; // dimensione di ciascuna griglia ( X * Y)