diff --git a/examples/osgintersection/osgintersection.cpp b/examples/osgintersection/osgintersection.cpp index a9ed2cd2a..58c7bc7a6 100644 --- a/examples/osgintersection/osgintersection.cpp +++ b/examples/osgintersection/osgintersection.cpp @@ -134,7 +134,7 @@ int main(int argc, char **argv) es.setDatabaseCacheReadCallback(los.getDatabaseCacheReadCallback()); es.setStartPoint(bs.center()+osg::Vec3d(bs.radius(),0.0,0.0) ); - es.setEndPoint(bs.center()+osg::Vec3d(bs.radius(),bs.radius(),bs.radius()) ); + es.setEndPoint(bs.center()+osg::Vec3d(0.0,0.0, bs.radius()) ); es.computeIntersections(scene.get()); diff --git a/src/osgSim/ElevationSlice.cpp b/src/osgSim/ElevationSlice.cpp index de4a495c1..2d90228ac 100644 --- a/src/osgSim/ElevationSlice.cpp +++ b/src/osgSim/ElevationSlice.cpp @@ -220,6 +220,8 @@ struct Segment _p1 = p2; _p2 = p1; } + osg::notify(osg::INFO).precision(12); + osg::notify(osg::INFO)<<"Segment::Segment p1 = "<<(_p1->distance)<<" "<<(_p1->height)<<" p2 = "<<(_p2->distance)<<" "<<(_p2->height)<distance - rhs._p1->distance) < epsilon) { if (fabs(_p2->height - rhs._p1->height) < epsilon) return JOINED; - else return SEPERATE; + // else return SEPERATE; } if (rhs._p2->distance < _p1->distance || _p2->distance < rhs._p1->distance) return SEPERATE; @@ -295,6 +297,14 @@ struct Segment _p1->position * one_minus_r + _p2->position * r); } + Point* createIntersectinPoint(const Segment& rhs) const + { + // temporary implementation + osg::notify(osg::INFO)<<"Error: Segment::createIntersectinPoint() not implementated yet"< _p1; osg::ref_ptr _p2; @@ -337,6 +347,7 @@ struct LineConstructor void report() { + osg::notify(osg::INFO)<<"Number of segments = "<<_segments.size()<height)<<" p2 = "<<(seg._p2->distance)<<" "<<(seg._p2->height)<<"\t"; - double latitude, longitude, height; - - p = s._p1->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) + SegmentSet::iterator nextItr = itr; + ++nextItr; + if (nextItr != _segments.end()) { - osg::notify(osg::INFO)<<" "<<&s<<" computed height delta ="<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 ="<distance<<" "<height<distance<<" "<height<distance) ); + Segment seg2( rhs._p1.get(), cp ); + Segment seg3( cp, lhs._p2.get() ); + Segment seg4( rhs.createPoint(lhs._p2->distance), lhs._p2.get() ); + + _segments.insert(seg1); + _segments.insert(seg2); + _segments.insert(seg3); + _segments.insert(seg4); + + _segments.erase(nextItr); + _segments.erase(itr); + + itr = _segments.find(seg1); + nextItr = itr; + ++nextItr; + } else if (dh1 <= 0.0 && dh2 <= 0.0) { - osg::notify(osg::INFO)<<"OVERLAPPING : lhs below rhs "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance), rhs._p2.get()); + + _segments.insert(newSeg); + _segments.erase(nextItr); + nextItr = itr; ++nextItr; + + osg::notify(osg::INFO)<<" newSeg_p1 "<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)); + + _segments.insert(newSeg); + _segments.erase(itr); + itr = _segments.find(newSeg); + nextItr = itr; ++nextItr; + + osg::notify(osg::INFO)<<" newSeg_p1 "<distance<<" "<height<distance<<" "<height<=0.0 && dh2>=0.0) { + + double d_left = enclosed._p1->distance - enclosing._p1->distance; + double d_right = enclosing._p2->distance - enclosed._p2->distance; + + if (d_left < epsilon && d_right < epsilon) + { + // treat ENCLOSED as ENCLOSING. + osg::notify(osg::INFO)<<" Treat enclosed above as enclosing "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance), enclosing._p2.get()); +#if 1 + nextItr = itr; + ++nextItr; + + _segments.erase(itr); + _segments.insert(newSeg); + + itr = nextItr; +#endif + ++nextItr; + + osg::notify(osg::INFO)<<" newSeg_p1 "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance) ); + + _segments.insert(newSeg); + _segments.erase(nextItr); + + nextItr = itr; + ++nextItr; + + osg::notify(osg::INFO)<<" newSeg_p1 "<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<distance<<" "<height<compare(*nextItr) : Segment::UNCLASSIFIED; + classification = ((itr != _segments.end()) && (nextItr != _segments.end())) ? itr->compare(*nextItr) : Segment::UNCLASSIFIED; } } } @@ -790,7 +946,7 @@ void ElevationSlice::computeIntersections(osg::Node* scene) } } -#if 0 +#if 1 osg::ref_ptr geode = new osg::Geode; for(itr = intersections.begin(); @@ -895,7 +1051,7 @@ void ElevationSlice::computeIntersections(osg::Node* scene) constructor.copyPoints(_intersections, _distanceHeightIntersections); -#if 0 +#if 1 { osg::ref_ptr geode = new osg::Geode;