Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
blocks.h
Go to the documentation of this file.
1/*
2 * vim: ts=4 sw=4 et tw=0 wm=0
3 *
4 * libvpsc - A solver for the problem of Variable Placement with
5 * Separation Constraints.
6 *
7 * Copyright (C) 2005-2012 Monash University
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 * See the file LICENSE.LGPL distributed with the library.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 *
19 * Author(s): Tim Dwyer
20 * Michael Wybrow
21*/
22
23/*
24 * @brief A block structure defined over the variables
25 *
26 * A block structure defined over the variables such that each block contains
27 * 1 or more variables, with the invariant that all constraints inside a block
28 * are satisfied by keeping the variables fixed relative to one another
29 *
30 */
31
32#ifndef VPSC_BLOCKS_H
33#define VPSC_BLOCKS_H
34
35#ifdef LIBVPSC_LOGGING
36#define LOGFILE "libvpsc.log"
37#endif
38
39#include <list>
40#include <vector>
41
42// size_t is strangely not defined on some older MinGW GCC versions.
43#include <cstddef>
44
45namespace vpsc {
46class Block;
47class Variable;
48class Constraint;
49/*
50 * A block structure defined over the variables such that each block contains
51 * 1 or more variables, with the invariant that all constraints inside a block
52 * are satisfied by keeping the variables fixed relative to one another
53 */
54class Blocks
55{
56public:
57 Blocks(std::vector<Variable*> const &vs);
58 ~Blocks(void);
59 void mergeLeft(Block *r);
60 void mergeRight(Block *l);
61 void split(Block *b, Block *&l, Block *&r, Constraint *c);
62 std::list<Variable*> *totalOrder();
63 void cleanup();
64 double cost();
65
66 size_t size() const;
67 Block *at(size_t index) const;
68 void insert(Block *block);
69
71private:
72 void dfsVisit(Variable *v, std::list<Variable*> *order);
73 void removeBlock(Block *doomed);
74
75 std::vector<Block*> m_blocks;
76 std::vector<Variable*> const &vs;
77 size_t nvs;
78};
79
80inline size_t Blocks::size() const
81{
82 return m_blocks.size();
83}
84
85inline Block *Blocks::at(size_t index) const
86{
87 return m_blocks[index];
88}
89
90inline void Blocks::insert(Block *block)
91{
92 m_blocks.push_back(block);
93}
94
95}
96#endif // VPSC_BLOCKS_H
void split(Block *b, Block *&l, Block *&r, Constraint *c)
Definition blocks.cpp:212
void insert(Block *block)
Definition blocks.h:90
std::vector< Block * > m_blocks
Definition blocks.h:75
size_t nvs
Definition blocks.h:77
void removeBlock(Block *doomed)
Definition blocks.cpp:169
long blockTimeCtr
Definition blocks.h:70
void mergeLeft(Block *r)
Definition blocks.cpp:107
double cost()
Definition blocks.cpp:239
std::list< Variable * > * totalOrder()
Definition blocks.cpp:74
void cleanup()
Definition blocks.cpp:175
Block * at(size_t index) const
Definition blocks.h:85
~Blocks(void)
Definition blocks.cpp:59
size_t size() const
Definition blocks.h:80
std::vector< Variable * > const & vs
Definition blocks.h:76
void dfsVisit(Variable *v, std::list< Variable * > *order)
Definition blocks.cpp:88
void mergeRight(Block *l)
Definition blocks.cpp:141
A constraint determines a minimum or exact spacing required between two Variable objects.
Definition constraint.h:45
A variable is comprised of an ideal position, final position and a weight.
Definition variable.h:45
double c[8][4]
const unsigned order
libvpsc: Variable Placement with Separation Constraints quadratic program solver library.
int index