cnr-isti-vclab / meshlab

The open source mesh processing system
http://www.meshlab.net
GNU General Public License v3.0
4.7k stars 821 forks source link

Feature Request: Quadric Edge Collapse Decimation with "Check Surface Distance" #977

Open jambus1986 opened 3 years ago

jambus1986 commented 3 years ago

Hi, you do very great work!!

to my question:

i need to simplyfy an very large mesh from a laserscan. but i am not allowed, to differ from original model more then 1 millimeter.

can you stop the "Quadric Edge Collapse Decimation" algorithm when a specific distance is reached instead of a target-triangle-count or procentual number?

thx

cignoni commented 3 years ago

Controlled simplification that respects hausdorff distance can easily implemented with a very small pymeshlab script :

import numpy as np
import pymeshlab as ml

ms = ml.MeshSet()
ms.load_new_mesh("laurana50k.ply"); # load two copies of the model, one will be simplified, the other used for reference
ms.load_new_mesh("laurana50k.ply"); # laurana model is in mm, 80cm large. 
print("Starting Face Num:",ms.current_mesh().face_number(), "VertNum",ms.current_mesh().vertex_number())
error=0.0
while error < 2.0 :  # target a 2mm error, repeat until you reach the error.
    ms.simplification_quadric_edge_collapse_decimation(targetperc=0.9)
    error = ms.hausdorff_distance(sampledmesh=0,targetmesh=1,samplevert=False,sampleface=True,samplenum=500000)['max']
    print("Current  Face Num:",ms.current_mesh().face_number(), "VertNum",ms.current_mesh().vertex_number(), "Max distance ",error)
jambus1986 commented 3 years ago

this is a nice solution, but works always for the whole model, i think about interrupting the algorithm on each vertex, that is simplified, when distance is too large...

alemuntoni commented 3 years ago

Sorry, this is a feature that is now not available in meshlab. The implementation of the decimation does not have maximum distance as a stop criteria.