void Read(KinBodyPtr& pbody, const std::vector<char>& data,const AttributesList& atts) { _ProcessAtts(atts); if( !pbody ) { pbody = RaveCreateKinBody(_penv,_bodytype); } pbody->SetName(_bodyname); Assimp::XFileParserOpenRAVE parser(data); _Read(pbody,parser.GetImportedData()); if( pbody->GetName().size() == 0 ) { pbody->SetName("body"); } }
void ReadFile(KinBodyPtr& pbody, const std::string& filename, const AttributesList& atts) { std::ifstream f(filename.c_str()); if( !f ) { throw OPENRAVE_EXCEPTION_FORMAT("failed to read %s filename",filename,ORE_InvalidArguments); } f.seekg(0,ios::end); std::vector<char> filedata(static_cast<size_t>(f.tellg())+1, 0); // need a null-terminator f.seekg(0,ios::beg); f.read(&filedata[0], filedata.size()); Read(pbody,filedata,atts); pbody->__struri = filename; #if defined(HAVE_BOOST_FILESYSTEM) && BOOST_VERSION >= 103600 // stem() was introduced in 1.36 boost::filesystem::path bfpath(filename); #if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION >= 3 pbody->SetName(bfpath.stem().string()); #else pbody->SetName(bfpath.stem()); #endif #endif }