Code

Filter effects dialog:
[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, Box3D::Axis const axis, Perspective3D *perspective) :
19         Line (pt, *(perspective->get_vanishing_point(axis)), true)
20 {
21     g_assert (perspective != NULL);
22     g_assert (Box3D::is_single_axis_direction (axis));
24     if (perspective->get_vanishing_point(axis)->state == VP_INFINITE) {
25         this->set_direction(perspective->get_vanishing_point(axis)->v_dir);
26     }
27     this->vp_dir = axis;
28     this->persp  = perspective;
29 }
31 // This function makes sure not to return NR::Nothing()
32 // FIXME: How to gracefully handle parallel lines?
33 NR::Maybe<NR::Point> PerspectiveLine::intersect (Line const &line)
34 {
35     NR::Maybe<NR::Point> pt = this->Line::intersect(line);
36     if (!pt) {
37         Box3D::VanishingPoint vp = *(persp->get_vanishing_point(vp_dir));
38         if (vp.state == VP_INFINITE) {
39             pt = vp;
40         } else {
41             pt = NR::Point (0.0, 0.0); // FIXME: Better solution needed
42         }
43     }
44     return pt; 
45 }
47 // FIXME: Do we really need two intersection methods?
48 NR::Point PerspectiveLine::meet(Line const &line)
49 {
50     return *intersect(line); // works since intersect() does not return NR::Nothing()
51 }
53 } // namespace Box3D 
54  
55 /*
56   Local Variables:
57   mode:c++
58   c-file-style:"stroustrup"
59   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
60   indent-tabs-mode:nil
61   fill-column:99
62   End:
63 */
64 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :