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.data(),vs,*cs,transitiveClosure?true:false);
+ int m = generateXConstraints(rs,vs,*cs,transitiveClosure?true:false);
for(int i=0;i<n;i++) {
delete rs[i];
}
* useNeighbourLists determines whether or not a heuristic is used to deciding whether to resolve
* all overlap in the x pass, or leave some overlaps for the y pass.
*/
-int generateXConstraints(const int n, Rectangle** rs, Variable** vars, Constraint** &cs, const bool useNeighbourLists) {
+int generateXConstraints(vector<Rectangle*> &rs, Variable** vars,
+ Constraint** &cs, const bool useNeighbourLists) {
+
vector<Event> events;
- events.reserve(2 * n);
- for(int i=0;i<n;i++) {
+ events.reserve(2 * rs.size());
+ for(size_t i=0;i<rs.size();i++) {
vars[i]->desiredPosition=rs[i]->getCentreX();
Node *v = new Node(vars[i],rs[i],rs[i]->getCentreX());
events.emplace_back(Open,v,rs[i]->getMinY());
*/
#pragma once
#include <iostream>
+#include <vector>
class Rectangle {
friend std::ostream& operator <<(std::ostream &os, const Rectangle &r);
struct Constraint;
// returns number of constraints generated
-int generateXConstraints(const int n, Rectangle** rs, Variable** vars, Constraint** &cs, const bool useNeighbourLists);
+int generateXConstraints(std::vector<Rectangle*> &rs, Variable** vars,
+ Constraint** &cs, const bool useNeighbourLists);
int generateYConstraints(const int n, Rectangle** rs, Variable** vars, Constraint** &cs);