00001 00031 #ifndef URDF2INVENTOR_FILEIO_H 00032 #define URDF2INVENTOR_FILEIO_H 00033 // Copyright Jennifer Buehler 00034 00035 //----------------------------------------------------- 00036 #include <urdf/model.h> 00037 #include <urdf2inventor/ConversionResult.h> 00038 #include <baselib_binding/SharedPtr.h> 00039 00040 #include <ros/ros.h> 00041 #include <iostream> 00042 #include <fstream> 00043 #include <string> 00044 #include <map> 00045 #include <vector> 00046 #include <map> 00047 00048 00049 00050 namespace urdf2inventor 00051 { 00052 00060 template<typename MeshFormat = std::string> 00061 class FileIO 00062 { 00063 public: 00064 typedef ConversionResult<MeshFormat> ConversionResultT; 00065 typedef typename baselib_binding::shared_ptr<ConversionResultT>::type ConversionResultPtr; 00066 00070 explicit FileIO(const std::string& _outputDir): 00071 outputDir(_outputDir) {} 00072 00073 virtual ~FileIO() 00074 { 00075 } 00076 00080 bool write(const ConversionResultPtr& data) const; 00081 00088 bool initOutputDir(const std::string& robotName) const; 00089 00090 00091 protected: 00092 bool writeMeshFiles(const std::map<std::string, MeshFormat>& meshes, 00093 const std::string& MESH_OUTPUT_EXTENSION, 00094 const std::string& MESH_OUTPUT_DIRECTORY_NAME) const; 00099 virtual bool initOutputDirImpl(const std::string& robotName) const 00100 { 00101 return true; 00102 }; 00103 00109 virtual bool writeImpl(const ConversionResultPtr& data) const 00110 { 00111 return true; 00112 } 00113 00114 inline const std::string& getOutputDirectory() const 00115 { 00116 return outputDir; 00117 } 00118 private: 00119 std::string outputDir; 00120 }; 00121 } // namespace urdf2inventor 00122 00123 #include <urdf2inventor/FileIO.hpp> 00124 00125 #endif // URDF2INVENTOR_FILEIO_H