diff --git a/lib/ReadGDSIIFile.cc b/lib/ReadGDSIIFile.cc index 9ac8d92..dbfdd48 100644 --- a/lib/ReadGDSIIFile.cc +++ b/lib/ReadGDSIIFile.cc @@ -529,13 +529,11 @@ double ConvertReal(BYTE *Bytes, DataType DType) } -// The allowed characters are [a-zA-Z?$_]. +// The allowed characters are all ASCII-printable characters, including space, except comma (,) and double quote ("). // Non-allowed characters at the end of the string are removed. // Non-allowed characters not at the end of the string are converted to underscores. bool IsAllowedChar(char c) -{ c=tolower(c); - return ('a' <= c && c <= 'z') || c=='$' || c=='_' || c=='?'; -} +{ return isprint(c) && c!='"' && c!=','; } string *MakeGDSIIString(char *Original, int Size) { diff --git a/lib/libGDSII.cc b/lib/libGDSII.cc index ad26acb..8101f25 100644 --- a/lib/libGDSII.cc +++ b/lib/libGDSII.cc @@ -43,7 +43,6 @@ GDSIIData::GDSIIData(const string FileName) UnitInMeters = 1.0e-6; FileUnits[0] = FileUnits[1]=0.0; GDSIIFileName = new string(FileName); - ReadGDSIIFile(FileName); // at this point ErrMsg is non-null if an error occurred @@ -124,6 +123,26 @@ PolygonList GDSIIData::GetPolygons(const char *Text, int Layer) PolygonList GDSIIData::GetPolygons(int Layer) { return GetPolygons(0,Layer); } +TextString NewTextString(Entity E, int Layer) +{ TextString TS; + TS.Text = E.Text; + TS.XY = dVec(E.XY); + TS.Layer = Layer; + return TS; +} + +TextStringList GDSIIData::GetTextStrings(int Layer) +{ + TextStringList TextStrings; + for(size_t nl=0; nlGetTextStrings(Layer); +} + /***************************************************************/ /* find the value of s at which the line p+s*d intersects the */ /* line segment connecting v1 to v2 (in 2 dimensions) */ diff --git a/lib/libGDSII.h b/lib/libGDSII.h index 942742f..d520c86 100644 --- a/lib/libGDSII.h +++ b/lib/libGDSII.h @@ -61,6 +61,9 @@ using namespace std; /****************************************************************************************/ typedef vector PolygonList; +typedef struct { char *Text; dVec XY; int Layer; } TextString; +typedef vector TextStringList; + /***************************************************************/ /* Data structures used to process GDSII files: */ /* (a) GDSIIElement and GDSIIStruct are used to store info */ @@ -142,7 +145,8 @@ namespace libGDSII // If Layer==-1, search all layers. // If Text==NULL, return a list of all polygons on the given layer. PolygonList GetPolygons(const char *Text, int Layer=-1); - PolygonList GetPolygons(int Layer); + PolygonList GetPolygons(int Layer=-1); + TextStringList GetTextStrings(int Layer=-1); /*--------------------------------------------------------*/ /* API data fields */ @@ -201,7 +205,8 @@ bool PointInPolygon(dVec Vertices, double X, double Y); /* to free memory allocated for the cache. */ /***********************************************************************/ PolygonList GetPolygons(const char *GDSIIFile, const char *Text, int Layer=-1); -PolygonList GetPolygons(const char *GDSIIFile, int Layer); +PolygonList GetPolygons(const char *GDSIIFile, int Layer=-1); +TextStringList GetTextStrings(const char *GDSIIFile, int Layer=-1); void ClearGDSIICache(); /***************************************************************/