EgtGeomKernel 2.2f5 :
- migliorie a intersezione coplanare linea triangolo per booleane di superfici trimesh - modifiche a costruzione superfici trimesh da zuppa di triangoli per gestire il doppio colore.
This commit is contained in:
+53
-54
@@ -97,8 +97,7 @@ IntersCoplanarLineTria( const Point3d& ptL, const Vector3d& vtL, double dLen, co
|
||||
}
|
||||
// Se segmento, calcolo le distanze dei suoi estremi dai lati del triangolo
|
||||
int nSegOnSide = -1 ;
|
||||
// if ( bFinite) {
|
||||
if ( false) {
|
||||
if ( bFinite) {
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
// Versore del lato del triangolo
|
||||
Vector3d vtSideDir = trTria.GetP( ( i + 1) % 3) - trTria.GetP( i) ;
|
||||
@@ -167,6 +166,58 @@ IntersCoplanarLineTria( const Point3d& ptL, const Vector3d& vtL, double dLen, co
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti due vertici del triangolo giacciono sulla linea
|
||||
else if ( nVertPos + nVertNeg == 1) {
|
||||
// Determino i vertici sulla linea
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
if ( vPos[i] == 0) {
|
||||
if ( nCount == 0)
|
||||
ptInt = trTria.GetP( i) ;
|
||||
else
|
||||
ptInt2 = trTria.GetP( i) ;
|
||||
nCount ++ ;
|
||||
}
|
||||
}
|
||||
// Ordino i vertici sulla linea
|
||||
double dUmin = ( ptInt - ptL) * vtL ;
|
||||
double dUmax = ( ptInt2 - ptL) * vtL ;
|
||||
if ( dUmin > dUmax) {
|
||||
swap( dUmin, dUmax) ;
|
||||
swap( ptInt, ptInt2) ;
|
||||
}
|
||||
// Per garantire l'appartenenza dei punti alla linea li ricalcolo
|
||||
ptInt = ptL + dUmin * vtL ;
|
||||
ptInt2 = ptL + dUmax * vtL ;
|
||||
// Se linea infinita
|
||||
if ( ! bFinite) {
|
||||
return ILTT_SEGM_ON_EDGE ;
|
||||
}
|
||||
// Altrimenti linea finita
|
||||
else {
|
||||
// se massimo coincide con inizio segmento di retta
|
||||
if ( abs( dUmax) < EPS_SMALL) {
|
||||
ptInt = ptInt2 ;
|
||||
return ILTT_VERT ;
|
||||
}
|
||||
// se minimo coincide con fine segmento di retta
|
||||
else if ( abs( dUmin - dLen) < EPS_SMALL) {
|
||||
return ILTT_VERT ;
|
||||
}
|
||||
// se segmento non si sovrappone
|
||||
else if ( dUmax < 0 || dUmin > dLen) {
|
||||
return ILTT_NO ;
|
||||
}
|
||||
// altrimenti sovrapposizione parziale
|
||||
else {
|
||||
if ( dUmin < 0)
|
||||
ptInt = ptL ;
|
||||
if ( dUmax > dLen)
|
||||
ptInt2 = ptL + vtL * dLen ;
|
||||
return ILTT_SEGM_ON_EDGE ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti due estremi del segmento giacciono su un lato del triangolo
|
||||
else if ( nSegOnSide == 0 || nSegOnSide == 1 || nSegOnSide == 2) {
|
||||
// Punto iniziale e versore del segmento del triangolo orientato secondo il segmento
|
||||
@@ -208,58 +259,6 @@ IntersCoplanarLineTria( const Point3d& ptL, const Vector3d& vtL, double dLen, co
|
||||
return ILTT_SEGM_ON_EDGE ;
|
||||
}
|
||||
}
|
||||
// se altrimenti due vertici del triangolo giacciono sulla linea
|
||||
else if ( nVertPos + nVertNeg == 1) {
|
||||
// Determino i vertici sulla linea
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < 3 ; ++i) {
|
||||
if ( vPos[i] == 0) {
|
||||
if ( nCount == 0)
|
||||
ptInt = trTria.GetP( i) ;
|
||||
else
|
||||
ptInt2 = trTria.GetP( i) ;
|
||||
nCount ++ ;
|
||||
}
|
||||
}
|
||||
// Ordino i vertici sulla linea
|
||||
double dUmin = ( ptInt - ptL) * vtL ;
|
||||
double dUmax = ( ptInt2 - ptL) * vtL ;
|
||||
if ( dUmin > dUmax) {
|
||||
swap( dUmin, dUmax) ;
|
||||
swap( ptInt, ptInt2) ;
|
||||
}
|
||||
// Per garantire l'appartenenza dei punti alla linea li ricalcolo
|
||||
ptInt = ptL + dUmin * vtL ;
|
||||
ptInt2 = ptL + dUmax * vtL ;
|
||||
// Se linea infinita
|
||||
if ( ! bFinite) {
|
||||
return ILTT_SEGM_ON_EDGE ;
|
||||
}
|
||||
// Altrimenti linea finita
|
||||
else {
|
||||
// se massimo coincide con inizio segmento di retta
|
||||
if ( abs( dUmax) < EPS_SMALL) {
|
||||
ptInt = ptInt2 ;
|
||||
return ILTT_VERT ;
|
||||
}
|
||||
// se minimo coincide con fine segmento di retta
|
||||
else if ( abs ( dUmin - dLen) < EPS_SMALL) {
|
||||
return ILTT_VERT ;
|
||||
}
|
||||
// se segmento non si sovrappone
|
||||
else if ( dUmax < 0 || dUmin > dLen) {
|
||||
return ILTT_NO ;
|
||||
}
|
||||
// altrimenti sovrapposizione parziale
|
||||
else {
|
||||
if ( dUmin < 0)
|
||||
ptInt = ptL ;
|
||||
if ( dUmax > dLen)
|
||||
ptInt2 = ptL + vtL * dLen ;
|
||||
return ILTT_SEGM_ON_EDGE ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se altrimenti un vertice del triangolo giace sulla retta e gli altri due sono dalla stessa parte
|
||||
else if ( ( nVertPos == 2 && nVertNeg == 0) || ( nVertPos == 0 && nVertNeg == 2)) {
|
||||
// Determino quale è il vertice sulla linea
|
||||
|
||||
Reference in New Issue
Block a user