QIS Library Logo

Code Example 1.

Simple Window Extraction and Clip/Boolean

In the following example we are going to use QisLib and QisBool to extract a window of polygons from a GDSII file and then clip the extracted polygons and booleanize the polygons.

We assume the user has written some functions already to obtain:

directory to the libraries

the gdsii file to open

the structure to open

the layer(s) to process

the selection window

the clipping window

example flow

The Sample Code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "qislib.h"
#include "qisbool.h"
Include the basic Microsoft headers and the
headers specific to QisLib and QisBool

/* User driven input functions */

const char* User_ExecDir(const char*);
const char* User_ExecPath(const char*);
const char* User_GDSIIFile();
int User_OpenStructure();
const char* User_ViewStructure();
int User_SetLayers();
const char* User_LayerString();
int User_SetWindow();
void User_GetWindow(CQisWindow*);
int User_SetClipWindow();
void User_ClipWindow(int*, int*, int*, int*);
Assume you have written functions 
to collect the following:
directory containing client program (and acs.key)
path & name of the user program
GDSII File name
function to select structure
string containing the structure name
function to set layers
layer list
function to set extraction window
extraction window coordinates
function to get clipping window
clipping window coordinates         

int booleanize_main(int argc, char* argv[])
  /* Initialize QisLib */
  #if(defined(WIN32) || defined(WIN64))
  int ret = QisLib_InitLib(User_ExecDir(argv[0]));
  int ret = QisLib_InitLib(User_ExecPath(argv[0]), NULL, NULL);
  if(ret) {
    fprintf(stderr, "error: QisLib_InitLib returned %d.\n", ret);
    if(ret == -3) {
      fprintf(stderr, "License error: %s\n", QisLib_GetErrorMsg()); 
    return 1;
Our main function to extract and 
booleanize starts here.

Check: Windows or Unix/Linux
Initialize for Windows

Initialize for Unix/Linux

Check for error initializing

possibly can't get a license?

  int err = 0;
  int storageHandle = -1;
  void* boolHandle = 0;
  int** XYOut = 0;
  int* NVOut = 0;
  int NOut = 0;
Initialize some variables
error indicator
handle for Qstore instance
handle for QisBool instance
array of array of polygon data
array of polygon vertex count
number of output polygons

do {

    /* Open GDSII file */
    ret = QisLib_OpenGDSII(User_GDSIIFile());
    if(ret) {
     fprintf(stderr, "QisLib_OpenGDSII returned %d.\n", ret);
     err = 1; break;

    /* Set View Structure */
    if(User_OpenStructure()) {
      ret = QisLib_OpenStructure(User_ViewStructure());
      if(ret) {
       fprintf(stderr, "QisLib_OpenStructure returned %d.\n", ret);
       err = 1; break;

    /* Set Layers */
    if(User_SetLayers()) {

    /* Set Window of interest */
    if(User_SetWindow()) {
      CQisWindow win;
We use a do loop of one pass to
insure that even if an error
knocks us out of the loop
we still execute code outside
the loop that cleans up.

Our user function provides the
name of the file to open.

Our user function passes the
name of the structure to
open (if not, the top
structure is automatically

Our user function provides
the list of layers to
process. (If not, all layers
are processed by default)

Our user function passes
the window coordinates for
extracting data.


Documentation Download Rev History Price

ARTWORK CONVERSION SOFTWARE, INC.                  Company Profile
417 Ingalls St.,     Santa Cruz, CA 95060         Tel (831) 426-6163     Fax 426-2824               email: info@artwork.com