Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PMP::longest_edge() #6496

Closed
wants to merge 15 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,54 @@ squared_edge_length(typename boost::graph_traits<PolygonMesh>::edge_descriptor e
return squared_edge_length(halfedge(e, pmesh), pmesh, np);
}

/**
* \ingroup PMP_measure_grp
*
* Finds the longest edge of a given polygon mesh.
MaelRL marked this conversation as resolved.
Show resolved Hide resolved
*
* @tparam PolygonMesh a model of `HalfedgeGraph`
MaelRL marked this conversation as resolved.
Show resolved Hide resolved
* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
*
* @param pmesh the polygon mesh to which `h` belongs
MaelRL marked this conversation as resolved.
Show resolved Hide resolved
* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
*
* \cgalNamedParamsBegin
* \cgalParamNBegin{vertex_point_map}
* \cgalParamDescription{a property map associating points to the vertices of `pmesh`}
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<PolygonMesh>::%vertex_descriptor`
* as key type and `%Point_3` as value type}
* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`}
* \cgalParamNEnd
*
* \cgalParamNBegin{geom_traits}
* \cgalParamDescription{an instance of a geometric traits class}
* \cgalParamType{a class model of `Kernel`}
* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`}
* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.}
* \cgalParamNEnd
* \cgalNamedParamsEnd
*
* @return the longest edge in `pmesh`. The return type is an `edge_descriptor`.
*
* @sa `squared_edge_length()`
* @sa `longest_border()`
*/

template<typename PolygonMesh,
typename NamedParameters = parameters::Default_named_parameters>
inline typename boost::graph_traits<PolygonMesh>::edge_descriptor
longest_edge(const PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) {

auto edge_range = edges(pmesh);
MaelRL marked this conversation as resolved.
Show resolved Hide resolved

CGAL_assertion(edge_range.size() > 0);
MaelRL marked this conversation as resolved.
Show resolved Hide resolved

return *std::max_element(edge_range.begin(), edge_range.end(), [&pmesh, &np](auto l, auto r) {
return squared_edge_length(l, pmesh, np)
MaelRL marked this conversation as resolved.
Show resolved Hide resolved
< squared_edge_length(r, pmesh, np);
});
}

/**
* \ingroup PMP_measure_grp
*
Expand Down