nanoflann_mesh_adaptor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020, Sebastian Pütz
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  *
16  * 3. Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * authors:
34  * Sebastian Pütz <spuetz@uni-osnabrueck.de>
35  *
36  */
37 
38 #ifndef MESH_MAP__NANOFLANN_MESH_ADAPTOR_H
39 #define MESH_MAP__NANOFLANN_MESH_ADAPTOR_H
40 
42 #include "nanoflann.hpp"
43 
44 namespace mesh_map{
46 {
48 
51 
52  inline lvr2::Index kdtree_get_point_count() const { return mesh.nextVertexIndex(); }
53 
54  inline float kdtree_get_pt(const lvr2::Index idx, const size_t dim) const
55  {
56  const lvr2::VertexHandle vH(idx);
57  if(mesh.containsVertex(vH))
58  {
59  const lvr2::BaseVector<float>& vertex = mesh.getVertexPosition(vH);
60  if (dim == 0) return vertex.x;
61  else if (dim == 1) return vertex.y;
62  else return vertex.z;
63  }
64  return std::nanf("");
65  }
66 
67  template <class BBOX>
68  bool kdtree_get_bbox(BBOX& /*bb*/) const { return false; }
69 
70 }; // end of PointCloudAdaptor
71 }
72 
73 #endif /* MESH_MAP__NANOFLANN_MESH_ADAPTOR_H */
bool containsVertex(VertexHandle vH) const
const lvr2::HalfEdgeMesh< lvr2::BaseVector< float > > & mesh
uint32_t Index
NanoFlannMeshAdaptor(const lvr2::HalfEdgeMesh< lvr2::BaseVector< float >> &mesh)
The constructor that sets the data set source.
lvr2::Index kdtree_get_point_count() const
Index nextVertexIndex() const
BaseVecT getVertexPosition(VertexHandle handle) const final
float kdtree_get_pt(const lvr2::Index idx, const size_t dim) const


mesh_map
Author(s): Sebastian Pütz
autogenerated on Tue May 24 2022 02:57:54