File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ namespace geode
8484 [[nodiscard]] const std::array< PointType, 3 >& vertices () const ;
8585 [[nodiscard]] BoundingBox< dimension > bounding_box () const ;
8686 [[nodiscard]] local_index_t longest_edge_index () const ;
87+ [[nodiscard]] local_index_t smallest_edge_index () const ;
8788 [[nodiscard]] double minimum_height () const ;
8889 [[nodiscard]] bool is_degenerated () const ;
8990 [[nodiscard]] std::string string () const ;
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ namespace geode
4040 FORWARD_DECLARATION_DIMENSION_CLASS ( Polygon );
4141 FORWARD_DECLARATION_DIMENSION_CLASS ( Vector );
4242 FORWARD_DECLARATION_DIMENSION_CLASS ( BoundingBox );
43+ FORWARD_DECLARATION_DIMENSION_CLASS ( Segment );
4344 FORWARD_DECLARATION_DIMENSION_CLASS ( SurfaceEdges );
4445 FORWARD_DECLARATION_DIMENSION_CLASS ( SurfaceMeshBuilder );
4546
@@ -404,6 +405,9 @@ namespace geode
404405 [[nodiscard]] std::optional< PolygonEdge > polygon_edge_from_vertices (
405406 index_t from_vertex_id, index_t to_vertex_id ) const ;
406407
408+ [[nodiscard]] Segment< dimension > segment (
409+ const PolygonEdge& polygon_edge ) const ;
410+
407411 /* !
408412 * Find the polygon edges corresponding to a pair of vertex indices.
409413 * @return Local indices of the edges found
Original file line number Diff line number Diff line change @@ -256,6 +256,27 @@ namespace geode
256256 return max_length_edge_id;
257257 }
258258
259+ template < typename PointType, index_t dimension >
260+ local_index_t
261+ GenericTriangle< PointType, dimension >::smallest_edge_index() const
262+ {
263+ local_index_t min_length_edge_id{ NO_LID };
264+ auto edge_min_length = std::numeric_limits< double >::max ();
265+ for ( const auto edge_id : LRange{ 3 } )
266+ {
267+ const auto next_vertex = edge_id == 2 ? 0 : edge_id + 1 ;
268+ const Point< dimension >& point0 = vertices_.at ( edge_id );
269+ const Point< dimension >& point1 = vertices_.at ( next_vertex );
270+ const auto edge_length = point_point_distance ( point0, point1 );
271+ if ( edge_length < edge_min_length )
272+ {
273+ min_length_edge_id = edge_id;
274+ edge_min_length = edge_length;
275+ }
276+ }
277+ return min_length_edge_id;
278+ }
279+
259280 template < typename PointType, index_t dimension >
260281 double GenericTriangle< PointType, dimension >::minimum_height() const
261282 {
Original file line number Diff line number Diff line change @@ -911,6 +911,14 @@ namespace geode
911911 return std::nullopt ;
912912 }
913913
914+ template < index_t dimension >
915+ Segment< dimension > SurfaceMesh< dimension >::segment(
916+ const PolygonEdge& polygon_edge ) const
917+ {
918+ const auto vertices = polygon_edge_vertices ( polygon_edge );
919+ return { this ->point ( vertices[0 ] ), this ->point ( vertices[1 ] ) };
920+ }
921+
914922 template < index_t dimension >
915923 PolygonsAroundEdge SurfaceMesh< dimension >::polygons_from_edge_vertices(
916924 absl::Span< const index_t > edge_vertices ) const
You can’t perform that action at this time.
0 commit comments