index b2e4d23402666a52c3ed27909a56024183f8a130..3e7d96fdd187fd28f6828b279de8b319472957e5 100644 (file)
--- a/src/perspective-line.cpp
+++ b/src/perspective-line.cpp
*/
#include "perspective-line.h"
+#include "persp3d.h"
namespace Box3D {
-PerspectiveLine::PerspectiveLine (NR::Point const &pt, PerspDir const axis, Perspective3D *perspective) :
- Line (pt, *(perspective->get_vanishing_point(axis)), true)
+PerspectiveLine::PerspectiveLine (Geom::Point const &pt, Proj::Axis const axis, Persp3D *persp) :
+ Line (pt, persp3d_get_VP(persp, axis).affine(), true)
{
- g_assert (perspective != NULL);
+ g_assert (persp != NULL);
- if (perspective->get_vanishing_point(axis)->state == VP_INFINITE) {
- this->set_direction(perspective->get_vanishing_point(axis)->v_dir);
+ if (!persp3d_get_VP(persp, axis).is_finite()) {
+ Proj::Pt2 vp(persp3d_get_VP(persp, axis));
+ this->set_direction(Geom::Point(vp[Proj::X], vp[Proj::Y]));
}
this->vp_dir = axis;
- this->persp = perspective;
-}
-
-// This function makes sure not to return NR::Nothing()
-// FIXME: How to gracefully handle parallel lines?
-NR::Maybe<NR::Point> PerspectiveLine::intersect (Line const &line)
-{
- NR::Maybe<NR::Point> pt = this->Line::intersect(line);
- if (!pt) {
- Box3D::VanishingPoint vp = *(persp->get_vanishing_point(vp_dir));
- if (vp.state == VP_INFINITE) {
- pt = vp;
- } else {
- pt = NR::Point (0.0, 0.0); // FIXME: Better solution needed
- }
- }
- return pt;
-}
-
-// FIXME: Do we really need two intersection methods?
-NR::Point PerspectiveLine::meet(Line const &line)
-{
- return *intersect(line); // works since intersect() does not return NR::Nothing()
+ this->persp = persp;
}
} // namespace Box3D