graph.cpp revision b5e66c5e6adbe1f6d2adc9d5fe7ed26b66fb1bcc
/*
* vim: ts=4 sw=4 et tw=0 wm=0
*
* libavoid - Fast, Incremental, Object-avoiding Line Router
* Copyright (C) 2004-2006 Michael Wybrow <mjwybrow@users.sourceforge.net>
*
* 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.
*
* 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. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "libavoid/connector.h"
#include "libavoid/geometry.h"
#include "libavoid/polyutil.h"
#include "libavoid/vertices.h"
#include <math.h>
namespace Avoid {
, _blocker(0)
, _added(false)
, _visible(false)
, _dist(-1)
{
// Not passed NULL values.
// We are in the same instance
}
{
if (_added)
{
makeInactive();
}
}
void EdgeInf::makeActive(void)
{
if (_visible)
{
_v1->visListSize++;
_v2->visListSize++;
}
else // if (invisible)
{
_v1->invisListSize++;
_v2->invisListSize++;
}
_added = true;
}
void EdgeInf::makeInactive(void)
{
if (_visible)
{
_v1->visListSize--;
_v2->visListSize--;
}
else // if (invisible)
{
_v1->invisListSize--;
_v2->invisListSize--;
}
_blocker = 0;
_added = false;
}
{
//assert(dist != 0);
{
makeInactive();
}
if (!_added)
{
_visible = true;
makeActive();
}
_blocker = 0;
}
void EdgeInf::alertConns(void)
{
{
*(*i) = true;
}
}
{
}
void EdgeInf::addCycleBlocker(void)
{
// Needs to be in invisibility graph.
addBlocker(-1);
}
void EdgeInf::addBlocker(int b)
{
{
makeInactive();
}
if (!_added)
{
_visible = false;
makeActive();
}
_dist = 0;
_blocker = b;
}
{
}
{
}
{
db_printf("Edge(");
db_printf(",");
db_printf(")\n");
}
{
{
db_printf("\tChecking visibility for existing invisibility edge..."
"\n\t\t");
db_print();
}
{
db_printf("\tChecking visibility for existing visibility edge..."
"\n\t\t");
db_print();
}
int blocker = 0;
bool cone1 = true;
bool cone2 = true;
{
}
else
{
{
db_printf("1: Edge of bounding shape\n");
// Don't even check this edge, it should be zero,
// since a point in a shape can't see it's corners
cone1 = false;
}
}
if (cone1)
{
// If outside the first cone, don't even bother checking.
{
}
else
{
{
db_printf("2: Edge of bounding shape\n");
// Don't even check this edge, it should be zero,
// since a point in a shape can't see it's corners
cone2 = false;
}
}
}
{
// if i and j see each other, add edge
db_printf("\tSetting visibility edge... \n\t\t");
db_print();
setDist(d);
}
else if (_router->InvisibilityGrph)
{
#if 0
#endif
// if i and j can't see each other, add blank edge
db_printf("\tSetting invisibility edge... \n\t\t");
db_print();
}
}
int EdgeInf::firstBlocker(void)
{
{
}
{
}
{
{
db_printf("Endpoint is inside shape %u so ignore shape edges.\n",
// One of the endpoints is inside this shape so ignore it.
{
// And skip the other vertices from this shape.
k = k->lstNext;
}
continue;
}
{
}
k = k->lstNext;
}
return 0;
}
{
{
return true;
}
return false;
}
{
{
return _v2;
}
return _v1;
}
{
if (knownNew)
{
}
else
{
edge = existingEdge(i, j);
{
}
}
{
delete edge;
}
return edge;
}
{
if (i->visListSize <= j->visListSize)
{
selected = i;
}
else
{
selected = j;
}
++edge)
{
{
return (*edge);
}
}
if (i->invisListSize <= j->invisListSize)
{
selected = i;
}
else
{
selected = j;
}
++edge)
{
{
return (*edge);
}
}
return NULL;
}
//===========================================================================
: _firstEdge(NULL)
, _count(0)
{
}
{
if (_firstEdge == NULL)
{
_firstEdge = edge;
}
else
{
}
_count++;
}
{
{
}
{
}
{
if (edge == _firstEdge)
{
_firstEdge = NULL;
}
}
else if (edge == _firstEdge)
{
}
_count--;
}
{
return _firstEdge;
}
{
return NULL;
}
}