From a72afde6510f9868ba9961d664fe91fc0362e6cb Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@kit.edu>
Date: Sun, 27 Jun 2021 17:30:57 +0200
Subject: [PATCH] Add articulated simox XML in ObjectClass

---
 .../armem_objects/aron/ObjectClass.xml        |  4 +++
 .../armem_objects/server/class/Segment.cpp    | 27 +++++++++++--------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml b/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml
index 650082eb4..cb3c418e6 100644
--- a/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml
+++ b/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml
@@ -31,6 +31,10 @@ Core segment type of Object/Class.
                 <armarx::arondto::PackagePath />
             </ObjectChild>
 
+            <ObjectChild key="articulatedSimoxXmlPath">
+                <armarx::arondto::PackagePath />
+            </ObjectChild>
+
             <ObjectChild key="meshWrlPath">
                 <armarx::arondto::PackagePath />
             </ObjectChild>
diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp
index ad3027f50..3e6ecfed3 100644
--- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp
+++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp
@@ -172,18 +172,23 @@ namespace armarx::armem::server::obj::clazz
 
         toAron(data.id, info.id());
 
-        if (fs::is_regular_file(info.simoxXML().absolutePath))
+        auto setPathIfExists = [](
+                armarx::arondto::PackagePath & aron,
+                const PackageFileLocation & location)
         {
-            toAron(data.simoxXmlPath, info.simoxXML());
-        }
-        if (fs::is_regular_file(info.wavefrontObj().absolutePath))
-        {
-            toAron(data.meshObjPath, info.wavefrontObj());
-        }
-        if (fs::is_regular_file(info.file(".wrl").absolutePath))
-        {
-            toAron(data.meshWrlPath, info.file(".wrl"));
-        }
+            if (fs::is_regular_file(location.absolutePath))
+            {
+                toAron(aron, location);
+            }
+            else
+            {
+                toAron(aron, PackageFileLocation());
+            }
+        };
+        setPathIfExists(data.simoxXmlPath, info.simoxXML());
+        setPathIfExists(data.articulatedSimoxXmlPath, info.articulatedSimoxXML());
+        setPathIfExists(data.meshObjPath, info.wavefrontObj());
+        setPathIfExists(data.meshWrlPath, info.meshWrl());
 
         auto aabb = info.loadAABB();
         toAron(data.aabb, aabb ? aabb.value() : simox::AxisAlignedBoundingBox());
-- 
GitLab