~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/livarot/Shape.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Ted Gould, Kees Cook
  • Date: 2009-06-24 14:00:43 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624140043-07stp20mry48hqup
Tags: 0.47~pre0-0ubuntu1
* New upstream release

[ Ted Gould ]
* debian/control: Adding libgsl0 and removing version specifics on boost

[ Kees Cook ]
* debian/watch: updated to run uupdate and mangle pre-release versions.
* Dropped patches that have been taken upstream:
  - 01_mips
  - 02-poppler-0.8.3
  - 03-chinese-inkscape
  - 05_fix_latex_patch
  - 06_gcc-4.4
  - 07_cdr2svg
  - 08_skip-bad-utf-on-pdf-import
  - 09_gtk-clist
  - 10_belarussian
  - 11_libpng
  - 12_desktop
  - 13_slider
  - 100_svg_import_improvements
  - 102_sp_pattern_painter_free
  - 103_bitmap_type_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
}
310
310
 
311
311
int
312
 
Shape::AddPoint (const NR::Point x)
 
312
Shape::AddPoint (const Geom::Point x)
313
313
{
314
314
  if (numberOfPoints() >= maxPt)
315
315
    {
1134
1134
    }
1135
1135
 
1136
1136
  dg_arete a;
1137
 
  a.dx = NR::Point(0, 0);
 
1137
  a.dx = Geom::Point(0, 0);
1138
1138
  a.st = a.en = -1;
1139
1139
  a.prevS = a.nextS = -1;
1140
1140
  a.prevE = a.nextE = -1;
1209
1209
    }
1210
1210
 
1211
1211
  dg_arete a;
1212
 
  a.dx = NR::Point(0, 0);
 
1212
  a.dx = Geom::Point(0, 0);
1213
1213
  a.st = a.en = -1;
1214
1214
  a.prevS = a.nextS = -1;
1215
1215
  a.prevE = a.nextE = -1;
1552
1552
}
1553
1553
 
1554
1554
int
1555
 
Shape::CmpToVert (NR::Point ax, NR::Point bx,bool as,bool bs)
 
