Skip to content

Commit 749b9e7

Browse files
committed
post fixes and cleanup
1 parent 578fbce commit 749b9e7

File tree

8 files changed

+92
-64
lines changed

8 files changed

+92
-64
lines changed

mesh_layers/src/inflation_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void InflationLayer::waveCostInflation(
364364
}
365365

366366
// The LVR2 PMP wrapper
367-
const auto mesh = std::dynamic_pointer_cast<lvr2::PMPMesh<mesh_map::Vector>>(map->mesh());
367+
const std::shared_ptr<lvr2::PMPMesh<mesh_map::Vector> > mesh = map->mesh();
368368
if (nullptr == mesh)
369369
{
370370
RCLCPP_ERROR(get_logger(), "Failed to dynamic_cast mesh to lvr2::PMPMesh! Currently only the lvr2::PMPMesh backend is supported!");

mesh_map/include/mesh_map/abstract_layer.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,20 @@
3535
*
3636
*/
3737

38+
#ifndef MESH_MAP__ABSTRACT_LAYER_H
39+
#define MESH_MAP__ABSTRACT_LAYER_H
40+
3841
#include <functional>
3942
#include <memory>
4043

4144
#include <boost/optional.hpp>
4245
#include <lvr2/io/AttributeMeshIOBase.hpp>
4346
#include <rclcpp/node.hpp>
4447

45-
#ifndef MESH_MAP__ABSTRACT_LAYER_H
46-
#define MESH_MAP__ABSTRACT_LAYER_H
48+
#include <mesh_map/definitions.h>
49+
4750
namespace mesh_map
4851
{
49-
class MeshMap;
50-
51-
typedef lvr2::BaseVector<float> Vector;
52-
typedef lvr2::Normal<float> Normal;
5352

5453
typedef std::function<void(const std::string&, const rclcpp::Time&, const std::set<lvr2::VertexHandle>&)> notify_func;
5554

@@ -126,12 +125,12 @@ class AbstractLayer
126125
* @param barycentric_coords The thee barycentric coordinates.
127126
* @return The vector for the given barycentric coordinates with respect to the corresponding triangle. Default is an vertex with length 0.
128127
*/
129-
virtual lvr2::BaseVector<float> vectorAt(const std::array<lvr2::VertexHandle, 3>& vertices,
128+
virtual Vector vectorAt(const std::array<lvr2::VertexHandle, 3>& vertices,
130129
const std::array<float, 3>& barycentric_coords)
131130
{
132131
(void) vertices;
133132
(void) barycentric_coords;
134-
return lvr2::BaseVector<float>();
133+
return Vector();
135134
}
136135

137136
/**
@@ -140,7 +139,7 @@ class AbstractLayer
140139
* the vector field into the mesh map.
141140
* @return an optional vector map.
142141
*/
143-
virtual const boost::optional<lvr2::VertexMap<lvr2::BaseVector<float>>&> vectorMap()
142+
virtual const boost::optional<lvr2::VertexMap<Vector>&> vectorMap()
144143
{
145144
return boost::none;
146145
}
@@ -149,10 +148,10 @@ class AbstractLayer
149148
* @brief Optional method if the layer computes vectors. Computes a vector for a given vertex handle
150149
* @return a vector for the given vertex. Default is an vertex with length 0.
151150
*/
152-
virtual lvr2::BaseVector<float> vectorAt(const lvr2::VertexHandle& vertex)
151+
virtual Vector vectorAt(const lvr2::VertexHandle& vertex)
153152
{
154153
(void) vertex;
155-
return lvr2::BaseVector<float>();
154+
return Vector();
156155
}
157156

158157
/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef MESH_MAP__DEFINITIONS_H
2+
#define MESH_MAP__DEFINITIONS_H
3+
4+
#include <lvr2/geometry/BaseVector.hpp>
5+
#include <lvr2/geometry/Normal.hpp>
6+
#include <lvr2/geometry/PMPMesh.hpp>
7+
8+
namespace mesh_map
9+
{
10+
11+
using Normal = lvr2::Normal<float>;
12+
using Vector = lvr2::BaseVector<float>;
13+
14+
class MeshMap;
15+
class AbstractLayer;
16+
class LayerManager;
17+
class NanoFlannMeshAdaptor;
18+
class LayerTimer;
19+
20+
} // namespace mesh_map
21+
22+
#endif // MESH_MAP__DEFINITIONS_H

mesh_map/include/mesh_map/layer_manager.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
*
3636
*/
3737

38-
#pragma once
38+
#ifndef MESH_MAP__LAYER_MANAGER_H
39+
#define MESH_MAP__LAYER_MANAGER_H
3940

4041
#include <boost/graph/adjacency_list.hpp>
4142
#include <pluginlib/class_loader.hpp>
@@ -44,13 +45,11 @@
4445
#include <lvr2/geometry/Handles.hpp>
4546

4647
#include <mesh_map/abstract_layer.h>
48+
#include <mesh_map/definitions.h>
4749

4850
namespace mesh_map
4951
{
5052

51-
class AbstractLayer;
52-
class MeshMap;
53-
5453
class LayerManager
5554
{
5655
public:
@@ -166,3 +165,5 @@ class LayerManager
166165
};
167166

168167
} /* namespace mesh_map */
168+
169+
#endif // MESH_MAP__LAYER_MANAGER_H

mesh_map/include/mesh_map/mesh_map.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@
6161
#include <lvr2/algorithm/raycasting/RaycasterBase.hpp>
6262
#include <lvr2/geometry/BaseVector.hpp>
6363
#include <lvr2/io/AttributeMeshIOBase.hpp>
64-
#include <lvr2/geometry/BaseMesh.hpp>
64+
#include <lvr2/geometry/PMPMesh.hpp>
6565

6666
#include "nanoflann.hpp"
6767
#include "nanoflann_mesh_adaptor.h"
6868

6969
namespace mesh_map
7070
{
71-
class MeshMap : public std::enable_shared_from_this<MeshMap>
71+
72+
class MeshMap
73+
: public std::enable_shared_from_this<MeshMap>
7274
{
7375
public:
7476
inline static const std::string MESH_MAP_NAMESPACE = "mesh_map";
@@ -212,7 +214,7 @@ class MeshMap : public std::enable_shared_from_this<MeshMap>
212214
* @param barycentric_coords The barycentric coordinates of the query position.
213215
* @return An optional vector of the computed direction. It is valid if a vector has been computed successfully.
214216
*/
215-
boost::optional<Vector> directionAtPosition(const lvr2::VertexMap<lvr2::BaseVector<float>>& vector_map,
217+
boost::optional<Vector> directionAtPosition(const lvr2::VertexMap<Vector>& vector_map,
216218
const std::array<lvr2::VertexHandle, 3>& vertices,
217219
const std::array<float, 3>& barycentric_coords);
218220

@@ -269,7 +271,7 @@ class MeshMap : public std::enable_shared_from_this<MeshMap>
269271
/**
270272
* @brief Returns the stored mesh
271273
*/
272-
std::shared_ptr<lvr2::BaseMesh<Vector> > mesh()
274+
std::shared_ptr<lvr2::PMPMesh<Vector> > mesh()
273275
{
274276
return mesh_ptr;
275277
}
@@ -399,7 +401,7 @@ class MeshMap : public std::enable_shared_from_this<MeshMap>
399401
* @param vector_map The vector field to publish
400402
* @param publish_face_vectors Enables to publish an additional vertex for the triangle's center.
401403
*/
402-
void publishVectorField(const std::string& name, const lvr2::DenseVertexMap<lvr2::BaseVector<float>>& vector_map,
404+
void publishVectorField(const std::string& name, const lvr2::DenseVertexMap<Vector>& vector_map,
403405
const bool publish_face_vectors = false);
404406

405407
/**
@@ -410,7 +412,7 @@ class MeshMap : public std::enable_shared_from_this<MeshMap>
410412
* @param cost_function A cost function to compute costs inside a triangle
411413
* @param publish_face_vectors Enables to publish an additional vertex for the triangle's center.
412414
*/
413-
void publishVectorField(const std::string& name, const lvr2::DenseVertexMap<lvr2::BaseVector<float>>& vector_map,
415+
void publishVectorField(const std::string& name, const lvr2::DenseVertexMap<Vector>& vector_map,
414416
const lvr2::DenseVertexMap<float>& values,
415417
const std::function<float(float)>& cost_function = {},
416418
const bool publish_face_vectors = false);
@@ -453,8 +455,7 @@ class MeshMap : public std::enable_shared_from_this<MeshMap>
453455
//! However we could also implement a server connection here
454456
//! We might use the pluginlib for that
455457
std::shared_ptr<lvr2::AttributeMeshIOBase> mesh_io_ptr;
456-
std::shared_ptr<lvr2::BaseMesh<Vector>> mesh_ptr;
457-
std::string hem_impl_;
458+
std::shared_ptr<lvr2::PMPMesh<Vector> > mesh_ptr;
458459

459460
private:
460461

mesh_map/include/mesh_map/nanoflann_mesh_adaptor.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,21 @@
3838
#ifndef MESH_MAP__NANOFLANN_MESH_ADAPTOR_H
3939
#define MESH_MAP__NANOFLANN_MESH_ADAPTOR_H
4040

41-
#include <lvr2/geometry/BaseMesh.hpp>
41+
#include <lvr2/geometry/PMPMesh.hpp>
4242
#include "nanoflann.hpp"
43+
#include <mesh_map/util.h>
44+
45+
namespace mesh_map
46+
{
4347

44-
namespace mesh_map{
4548
struct NanoFlannMeshAdaptor
4649
{
47-
const std::shared_ptr<lvr2::BaseMesh<lvr2::BaseVector<float>>> mesh;
50+
const std::shared_ptr<lvr2::PMPMesh<Vector> > mesh;
4851

4952
/// The constructor that sets the data set source
50-
NanoFlannMeshAdaptor(const std::shared_ptr<lvr2::BaseMesh<lvr2::BaseVector<float>>> mesh) : mesh(mesh) { }
53+
NanoFlannMeshAdaptor(const std::shared_ptr<lvr2::PMPMesh<Vector> > mesh)
54+
:mesh(mesh)
55+
{ }
5156

5257
inline lvr2::Index kdtree_get_point_count() const { return mesh->nextVertexIndex(); }
5358

@@ -56,7 +61,7 @@ struct NanoFlannMeshAdaptor
5661
const lvr2::VertexHandle vH(idx);
5762
if(mesh->containsVertex(vH))
5863
{
59-
const lvr2::BaseVector<float>& vertex = mesh->getVertexPosition(vH);
64+
const Vector& vertex = mesh->getVertexPosition(vH);
6065
if (dim == 0) return vertex.x;
6166
else if (dim == 1) return vertex.y;
6267
else return vertex.z;
@@ -68,6 +73,7 @@ struct NanoFlannMeshAdaptor
6873
bool kdtree_get_bbox(BBOX& /*bb*/) const { return false; }
6974

7075
}; // end of PointCloudAdaptor
71-
}
76+
77+
} // namespace mesh_map
7278

7379
#endif /* MESH_MAP__NANOFLANN_MESH_ADAPTOR_H */

mesh_map/include/mesh_map/util.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@
4949
#include <tf2/LinearMath/Vector3.h>
5050

5151
#include <lvr2/types/MeshBuffer.hpp>
52+
#include <lvr2/geometry/PMPMesh.hpp>
5253
#include <assimp/scene.h>
5354

55+
#include <mesh_map/definitions.h>
56+
5457
namespace mesh_map
5558
{
5659

57-
//! use normals with datatype float
58-
typedef lvr2::Normal<float> Normal;
59-
60-
//! use vectors with datatype folat
61-
typedef lvr2::BaseVector<float> Vector;
6260

6361

6462
lvr2::MeshBufferPtr extractMeshByName(const aiScene* ascene, std::string name);

0 commit comments

Comments
 (0)