8 #ifndef LIMBO_PARSERS_GDSII_GDSDB_GDSOBJECTHELPERS_H
9 #define LIMBO_PARSERS_GDSII_GDSDB_GDSOBJECTHELPERS_H
12 #include <boost/geometry/strategies/transform.hpp>
36 template <
typename ActionType>
43 case ::GdsParser::GdsRecords::BOUNDARY:
49 case ::GdsParser::GdsRecords::PATH:
55 case ::GdsParser::GdsRecords::TEXT:
61 case ::GdsParser::GdsRecords::SREF:
67 case ::GdsParser::GdsRecords::AREF:
77 catch (std::exception& e)
79 limboPrint(limbo::kERROR,
"exception in action %s: %s\n", action.message().c_str(), e.what());
88 std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*>&
target;
101 template <
typename ObjectType>
105 target.second =
new ObjectType(*
object);
111 return "CopyCellObjectAction";
118 std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*>&
target;
130 template <
typename ObjectType>
139 return "DeleteCellObjectAction";
145 template <
typename GdsWriterType>
150 std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*>
const&
target;
164 template <
typename ObjectType>
167 writer.write(gdsWriter, *
object);
173 return "WriteCellObjectAction";
179 namespace ExtractCellObjectActionDetails
187 template <
typename ObjectType>
190 ObjectType* ptr =
new ObjectType (*
object);
191 targetCell.
objects().push_back(std::make_pair(type, ptr));
203 limboAssert(type == ::GdsParser::GdsRecords::SREF);
204 limboAssertMsg(srcCell.name() !=
object->refCell(),
"self reference of cell %s", srcCell.name().c_str());
205 GdsCell const* refCell = gdsDB.getCell(object->refCell());
206 limboAssertMsg(refCell,
"failed to find reference cell %s", object->refCell().c_str());
208 GdsCell cell =
object->extractCellRef(gdsDB, *refCell);
210 targetCell.
objects().insert(targetCell.objects().end(), cell.objects().begin(), cell.objects().end());
212 cell.objects().clear();
221 limboAssert(type == ::GdsParser::GdsRecords::AREF);
252 template <
typename ObjectType>
261 return "ExtractCellObjectAction";
268 namespace ApplyCellReferenceActionDetails
278 Translate(GdsCellReference::point_type
const& o) : offset(o) {}
284 p = gtl::construct<GdsCellReference::point_type>(p.x()+offset.x(), p.y()+offset.y());
298 cosAngle = cos(angle/180.0*M_PI);
299 sinAngle = sin(angle/180.0*M_PI);
309 p = gtl::construct<GdsCellReference::point_type>(
324 MagScale(
double sx,
double sy) : scaleX(sx), scaleY(sy) {}
330 p = gtl::construct<GdsCellReference::point_type>(p.x()*
scaleX, p.y()*
scaleY);
340 p = gtl::construct<GdsCellReference::point_type>(p.x(), -p.y());
349 template <
typename Iterator,
typename TransformerType>
352 for (; first != last; ++first)
360 template <
typename ObjectType>
361 inline void copyToArray(std::vector<GdsCellReference::point_type>& vPoint, ObjectType*
object)
363 vPoint.assign(object->begin(),
object->end());
371 vPoint.assign(1, object->position());
377 template <
typename ObjectType>
378 inline void copyFromArray(std::vector<GdsCellReference::point_type>
const& vPoint, ObjectType*
object)
380 object->set(vPoint.begin(), vPoint.end());
388 object->setPosition(vPoint.front());
395 template <
typename ObjectType>
398 std::vector<GdsCellReference::point_type> vPoint;
456 template <
typename ObjectType>
465 return "ApplyCellReferenceAction";
DeleteCellObjectAction(std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > &t)
constructor
header to include PrintMsg.h and AssertMsg.h
std::string message() const
double sinAngle
sine value of angle
ApplyCellReferenceAction(ApplyCellReferenceAction const &rhs)
a helper to facilitate actions on different GDSII objects.
void apply(GdsCellReference const &cellRef, ObjectType *object)
apply cell reference
WriteCellObjectAction(WriteCellObjectAction const &rhs)
copy constructor
void copyToArray(std::vector< GdsCellReference::point_type > &vPoint, ObjectType *object)
copy points of objects to array
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > & target
target cell
void transform(Iterator first, Iterator last, TransformerType transform)
Transform operation over an array.
point_type const & position() const
Rotate(double a)
constructor
Translate(GdsCellReference::point_type const &o)
constructor
GdsWriterType const & writer
wrapper of GDSII writer which will invoke GdsParser::GdsWriter to write
GdsCellReference::point_type offset
offset
void apply< GdsCellArray >(GdsCellReference const &, GdsCellArray *)
no reference to cell array; it should not reach here
void operator()(::GdsParser::GdsRecords::EnumType, ObjectType *object)
API to run the copy action.
std::vector< std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > > const & objects() const
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > const & target
target object
void copyFromArray< GdsText >(std::vector< GdsCellReference::point_type > const &vPoint, GdsText *object)
copy points of objects from array
void operator()(GdsCellReference::point_type &p) const
API to run operation.
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > & target
target cell
an action function for delete a cell
double cosAngle
cosine value of angle
CopyCellObjectAction(CopyCellObjectAction const &rhs)
copy constructor
ApplyCellReferenceAction(GdsCellReference const &cr)
constructor
double magnification() const
std::string message() const
MagScale(double sx, double sy)
constructor
an action function for copy a cell
namespace for Limbo.GdsParser
void copyFromArray(std::vector< GdsCellReference::point_type > const &vPoint, ObjectType *object)
copy points of objects from array
std::string message() const
std::iterator_traits< Iterator >::value_type max(Iterator first, Iterator last)
get max of an array
Apply cell reference action. It needs to call functions in GdsParser::GdsDB::ApplyCellReferenceAction...
void apply< GdsCellReference >(GdsCellReference const &, GdsCellReference *)
no reference to cell reference; it should not reach here
GdsCellReference const & cellRef
CREF object.
#define limboAssert(condition)
custom assertion without message
int limboPrint(MessageType m, const char *format,...)
formatted print with prefix
void operator()(::GdsParser::GdsRecords::EnumType type, ObjectType *object)
API to run the copy action.
WriteCellObjectAction(GdsWriterType const &w,::GdsParser::GdsWriter &gw, std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > const &t)
constructor
void operator()(::GdsParser::GdsRecords::EnumType type, GdsObject *object, ActionType action) const
API to run the actions over all GDSII objects.
std::string message() const
CopyCellObjectAction(std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > &t)
constructor
void operator()(::GdsParser::GdsRecords::EnumType, ObjectType *object)
API to run the action.
EnumType
enum type of GDSII records
void operator()(GdsCellReference::point_type &p) const
API to run operation.
#define limboAssertMsg(condition, args...)
custom assertion with message
DeleteCellObjectAction(DeleteCellObjectAction const &rhs)
copy constructor
void operator()(GdsCellReference::point_type &p) const
API to run operation. Transformation matrix cos(theta) -sin(theta) sin(theta) cos(theta) ...
::GdsParser::GdsWriter & gdsWriter
GDSII writer.
void operator()(GdsCellReference::point_type &p) const
API to run operation.
void operator()(::GdsParser::GdsRecords::EnumType, ObjectType *object)
API to run the writing action.
void copyToArray< GdsText >(std::vector< GdsCellReference::point_type > &vPoint, GdsText *object)
copy points of objects to array