Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
18df59e6
Commit
18df59e6
authored
6 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Documentation
parent
f78e9bba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
VirtualRobot/examples/MjcfConverter/SimoxXMLDocument.cpp
+2
-3
2 additions, 3 deletions
VirtualRobot/examples/MjcfConverter/SimoxXMLDocument.cpp
VirtualRobot/examples/MjcfConverter/SimoxXMLDocument.h
+39
-5
39 additions, 5 deletions
VirtualRobot/examples/MjcfConverter/SimoxXMLDocument.h
with
41 additions
and
8 deletions
VirtualRobot/examples/MjcfConverter/SimoxXMLDocument.cpp
+
2
−
3
View file @
18df59e6
...
...
@@ -28,7 +28,6 @@ void SimoxXMLDocument::LoadFile(const fs::path& path)
collisionModelFiles
.
clear
();
visualizationFiles
.
clear
();
includedFiles
.
clear
();
XMLNode
*
xmlRobot
=
FirstChildElement
(
"Robot"
);
assert
(
xmlRobot
);
...
...
@@ -36,7 +35,7 @@ void SimoxXMLDocument::LoadFile(const fs::path& path)
SimoxXMLVisitor
visitor
(
*
this
);
xmlRobot
->
Accept
(
&
visitor
);
for
(
fs
::
path
file
:
includedFiles
)
for
(
fs
::
path
file
:
visitor
.
includedFiles
)
{
VR_INFO
<<
"Loading included XML: "
<<
file
<<
std
::
endl
;
...
...
@@ -140,7 +139,7 @@ bool SimoxXMLVisitor::VisitEnter(const tinyxml2::XMLElement& elem, const tinyxml
assert
(
file
);
fs
::
path
relPath
=
file
->
GetText
();
xml
.
includedFiles
.
push_back
(
xml
.
inputFilePath
.
parent_path
()
/
relPath
);
includedFiles
.
push_back
(
xml
.
inputFilePath
.
parent_path
()
/
relPath
);
}
return
true
;
...
...
This diff is collapsed.
Click to expand it.
VirtualRobot/examples/MjcfConverter/SimoxXMLDocument.h
+
39
−
5
View file @
18df59e6
...
...
@@ -11,7 +11,11 @@
namespace
VirtualRobot
{
/**
* @brief A Simox XML document offering access to information not included
* in a VirtualRobot::Robot.
*/
class
SimoxXMLDocument
:
private
tinyxml2
::
XMLDocument
{
using
Base
=
tinyxml2
::
XMLDocument
;
...
...
@@ -20,48 +24,78 @@ class SimoxXMLDocument : private tinyxml2::XMLDocument
public:
/// Constructor.
SimoxXMLDocument
();
/**
* @brief Load a Simox XML file.
* Loads the given XML file and traverses it to collect the wanted
* information. If the file references any other XML files via a
* <ChildFromRobot> element, loads that as well and aggregates its
* information into this.
*/
void
LoadFile
(
const
boost
::
filesystem
::
path
&
path
);
/// @see LoadFile(const boost::filesyste::path&)
void
LoadFile
(
const
std
::
string
&
path
);
/// Indicate whether a RobotNode has specified a collision model file.
bool
hasCollisionModelFile
(
RobotNodePtr
robotNode
)
const
;
/// Indicate whether a RobotNode has specified a visualization file.
bool
hasVisualizationFile
(
RobotNodePtr
robotNode
)
const
;
/// Get the collision model file of a RobotNode. If the node did not
/// specify a collision model file, an empty path is returned.
boost
::
filesystem
::
path
collisionModelFile
(
RobotNodePtr
robotNode
)
const
;
/// Get the visualization file of a RobotNode. If the node did not
/// specify a visualization model file, an empty path is returned.
boost
::
filesystem
::
path
visualizationFile
(
RobotNodePtr
robotNode
)
const
;
private:
/// Map from (node) name to a path.
using
NamePathMap
=
std
::
map
<
std
::
string
,
boost
::
filesystem
::
path
>
;
/// Return true when there is an entry for the robot node in the map.
bool
hasEntry
(
RobotNodePtr
robotNode
,
const
NamePathMap
&
map
)
const
;
/// Return the value of the robot node in the map. If none is found, return an empty path.
boost
::
filesystem
::
path
getEntry
(
RobotNodePtr
robotNode
,
const
NamePathMap
&
map
)
const
;
/// The input file path. Necessary for resolving relative paths.
boost
::
filesystem
::
path
inputFilePath
;
/// The collision model files of RobotNodes.
NamePathMap
collisionModelFiles
;
/// The visualization files of RobotNodes.
NamePathMap
visualizationFiles
;
std
::
vector
<
boost
::
filesystem
::
path
>
includedFiles
;
};
/**
* @brief The SimoxXMLVisitor class
*/
class
SimoxXMLVisitor
:
public
tinyxml2
::
XMLVisitor
{
friend
class
SimoxXMLDocument
;
public:
SimoxXMLVisitor
(
SimoxXMLDocument
&
xml
);
/// Stores mesh files of RobotNodes, and stores files included <ChildFromRobot> elements.
virtual
bool
VisitEnter
(
const
tinyxml2
::
XMLElement
&
,
const
tinyxml2
::
XMLAttribute
*
)
override
;
private:
SimoxXMLDocument
&
xml
;
/// The files included by the input file.
std
::
vector
<
boost
::
filesystem
::
path
>
includedFiles
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment