Unique Id's

Hi,
I have cube model cube.iges and when i try to give unique id's to this model using TopTools_DataMapOfShapeInteger Class, it binds 24 unique id instead of 8.(If I don't bind anything, it counts 48 points total) I am using the code below to bind id's, is there any other way? or if there is not, is there a way to merge (weld) points close enough to get a cube shape with 8 unique points?

Thanks in advance...

int uniqueVertexId = 0;
TopExp_Explorer ex;
for (ex.Init(getContext()->SelectedShape(), TopAbs_VERTEX); ex.More(); ex.Next())
{
TopoDS_Vertex aVertex = TopoDS::Vertex(ex.Current());
if(!_map_shape_int.IsBound(aVertex))
{
_map_shape_int.Bind(aVertex,uniqueVertexId);
cout uniqueVertexId++;
}
}

Rob Bachrach's picture

Two questions...
First, are you sure there are 48 items in the map when you are done? Although your counter reaches 48, it is possible that your vertices are actually repeated for each edge. So, when calling Bind with the same vertex again, it is not actually added. Try checking the Extent of your map after the loop completes.

Second. have you considered using a TopTools_IndexedMapOfShape instead? It will automatically assign indexes to new items instead of you having to keep a counter.

If you are truly running into 48 distinct vertices, you might want to try using the shape healing module.

Rob

xaeroxx's picture

Hi, thanks for reply
I have used TopTools_IndexedMapOfShape and result is same (code is below) I don't know about .iges files but maybe file is corrupt (I mean the cube is false represented in the file) And what exactly do you mean by 'shape healing module' and how can I use it to resolve this problem?

Thanks again

int iteration = 0;
TopExp_Explorer ex;
for (ex.Init(getContext()->SelectedShape(), TopAbs_VERTEX); ex.More(); ex.Next())
{
....iteration++;
....TopoDS_Vertex aVertex = TopoDS::Vertex(ex.Current());
...._map_shape.Add(aVertex);
}
cout<<"unique : "<<_map_shape.Extent()<

Bearloga's picture

Iges file usually contains not-sewed faces. You should apply sewing algo to your shape before doing anything with it.

xaeroxx's picture

Thanks for the quick reply and it worked..
after sewing :
unique : 8
iteration : 48

Thanks again