summaryrefslogtreecommitdiffstats
path: root/src/libvpsc
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
committerMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
commita168040d5a452544328a1e6ad35aaac351f94d44 (patch)
treefae1ba829f543a473da281bd5fa6e4deabbf6912 /src/libvpsc
parentRemoved function pointers from SPObject and subclasses. (diff)
parentDutch translation update (diff)
downloadinkscape-a168040d5a452544328a1e6ad35aaac351f94d44.tar.gz
inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.zip
merged from trunk
(bzr r11608.1.56)
Diffstat (limited to 'src/libvpsc')
-rw-r--r--src/libvpsc/csolve_VPSC.cpp120
-rw-r--r--src/libvpsc/csolve_VPSC.h2
-rw-r--r--src/libvpsc/generate-constraints.cpp6
-rw-r--r--src/libvpsc/remove_rectangle_overlap.cpp1
4 files changed, 67 insertions, 62 deletions
diff --git a/src/libvpsc/csolve_VPSC.cpp b/src/libvpsc/csolve_VPSC.cpp
index 24459d09f..60e88a50b 100644
--- a/src/libvpsc/csolve_VPSC.cpp
+++ b/src/libvpsc/csolve_VPSC.cpp
@@ -8,6 +8,7 @@
*
* Released under GNU LGPL. Read the file 'COPYING' for more information.
*/
+#include <glib.h>
#include <iostream>
#include <cassert>
#include <cstdlib>
@@ -19,108 +20,109 @@
using namespace vpsc;
extern "C" {
Variable* newVariable(int id, double desiredPos, double weight) {
- return new Variable(id,desiredPos,weight);
+ return new Variable(id,desiredPos,weight);
}
Constraint* newConstraint(Variable* left, Variable* right, double gap) {
- return new Constraint(left,right,gap);
+ return new Constraint(left,right,gap);
}
Solver* newSolver(int n, Variable* vs[], int m, Constraint* cs[]) {
- return new Solver(n,vs,m,cs);
+ return new Solver(n,vs,m,cs);
}
Solver* newIncSolver(int n, Variable* vs[], int m, Constraint* cs[]) {
- return (Solver*)new vpsc::IncSolver(n,vs,m,cs);
+ return (Solver*)new vpsc::IncSolver(n,vs,m,cs);
}
int genXConstraints(int n, boxf* bb, Variable** vs, Constraint*** cs,int transitiveClosure) {
- Rectangle* rs[n];
- for(int i=0;i<n;i++) {
- rs[i]=new Rectangle(bb[i].LL.x,bb[i].UR.x,bb[i].LL.y,bb[i].UR.y);
- }
- int m = generateXConstraints(n,rs,vs,*cs,transitiveClosure);
- for(int i=0;i<n;i++) {
- delete rs[i];
- }
- return m;
+ Rectangle* rs[n];
+ for(int i=0;i<n;i++) {
+ rs[i]=new Rectangle(bb[i].LL.x,bb[i].UR.x,bb[i].LL.y,bb[i].UR.y);
+ }
+ int m = generateXConstraints(n,rs,vs,*cs,transitiveClosure);
+ for(int i=0;i<n;i++) {
+ delete rs[i];
+ }
+ return m;
}
int genYConstraints(int n, boxf* bb, Variable** vs, Constraint*** cs) {
- Rectangle* rs[n];
- for(int i=0;i<n;i++) {
- rs[i]=new Rectangle(bb[i].LL.x,bb[i].UR.x,bb[i].LL.y,bb[i].UR.y);
- }
- int m = generateYConstraints(n,rs,vs,*cs);
- for(int i=0;i<n;i++) {
- delete rs[i];
- }
- return m;
+ g_assert(n > 0);
+ Rectangle* rs[n];
+ for(int i=0;i<n;i++) {
+ rs[i]=new Rectangle(bb[i].LL.x,bb[i].UR.x,bb[i].LL.y,bb[i].UR.y);
+ }
+ int m = generateYConstraints(n,rs,vs,*cs);
+ for(int i=0;i<n;i++) {
+ delete rs[i];
+ }
+ return m;
}
Constraint** newConstraints(int m) {
- return new Constraint*[m];
+ return new Constraint*[m];
}
void deleteConstraints(int m, Constraint **cs) {
- for(int i=0;i<m;i++) {
- delete cs[i];
- }
- delete [] cs;
+ for(int i=0;i<m;i++) {
+ delete cs[i];
+ }
+ delete [] cs;
}
void deleteConstraint(Constraint* c) {
- delete c;
+ delete c;
}
void deleteVariable(Variable* v) {
- delete v;
+ delete v;
}
void satisfyVPSC(Solver* vpsc) {
- try {
- vpsc->satisfy();
- } catch(const char *e) {
- std::cerr << e << std::endl;
- exit(1);
- }
+ try {
+ vpsc->satisfy();
+ } catch(const char *e) {
+ std::cerr << e << std::endl;
+ exit(1);
+ }
}
int getSplitCnt(IncSolver *vpsc) {
- return vpsc->splitCnt;
+ return vpsc->splitCnt;
}
void deleteVPSC(Solver *vpsc) {
- assert(vpsc!=NULL);
- delete vpsc;
+ assert(vpsc!=NULL);
+ delete vpsc;
}
void solveVPSC(Solver* vpsc) {
- vpsc->solve();
+ vpsc->solve();
}
void splitIncVPSC(IncSolver* vpsc) {
- vpsc->splitBlocks();
+ vpsc->splitBlocks();
}
void setVariableDesiredPos(Variable *v, double desiredPos) {
- v->desiredPosition = desiredPos;
+ v->desiredPosition = desiredPos;
}
double getVariablePos(Variable *v) {
- return v->position();
+ return v->position();
}
void remapInConstraints(Variable *u, Variable *v, double dgap) {
- for(Constraints::iterator i=u->in.begin();i!=u->in.end();i++) {
- Constraint* c=*i;
- c->right=v;
- c->gap+=dgap;
- v->in.push_back(c);
- }
- u->in.clear();
+ for(Constraints::iterator i=u->in.begin();i!=u->in.end();i++) {
+ Constraint* c=*i;
+ c->right=v;
+ c->gap+=dgap;
+ v->in.push_back(c);
+ }
+ u->in.clear();
}
void remapOutConstraints(Variable *u, Variable *v, double dgap) {
- for(Constraints::iterator i=u->out.begin();i!=u->out.end();i++) {
- Constraint* c=*i;
- c->left=v;
- c->gap+=dgap;
- v->out.push_back(c);
- }
- u->out.clear();
+ for(Constraints::iterator i=u->out.begin();i!=u->out.end();i++) {
+ Constraint* c=*i;
+ c->left=v;
+ c->gap+=dgap;
+ v->out.push_back(c);
+ }
+ u->out.clear();
}
int getLeftVarID(Constraint *c) {
- return c->left->id;
+ return c->left->id;
}
int getRightVarID(Constraint *c){
- return c->right->id;
+ return c->right->id;
}
double getSeparation(Constraint *c){
- return c->gap;
+ return c->gap;
}
}
diff --git a/src/libvpsc/csolve_VPSC.h b/src/libvpsc/csolve_VPSC.h
index b0d01e763..edfd16657 100644
--- a/src/libvpsc/csolve_VPSC.h
+++ b/src/libvpsc/csolve_VPSC.h
@@ -60,7 +60,9 @@ int genXConstraints(int n, boxf[], Variable** vs, Constraint*** cs,
int genYConstraints(int n, boxf[], Variable** vs, Constraint*** cs);
void satisfyVPSC(Solver*);
+void deleteVPSC(Solver*);
void solveVPSC(Solver*);
+void splitIncVPSC(IncSolver*);
Solver* newIncSolver(int n, Variable* vs[], int m, Constraint* cs[]);
void splitIncSolver(IncSolver*);
int getSplitCnt(IncSolver *vpsc);
diff --git a/src/libvpsc/generate-constraints.cpp b/src/libvpsc/generate-constraints.cpp
index 8dd2d9331..fabe5217f 100644
--- a/src/libvpsc/generate-constraints.cpp
+++ b/src/libvpsc/generate-constraints.cpp
@@ -105,7 +105,7 @@ bool CmpNodePos::operator() (const Node* u, const Node* v) const {
*/
}
-NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
+static NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
NodeSet *leftv = new NodeSet;
NodeSet::iterator i=scanline.find(v);
while(i--!=scanline.begin()) {
@@ -120,7 +120,7 @@ NodeSet* getLeftNeighbours(NodeSet &scanline,Node *v) {
}
return leftv;
}
-NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) {
+static NodeSet* getRightNeighbours(NodeSet &scanline,Node *v) {
NodeSet *rightv = new NodeSet;
NodeSet::iterator i=scanline.find(v);
for(++i;i!=scanline.end(); ++i) {
@@ -144,7 +144,7 @@ struct Event {
Event(EventType t, Node *v, double p) : type(t),v(v),pos(p) {};
};
Event **events;
-int compare_events(const void *a, const void *b) {
+static int compare_events(const void *a, const void *b) {
Event *ea=*(Event**)a;
Event *eb=*(Event**)b;
if(ea->v->r==eb->v->r) {
diff --git a/src/libvpsc/remove_rectangle_overlap.cpp b/src/libvpsc/remove_rectangle_overlap.cpp
index 381759f3c..d667ffb1e 100644
--- a/src/libvpsc/remove_rectangle_overlap.cpp
+++ b/src/libvpsc/remove_rectangle_overlap.cpp
@@ -15,6 +15,7 @@
#include "solve_VPSC.h"
#include "variable.h"
#include "constraint.h"
+#include "remove_rectangle_overlap.h" /* own include */
#ifdef RECTANGLE_OVERLAP_LOGGING
#include <fstream>
#include "blocks.h"