IGES : Problem in finding number of EDGES

Dear All,

I have an IGES file(created by someone else) which contains a solid
box.
I tried to find the number of EDGES present in this drawing using the
following code.

/***********************************************************
IGESControl_Reader reader;
IFSelect_ReturnStatus status = reader.ReadFile(filename);

if(status != IFSelect_RetDone)
AfxMessageBox("Failed to load IGES file");

reader.TransferRoots();

TopoDS_Shape aShape = reader.OneShape();
int nCount = 0;
for
(TopExp_Explorer expEdge(aShape, TopAbs_EDGE);
expEdge.More();
expEdge.Next()
)
{
nCount++;
}

CString str;
str.Format("%d", nCount);
AfxMessageBox(str);
/***********************************************************

Although the expected result is 12, I am getting 28.

What will be wrong with me?

TIA,

Regards,
Jahfer

Francois Lauzon's picture

Hello Jahfer,
I'm not sure of how exactly TopExp_Explorer return the sub-shape it explore, my guess is you might receive the same edge multiple time ( since when you explorer your cube, you have face that share edges, so each edge is repeated at least twice by the explorer.). You have to add your explored sub-shape in some kind of map to be sure you don't have it (and count it) twice. That's what I always do and it work. You might try:

TopTools_IndexedMapOfShape aMap;
TopExp::MapShapes(aShape, TopAbs_EDGE, aMap);
and then count the shape in the map.

And don't forget that one side of a face of your cube might be compose of more than one edge...

Good Luck,
Francois.