# How to Preserve Sharp Edges with AutoRemesher: A Complete Technical Guide

> Learn to preserve sharp edges in AutoRemesher by setting a dihedral angle threshold. This guide explains how AutoRemesher uses feature edges to avoid collapse and smoothing for precise results.

- Repository: [Jeremy HU/autoremesher](https://github.com/huxingyi/autoremesher)
- Tags: how-to-guide
- Published: 2026-07-09

---

**You can preserve sharp edges with AutoRemesher by setting a dihedral angle threshold in degrees; the algorithm converts this to an included-angle radian value and marks exceeding edges as feature edges, excluding them from collapse and smoothing operations during remeshing.**

When remeshing 3D models, maintaining geometric fidelity at hard creases is critical for production workflows. You can **preserve sharp edges with AutoRemesher**, an open-source isotropic remeshing library by huxingyi, by configuring a user-defined angle threshold that protects feature edges through the entire pipeline. This guide explains the exact source code implementation, from UI parameter to geometric constraint.

## How to Preserve Sharp Edges with AutoRemesher: The Pipeline

The workflow follows a strict data flow from the user interface to the half-edge data structure. Understanding each stage ensures you can reliably configure edge preservation in both GUI and API contexts.

### Setting the Angle Threshold

The process begins with the **sharp edge degrees** parameter, representing the dihedral angle cutoff. In the GUI, this appears as a slider control stored in `m_sharpEdgeDegrees` [src/mainwindow.cpp](https://github.com/huxingyi/autoremesher/blob/master/src/mainwindow.cpp#L180-L186). For programmatic access, the `IsotropicRemesher` class exposes `setSharpEdgeDegrees()` to configure this threshold before remeshing begins [src/AutoRemesher/isotropicremesher.h](https://github.com/huxingyi/autoremesher/blob/master/src/AutoRemesher/isotropicremesher.h#L53-L56).

### Parameter Propagation to the Core Engine

When remeshing initiates, the parameter travels through the generator layer. The `QuadMeshGenerator` forwards the user-defined degrees to the remesher instance via `m_autoRemesher->setSharpEdgeDegrees(m_parameters.sharpEdgeDegrees)` [src/quadmeshgenerator.cpp](https://github.com/huxingyi/autoremesher/blob/master/src/quadmeshgenerator.cpp#L66). This bridges the UI settings to the computational backend.

### Radian Conversion and Feature Detection

Before mesh processing, the system converts degrees to radians using the complement formula to calculate the included angle:

```cpp
m_sharpEdgeThresholdRadians = (180 - degrees) * (M_PI/180.0);

```

This conversion occurs in `setSharpEdgeIncludedAngle` [src/AutoRemesher/isotropicremesher.cpp](https://github.com/huxingyi/autoremesher/blob/master/src/AutoRemesher/isotropicremesher.cpp#L36-L39). During remeshing, the half-edge mesh marks edges exceeding this threshold via `m_halfedgeMesh->featureEdges(m_sharpEdgeThresholdRadians)` [src/AutoRemesher/isotropicremesher.cpp](https://github.com/huxingyi/autoremesher/blob/master/src/AutoRemesher/isotropicremesher.cpp#L330-L333). These marked edges are excluded from edge-collapse and Laplacian smoothing operations.

## Implementation Code Examples

### C++ API Configuration

Use the `AutoRemesher` class interface to programmatically preserve sharp edges:

```cpp
#include "AutoRemesher/autoremesher.h"

// Initialize with your mesh data
AutoRemesher::AutoRemesher remesher(vertices, triangles);

// Preserve edges sharper than 45 degrees
remesher.setSharpEdgeDegrees(45.0);

// Execute remeshing
bool success = remesher.remesh();

// Access results
const auto& newVertices = remesher.remeshedVertices();
const auto& newTriangles = remesher.remeshedTriangles();

```

### GUI Workflow

1. Launch AutoRemesher and load your target mesh.
2. Locate the **Sharp Edge** slider (default: 60°).
3. Adjust the threshold—lower values (e.g., 30°) preserve more edges, while higher values allow increased smoothing.
4. Click **Remesh**; the system automatically propagates your setting through `setSharpEdgeDegrees()` and protects detected features.

## Key Source Files and Functions

Understanding the architecture requires familiarity with these specific components:

- **[`src/AutoRemesher/isotropicremesher.h`](https://github.com/huxingyi/autoremesher/blob/main/src/AutoRemesher/isotropicremesher.h)**: Declares `setSharpEdgeDegrees()` and the `m_sharpEdgeDegrees` storage member.
- **[`src/AutoRemesher/isotropicremesher.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/AutoRemesher/isotropicremesher.cpp)**: Implements radian conversion and calls `featureEdges()` to mark sharp edges.
- **[`src/quadmeshgenerator.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/quadmeshgenerator.cpp)**: Bridges UI parameters to the remesher instance.
- **[`src/AutoRemesher/autoremesher.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/AutoRemesher/autoremesher.cpp)**: Intermediate layer forwarding sharp edge values to the isotropic core.
- **[`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp)**: Houses the UI widget controlling the sharp edge angle input.

## Summary

- AutoRemesher preserves sharp edges by treating them as **feature edges** in the half-edge data structure.
- The pipeline uses a **dihedral angle threshold** converted to an included-angle radian via `(180 - degrees) * π/180`.
- Critical functions include `setSharpEdgeDegrees()` for configuration and `IsotropicRemesher::featureEdges()` for geometric marking.
- Implementation spans from [`mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/mainwindow.cpp) through [`quadmeshgenerator.cpp`](https://github.com/huxingyi/autoremesher/blob/main/quadmeshgenerator.cpp) to the core logic in [`isotropicremesher.cpp`](https://github.com/huxingyi/autoremesher/blob/main/isotropicremesher.cpp).

## Frequently Asked Questions

### What dihedral angle should I use to preserve sharp edges with AutoRemesher?

Start with **60 degrees** for general mechanical parts, which preserves intentional hard edges while allowing slight smoothing on rounded corners. Use **30–45 degrees** for high-detail models like character armor where subtle creases must remain crisp, and **90 degrees** for architectural models with strict right angles.

### Does AutoRemesher support per-edge sharpness control?

The current implementation uses a **global threshold** via `setSharpEdgeDegrees()` applied to the entire mesh. According to the source code in [`isotropicremesher.cpp`](https://github.com/huxingyi/autoremesher/blob/main/isotropicremesher.cpp), the `featureEdges()` method evaluates all edges against the single `m_sharpEdgeThresholdRadians` value. Per-edge customization would require modifying the half-edge marking logic directly.

### Why are my sharp edges still being smoothed after I adjusted the threshold?

Verify that you call `setSharpEdgeDegrees()` **before** `remesh()`, as the threshold is only applied during the initial feature detection phase at line 330 of [`isotropicremesher.cpp`](https://github.com/huxingyi/autoremesher/blob/main/isotropicremesher.cpp). Additionally, ensure your angle value is appropriate—values too high (e.g., 170°) treat nearly all edges as smooth, while extremely low values (e.g., 10°) may over-constrain the mesh and cause artifacts.

### How does preserving sharp edges affect final mesh density?

Protecting sharp edges constrains the remeshing algorithm along creases, often resulting in **higher triangle density** near these features to maintain geometric fidelity. The isotropic remesher balances this against the target edge length, so very low sharp-edge thresholds may produce locally dense clusters around every minor ridge.