maliput
mesh_simplification.h File Reference
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <functional>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
#include "maliput/common/maliput_hash.h"
#include "maliput/math/vector.h"
#include "maliput/utility/mesh.h"
Include dependency graph for mesh_simplification.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  DirectedEdgeIndex
 Index for a directed edge in a GeoMesh. More...
 
struct  FaceEdgeIndex
 Index for a face edge in a GeoMesh. More...
 
struct  FaceVertexIndex
 Index of a face vertex in a GeoMesh. More...
 

Namespaces

 maliput
 Code in this file is inspired by: https://github.com/RobotLocomotion/drake/blob/master/common/text_logging.h.
 
 maliput::utility
 
 maliput::utility::mesh
 

Typedefs

using InverseFaceEdgeMap = std::unordered_map< DirectedEdgeIndex, FaceEdgeIndex, maliput::common::DefaultHash >
 The inverse of the mapping from face edges indices to their associated directed edge indices. More...
 
using FaceAdjacencyMap = std::unordered_map< int, std::vector< FaceEdgeIndex > >
 A mapping from each IndexFace index in a given GeoMesh to each of its adjacent faces, along with the index of the edge these share. More...
 

Functions

double DistanceToAPlane (const math::Vector3 n, const math::Vector3 p, const math::Vector3 q)
 Let \(B\) be a plane in the 3D Inertial Frame defined by a point \(p\) and a normal non-zero vector \(n\), and let \(q\) be another point in the 3D Inertial Frame. More...
 
double DistanceToALine (const math::Vector3 &p, const math::Vector3 &r, const math::Vector3 &q)
 Let \(F(t) = P + Rt\) be a parametric line in the 3D Inertial Frame defined by a point \(P\) and a vector \(R\), and let \(Q\) be another point in the 3D Inertial Frame. More...
 
bool operator== (const DirectedEdgeIndex &lhs, const DirectedEdgeIndex &rhs)
 
bool operator!= (const DirectedEdgeIndex &lhs, const DirectedEdgeIndex &rhs)
 
template<class HashAlgorithm >
void hash_append (HashAlgorithm &hasher, const DirectedEdgeIndex &item) noexcept
 Implements the hash_append generic hashing concept. More...
 
bool operator== (const FaceEdgeIndex &lhs, const FaceEdgeIndex &rhs)
 
bool operator!= (const FaceEdgeIndex &lhs, const FaceEdgeIndex &rhs)
 
InverseFaceEdgeMap ComputeInverseFaceEdgeMap (const std::vector< IndexFace > &faces)
 Computes the inverse of the mapping from face edges indices to their associated directed edge indices for the given faces collection. More...
 
FaceAdjacencyMap ComputeFaceAdjacencyMap (const std::vector< IndexFace > &faces)
 Computes a mapping from each IndexFace index in faces to each of its adjacent faces, along with the index of the edge these share. More...
 
const math::Vector3 & GetMeshFaceVertexPosition (const GeoMesh &mesh, const IndexFace::Vertex &vertex)
 Gets global position of the vertex in the given mesh. More...
 
const math::Vector3 & GetMeshFaceVertexNormal (const GeoMesh &mesh, const IndexFace::Vertex &vertex)
 Gets normal vector of the vertex in the given mesh. More...
 
template<typename InputIt >
bool DoMeshVerticesLieOnPlane (const GeoMesh &mesh, InputIt first, InputIt last, const math::Vector3 &n, const math::Vector3 &p, double tolerance)
 Checks if all the IndexFace::Vertex instances, from first to last, in the given mesh lie on the provided plane defined by a normal non-zero vector n and a point p by verifying all of them are within one tolerance distance, in meters, away from it along the line subtended by its normal. More...
 
bool IsMeshFaceCoplanarWithPlane (const GeoMesh &mesh, const IndexFace &face, const math::Vector3 &n, const math::Vector3 &p, double tolerance)
 Checks if the face in the given mesh is coplanar with the given plane defined by a normal non-zero vector n and a point p, by verifying if all face vertices are within one tolerance distance, in meters, from it. More...
 
bool IsMeshFacePlanar (const GeoMesh &mesh, const IndexFace &face, double tolerance, math::Vector3 *n, math::Vector3 *p)
 Checks if the face in the given mesh is planar, by verifying all face vertices lie on a plane using the given tolerance (see DoMeshVerticesLieOnPlane()). More...
 
std::set< int > AggregateAdjacentCoplanarMeshFaces (const GeoMesh &mesh, int start_face_index, const FaceAdjacencyMap &adjacent_faces_map, double tolerance, std::set< int > *visited_faces_indices)
 Aggregates all coplanar faces adjacent to the referred face in the mesh. More...
 
FaceEdgeIndex FindOuterFaceEdgeIndex (const std::set< int > &simply_connected_faces_indices, const FaceAdjacencyMap &adjacent_faces_map)
 Finds the index to the first outer face edge in the given simply_connected_faces_indices. More...
 
std::vector< FaceVertexIndex > ComputeMeshFacesContour (const std::set< int > &simply_connected_faces_indices, const FaceAdjacencyMap &adjacent_faces_map)
 Computes the contour of the simply connected region that all the faces referred by the given simply_connected_faces_indices yield. More...
 
const IndexFace::Vertex & MeshFaceVertexAt (const GeoMesh &mesh, const FaceVertexIndex &face_vertex_index)
 Gets the face vertex in the mesh referred by the given face_vertex_index. More...
 
template<typename InputIt , typename VertexFn , typename EdgeFn , typename OutputIt >
void ApplyDouglasPeuckerSimplification (InputIt first, InputIt last, VertexFn to_vertex, EdgeFn to_edge, double tolerance, OutputIt output)
 Applies the Douglas-Peucker simplification algorithm [1] over the given collection of vertices. More...
 
std::vector< FaceVertexIndex > SimplifyMeshFacesContour (const GeoMesh &mesh, const std::vector< FaceVertexIndex > &contour_indices, double tolerance)
 Simplifies the mesh faces' contour referred by the given contour_indices by elimination of redundant vertices, i.e. More...
 
GeoFace MergeMeshFaces (const GeoMesh &mesh, const std::set< int > &mergeable_faces_indices, const FaceAdjacencyMap &adjacent_faces_map, double tolerance)
 Merges all the faces in the given mesh referred by mergeable_faces_indices into a single GeoFace. More...
 
GeoMesh SimplifyMeshFaces (const GeoMesh &input_mesh, double tolerance)
 Simplifies a mesh by merging adjacent coplanar faces. More...