How to Control the Target Quad Count in AutoRemesher: CLI and GUI Methods
Use the --target-quads command-line flag (default 50000) or the "Target Quads" spinner in the GUI to set the desired quadrilateral face count, which AutoRemesher internally doubles to calculate the target triangle count for the remeshing algorithm.
The open-source AutoRemesher project (huxingyi/autoremesher) provides automatic quad-dominant remeshing for 3D models. Controlling the target quad count allows you to dictate the density of the output mesh, balancing detail against file size and processing time. Whether you prefer command-line automation or interactive GUI adjustments, the repository exposes this parameter through a unified internal API that converts your quad target into the triangle budget used by the remeshing core.
Command-Line Interface
The CLI entry point in src/main.cpp defines the --target-quads option with a default value of 50000. The argument is declared at lines 102-105 and parsed at lines 61-62.
./autoremesher \
--input model.obj \
--output remeshed.obj \
--target-quads 80000
You can specify any integer between 1000 and 1000000. Values outside this range are not validated by the CLI parser itself, but the remeshing core may produce unstable results if the count is extremely low or high.
Graphical User Interface
The main window constructor in src/mainwindow.cpp instantiates an IntNumberWidget for the target quad count at lines 207-214. This widget enforces a valid range of 1000 to 1000000 quads via setRange at line 209 and connects to the m_targetQuadCount member variable through a lambda at lines 212-214.
// From src/mainwindow.cpp
m_targetQuadCountWidget = new IntNumberWidget(this, false);
m_targetQuadCountWidget->setItemName(tr("Target Quads"));
m_targetQuadCountWidget->setRange(1000, 1000000);
m_targetQuadCountWidget->setValue(m_targetQuadCount);
connect(m_targetQuadCountWidget, &IntNumberWidget::valueChanged,
[=](int value) { m_targetQuadCount = value; });
When you adjust the spinner in the Preferences panel, the new value is stored immediately in m_targetQuadCount and will be applied the next time you trigger the remeshing operation.
Internal Conversion to Triangle Count
The remeshing algorithm operates on triangles, so AutoRemesher converts the target quad count to a target triangle count by doubling the value. This calculation occurs in src/mainwindow.cpp at lines 773 and 814, where parameters.targetTriangleCount is assigned m_targetQuadCount * 2.
// Parameters passed to the remeshing core
RemeshingParameters params;
params.targetTriangleCount = m_targetQuadCount * 2; // e.g., 50000 quads → 100000 triangles
This conversion ensures that the final quad-dominant mesh contains approximately the number of faces you requested, since each quadrilateral is formed by two triangles during the intermediate processing steps.
Practical Examples
Batch Processing with Custom Density
# Generate a high-density mesh (~120k quads)
./autoremesher --input scan.obj --output detailed.obj --target-quads 120000
# Generate a lightweight mesh for real-time preview
./autoremesher --input scan.obj --output preview.obj --target-quads 5000
Adjusting the UI Widget Programmatically
If you are extending the application or writing a plugin that manipulates the main window before display, you can preset the widget value:
// Access the widget before showing the window
mainWindow->m_targetQuadCountWidget->setValue(25000);
mainWindow->m_targetQuadCountWidget->valueChanged(25000); // Trigger the lambda update
Summary
- The
--target-quadsCLI option accepts values from 1000 to 1000000, defaulting to 50000. - The GUI uses an
IntNumberWidgetdefined insrc/mainwindow.cppwith the same range constraints. - Internally, AutoRemesher multiplies the target quad count by 2 to derive
targetTriangleCountfor the remeshing core. - Both interfaces ultimately modify the same
m_targetQuadCountvariable that drives the algorithm.
Frequently Asked Questions
What is the default target quad count if I don't specify it?
The default value is 50000 quads. This is hardcoded in the CLI argument parser at src/main.cpp lines 102-105 and reflected in the GUI widget initialization in src/mainwindow.cpp.
Why does the remesher use triangle count internally when I specified quads?
The underlying algorithm operates on triangle meshes. As implemented in src/mainwindow.cpp lines 773-814, AutoRemesher converts your target quad count to a target triangle count by multiplying by 2, ensuring the final quad-dominant mesh matches your desired density.
What happens if I set a value outside the 1000-1000000 range?
The GUI IntNumberWidget enforces this range at the UI level via setRange(1000, 1000000) at src/mainwindow.cpp line 209. If using the CLI, values outside this range may still be accepted by the parser but could lead to extreme mesh densities or processing failures; the source code does not appear to clamp CLI values explicitly.
Can I change the target quad count after loading a model in the GUI?
Yes. The widget is connected via a lambda that updates m_targetQuadCount immediately when the value changes (src/mainwindow.cpp lines 212-214). You must regenerate the mesh (typically by clicking the remesh button) for the new count to take effect, as the parameter is read when the remeshing process starts.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →