From ea1ea88a17f35efc0a2664d84477af91aea5b7f5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 19 Sep 2005 13:15:59 +0000 Subject: [PATCH] Added countMultipleIntersections to help with debugging. --- src/osgSim/SphereSegment.cpp | 46 ++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/osgSim/SphereSegment.cpp b/src/osgSim/SphereSegment.cpp index 27c33bf01..ef1c5fe59 100644 --- a/src/osgSim/SphereSegment.cpp +++ b/src/osgSim/SphereSegment.cpp @@ -1383,7 +1383,7 @@ struct TriangleIntersectOperator if (region._topSurface == Region::INTERSECTS) ++_intersects_topSurface; } - Region::Classification overallClassification() + Region::Classification overallClassification() const { // if all vertices are outside any of the surfaces then we are completely outside if (_outside_radiusSurface==_numVertices || @@ -1401,6 +1401,17 @@ struct TriangleIntersectOperator return Region::INTERSECTS; } + + int numberOfIntersectingSurfaces() const + { + int sidesThatIntersect = 0; + if (_outside_radiusSurface!=_numVertices && _inside_radiusSurface!=_numVertices) ++sidesThatIntersect; + if (_outside_leftSurface!=_numVertices && _inside_leftSurface!=_numVertices) ++sidesThatIntersect; + if (_outside_rightSurface!=_numVertices && _inside_rightSurface!=_numVertices) ++sidesThatIntersect; + if (_outside_topSurface!=_numVertices && _inside_topSurface!=_numVertices) ++sidesThatIntersect; + if (_outside_bottomSurface!=_numVertices && _inside_bottomSurface!=_numVertices) ++sidesThatIntersect; + return sidesThatIntersect; + } unsigned int _numVertices; unsigned int _outside_radiusSurface; @@ -1661,7 +1672,36 @@ struct TriangleIntersectOperator return edge; } } - + + void countMultipleIntersections() const + { + osg::notify(osg::NOTICE)<<"countMultipleIntersections("<get(); + RegionCounter rc; + rc.add(_regions[tri->_p1]); + rc.add(_regions[tri->_p2]); + rc.add(_regions[tri->_p3]); + int numIntersections = rc.numberOfIntersectingSurfaces(); + if (numIntersections==0) ++numZero; + else if (numIntersections==1) ++numOne; + else if (numIntersections==2) ++numTwo; + else if (numIntersections>=3) ++numMore; + } + osg::notify(osg::NOTICE)<<" numZero "<