Code

fix transformation of LPECurveStitch when "Scale width relative" is set
[inkscape.git] / src / libavoid / static.cpp
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libavoid - Fast, Incremental, Object-avoiding Line Router
5  * Copyright (C) 2004-2006  Michael Wybrow <mjwybrow@users.sourceforge.net>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  * 
21 */
23 #include <cassert>
24 #include <iostream>
25 #include "libavoid/vertices.h"
26 #include "libavoid/connector.h"
27 #include "libavoid/graph.h"
28 #include "libavoid/static.h"
29 #include "libavoid/shape.h"
30 #include "libavoid/visibility.h"
31 #include "libavoid/debug.h"
32 #include "libavoid/router.h"
34 namespace Avoid {
36 static void computeCompleteVis(Router *router);
39 // This should only be used for the static algorithm.
40 //
41 // XXX: If to set up the vis graph for incremental it would need 
42 //      the shapeRef pointers in obs.
43 //
44 void CreateVisGraph(Router *router, Polygn **obs, int n_obs)
45 {
46     for (int poly_i = 0; poly_i < n_obs; poly_i++)
47     {
48         unsigned int id = obs[poly_i]->id;
49         
50         new ShapeRef(router, id, *(obs[poly_i]));
51     }
52     computeCompleteVis(router);
53 }
56 static void computeCompleteVis(Router *router)
57 {
58     VertInf *beginVert = router->vertices.shapesBegin();
59     VertInf *endVert = router->vertices.end();
60     for (VertInf *i = beginVert; i != endVert; i = i->lstNext)
61     {
62         db_printf("-- CONSIDERING --\n");
63         i->id.db_print();
65         for (VertInf *j = i->lstPrev ; j != NULL; j = j->lstPrev)
66         {
67             bool knownNew = true;
68             EdgeInf::checkEdgeVisibility(i, j, knownNew);
69         }
70     }
71 }
74 void DestroyVisGraph(Router *router)
75 {
76     ShapeRefList::iterator sFinish = router->shapeRefs.end();
77     ShapeRefList::iterator sCurr;
78     
79     while ((sCurr = router->shapeRefs.begin()) != sFinish)
80     {
81         ShapeRef *shape = (*sCurr);
83         shape->removeFromGraph();
84         delete shape;
85     }
86     
87     ConnRefList::iterator cFinish = router->connRefs.end();
88     ConnRefList::iterator cCurr;
89     
90     while ((cCurr = router->connRefs.begin())!= cFinish)
91     {
92         ConnRef *conn = (*cCurr);
94         conn->removeFromGraph();
95         conn->unInitialise();
96     }
97     // Clear contains info.
98     router->contains.clear();
100     assert(router->vertices.connsBegin() == NULL);