Skip to content

Commit e63e69e

Browse files
committed
Parse pipeline config as collection of sections
1 parent 4cb018b commit e63e69e

6 files changed

+54
-287
lines changed

libraries/YarpCloudUtils/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ if(ENABLE_YarpCloudUtils)
66
YarpCloudUtils-ply-export.cpp
77
YarpCloudUtils-ply-import.cpp
88
YarpCloudUtils-pcl.cpp
9-
SurfaceMeshingOptions.hpp
10-
SurfaceMeshingOptions.cpp
119
tinyply.h)
1210

13-
set_property(TARGET YarpCloudUtils PROPERTY PUBLIC_HEADER YarpCloudUtils.hpp SurfaceMeshingOptions.hpp)
11+
set_property(TARGET YarpCloudUtils PROPERTY PUBLIC_HEADER YarpCloudUtils.hpp)
1412

1513
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tinyply.cpp "#include \"tinyply.h\"")
1614
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/tinyply.cpp PROPERTY COMPILE_DEFINITIONS TINYPLY_IMPLEMENTATION)

libraries/YarpCloudUtils/SurfaceMeshingOptions.cpp

-211
This file was deleted.

libraries/YarpCloudUtils/SurfaceMeshingOptions.hpp

-63
This file was deleted.

libraries/YarpCloudUtils/YarpCloudUtils-pcl-inst.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <yarp/sig/Vector.h>
99

1010
#define YCU_PCL_INST_SIGNATURE(in, out) \
11-
template bool meshFromCloud(const in &, out &, yarp::sig::VectorOf<int> &, const yarp::sig::VectorOf<yarp::os::Property> &);
11+
template bool meshFromCloud(const in &, out &, yarp::sig::VectorOf<int> &, const yarp::os::Searchable &, const std::string &);
1212

1313
namespace roboticslab
1414
{

libraries/YarpCloudUtils/YarpCloudUtils-pcl.cpp

+46
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,42 @@ namespace
920920
}
921921
#endif
922922

923+
namespace
924+
{
925+
auto makeFromConfig(const yarp::os::Searchable & config, const std::string & collection)
926+
{
927+
yarp::sig::VectorOf<yarp::os::Property> options;
928+
const auto & pipeline = config.findGroup(collection);
929+
930+
if (!pipeline.isNull())
931+
{
932+
auto groups = pipeline.tail();
933+
934+
for (auto i = 0; i < groups.size(); i++)
935+
{
936+
auto groupName = groups.get(i).asString();
937+
const auto & group = config.findGroup(groupName);
938+
939+
if (!group.isNull())
940+
{
941+
auto groupConfig = group.tail();
942+
options.emplace_back(groupConfig.toString().c_str());
943+
}
944+
else
945+
{
946+
yWarning() << "group not found:" << groupName;
947+
}
948+
}
949+
}
950+
else
951+
{
952+
yWarning() << "collection not found:" << collection;
953+
}
954+
955+
return options;
956+
}
957+
}
958+
923959
namespace roboticslab
924960
{
925961

@@ -986,6 +1022,16 @@ bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
9861022
#endif
9871023
}
9881024

1025+
template <typename T1, typename T2>
1026+
bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
1027+
yarp::sig::PointCloud<T2> & meshPoints,
1028+
yarp::sig::VectorOf<int> & meshIndices,
1029+
const yarp::os::Searchable & config,
1030+
const std::string & collection)
1031+
{
1032+
return meshFromCloud(cloud, meshPoints, meshIndices, makeFromConfig(config, collection));
1033+
}
1034+
9891035
} // namespace YarpCloudUtils
9901036

9911037
} // namespace roboticslab

libraries/YarpCloudUtils/YarpCloudUtils.hpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
#include <string>
77

88
#include <yarp/os/Property.h>
9+
#include <yarp/os/Searchable.h>
910

1011
#include <yarp/sig/PointCloud.h>
1112
#include <yarp/sig/Vector.h>
1213

13-
#include <SurfaceMeshingOptions.hpp>
14-
1514
/**
1615
* @ingroup vision_libraries
1716
* @defgroup YarpCloudUtils
@@ -54,14 +53,12 @@ bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
5453
{{"algorithm", yarp::os::Value("Poisson")}}
5554
});
5655

57-
template <typename T>
58-
bool meshFromCloud(const yarp::sig::PointCloud<T> & cloud,
56+
template <typename T1, typename T2 = T1>
57+
bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
58+
yarp::sig::PointCloud<T2> & meshPoints,
5959
yarp::sig::VectorOf<int> & meshIndices,
60-
const yarp::sig::VectorOf<yarp::os::Property> & options)
61-
{
62-
yarp::sig::PointCloud<T> meshPoints;
63-
return meshFromCloud(cloud, meshPoints, meshIndices, options);
64-
}
60+
const yarp::os::Searchable & config,
61+
const std::string & collection = "meshPipeline");
6562

6663
} // namespace YarpCloudUtils
6764

0 commit comments

Comments
 (0)