1616#include < filesystem>
1717
1818
19- int fixLOD (float factor, const std::string& filename)
19+ int fixLOD (float factor, const std::string& filename, bool includeData )
2020{
2121
2222 osgDB::Options *options= new osgDB::Options;
23-
24- options->setOptionString (" WriteImageHint=IncludeFile" );
23+ if (includeData)
24+ options->setOptionString (" WriteImageHint=IncludeData" );
25+ else
26+ options->setOptionString (" WriteImageHint=IncludeFile" );
2527 osg::Node *root=nullptr ;
2628 std::filesystem::path p;
2729 p = filename;
@@ -40,7 +42,10 @@ int fixLOD(float factor, const std::string& filename)
4042 nrl.push_back (ranges[i]);
4143 }
4244 double newRad = factor * plod->getRadius ();
43- nrl[0 ].first = newRad;
45+ if ((int )ranges.size ()==1 )
46+ nrl[0 ].first = 0 ;
47+ else
48+ nrl[0 ].first = newRad;
4449 nrl[0 ].second = 1.0E10 ;
4550 for (int i = 1 ; i< (int )ranges.size (); i++)
4651 {
@@ -96,19 +101,28 @@ int fixLOD(float factor, const std::string& filename)
96101}
97102
98103int main (int argc, char **argv) {
104+ int argOffset = 0 ;
105+ bool writeAsData = false ;
106+ if (argc > 1 && strcmp (argv[1 ], " data" ) == 0 )
107+ {
108+ argc--;
109+ argOffset++;
110+ writeAsData = true ;
111+ }
99112 if (argc == 2 )
100113 {
101- std::string filename = argv[1 ];
102- return fixLOD (5.0 , filename);
114+ std::string filename = argv[1 + argOffset ];
115+ return fixLOD (5.0 , filename, writeAsData );
103116 }
104117 else if (argc == 3 )
105118 {
106- std::string filename = argv[2 ];
107- return fixLOD (atof (argv[1 ]), filename);
119+ std::string filename = argv[2 + argOffset ];
120+ return fixLOD (atof (argv[1 + argOffset ]), filename, writeAsData );
108121 }
109122 else
110123 {
111- std::cerr << " Usage: fixLOD [scaleFactor] [file.osgb]" << std::endl;
124+ std::cerr << " Usage: fixLOD [data] [scaleFactor] [file.osgb]" << std::endl;
125+ std::cerr << " if pictures are missing, use data option" << std::endl;
112126 }
113127
114128 return 0 ;
0 commit comments