Open flm8620 opened 7 years ago
I agree with the reporter. For the face that is recycled, we should call the destructor ~Face()
, and then a placement new to call the default constructor again. And do the same consistently in Triangulation_2 and Triangulation_3. That consistent behavior would have saved a lot of trouble in the Mesh_2 and Mesh_3 package.
A solution to your problem would be to identify an edge as a sorted pair of vertex handles. Then you can use a hash map or a map to access to the edge.
Just a historical comment about one of the questions
I found a better way to implement a real Edge object. I use shared_ptr in Face to point to Edge. Edge will be automatically created, destroyed and shared properly. See my github CGAL_edge If you are interested.
Besides, I think I might know the reason for this design. CGAL use CGAL::Compact_Container
to hold objects like faces, vertices. This container use lazy deletion, which means the memory of deleted objects is not freed, their destructor is called but their memory is marked "freed". So the programmer want to minimize the creation of new object.
Problem
I want to store userdata in edges. But CGAL::TriangulationDataStructure_2 Concept only has a implicit representations for edge, which is attached to a face.
So I can create my face class and plug it into
CGAL::TriangulationDataStructure_2
. But then I found this function: TriangulationDataStructure_2::insert_in_face(Face_handle f)It add a vertex in a face and then split it in three faces. But actually the old face is reused and two new faces are created. So in my case, my userdata in the old face wasn't aware of this change, and the edge to which my userdata correspond doesn't exist any more. Which leads to unexpected result in my codes.
Question
insert_in_face
is like this ? Why not just destroy the old face and create three new one ? The latter way looks more "symmetric" in the sense that none of new faces are related to old one, they are all fresh and "equal"