Overview

Reading and Writing of IGES files is handled by the igs_iges_file class, which also holds the IGES header data. To read an IGES file, first create a RoseDesign to hold the results, create an instance of the igs_iges_file within that, and then call the read() function to bring in the IGES file and populate the design.

The reading function takes a second boolean argument that indicates whether to return on parsing errors. The function returns a zero value if there was an error opening or processing the file. The sample code for iges2step shows a more detailed example.

void main()
{
    // create an empty design
    RoseDesign * design = new RoseDesign("sample_part");
    igs_iges_file * f = pnewIn(design) igs_iges_file;

    // read the contents of the file
    if ( !f-> read("sample_part.igs", ROSE_FALSE) ) {
       // problem reading
    }

    // process the iges entities now in the design
}

There are two versions of the read function. One takes a const char* filename and the other takes a FILE* file pointer. On Windows, you can use the file pointer version to read files opened by fopen() or wfopen(). On other systems, fopen() will accept UTF-8 encoded filenames so you can use either version to read files with wide character names.

void main()
{
    // create an empty design
    RoseDesign * design = new RoseDesign("sample_part");
    igs_iges_file * f = pnewIn(design) igs_iges_file;

    FILE * file = fopen ("sample_part.igs", "rb");
    if (!file || !f->read (file, ROSE_FALSE)) {
       // problem reading
    }
    fclose (file);

    // process the iges entities now in the design
}