45#include <libtopology/topology_graph.h>
46#include <libproject/project.h>
55 topology::Node *v =
new topology::Node(vs.size(), r);
59void addToPath(topology::EdgePoints& ps, topology::Node *v, topology::EdgePoint::RectIntersect i) {
60 ps.push_back(
new topology::EdgePoint(v,i));
59void addToPath(topology::EdgePoints& ps, topology::Node *v, topology::EdgePoint::RectIntersect i) {
…}
63 Test(
const double d,
const unsigned i,topology::Nodes& vs, topology::Edges& es) :
TestConvergence(d,i), vs(vs),
es(
es), iter(1) {}
64 bool operator()(
const double new_stress, valarray<double> & X, valarray<double> & Y) {
67 cout <<
"stress="<<new_stress<<
" iteration="<<iter<<endl;
69 ss<<
outFName<<
"-"<< setfill(
'0') << setw(3) << iter++ <<
".svg";
88 const std::size_t E =
sizeof(edge_array) /
sizeof(
Edge);
89 vector<Edge>
es(edge_array,edge_array+E);
90 vector<vpsc::Rectangle*>
rs;
91 const double w=54, h=34;
93 x[]={406, 444, 474, 406, 441, 375, 408, 373, 339},
94 y[]={279, 224, 179, 92, 135, 135, 179, 226, 179};
95 const unsigned resizeID=6;
96 for(
unsigned i=0;i<V;++i) {
99 double idealLength=60;
102 for(vector<Rectangle*>::iterator i =
rs.begin(); i!=
rs.end();++i) {
113 Test
test(0.00001,100,vs,tes);
120 printf(
"finalStress=%f\n",finalStress);
Implements a constrained force-directed layout algorithm.
void run(bool x=true, bool y=true)
Implements the main layout loop, taking descent steps until stress is no-longer significantly reduced...
void setTopology(TopologyAddonInterface *topology)
Set an addon for doing topology preserving layout.
double computeStress() const
A default functor that is called before each iteration in the main loop of the ConstrainedFDLayout::r...
A Resize specifies a new required bounding box for a node.
A default functor that is called after each iteration of the layout algorithm.
virtual bool operator()(const double new_stress, std::valarray< double > &X, std::valarray< double > &Y)
A rectangle represents a fixed-size shape in the diagram that may be moved to prevent overlaps and sa...
double getCentreY() const
double getCentreX() const
vector< vpsc::Rectangle * > rs
void writeFile(const topology::Nodes &vs, const topology::Edges &es, const string &outputFileName)
libcola: Force-directed network layout subject to separation constraints library.
std::vector< cola::Resize > Resizes
A vector of Resize objects.
std::pair< unsigned, unsigned > Edge
Edges are simply a pair of indices to entries in the Node vector.
topology::Node * addNode(topology::Nodes &vs, vpsc::Rectangle *r)
void addToPath(topology::EdgePoints &ps, topology::Node *v, topology::EdgePoint::RectIntersect i)