1b85e111dc
- aggiunto calcolo baricentro di Curve - migliorata gestione richiesta nuovo Id - aggiunta intersezione linea-piano e linea-triangolo - corretto errore in PointGrid3d con 1 solo punto (non faceva alcunchè) - aggiunte funzioni di accesso a dati di SurfTM.
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : IntersLinePlane.cpp Data : 18.02.15 Versione : 1.6b7
|
|
// Contenuto : Implementazione della intersezione linea/piano.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 18.02.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "ProjPlane.h"
|
|
#include "/EgtDev/Include/EGkIntersLineTria.h"
|
|
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
IntersLineTria( const Point3d& ptL1, const Point3d& ptL2, const Triangle3d& trTria, Point3d& ptInt)
|
|
{
|
|
Vector3d vtL = ptL2 - ptL1 ;
|
|
double dLen = vtL.Len() ;
|
|
if ( dLen > EPS_SMALL)
|
|
vtL /= dLen ;
|
|
else
|
|
vtL = V_NULL ;
|
|
return IntersLineTria( ptL1, vtL, dLen, trTria, ptInt) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
IntersLineTria( const Point3d& ptL, const Vector3d& vtL, double dLen, const Triangle3d& trTria, Point3d& ptInt)
|
|
{
|
|
// determino il piano del triangolo
|
|
Plane3d plPlane ;
|
|
plPlane.vtN = trTria.GetN() ;
|
|
plPlane.dDist = ( trTria.GetP(0) - ORIG) * plPlane.vtN ;
|
|
// calcolo l'intersezione tra il segmento di linea e il piano del triangolo
|
|
int nRes = IntersLinePlane( ptL, vtL, dLen, plPlane, ptInt) ;
|
|
// se non c'è intersezione
|
|
if ( nRes == ILPT_NO)
|
|
return ILTT_NO ;
|
|
// se c'è una intersezione
|
|
else if ( nRes == ILPT_START || nRes == ILPT_END || nRes == ILPT_YES) {
|
|
int nPTT = PointInTria( ptInt, trTria.GetP(0), trTria.GetP(1), trTria.GetP(2), trTria.GetN()) ;
|
|
switch ( nPTT) {
|
|
case PTT_OUT :
|
|
return ILTT_NO ;
|
|
case PTT_VERT :
|
|
return ILTT_VERT ;
|
|
case PTT_EDGE :
|
|
return ILTT_EDGE ;
|
|
default :
|
|
return ILTT_IN ;
|
|
}
|
|
}
|
|
// se la linea giace nel piano del triangolo
|
|
else {
|
|
// !!!! DA FARE !!!!
|
|
return ILTT_NO ;
|
|
}
|
|
}
|