added assert for discouraging inconsistent triangleplane intersection

This commit is contained in:
Paolo Cignoni 2011-11-21 08:54:35 +00:00
parent 20ec79715b
commit 4c4d505b6f
1 changed files with 8 additions and 3 deletions

View File

@ -269,6 +269,8 @@ namespace vcg {
/// intersection between plane and triangle
// not optimal: uses plane-segment intersection (and the fact the two or none edges can be intersected)
// its use is rather dangerous because it can return inconsistent stuff on degenerate cases.
// added assert to underline this danger.
template<typename TRIANGLETYPE>
inline bool IntersectionPlaneTriangle( const Plane3<typename TRIANGLETYPE::ScalarType> & pl,
const TRIANGLETYPE & tr,
@ -280,15 +282,18 @@ namespace vcg {
return true;
else
{
IntersectionPlaneSegment(pl,Segment3<T>(tr.P(1),tr.P(2)),sg.P1());
return true;
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(1),tr.P(2)),sg.P1()))
return true;
else assert(0);
return true;
}
}
else
{
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(1),tr.P(2)),sg.P0()))
{
IntersectionPlaneSegment(pl,Segment3<T>(tr.P(0),tr.P(2)),sg.P1());
if(IntersectionPlaneSegment(pl,Segment3<T>(tr.P(0),tr.P(2)),sg.P1()))return true;
assert(0);
return true;
}
}