EgtGeomKernel :
- miglioramenti negli algoritmi di controllo collisioni tra solidi semplici e Zmap (aumento velocità 2x, 5x).
This commit is contained in:
+118
-207
@@ -1102,10 +1102,16 @@ VolZmap::AvoidSimpleConeFrustum( const Frame3d& frCone, double dMinRad, double d
|
||||
else if ( vtRefAx.IsZ())
|
||||
b3Cone.Expand( dMaxRad, dMaxRad, 0) ;
|
||||
else {
|
||||
double dExpandX = dMaxRad * sqrt( 1 - vtRefAx.x * vtRefAx.x) ;
|
||||
double dExpandY = dMaxRad * sqrt( 1 - vtRefAx.y * vtRefAx.y) ;
|
||||
double dExpandZ = dMaxRad * sqrt( 1 - vtRefAx.z * vtRefAx.z) ;
|
||||
b3Cone.Expand( dExpandX, dExpandY, dExpandZ) ;
|
||||
double dCoeffX = sqrt( 1 - vtRefAx.x * vtRefAx.x) ;
|
||||
double dCoeffY = sqrt( 1 - vtRefAx.y * vtRefAx.y) ;
|
||||
double dCoeffZ = sqrt( 1 - vtRefAx.z * vtRefAx.z) ;
|
||||
BBox3d b3Base( ptRefPoint) ;
|
||||
b3Base.Expand( dMinRad * dCoeffX, dMinRad * dCoeffY, dMinRad * dCoeffZ) ;
|
||||
BBox3d b3Top( ptRefPoint + vtRefAx * dHeight) ;
|
||||
b3Top.Expand( dMaxRad * dCoeffX, dMaxRad * dCoeffY, dMaxRad * dCoeffZ) ;
|
||||
b3Cone.Reset() ;
|
||||
b3Cone.Add( b3Base) ;
|
||||
b3Cone.Add( b3Top) ;
|
||||
}
|
||||
|
||||
// Se non interferiscono, posso uscire
|
||||
@@ -1304,7 +1310,7 @@ VolZmap::AvoidSimpleConeFrustum( const Frame3d& frCone, double dMinRad, double d
|
||||
//----------------------------------------------------------------------------
|
||||
// Ha come asse Z l'asse del cono/tronco di cono. Se è un cono proprio l'origine
|
||||
// è nel vertice del cono e l'asse Z è diretto verso l'apertura.
|
||||
// Se è un tronco di cono l'origine è nel centro della base Bot e l'azze Z è diretto verso
|
||||
// Se è un tronco di cono l'origine è nel centro della base Bot e l'asse Z è diretto verso
|
||||
// la base Top, a prescindere da quale base abbia raggio maggiore.
|
||||
bool
|
||||
VolZmap::AvoidConeFrustum( const Frame3d& frCone, double dRadBot, double dRadTop, double dHeight,
|
||||
@@ -1399,150 +1405,28 @@ VolZmap::AvoidConeFrustum( const Frame3d& frCone, double dRadBot, double dRadTop
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
RectPrismoidSegmentCollision( const Frame3d& frPrismoid, double dLenghtBaseX, double dLenghtBaseY,
|
||||
double dLenghtTopX, double dLenghtTopY, double dHeight,
|
||||
const Point3d& ptSt, const Point3d& ptEn)
|
||||
IntersSegmentPlanePlus( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3,
|
||||
const Point3d& ptLnSt, const Vector3d& vtLnDir, double dLnLen,
|
||||
double& dStU, double& dEnU)
|
||||
{
|
||||
// Se il solido non è ben definito, non ha senso continuare.
|
||||
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
|
||||
max( dLenghtBaseY, dLenghtTopY) < EPS_SMALL ||
|
||||
dHeight < EPS_SMALL)
|
||||
Plane3d plPlane ;
|
||||
if ( ! plPlane.Set( ptP1, ptP2, ptP3))
|
||||
return false ;
|
||||
|
||||
// Porto il segmento nel sistema del tronco.
|
||||
Point3d ptMySt = ptSt ;
|
||||
ptMySt.ToLoc( frPrismoid) ;
|
||||
Point3d ptMyEn = ptEn ;
|
||||
ptMyEn.ToLoc( frPrismoid) ;
|
||||
|
||||
// Se il segmento non è ben definito, non ha senso continuare.
|
||||
Vector3d vtMySeg = ptMyEn - ptMySt ;
|
||||
if ( ! vtMySeg.Normalize())
|
||||
return false ;
|
||||
|
||||
double dHalfBaseX = 0.5 * dLenghtBaseX ;
|
||||
double dHalfBaseY = 0.5 * dLenghtBaseY ;
|
||||
double dHalfTopX = 0.5 * dLenghtTopX ;
|
||||
double dHalfTopY = 0.5 * dLenghtTopY ;
|
||||
|
||||
// Se almeno un vertice collide ho finito
|
||||
if ( ( ptMySt.z > - EPS_SMALL && ptMySt.z < dHeight + EPS_SMALL &&
|
||||
( ptMySt.x + dHalfBaseX + EPS_SMALL) * dHeight > ( dHalfBaseX - dHalfTopX) * ptMySt.z &&
|
||||
( ptMySt.x - dHalfBaseX - EPS_SMALL) * dHeight < ( dHalfTopX - dHalfBaseX) * ptMySt.z &&
|
||||
( ptMySt.y + dHalfBaseY + EPS_SMALL) * dHeight > ( dHalfBaseY - dHalfTopY) * ptMySt.z &&
|
||||
( ptMySt.y - dHalfBaseY - EPS_SMALL) * dHeight < ( dHalfTopY - dHalfBaseY) * ptMySt.z) ||
|
||||
( ptMyEn.z > - EPS_SMALL && ptMySt.z < dHeight + EPS_SMALL &&
|
||||
( ptMyEn.x + dHalfBaseX + EPS_SMALL) * dHeight > ( dHalfBaseX - dHalfTopX) * ptMyEn.z &&
|
||||
( ptMyEn.x - dHalfBaseX - EPS_SMALL) * dHeight < ( dHalfTopX - dHalfBaseX) * ptMyEn.z &&
|
||||
( ptMyEn.y + dHalfBaseY + EPS_SMALL) * dHeight > ( dHalfBaseY - dHalfTopY) * ptMyEn.z &&
|
||||
( ptMyEn.y - dHalfBaseY - EPS_SMALL) * dHeight < ( dHalfTopY - dHalfBaseY) * ptMyEn.z))
|
||||
Point3d ptInt ;
|
||||
int nIntType = IntersLinePlane( ptLnSt, vtLnDir, dLnLen, plPlane, ptInt) ;
|
||||
if ( nIntType == ILPT_INPLANE)
|
||||
return true ;
|
||||
|
||||
// Se c'è collisione con almeno un triangolo delle facce ho finito
|
||||
Triangle3d trFaceTria1, trFaceTria2 ;
|
||||
Point3d ptInt, ptInt2 ;
|
||||
// Faccia base
|
||||
trFaceTria1.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( - dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0.)) ;
|
||||
if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
trFaceTria2.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, - dHalfBaseY, 0.)) ;
|
||||
if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
// Faccia top
|
||||
trFaceTria1.Set( Point3d( - dHalfTopX, - dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, dHalfTopY, dHeight),
|
||||
Point3d( - dHalfTopX, dHalfTopY, dHeight)) ;
|
||||
if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
trFaceTria2.Set( Point3d( - dHalfTopX, - dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, - dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, dHalfTopY, dHeight)) ;
|
||||
if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
// Faccia laterale 1
|
||||
trFaceTria1.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX , - dHalfTopY , dHeight),
|
||||
Point3d( - dHalfTopX , - dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
trFaceTria2.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX, - dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
// Faccia laterale 2
|
||||
trFaceTria1.Set( Point3d( dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX , dHalfTopY , dHeight),
|
||||
Point3d( dHalfTopX , - dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
trFaceTria2.Set( Point3d( dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX , dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
// Faccia laterale 3
|
||||
trFaceTria1.Set( Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( - dHalfTopX , dHalfTopY , dHeight),
|
||||
Point3d( dHalfTopX , dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
trFaceTria2.Set( Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( - dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( - dHalfTopX , dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
// Faccia laterale 4
|
||||
trFaceTria1.Set( Point3d( - dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( - dHalfTopX , - dHalfTopY , dHeight),
|
||||
Point3d( - dHalfTopX , dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
trFaceTria2.Set( Point3d( - dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( - dHalfBaseX, - dHalfBaseY, 0.),
|
||||
Point3d( - dHalfTopX , - dHalfTopY , dHeight)) ;
|
||||
if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO)
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
IntersSegmentTrianglePlus( const Point3d& ptTr1, const Point3d& ptTr2, const Point3d& ptTr3,
|
||||
const Point3d& ptLnSt, const Vector3d& vtLnDir, double dLnLen,
|
||||
double& dStU, double& dEnU)
|
||||
{
|
||||
Triangle3d trFaceTria ;
|
||||
trFaceTria.Set( ptTr1, ptTr2, ptTr3) ;
|
||||
if ( trFaceTria.Validate()) {
|
||||
Point3d ptMyIntSt, ptMyIntEn ;
|
||||
int nIntType = IntersLineTria( ptLnSt, vtLnDir, dLnLen, trFaceTria, ptMyIntSt, ptMyIntEn, true) ;
|
||||
if ( nIntType != ILTT_NO) {
|
||||
if ( nIntType == ILTT_VERT || nIntType == ILTT_EDGE || nIntType == ILTT_IN) {
|
||||
double dCurU = ( ptMyIntSt - ptLnSt) * vtLnDir ;
|
||||
if ( dCurU < dStU)
|
||||
dStU = dCurU ;
|
||||
if ( dCurU > dEnU)
|
||||
dEnU = dCurU ;
|
||||
}
|
||||
else {
|
||||
double dCurStU = ( ptMyIntSt - ptLnSt) * vtLnDir ;
|
||||
double dCurEnU = ( ptMyIntEn - ptLnSt) * vtLnDir ;
|
||||
if ( dCurStU < dStU)
|
||||
dStU = dCurStU ;
|
||||
if ( dCurEnU > dEnU)
|
||||
dEnU = dCurEnU ;
|
||||
}
|
||||
}
|
||||
if ( nIntType == ILPT_NO) {
|
||||
if ( DistPointPlane( ptLnSt, plPlane) > 0)
|
||||
dEnU = -1 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
double dIntU = ( ptInt - ptLnSt) * vtLnDir ;
|
||||
if ( vtLnDir * plPlane.GetVersN() > 0)
|
||||
dEnU = min( dEnU, dIntU) ;
|
||||
else
|
||||
dStU = max( dStU, dIntU) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1552,19 +1436,17 @@ RectPrismoidSegmentCollisionPlus( const Frame3d& frPrismoid, double dLenghtBaseX
|
||||
const Point3d& ptSt, const Point3d& ptEn,
|
||||
double& dStU, double& dEnU)
|
||||
{
|
||||
// Se il solido non è ben definito, non ha senso continuare.
|
||||
// Se il solido non è ben definito, non ha senso continuare
|
||||
if ( max( dLenghtBaseX, dLenghtTopX) < EPS_SMALL ||
|
||||
max( dLenghtBaseY, dLenghtTopY) < EPS_SMALL ||
|
||||
dHeight < EPS_SMALL)
|
||||
return false ;
|
||||
|
||||
// Porto il segmento nel sistema del prismoide a base rettangolare
|
||||
Point3d ptMySt = ptSt ;
|
||||
ptMySt.ToLoc( frPrismoid) ;
|
||||
Point3d ptMyEn = ptEn ;
|
||||
ptMyEn.ToLoc( frPrismoid) ;
|
||||
Point3d ptMySt = GetToLoc( ptSt, frPrismoid) ;
|
||||
Point3d ptMyEn = GetToLoc( ptEn, frPrismoid) ;
|
||||
|
||||
// Se il segmento non è ben definito, non ha senso continuare.
|
||||
// Se il segmento non è ben definito, non ha senso continuare
|
||||
Vector3d vtMySeg = ptMyEn - ptMySt ;
|
||||
double dSegLen = vtMySeg.Len() ;
|
||||
if ( dSegLen < EPS_SMALL)
|
||||
@@ -1577,78 +1459,87 @@ RectPrismoidSegmentCollisionPlus( const Frame3d& frPrismoid, double dLenghtBaseX
|
||||
double dHalfTopX = 0.5 * dLenghtTopX ;
|
||||
double dHalfTopY = 0.5 * dLenghtTopY ;
|
||||
|
||||
// Inizializzo gli estremi della parte di retta che interseca il prismoide
|
||||
dStU = INFINITO ;
|
||||
dEnU = -INFINITO ;
|
||||
// Interseco la retta con le facce e salvo i punti d'intersezione
|
||||
// Faccia base
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( -dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
// Parametri estremi linea
|
||||
dStU = 0 ;
|
||||
dEnU = dSegLen ;
|
||||
// Verifico con faccia base
|
||||
IntersSegmentPlanePlus( Point3d( -dHalfBaseX, -dHalfBaseY, 0),
|
||||
Point3d( -dHalfBaseX, dHalfBaseY, 0),
|
||||
Point3d( dHalfBaseX, 0, 0),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
if ( dEnU < dStU - EPS_ZERO)
|
||||
return false ;
|
||||
// Verifico con faccia top
|
||||
IntersSegmentPlanePlus( Point3d( -dHalfTopX, dHalfTopY, dHeight),
|
||||
Point3d( -dHalfTopX, -dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, 0, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
if ( dEnU < dStU - EPS_ZERO)
|
||||
return false ;
|
||||
// Verifico con faccia laterale 1
|
||||
if ( dHalfTopX > dHalfBaseX)
|
||||
IntersSegmentPlanePlus( Point3d( 0, -dHalfBaseY, 0),
|
||||
Point3d( dHalfTopX, -dHalfTopY, dHeight),
|
||||
Point3d( -dHalfTopX, -dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, -dHalfBaseY, 0.),
|
||||
else
|
||||
IntersSegmentPlanePlus( Point3d( -dHalfBaseX, -dHalfBaseY, 0),
|
||||
Point3d( dHalfBaseX, -dHalfBaseY, 0),
|
||||
Point3d( 0, -dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
// Faccia top
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfTopX, -dHalfTopY, dHeight),
|
||||
if ( dEnU < dStU - EPS_ZERO)
|
||||
return false ;
|
||||
// Verifico con faccia laterale 2
|
||||
if ( dHalfTopY > dHalfBaseY)
|
||||
IntersSegmentPlanePlus( Point3d( dHalfBaseX, 0, 0),
|
||||
Point3d( dHalfTopX, dHalfTopY, dHeight),
|
||||
Point3d( -dHalfTopX, dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfTopX, -dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, -dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
else
|
||||
IntersSegmentPlanePlus( Point3d( dHalfBaseX, -dHalfBaseY, 0),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0),
|
||||
Point3d( dHalfTopX, 0, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
if ( dEnU < dStU - EPS_ZERO)
|
||||
return false ;
|
||||
// Verifico con faccia laterale 3
|
||||
if ( dHalfTopX > dHalfBaseX)
|
||||
IntersSegmentPlanePlus( Point3d( 0, dHalfBaseY, 0),
|
||||
Point3d( -dHalfTopX, dHalfTopY, dHeight),
|
||||
Point3d( dHalfTopX, dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
// Faccia laterale 1
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX , -dHalfTopY , dHeight),
|
||||
Point3d( -dHalfTopX , -dHalfTopY , dHeight),
|
||||
else
|
||||
IntersSegmentPlanePlus( Point3d( dHalfBaseX, dHalfBaseY, 0),
|
||||
Point3d( -dHalfBaseX, dHalfBaseY, 0),
|
||||
Point3d( 0, dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX, -dHalfTopY , dHeight),
|
||||
if ( dEnU < dStU - EPS_ZERO)
|
||||
return false ;
|
||||
// Verifico con faccia laterale 4
|
||||
if ( dHalfTopY > dHalfBaseY)
|
||||
IntersSegmentPlanePlus( Point3d( -dHalfBaseX, 0, 0),
|
||||
Point3d( -dHalfTopX, -dHalfTopY, dHeight),
|
||||
Point3d( -dHalfTopX, dHalfTopY, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
// Faccia laterale 2
|
||||
IntersSegmentTrianglePlus( Point3d( dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX , dHalfTopY , dHeight),
|
||||
Point3d( dHalfTopX , -dHalfTopY , dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
IntersSegmentTrianglePlus( Point3d( dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( dHalfTopX , dHalfTopY , dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
// Faccia laterale 3
|
||||
IntersSegmentTrianglePlus( Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( -dHalfTopX , dHalfTopY , dHeight),
|
||||
Point3d( dHalfTopX , dHalfTopY , dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
IntersSegmentTrianglePlus( Point3d( dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( -dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( -dHalfTopX , dHalfTopY , dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
// Faccia laterale 4
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( -dHalfTopX , -dHalfTopY , dHeight),
|
||||
Point3d( -dHalfTopX , dHalfTopY , dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
IntersSegmentTrianglePlus( Point3d( -dHalfBaseX, dHalfBaseY, 0.),
|
||||
Point3d( -dHalfBaseX, -dHalfBaseY, 0.),
|
||||
Point3d( -dHalfTopX , -dHalfTopY , dHeight),
|
||||
else
|
||||
IntersSegmentPlanePlus( Point3d( -dHalfBaseX, dHalfBaseY, 0),
|
||||
Point3d( -dHalfBaseX, -dHalfBaseY, 0),
|
||||
Point3d( -dHalfTopX, 0, dHeight),
|
||||
ptMySt, vtMySeg, dSegLen,
|
||||
dStU, dEnU) ;
|
||||
if ( dEnU < dStU - EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
return ( dEnU > dStU - EPS_ZERO && dStU < dSegLen + EPS_SMALL && dEnU > -EPS_SMALL) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1672,10 +1563,28 @@ VolZmap::AvoidSimpleRectPrismoid( const Frame3d& frPrismoid, double dLenghtBaseX
|
||||
// Se i box non interferiscono, posso uscire
|
||||
if ( ! b3Zmap.Overlaps( b3PrismI) || ! b3Zmap.Overlaps( frPrismInt, b3PrismL))
|
||||
return true ;
|
||||
|
||||
// BBox del tronco di prismoide ottimizzato nel riferimento intrinseco dello Zmap
|
||||
Point3d ptMyCen = frPrismInt.Orig() ;
|
||||
Vector3d vtMyAxX = frPrismInt.VersX() ;
|
||||
Vector3d vtMyAxY = frPrismInt.VersY() ;
|
||||
Vector3d vtMyAxZ = frPrismInt.VersZ() ;
|
||||
BBox3d b3Prism ;
|
||||
b3Prism.Add( ptMyCen - dLenghtBaseX / 2 * vtMyAxX - dLenghtBaseY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen + dLenghtBaseX / 2 * vtMyAxX - dLenghtBaseY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen + dLenghtBaseX / 2 * vtMyAxX + dLenghtBaseY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen - dLenghtBaseX / 2 * vtMyAxX + dLenghtBaseY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen + dHeight * vtMyAxZ - dLenghtTopX / 2 * vtMyAxX - dLenghtTopY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen + dHeight * vtMyAxZ + dLenghtTopX / 2 * vtMyAxX - dLenghtTopY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen + dHeight * vtMyAxZ + dLenghtTopX / 2 * vtMyAxX + dLenghtTopY / 2 * vtMyAxY) ;
|
||||
b3Prism.Add( ptMyCen + dHeight * vtMyAxZ - dLenghtTopX / 2 * vtMyAxX + dLenghtTopY / 2 * vtMyAxY) ;
|
||||
|
||||
// Se i box non interferiscono, posso uscire
|
||||
BBox3d b3Int ;
|
||||
if ( ! b3Zmap.FindIntersection( b3PrismI, b3Int))
|
||||
if ( ! b3Zmap.FindIntersection( b3Prism, b3Int))
|
||||
return true ;
|
||||
|
||||
// Se verifico solo prima mappa
|
||||
if ( ! bPrecise) {
|
||||
// Limiti su indici
|
||||
int nStI = Clamp( int( b3Int.GetMin().x / m_dStep), 0, m_nNx[0] - 1) ;
|
||||
@@ -1716,6 +1625,8 @@ VolZmap::AvoidSimpleRectPrismoid( const Frame3d& frPrismoid, double dLenghtBaseX
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// altrimenti verifico con tutte e tre le mappe
|
||||
else {
|
||||
// Ciclo sulle mappe
|
||||
for ( int nMap = 0 ; nMap < m_nMapNum ; ++ nMap) {
|
||||
|
||||
Reference in New Issue
Block a user