Functions
urdf2inventor::helpers Namespace Reference

Functions

bool fixFileReferences (const std::string &modelDir, const std::string &fileDir, const std::string &fileRootDir, const std::set< std::string > &filesInUse, std::string &modelString, std::map< std::string, std::set< std::string > > &filesToCopy)
void redirectStdOut (const char *toFile)
void resetStdOut ()
bool writeFiles (const std::map< std::string, std::set< std::string > > &files, const std::string &outputDir)

Function Documentation

bool urdf2inventor::helpers::fixFileReferences ( const std::string &  modelDir,
const std::string &  fileDir,
const std::string &  fileRootDir,
const std::set< std::string > &  filesInUse,
std::string &  modelString,
std::map< std::string, std::set< std::string > > &  filesToCopy 
)

All file references in the model modelString (to be saved in modelDir) will be changed from absolute paths to references relative to modelDir. References will refer to files which will be stored in fileDir or a subdirectory of it. The directory structure to be created in fileDir mirrors the one where the original files are currently stored, relative to fileRootDir. The directory structure to create in fileDir will be returned as part of the result in filesToCopy.

Example: modelDir is ``iv/myrobot/`` and fileDir is ``iv/textures/``. The fileRootDir is set to be ``/home/user/mytextures/``, which has directories ``colortex/`` and ``imagetex/`` in it, both containing a number of texture files. Then, assuming the model described in modelString will be saved in a file in ``iv/myrobot/<filename>.<extension>``, all references in modelString will point to ``../textures/colortex/<rest-of-path-to-texture>`` and ``../files/imagetex/<rest-of-path-to-texture>``.

Parameters:
modelDirwhen writing the model files to disk, and the installation destination is any ``<install-prefix>``, all model files will be put in ``<install-prefix>/modelDir``. The path may also be absolute but it's not required.
fileDirwhen writing the model files to disk, and the installation destination is any ``<install-prefix>``, all files will be put in ``<install-prefix>/fileDir``. The path may also be absolute but it's not required.
fileRootDirthe common parent path of all filesInUse to use. This can be the direct result of urdf_traverser::helpers::getCommonParentPath(filesInuse, fileRootDir), or it can be a directory higher up in the hierarchy, if desired. Based on this path, a directory structure in the target directory fileDir is created which is equal to the directory structure starting at fileRootDir (including *only* directories which contain referenced files). If the path is not a common parent path of all files in filesInUse, the method returns false.
filesInUseall files which are referenced from within the model. This should be absolute paths!
modelStringthe string representation (eg. XML) of the model which is to be adjusted (fixing file references).
filesToCopyThe file names to copy to target directories: Map **key** is the path to the output file directory, which will be located in the global output directory (eg. ``<fileDir>/path/to/file``). So if fileDir was given as absolute path, this path will be absolute too, otherwise it will be relative. Map **value** is a list of *absolute* filenames to copy into this directory. So copying *all* files i ``<mapIterator->second[i]>`` to ``<output-dir>/<mapIterator->first>`` will be required when installing the model file modelString to ``<output-dir>/<filename>.<extension>``.
Returns:
false if no common parent directory could be determined for all of the files and/or the common parent is no subdirectory of fileRootDir.

Definition at line 153 of file Helpers.cpp.

void urdf2inventor::helpers::redirectStdOut ( const char *  toFile)

Definition at line 74 of file Helpers.cpp.

################################################################################################################ Minor helpers (e.g. file writing)

Author:
Jennifer Buehler
Date:
last edited October 2015 ################################################################################################################

Definition at line 56 of file Helpers.cpp.

bool urdf2inventor::helpers::writeFiles ( const std::map< std::string, std::set< std::string > > &  files,
const std::string &  outputDir 
)

Copies all files as given in files to the target directory outputDir. Will copy all files i ``<mapIterator->second[i]>`` to ``<output-dir>/<mapIterator->first>``.

Parameters:
filesThe file names to copy to target directories: Map **key** is the path to the file. It may be an absolute path, in which case outputDir is ignored. Or it may be a relative path, in which case the file is saved relative to outputDir. Map **value** is a list of *absolute* filenames of files to copy into this directory.

Definition at line 98 of file Helpers.cpp.



urdf2inventor
Author(s): Jennifer Buehler
autogenerated on Fri Mar 1 2019 03:38:11