Contente
(Sergio Magalhães Contente)
March 20, 2023, 2:16pm
1
Hello, everyone.
In order to use the decimation method, we call the method:
segmentation.SetConversionParameter("Decimation factor", "0.90")
My question is: by default, this method implements the DecimatePro algorithm or the new Quadric/FastQuadric ones? If not, then how can I call it using python to select which one I want to use (such as the “Boundary Deletion” checkbox in the GUI version).
For context purpouse, when I use the decimate by GUI I get an OBJ file with 200MB size and when I use python scripts with CLI I get an OBJ with 1GB with this decimate method from segmentation module. I’m trying to figure out why there is this difference.
lassoan
(Andras Lasso)
March 20, 2023, 2:17pm
2
You can have a look at what the GUI does and do the same in your script:
def decimate(inputModel, outputModel, reductionFactor=0.8, decimateBoundary=True, lossless=False, aggressiveness=7.0):
"""Perform a topology-preserving reduction of surface triangles. FastMesh method uses Sven Forstmann's method
(https://github.com/sp4cerat/Fast-Quadric-Mesh-Simplification).
:param reductionFactor: Target reduction factor during decimation. Ratio of triangles that are requested to
be eliminated. 0.8 means that the mesh size is requested to be reduced by 80%.
:param decimateBoundary: If enabled then 'FastQuadric' method is used (it provides more even element sizes but cannot
be forced to preserve boundary), otherwise 'DecimatePro' method is used (that can preserve boundary edges but tend
to create more ill-shaped triangles).
:param lossless: Lossless remeshing for FastQuadric method. The flag has no effect if other method is used.
:param aggressiveness: Balances between accuracy and computation time for FastQuadric method (default = 7.0). The flag has no effect if other method is used.
"""
parameters = {
"inputModel": inputModel,
"outputModel": outputModel,
"reductionFactor": reductionFactor,
"method": "FastQuadric" if decimateBoundary else "DecimatePro",
"boundaryDeletion": decimateBoundary
}
cliNode = slicer.cli.runSync(slicer.modules.decimation, None, parameters)
slicer.mrmlScene.RemoveNode(cliNode)
Contente
(Sergio Magalhães Contente)
March 20, 2023, 7:31pm
3
Thank you very much. I’ve managed to finally decrease the size of the models using this approach.
1 Like