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

« back to all changes in this revision

Viewing changes to src/line-geometry.h

  • 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:
12
12
#ifndef SEEN_LINE_GEOMETRY_H
13
13
#define SEEN_LINE_GEOMETRY_H
14
14
 
15
 
#include "libnr/nr-point.h"
16
 
#include "libnr/nr-point-fns.h"
17
 
#include "libnr/nr-maybe.h"
 
15
#include <boost/optional.hpp>
18
16
#include "glib.h"
19
17
#include "display/sp-ctrlline.h"
20
18
#include "axis-manip.h" // FIXME: This is only for Box3D::epsilon; move that to a better location
26
24
 
27
25
class Line {
28
26
public:
29
 
    Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint = true);
 
27
    Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint = true);
30
28
    Line(Line const &line);
31
29
    virtual ~Line() {}
32
30
    Line &operator=(Line const &line);
33
 
    virtual NR::Maybe<NR::Point> intersect(Line const &line);
34
 
    inline NR::Point direction () { return v_dir; }
 
31
    virtual boost::optional<Geom::Point> intersect(Line const &line);
 
32
    inline Geom::Point direction () { return v_dir; }
35
33
    
36
 
    NR::Point closest_to(NR::Point const &pt); // returns the point on the line closest to pt 
 
34
    Geom::Point closest_to(Geom::Point const &pt); // returns the point on the line closest to pt 
37
35
 
38
36
    friend inline std::ostream &operator<< (std::ostream &out_file, const Line &in_line);
39
 
    NR::Maybe<NR::Point> intersection_with_viewbox (SPDesktop *desktop);
40
 
    inline bool lie_on_same_side (NR::Point const &A, NR::Point const &B) {
 
37
    boost::optional<Geom::Point> intersection_with_viewbox (SPDesktop *desktop);
 
38
    inline bool lie_on_same_side (Geom::Point const &A, Geom::Point const &B) {
41
39
        /* If A is a point in the plane and n is the normal vector of the line then
42
40
           the sign of dot(A, n) specifies the half-plane in which A lies.
43
41
           Thus A and B lie on the same side if the dot products have equal sign. */
44
 
        return ((NR::dot(A, normal) - d0) * (NR::dot(B, normal) - d0)) > 0;
 
42
        return ((Geom::dot(A, normal) - d0) * (Geom::dot(B, normal) - d0)) > 0;
45
43
    }
46
44
 
47
 
    double lambda (NR::Point const pt);
48
 
    inline NR::Point point_from_lambda (double const lambda) { 
49
 
        return (pt + lambda * NR::unit_vector (v_dir)); }
 
45
    double lambda (Geom::Point const pt);
 
46
    inline Geom::Point point_from_lambda (double const lambda) { 
 
47
        return (pt + lambda * Geom::unit_vector (v_dir)); }
50
48
 
51
49
protected:
52
 
    void set_direction(NR::Point const &dir);
53
 
    inline static bool pts_coincide (NR::Point const pt1, NR::Point const pt2)
 
50
    void set_direction(Geom::Point const &dir);
 
51
    inline static bool pts_coincide (Geom::Point const pt1, Geom::Point const pt2)
54
52
    {
55
 
        return (NR::L2 (pt2 - pt1) < epsilon);
 
53
        return (Geom::L2 (pt2 - pt1) < epsilon);
56
54
    }
57
55
 
58
 
    NR::Point pt;
59
 
    NR::Point v_dir;
60
 
    NR::Point normal;
61
 
    NR::Coord d0;
 
56
    Geom::Point pt;
 
57
    Geom::Point v_dir;
 
58
    Geom::Point normal;
 
59
    Geom::Coord d0;
62
60
};
63
61
 
64
 
inline double determinant (NR::Point const &a, NR::Point const &b)
 
62
inline double determinant (Geom::Point const &a, Geom::Point const &b)
65
63
{
66
 
    return (a[NR::X] * b[NR::Y] - a[NR::Y] * b[NR::X]);
 
64
    return (a[Geom::X] * b[Geom::Y] - a[Geom::Y] * b[Geom::X]);
67
65
}
68
 
std::pair<double, double> coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w);
69
 
bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w);
70
 
bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt);
71
 
std::pair<NR::Point, NR::Point> side_of_intersection (NR::Point const &A, NR::Point const &B,
72
 
                                                      NR::Point const &C, NR::Point const &D,
73
 
                                                      NR::Point const &pt, NR::Point const &dir);
 
66
std::pair<double, double> coordinates (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w);
 
67
bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w);
 
68
bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt);
 
69
std::pair<Geom::Point, Geom::Point> side_of_intersection (Geom::Point const &A, Geom::Point const &B,
 
70
                                                          Geom::Point const &C, Geom::Point const &D,
 
71
                                                          Geom::Point const &pt, Geom::Point const &dir);
74
72
 
75
73
/*** For debugging purposes: Draw a knot/node of specified size and color at the given position ***/
76
 
void create_canvas_point(NR::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
 
74
void create_canvas_point(Geom::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
77
75
 
78
76
/*** For debugging purposes: Draw a line between the specified points ***/
79
 
void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba = 0xff00007f);
 
77
void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba = 0xff00007f);
80
78
 
81
79
 
82
80
/** A function to print out the Line.  It just prints out the coordinates of start point and