What am I doing wrong? Access violation exception

Hi,

I am getting an Access violation exception when trying to read an iges file, here is a stripped down console app that reproduces the problem. The file is good and can be read by open source apps using OCC.
The file is quite large w.r.t the number of faces and the code below works fine on other smaller files.

I must be doing something very wrong. I can comment out Poly_Connect pc(facing) then the problem happens further down (not shown).

This is driving me mad!

Any help is appreciated

Julian

#include "StdAfx.h"
#include

int _tmain(int argc, _TCHAR* argv[])
{
Standard_CString aFileName = (Standard_CString) "C:\\Users\\Julian\\Desktop\\Crash.igs";
IGESControl_Reader Reader;
int status = Reader.ReadFile(aFileName);
if ( status == IFSelect_RetDone )
{
Reader.TransferRoots();
TopoDS_Shape shape = Reader.OneShape();
BRepMesh::Mesh(shape, 1);
TopExp_Explorer explorer(shape, TopAbs_FACE);
for (; explorer.More(); explorer.Next())
{
TopLoc_Location topLoc_Location;
TopoDS_Face face = TopoDS::Face(explorer.Current());
Handle_Poly_Triangulation facing = BRep_Tool::Triangulation(face, topLoc_Location);
gp_Trsf tr = topLoc_Location;
Poly_Connect pc(facing);
}
}

return 0;
}

Julian Paphitis's picture

OK, I was not checking if facing was IsNull. School buy error!

Julian