//---------------------------------------------------------------------------- // EgalTech 2015-2015 //---------------------------------------------------------------------------- // File : IntersLineSurfTm.cpp Data : 09.03.15 Versione : 1.6b8 // Contenuto : Implementazione della intersezione linea/superficie trimesh. // // // // Modifiche : 09.03.15 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "ProjPlane.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkIntersLineTria.h" #include "/EgtDev/Include/EGkIntersLineSurfTm.h" using namespace std ; //---------------------------------------------------------------------------- bool IntersLineSurfTm( const Point3d& ptL, const Vector3d& vtL, double dLen, const ISurfTriMesh& Stm, ILSIVECTOR& vInfo) { // verifico linea Vector3d vtDir = vtL ; if ( ! vtDir.Normalize( EPS_ZERO)) return false ; // verifico superficie if ( &Stm == nullptr) return false ; // verifico parametro di ritorno if ( &vInfo == nullptr) return false ; // cerco i triangoli intersecati dalla linea Triangle3d Tria ; int nT = Stm.GetFirstTriangle( Tria) ; while ( nT != SVT_NULL) { Point3d ptInt, ptInt2 ; int nRes = IntersLineTria( ptL, vtDir, dLen, Tria, ptInt, ptInt2) ; if ( nRes == ILTT_IN || nRes == ILTT_EDGE || nRes == ILTT_VERT) { double dU = ( ptInt - ptL) * vtDir ; vInfo.emplace_back( dU, nT, ptInt) ; } nT = Stm.GetNextTriangle( nT, Tria) ; } // se non trovati, esco if ( vInfo.size() == 0) return true ; // ordino il vettore delle intersezioni secondo il senso crescente del parametro di linea sort( vInfo.begin(), vInfo.end(), []( const IntLinStmInfo& a, const IntLinStmInfo&b) { return a.dU < b.dU ; }) ; return true ; }