Comments (3)
Thanks a lot. That solved my problem. I copied code from example files "kd_tree_custom_space_type.cpp", that is why it is std::deque. Initially I want to use std::vector.
Thanks again.
from pico_tree.
You can definitely use pico_tree with PCL. At first glance your custom PointTraits are fine, except that I don't see a namespace:
namespace pico_tree {
template <>
struct PointTraits<pcl::PointXYZI> {
...
};
} // namespace pico_tree
However, your custom SpaceTraits needs a few changes:
namespace pico_tree {
// pcl::PointXYZI doesn't require template arguments, so we leave the template
// parameters for SpaceTraits empty. This results in a full template
// specialization for std::deque<pcl::PointXYZI>.
template <>
struct SpaceTraits<std::deque<pcl::PointXYZI>> {
...
using ScalarType = float;
static std::size_t constexpr Dim = 3;
...
};
} // namespace pico_tree
from pico_tree.
Note that I would recommend using an std::vector
over an std::deque
because it would be faster. All you have to do is #include <pico_tree/vector_traits.hpp>
and add your custom PointTraits<pcl::PointXYZI>
.
If you really want to work with std::deque
then here is a generic SpaceTraits<std::deque<Point_>>
that will work for any point type Point_
supported by a PointTraits<Point_>
:
namespace pico_tree {
// Provides an interface for an std::deque<Point_>.
template <typename Point_>
struct SpaceTraits<std::deque<Point_>> {
using SpaceType = std::deque<Point_>;
using PointType = Point_;
using ScalarType = typename PointTraits<Point_>::ScalarType;
static std::size_t constexpr Dim = PointTraits<Point_>::Dim;
// It is not reliably possible to get the spatial dimension of an std::deque.
// I.e., when the point set is empty.
static_assert(
Dim != kDynamicSize, "DEQUE_OF_POINT_DOES_NOT_SUPPORT_DYNAMIC_DIM");
// Returns a point from the input space at the specified index.
template <typename Index_>
inline static PointType const& PointAt(
SpaceType const& space, Index_ const index) {
return space[static_cast<std::size_t>(index)];
}
// Returns number of points contained by the space.
inline static std::size_t size(SpaceType const& space) {
return space.size();
}
// Returns the number of coordinates or spatial dimension of each point.
inline static constexpr std::size_t sdim(SpaceType const&) { return Dim; }
};
} // namespace pico_tree
from pico_tree.
Related Issues (7)
- I am curious if you have benchmarked this against octree approaches HOT 2
- Python bindings do not respect non-contiguous NumPy arrays HOT 1
- The pip workflow fails. CMake no longer finds libomp on macos-latest.
- The build-and-test workflow fails. googletest no longer builds in macos-latest
- OpenCV build disabled in the build-and-test workflow for Windows
- can not compile on Ubuntu18.04 gcc7.5 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pico_tree.