Getting an "ID" from a shape


I am writing an application with its own GUI and I
am using OpenCascade to fillet shapes. What I want is the user
to be able to select an edge, then get some integer value from it
like a hash or an address. Put those ints in a list, and sometime a
afterwards I would like to get the TopoDS_Edge from the integer.
So my code would be like the following:

TopoDS_Edge E = pickedge();
int value = GetValueFromEdge(E);
TopoDS_Edge E = GetEdgeFromValue(value);

Any idea what GetValueFromEdge and GetEdgeFromValue could look like?
For example I could use HashCode to implement the GetValueFromEdge, but then for the other function I should search every Edge in my Shape for that hashcode witch isn't good for shapes with too many edges.
Any ideas??
Thank you in advance

Alessandro Tasora's picture

I have the similar problem (I am writing my own CAD system using
OpenCASCADE, but I do _not_ use OCAF: simply TopoDS_Shape objects).
Maybe that the 'topological naming mechanism' may fit our needs,
but there are no clear demos, neither deep documentation.
If you happen to find a solution, tell me...


Alessandro Tasora

francisco castillo's picture

Use a map of Shape-Integer:

On header:
static TopTools_DataMapOfShapeInteger _map_shape_int;
On source code:
When you crate a new shape ...
TopoDS_Shape shape = MakeShape();
int shape_id = ....
_map_shape_int.Bind( shape, shape_id );

When you need the shape id for the TopoDS_Shape aShape ...
int shape_id = 0;
if ( _map_shape_int.IsBound( aShape ) ) {
shape_id = _map_shape_int( aShape );