0

I need to process some 3D geometry, I created a program that transform the mesh geometry but keeping the overall mesh volume.

I have some information associated with each face on the input mesh, and I need to propagate this information to the output mesh. Id like to avoid using property_maps because it's not working with all algorithms and I prefer to have the flexibility to use any algorithm and reconstuct the face metadata at the end. So I'd like to save all the face metadata in a global datastructure from the original mesh, and use that to associate the face metadata on the generated mesh.

I plan to have a global hashmap with a Plane_3 as key and a list of face polygons and their metadata as value. This way, to associate metadata to a face, I construct the Plane_3 for that face and fetch the metadata in the global hash map.

The problem is that Plane_3 does not provide a hash value. Is there a way I could construct such a hash value?

I need two planes that are equal to have the same hash value, regardless of how those planes were constructed. If a plane is defined by a point (x,y,z) and a normal vector(nx,ny,nz) then the same plane could be defined by different values (the normal vector can change its length for example but the defined plane is still identical).

If possible I'd like to avoid the use of square root.

For a plane, I also have access to the a, b, c, d values, those values defines the plane by the equation

a*x + b*y + c*z + d = 0

Is there a way to normalize the coefficients a, b, c, d such as they are always equal if the plane is identical?

There is another question that explains how to normalize a plane equation: coplanar equations of a plane but it uses the square root to compute a norm. I'd like to have a way to handle such normalization without needing the square root.

Mildred
  • 463
  • 4
  • 13

1 Answers1

0

We just need to multiply a, b, c, d by some common factor to ensure that identical planes will have the same a, b, c and d:

  • if a != 0 then multiply a, b, c, d by 1/a
  • else if b != 0 then multiply a, b, c, d by 1/b
  • else multiply a, b, c, d by 1/c

This might not be the most elegant solution but I believe it should work. I'm open to better suggestions.

Then, it's just a matter of packing 4 numbers in a data structure that can work as a hash map key.

Mildred
  • 463
  • 4
  • 13