crossing.h revision a4030d5ca449e7e384bc699cd249ee704faaeab0
/**
* \file
* \brief \todo brief description
*
* Authors:
* Michael Sloane <?@?.?>
* Marco <?@?.?>
*
* Copyright 2006-2008 authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
*/
#ifndef __GEOM_CROSSING_H
#define __GEOM_CROSSING_H
#include <vector>
//Crossing between one or two paths
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; }
};
/*
struct Edge {
unsigned node, path;
double time;
bool reverse;
Edge(unsigned p, double t, bool r) : path(p), time(t), reverse(r) {}
bool operator==(Edge const &other) const { return other.path == path && other.time == time && other.reverse == reverse; }
};
struct CrossingNode {
std::vector<Edge> edges;
CrossingNode() : edges(std::vector<Edge>()) {}
explicit CrossingNode(std::vector<Edge> es) : edges(es) {}
void add_edge(Edge const &e) {
if(std::find(edges.begin(), edges.end(), e) == edges.end())
edges.push_back(e);
}
double time_on(unsigned p) {
for(unsigned i = 0; i < edges.size(); i++)
if(edges[i].path == p) return edges[i].time;
std::cout << "CrossingNode time_on failed\n";
return 0;
}
};
typedef std::vector<CrossingNode> CrossingGraph;
struct TimeOrder {
bool operator()(Edge a, Edge b) {
}
};
class Path;
CrossingGraph create_crossing_graph(std::vector<Path> const &p, Crossings const &crs);
*/
/*inline bool are_near(Crossing a, Crossing b) {
}
struct NearF { bool operator()(Crossing a, Crossing b) { return are_near(a, b); } };
*/
struct CrossingOrder {
unsigned ix;
bool rev;
if(rev)
else
}
};
for (unsigned i = 0; i < a.size(); i++) {
if (bb) {
}
}
return rs;
}
// provide specific method for Paths because paths can be closed or open. Path::size() is named somewhat wrong...
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:fileencoding=utf-8:textwidth=99 :