Overview

Writing of IGES files is handled by the igs_iges_file class. First, populate a RoseDesign with your desire IGES entities. There should be one instance of the igs_iges_file class containing the header information. When you are ready to write the IGES file, call the write() function on that instance.

The writing function takes a second boolean argument that indicates whether to write default values. When true, any empty or blank fields within the global or parameter data section are replaced with the appropriate defaults. The function returns a zero value if there was an error opening the file for writing. The sample code for step2iges 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;

    // create iges entities in the design for your export data

    // write the contents of the design as an IGES file
    if ( !f-> write("sample_part.igs", ROSE_FALSE) ) {
       // problem writing
    }
}

There are two versions of the write 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 write files opened by fopen() or wfopen(). On other systems, fopen() will accept UTF-8 encoded filenames so you can use either version to write 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;

    // create iges entities in the design for your export data

    // write the contents of the design as an IGES file
    FILE * file = fopen ("sample_part.igs", "w");
    if (!file || !f->write (file, ROSE_FALSE)) {
       // problem writing
    }
    fclose (file);
}