Skip to content

detect_sharp_features

detect_sharp_features(V, F, thres_concave=0.2, thres_convex=40.0)

Detect sharp edges, concave edges and corners of a triangle mesh.

An edge is sharp (convex) if the dihedral angle between its two faces deviates from flat by more than thres_convex degrees, and concave if the surface folds inwards along it by more than thres_concave. Feature edges are grouped into feature lines, split at corners. These are the features that a feature-preserving medial axis has to keep.

Parameters:

Name Type Description Default
V (n,3) numpy double array

Vertex positions of a closed, manifold triangle mesh.

required
F (m,3) numpy int array

Triangles.

required
thres_concave float, optional (default 0.2)

Threshold for concave edges (smaller is more sensitive).

0.2
thres_convex float, optional (default 40.0)

Dihedral angle threshold in degrees for sharp edges (smaller is more sensitive).

40.0

Returns:

Name Type Description
E (k,2) numpy int array

Feature edges, as indices into V.

E_type (k,) numpy int array

1 for a sharp (convex) edge, 2 for a concave edge.

E_line (k,) numpy int array

Id of the feature line containing each edge.

corners (c,) numpy int array

Corner vertices, as indices into V.

corner_type (c,) numpy int array

1 for a sharp corner (adjacent to sharp edges), 2 for a concave corner (adjacent to more than two concave edges only).

Notes

The mesh must be closed (no boundary edges).

C++: void libmat::detect_sharp_features(V, F, thres_concave, thres_convex, E, E_type, E_line, corners, corner_type) in <libmat/detect_sharp_features.h>.

Examples:

import numpy as np
import libmat
V, F = libmat.read_surface_mesh("data/mesh_69058.obj")
E, E_type, E_line, corners, corner_type = libmat.detect_sharp_features(V, F)
print("sharp edges:  ", np.sum(E_type == 1))
print("concave edges:", np.sum(E_type == 2))
print("feature lines:", len(np.unique(E_line)))

C++

#include <libmat/detect_sharp_features.h>

// Detect sharp (convex) feature edges, concave feature edges and corners of a
// closed triangle mesh, and group the feature edges into feature lines.
//
// Inputs:
//   V  #V by 3 vertex positions
//   F  #F by 3 triangles (closed, manifold)
//   thres_concave  threshold for concave edges (smaller = more sensitive)
//   thres_convex   dihedral angle threshold in degrees for sharp edges
//                  (smaller = more sensitive)
// Outputs:
//   E            #E by 2 feature edges (indices into V)
//   E_type       #E edge type: 1 = sharp (convex) edge, 2 = concave edge
//   E_line       #E id of the feature line each edge belongs to
//   corners      #C corner vertices (indices into V)
//   corner_type  #C corner type: 1 = sharp corner (adjacent to sharp edges),
//                2 = concave corner (adjacent to > 2 concave edges only)
void detect_sharp_features(const Eigen::MatrixXd& V, const Eigen::MatrixXi& F,
                           double thres_concave, double thres_convex,
                           Eigen::MatrixXi& E, Eigen::VectorXi& E_type,
                           Eigen::VectorXi& E_line, Eigen::VectorXi& corners,
                           Eigen::VectorXi& corner_type);