40 if (el.
GetName() !=
"Point2DInt")
43 _(
"Wrong XML element."));
62 el.SetAttribute(
"y",
Y);
90 std::vector<Point2DInt> segment;
99 int lg_delta, sh_delta, cycle, lg_step, sh_step;
100 lg_delta = (int)x2 - (
int)x1;
101 sh_delta = (int)y2 - (
int)y1;
104 lg_delta = -lg_delta;
112 sh_delta = -sh_delta;
118 if (sh_delta < lg_delta)
120 cycle = lg_delta >> 1;
124 cycle = cycle + sh_delta;
125 if (cycle > lg_delta)
128 cycle = cycle - lg_delta;
136 cycle = sh_delta >> 1;
146 cycle = cycle + sh_delta;
147 if (cycle > lg_delta)
150 cycle = cycle - lg_delta;
164 Cloner::Register<Point2DInt>();
std::vector< Point2DInt > MakeSegment(const Point2DInt &p_begin, const Point2DInt &p_end)
Make a segment between two points.
StringUTF8 GetName() const
Gets the label of the element.
Direction
An enumeration of directions.
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
void Advance(const Direction &dir, int step=1)
Moves the point towards a direction.
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
void SetAttribute(const StringUTF8 &name, const StringUTF8 &value)
Sets the value of an attribute.
T GetAttribute(const StringUTF8 &name, bool silent=true) const
Gets an attribute.
xml::Element Serialize(xml::Element &parent) const
Dumps the object to an XML element. Unsafe.
A character string class.
void Deserialize(xml::Element &el)
Initializes the object from an XML element. Unsafe.
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
Invalid argument error (e.g.: nullptr pointer)
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.