e1e3da7f24
- correzione a ExeGetFileType (funzionava solo se path completa) - modifiche a ExePointCurveDist e ExePointCurveD, aggiunta ExePointSurfTmDist - aggiunte funzioni lua EgtPointCurveDist e EgtPointSurfTmDist - cambiati nomi di funzioni Exe e Lua di intersezione (prima sempre entità più semplice).
125 lines
4.5 KiB
C++
125 lines
4.5 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2018-2018
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_GeoDist.cpp Data : 15.12.18 Versione : 1.9l
|
|
// Contenuto : Funzioni di distanza tra oggetto geometrici per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 15.12.18 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Const.h"
|
|
#include "EXE_Macro.h"
|
|
#include "AuxTools.h"
|
|
#include "GeoTools.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
|
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
ExePointCurveDist( const Point3d& ptP, int nCurveId, int nRefType,
|
|
double* pdDist, Point3d& ptMin, double* pdU)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// verifico il primo parametro di ritorno obbligatorio
|
|
if ( pdDist == nullptr)
|
|
return false ;
|
|
// recupero la curva
|
|
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ;
|
|
if ( pCurve == nullptr)
|
|
return false ;
|
|
// recupero il suo riferimento globale
|
|
Frame3d frCurve ;
|
|
if ( ! pGeomDB->GetGlobFrame( nCurveId, frCurve))
|
|
return false ;
|
|
// porto il punto nel riferimento della curva
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frCurve) ;
|
|
// calcolo la minima distanza
|
|
DistPointCurve distPC( ptPL, *pCurve) ;
|
|
// recupero i risultati
|
|
if ( ! distPC.GetDist( *pdDist))
|
|
return false ;
|
|
MinDistPCInfo aInfo ;
|
|
if ( ! distPC.GetMinDistInfo( 0, aInfo))
|
|
return false ;
|
|
if ( &ptMin != nullptr)
|
|
ptMin = GetPointInRef( pGeomDB, aInfo.ptQ, frCurve, nRefType) ;
|
|
if ( pdU != nullptr)
|
|
*pdU = aInfo.dPar ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
ExePointCurveDistSide( const Point3d& ptP, int nCurveId, const Vector3d& vtN, int nRefType,
|
|
double* pdDist, Point3d& ptMin, int* pnSide)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// verifico i parametri di ritorno
|
|
if ( pdDist == nullptr || &ptMin == nullptr || pnSide == nullptr)
|
|
return false ;
|
|
// recupero la curva
|
|
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ;
|
|
if ( pCurve == nullptr)
|
|
return false ;
|
|
// recupero il suo riferimento globale
|
|
Frame3d frCurve ;
|
|
if ( ! pGeomDB->GetGlobFrame( nCurveId, frCurve))
|
|
return false ;
|
|
// porto il punto e la normale nel riferimento della curva
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frCurve) ;
|
|
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frCurve) ;
|
|
// calcolo la minima distanza
|
|
DistPointCurve distPC( ptPL, *pCurve) ;
|
|
// recupero i risultati
|
|
if ( ! distPC.GetDist( *pdDist))
|
|
return false ;
|
|
Point3d ptMinL ; int nFlag ;
|
|
if ( ! distPC.GetMinDistPoint( 0, ptMinL, nFlag))
|
|
return false ;
|
|
ptMin = GetPointInRef( pGeomDB, ptMinL, frCurve, nRefType) ;
|
|
return distPC.GetSideAtMinDistPoint( 0, vtNL, *pnSide) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
ExePointSurfTmDist( const Point3d& ptP, int nStmId, int nRefType,
|
|
double* pdDist, Point3d& ptMin, int* pnTria)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// verifico il primo parametro di ritorno obbligatorio
|
|
if ( pdDist == nullptr)
|
|
return false ;
|
|
// recupero la superficie trimesh
|
|
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nStmId)) ;
|
|
if ( pStm == nullptr)
|
|
return false ;
|
|
// recupero il suo riferimento globale
|
|
Frame3d frStm ;
|
|
if ( ! pGeomDB->GetGlobFrame( nStmId, frStm))
|
|
return false ;
|
|
// porto il punto nel riferimento della superficie
|
|
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frStm) ;
|
|
// recupero i risultati
|
|
DistPointSurfTm distPS( ptPL, *pStm) ;
|
|
if ( ! distPS.GetDist( *pdDist))
|
|
return false ;
|
|
Point3d ptMinL ;
|
|
if ( ! distPS.GetMinDistPoint( ptMinL))
|
|
return false ;
|
|
ptMin = GetPointInRef( pGeomDB, ptMinL, frStm, nRefType) ;
|
|
return distPS.GetMinDistTriaIndex( *pnTria) ;
|
|
}
|