//---------------------------------------------------------------------------- // EgalTech 2025 //---------------------------------------------------------------------------- // File : DistPointSurfBz.cpp Data : 29.10.25 Versione : 2.7j3 // Contenuto : Implementazione della classe distanza Punto da superficie Bezier. // // // // Modifiche : 29.10.25 DB Creazione modulo. // // //---------------------------------------------------------------------------- #include "stdafx.h" #include "SurfTriMesh.h" #include "SurfBezier.h" #include "/EgtDev/Include/EGkDistPointTria.h" #include "/EgtDev/Include/EGkDistPointSurfTm.h" #include "/EgtDev/Include/EGkDistPointSurfBz.h" #include "/EgtDev/Include/EGkIntersLineTria.h" using namespace std ; //---------------------------------------------------------------------------- DistPointSurfBz::DistPointSurfBz( const Point3d& ptP, const ISurfBezier& pSrfBz) : m_dDist( -1), m_bIsInside( false), m_bIsSurfClosed( false) { // Bezier non valida if ( ! pSrfBz.IsValid()) return ; // Calcolo la distanza Calculate( ptP, pSrfBz) ; } //---------------------------------------------------------------------------- void DistPointSurfBz::Calculate( const Point3d& ptP, const ISurfBezier& srfBz) { // Inizializzo distanza non calcolata m_dDist = -1 ; // Controllo se la superficie è chiusa m_bIsSurfClosed = srfBz.IsClosed() ; // Lavoro con l'oggetto superficie trimesh di base const ISurfTriMesh* pStmRef = srfBz.GetAuxSurfRefined() ; if ( pStmRef == nullptr) return ; DistPointSurfTm dpst( ptP, *pStmRef) ; // recupero il punto a distanza minima sulla trimesh e lo raffino, prima di restituire distanza e punto minimo Point3d ptMinTm ; dpst.GetMinDistPoint( ptMinTm) ; int nT ; dpst.GetMinDistTriaIndex( nT) ; // salvo il punto corrispondente nel parametrico srfBz.UnprojectPointFromStm( nT, ptMinTm, m_ptParam) ; // salvo il punto a minima distanza sulla superficie e la normale alla superficie in quel punto srfBz.GetPointNrmD1D2( m_ptParam.x, m_ptParam.y, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, m_ptMinDistPoint, m_vtN) ; // salvo la distanza minima m_dDist = Dist( ptP, m_ptMinDistPoint) ; // se il punto è sulla superficie if ( m_dDist < EPS_SMALL) { m_bIsInside = false ; return ; } else { m_bIsInside = ( ( ptP - m_ptMinDistPoint) * m_vtN < - EPS_SMALL) ; return ; } } //---------------------------------------------------------------------------- bool DistPointSurfBz::GetDist( double& dDist) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) return false ; // Distanza valida dDist = m_dDist ; return true ; } //---------------------------------------------------------------------------- bool DistPointSurfBz::GetMinDistPoint( Point3d& ptMinDistPoint) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) return false ; // Distanza valida ptMinDistPoint = m_ptMinDistPoint ; return true ; } //---------------------------------------------------------------------------- bool DistPointSurfBz::GetParamsAtMinDistPoint( double& dU, double& dV) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) return false ; // Distanza valida dU = m_ptParam.x ; dV = m_ptParam.y ; return true ; } //---------------------------------------------------------------------------- bool DistPointSurfBz::GetNorm( Vector3d& vtN) const { // Distanza non valida if ( m_dDist < -EPS_ZERO) return false ; // Distanza valida vtN = m_vtN ; return true ; }