* scribo/core/paragraph_info.hh: Here.
* scribo/core/tag/paragraph.hh: Introduce paragraph tags.
---
scribo/ChangeLog | 9 ++++++
scribo/scribo/core/paragraph_info.hh | 52 +++++++++++++++++++++++++++++----
scribo/scribo/core/tag/paragraph.hh | 14 +++++++++
3 files changed, 68 insertions(+), 7 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 450c4d5..dd7baec 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,14 @@
2011-06-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add support for tags in paragraph_info.
+
+ * scribo/core/paragraph_info.hh: Here.
+
+ * scribo/core/tag/paragraph.hh: Introduce paragraph tags.
+
+
+2011-06-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Improve output cleanup for historical document toolchain.
* scribo/filter/paragraphs_in_borders.hh,
diff --git a/scribo/scribo/core/paragraph_info.hh b/scribo/scribo/core/paragraph_info.hh
index 90db7da..1029913 100644
--- a/scribo/scribo/core/paragraph_info.hh
+++ b/scribo/scribo/core/paragraph_info.hh
@@ -28,6 +28,7 @@
# include <scribo/core/line_info.hh>
# include <scribo/core/line_links.hh>
+# include <scribo/core/tag/paragraph.hh>
# include <mln/util/array.hh>
# include <mln/accu/shape/bbox.hh>
@@ -79,6 +80,11 @@ namespace scribo
void set_delta_baseline(const int delta_baseline);
int delta_baseline() const;
+ void fast_merge(paragraph_info<L>& info);
+
+ void update_tag(paragraph::Tag tag);
+ paragraph::Tag tag() const;
+
private:
mln::util::array<line_id_t> line_ids_;
mln::accu::shape::bbox<mln_site(L)> bbox_;
@@ -88,7 +94,7 @@ namespace scribo
float color_reliability_;
int delta_baseline_;
- bool needs_stats_update_;
+ paragraph::Tag tag_;
bool is_valid_;
};
@@ -103,13 +109,13 @@ namespace scribo
template <typename L>
paragraph_info<L>::paragraph_info()
- : needs_stats_update_(false), is_valid_(false)
+ : tag_(paragraph::None), is_valid_(false)
{
}
template <typename L>
paragraph_info<L>::paragraph_info(const line_links<L>& llinks)
- : llinks_(llinks), needs_stats_update_(false), is_valid_(true)
+ : llinks_(llinks), tag_(paragraph::None), is_valid_(true)
{
}
@@ -121,7 +127,7 @@ namespace scribo
bbox_.take(line.bbox());
// More data may need to be updated!
- needs_stats_update_ = true;
+ tag_ = paragraph::Needs_Precise_Stats_Update;
}
template <typename L>
@@ -206,14 +212,14 @@ namespace scribo
bool
paragraph_info<L>::needs_stats_update() const
{
- return needs_stats_update_;
+ return tag_ == paragraph::Needs_Precise_Stats_Update;
}
template <typename L>
void
paragraph_info<L>::force_stats_update()
{
- if (!needs_stats_update_)
+ if (!needs_stats_update())
return;
const line_set<L>& lines = llinks_.lines();
@@ -259,7 +265,7 @@ namespace scribo
// FIXME: Update paragraph stats
- needs_stats_update_ = false;
+ tag_ = paragraph::None;
}
template <typename L>
@@ -277,6 +283,38 @@ namespace scribo
}
template <typename L>
+ void
+ paragraph_info<L>::fast_merge(paragraph_info<L>& other)
+ {
+ tag_ = paragraph::Needs_Precise_Stats_Update;
+ other.update_tag(paragraph::Merged);
+ other.invalidate();
+
+ // Merge bboxes.
+ bbox_.take(other.bbox());
+
+ // Update delta_baseline
+ // FIXME: delta base line should be updated correctly!!
+ set_delta_baseline(std::max(other.delta_baseline_, delta_baseline_));
+
+ line_ids_.append(other.line_ids());
+ }
+
+ template <typename L>
+ void
+ paragraph_info<L>::update_tag(paragraph::Tag tag)
+ {
+ tag_ = tag;
+ }
+
+ template <typename L>
+ paragraph::Tag
+ paragraph_info<L>::tag() const
+ {
+ return tag_;
+ }
+
+ template <typename L>
bool
operator==(const paragraph_info<L>& lhs, const paragraph_info<L>&
rhs)
{
diff --git a/scribo/scribo/core/tag/paragraph.hh b/scribo/scribo/core/tag/paragraph.hh
index 14dd579..9a11a45 100644
--- a/scribo/scribo/core/tag/paragraph.hh
+++ b/scribo/scribo/core/tag/paragraph.hh
@@ -36,6 +36,20 @@ namespace scribo
// Paragraph id tag.
struct ParagraphId;
+ namespace paragraph
+ {
+
+
+ enum Tag
+ {
+ None = 0,
+ Needs_Precise_Stats_Update,
+ Merged
+ };
+
+
+ } // end of namespace scribo::paragraph
+
} // end of namespace scribo
--
1.5.6.5
Show replies by date