/*
* vim: ts=4 sw=4 et tw=0 wm=0
*
* libavoid - Fast, Incremental, Object-avoiding Line Router
*
* Copyright (C) 2004-2009 Monash University
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* See the file LICENSE.LGPL distributed with the library.
*
* Licensees holding a valid commercial license may use this file in
* accordance with the commercial license agreement provided with the
* library.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Author(s): Michael Wybrow <mjwybrow@users.sourceforge.net>
*/
#include <cmath>
#include <cfloat>
#include <cstdlib>
#include "libavoid/geomtypes.h"
#include "libavoid/assertions.h"
namespace Avoid
{
id(0),
{
}
x(xv),
y(yv),
id(0),
{
}
{
{
return true;
}
return false;
}
{
{
return true;
}
return false;
}
// Just defined to allow std::set<Point>. Not particularly meaningful!
{
if (x == rhs.x)
{
return (y < rhs.y);
}
return (x < rhs.x);
}
{
return ((dimension == 0) ? x : y);
}
{
return ((dimension == 0) ? x : y);
}
: PolygonInterface(),
{
{
{
{
break;
}
}
}
}
: PolygonInterface()
{
clear();
}
{
}
{
}
{
}
{
return _id;
}
{
}
{
double progressiveMinX = DBL_MAX;
double progressiveMinY = DBL_MAX;
double progressiveMaxX = -DBL_MAX;
double progressiveMaxY = -DBL_MAX;
{
}
if (minX)
{
*minX = progressiveMinX;
}
if (maxX)
{
*maxX = progressiveMaxX;
}
if (minY)
{
*minY = progressiveMinY;
}
if (maxY)
{
*maxY = progressiveMaxY;
}
}
: PolygonInterface()
{
clear();
}
: PolygonInterface(),
{
}
: PolygonInterface(),
{
{
}
}
{
}
{
}
{
}
{
return _id;
}
{
}
static const unsigned int SHORTEN_NONE = 0;
static const unsigned int SHORTEN_START = 1;
static const unsigned int SHORTEN_END = 2;
// shorten_line():
// Given the two endpoints of a line segment, this function adjusts the
// endpoints of the line to shorten the line by shorten_length at either
// or both ends.
//
const unsigned int mode, const double shorten_length)
{
if (mode == SHORTEN_NONE)
{
return;
}
// Handle case where shorten length is greater than the length of the
// line segment.
if ((mode == SHORTEN_BOTH) &&
{
return;
}
else if ((mode == SHORTEN_START) &&
{
return;
}
else if ((mode == SHORTEN_END) &&
{
return;
}
// Handle orthogonal line segments.
{
// Vertical
if (mode & SHORTEN_START)
{
}
if (mode & SHORTEN_END)
{
}
return;
}
{
// Horizontal
if (mode & SHORTEN_START)
{
}
if (mode & SHORTEN_END)
{
}
return;
}
if (mode & SHORTEN_END)
{
{
}
{
}
}
if (mode & SHORTEN_START)
{
{
}
{
}
}
}
{
{
}
}
{
// Combine collinear line segments into single segments:
{
simplified.ps[j]) == 0)
{
// These three points make up two collinear segments, so just
// compine them into a single segment.
}
else
{
++j;
++it;
}
}
return simplified;
}
// curvedPolyline():
// Returns a curved approximation of this multi-segment PolyLine, with
// the corners replaced by smooth Bezier curves. curve_amount describes
// how large to make the curves.
// The ts value for each point in the returned Polygon describes the
// drawing operation: 'M' (move) marks the first point, a line segment
// is marked with an 'L' and three 'C's (along with the previous point)
// describe the control points of a Bezier curve.
//
const bool closed) const
{
if (num_of_points <= 2)
{
// There is only a single segment, do nothing.
curved = *this;
return curved;
}
// Build the curved polyline:
double last_x = 0;
double last_y = 0;
if (closed)
{
}
else
{
}
{
if (!closed)
{
if (j == 1)
{
mode = SHORTEN_END;
}
else if (j == (size() - 1))
{
}
}
if (j > 1)
{
}
{
// Close the path.
break;
}
}
return curved;
}
: Polygon(4)
{
}
const double height)
{
}
}