* scribo/filter/object_links_non_aligned_simple.hh: Handle new cases. * scribo/filter/object_links_left_aligned.hh, * scribo/filter/object_links_right_aligned.hh: New filters. --- scribo/ChangeLog | 10 +++++ ...top_aligned.hh => object_links_left_aligned.hh} | 33 +++++++++--------- scribo/filter/object_links_non_aligned_simple.hh | 36 ++++++++++++++++++++ ...op_aligned.hh => object_links_right_aligned.hh} | 30 ++++++++-------- 4 files changed, 78 insertions(+), 31 deletions(-) copy scribo/filter/{object_links_top_aligned.hh => object_links_left_aligned.hh} (76%) copy scribo/filter/{object_links_top_aligned.hh => object_links_right_aligned.hh} (77%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 45faa9f..01ab3a1 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,15 @@ 2010-02-19 Guillaume Lazzara <z@lrde.epita.fr> + Add new link filters. + + * scribo/filter/object_links_non_aligned_simple.hh: Handle new + cases. + + * scribo/filter/object_links_left_aligned.hh, + * scribo/filter/object_links_right_aligned.hh: New filters. + +2010-02-19 Guillaume Lazzara <z@lrde.epita.fr> + Improve object linking backend. * scribo/primitive/internal/find_left_link.hh, diff --git a/scribo/filter/object_links_top_aligned.hh b/scribo/filter/object_links_left_aligned.hh similarity index 76% copy from scribo/filter/object_links_top_aligned.hh copy to scribo/filter/object_links_left_aligned.hh index 4a92c96..e69b110 100644 --- a/scribo/filter/object_links_top_aligned.hh +++ b/scribo/filter/object_links_left_aligned.hh @@ -23,14 +23,15 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_FILTER_OBJECT_LINKS_TOP_ALIGNED_HH -# define SCRIBO_FILTER_OBJECT_LINKS_TOP_ALIGNED_HH +#ifndef SCRIBO_FILTER_OBJECT_LINKS_LEFT_ALIGNED_HH +# define SCRIBO_FILTER_OBJECT_LINKS_LEFT_ALIGNED_HH /// \file /// -/// Invalidate links between two objects if their top are not +/// Invalidate links between two objects if their left are not /// aligned. - +/// +/// \fixme UPDATE DOC! # include <mln/util/array.hh> @@ -48,7 +49,7 @@ namespace scribo using namespace mln; - /*! \brief Invalidate links between two objects if their top are not + /*! \brief Invalidate links between two objects if their left are not aligned. \param[in] objects An object image. @@ -77,13 +78,13 @@ namespace scribo \endverbatim - The angle between the two tops must be lower than \p max_alpha. + The angle between the two lefts must be lower than \p max_alpha. */ template <typename L> object_links<L> - object_links_top_aligned(const object_image(L)& objects, - const object_links<L>& links, - float max_alpha); + object_links_left_aligned(const object_image(L)& objects, + const object_links<L>& links, + float max_alpha); # ifndef MLN_INCLUDE_ONLY @@ -91,21 +92,21 @@ namespace scribo template <typename L> object_links<L> - object_links_top_aligned(const object_image(L)& objects, - const object_links<L>& links, - float max_alpha) + object_links_left_aligned(const object_image(L)& objects, + const object_links<L>& links, + float max_alpha) { - trace::entering("scribo::filter::object_links_top_aligned"); + trace::entering("scribo::filter::object_links_left_aligned"); mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); object_links<L> output = object_links_non_aligned_simple(objects, links, - 1, + 3, max_alpha); - trace::exiting("scribo::filter::object_links_top_aligned"); + trace::exiting("scribo::filter::object_links_left_aligned"); return output; } @@ -118,4 +119,4 @@ namespace scribo } // end of namespace scribo -#endif // ! SCRIBO_FILTER_OBJECT_LINKS_TOP_ALIGNED_HH +#endif // ! SCRIBO_FILTER_OBJECT_LINKS_LEFT_ALIGNED_HH diff --git a/scribo/filter/object_links_non_aligned_simple.hh b/scribo/filter/object_links_non_aligned_simple.hh index 706497d..15be8e9 100644 --- a/scribo/filter/object_links_non_aligned_simple.hh +++ b/scribo/filter/object_links_non_aligned_simple.hh @@ -84,6 +84,8 @@ namespace scribo 0 = center 1 = top 2 = bottom + 3 = left + 4 = right */ template <typename L> @@ -166,6 +168,40 @@ namespace scribo } } } + // Left + else if (edge == 3) + { + for_all_components(i, objects.bboxes()) + { + if (links[i] != i) + { + dr = math::abs(bboxes[i].center().row() + - bboxes[links[i]].center().row()); + dc = math::abs(bboxes[i].pmin().col() + - bboxes[links[i]].pmin().col()); + + if (std::atan(dc / dr) > max_alpha_rad) + output[i] = i; + } + } + } + // Right + else if (edge == 4) + { + for_all_components(i, objects.bboxes()) + { + if (links[i] != i) + { + dr = math::abs(bboxes[i].center().row() + - bboxes[links[i]].center().row()); + dc = math::abs(bboxes[i].pmax().col() + - bboxes[links[i]].pmax().col()); + + if (std::atan(dc / dr) > max_alpha_rad) + output[i] = i; + } + } + } else { trace::warning("Invalid edge value... Aborting computation."); diff --git a/scribo/filter/object_links_top_aligned.hh b/scribo/filter/object_links_right_aligned.hh similarity index 77% copy from scribo/filter/object_links_top_aligned.hh copy to scribo/filter/object_links_right_aligned.hh index 4a92c96..2ee0280 100644 --- a/scribo/filter/object_links_top_aligned.hh +++ b/scribo/filter/object_links_right_aligned.hh @@ -23,12 +23,12 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_FILTER_OBJECT_LINKS_TOP_ALIGNED_HH -# define SCRIBO_FILTER_OBJECT_LINKS_TOP_ALIGNED_HH +#ifndef SCRIBO_FILTER_OBJECT_LINKS_RIGHT_ALIGNED_HH +# define SCRIBO_FILTER_OBJECT_LINKS_RIGHT_ALIGNED_HH /// \file /// -/// Invalidate links between two objects if their top are not +/// Invalidate links between two objects if their right are not /// aligned. @@ -48,7 +48,7 @@ namespace scribo using namespace mln; - /*! \brief Invalidate links between two objects if their top are not + /*! \brief Invalidate links between two objects if their right are not aligned. \param[in] objects An object image. @@ -77,13 +77,13 @@ namespace scribo \endverbatim - The angle between the two tops must be lower than \p max_alpha. + The angle between the two rights must be lower than \p max_alpha. */ template <typename L> object_links<L> - object_links_top_aligned(const object_image(L)& objects, - const object_links<L>& links, - float max_alpha); + object_links_right_aligned(const object_image(L)& objects, + const object_links<L>& links, + float max_alpha); # ifndef MLN_INCLUDE_ONLY @@ -91,21 +91,21 @@ namespace scribo template <typename L> object_links<L> - object_links_top_aligned(const object_image(L)& objects, - const object_links<L>& links, - float max_alpha) + object_links_right_aligned(const object_image(L)& objects, + const object_links<L>& links, + float max_alpha) { - trace::entering("scribo::filter::object_links_top_aligned"); + trace::entering("scribo::filter::object_links_right_aligned"); mln_precondition(objects.is_valid()); mln_precondition(links.is_valid()); object_links<L> output = object_links_non_aligned_simple(objects, links, - 1, + 4, max_alpha); - trace::exiting("scribo::filter::object_links_top_aligned"); + trace::exiting("scribo::filter::object_links_right_aligned"); return output; } @@ -118,4 +118,4 @@ namespace scribo } // end of namespace scribo -#endif // ! SCRIBO_FILTER_OBJECT_LINKS_TOP_ALIGNED_HH +#endif // ! SCRIBO_FILTER_OBJECT_LINKS_RIGHT_ALIGNED_HH -- 1.5.6.5
participants (1)
-
Guillaume Lazzara