EgtGeomKernel :
- aggiunta funzione di raffinamento dei punti di intersezione per Bezier.
This commit is contained in:
+71
-43
@@ -18,6 +18,7 @@
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfBez.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Extern/Eigen/Dense"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -48,61 +49,88 @@ IntersLineSurfBz( const Point3d& ptL, const Vector3d& vtL, double dLen, const IS
|
||||
|
||||
// ricavo le intersezioni con la superficie di Bezier
|
||||
for ( IntLinStmInfo InfoTm : vInfoTm ) {
|
||||
int nIL, nTT ;
|
||||
// devo raffinare i parametri lungo la curva, l'angolo e i punti di intersezione
|
||||
double dUU, dUU2, dCos ;
|
||||
Point3d ptP, ptP2, ptSP, ptSP2 ;
|
||||
IntLinSbzInfo InfoBz( InfoTm.nILTT, dUU, dUU2, nTT, dCos, ptP, ptP2, ptSP, ptSP2) ;
|
||||
Point3d ptI, ptI2 ;
|
||||
// devo trovare le intersezioni
|
||||
Point3d ptSP, ptSP2 ;
|
||||
RefinePoints( pSurfTm, InfoTm.nILTT, InfoTm.nT, ptI, ptI2,ptSP, ptSP2) ;
|
||||
IntLinSbzInfo InfoBz( InfoTm.nILTT, dUU, dUU2, InfoTm.nT, dCos, InfoTm.ptI, InfoTm.ptI2, ptSP, ptSP2) ;
|
||||
vInfo.emplace_back( InfoBz) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////// interlineSurfTm
|
||||
|
||||
|
||||
// limito la linea al box dei triangoli della superficie
|
||||
BBox3d b3Stm = Stm.GetAllTriaBox() ;
|
||||
if ( b3Stm.IsEmpty())
|
||||
return false ;
|
||||
// lo ingrandisco per non avere problemi con faccia piana su piani canonici
|
||||
b3Stm.Expand( 10 * EPS_SMALL) ;
|
||||
double dU1, dU2 ;
|
||||
if ( ! IntersLineBox( ptL, vtL, b3Stm.GetMin() , b3Stm.GetMax(), dU1, dU2))
|
||||
return true ;
|
||||
if ( bFinite) {
|
||||
dU1 = max( dU1, 0.) ;
|
||||
dU2 = min( dU2, dLen) ;
|
||||
if ( dU2 - dU1 < EPS_SMALL)
|
||||
return true ;
|
||||
}
|
||||
Point3d ptStart = ptL + dU1 * vtL ;
|
||||
double dLenEff = dU2 - dU1 ;
|
||||
// cerco i triangoli intersecati dalla linea
|
||||
const double BOX_STEP = 10 ;
|
||||
int nStep = int( ceil( dLenEff / BOX_STEP)) ;
|
||||
Vector3d vtStep = dLenEff / nStep * vtL ;
|
||||
INTVECTOR vPrevT ;
|
||||
for ( int i = 0 ; i < nStep ; ++ i) {
|
||||
BBox3d b3Box( ptStart + i * vtStep, ptStart + ( i + 1) * vtStep) ;
|
||||
INTVECTOR vT ;
|
||||
if ( Stm.GetAllTriaOverlapBox( b3Box, vT)) {
|
||||
for ( auto nT : vT) {
|
||||
if ( find( vPrevT.begin(), vPrevT.end(), nT) == vPrevT.end()) {
|
||||
vPrevT.emplace_back( nT) ;
|
||||
Triangle3d Tria ;
|
||||
Stm.GetTriangle( nT, Tria) ;
|
||||
// aggiorno info con intersezione
|
||||
UpdateInfoIntersLineSurfTm( ptL, vtDir, dLen, nT, Tria, vInfo, bFinite) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//// limito la linea al box dei triangoli della superficie
|
||||
// BBox3d b3Stm = Stm.GetAllTriaBox() ;
|
||||
// if ( b3Stm.IsEmpty())
|
||||
// return false ;
|
||||
//// lo ingrandisco per non avere problemi con faccia piana su piani canonici
|
||||
// b3Stm.Expand( 10 * EPS_SMALL) ;
|
||||
// double dU1, dU2 ;
|
||||
// if ( ! IntersLineBox( ptL, vtL, b3Stm.GetMin() , b3Stm.GetMax(), dU1, dU2))
|
||||
// return true ;
|
||||
// if ( bFinite) {
|
||||
// dU1 = max( dU1, 0.) ;
|
||||
// dU2 = min( dU2, dLen) ;
|
||||
// if ( dU2 - dU1 < EPS_SMALL)
|
||||
// return true ;
|
||||
// }
|
||||
// Point3d ptStart = ptL + dU1 * vtL ;
|
||||
// double dLenEff = dU2 - dU1 ;
|
||||
//// cerco i triangoli intersecati dalla linea
|
||||
// const double BOX_STEP = 10 ;
|
||||
// int nStep = int( ceil( dLenEff / BOX_STEP)) ;
|
||||
// Vector3d vtStep = dLenEff / nStep * vtL ;
|
||||
// INTVECTOR vPrevT ;
|
||||
// for ( int i = 0 ; i < nStep ; ++ i) {
|
||||
// BBox3d b3Box( ptStart + i * vtStep, ptStart + ( i + 1) * vtStep) ;
|
||||
// INTVECTOR vT ;
|
||||
// if ( Stm.GetAllTriaOverlapBox( b3Box, vT)) {
|
||||
// for ( auto nT : vT) {
|
||||
// if ( find( vPrevT.begin(), vPrevT.end(), nT) == vPrevT.end()) {
|
||||
// vPrevT.emplace_back( nT) ;
|
||||
// Triangle3d Tria ;
|
||||
// Stm.GetTriangle( nT, Tria) ;
|
||||
// // aggiorno info con intersezione
|
||||
// UpdateInfoIntersLineSurfTm( ptL, vtDir, dLen, nT, Tria, vInfo, bFinite) ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// ordino il vettore delle eventuali intersezioni secondo il senso crescente del parametro di linea
|
||||
OrderInfoIntersLineSurfTm( vInfo) ;
|
||||
//// ordino il vettore delle eventuali intersezioni secondo il senso crescente del parametro di linea
|
||||
// OrderInfoIntersLineSurfTm( vInfo) ;
|
||||
|
||||
return true ;
|
||||
// return true ;
|
||||
|
||||
//////////////////////////////////////////////////////// interlineSurfTm
|
||||
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// raffino i punti di intersezione e recupero le rispettive coordinate nello spazio parametrico
|
||||
bool
|
||||
RefinePoints( const ISurfTriMesh* pSurfTm ,int nIL, int nT, Point3d& ptI, Point3d& ptI2, Point3d& ptSP, Point3d& ptSP2) {
|
||||
int nVert[3] ;
|
||||
pSurfTm->GetTriangle( nT, nVert) ;
|
||||
double dU0, dV0, dU1, dV1,dU2, dV2 ;
|
||||
pSurfTm->GetVertexParam( nVert[0], dU0, dV0) ;
|
||||
pSurfTm->GetVertexParam( nVert[1], dU1, dV1) ;
|
||||
pSurfTm->GetVertexParam( nVert[2], dU2, dV2) ;
|
||||
Point3d pt0, pt1, pt2 ;
|
||||
pSurfTm->GetVertex( nVert[0], pt0) ;
|
||||
pSurfTm->GetVertex( nVert[1], pt1) ;
|
||||
pSurfTm->GetVertex( nVert[2], pt2) ;
|
||||
Eigen::Matrix3d m3x3 ;
|
||||
//m3x3 << pt0.x, pt1.x, pt2.x, pt0.y, pt1.y, pt2.y, pt0.z, pt1.z, pt2.z ;
|
||||
m3x3.col(0) << pt0.x, pt0.y , pt0.z ;
|
||||
m3x3.col(1) << pt1.x, pt1.y , pt1.z ;
|
||||
m3x3.col(2) << pt2.x, pt2.y , pt2.z ;
|
||||
Eigen::Vector3d b ( ptI.x, ptI.y, ptI.z) ;
|
||||
Eigen::Vector3d x = m3x3.fullPivLu().solve(b) ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user