Exemplo n.º 1
0
sofa::simulation::Node::SPtr SceneLoaderXML::load(const char *filename)
{
    sofa::simulation::Node::SPtr root;

    if (!canLoadFileName(filename))
        return 0;

    notifyLoadingScene();

    xml::BaseElement* xml = xml::loadFromFile ( filename );
    root = processXML(xml, filename);

    delete xml;

    return root;
}
sofa::simulation::Node::SPtr SceneLoaderXML::load(const char *filename)
{
    sofa::simulation::Node::SPtr root;

    if (!canLoadFileName(filename))
        return 0;

    //::sofa::simulation::init();
    // 				std::cerr << "Loading simulation XML file "<<filename<<std::endl;
    xml::BaseElement* xml = xml::loadFromFile ( filename );

    root = processXML(xml, filename);

    // 				std::cout << "load done."<<std::endl;
    delete xml;

    return root;
}
Exemplo n.º 3
0
sofa::simulation::Node::SPtr SceneLoaderPHP::load(const char *filename)
{
    sofa::simulation::Node::SPtr root;

    if (!canLoadFileName(filename))
        return 0;

    std::string out="",error="";
    std::vector<std::string> args;


    //TODO : replace when PipeProcess will get file as stdin
    //at the moment, the filename is given as an argument
    args.push_back(std::string("-f" + std::string(filename)));
    //args.push_back("-w");
    std::string newFilename="";
    //std::string newFilename=filename;

    helper::system::FileRepository fp("PATH", ".");
#ifdef WIN32
    std::string command = "php.exe";
#else
    std::string command = "php";
#endif
    if (!fp.findFile(command,""))
    {
        msg_error("SceneLoaderPHP") << "Php not found in your PATH environment." ;
        return NULL;
    }

    sofa::helper::system::PipeProcess::executeProcess(command.c_str(), args,  newFilename, out, error);

    if(error != "")
    {
        msg_error("SceneLoaderPHP") << error ;
        if (out == "")
            return NULL;
    }
    root = SceneLoaderXML::loadFromMemory(filename, out.c_str(), (unsigned int)out.size());

    return root;
}