<commit_before>// -*-c++-*-

/*
 *
 * VRML2 file converter for OpenSceneGraph.
 *
 * authors : <NAME> (<EMAIL>), 
 *           <NAME> (<EMAIL>), 
 *           <NAME> (<EMAIL>)
 *           
 *           (c) VRlab EPFL, Switzerland, 2004-2006
 */

#include <iostream>
#include <fstream>
#include <string>

#include <openvrml/vrml97node.h>
#include <openvrml/common.h>
#include <openvrml/browser.h>
#include <openvrml/node.h>
#include <openvrml/node_ptr.h>
#include <openvrml/field.h>

#include <osg/TexEnv>
#include <osg/CullFace>

#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/Light>
#include <osg/LightSource>

#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>

#include <assert.h>
#include <map>


/**
 * OpenSceneGraph plugin wrapper/converter.
 */
class ReaderWriterVRML2 : public osgDB::ReaderWriter
{
    public:
        ReaderWriterVRML2() { }

        virtual const char* className()
        {
            return "VRML2 Reader/Writer";
        }

        virtual bool acceptsExtension(const std::string& extension)
        {
            return osgDB::equalCaseInsensitive(extension, "wrl") ? true : false;
        }

        virtual ReadResult readNode(const std::string&, const osgDB::ReaderWriter::Options *options = NULL) const;
    private:
        osg::ref_ptr<osg::Node> convertFromVRML(openvrml::node *obj) const;
};

// Register with Registry to instantiate the above reader/writer.
REGISTER_OSGPLUGIN(vrml, ReaderWriterVRML2)

osgDB::ReaderWriter::ReadResult ReaderWriterVRML2::readNode(const std::string &fname, const Options* opt) const
{
    std::string fileName = osgDB::findDataFile(fname, opt);
    if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;

    // convert possible Windows backslashes to Unix slashes
    // OpenVRML doesn't like backslashes, even on Windows
    std::string unixFileName = osgDB::convertFileNameToUnixStyle(fileName);

#ifdef WIN32
    fileName = "file://" + unixFileName;
#else
    if(unixFileName[0] == '/') // absolute path
        fileName = "file://" + unixFileName;
    else // relative path
        fileName = unixFileName;
#endif

    std::fstream null;
    openvrml::browser *browser = new openvrml::browser(null, null);
<commit_msg>From <NAME>, "After a bit more testing, it was still not 100% robust, so this fix will bring the change in line with what is done on other OSes (Linux) and works in all tested cases.<commit_after>// -*-c++-*-

/*
 *
 * VRML2 file converter for OpenSceneGraph.
 *
 * authors : <NAME> (<EMAIL>), 
 *           <NAME> (<EMAIL>), 
 *           <NAME> (<EMAIL>)
 *           
 *           (c) VRlab EPFL, Switzerland, 2004-2006
 */

#include <iostream>
#include <fstream>
#include <string>

#include <openvrml/vrml97node.h>
#include <openvrml/common.h>
#include <openvrml/browser.h>
#include <openvrml/node.h>
#include <openvrml/node_ptr.h>
#include <openvrml/field.h>

#include <osg/TexEnv>
#include <osg/CullFace>

#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Material>
#include <osg/Image>
#include <osg/Texture2D>
#include <osg/Group>
#include <osg/MatrixTransform>
#include <osg/Light>
#include <osg/LightSource>

#include <osg/Notify>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>

#include <assert.h>
#include <map>


/**
 * OpenSceneGraph plugin wrapper/converter.
 */
class ReaderWriterVRML2 : public osgDB::ReaderWriter
{
    public:
        ReaderWriterVRML2() { }

        virtual const char* className()
        {
            return "VRML2 Reader/Writer";
        }

        virtual bool acceptsExtension(const std::string& extension)
        {
            return osgDB::equalCaseInsensitive(extension, "wrl") ? true : false;
        }

        virtual ReadResult readNode(const std::string&, const osgDB::ReaderWriter::Options *options = NULL) const;
    private:
        osg::ref_ptr<osg::Node> convertFromVRML(openvrml::node *obj) const;
};

// Register with Registry to instantiate the above reader/writer.
REGISTER_OSGPLUGIN(vrml, ReaderWriterVRML2)

osgDB::ReaderWriter::ReadResult ReaderWriterVRML2::readNode(const std::string &fname, const Options* opt) const
{
    std::string fileName = osgDB::findDataFile(fname, opt);
    if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;

    // convert possible Windows backslashes to Unix slashes
    // OpenVRML doesn't like backslashes, even on Windows
    std::string unixFileName = osgDB::convertFileNameToUnixStyle(fileName);

#ifdef WIN32
    if(unixFileName[1] == ':') // absolute path
#else
    if(unixFileName[0] == '/') // absolute path
#endif
        fileName = "file://" + unixFileName;
    else // relative path
        fileName = unixFileName;

    std::fstream null;
    openvrml::browser *browser = new openvrml::browser(null, null);

{'fraction_non_alphanumeric': 0.13523771474230922, 'fraction_numerical': 0.008789452656811825, 'mean_word_length': 3.6794392523364485, 'pattern_counts': {'":': 0, '<': 72, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7546126', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1680, 'n_words': 397}