420a82b278
- aggiunte funzioni per intersezione Linea-Box e Piano-Box.
62 lines
2.0 KiB
C++
62 lines
2.0 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2020-2020
|
|
//----------------------------------------------------------------------------
|
|
// File : IntersLineBox.cpp Data : 07.05.20 Versione : 2.2e1
|
|
// Contenuto : Implementazione della intersezione linea/box.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 07.05.20 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "SurfTriMesh.h"
|
|
#include "/EgtDev/Include/EGkIntersPlaneBox.h"
|
|
#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
IntersPlaneBox( const Point3d& ptOn, const Vector3d& vtN, const BBox3d& b3Box,
|
|
PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria)
|
|
{
|
|
// Creo il piano
|
|
Plane3d plPlane ;
|
|
if ( ! plPlane.Set( ptOn, vtN))
|
|
return false ;
|
|
// Recupero i dati del Box
|
|
Point3d ptMin ;
|
|
double dDimX, dDimY, dDimZ ;
|
|
if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimZ))
|
|
return false ;
|
|
// Contorno di base
|
|
PolyLine PL ;
|
|
PL.AddUPoint( 0, ptMin) ;
|
|
PL.AddUPoint( 1, ptMin + Vector3d( dDimX, 0, 0)) ;
|
|
PL.AddUPoint( 2, ptMin + Vector3d( dDimX, dDimY, 0)) ;
|
|
PL.AddUPoint( 3, ptMin + Vector3d( 0, dDimY, 0)) ;
|
|
PL.Close() ;
|
|
// Vettore altezza
|
|
Vector3d vtExtr( 0, 0, dDimZ) ;
|
|
// Creo la superficie trimesh equivalente
|
|
SurfTriMesh Stm ;
|
|
if ( ! Stm.CreateByExtrusion( PL, vtExtr))
|
|
return false ;
|
|
SurfTriMesh StmBot ;
|
|
if ( ! StmBot.CreateByFlatContour( PL))
|
|
return false ;
|
|
StmBot.Invert() ;
|
|
SurfTriMesh StmTop ;
|
|
if ( ! StmTop.CreateByFlatContour( PL))
|
|
return false ;
|
|
StmTop.Translate( vtExtr) ;
|
|
if ( ! Stm.DoSewing( StmBot) || ! Stm.DoSewing( StmTop))
|
|
return false ;
|
|
// Calcolo l'intersezione
|
|
return IntersPlaneSurfTm( plPlane, Stm, vPnt, vBpt, vTria) ;
|
|
}
|