451ef8356b
- aggiunta funzione IntersCurveSurfTm - funzioni di intersezione Line e Plane con Zmap separate dall'oggetto per l'interfaccia
107 lines
4.1 KiB
C++
107 lines
4.1 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2024-2024
|
|
//----------------------------------------------------------------------------
|
|
// File : IntersLineVolZmap.cpp Data : 22.02.24 Versione : 2.6b4
|
|
// Contenuto : Implementazione della intersezione linea/VolZmap.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 22.02.24 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "VolZmap.h"
|
|
#include "/EgtDev/Include/EGkIntersLineVolZmap.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
// Intersezione di una linea con la superficie di un solido VolZmap
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
IntersLineVolZmap( const Point3d& ptL, const Vector3d& vtL, const IVolZmap& Vzm, ILZIVECTOR& vInfo)
|
|
{
|
|
// verifico linea
|
|
Vector3d vtDir = vtL ;
|
|
if ( ! vtDir.Normalize( EPS_ZERO))
|
|
return false ;
|
|
// verifico volume
|
|
const VolZmap* pVzm = GetBasicVolZmap( &Vzm) ;
|
|
if ( pVzm == nullptr)
|
|
return false ;
|
|
// verifico parametro di ritorno
|
|
if ( &vInfo == nullptr)
|
|
return false ;
|
|
|
|
// eseguo intersezione
|
|
return pVzm->GetLineIntersection( ptL, vtL, vInfo) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
FilterLineVolZmapInters( const ILZIVECTOR& vInfo, INTDBLVECTOR& vInters)
|
|
{
|
|
// ciclo sulle intersezioni
|
|
for ( const auto& Info : vInfo) {
|
|
// se intersezione puntuale
|
|
if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) {
|
|
int nFlag = LZT_TOUCH ;
|
|
if ( Info.dCosDN > EPS_ZERO)
|
|
nFlag = LZT_OUT ;
|
|
else if ( Info.dCosDN < -EPS_ZERO)
|
|
nFlag = LZT_IN ;
|
|
vInters.emplace_back( nFlag, Info.dU) ;
|
|
}
|
|
// se altrimenti intersezione con coincidenza
|
|
else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) {
|
|
vInters.emplace_back( LZT_TG_INI, Info.dU) ;
|
|
vInters.emplace_back( LZT_TG_FIN, Info.dU2) ;
|
|
}
|
|
}
|
|
// elimino intersezioni ripetute
|
|
for ( size_t j = 1 ; j < vInters.size() ; ) {
|
|
// intersezione precedente
|
|
size_t i = j - 1 ;
|
|
// se hanno lo stesso parametro
|
|
if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) {
|
|
// se sono entrambe entranti o uscenti, elimino la seconda
|
|
if ( ( vInters[i].first == LZT_IN && vInters[j].first == LZT_IN) ||
|
|
( vInters[i].first == LZT_OUT && vInters[j].first == LZT_OUT)) {
|
|
vInters.erase( vInters.begin() + j) ;
|
|
continue ;
|
|
}
|
|
// se una entrante e l'altra uscente, cambio in touch ed elimino la seconda
|
|
else if ( ( vInters[i].first == LZT_IN && vInters[j].first == LZT_OUT) ||
|
|
( vInters[i].first == LZT_OUT && vInters[j].first == LZT_IN)) {
|
|
vInters[i].first = LZT_TOUCH ;
|
|
vInters.erase( vInters.begin() + j) ;
|
|
continue ;
|
|
}
|
|
// se una puntuale e l'altra inizio di coincidenza, elimino la prima
|
|
else if ( ( vInters[i].first == LZT_IN || vInters[i].first == LZT_OUT || vInters[i].first == LZT_TOUCH) && vInters[j].first == LZT_TG_INI) {
|
|
vInters.erase( vInters.begin() + i) ;
|
|
continue ;
|
|
}
|
|
// se una fine di coincidenza e l'altra puntuale, elimino la seconda
|
|
else if ( vInters[i].first == LZT_TG_FIN && ( vInters[j].first == LZT_IN || vInters[j].first == LZT_OUT || vInters[j].first == LZT_TOUCH)) {
|
|
vInters.erase( vInters.begin() + j) ;
|
|
continue ;
|
|
}
|
|
// se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe
|
|
else if ( i > 0 && vInters[i].first == LZT_TG_FIN && vInters[j].first == LZT_TG_INI) {
|
|
vInters.erase( vInters.begin() + j) ;
|
|
vInters.erase( vInters.begin() + i) ;
|
|
-- j ;
|
|
continue ;
|
|
}
|
|
}
|
|
// passo alla successiva
|
|
++ j ;
|
|
}
|
|
|
|
return true ;
|
|
}
|