web_header.gif


Example GBRUnion DLL Program Flow

An example of a typical flow using GBRUnion DLL


Assumptions

  1. The GBRUnion DLL library is located in C:\wcad\Gbrunion DLL\artwork

  2. The file you wish to process is located in c:\wcad\GBRUnion DLL\EXAMPLES

  3. your data correction module needs the polygons for this file in Leonov format.

  4. you want all the polygons for the entire layout in one data structure.

  5. you don't need the data sized, scaled or otherwise transformed.


    Functions

    heading.gif Initialize the GBRUnion Library

    You have to start by initializing the library. You set up a pointer to a structure that contains the path to the library along with a handle. In this case the path to the library is: C:\wcad\Gbrunion DLL\artwork

      Checking the Return Code

      Check the return code and use the function ACS_Gbrunion_GetErrCode to determine the problem. The most likely problem at this stage is failure to check out a license. This may mean: the license files (acs.key and flexlm.lic) are not present or correctly formatted; the license hostid doesn't match the machine's hostid, the license server can't be found or the license server is not issuing a license due to no product available.


    heading.gif Setup the Parameters for Data Extraction

    Before you can call the function that returns your polygons you have to set up the parameters using:
    int ACS_Gbrunion_Setup (argc, *argv[]);

    Basically you prepare a data structure holding what would be command line arguments (as if you were using the executable) and then call the setup function.

    Here are our desired control settings:

      input file: C:\wcad\GBRUnion DLL\EXAMPLES\icsxceed.gbr

      working directory: C:\GBUnion DLL\EXAMPLES\work

      number of threads: 4

      arc resolution: 45

      arc sag: 0.0005

      polygon format:leonov


    Then our string *argv[], holding the arguments would look like:

    "C:\wcad\GBRUnion DLL\EXAMPLES\icsxceed.gbr" 
          "-wdir:C:\wcad\GBRUnion DLL\EXAMPLES\work" 
             -thrnum:4 
                  -arcres:45 
                     -arcsag:0.0005 
                        -polyformat:leonov

    and argc, the number of arguments = 6


    heading.gif Opening the Gerber File

    Now that our parameters are set up we open the Gerber file using the function:

    int  ACS_GBRUNION_LIB_API ACS_Gbrunion_Open();

    The return code should be checked to insure it opened correctly.


    heading.gif Information about the Gerber File

    Gerber files come in units of inches and mm and the resolution can vary depending on the source. To obtain the units and data resolution call this function:

    void ACS_Gbrunion_GetFileInfo ( ACS_GBRUNION_FileInfo *pFileInfo );

    heading.gif Setup Display of Progress

    For large files, extracting and unionizing the polygons might take a while and the user should be notified of the progress of this operation. If you wish to use the built in progress window then do nothing. However if you want to display progress in your own way, then setup a call back function that communicates with the library.

    void ACS_Gbrunion_SetProgressCallbackFn( ACSGbrUnionProgressCbFnPtr callbackFnPtr );

    heading.gif Generating the Polygons

    Now we can generate our polygons using the function:

    int ACS_Gbrunion_GetPolygons ( ACS_GBRUNION_Polygon **ppolylist, int *ppolycnt);

    The program will return a list of polygon coordinates and polygon vertex counts. The calling application can now do whatever processing it needs to with this geometric data: sizing, corrections, rasterization and such.


    heading.gif Releasing the Memory

    Once you are done with the polygons generated by the library you should release the memory using:

    void ACS_Gbrunion_FreePolygons (ACS_GBRUNION_Polygon *polylist, int polycnt);

    heading.gif Closing Up Shop

    When the calling application is done with the library, it should be properly closed. Not only does this release the license but it also frees any memory that the DLL allocated.

    void ACS_Gbrunion_Close ( );



Download Functions Example Flow Polygon Data Structure Price Revision History