Reading CIF files

Download: cifread.zip

This is a work in progress. It started with the program cif2ps, which is a basic C program. The goal is to produce a C++ object-oriented version.

See:

define.h
cifdata.cpp
layers.cpp
cifmatrix.cpp

You can download cif2ps as a zip archive. Rubin's description of the CIF format is very good. You can also download a pdf of the original Caltech technical report describing the format.

Finally, you can download an archive of examples - some of which do not process fully using cif2ps or cifread.

cifread.cpp


// cifread.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "define.h"

int cifread(const wchar_t *ciffile);
void show_cif();

int _tmain(int argc, _TCHAR* argv[])
{
	wchar_t *filename;
	if (argc<2) {
		filename = _T("everything.cif");
		/*
		fprintf(stderr,"Usage: cifgood cif_filename\n");
		return -1;
		*/
	}
	else filename = argv[1];
	cifread(filename);
	show_cif();
	return 0;
}


Results

This is the file everyting.cif

DS 1 100 1;
9 test;
L CMF;
B 20 20 10 10;
R 10 30 10;
P 0 40
 10 50
 20 40;
W 2
  0 60
 10 60
 30 40
 30 0;
DF;
C 1;
E

This is the output from cifread everything.cif

16 lines processed
Symbols are:
0	top_level
1	test

layer	name
0	CMF

table name: top_level
symbol 0 a 1 b 1
call symbol 1
done


table name: test
symbol 1 a 100 b 1
box layer(0) 0 0 2000 2000
cif object
polygon with 3 points
wire layer(0) width(200) with 4 points
done


Maintained by John Loomis, updated Mon Feb 12 23:32:12 2007