* mln/world/k2/fill_non_primary_from_primary_2_faces.hh,
* mln/world/kn/fill_0_from_1_faces.hh,
* mln/world/kn/fill_0_from_2_faces.hh,
* mln/world/kn/fill_1_from_2_faces.hh,
* mln/world/kn/fill_1_from_aux_2_faces.hh,
* mln/world/kn/fill_2_from_1_faces.hh: Check if neighbor site is
in the domain.
---
milena/ChangeLog | 12 +++++++
.../k2/fill_non_primary_from_primary_2_faces.hh | 34 +++++++++++++-------
milena/mln/world/kn/fill_0_from_1_faces.hh | 15 ++++++---
milena/mln/world/kn/fill_0_from_2_faces.hh | 15 ++++++---
milena/mln/world/kn/fill_1_from_2_faces.hh | 17 ++++++---
milena/mln/world/kn/fill_1_from_aux_2_faces.hh | 17 ++++++---
milena/mln/world/kn/fill_2_from_1_faces.hh | 15 ++++++---
7 files changed, 86 insertions(+), 39 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 3b898e8..d7d8e1e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2012-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Do not read outside images in fill functions with accumulators.
+
+ * mln/world/k2/fill_non_primary_from_primary_2_faces.hh,
+ * mln/world/kn/fill_0_from_1_faces.hh,
+ * mln/world/kn/fill_0_from_2_faces.hh,
+ * mln/world/kn/fill_1_from_2_faces.hh,
+ * mln/world/kn/fill_1_from_aux_2_faces.hh,
+ * mln/world/kn/fill_2_from_1_faces.hh: Check if neighbor site is
+ in the domain.
+
+2012-10-26 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Various fixes.
* mln/util/hqueue.hh: Add a precondition.
diff --git a/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh
b/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh
index b97a645..8bf7f84 100644
--- a/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh
+++ b/milena/mln/world/k2/fill_non_primary_from_primary_2_faces.hh
@@ -155,31 +155,41 @@ namespace mln
I& ima = exact(ima_);
A accu = exact(accu_);
+ typedef mln_value(I) VI;
typedef mln_argument(A) V;
- mln_piter(I) p(ima.domain());
+ mln_box(I) b = ima.domain();
+ mln_piter(I) p(b);
for_all(p)
if (is_non_primary_2_face_vertical(p))
{
accu.init();
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * left)));
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * right)));
- ima(p) = kn::safe_cast(accu.to_result());
+ if (ima.domain().has(p + 2 * left))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * left)));
+ if (ima.domain().has(p + 2 * right))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * right)));
+ ima(p) = kn::safe_cast_to<VI>(accu.to_result());
}
else if (is_non_primary_2_face_horizontal(p))
{
accu.init();
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * up)));
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * down)));
- ima(p) = kn::safe_cast(accu.to_result());
+ if (ima.domain().has(p + 2 * up))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * up)));
+ if (ima.domain().has(p + 2 * down))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * down)));
+ ima(p) = kn::safe_cast_to<VI>(accu.to_result());
}
else if (is_non_primary_2_face_center(p))
{
accu.init();
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * up_left)));
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * up_right)));
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * down_left)));
- accu.take(kn::safe_cast_to<V>(ima(p + 2 * down_right)));
- ima(p) = kn::safe_cast(accu.to_result());
+ if (ima.domain().has(p + 2 * up_left))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * up_left)));
+ if (ima.domain().has(p + 2 * up_right))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * up_right)));
+ if (ima.domain().has(p + 2 * down_left))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * down_left)));
+ if (ima.domain().has(p + 2 * down_right))
+ accu.take(kn::safe_cast_to<V>(ima(p + 2 * down_right)));
+ ima(p) = kn::safe_cast_to<VI>(accu.to_result());
}
trace::exiting("mln::world::k2::fill_non_primary_from_primary_2_faces");
diff --git a/milena/mln/world/kn/fill_0_from_1_faces.hh
b/milena/mln/world/kn/fill_0_from_1_faces.hh
index 43b5096..3d1548d 100644
--- a/milena/mln/world/kn/fill_0_from_1_faces.hh
+++ b/milena/mln/world/kn/fill_0_from_1_faces.hh
@@ -87,15 +87,20 @@ namespace mln
(void) accu_;
A accu = A();
- mln_piter(I) p(inout.domain());
+ mln_box(I) b = inout.domain();
+ mln_piter(I) p(b);
for_all(p)
if (is_0_face(p))
{
accu.init();
- accu.take(inout(p + left));
- accu.take(inout(p + right));
- accu.take(inout(p + up));
- accu.take(inout(p + down));
+ if (inout.domain().has(p + left))
+ accu.take(inout(p + left));
+ if (inout.domain().has(p + right))
+ accu.take(inout(p + right));
+ if (inout.domain().has(p + up))
+ accu.take(inout(p + up));
+ if (inout.domain().has(p + down))
+ accu.take(inout(p + down));
inout(p) = accu.to_result();
}
diff --git a/milena/mln/world/kn/fill_0_from_2_faces.hh
b/milena/mln/world/kn/fill_0_from_2_faces.hh
index 47fb230..798bed3 100644
--- a/milena/mln/world/kn/fill_0_from_2_faces.hh
+++ b/milena/mln/world/kn/fill_0_from_2_faces.hh
@@ -100,15 +100,20 @@ namespace mln
(void) accu_;
A accu = A();
- mln_piter(I) p(inout.domain());
+ mln_box(I) b = inout.domain();
+ mln_piter(I) p(b);
for_all(p)
if (kn::is_0_face(p))
{
accu.init();
- accu.take(inout(p + up_left));
- accu.take(inout(p + up_right));
- accu.take(inout(p + down_left));
- accu.take(inout(p + down_right));
+ if (inout.domain().has(p + up_left))
+ accu.take(inout(p + up_left));
+ if (inout.domain().has(p + up_right))
+ accu.take(inout(p + up_right));
+ if (inout.domain().has(p + down_left))
+ accu.take(inout(p + down_left));
+ if (inout.domain().has(p + down_right))
+ accu.take(inout(p + down_right));
inout(p) = accu.to_result();
}
diff --git a/milena/mln/world/kn/fill_1_from_2_faces.hh
b/milena/mln/world/kn/fill_1_from_2_faces.hh
index b638e81..3a8b93c 100644
--- a/milena/mln/world/kn/fill_1_from_2_faces.hh
+++ b/milena/mln/world/kn/fill_1_from_2_faces.hh
@@ -73,7 +73,7 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- // Facade
+ // Facades
template <typename I, typename A>
@@ -86,20 +86,25 @@ namespace mln
(void) accu_;
A accu = A();
- mln_piter(I) p(inout.domain());
+ mln_box(I) b = inout.domain();
+ mln_piter(I) p(b);
for_all(p)
if (kn::is_1_face_vertical(p))
{
accu.init();
- accu.take(inout(p + left));
- accu.take(inout(p + right));
+ if (inout.domain().has(p + left))
+ accu.take(inout(p + left));
+ if (inout.domain().has(p + right))
+ accu.take(inout(p + right));
inout(p) = accu.to_result();
}
else if (is_1_face_horizontal(p))
{
accu.init();
- accu.take(inout(p + up));
- accu.take(inout(p + down));
+ if (inout.domain().has(p + up))
+ accu.take(inout(p + up));
+ if (inout.domain().has(p + down))
+ accu.take(inout(p + down));
inout(p) = accu.to_result();
}
diff --git a/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
b/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
index eb999cf..b9cbffe 100644
--- a/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
+++ b/milena/mln/world/kn/fill_1_from_aux_2_faces.hh
@@ -76,7 +76,7 @@ namespace mln
/// \overload
template <typename I, typename J, typename A>
void fill_1_from_aux_2_faces(Image<I>& inout, const Image<J>&
aux,
- const Accumulator<A>& accu);
+ const Accumulator<A>& accu);
# ifndef MLN_INCLUDE_ONLY
@@ -123,20 +123,25 @@ namespace mln
(void) accu_;
A accu = A();
- mln_piter(I) p(inout.domain());
+ mln_box(I) b = inout.domain();
+ mln_piter(I) p(b);
for_all(p)
if (kn::is_1_face_vertical(p))
{
accu.init();
- accu.take(aux(p + left));
- accu.take(aux(p + right));
+ if (aux.domain().has(p + left))
+ accu.take(aux(p + left));
+ if (aux.domain().has(p + right))
+ accu.take(aux(p + right));
inout(p) = accu.to_result();
}
else if (kn::is_1_face_horizontal(p))
{
accu.init();
- accu.take(aux(p + up));
- accu.take(aux(p + down));
+ if (aux.domain().has(p + up))
+ accu.take(aux(p + up));
+ if (aux.domain().has(p + down))
+ accu.take(aux(p + down));
inout(p) = accu.to_result();
}
diff --git a/milena/mln/world/kn/fill_2_from_1_faces.hh
b/milena/mln/world/kn/fill_2_from_1_faces.hh
index 5887572..f3c7c7e 100644
--- a/milena/mln/world/kn/fill_2_from_1_faces.hh
+++ b/milena/mln/world/kn/fill_2_from_1_faces.hh
@@ -100,15 +100,20 @@ namespace mln
(void) accu_;
A accu = A();
- mln_piter(I) p(inout.domain());
+ mln_box(I) b = inout.domain();
+ mln_piter(I) p(b);
for_all(p)
if (kn::is_2_face(p))
{
accu.init();
- accu.take(inout(p + up));
- accu.take(inout(p + left));
- accu.take(inout(p + right));
- accu.take(inout(p + down));
+ if (inout.domain().has(p + up))
+ accu.take(inout(p + up));
+ if (inout.domain().has(p + left))
+ accu.take(inout(p + left));
+ if (inout.domain().has(p + right))
+ accu.take(inout(p + right));
+ if (inout.domain().has(p + down))
+ accu.take(inout(p + down));
inout(p) = accu.to_result();
}
--
1.7.2.5
Show replies by date