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";
145template <
typename GdsWriterType>
150 std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject*>
const&
target;
164 template <
typename ObjectType>
173 return "WriteCellObjectAction";
187template <
typename ObjectType>
190 ObjectType* ptr =
new ObjectType (*
object);
191 targetCell.
objects().push_back(std::make_pair(type, ptr));
203 limboAssert(type == ::GdsParser::GdsRecords::SREF);
208 GdsCell cell =
object->extractCellRef(gdsDB, *refCell);
221 limboAssert(type == ::GdsParser::GdsRecords::AREF);
252 template <
typename ObjectType>
261 return "ExtractCellObjectAction";
272template<
typename Po
intType>
285 p = gtl::construct<PointType>(p.x()+
offset.x(), p.y()+
offset.y());
289template<
typename Po
intType>
311 p = gtl::construct<PointType>(
318template<
typename Po
intType>
333 p = gtl::construct<PointType>(p.x()*
scaleX, p.y()*
scaleY);
337template<
typename Po
intType>
344 p = gtl::construct<PointType>(p.x(), -p.y());
353template <
typename Iterator,
typename TransformerType>
356 for (; first != last; ++first)
364template <
typename ObjectType>
365inline void copyToArray(std::vector<GdsCellReference::point_type>& vPoint, ObjectType*
object)
367 vPoint.assign(object->begin(), object->end());
375 vPoint.assign(1, object->
position());
381template <
typename ObjectType>
382inline void copyFromArray(std::vector<GdsCellReference::point_type>
const& vPoint, ObjectType*
object)
384 object->set(vPoint.begin(), vPoint.end());
392 object->setPosition(vPoint.front());
399template <
typename ObjectType>
402 std::vector<GdsCellReference::point_type> vPoint;
403 std::vector<GdsCellReference::float_point_type> vFloatPoint;
407 vFloatPoint.reserve(vPoint.size());
408 for (std::vector<GdsCellReference::point_type>::const_iterator it = vPoint.begin(); it != vPoint.end(); ++it)
410 vFloatPoint.push_back(gtl::construct<GdsCellReference::float_point_type>(it->x(), it->y()));
414 if (cellRef.
strans() != std::numeric_limits<int>::max() && (cellRef.
strans() & 0x8000))
419 if ( cellRef.
magnification() != std::numeric_limits<double>::max())
424 if ( cellRef.
angle() != std::numeric_limits<double>::max())
429 if (cellRef.
position().x() != std::numeric_limits<int>::max() && cellRef.
position().y() != std::numeric_limits<int>::max())
436 for (std::vector<GdsCellReference::float_point_type>::const_iterator it = vFloatPoint.begin(); it != vFloatPoint.end(); ++it)
438 vPoint.push_back(gtl::construct<GdsCellReference::point_type>(round(it->x()), round(it->y())));
475 template <
typename ObjectType>
484 return "ApplyCellReferenceAction";
#define limboAssertMsg(condition, args...)
custom assertion with message
#define limboAssert(condition)
custom assertion without message
header to include PrintMsg.h and AssertMsg.h
std::vector< std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > > const & objects() const
std::string const & name() const
std::string const & refCell() const
point_type const & position() const
double magnification() const
point_type const & position() const
An action function to apply changes to a copied cell reference. It contains various transformers.
void copyFromArray(std::vector< GdsCellReference::point_type > const &vPoint, ObjectType *object)
copy points of objects from array
void transform(Iterator first, Iterator last, TransformerType transform)
Transform operation over an array.
void copyToArray< GdsText >(std::vector< GdsCellReference::point_type > &vPoint, GdsText *object)
copy points of objects to array
void apply(GdsCellReference const &cellRef, ObjectType *object)
apply cell reference
void apply< GdsCellArray >(GdsCellReference const &, GdsCellArray *)
no reference to cell array; it should not reach here
void copyFromArray< GdsText >(std::vector< GdsCellReference::point_type > const &vPoint, GdsText *object)
copy points of objects from array
void apply< GdsCellReference >(GdsCellReference const &, GdsCellReference *)
no reference to cell reference; it should not reach here
void copyToArray(std::vector< GdsCellReference::point_type > &vPoint, ObjectType *object)
copy points of objects to array
namespace for Limbo.GdsParser.GdsDB
namespace for Limbo.GdsParser
void operator()(PointType &p) const
API to run operation.
MagScale(double sx, double sy)
constructor
Rotate(double a)
constructor
double sinAngle
sine value of angle
double cosAngle
cosine value of angle
void operator()(PointType &p) const
API to run operation. Transformation matrix cos(theta) -sin(theta) sin(theta) cos(theta).
void operator()(PointType &p) const
API to run operation.
Translate(PointType const &o)
constructor
void operator()(PointType &p) const
API to run operation.
void operator()(::GdsParser::GdsRecords::EnumType, ObjectType *object)
API to run the action.
std::string message() const
GdsCellReference const & cellRef
CREF object.
ApplyCellReferenceAction(GdsCellReference const &cr)
constructor
ApplyCellReferenceAction(ApplyCellReferenceAction const &rhs)
std::string message() const
CopyCellObjectAction(std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > &t)
constructor
CopyCellObjectAction(CopyCellObjectAction const &rhs)
copy constructor
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > & target
target cell
void operator()(::GdsParser::GdsRecords::EnumType type, ObjectType *object)
API to run the copy action.
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > & target
target cell
std::string message() const
void operator()(::GdsParser::GdsRecords::EnumType, ObjectType *object)
API to run the copy action.
DeleteCellObjectAction(std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > &t)
constructor
DeleteCellObjectAction(DeleteCellObjectAction const &rhs)
copy constructor
a helper to facilitate actions on different GDSII objects.
void operator()(::GdsParser::GdsRecords::EnumType type, GdsObject *object, ActionType action) const
API to run the actions over all GDSII objects.
::GdsParser::GdsWriter & gdsWriter
GDSII writer.
GdsWriterType const & writer
wrapper of GDSII writer which will invoke GdsParser::GdsWriter to write
std::string message() const
std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > const & target
target object
void operator()(::GdsParser::GdsRecords::EnumType, ObjectType *object)
API to run the writing action.
WriteCellObjectAction(WriteCellObjectAction const &rhs)
copy constructor
WriteCellObjectAction(GdsWriterType const &w, ::GdsParser::GdsWriter &gw, std::pair< ::GdsParser::GdsRecords::EnumType, GdsObject * > const &t)
constructor
EnumType
enum type of GDSII records