From ff40851987c11802a9240025e182be45266b05fd Mon Sep 17 00:00:00 2001 From: Damien Dupuis Date: Thu, 3 Jun 2010 14:02:24 +0000 Subject: [PATCH] Copy cif directory (no more svn move for me) --- vlsisapd/src/cif/CMakeLists.txt | 9 ++++++ vlsisapd/src/cif/CifCircuit.cpp | 54 +++++++++++++++++++++++++++++++++ vlsisapd/src/cif/CifCircuit.h | 23 ++++++++++++++ vlsisapd/src/cif/CifPolygon.cpp | 29 ++++++++++++++++++ vlsisapd/src/cif/CifPolygon.h | 20 ++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 vlsisapd/src/cif/CMakeLists.txt create mode 100644 vlsisapd/src/cif/CifCircuit.cpp create mode 100644 vlsisapd/src/cif/CifCircuit.h create mode 100644 vlsisapd/src/cif/CifPolygon.cpp create mode 100644 vlsisapd/src/cif/CifPolygon.h diff --git a/vlsisapd/src/cif/CMakeLists.txt b/vlsisapd/src/cif/CMakeLists.txt new file mode 100644 index 00000000..0b6489ef --- /dev/null +++ b/vlsisapd/src/cif/CMakeLists.txt @@ -0,0 +1,9 @@ +INCLUDE_DIRECTORIES(${CHAMS_SOURCE_DIR}/cif) + +SET ( includes CifCircuit.h CifPolygon.h ) +SET ( cpps CifCircuit.cpp CifPolygon.cpp ) + +ADD_LIBRARY(cif ${cpps}) +INSTALL(TARGETS cif DESTINATION lib${LIB_SUFFIX}) + +INSTALL(FILES ${includes} DESTINATION include/vlsisapd/cif) diff --git a/vlsisapd/src/cif/CifCircuit.cpp b/vlsisapd/src/cif/CifCircuit.cpp new file mode 100644 index 00000000..0024edfb --- /dev/null +++ b/vlsisapd/src/cif/CifCircuit.cpp @@ -0,0 +1,54 @@ +#include +#include +#include +using namespace std; + +#include "CifCircuit.h" +#include "CifPolygon.h" + +namespace vlsisapd { + +CifCircuit::CifCircuit(string name, string unit, double scale) : _name(name), _unit(unit), _scale(scale) {} + + +bool CifCircuit::addPolygon(CifPolygon* polygon) { + if(polygon) + _polygons.push_back(polygon); + else { + cerr << "[CIF DRIVE ERROR]: cannot add invalid polygon." << endl; + return false; + } + return true; +} + +bool CifCircuit::write(string filename) { + time_t curtime = time(0); + tm now = *localtime(&curtime); + char date[BUFSIZ]={0}; + const char format[]="%d-%b-%Y %H:%M:%S"; + if (!strftime(date, sizeof(date)-1, format, &now)>0) + cerr << "[CIF DRIVE ERROR]: cannot build current date." << endl; + + ofstream file; + file.open(filename.c_str(), ios::out); + // Header + file << "(CIF file written on " << date << " by VLSISAPD_CIF_DRIVER);" << endl + << "(Units: " << _unit << " - UU/DB Scale: " << _scale << ");" << endl + << "DS 1 1 1;" << endl + << "9 " << _name << ";" << endl; + + // For each Polygon : write polygon. + for ( vector::iterator it = _polygons.begin() ; it < _polygons.end() ; it++ ) { + (*it)->write(file); + } + + // Footer + file << "DF;" << endl + << "C 1;" << endl + << "E" << endl; + + file.close(); + return true; +} +} // namespace + diff --git a/vlsisapd/src/cif/CifCircuit.h b/vlsisapd/src/cif/CifCircuit.h new file mode 100644 index 00000000..3ffaef7b --- /dev/null +++ b/vlsisapd/src/cif/CifCircuit.h @@ -0,0 +1,23 @@ +#ifndef __CIF_CIRCUIT_H +#define __CIF_CIRCUIT_H + +#include + +namespace vlsisapd { +class CifPolygon; +class CifCircuit { + public: + CifCircuit(string name, string unit, double scale); + + bool addPolygon ( CifPolygon* ); + bool write ( string ); + + private: + string _name; + string _unit; + double _scale; + + std::vector _polygons; +}; +} // namespace +#endif diff --git a/vlsisapd/src/cif/CifPolygon.cpp b/vlsisapd/src/cif/CifPolygon.cpp new file mode 100644 index 00000000..8fc63e1c --- /dev/null +++ b/vlsisapd/src/cif/CifPolygon.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +using namespace std; + +#include "CifPolygon.h" + +namespace vlsisapd { + +CifPolygon::CifPolygon(long layer) : _layer(layer) {} + + +void CifPolygon::addPoint(long x, long y) { + _points.push_back(pair(x,y)); +} + +void CifPolygon::write(ofstream& file) { + file << "L " << _layer << "; P"; + + // For each point : write point. + for ( vector >::iterator it = _points.begin() ; it < _points.end() ; it++ ) { + file << " " << (*it).first << "," << (*it).second; + } + + file << ";" << endl; +} +} // namespace + + diff --git a/vlsisapd/src/cif/CifPolygon.h b/vlsisapd/src/cif/CifPolygon.h new file mode 100644 index 00000000..4dc82981 --- /dev/null +++ b/vlsisapd/src/cif/CifPolygon.h @@ -0,0 +1,20 @@ +#ifndef __CIF_POLYGON_H +#define __CIF_POLYGON_H + +#include +#include + +namespace vlsisapd { +class CifPolygon { + public: + CifPolygon(long); + + void addPoint (long, long); + void write ( ofstream& ); + + private: + long _layer; + std::vector > _points; +}; +} // namespace +#endif