Code

Fixed a crash when changing blur of filtered object after duplicating it
[inkscape.git] / src / perspective-line.cpp
1 #define __PERSPECTIVE_LINE_C__
3 /*
4  * Perspective line for 3D perspectives
5  *
6  * Authors:
7  *   Maximilian Albert <Anhalter42@gmx.de>
8  *
9  * Copyright (C) 2007 authors
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
14 #include "perspective-line.h"
16 namespace Box3D {
18 PerspectiveLine::PerspectiveLine (NR::Point const &pt, PerspDir const axis, Perspective3D *perspective) :
19         Line (pt, *(perspective->get_vanishing_point(axis)), true)
20 {
21     g_assert (perspective != NULL);
23     if (perspective->get_vanishing_point(axis)->state == VP_INFINITE) {
24         this->set_direction(perspective->get_vanishing_point(axis)->v_dir);
25     }
26     this->vp_dir = axis;
27     this->persp  = perspective;
28 }
30 // This function makes sure not to return NR::Nothing()
31 // FIXME: How to gracefully handle parallel lines?
32 NR::Maybe<NR::Point> PerspectiveLine::intersect (Line const &line)
33 {
34     NR::Maybe<NR::Point> pt = this->Line::intersect(line);
35     if (!pt) {
36         Box3D::VanishingPoint vp = *(persp->get_vanishing_point(vp_dir));
37         if (vp.state == VP_INFINITE) {
38             pt = vp;
39         } else {
40             pt = NR::Point (0.0, 0.0); // FIXME: Better solution needed
41         }
42     }
43     return pt; 
44 }
46 // FIXME: Do we really need two intersection methods?
47 NR::Point PerspectiveLine::meet(Line const &line)
48 {
49     return *intersect(line); // works since intersect() does not return NR::Nothing()
50 }
52 } // namespace Box3D 
53  
54 /*
55   Local Variables:
56   mode:c++
57   c-file-style:"stroustrup"
58   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
59   indent-tabs-mode:nil
60   fill-column:99
61   End:
62 */
63 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :