MaxP

05-10-2005, 07:23 PM

I'm trying to plan the data structure for an editor/geometry creation program and would welcome some input.

In my editor the user can create lines from linked line segments, which are defined by a start and end point. What is slightly unusual is that a point can belong to any number of line segments (not just one or two). Since points can be shared in this way (potentially between several lines), it seems sensible to have the line segments which share a common point reference a single instance of the shared point. However, the user can both create and delete line segments and points, it is therefore possible that a point may no longer be referenced by any line segements, in which case it should be destroyed. Given this, is reference counting the best solution to managing the points data or is there something more suitable? I guess this is analogous to a vertex being shared by several polygon edges in a 3D editor.

Any thoughts?

Max

In my editor the user can create lines from linked line segments, which are defined by a start and end point. What is slightly unusual is that a point can belong to any number of line segments (not just one or two). Since points can be shared in this way (potentially between several lines), it seems sensible to have the line segments which share a common point reference a single instance of the shared point. However, the user can both create and delete line segments and points, it is therefore possible that a point may no longer be referenced by any line segements, in which case it should be destroyed. Given this, is reference counting the best solution to managing the points data or is there something more suitable? I guess this is analogous to a vertex being shared by several polygon edges in a 3D editor.

Any thoughts?

Max