diff --git a/src/osgSim/ElevationSlice.cpp b/src/osgSim/ElevationSlice.cpp index 27971a2e2..de4a495c1 100644 --- a/src/osgSim/ElevationSlice.cpp +++ b/src/osgSim/ElevationSlice.cpp @@ -77,7 +77,7 @@ struct DistanceHeightCalculator _radiusList.push_back(newRadius); _distanceList.push_back(distance); - // osg::notify(osg::NOTICE)<<" newVector = "<position; + _em->convertXYZToLatLongHeight(p.x(), p.y(), p.z(), latitude, longitude, height); + double delta1 = height - s._p1->height; + + p = s._p1->position; + _em->convertXYZToLatLongHeight(p.x(), p.y(), p.z(), latitude, longitude, height); + double delta2 = height - s._p2->height; + + if (delta1>0.0 || delta2>0.0) + { + osg::notify(osg::INFO)<<" "<<&s<<" computed height delta ="<=Segment::OVERLAPPING) { - SegmentSet::iterator tempItr = nextItr; - ++nextItr; - _segments.erase(tempItr); + switch(classification) + { + case(Segment::OVERLAPPING): + { + // cases.... + // compute new end points for both segments + // need to work out which points are overlapping - lhs_p2 && rhs_p1 or lhs_p1 and rhs_p2 + // also need to check for cross cases. + + const Segment& lhs = *itr; + const Segment& rhs = *nextItr; + + bool rhs_p1_inside = (lhs._p1->distance <= rhs._p1->distance) && (rhs._p1->distance <= lhs._p2->distance); + bool lhs_p2_inside = (rhs._p1->distance <= lhs._p2->distance) && (lhs._p2->distance <= rhs._p2->distance); + + if (rhs_p1_inside && lhs_p2_inside) + { + double distance_between = osg::Vec2d(lhs._p2->distance - rhs._p1->distance, + lhs._p2->height - rhs._p1->height).length2(); + + if (distance_between < epsilon) + { + // osg::notify(osg::INFO)<<"OVERLAPPING : distance_between acceptable "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<= 0.0 && dh2 >= 0.0) + { + osg::notify(osg::INFO)<<"OVERLAPPING : lhs above rhs "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<=0.0 && dh2>=0.0) + { + osg::notify(osg::INFO)<<"ENCLOSING: ENCLOSING is below enclosed "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<=0.0 && dh2>=0.0) + { + osg::notify(osg::INFO)<<"ENCLOSED: ENCLOSING is below enclosed "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<compare(*nextItr) : Segment::UNCLASSIFIED; } } } @@ -340,7 +623,7 @@ struct LineConstructor ++nextItr; unsigned int numOverlapping = 0; - while (nextItr!=_segments.end() && startItr->compare(*nextItr)==Segment::OVERLAPPING) + while (nextItr!=_segments.end() && startItr->compare(*nextItr)>=Segment::OVERLAPPING) { ++numOverlapping; ++nextItr; @@ -391,6 +674,8 @@ struct LineConstructor SegmentSet _segments; osg::ref_ptr _previousPoint; + osg::Plane _plane; + osg::ref_ptr _em; }; @@ -420,13 +705,13 @@ void ElevationSlice::computeIntersections(osg::Node* scene) em->convertXYZToLatLongHeight(_startPoint.x(), _startPoint.y(), _startPoint.z(), start_latitude, start_longitude, start_height); - osg::notify(osg::NOTICE)<<"start_lat = "< geode = new osg::Geode; @@ -544,6 +826,8 @@ void ElevationSlice::computeIntersections(osg::Node* scene) #endif ElevationSliceUtils::LineConstructor constructor; + constructor._plane = plane; + constructor._em = em; if (em) { @@ -569,7 +853,7 @@ void ElevationSlice::computeIntersections(osg::Node* scene) double pi_height = *aitr; - // osg::notify(osg::NOTICE)<<"computed height = "<