EgtGeomKernel 2.5f4 :

- corretta IntersSegmentCylinder (qui come cilindro si intende solo la superficie dello stesso)
- corretta e velocizzata AvoidSurfTm di VolZmap nel caso di test con singola map.
This commit is contained in:
DarioS
2023-06-21 08:26:21 +02:00
parent c4f1a7f97b
commit 8a3d46416d
4 changed files with 72 additions and 61 deletions
+58 -48
View File
@@ -19,6 +19,7 @@
#include "IntersLineBox.h"
#include "IntersLineCyl.h"
#include "IntersLineCone.h"
#include "IntersLineCaps.h"
#include "IntersLineSurfStd.h"
#include "/EgtDev/Include/EGkIntersLineTria.h"
#include "/EgtDev/Include/EGkIntersLinePlane.h"
@@ -451,7 +452,9 @@ VolZmap::AvoidSimpleBox( const Frame3d& frBox, const Vector3d& vtDiag, bool bPre
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3Int.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z)
continue ;
for ( int k = 0 ; k < 5 ; ++ k) {
Point3d ptT = ptO + ( i + 0.5) * m_dStep * vtX + ( j + 0.5) * m_dStep * vtY ;
@@ -668,7 +671,9 @@ VolZmap::AvoidSimpleSphere( const Point3d& ptCenter, double dRad, bool bPrecise)
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3Int.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z)
continue ;
if ( m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z || m_Values[0][nPos][0].dMin > b3Int.GetMax().z)
continue ;
@@ -841,7 +846,9 @@ VolZmap::AvoidSimpleCylinder( const Frame3d& frCyl, double dR, double dH, bool b
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3Int.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z)
continue ;
if ( m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z || m_Values[0][nPos][0].dMin > b3Int.GetMax().z)
continue ;
@@ -1041,7 +1048,9 @@ VolZmap::AvoidSimpleConeFrustum( const Frame3d& frCone, double dMinRad, double d
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3Int.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z)
continue ;
if ( m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z || m_Values[0][nPos][0].dMin > b3Int.GetMax().z)
continue ;
@@ -1423,7 +1432,9 @@ VolZmap::AvoidSimpleRectPrismoid( const Frame3d& frPrismoid, double dLenghtBaseX
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3Int.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z)
continue ;
double dParMin = m_Values[0][nPos][0].dMin ;
double dParMax = m_Values[0][nPos][nSize-1].dMax ;
@@ -1701,7 +1712,9 @@ VolZmap::AvoidSimpleTorus( const Frame3d& frTorus, double dMaxRad, double dMinRa
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3Int.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3Int.GetMin().z)
continue ;
double dParMin = m_Values[0][nPos][0].dMin ;
double dParMax = m_Values[0][nPos][nSize-1].dMax ;
@@ -1856,6 +1869,12 @@ VolZmap::AvoidSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecis
// Se verifico solo prima mappa
if ( ! bPrecise || m_nMapNum == 1) {
// Vettore direzione dei dexel nel riferimento locale Zmap
Vector3d vtK = GetToGlob( Z_AX, m_MapFrame) ;
// Riferimento intrinseco dei dexel nel riferimento locale Zmap
Point3d ptO = GetToGlob( ORIG, m_MapFrame) ;
Vector3d vtX = GetToGlob( X_AX, m_MapFrame) ;
Vector3d vtY = GetToGlob( Y_AX, m_MapFrame) ;
// Ciclo sui triangoli che cadono nel box
for ( int nT : vTriaIndex) {
Triangle3d trTria ;
@@ -1882,52 +1901,43 @@ VolZmap::AvoidSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecis
for ( int j = nStJ ; j <= nEnJ ; ++ j) {
int nPos = j * m_nNx[0] + i ;
int nSize = int( m_Values[0][nPos].size()) ;
if ( nSize == 0)
if ( nSize == 0 ||
m_Values[0][nPos][0].dMin > b3TriaBox.GetMax().z ||
m_Values[0][nPos][nSize-1].dMax < b3TriaBox.GetMin().z)
continue ;
for ( int k = 0 ; k < 5 ; ++ k) {
Point3d ptLineSt = ORIG + ( i + 0.5) * m_dStep * X_AX + ( j + 0.5) * m_dStep * Y_AX ;
if ( k == 0)
;
else if ( k == 1)
ptLineSt += - 0.4 * m_dStep * X_AX - 0.4 * m_dStep * Y_AX ;
else if ( k == 2)
ptLineSt += + 0.4 * m_dStep * X_AX - 0.4 * m_dStep * Y_AX ;
else if ( k == 3)
ptLineSt += + 0.4 * m_dStep * X_AX + 0.4 * m_dStep * Y_AX ;
else if ( k == 4)
ptLineSt += - 0.4 * m_dStep * X_AX + 0.4 * m_dStep * Y_AX ;
Vector3d vtLineDir = Z_AX ;
// Porto punto iniziale e vettore nel sistema locale
ptLineSt.ToGlob( m_MapFrame) ;
vtLineDir.ToGlob( m_MapFrame) ;
for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) {
// Segmento ormai nel sistema locale
Point3d ptSegSt = ptLineSt + m_Values[0][nPos][nIndex].dMin * vtLineDir ;
double dSegLen = m_Values[0][nPos][nIndex].dMax - m_Values[0][nPos][nIndex].dMin ;
// Se la distanza di sicurezza è significativa
if ( dSafeDist > EPS_SMALL) {
// Valuto sfere nei vertici e cilindri lungo gli edge.
for ( int nV = 0 ; nV < 3 ; ++ nV) {
Point3d ptVertP = trTria.GetP( nV) ;
Vector3d vtEdgeV = trTria.GetP( ( nV + 1) % 3) - ptVertP ;
double dEdgeLen = vtEdgeV.Len() ;
vtEdgeV /= dEdgeLen ;
double dU1, dU2 ;
int nIntersType = SegmentSphere( ptSegSt, vtLineDir, dSegLen, ptVertP, dSafeDist, dU1, dU2) ;
if ( nIntersType != LinCompSphereIntersType::S_NO_INTERS)
return false ;
nIntersType = IntersSegmentCylinder( ptSegSt, vtLineDir, dSegLen, ptVertP, vtEdgeV,
dSafeDist, dEdgeLen, dU1, dU2) ;
if ( nIntersType != LinCompCCIntersType::CC_NO_INTERS)
return false ;
Point3d ptT = ptO + ( i + 0.5) * m_dStep * vtX + ( j + 0.5) * m_dStep * vtY ;
switch ( k) {
case 0 : break ;
case 1 : ptT += - 0.4 * m_dStep * vtX - 0.4 * m_dStep * vtY ; break ;
case 2 : ptT += + 0.4 * m_dStep * vtX - 0.4 * m_dStep * vtY ; break ;
case 3 : ptT += + 0.4 * m_dStep * vtX + 0.4 * m_dStep * vtY ; break ;
case 4 : ptT += - 0.4 * m_dStep * vtX + 0.4 * m_dStep * vtY ; break ;
}
// Se la distanza di sicurezza è significativa
if ( dSafeDist > EPS_SMALL) {
// Intersezione della linea con i capsule dei lati
for ( int nV = 0 ; nV < 3 ; ++ nV) {
double dZmin, dZmax ;
if ( IntersLineCaps( ptT, vtK, trTria.GetP( nV), trTria.GetP( ( nV + 1) % 3), dSafeDist, dZmin, dZmax)) {
for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) {
if ( dZmax > m_Values[0][nPos][nIndex].dMin - EPS_SMALL &&
dZmin < m_Values[0][nPos][nIndex].dMax + EPS_SMALL)
return false ;
}
}
}
// Intersezione segmento con triangolo eventualmente offsettato
Point3d ptInt, ptInt2 ;
int nIntersType = IntersLineTria( ptSegSt, vtLineDir, dSegLen, trNewTria, ptInt, ptInt2) ;
// Collisione
if ( nIntersType != IntLineTriaType::ILTT_NO)
return false ;
}
// Intersezione della linea con triangolo eventualmente offsettato
Point3d ptInt, ptInt2 ;
if ( IntersLineTria( ptT, vtK, 1, trNewTria, ptInt, ptInt2, false) != IntLineTriaType::ILTT_NO) {
double dZmin = ( ptInt - ptT) * vtK ;
double dZmax = ( ptInt2 - ptT) * vtK ;
for ( int nIndex = 0 ; nIndex < nSize ; nIndex += 1) {
if ( dZmax > m_Values[0][nPos][nIndex].dMin - EPS_SMALL &&
dZmin < m_Values[0][nPos][nIndex].dMax + EPS_SMALL)
return false ;
}
}
}
}