diff --git a/DistPointSurfBz.cpp b/DistPointSurfBz.cpp new file mode 100644 index 0000000..0495786 --- /dev/null +++ b/DistPointSurfBz.cpp @@ -0,0 +1,119 @@ +//---------------------------------------------------------------------------- +// 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) +{ + // Bezier non valida + if ( &pSrfBz == nullptr || ! 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 / SBZ_TREG_COEFF, m_ptParam.y / SBZ_TREG_COEFF, 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::GetParamPoint( Point3d& ptParamPoint) const +{ + // Distanza non valida + if ( m_dDist < -EPS_ZERO) + return false ; + // Distanza valida + ptParamPoint = m_ptParam ; + 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 ; +} \ No newline at end of file diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index d71a302..739262b 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -310,6 +310,7 @@ copy $(TargetPath) \EgtProg\Dll64 + false diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index 30abde1..2a98ac7 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -555,6 +555,9 @@ File di origine\Gdb + + File di origine\GeoDist + diff --git a/SurfBezier.cpp b/SurfBezier.cpp index afa43f5..482f580 100644 --- a/SurfBezier.cpp +++ b/SurfBezier.cpp @@ -3177,7 +3177,7 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in } // se l'intersezione era su un vertice ( NON DI POLO) restituisco le coordinate parametriche del vertice - if ( nIL == 3 && ! bIsPole) { + if ( nIL == IntLineTriaType::ILTT_VERT && ! bIsPole) { if ( AreSamePointApprox(ptI, vPT[0])) ptSP = vPtPa[0] ; else if ( AreSamePointApprox(ptI, vPT[1])) @@ -3243,7 +3243,7 @@ SurfBezier::UnprojectPoint( const Point3d& pt3D, Point3d& ptParam, const Point3d // per trovare il primo punto trovo il triangolo della trimesh ausiliaria più vicino e il punto più vicino DistPointSurfTm dptSurfTm( pt3D, *GetAuxSurfRefined()) ; Point3d ptI ; dptSurfTm.GetMinDistPoint( ptI) ; - if ( ! UnprojectPointFromStm( -1, ptI, ptParam, 5, ptIPrev, bThroughEdge)) + if ( ! UnprojectPointFromStm( -1, ptI, ptParam, IntLineTriaType::ILTT_IN, ptIPrev, bThroughEdge)) return false ; Point3d ptBez ; GetPointD1D2( ptParam.x / SBZ_TREG_COEFF, ptParam.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, ptBez) ; diff --git a/SurfBezier.h b/SurfBezier.h index 6d5af31..00b6a1f 100644 --- a/SurfBezier.h +++ b/SurfBezier.h @@ -20,6 +20,7 @@ #include "SurfTriMesh.h" #include "SurfFlatRegion.h" #include "/EgtDev/Include/EGkSurfBezier.h" +#include "/EgtDev/Include/EGkIntersLineTria.h" #include "/EgtDev/Include/EGkGeoCollection.h" //---------------------------------------------------------------------------- @@ -120,8 +121,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW bool GetLeaves( std::vector>& vLeaves) const override ; bool GetTriangles2D( std::vector>& vTria2D) const override ; // funzioni che servono per ricavare l'immagine nel parametrico di un punto appartenente alla trimesh ausiliaria della superficie di Bezier - // a nIL si può passare 5 come valore di default - bool UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, int nIL = 5) const override ; + bool UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, int nIL = IntLineTriaType::ILTT_IN) const override ; bool UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, int nIL, const Point3d& ptIPrev, bool* bTroughEdge = nullptr) const override ; // restituisce il corrispettivo parametrico di un punto qualunque della trimesh associata alla superficie // ptIPrev è un punto addizionale che precede o segue il punto pt3D nel caso in cui il punto faccia parte di una curva 3d sulla superficie