Open sebmestrallet opened 1 year ago
Let me know if something should be tweaked. I particular in-code documentation about 'next' and 'prev' whose meaning I must have missed.
I can share the Excalidraw file if it is useful.
Here is a small app (can be appended to the PR) that showcase this behavior:
move_to_prev_around_facet()
→ clockwisemove_to_next_around_facet()
→ counterclockwisemove_to_prev_around_vertex()
→ counterclockwisemove_to_next_around_vertex()
→ clockwiseMaybe prev/next make more sense around facets, but I think (counter)clockwise makes more sense around vertices.
PLOT TWIST : I still don't understand everything but it seems like I was wrong about the halfedges representation.
H.facet
→ ~left facet~ right facetmove_to_prev_around_facet()
→ ~clockwise~ counterclockwisemove_to_next_around_facet()
→ ~counterclockwise~ clockwisemove_to_prev_around_vertex()
→ ~counterclockwise~ clockwisemove_to_next_around_vertex()
→ ~clockwise~ counterclockwiseIncoming fix
@BrunoLevy my modifications are now ready for review
Addition:
facet
and corner
facet
and corner
fieldsThere were inconsistencies in the facet normals direction of the meshes I tested (some inward, some outward).
This leads us to a design choice:
MeshHalfedges
with an additional argument, or make MeshHalfedges
detect facet normals direction*_around_vertex()
Hi there ! Wow, impressive work and documentation ! It's fantastic ! (sorry for beeing not reactive at all, I was completely swamped in many projects + administrative tasks). About the names of the things, we do not trust orientation, this is why the names of the functions are not "clockwise" and "counterclockwise" because depending on the input mesh, they may be swapped ! And also, consider a non-closed surface, then it depends from which side you look at the surface. Anyway, at any moment if you want to discuss we can plan a videochat (will be easier than exchanging written messages, especially if we need to draw things).
Now this PR doesn't assume any orientation (3rd design choice of my last message). No more move_(counter)clockwise_around_facet()
, move_(counter)clockwise_around_vertex()
.
MeshHalfedges
, MeshHalfedges::Halfedge
and MeshHalfedges::Halfedge.corner
areMeshHalfedges::Halfedge.facet
is described as the supporting facet (no more left or right)🆕 is_using_facet_region()
To be asserted at the beginning of functions receiving a MeshHalfedges
and expecting facet regions
with a new argument for move_to_*_around_vertex()
Useful when we need to keep track of all the facets between two border segments
private
→ protected
Currently we can have their 3D coordinates (halfedge_vertex_from()
and halfedge_vertex_to()
) but not their index.
Because I'm used to the "point" naming from mesh.vertices.point()
for coordinates, I wanted to rename existing functions:
halfedge_vertex_from()
→ halfedge_point_from()
which returns a vec3
halfedge_vertex_to()
→ halfedge_point_to()
which returns a vec3
halfedge_vertex_from()
which returns an index_t
halfedge_vertex_to()
which returns an index_t
But inside, the coordinates getters use Geom::mesh_vertex()
from mesh_geometry.h
, so it seems "vertex" sometimes means the index, sometimes the coordinates.
So, I've chosen:
halfedge_vertex_from()
which returns a vec3
(unchanged)halfedge_vertex_to()
which returns a vec3
(unchanged)halfedge_vertex_index_from()
which returns an index_t
halfedge_vertex_index_to()
which returns an index_t
halfedge_facet_main()
= supporting facet = H.facet
halfedge_facet_secondary()
= facet at the other side of Hhalfedge_bottom_main_corner()
= facet corner of the main facet which is on the origin vertexhalfedge_bottom_secondary_corner()
= facet corner of the secondary facet which is on the origin vertexhalfedge_top_main_corner()
= facet corner of the main facet which is on the extremity vertexhalfedge_top_secondary_corner()
= facet corner of the secondary facet which is on the extremity vertex
Summary
This PR extends the halfedges API without breaking existing functions. The only modified files are
src/lib/geogram/mesh/mesh_halfedges.h
/.cpp
.Motivation
I need to move on surface meshes and the halfedges API of Geogram allowed me to implement the operators I wanted. But I had several issues:
H.facet
andH.corner
in relation toH
, the meaning of next and previous is unclear)Because my code relies more and more on halfedges, I plunge into the original class to understand what was already done and to add what I needed. I found that 'next' and 'prev' don't seem to follow the same convention around facets and vertices...
Notes on existing functions
Could be helpful in the wiki
New functions
halfedge_vertex_index_from()
: because before the user could access the 3D coordinates of the origin but not the vertex indexhalfedge_vertex_index_to()
: because before the user could access the 3D coordinates of the extremity but not the vertex indexhalfedge_facet_left()
which is basicallyH.facet
but now the user doesn't need to know the underlying structurehalfedge_facet_right()
, to improve readability of the user's codemove_clockwise_around_facet()
which is more explicit thanmove_to_prev_around_facet()
move_counterclockwise_around_facet()
which is more explicit thanmove_to_next_around_facet()
move_clockwise_around_vertex()
which is more explicit thanmove_to_next_around_vertex()
move_counterclockwise_around_vertex()
which is more explicit thanmove_to_prev_around_vertex()
I hope those modifications are in line with your vision for Geogram.