maliput
maliput::utility::mesh Namespace Reference

## 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...

class  GeoFace
An Inertial-frame face: a sequence of vertices with corresponding normals. More...

class  GeoMesh
An Inertial-frame mesh: a collection of GeoFaces. More...

class  GeoNormal
An Inertial-frame normal vector. More...

class  GeoVertex
An Inertial-frame vertex. More...

class  IndexFace
A face — a sequence of vertices with normals — in which the vertices and normals are represented by integer indices into some other container/dictionary. More...

class  SrhFace
A Lane-frame face: a sequence of vertices expressed in the (s,r,h) coordinates of an api::Lane (which is not referenced here). More...

class  UniqueIndexer
A container for a set of unique objects which keeps track of the original insertion order. More...

## 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...

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::Vector3GetMeshFaceVertexPosition (const GeoMesh &mesh, const IndexFace::Vertex &vertex)
Gets global position of the vertex in the given mesh. More...

const math::Vector3GetMeshFaceVertexNormal (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...

Finds the index to the first outer face edge in the given simply_connected_faces_indices. More...

Computes the contour of the simply connected region that all the faces referred by the given simply_connected_faces_indices yield. More...

const IndexFace::VertexMeshFaceVertexAt (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  over the given collection of vertices. More...

std::vector< FaceVertexIndexSimplifyMeshFacesContour (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...

## Typedef Documentation

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.

FaceEdgeIndex

## ◆ InverseFaceEdgeMap

 using InverseFaceEdgeMap = std::unordered_map

The inverse of the mapping from face edges indices to their associated directed edge indices.

ComputeInverseFaceEdgeMap

## Function Documentation

 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.

Parameters
 mesh Mesh where faces are to be found. start_face_index Index of the face to start aggregation with. adjacent_faces_map Map of adjacent faces associated with the given mesh. tolerance For coplanarity checks, in meters. See IsMeshFacePlanar() and IsMeshFaceCoplanarWithPlane() functions for further details. visited_faces_indices The indices of the faces visited so far.
Returns
The indices of the adjacent coplanar faces found.
Precondition
Given start_face_index is valid for the given mesh.
Given tolerance is a positive real number.
Given visited_faces_indices collection is not nullptr.
Given start_face_index has not been visited yet (i.e. visited_faces_indices.count(start_face_index) == 0).
Postcondition
All adjacent coplanar faces found are marked as visited.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ ApplyDouglasPeuckerSimplification()

 void maliput::utility::mesh::ApplyDouglasPeuckerSimplification ( InputIt first, InputIt last, VertexFn to_vertex, EdgeFn to_edge, double tolerance, OutputIt output )

Applies the Douglas-Peucker simplification algorithm  over the given collection of vertices.

•  Douglas, D. H., & Peucker, T. K. (1973). Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartographica: The International Journal for Geographic Information and Geovisualization, 10(2), 112–122.
Parameters
 first Iterator to first element of the collection. last Iterator to the last element of the collection. to_vertex A function to retrieve the vertex associated with an element of the collection (may be a pass-through). to_edge A function to construct an edge out of a pair of vertices. This function must return a std::pair containing the origin vertex and the unit direction vector of the parametric line. tolerance Simplification tolerance, in distance units. output Output iterator for the simplification result.
Template Parameters
 InputIt Input iterators type. VertexFn Vertex getter function type. EdgeFn Edge building function type. OutputIt Output iterator type.

Computes a mapping from each IndexFace index in faces to each of its adjacent faces, along with the index of the edge these share.

For each face at index i in faces, a sequence to map each edge j to its adjacent face and edge index is added to the map at i. If a given edge is not adjacent to any face, an invalid face and edge index (both set to -1, see FaceEdgeIndex) is put in its place.

Precondition
Any given pair of vertices is shared by two faces at most.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ ComputeInverseFaceEdgeMap()

 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.

Precondition
Mapping from directed edges to face edges is 1-to-1. In other words, any given pair of vertices can be shared by two faces at most. This implies that the mesh is well-oriented, such that any adjacent have the common edge in opposite directions.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ ComputeMeshFacesContour()

 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.

Parameters
 simply_connected_faces_indices Indices of the faces whose outer face edge is to be found. adjacent_faces_map Mapping of adjacent faces for the faces referred in simply_connected_faces_indices.
Returns
Face vertices as a counter-clockwise contour.
Precondition
The union of the all the faces referred by the given simply_connected_faces_indices yield a simply connected region (i.e. with no holes).

## ◆ DistanceToALine()

 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.

This function returns the Euclidean distance of $$Q$$ to $$F(t)$$.

Parameters
 p Is the origin of the parametric line. r Is the direction of the parametric line. q Is a coordinate out of the line.
Returns
The Euclidean distance of q point to the line $$F(t)$$.

## ◆ DistanceToAPlane()

 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.

This method returns the Euclidean distance of $$q$$ to $$B$$.

Parameters
 n Is a vector normal to the plane. p Is a coordinate in the plane. q Is a coordinate out of the plane.
Returns
The Euclidean distance of q point to the plane $$B$$.
Precondition
The norm of n is different from zero.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ DoMeshVerticesLieOnPlane()

 bool maliput::utility::mesh::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.

Precondition
Given vertices belong to the mesh.
Warning
If any of the preconditions is not met, this function will abort execution.
Template Parameters
 InputIt An IndexFace::Vertex container iterator type.

## ◆ FindOuterFaceEdgeIndex()

 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.

Parameters
 simply_connected_faces_indices Indices of the faces whose outer face edge is to be found. adjacent_faces_map Mapping of adjacent faces for the faces referred by simply_connected_faces_indices.
Returns
The index of first outer face edge found or an invalid index if it failed to find any due to unmet preconditions.
Precondition
The union of the all the faces referred by the given simply_connected_faces_indices yields a simply connected region (i.e. with no holes).

## ◆ GetMeshFaceVertexNormal()

 const math::Vector3 & GetMeshFaceVertexNormal ( const GeoMesh & mesh, const IndexFace::Vertex & vertex )

Gets normal vector of the vertex in the given mesh.

Precondition
Given vertex belongs to the mesh.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ GetMeshFaceVertexPosition()

 const math::Vector3 & GetMeshFaceVertexPosition ( const GeoMesh & mesh, const IndexFace::Vertex & vertex )

Gets global position of the vertex in the given mesh.

Precondition
Given vertex belongs to the mesh.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ hash_append()

 void maliput::utility::mesh::hash_append ( HashAlgorithm & hasher, const DirectedEdgeIndex & item )
noexcept

Implements the hash_append generic hashing concept.

## ◆ IsMeshFaceCoplanarWithPlane()

 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.

Precondition
Given face belongs to the mesh.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ IsMeshFacePlanar()

 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()).

Said plane, built out of the first vertex position and normal in the face, is returned as a plane defined by a point p and a normal non-zero vector n.

Parameters
 [in] mesh Is a Inertial-frame mesh. [in] face Is a sequence of vertices with normals. [in] tolerance Is the tolerance to compute face planarity. [out] n Is a vector that with p define a plane that should contain all the face vertices. [out] p Is a point that with n define a plane that should contain all the face vertices.
Precondition
Given n is not nullptr.
Given p is not nullptr.
Given face belongs to the mesh.
Given face has at least three (3) vertices.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ MergeMeshFaces()

 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.

Parameters
 mesh Mesh the faces to be merged belong to. mergeable_faces_indices Indices of the faces in mesh to be merged. adjacent_faces_map Mapping of adjacent faces for the faces referred in mergeable_faces_indices. tolerance For contour simplification, in meters. See SimplifyMeshFacesContour() function for further details.
Returns
Merged mesh faces as a single GeoFace.
Precondition
The union of the all the faces referred by the given mergeable_faces_indices yields a simply connected region (i.e. with no holes).

## ◆ MeshFaceVertexAt()

 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.

Precondition
Given face_vertex_index refers to a valid vertex in the mesh.
Warning
If any of the preconditions is not met, this function will abort execution.

## ◆ operator!=() [1/2]

 bool maliput::utility::mesh::operator!= ( const DirectedEdgeIndex & lhs, const DirectedEdgeIndex & rhs )

## ◆ operator!=() [2/2]

 bool maliput::utility::mesh::operator!= ( const FaceEdgeIndex & lhs, const FaceEdgeIndex & rhs )

## ◆ operator==() [1/2]

 bool maliput::utility::mesh::operator== ( const DirectedEdgeIndex & lhs, const DirectedEdgeIndex & rhs )

## ◆ operator==() [2/2]

 bool maliput::utility::mesh::operator== ( const FaceEdgeIndex & lhs, const FaceEdgeIndex & rhs )

## ◆ SimplifyMeshFaces()

 GeoMesh SimplifyMeshFaces ( const GeoMesh & input_mesh, double tolerance )

Simplifies a mesh by merging adjacent coplanar faces.

Parameters
 input_mesh Mesh to be simplified. tolerance Tolerance for simplification, in meters. See MergeMeshFaces() and AggregateAdjacentCoplanarMeshFaces() functions for further details.
Returns
Output, simplified mesh.
Precondition
The union of the all the faces in the given input_mesh yields a simply connected region (i.e. with no holes).

## ◆ SimplifyMeshFacesContour()

 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.

vertices that lie within one tolerance distance, in meters, from the line that the their following and preceding vertices subtend.