Copyright 2010, SIL International All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html.
Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version.
*/ #include <algorithm> #include <cmath> #include <limits>
for (iterator i = _exclusions.begin(), ie = _exclusions.end(); i != ie && e.x < e.xm; ++i)
{ const uint8 oca = e.outcode(i->x),
ocb = e.outcode(i->xm); if ((oca & ocb) != 0) continue;
switch (oca ^ ocb) // What kind of overlap?
{ case 0: // e completely covers i // split e at i.x into e1,e2 // split e2 at i.mx into e2,e3 // drop e1 ,i+e2, e=e3
*i += e;
e.left_trim(i->xm); break; case 1: // e overlaps on the rhs of i // split i at e->x into i1,i2 // split e at i.mx into e1,e2 // trim i1, insert i2+e1, e=e2 if (!separated(i->xm, e.x)) break; if (separated(i->x,e.x)) { i = _exclusions.insert(i,i->split_at(e.x)); ++i; }
*i += e;
e.left_trim(i->xm); break; case 2: // e overlaps on the lhs of i // split e at i->x into e1,e2 // split i at e.mx into i1,i2 // drop e1, insert e2+i1, trim i2 if (!separated(e.xm, i->x)) return; if (separated(e.xm, i->xm)) i = _exclusions.insert(i,i->split_at(e.xm));
*i += e; return; case 3: // i completely covers e // split i at e.x into i1,i2 // split i2 at e.mx into i2,i3 // insert i1, insert e+i2 if (separated(e.xm, i->xm)) i = _exclusions.insert(i,i->split_at(e.xm));
i = _exclusions.insert(i, i->split_at(e.x));
*++i += e; return;
}
for (iterator i = _exclusions.begin(), ie = _exclusions.end(); i != ie; ++i)
{ const uint8 oca = i->outcode(x),
ocb = i->outcode(xm); if ((oca & ocb) != 0) continue;
switch (oca ^ ocb) // What kind of overlap?
{ case 0: // i completely covers e if (separated(i->x, x)) { i = _exclusions.insert(i,i->split_at(x)); ++i; }
GR_FALLTHROUGH; // no break case 1: // i overlaps on the rhs of e
i->left_trim(xm); return; case 2: // i overlaps on the lhs of e
i->xm = x; if (separated(i->x, i->xm)) break;
GR_FALLTHROUGH; // no break case 3: // e completely covers i
i = _exclusions.erase(i);
--i; break;
}
ie = _exclusions.end();
}
}
Zones::const_iterator Zones::find_exclusion_under(float x) const
{
size_t l = 0, h = _exclusions.size();
while (l < h)
{
size_t const p = (l+h) >> 1; switch (_exclusions[p].outcode(x))
{ case 0 : return _exclusions.begin()+p; case 1 : h = p; break; case 2 : case 3 : l = p+1; break;
}
}
// Forward scan looking for lowest cost for (const_iterator i = start, ie = _exclusions.end(); i != ie; ++i) if (i->track_cost(best_c, best_x, origin)) break;
// Backward scan looking for lowest cost // We start from the exclusion to the immediate left of start since we've // already tested start with the right most scan above. for (const_iterator i = start-1, ie = _exclusions.begin()-1; i != ie; --i) if (i->track_cost(best_c, best_x, origin)) break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.