1555
Shape::CmpToVert (Geom::Point ax, Geom::Point bx,bool as,bool bs)
1556
1556
{
1557
1557
  int tstAX = 0;
1558
1558
  int tstAY = 0;
1671
1671
  if (quadA > quadB)
1672
1672
    return -1;
1673
1673
 
1674
 
  NR::Point av, bv;
 
1674
  Geom::Point av, bv;
1675
1675
  av = ax;
1676
1676
  bv = bx;
1677
1677
  double si = cross (bv, av);
1702
1702
 
1703
1703
  int ppos = (s + e) / 2;
1704
1704
  int plast = ppos;
1705
 
  NR::Point pvalx = list[ppos].x;
 
1705
  Geom::Point pvalx = list[ppos].x;
1706
1706
  bool      pvals = list[ppos].starting;
1707
1707
  
1708
1708
  int le = s, ri = e;
2054
2054
// other=depends on your fill rule
2055
2055
// if the polygon is uncrossed, it's all the same, usually
2056
2056
int
2057
 
Shape::PtWinding (const NR::Point px) const 
 
2057
Shape::PtWinding (const Geom::Point px) const 
2058
2058
{
2059
2059
  int lr = 0, ll = 0, rr = 0;
2060
2060
  
2061
2061
  for (int i = 0; i < numberOfEdges(); i++)
2062
2062
  {
2063
 
    NR::Point const adir = getEdge(i).dx;
 
2063
    Geom::Point const adir = getEdge(i).dx;
2064
2064
 
2065
 
    NR::Point const ast = getPoint(getEdge(i).st).x;
2066
 
    NR::Point const aen = getPoint(getEdge(i).en).x;
 
2065
    Geom::Point const ast = getPoint(getEdge(i).st).x;
 
2066
    Geom::Point const aen = getPoint(getEdge(i).en).x;
2067
2067
    
2068
2068
    //int const nWeight = eData[i].weight;
2069
2069
    int const nWeight = 1;
2094
2094
      if (aen[1] >= px[1]) continue;
2095
2095
    }
2096
2096
 
2097
 
    NR::Point const diff = px - ast;
 
2097
    Geom::Point const diff = px - ast;
2098
2098
    double const cote = cross(diff, adir);
2099
2099
    if (cote == 0) continue;
2100
2100
    if (cote < 0) {
2190
2190
 *    \return Minimum distance from p to any of the points or edges of s.
2191
2191
 */
2192
2192
 
2193
 
double distance(Shape const *s, NR::Point const &p)
 
2193
double distance(Shape const *s, Geom::Point const &p)
2194
2194
{
2195
2195
    if ( s->hasPoints() == false) {
2196
2196
        return 0.0;
2201
2201
    ** us the distance squared; we can leave the square root
2202
2202
    ** until the end.
2203
2203
    */
2204
 
    double bdot = NR::dot(p - s->getPoint(0).x, p - s->getPoint(0).x);
 
2204
    double bdot = Geom::dot(p - s->getPoint(0).x, p - s->getPoint(0).x);
2205
2205
 
2206
2206
    for (int i = 0; i < s->numberOfPoints(); i++) {
2207
 
        NR::Point const offset( p - s->getPoint(i).x );
2208
 
        double ndot = NR::dot(offset, offset);
 
2207
        Geom::Point const offset( p - s->getPoint(i).x );
 
2208
        double ndot = Geom::dot(offset, offset);
2209
2209
        if ( ndot < bdot ) {
2210
2210
            bdot = ndot;
2211
2211
        }
2214
2214
    for (int i = 0; i < s->numberOfEdges(); i++) {
2215
2215
        if ( s->getEdge(i).st >= 0 && s->getEdge(i).en >= 0 ) {
2216
2216
            /* The edge has start and end points */
2217
 
            NR::Point const st(s->getPoint(s->getEdge(i).st).x); // edge start
2218
 
            NR::Point const en(s->getPoint(s->getEdge(i).en).x); // edge end
 
2217
            Geom::Point const st(s->getPoint(s->getEdge(i).st).x); // edge start
 
2218
            Geom::Point const en(s->getPoint(s->getEdge(i).en).x); // edge end
2219
2219
 
2220
 
            NR::Point const d(p - st);       // vector between p and edge start
2221
 
            NR::Point const e(en - st);      // vector of the edge
2222
 
            double const el = NR::dot(e, e); // edge length
 
2220
            Geom::Point const d(p - st);       // vector between p and edge start
 
2221
            Geom::Point const e(en - st);      // vector of the edge
 
2222
            double const el = Geom::dot(e, e); // edge length
2223
2223
 
2224
2224
            /* Update bdot if appropriate */
2225
2225
            if ( el > 0.001 ) {
2226
 
                double const npr = NR::dot(d, e);
 
2226
                double const npr = Geom::dot(d, e);
2227
2227
                if ( npr > 0 && npr < el ) {
2228
2228
                    double const nl = fabs( NR::cross(d, e) );
2229
2229
                    double ndot = nl * nl / el;
2252
2252
 *    \param max_l2 L2 distance.
2253
2253
 */
2254
2254
 
2255
 
bool distanceLessThanOrEqual(Shape const *s, NR::Point const &p, double const max_l2)
 
2255
bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const max_l2)
2256
2256
{
2257
2257
    if ( s->hasPoints() == false ) {
2258
2258
        return false;
2270
2270
  
2271
2271
    double const max_l1 = max_l2 * M_SQRT2;
2272
2272
    for (int i = 0; i < s->numberOfPoints(); i++) {
2273
 
        NR::Point const offset( p - s->getPoint(i).x );
 
2273
        Geom::Point const offset( p - s->getPoint(i).x );
2274
2274
        double const l1 = NR::L1(offset);
2275
 
        if ( (l1 <= max_l2) || ((l1 <= max_l1) && (NR::L2(offset) <= max_l2)) ) {
 
2275
        if ( (l1 <= max_l2) || ((l1 <= max_l1) && (Geom::L2(offset) <= max_l2)) ) {
2276
2276
            return true;
2277
2277
        }
2278
2278
    }
2279
2279
    
2280
2280
    for (int i = 0; i < s->numberOfEdges(); i++) {
2281
2281
        if ( s->getEdge(i).st >= 0 && s->getEdge(i).en >= 0 ) {
2282
 
            NR::Point const st(s->getPoint(s->getEdge(i).st).x);
2283
 
            NR::Point const en(s->getPoint(s->getEdge(i).en).x);
2284
 
            NR::Point const d(p - st);
2285
 
            NR::Point const e(en - st);
2286
 
            double const el = NR::L2(e);
 
2282
            Geom::Point const st(s->getPoint(s->getEdge(i).st).x);
 
2283
            Geom::Point const en(s->getPoint(s->getEdge(i).en).x);
 
2284
            Geom::Point const d(p - st);
 
2285
            Geom::Point const e(en - st);
 
2286
            double const el = Geom::L2(e);
2287
2287
            if ( el > 0.001 ) {
2288
 
                NR::Point const e_unit(e / el);
2289
 
                double const npr = NR::dot(d, e_unit);
 
2288
                Geom::Point const e_unit(e / el);
 
2289
                double const npr = Geom::dot(d, e_unit);
2290
2290
                if ( npr > 0 && npr < el ) {
2291
2291
                    double const nl = fabs(NR::cross(d, e_unit));
2292
2292
                    if ( nl <= max_l2 ) {