pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
instance-filter.hpp
1//
2// Copyright (c) 2022 INRIA
3//
4
5#ifndef __pinocchio_multibody_instance_filter_hpp__
6#define __pinocchio_multibody_instance_filter_hpp__
7
8#include <vector>
9
10namespace pinocchio
11{
12
14 template<typename T>
16 {
24 virtual bool operator()(const T & obj) const = 0;
25
34 template<typename Allocator>
35 std::vector<size_t> apply(const std::vector<T, Allocator> & object_vector) const
36 {
37 std::vector<size_t> res;
38 res.reserve(object_vector.size());
39
40 for (size_t k = 0; k < object_vector.size(); ++k)
41 {
42 if ((*this)(object_vector[k]))
43 res.push_back(k);
44 }
45
46 res.reserve(res.size());
47 return res;
48 }
49 };
50
51} // namespace pinocchio
52
53#endif // #ifndef __pinocchio_multibody_instance_filter_hpp__
Main pinocchio namespace.
Definition treeview.dox:11
Instance filter base class.
virtual bool operator()(const T &obj) const =0
Returns true if the input obj matches the filter conditions.
std::vector< size_t > apply(const std::vector< T, Allocator > &object_vector) const
Apply the filter on the given vector of objects and returns the list of indexes of the objects matchi...