Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix face area weighting in quadric edge collapse #238

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

flm8620
Copy link

@flm8620 flm8620 commented May 21, 2024

Thank you for sending a Pull Request to the VCGLib!

Check with [x] what is your case:
  • I already signed and sent via email the CLA;
  • I will sign and send the CLA via email as soon as possible;
  • I don't want to sign the CLA.

I think there is a bug in the area weighting of quadric edge decimation. In the paper "Simplifying Surfaces with Color and Texture using Quadric Error Metrics" and "New Quadric Metric for Simplifying Meshes
with Appearance Attributes", they both mentioned that the area weighting should be appied on the matrix Q, meaning Q *= Area.

But in the vcglib's implementation, the squared area is multiplied into Q. I think it's a mistake. The current code

facePlane.SetDirection( ( (*fi).V(1)->cP() - (*fi).V(0)->cP() ) ^  ( (*fi).V(2)->cP() - (*fi).V(0)->cP() ));

will actually multiple the area into the unit normal vector. And this face normal vector is used to construct the matrix Q, where each component is squared, or multiplied to each other, therefore the squared area is incorrectly weighted into Q.

Here is an actual experiment:
In meshlab, we can take a sphere mesh and select half of its faces and do subdivision (Here I used midpoint subdivision three times)
截屏2024-05-21 21 37 05
And we decimate the mesh to 10000 faces. In the current implementation, we will observe a non-uniform face size. It's because the area is incorrectly squared, and most face area area less than one. So the smaller face will have a incorrect even smaller weight, which make the algorithm think the smaller face should have fewer cost, therefore being decimated much more.

截屏2024-05-21 21 50 21

After this fix, it works correctly. All the faces are distributed uniformly.

截屏2024-05-21 21 38 12

@FishWoWater
Copy link

Seems that UseArea not exposed to meshlab by default?
image

@flm8620
Copy link
Author

flm8620 commented May 29, 2024

UseArea is by default turned on. You can check the code, it's initialized to true.

@FishWoWater
Copy link

UseArea is by default turned on. You can check the code, it's initialized to true.

OK, you are right :)

@alemuntoni
Copy link
Member

Thank you very much, @flm8620! :)

@alemuntoni alemuntoni merged commit 48b5508 into cnr-isti-vclab:devel Jun 3, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants