From Sukender, "I just fount that writing double precision values (eg. Vec3dArray for vertices) works with .osg but not .osgt/.osgx. So here is the fix (SVN trunk r12712). I suppose .osgb works as expected on this point and did not change anything.
So, as for .osg, if you add "precision 16" (for instance) to the optionString, then you'll get double precision vertices written correctly. "
This commit is contained in:
@@ -7,8 +7,12 @@
|
||||
class AsciiOutputIterator : public osgDB::OutputIterator
|
||||
{
|
||||
public:
|
||||
AsciiOutputIterator( std::ostream* ostream )
|
||||
: _readyForIndent(false), _indent(0) { _out = ostream; }
|
||||
AsciiOutputIterator( std::ostream* ostream, int precision )
|
||||
: _readyForIndent(false), _indent(0)
|
||||
{
|
||||
_out = ostream;
|
||||
if (precision>0) _out->precision(precision);
|
||||
}
|
||||
|
||||
virtual ~AsciiOutputIterator() {}
|
||||
|
||||
|
||||
@@ -71,15 +71,29 @@ InputIterator* readInputIterator( std::istream& fin, const Options* options )
|
||||
|
||||
OutputIterator* writeOutputIterator( std::ostream& fout, const Options* options )
|
||||
{
|
||||
// Read precision parameter, for text & XML formats
|
||||
int precision(-1);
|
||||
if ( options ) {
|
||||
std::istringstream iss(options->getOptionString());
|
||||
std::string opt;
|
||||
while (iss >> opt)
|
||||
{
|
||||
if(opt=="PRECISION" || opt=="precision")
|
||||
{
|
||||
iss >> precision;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( options && options->getOptionString().find("Ascii")!=std::string::npos )
|
||||
{
|
||||
fout << std::string("#Ascii") << ' ';
|
||||
return new AsciiOutputIterator(&fout);
|
||||
return new AsciiOutputIterator(&fout, precision);
|
||||
}
|
||||
else if ( options && options->getOptionString().find("XML")!=std::string::npos )
|
||||
{
|
||||
fout << std::string("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>") << std::endl;
|
||||
return new XmlOutputIterator(&fout);
|
||||
return new XmlOutputIterator(&fout, precision);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,10 +19,11 @@ public:
|
||||
TEXT_LINE // A text line, e.g. recording array elements
|
||||
};
|
||||
|
||||
XmlOutputIterator( std::ostream* ostream )
|
||||
XmlOutputIterator( std::ostream* ostream, int precision )
|
||||
: _readLineType(FIRST_LINE), _prevReadLineType(FIRST_LINE), _hasSubProperty(false)
|
||||
{
|
||||
_out = ostream;
|
||||
if (precision>0) _sstream.precision(precision);
|
||||
_root = new osgDB::XmlNode;
|
||||
_root->type = osgDB::XmlNode::GROUP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user