# How Edge Scaling Factor and Target Quad Count Relate in AutoRemesher

> Understand how AutoRemesher's edge scaling factor and target quad count interact. Learn how edge scaling controls mesh density with a simple formula for precise remeshing results.

- Repository: [Jeremy HU/autoremesher](https://github.com/huxingyi/autoremesher)
- Tags: deep-dive
- Published: 2026-07-11

---

**The edge scaling factor acts as a multiplier on the base edge length calculated from the target quad count, allowing fine-grained control over final mesh density through the formula `finalEdgeLength = baseEdgeLength × edgeScaling` before the remeshing algorithm executes.**

AutoRemesher, the open-source quad-dominant mesh generator from `huxingyi/autoremesher`, balances user-specified density goals with adjustable edge length multipliers to produce clean topology. While the **target quad count** (`targetQuads`) establishes the approximate density goal, the **edge scaling factor** (`edgeScaling`) provides direct control over the actual edge length used during the remeshing process.

## The Mathematical Relationship Between Edge Scaling and Quad Count

The remesher derives the final mesh resolution through a two-step calculation that connects the nominal target count to the actual edge length constraint.

### Base Edge Length Estimation

First, AutoRemesher estimates a **base edge length** from the desired quad density. This value is roughly proportional to the square root of the target quad count divided by the mesh surface area (√(targetQuads / area)). This calculation establishes the approximate edge length that would yield the requested number of quads if no scaling were applied.

### Final Edge Length Calculation

The edge scaling factor directly modifies this base length before remeshing begins:

```

finalEdgeLength = baseEdgeLength × edgeScaling

```

The `QuadMeshGenerator` then attempts to maintain edge lengths close to this `finalEdgeLength` value. Because the scaling factor defaults to `1.0` with a valid range of `1.0` to `4.0` according to the UI constraints in the source code, users can modulate density as follows:

- **Scaling > 1.0** (e.g., 2.0 or 4.0): Produces longer edges, resulting in fewer quads than the nominal `targetQuads` value
- **Scaling < 1.0**: (if supported via command line) Produces shorter edges, creating more quads than the target
- **Scaling = 1.0**: Uses the calculated base edge length directly, attempting to match the target quad count closely

## Implementation in the AutoRemesher Source Code

The relationship between these parameters flows through three main components in the codebase, from UI storage to generator consumption.

### Parameter Storage in MainWindow

In [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp), the `MainWindow` class stores both values as member variables within the `setHeadlessParams` method (lines 706–715):

```cpp
void MainWindow::setHeadlessParams(const QString& inputPath,
                                   const QString& outputPath,
                                   int targetQuads, double edgeScaling,
                                   double sharpEdgeDegrees, double smoothNormalDegrees,
                                   double adaptivity)
{
    m_targetQuadCount = targetQuads;            // target quad count
    m_targetScaling   = static_cast<float>(edgeScaling); // edge-scaling factor
    // ...
}

```

### Struct Population for the Generator

The parameters are then packaged into a `QuadMeshGenerator::Parameters` struct before execution (lines 771–775 in [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp)):

```cpp
QuadMeshGenerator::Parameters parameters;
parameters.targetTriangleCount = m_targetQuadCount * 2; // quad count → triangle count
parameters.scaling             = m_targetScaling;      // edge-scaling factor

```

Note that the generator internally operates on triangle counts, multiplying the quad target by 2 since each quad comprises two triangles.

### UI Constraints and Validation

The Qt-based interface enforces the scaling factor range through a `FloatNumberWidget` (lines 216–221 in [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp)):

```cpp
m_targetScalingWidget = new FloatNumberWidget(this, false);
m_targetScalingWidget->setItemName(tr("Edge Scaling"));
m_targetScalingWidget->setRange(1.0, 4.0);
m_targetScalingWidget->setValue(m_targetScaling);
connect(m_targetScalingWidget, &FloatNumberWidget::valueChanged,
        [=](float value) { m_targetScaling = value; });

```

Meanwhile, [`src/main.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/main.cpp) handles command-line parsing for `--target-quads` and `--edge-scaling` flags, feeding these values into the same parameter pipeline.

## Practical Usage Examples

### Command-Line Workflow

To generate a mesh with 50,000 target quads but double the edge length (effectively reducing final quad count):

```bash
autoremesher -i model.obj -o model_remeshed.obj \
    --target-quads 50000 \
    --edge-scaling 2.0

```

### Programmatic Configuration

When using AutoRemesher as a library or extending the UI, the scaling factor is passed as a float to the parameter struct:

```cpp
// Configuring parameters directly
QuadMeshGenerator::Parameters params;
params.targetTriangleCount = 100000;  // Equivalent to 50,000 quads
params.scaling = 1.5f;              // 1.5x edge length multiplier

```

## Summary

- The **edge scaling factor** multiplies the base edge length derived from the **target quad count**, with the formula `finalEdgeLength = baseEdgeLength × edgeScaling`.
- Default scaling is `1.0` with a UI-enforced range of `1.0` to `4.0`, though command-line usage may support other values.
- Values greater than `1.0` reduce the final quad count below the target, while values less than `1.0` increase density beyond the target.
- The implementation flows from `MainWindow` storage in [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp) to the `QuadMeshGenerator::Parameters` struct, where `targetTriangleCount` is calculated as `targetQuads × 2`.

## Frequently Asked Questions

### What happens if I set the edge scaling factor to 2.0?

Setting the edge scaling factor to `2.0` doubles the target edge length compared to the value calculated from your target quad count. According to the source code implementation in [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp), this results in longer edges and approximately half the number of quads relative to your `--target-quads` specification, producing a coarser, more lightweight mesh.

### Why does AutoRemesher multiply the target quad count by 2 for triangles?

The `QuadMeshGenerator` algorithm internally operates on triangle counts rather than quad counts, as documented in lines 771–775 of [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp). Since every quadrilateral face consists of two triangles, the code sets `parameters.targetTriangleCount = m_targetQuadCount * 2` to ensure the remesher generates the correct number of quad faces while using triangle-based mesh operations internally.

### What is the default edge scaling value in AutoRemesher?

The default edge scaling value is `1.0`, which means the remesher uses the base edge length calculated directly from the target quad count without modification. This default is enforced in the UI through the `FloatNumberWidget` initialization shown in lines 216–221 of [`src/mainwindow.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/mainwindow.cpp).

### How does the edge scaling factor affect remeshing performance?

Higher edge scaling values (e.g., `3.0` or `4.0`) produce longer edges and fewer total polygons, which reduces computation time and memory usage during the remeshing process implemented in [`src/quadmeshgenerator.cpp`](https://github.com/huxingyi/autoremesher/blob/main/src/quadmeshgenerator.cpp). Conversely, scaling factors below `1.0` (if supported by your build) create denser meshes with more elements, increasing processing time but capturing finer surface details.