crossing.h revision ed0798e33e14e86b60f8cd254d7131f9d83ba8c0
#ifndef __GEOM_CROSSING_H
#define __GEOM_CROSSING_H
#include <vector>
#include <set>
#include "rect.h"
#include "sweep.h"
struct Crossing {
bool dir; //True: along a, a becomes outside.
unsigned a, b; //storage of indices
Crossing(double t_a, double t_b, unsigned ai, unsigned bi, bool direction) : dir(direction), ta(t_a), tb(t_b), a(ai), b(bi) {}
bool operator==(const Crossing & other) const { return a == other.a && b == other.b && dir == other.dir && ta == other.ta && tb == other.tb; }
};
/*inline bool near(Crossing a, Crossing b) {
}
struct NearF { bool operator()(Crossing a, Crossing b) { return near(a, b); } };
*/
struct CrossingOrder {
unsigned ix;
CrossingOrder(unsigned i) : ix(i) {}
}
};
return rs;
}
inline void sort_crossings(Crossings &cr, unsigned ix) { std::sort(cr.begin(), cr.end(), CrossingOrder(ix)); }
struct Crosser {
virtual Crossings crossings(T const &a, T const &b) { return crossings(std::vector<T>(1,a), std::vector<T>(1,b))[0]; }
//Sort & add A-sorted crossings
sort_crossings(cr, i);
std::merge(results[i].begin(), results[i].end(), cr.begin(), cr.end(), n.begin(), CrossingOrder(i));
results[i] = n;
//Sort & add B-sorted crossings
std::merge(results[jc].begin(), results[jc].end(), cr.begin(), cr.end(), n.begin(), CrossingOrder(jc));
}
}
return results;
}
};
}
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :