From 1dc215a1daaf68d18d45a5400b3ea6de9ccba5aa Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 12 Jun 2012 20:15:58 +0000 Subject: [PATCH] Added FileNameComparator to sort the filenames in an ImageSequence into alphanumerical order so that it can handle the numerical ordering found in screenshot numbered sets of files --- src/osgPresentation/SlideShowConstructor.cpp | 52 +++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/osgPresentation/SlideShowConstructor.cpp b/src/osgPresentation/SlideShowConstructor.cpp index a488637b1..6a58062eb 100644 --- a/src/osgPresentation/SlideShowConstructor.cpp +++ b/src/osgPresentation/SlideShowConstructor.cpp @@ -857,6 +857,56 @@ osg::Geometry* SlideShowConstructor::createTexturedQuadGeometry(const osg::Vec3& return pictureQuad; } +struct FileNameComparotor +{ + bool operator() (const std::string& lhs, const std::string& rhs) const + { + std::string::size_type size_lhs = lhs.size(); + std::string::size_type size_rhs = rhs.size(); + std::string::size_type pos_lhs = 0; + std::string::size_type pos_rhs = 0; + while(pos_lhs='0' && lhs[pos_lhs]<='9'; + bool numeric_rhs = rhs[pos_rhs]>='0' && rhs[pos_rhs]<='9'; + if (numeric_lhs && numeric_rhs) + { + std::string::size_type start_lhs = pos_lhs; + ++pos_lhs; + while(pos_lhs='0' && lhs[pos_lhs]<='9')) ++pos_lhs; + + std::string::size_type start_rhs = pos_rhs; + ++pos_rhs; + while(pos_rhs='0' && rhs[pos_rhs]<='9')) ++pos_rhs; + + if (pos_lhsrhs[start_rhs]) return false; + ++start_lhs; + ++start_rhs; + } + } + else + { + if (c_lhs options = _options; @@ -932,7 +982,7 @@ osg::Image* SlideShowConstructor::readImage(const std::string& filename, const I else { // make sure images are in alphabetical order. - std::sort(filenames.begin(), filenames.end()); + std::sort(filenames.begin(), filenames.end(), FileNameComparotor()); osg::ref_ptr imageSequence = new osg::ImageSequence;