Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
October 2008
- 14 participants
- 373 discussions
URL: https://svn.lrde.epita.fr/svn/scool/branches/scool-ng
ChangeLog:
2008-10-17 Maxime van Noppen <yabo(a)lrde.epita.fr>
Handle C++ const methods
* cxx-syn/CxxFun.sdf: Add a grammar rule to produce const methods.
* cxx-syn/Lexical.sdf: Add the "const" keyword.
* scl-syn/Declaration.sdf: Remove useless commented code.
* scl-syn/Lexical.sdf: Cleanup keywords.
cxx-syn/CxxFun.sdf | 3 +++
cxx-syn/Lexical.sdf | 2 ++
scl-syn/Declaration.sdf | 1 -
scl-syn/Lexical.sdf | 13 +++++++------
4 files changed, 12 insertions(+), 7 deletions(-)
Index: branches/scool-ng/src/scl-syn/Declaration.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Declaration.sdf (revision 118)
+++ branches/scool-ng/src/scl-syn/Declaration.sdf (revision 119)
@@ -25,7 +25,6 @@
FunctionQualifier? Identifier ":" FunctionType ";" -> Declaration {cons("FunctionDeclaration")}
FunctionQualifier? Identifier ":" FunctionType "=" FunctionBlock -> Declaration {cons("FunctionDefinition")}
-%% FunctionQualifier? Identifier ":" FunctionType "=>" Expression ";" -> Declaration {cons("FunctionDefinition")}
Identifier ":" ParametersDeclaration "->" "type" "=" StaticBlock -> StaticFunction {cons("StaticTypeFunction")}
ClassQualifier? Identifier ":" ParametersDeclaration "->" "class" "=" StaticClassBlock -> StaticFunction {cons("StaticClassFunction")}
Index: branches/scool-ng/src/scl-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/scl-syn/Lexical.sdf (revision 118)
+++ branches/scool-ng/src/scl-syn/Lexical.sdf (revision 119)
@@ -29,17 +29,18 @@
"var" -> SimpleQualifier
"final" -> ClassQualifier
+ "abtract" -> ClassQualifier
"models" -> TypeQualifier
+ "abtract" -> FunctionQualifier
+ "mutable" -> FunctionQualifier
- "decl" -> FunctionQualifier
- "abtract" -> MethodQualifier
-
+ SimpleQualifier -> Keyword
+ ClassQualifier -> Keyword
+ TypeQualifier -> Keyword
+ FunctionQualifier -> Keyword
"class" -> Keyword
"concept" -> Keyword
- "var" -> Keyword
- "final" -> Keyword
- "models" -> Keyword
"type" -> Keyword
"ref" -> Keyword
"public" -> Keyword
Index: branches/scool-ng/src/cxx-syn/CxxFun.sdf
===================================================================
--- branches/scool-ng/src/cxx-syn/CxxFun.sdf (revision 118)
+++ branches/scool-ng/src/cxx-syn/CxxFun.sdf (revision 119)
@@ -17,6 +17,9 @@
"template" "<" {(CxxType CxxId) ","}* ">"
CxxType CxxId "(" {(CxxType CxxId) ","}* ")" ";" -> CxxTopLevel {cons("CxxFun")}
+ "template" "<" {(CxxType CxxId) ","}* ">"
+ CxxType CxxId "(" {(CxxType CxxId) ","}* ")" Const? ";" -> CxxTopLevel {cons("CxxFun")}
+
CxxId ("<" {CxxType ","}* ">")? "(" {(CxxType CxxId) ","}* ")" ";" -> CxxTopLevel {cons("CxxFunCall")}
CxxDecl -> CxxTopLevel
Index: branches/scool-ng/src/cxx-syn/Lexical.sdf
===================================================================
--- branches/scool-ng/src/cxx-syn/Lexical.sdf (revision 118)
+++ branches/scool-ng/src/cxx-syn/Lexical.sdf (revision 119)
@@ -11,6 +11,8 @@
"public" -> CxxAccessModifier
"protected" -> CxxAccessModifier
+
context-free syntax
CxxId -> CxxId {cons("CxxId")}
CxxType "::" CxxId -> CxxId {cons("CxxScope")}
+ "const" -> Const {cons("Const")}
--
\__/ \__/
(00) Maxime `yabo` van Noppen (00)
___) \ Epita 2009 / (___
(_____/ \_____)
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix some morpho operators.
* milena/tests/morpho/erosion.cc: Fix typo.
* milena/mln/core/routine/ops.hh (todo): New.
* milena/mln/morpho/erosion.spe.hh (octagon2d): Fix.
(hline2d, vline2d): Fix dispatch.
mln/core/routine/ops.hh | 8 +++
mln/morpho/erosion.spe.hh | 97 +++++++++++++++++++++++++++++++++++++---------
tests/morpho/erosion.cc | 8 +--
3 files changed, 91 insertions(+), 22 deletions(-)
Index: milena/tests/morpho/erosion.cc
--- milena/tests/morpho/erosion.cc (revision 2587)
+++ milena/tests/morpho/erosion.cc (working copy)
@@ -194,20 +194,20 @@
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
}
- std::cout << "-------------------------- Octogone: " << std::endl;
+ std::cout << "-------------------------- Octagon: " << std::endl;
- //Octogone
+ // Octagon
{
t.start();
ref = morpho::impl::generic::erosion_on_function(lena, oct);
- std::cout << "generic on octogone: " << t << std::endl;
+ std::cout << "generic on octagon: " << t << std::endl;
io::pgm::save(ref, "out_oct_ref.pgm");
}
{
t.start();
out = morpho::erosion(lena, oct);
- std::cout << "dispach on octogone: " << t << std::endl;
+ std::cout << "dispach on octagon: " << t << std::endl;
bool test = out == ref;
mln_assertion(test);
std::cout << " " << (test ? "OK" : "KO!!!") << std::endl;
Index: milena/mln/core/routine/ops.hh
--- milena/mln/core/routine/ops.hh (revision 2587)
+++ milena/mln/core/routine/ops.hh (working copy)
@@ -78,6 +78,14 @@
* \endcode
*
* \todo Complete those definitions (...) + Overload for const (?)
+ *
+ * \todo Optimize deduced ops to eliminate object creation. E.g.
+ * in the unary minus op:
+ * literal::zero_t* p_zero = 0;
+ * return O(*p_zero) - exact(rhs);
+ * can become:
+ * static O zero =...
+ * return zero - exact(rhs);
*/
# include <mln/trait/op/all.hh>
Index: milena/mln/morpho/erosion.spe.hh
--- milena/mln/morpho/erosion.spe.hh (revision 2587)
+++ milena/mln/morpho/erosion.spe.hh (working copy)
@@ -302,9 +302,8 @@
mln_concrete(I) temp_1, temp_2, output;
temp_1 = morpho::erosion(input, win::hline2d(len));
- temp_2 = morpho::erosion(temp_1, win::vline2d(len));
- temp_1 = morpho::erosion(temp_2, win::diag2d(len));
- output = morpho::erosion(temp_1, win::backdiag2d(len));
+ temp_2 = morpho::erosion(temp_1, win::diag2d(len));
+ output = morpho::erosion(temp_2, win::backdiag2d(len));
trace::exiting("morpho::impl::erosion_(win::octagon2d)");
return output;
@@ -683,16 +682,16 @@
min.init();
p[dir]--;
mln_qiter(W) q(win, p);
- for_all(q)
+ for_all(q) if (input.has(q))
min.take(input(q));
p[dir]++;
}
void next()
{
- for_all(q_l)
+ for_all(q_l) if (input.has(q_l))
min.untake(input(q_l));
- for_all(q_r)
+ for_all(q_r) if (input.has(q_r))
min.take(input(q_r));
output(p) = min;
}
@@ -735,13 +734,9 @@
enum { dim = I::site::dim };
unsigned dir;
- window2d
- win_left,
- win_right;
+ window2d win_left, win_right;
- mln_qixter(const I, window2d)
- q_l,
- q_r;
+ mln_qixter(const I, window2d) q_l, q_r;
erosion_directional_nd_fastest_functor(const I& input, const W& win, unsigned dir)
: input(input),
@@ -984,27 +979,93 @@
}
+ /// Handling win::hline2d.
+ /// \{
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_dispatch_wrt_win(metal::true_,
+ const I& input, const win::hline2d& win)
+ {
+ return erosion_dispatch_for_directional(input, win, 1);
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_dispatch_wrt_win(metal::false_,
+ const I& input, const win::hline2d& win)
+ {
+ return erosion_dispatch_for_generic(input, win);
+ }
+
template <typename I>
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::hline2d& win)
{
- if (win.size() <= 3)
+ if (win.size() == 1)
+ return clone(input);
+ else if (win.size() == 3)
return erosion_dispatch_for_generic(input, win);
else
- return impl::erosion_line_on_function(input, win);
-// return erosion_dispatch_for_directional(input, win, 1);
+ {
+ typedef mlc_is_not(mln_trait_image_kind(I),
+ mln::trait::image::kind::logic) test_not_logic;
+ typedef mlc_is_a(mln_pset(I), Box) test_box;
+ typedef mlc_equal(mln_trait_image_quant(I),
+ mln::trait::image::quant::low) test_lowq;
+ typedef mlc_and(test_not_logic, test_box) temp;
+ typedef mlc_and(temp, test_lowq) tests;
+ return erosion_dispatch_wrt_win(typename tests::eval (),
+ input, win);
+ }
+ }
+
+ /// \}
+
+
+
+ /// Handling win::vline2d.
+ /// \{
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_dispatch_wrt_win(metal::true_,
+ const I& input, const win::vline2d& win)
+ {
+ return erosion_dispatch_for_directional(input, win, 0);
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_dispatch_wrt_win(metal::false_,
+ const I& input, const win::vline2d& win)
+ {
+ return erosion_dispatch_for_generic(input, win);
}
template <typename I>
mln_concrete(I)
erosion_dispatch_wrt_win(const I& input, const win::vline2d& win)
{
- if (win.size() <= 3)
+ if (win.size() == 1)
+ return clone(input);
+ else if (win.size() == 3)
return erosion_dispatch_for_generic(input, win);
else
- return impl::erosion_line_on_function(input, win);
-// return erosion_dispatch_for_directional(input, win, 0);
+ {
+ typedef mlc_is_not(mln_trait_image_kind(I),
+ mln::trait::image::kind::logic) test_not_logic;
+ typedef mlc_is_a(mln_pset(I), Box) test_box;
+ typedef mlc_equal(mln_trait_image_quant(I),
+ mln::trait::image::quant::low) test_lowq;
+ typedef mlc_and(test_not_logic, test_box) temp;
+ typedef mlc_and(temp, test_lowq) tests;
+ return erosion_dispatch_wrt_win(typename tests::eval (),
+ input, win);
}
+ }
+
+ /// \}
// The dispatch entry point.
1
0
16 Oct '08
---
ChangeLog | 4 ++++
configure.ac | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e039de5..93d7d20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-15 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * configure.ac: Configure milena/tests/io/off/Makefile.
+
2008-16-07 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix ambiguous namespaces.
diff --git a/configure.ac b/configure.ac
index c6dcd24..9ad3ce7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -191,6 +191,7 @@ AC_CONFIG_FILES([
milena/tests/histo/Makefile
milena/tests/io/Makefile
milena/tests/io/fits/Makefile
+ milena/tests/io/off/Makefile
milena/tests/io/pbm/Makefile
milena/tests/io/pfm/Makefile
milena/tests/io/pgm/Makefile
--
1.6.0.1
1
0
16 Oct '08
* tests/io/Makefile.am (SUBDIRS): Add io.
* tests/io/off/: New directory.
* tests/io/off/load_bin.cc: New.
* tests/io/off/Makefile.am: New.
---
milena/ChangeLog | 9 +++++
milena/tests/io/Makefile.am | 1 +
milena/tests/io/{ => off}/Makefile.am | 13 +++----
milena/tests/io/off/load_bin.cc | 64 +++++++++++++++++++++++++++++++++
4 files changed, 80 insertions(+), 7 deletions(-)
copy milena/tests/io/{ => off}/Makefile.am (56%)
create mode 100644 milena/tests/io/off/load_bin.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 546bec0..d8b0307 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Exercise mln::io::load on OFF file (with no color data).
+
+ * tests/io/Makefile.am (SUBDIRS): Add io.
+ * tests/io/off/: New directory.
+ * tests/io/off/load_bin.cc: New.
+ * tests/io/off/Makefile.am: New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a routine to create a complex-based image from an OFF file.
* mln/io/off/load.hh: New.
diff --git a/milena/tests/io/Makefile.am b/milena/tests/io/Makefile.am
index 89cfa56..36d7797 100644
--- a/milena/tests/io/Makefile.am
+++ b/milena/tests/io/Makefile.am
@@ -4,6 +4,7 @@ include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
fits \
+ off \
pbm \
pfm \
pgm \
diff --git a/milena/tests/io/Makefile.am b/milena/tests/io/off/Makefile.am
similarity index 56%
copy from milena/tests/io/Makefile.am
copy to milena/tests/io/off/Makefile.am
index 89cfa56..4b592ce 100644
--- a/milena/tests/io/Makefile.am
+++ b/milena/tests/io/off/Makefile.am
@@ -2,10 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
-SUBDIRS = \
- fits \
- pbm \
- pfm \
- pgm \
- pnm \
- ppm
+check_PROGRAMS = \
+ load_bin
+
+load_bin_SOURCES = load_bin.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/io/off/load_bin.cc b/milena/tests/io/off/load_bin.cc
new file mode 100644
index 0000000..e171704
--- /dev/null
+++ b/milena/tests/io/off/load_bin.cc
@@ -0,0 +1,64 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/io/off/load_bin.cc
+/// \brief Test mln::io::off::load with an
+/// mln::complex_image<3, geom::complex_data<3, point3df>, bool>.
+
+#include <algorithm>
+#include <iterator>
+#include <iostream>
+
+#include <mln/io/off/load.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ /* FIXME: Create an alias in milena/mln/core/alias/ for this
+ particular image type? */
+ typedef mln::complex_image<2, geom::complex_geometry<2,point3df>, bool> ima_t;
+ ima_t ima;
+ io::off::load(ima, MLN_MESH_DIR "/tetrahedron.off");
+
+ std::cout << ima.domain().cplx() << std::endl;
+
+ mln_piter_(ima_t) p(ima.domain());
+ for_all(p)
+ {
+ std::cout << "ima(" << p << ") = " << ima(p) << " ( ";
+ // Print site(s).
+ typedef mln_site_(ima_t) site_t;
+ site_t s(p);
+ std::copy (s.sites.begin(), s.sites.end(),
+ std::ostream_iterator<site_t::location>(std::cout, " "));
+ std::cout << ")" << std::endl;
+ }
+}
--
1.6.0.1
1
0
2585: Add a routine to create a complex-based image from an OFF file.
by Roland Levillain 16 Oct '08
by Roland Levillain 16 Oct '08
16 Oct '08
* mln/io/off/load.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/io/off/load.hh | 308 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 314 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/io/off/load.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 30e48e9..546bec0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a routine to create a complex-based image from an OFF file.
+
+ * mln/io/off/load.hh: New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a macro containing the path to meshes, to be used in tests.
* tests/data.hh.in (MLN_MESH_DIR): New macro.
diff --git a/milena/mln/io/off/load.hh b/milena/mln/io/off/load.hh
new file mode 100644
index 0000000..ff8d106
--- /dev/null
+++ b/milena/mln/io/off/load.hh
@@ -0,0 +1,308 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_IO_OFF_LOAD_HH
+# define MLN_IO_OFF_LOAD_HH
+
+/// \file mln/io/off/load.hh
+/// \brief Input loading function for OFF files.
+///
+/// \see http://shape.cs.princeton.edu/benchmark/documentation/off_format.html
+
+# include <cstdlib>
+
+# include <iostream>
+# include <fstream>
+
+# include <string>
+
+# include <mln/core/image/complex_image.hh>
+# include <mln/geom/complex_geometry.hh>
+# include <mln/core/alias/point3df.hh>
+
+// // FIXME: Really needed?
+// # include <mln/topo/n_faces_set.hh>
+
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace off
+ {
+
+ /** \brief Load a (boolean) OFF image into a complex image.
+
+ \param[out] ima A reference to the image to construct.
+ \param[in] filename The name of the file to load.
+
+ The image is said boolean since data only represent the
+ existence of vertices and faces. */
+ void load(complex_image<2, geom::complex_geometry<2,point3df>, bool>& ima,
+ const std::string& filename);
+
+ namespace internal
+ {
+ /// A stream manipulator eating comments starting with a `#'
+ /// and ending at an end of line
+ std::istream& eat_comment (std::istream& istr);
+ }
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ void load(complex_image<2 ,geom::complex_geometry<2,point3df>, bool>& ima,
+ const std::string& filename)
+ {
+ const std::string me = "mln::io::load::off";
+
+ std::ifstream istr(filename.c_str());
+ if (!istr)
+ {
+ std::cerr << me << ": `" << filename << "' not found." << std::endl;
+ /* FIXME: Too violent. We should allow the use of
+ exception, at least to have Milena's code behave
+ correctly in interpreted environments (std::exit() or
+ std::abort() causes the termination of a Python
+ interpreter, for instance!). */
+ std::exit(1);
+ }
+
+ /*---------.
+ | Header. |
+ `---------*/
+
+ /* ``The .off files in the Princeton Shape Benchmark conform
+ to the following standard. */
+
+ /* OFF files are all ASCII files beginning with the keyword
+ OFF. '' */
+ std::string type;
+ istr >> internal::eat_comment >> type;
+ if (type != "OFF")
+ {
+ std::cerr << me << ": `" << filename << "': ill-formed header."
+ << std::endl;
+ std::exit(1);
+ }
+
+ /* ``The next line states the number of vertices, the number
+ of faces, and the number of edges. The number of edges can
+ be safely ignored.'' */
+ unsigned nvertices, nfaces, nedges;
+ istr >> internal::eat_comment >> nvertices
+ >> internal::eat_comment >> nfaces
+ >> internal::eat_comment >> nedges;
+
+ /*-------.
+ | Data. |
+ `-------*/
+
+ /* FIXME: Maybe we could sugar all this (using make_whatever
+ helpers?). */
+
+ // --------- //
+ // Complex. //
+ // --------- //
+
+ const unsigned D = 2;
+ topo::complex<D> c;
+
+ // ------------------------------------------ //
+ // Vertices & geometry (vertices locations). //
+ // ------------------------------------------ //
+
+ /* ``The vertices are listed with x, y, z coordinates, written
+ one per line. */
+
+ /* FIXME: We should have a faster way to create a bunch of
+ 0-faces (vertices). */
+ for (unsigned v = 0; v < nvertices; ++v)
+ c.add_face();
+
+ typedef point3df P;
+ typedef mln_coord_(P) C;
+ typedef geom::complex_geometry<D, P> G;
+ G geom;
+ for (unsigned v = 0; v < nvertices; ++v)
+ {
+ C x, y, z;
+ istr >> internal::eat_comment >> x
+ >> internal::eat_comment >> y
+ >> internal::eat_comment >> z;
+ geom.add_location(point3df(x, y, z));
+ }
+
+ // --------------- //
+ // Faces & edges. //
+ // --------------- //
+
+ /* After the list of vertices, the faces are listed, with one
+ face per line. For each face, the number of vertices is
+ specified, followed by indices into the list of
+ vertices.'' */
+
+ // An adjacenty matrix recording the edges seen so far.
+ typedef std::vector< std::vector<bool> > complex_edges_t;
+ complex_edges_t complex_edges (nvertices,
+ std::vector<bool>(nvertices, false));
+
+ for (unsigned f = 0; f < nfaces; ++f)
+ {
+ unsigned nface_vertices;
+ istr >> internal::eat_comment >> nface_vertices;
+ if (nface_vertices <= 2)
+ {
+ std::cerr << me << ": `" << filename
+ << "': ill-formed face (" << nface_vertices
+ << " vertices)" << std::endl;
+ std::exit(1);
+ }
+
+ // The edges of the face.
+ topo::n_faces_set<1, D> face_edges_set;
+ face_edges_set.reserve(nface_vertices);
+
+ // The first vertex id of the face.
+ unsigned first_vertex_id;
+ istr >> internal::eat_comment >> first_vertex_id;
+ // The current vertex id initialized with the first id.
+ unsigned vertex_id = first_vertex_id;
+ if (first_vertex_id >= nvertices)
+ {
+ std::cerr << me << ": `" << filename
+ << "': invalid vertex id " << first_vertex_id
+ << std::endl;
+ std::exit(1);
+ }
+ // Iterate on vertices and form edges.
+ for (unsigned v = 0; v < nface_vertices; ++v)
+ {
+ /* The next vertex id. The pair (vertex_id, next_vertex_id)
+ is an edge of the mesh/complex. */
+ unsigned next_vertex_id;
+ /* When V is the id of the last vertex of the face F,
+ set next_vertex_id to first_vertex_id; otherwise,
+ read it from the input. */
+ if (v == nface_vertices - 1)
+ next_vertex_id = first_vertex_id;
+ else
+ {
+ istr >> internal::eat_comment >> next_vertex_id;
+ if (next_vertex_id >= nvertices)
+ {
+ std::cerr << me << ": `" << filename
+ << "': invalid vertex id " << next_vertex_id
+ << std::endl;
+ std::exit(1);
+ }
+ }
+ // The ends of the current edge.
+ topo::n_face<0, D> vertex(c, vertex_id);
+ topo::n_face<0, D> next_vertex(c, next_vertex_id);
+ // The current edge.
+ topo::n_face<1, D> edge;
+ // If the edge has been constructed yet, create it;
+ // otherwise, retrieve its id from the complex.
+ if (!complex_edges[vertex_id][next_vertex_id])
+ {
+ complex_edges[vertex_id][next_vertex_id] = true;
+ complex_edges[next_vertex_id][vertex_id] = true;
+ edge = c.add_face(vertex + next_vertex);
+ }
+ else
+ {
+ edge = topo::edge(vertex, next_vertex);
+ mln_assertion(edge.is_valid());
+ }
+ // Record this edge.
+ face_edges_set += edge;
+ // Next vertex.
+ vertex_id = next_vertex_id;
+ }
+
+ // Add face.
+ c.add_face(face_edges_set);
+ }
+
+ /*--------.
+ | Image. |
+ `--------*/
+
+ // Value type.
+ typedef bool V;
+
+ // Site set.
+ p_complex<D, G> pc(c, geom);
+
+ // Values.
+ metal::vec<D + 1, std::vector<V> > values;
+ for (unsigned i = 0; i <= D; ++i)
+ values[i].insert(values[i].begin(), pc.cplx().nfaces(i), true);
+
+ // Image.
+ ima.init_(pc, values);
+
+ istr.close();
+ }
+
+
+ namespace internal
+ {
+ /// A stream manipulator eating comments starting with a `#'
+ /// and ending at an end of line
+ std::istream& eat_comment (std::istream& istr)
+ {
+ // Skip whitespace and newlines.
+ std::ws(istr);
+ while (istr.peek() == '#')
+ {
+ /* Eat the `#' and the rest of the line until `\n' or
+ `\r' is found or the end of the file is reached. */
+ char c;
+ do
+ istr.get(c);
+ while (c != '\n' && c != '\r' && !istr.eof());
+ // Skip whitespace and newlines.
+ std::ws(istr);
+ }
+ return istr;
+ }
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::off
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_OFF_LOAD_HH
--
1.6.0.1
1
0
2584: Add a macro containing the path to meshes, to be used in tests.
by Roland Levillain 16 Oct '08
by Roland Levillain 16 Oct '08
16 Oct '08
* tests/data.hh.in (MLN_MESH_DIR): New macro.
---
milena/ChangeLog | 6 ++++++
milena/tests/data.hh.in | 9 ++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 582245d..30e48e9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a macro containing the path to meshes, to be used in tests.
+
+ * tests/data.hh.in (MLN_MESH_DIR): New macro.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add more meshes.
* mesh/cube.off,
diff --git a/milena/tests/data.hh.in b/milena/tests/data.hh.in
index f30cfdc..f26299b 100644
--- a/milena/tests/data.hh.in
+++ b/milena/tests/data.hh.in
@@ -30,10 +30,13 @@
# include <string>
-/** \brief The absolute path to the img directory of Milena.
+/* Macros are evil, but they save us an extra compilation unit here
+ (as well as additional burden in Makefiles, too.). */
- Macros are evil, but they save us an extra compilation unit here
- (as well as additional burden in Makefiles, too.). */
+/// \brief The absolute path to the img directory of Milena.
# define MLN_IMG_DIR "@abs_top_srcdir@/milena/img"
+/// \brief The absolute path to the mesh directory of Milena.
+# define MLN_MESH_DIR "@abs_top_srcdir@/milena/mesh"
+
#endif // ! TESTS_DATA_HH
--
1.6.0.1
1
0
* mesh/cube.off,
* mesh/tetrahedron.off:
New.
---
milena/ChangeLog | 8 ++++++++
milena/mesh/cube.off | 16 ++++++++++++++++
milena/mesh/tetrahedron.off | 10 ++++++++++
3 files changed, 34 insertions(+), 0 deletions(-)
create mode 100644 milena/mesh/cube.off
create mode 100644 milena/mesh/tetrahedron.off
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 24542de..582245d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add more meshes.
+
+ * mesh/cube.off,
+ * mesh/tetrahedron.off:
+ New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Exercise mln::geom::complex_geometry with mln::p_complex.
* tests/core/image/complex_image.cc,
diff --git a/milena/mesh/cube.off b/milena/mesh/cube.off
new file mode 100644
index 0000000..b251b4e
--- /dev/null
+++ b/milena/mesh/cube.off
@@ -0,0 +1,16 @@
+OFF
+8 6 12
+ 1.632993 0.000000 1.154701
+ 0.000000 1.632993 1.154701
+ -1.632993 0.000000 1.154701
+ -0.000000 -1.632993 1.154701
+ 1.632993 -0.000000 -1.154701
+ 0.000000 1.632993 -1.154701
+ -1.632993 0.000000 -1.154701
+ -0.000000 -1.632993 -1.154701
+ 4 0 1 2 3
+ 4 7 4 0 3
+ 4 4 5 1 0
+ 4 5 6 2 1
+ 4 3 2 6 7
+ 4 6 5 4 7
diff --git a/milena/mesh/tetrahedron.off b/milena/mesh/tetrahedron.off
new file mode 100644
index 0000000..70900c0
--- /dev/null
+++ b/milena/mesh/tetrahedron.off
@@ -0,0 +1,10 @@
+OFF
+4 4 6
+ 0.0 0.0 2.0
+ 1.632993 -0.942809 -0.666667
+ 0.000000 1.885618 -0.666667
+ -1.632993 -0.942809 -0.666667
+ 3 1 0 3
+ 3 2 0 1
+ 3 3 0 2
+ 3 3 2 1
--
1.6.0.1
1
0
16 Oct '08
* tests/core/image/complex_image.cc,
* tests/morpho/complex_image_morpho.cc:
...here.
Adjust: s/P/G/.
* tests/core/site_set/p_complex.cc: New.
* tests/core/site_set/Makefile.am (check_PROGRAMS): Add p_complex.
(p_complex_SOURCES): New.
---
milena/ChangeLog | 12 +++
milena/tests/core/image/complex_image.cc | 79 ++++++++++-------
milena/tests/core/site_set/Makefile.am | 2 +
milena/tests/core/site_set/p_complex.cc | 127 +++++++++++++++++++++++++++
milena/tests/morpho/complex_image_morpho.cc | 36 +++++---
5 files changed, 209 insertions(+), 47 deletions(-)
create mode 100644 milena/tests/core/site_set/p_complex.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index fa3e596..24542de 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,17 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Exercise mln::geom::complex_geometry with mln::p_complex.
+
+ * tests/core/image/complex_image.cc,
+ * tests/morpho/complex_image_morpho.cc:
+ ...here.
+ Adjust: s/P/G/.
+ * tests/core/site_set/p_complex.cc: New.
+ * tests/core/site_set/Makefile.am (check_PROGRAMS): Add p_complex.
+ (p_complex_SOURCES): New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Have complex-based site set use geometry functor for site location.
* mln/core/site_set/p_complex.hh
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index d30ccc4..4b81713 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -57,15 +57,17 @@ int main()
/* A 2-d (simplicial) complex and its adjacency graph.
- v0 e3 v3
- o-----------o v0----e3----v3
- / \ ,-----. / / \ | /
- / . \ \ t1/ / / \ t1 /
- e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
- / /t0 \ \ ' / / t0 \ /
- / `-----' \ / / | \ /
- o-----------o v1----e2----v2
- v1 e2 v2
+ c 0 1 2 3
+ r .------------------------
+ | v0 e3 v3
+ 0 | o-----------o v0----e3----v3
+ | / \ ,-----. / / \ | /
+ | / . \ \ t1/ / / \ t1 /
+ 1 | e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
+ | / /t0 \ \ ' / / t0 \ /
+ | / `-----' \ / / | \ /
+ 2 | o-----------o v1----e2----v2
+ | v1 e2 v2
v = vertex
e = edge
@@ -94,18 +96,29 @@ int main()
topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
-
+
+ /*------------------------------.
+ | Complex geometry (location). |
+ `------------------------------*/
+
+ typedef point2d P;
+ typedef geom::complex_geometry<D, P> G;
+ G geom;
+ geom.add_location(point2d(0,1)); // 0-face #0.
+ geom.add_location(point2d(2,0)); // 0-face #1.
+ geom.add_location(point2d(2,2)); // 0-face #2.
+ geom.add_location(point2d(0,3)); // 0-face #3.
+
+
/*---------------------.
| Complex-based pset. |
`---------------------*/
- typedef point2d P;
-
// A pset.
- p_complex<D, P> pc(c);
+ p_complex<D, G> pc(c, geom);
topo::face<D> af(e0);
// An associated psite.
- complex_psite<D, P> cs(pc, af);
+ complex_psite<D, G> cs(pc, af);
/*--------------------.
@@ -117,16 +130,16 @@ int main()
of the test? */
// Pset of 0-faces.
- p_faces<0, D, P> pf0(c);
+ p_faces<0, D, G> pf0(c);
// Pset of 1-faces.
- p_faces<1, D, P> pf1(c);
+ p_faces<1, D, G> pf1(c);
// Pset of 2-faces.
- p_faces<2, D, P> pf2(c);
+ p_faces<2, D, G> pf2(c);
// Some psites on faces.
- faces_psite<0, D, P> fs0(pf0, v0);
- faces_psite<1, D, P> fs1(pf1, e0);
- faces_psite<2, D, P> fs2(pf2, t0);
+ faces_psite<0, D, G> fs0(pf0, v0);
+ faces_psite<1, D, G> fs1(pf1, e0);
+ faces_psite<2, D, G> fs2(pf2, t0);
/*----------------------.
@@ -137,7 +150,7 @@ int main()
// An image type built on a 2-complex with mln::int_u8 values on
// each face.
- typedef complex_image<D, P, int_u8> ima_t;
+ typedef complex_image<D, G, int_u8> ima_t;
// Values.
metal::vec<D + 1, std::vector< int_u8 > > values;
@@ -179,8 +192,8 @@ int main()
// Dynamic version.
for (unsigned n = 0; n <= D; ++n)
{
- p_n_faces_fwd_piter<D, P> fwd_np(ima.domain(), n);
- p_n_faces_bkd_piter<D, P> bkd_np(ima.domain(), n);
+ p_n_faces_fwd_piter<D, G> fwd_np(ima.domain(), n);
+ p_n_faces_bkd_piter<D, G> bkd_np(ima.domain(), n);
for_all_2(fwd_np, bkd_np)
std::cout << "ima(" << fwd_np << ") = " << ima(fwd_np) << '\t'
<< "ima(" << bkd_np << ") = " << ima(bkd_np)
@@ -192,7 +205,7 @@ int main()
// FIXME: Disabled (moved to the attic).
# if 0
// FIXME: Sugar the name of the iterator.
- p_complex_faces_fwd_piter_<0, D, P> f0p(ima.domain());
+ p_complex_faces_fwd_piter_<0, D, G> f0p(ima.domain());
for_all(f0p)
std::cout << "ima(" << f0p << ") = " << ima(f0p) << std::endl;
#endif
@@ -211,7 +224,7 @@ int main()
// Iterate on the lower-dimension faces of each face.
{
- typedef complex_lower_neighborhood<D, P> nbh_t;
+ typedef complex_lower_neighborhood<D, G> nbh_t;
nbh_t nbh;
mln_fwd_niter_(nbh_t) fn(nbh, fp);
mln_bkd_niter_(nbh_t) bn(nbh, fp);
@@ -221,9 +234,9 @@ int main()
for_all_2(fn, bn)
{
mln_assertion((fn.center() ==
- static_cast<const complex_psite<D, P>&>(fp)));
+ static_cast<const complex_psite<D, G>&>(fp)));
mln_assertion((bn.center() ==
- static_cast<const complex_psite<D, P>&>(fp)));
+ static_cast<const complex_psite<D, G>&>(fp)));
std::cout << " " << fn << '\t' << bn << std::endl;
}
}
@@ -232,7 +245,7 @@ int main()
// Iterate on the higher-dimension faces of each face.
{
- typedef complex_higher_neighborhood<D, P> nbh_t;
+ typedef complex_higher_neighborhood<D, G> nbh_t;
nbh_t nbh;
mln_fwd_niter_(nbh_t) fn(nbh, fp);
mln_bkd_niter_(nbh_t) bn(nbh, fp);
@@ -242,9 +255,9 @@ int main()
for_all_2(fn, bn)
{
mln_assertion((fn.center() ==
- static_cast<const complex_psite<D, P>&>(fp)));
+ static_cast<const complex_psite<D, G>&>(fp)));
mln_assertion((bn.center() ==
- static_cast<const complex_psite<D, P>&>(fp)));
+ static_cast<const complex_psite<D, G>&>(fp)));
std::cout << " " << fn << '\t' << bn << std::endl;
}
}
@@ -253,7 +266,7 @@ int main()
// Iterate on the lower- and higher-dimension faces of each face.
{
- typedef complex_lower_higher_neighborhood<D, P> nbh_t;
+ typedef complex_lower_higher_neighborhood<D, G> nbh_t;
nbh_t nbh;
mln_fwd_niter_(nbh_t) fn(nbh, fp);
mln_bkd_niter_(nbh_t) bn(nbh, fp);
@@ -264,9 +277,9 @@ int main()
for_all_2(fn, bn)
{
mln_assertion((fn.center() ==
- static_cast<const complex_psite<D, P>&>(fp)));
+ static_cast<const complex_psite<D, G>&>(fp)));
mln_assertion((bn.center() ==
- static_cast<const complex_psite<D, P>&>(fp)));
+ static_cast<const complex_psite<D, G>&>(fp)));
std::cout << " " << fn << '\t' << bn << std::endl;
}
}
diff --git a/milena/tests/core/site_set/Makefile.am b/milena/tests/core/site_set/Makefile.am
index 1b23c79..7c9c2a8 100644
--- a/milena/tests/core/site_set/Makefile.am
+++ b/milena/tests/core/site_set/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
p_array \
## p_bgraph \
+ p_complex \
p_edges \
p_image \
p_priority_queue \
@@ -16,6 +17,7 @@ check_PROGRAMS = \
p_array_SOURCES = p_array.cc
##p_bgraph_SOURCES = p_bgraph.cc
+p_complex_SOURCES = p_complex.cc
p_image_SOURCES = p_image.cc
p_priority_queue_SOURCES = p_priority_queue.cc
p_queue_SOURCES = p_queue.cc
diff --git a/milena/tests/core/site_set/p_complex.cc b/milena/tests/core/site_set/p_complex.cc
new file mode 100644
index 0000000..490d387
--- /dev/null
+++ b/milena/tests/core/site_set/p_complex.cc
@@ -0,0 +1,127 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// \file tests/core/image/p_complex.cc
+/// \brief Test of mln::p_complex and mln::geom::complex_geometry.
+
+#include <algorithm>
+#include <iterator>
+#include <iostream>
+
+#include <mln/value/int_u8.hh>
+#include <mln/core/alias/point2d.hh>
+
+#include <mln/core/site_set/p_faces.hh>
+#include <mln/core/image/complex_image.hh>
+
+/* FIXME: Split this test (and maybe factor common parts, like the
+ construction of the complex), since it exercises too many features
+ in a single file. */
+
+
+int main()
+{
+ using namespace mln;
+
+ /*----------.
+ | Complex. |
+ `----------*/
+
+ /* A 2-d (simplicial) complex and its adjacency graph.
+
+ c 0 1 2 3
+ r .------------------------
+ | v0 e3 v3
+ 0 | o-----------o v0----e3----v3
+ | / \ ,-----. / / \ | /
+ | / . \ \ t1/ / / \ t1 /
+ 1 | e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
+ | / /t0 \ \ ' / / t0 \ /
+ | / `-----' \ / / | \ /
+ 2 | o-----------o v1----e2----v2
+ | v1 e2 v2
+
+ v = vertex
+ e = edge
+ t = triangle
+ */
+
+
+ const unsigned D = 2;
+
+ topo::complex<D> c;
+
+ // 0-faces (points).
+ topo::n_face<0, D> v0 = c.add_face();
+ topo::n_face<0, D> v1 = c.add_face();
+ topo::n_face<0, D> v2 = c.add_face();
+ topo::n_face<0, D> v3 = c.add_face();
+
+ // 1-faces (segments).
+ topo::n_face<1, D> e0 = c.add_face(v0 + v1);
+ topo::n_face<1, D> e1 = c.add_face(v0 + v2);
+ topo::n_face<1, D> e2 = c.add_face(v1 + v2);
+ topo::n_face<1, D> e3 = c.add_face(v0 + v3);
+ topo::n_face<1, D> e4 = c.add_face(v2 + v3);
+
+ // 2-faces (triangles).
+ topo::n_face<2, D> t0 = c.add_face(e0 + e1 + e2);
+ topo::n_face<2, D> t1 = c.add_face(e1 + e3 + e4);
+
+
+ /*------------------------------.
+ | Complex geometry (location). |
+ `------------------------------*/
+
+ typedef point2d P;
+ typedef geom::complex_geometry<D, P> G;
+ G geom;
+ geom.add_location(point2d(0,1)); // 0-face #0.
+ geom.add_location(point2d(2,0)); // 0-face #1.
+ geom.add_location(point2d(2,2)); // 0-face #2.
+ geom.add_location(point2d(0,3)); // 0-face #3.
+
+
+ /*---------------------.
+ | Complex-based pset. |
+ `---------------------*/
+
+ // A pset.
+ p_complex<D, G> pc(c, geom);
+
+ // An iterator on this pset.
+ p_complex_fwd_piter_<D, G> p(pc);
+ for_all(p)
+ {
+ std::cout << p << ": ";
+ // Print site(s).
+ mln_site_(G) s(p);
+ std::copy (s.sites.begin(), s.sites.end(),
+ std::ostream_iterator<P>(std::cout, " "));
+ std::cout << std::endl;
+ }
+}
diff --git a/milena/tests/morpho/complex_image_morpho.cc b/milena/tests/morpho/complex_image_morpho.cc
index e8b7d25..baf0f68 100644
--- a/milena/tests/morpho/complex_image_morpho.cc
+++ b/milena/tests/morpho/complex_image_morpho.cc
@@ -65,15 +65,17 @@ int main()
/* A 2-d (simplicial) complex and its adjacency graph.
- v0 e3 v3
- o-----------o v0----e3----v3
- / \ ,-----. / / \ | /
- / . \ \ t1/ / / \ t1 /
- e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
- / /t0 \ \ ' / / t0 \ /
- / `-----' \ / / | \ /
- o-----------o v1----e2----v2
- v1 e2 v2
+ c 0 1 2 3
+ r .------------------------
+ | v0 e3 v3
+ 0 | o-----------o v0----e3----v3
+ | / \ ,-----. / / \ | /
+ | / . \ \ t1/ / / \ t1 /
+ 1 | e0 / / \ e1\ / / e4 e0. ,e1Ž `e4
+ | / /t0 \ \ ' / / t0 \ /
+ | / `-----' \ / / | \ /
+ 2 | o-----------o v1----e2----v2
+ | v1 e2 v2
v = vertex
e = edge
@@ -108,7 +110,13 @@ int main()
`-------------------------*/
typedef point2d P;
- p_complex<D, P> pc(c);
+ typedef geom::complex_geometry<D, P> G;
+ G geom;
+ geom.add_location(point2d(0,1)); // 0-face #0.
+ geom.add_location(point2d(2,0)); // 0-face #1.
+ geom.add_location(point2d(2,2)); // 0-face #2.
+ geom.add_location(point2d(0,3)); // 0-face #3.
+ p_complex<D, G> pc(c, geom);
/*----------------------.
@@ -119,7 +127,7 @@ int main()
// An image type built on a 2-complex with mln::int_u8 values on
// each face.
- typedef complex_image<D, P, int_u8> ima_t;
+ typedef complex_image<D, G, int_u8> ima_t;
ima_t ima(pc);
// Initialize values.
debug::iota(ima);
@@ -148,9 +156,9 @@ int main()
| Morphological operations on complex-based images. |
`---------------------------------------------------*/
- test_morpho(ima, complex_lower_window_p<D, P>());
- test_morpho(ima, complex_higher_window_p<D, P>());
- test_morpho(ima, complex_lower_higher_window_p<D, P>());
+ test_morpho(ima, complex_lower_window_p<D, G>());
+ test_morpho(ima, complex_higher_window_p<D, G>());
+ test_morpho(ima, complex_lower_higher_window_p<D, G>());
/* FIXME: Exercise elementary erosion/dilation (with neighborhoods)
when available. */
--
1.6.0.1
1
0
2581: Have complex-based site set use geometry functor for site location.
by Roland Levillain 16 Oct '08
by Roland Levillain 16 Oct '08
16 Oct '08
* mln/core/site_set/p_complex.hh
(p_complex<D, P>): Replace parameter P, standing for a site type,
by...
(p_complex<D, G>): ...a parameter G, standing for a geometry
functor type.
Adjust.
Update documentation.
(mln::p_complex<D, G>::geom_): New attribute.
(mln::p_complex<D, G>::geom): New accessor.
(mln::p_complex::p_complex(const topo::complex<D>&)):
Add an extra parameter...
(mln::p_complex::p_complex(const topo::complex<D>&, const G&)):
...to initialize mln::p_complex<D, G>::geom_.
* mln/core/image/complex_higher_neighborhood.hh,
* mln/core/image/complex_higher_window_p.hh,
* mln/core/image/complex_lower_higher_neighborhood.hh,
* mln/core/image/complex_lower_higher_window_p.hh,
* mln/core/image/complex_lower_neighborhood.hh,
* mln/core/image/complex_lower_window_p.hh,
* mln/core/image/complex_neighborhood_piter.hh,
* mln/core/image/complex_window_piter.hh,
* mln/core/image/complex_image.hh,
* mln/core/site_set/complex_psite.hh,
* mln/core/site_set/p_complex_piter.hh:
Adjust: s/P/G/.
* mln/core/image/complex_image.hh
(mln::trait::image_< complex_image<D, G, V> >::dimension): Adjust.
(mln::complex_image<D, G, V>): More documentation.
* mln/core/site_set/complex_psite.hh: Use #if 0 / #endif to
disable code instead of comments.
(mln::complex_psite<D, G>::p_): Set type to mln_site(G).
(mln::complex_psite::complex_psite): Don't update unconditionally,
ensure the iterator is valid first.
(mln::complex_psite::complex_psite<D, G>::subj_())
(mln::complex_psite::complex_psite<D, G>::update_()):
Provide actual implementations.
* mln/core/site_set/p_complex_piter.hh
(mln::p_complex_fwd_piter_<D, G>)
(mln::p_complex_bkd_piter_<D, G>):
Adjust site type passed as parameter as super class.
(mln::p_complex_fwd_piter_<D, G>::super_)
(mln::p_complex_bkd_piter_<D, G>::super_):
Likewise.
---
milena/ChangeLog | 48 ++++++
.../mln/core/image/complex_higher_neighborhood.hh | 22 ++--
milena/mln/core/image/complex_higher_window_p.hh | 30 ++--
milena/mln/core/image/complex_image.hh | 107 +++++++-------
.../image/complex_lower_higher_neighborhood.hh | 22 ++--
.../core/image/complex_lower_higher_window_p.hh | 30 ++--
.../mln/core/image/complex_lower_neighborhood.hh | 22 ++--
milena/mln/core/image/complex_lower_window_p.hh | 30 ++--
.../mln/core/image/complex_neighborhood_piter.hh | 100 +++++++-------
milena/mln/core/image/complex_window_piter.hh | 100 +++++++-------
milena/mln/core/site_set/complex_psite.hh | 156 +++++++++++---------
milena/mln/core/site_set/p_complex.hh | 110 ++++++++------
milena/mln/core/site_set/p_complex_piter.hh | 62 ++++----
13 files changed, 464 insertions(+), 375 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index afe3d11..fa3e596 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,53 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Have complex-based site set use geometry functor for site location.
+
+ * mln/core/site_set/p_complex.hh
+ (p_complex<D, P>): Replace parameter P, standing for a site type,
+ by...
+ (p_complex<D, G>): ...a parameter G, standing for a geometry
+ functor type.
+ Adjust.
+ Update documentation.
+ (mln::p_complex<D, G>::geom_): New attribute.
+ (mln::p_complex<D, G>::geom): New accessor.
+ (mln::p_complex::p_complex(const topo::complex<D>&)):
+ Add an extra parameter...
+ (mln::p_complex::p_complex(const topo::complex<D>&, const G&)):
+ ...to initialize mln::p_complex<D, G>::geom_.
+ * mln/core/image/complex_higher_neighborhood.hh,
+ * mln/core/image/complex_higher_window_p.hh,
+ * mln/core/image/complex_lower_higher_neighborhood.hh,
+ * mln/core/image/complex_lower_higher_window_p.hh,
+ * mln/core/image/complex_lower_neighborhood.hh,
+ * mln/core/image/complex_lower_window_p.hh,
+ * mln/core/image/complex_neighborhood_piter.hh,
+ * mln/core/image/complex_window_piter.hh,
+ * mln/core/image/complex_image.hh,
+ * mln/core/site_set/complex_psite.hh,
+ * mln/core/site_set/p_complex_piter.hh:
+ Adjust: s/P/G/.
+ * mln/core/image/complex_image.hh
+ (mln::trait::image_< complex_image<D, G, V> >::dimension): Adjust.
+ (mln::complex_image<D, G, V>): More documentation.
+ * mln/core/site_set/complex_psite.hh: Use #if 0 / #endif to
+ disable code instead of comments.
+ (mln::complex_psite<D, G>::p_): Set type to mln_site(G).
+ (mln::complex_psite::complex_psite): Don't update unconditionally,
+ ensure the iterator is valid first.
+ (mln::complex_psite::complex_psite<D, G>::subj_())
+ (mln::complex_psite::complex_psite<D, G>::update_()):
+ Provide actual implementations.
+ * mln/core/site_set/p_complex_piter.hh
+ (mln::p_complex_fwd_piter_<D, G>)
+ (mln::p_complex_bkd_piter_<D, G>):
+ Adjust site type passed as parameter as super class.
+ (mln::p_complex_fwd_piter_<D, G>::super_)
+ (mln::p_complex_bkd_piter_<D, G>::super_):
+ Likewise.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a functor encoding the geometry of a complex using its 0-faces.
* mln/geom/complex_geometry.hh: New.
diff --git a/milena/mln/core/image/complex_higher_neighborhood.hh b/milena/mln/core/image/complex_higher_neighborhood.hh
index b3fc4b9..4dce482 100644
--- a/milena/mln/core/image/complex_higher_neighborhood.hh
+++ b/milena/mln/core/image/complex_higher_neighborhood.hh
@@ -44,19 +44,19 @@
namespace mln
{
// Forward declarations.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_fwd_piter;
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_bkd_piter;
/// \brief Neighborhood centered on a n-face of complex returning its
/// adjacent (n-1)-faces.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
class complex_higher_neighborhood
- : public Neighborhood< complex_higher_neighborhood<D, P> >
+ : public Neighborhood< complex_higher_neighborhood<D, G> >
{
- typedef complex_higher_neighborhood<D, P> self_;
+ typedef complex_higher_neighborhood<D, G> self_;
public:
/// The associated complex iterators.
@@ -69,19 +69,19 @@ namespace mln
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// The type of site corresponding to the neighborhood.
typedef mln_site(psite) site;
/// \brief Site_Iterator type to browse the psites of the neighborhood
/// w.r.t. the ordering of vertices.
typedef
- complex_neighborhood_fwd_piter<complex_fwd_iter, P, self_> fwd_niter;
+ complex_neighborhood_fwd_piter<complex_fwd_iter, G, self_> fwd_niter;
/// \brief Site_Iterator type to browse the psites of the neighborhood
/// w.r.t. the reverse ordering of vertices.
typedef
- complex_neighborhood_bkd_piter<complex_bkd_iter, P, self_> bkd_niter;
+ complex_neighborhood_bkd_piter<complex_bkd_iter, G, self_> bkd_niter;
/// The default niter type.
typedef fwd_niter niter;
@@ -102,11 +102,11 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
// FIXME: Dummy.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
// FIXME: Change (dummy) type.
- const typename complex_higher_neighborhood<D, P>::window&
- complex_higher_neighborhood<D, P>::win() const
+ const typename complex_higher_neighborhood<D, G>::window&
+ complex_higher_neighborhood<D, G>::win() const
{
// FIXME: Dummy.
return *this;
diff --git a/milena/mln/core/image/complex_higher_window_p.hh b/milena/mln/core/image/complex_higher_window_p.hh
index 39108c4..b043ce9 100644
--- a/milena/mln/core/image/complex_higher_window_p.hh
+++ b/milena/mln/core/image/complex_higher_window_p.hh
@@ -43,16 +43,16 @@
namespace mln
{
// Forward declarations.
- template <unsigned D, typename P> class complex_higher_window_p;
- template <typename I, typename P, typename W> class complex_window_fwd_piter;
- template <typename I, typename P, typename W> class complex_window_bkd_piter;
+ template <unsigned D, typename G> class complex_higher_window_p;
+ template <typename I, typename G, typename W> class complex_window_fwd_piter;
+ template <typename I, typename G, typename W> class complex_window_bkd_piter;
namespace trait
{
- template <unsigned D, typename P>
- struct window_< mln::complex_higher_window_p<D,P> >
+ template <unsigned D, typename G>
+ struct window_< mln::complex_higher_window_p<D,G> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::irregular support;
@@ -64,11 +64,11 @@ namespace mln
/// \brief Window centered on a n-face of complex returning its
/// adjacent (n+1)-faces as well as the center n-face.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
class complex_higher_window_p
- : public Window< complex_higher_window_p<D, P> >
+ : public Window< complex_higher_window_p<D, G> >
{
- typedef complex_higher_window_p<D, P> self_;
+ typedef complex_higher_window_p<D, G> self_;
/// The complex iterators on the <em>adjacent</em> faces only
/// (without the center point).
/// \{
@@ -87,7 +87,7 @@ namespace mln
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// The type of site corresponding to the window.
typedef mln_site(psite) site;
@@ -97,12 +97,12 @@ namespace mln
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
typedef
- complex_window_fwd_piter<complex_fwd_iter, P, self_> fwd_qiter;
+ complex_window_fwd_piter<complex_fwd_iter, G, self_> fwd_qiter;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the reverse ordering of vertices.
typedef
- complex_window_bkd_piter<complex_bkd_iter, P, self_> bkd_qiter;
+ complex_window_bkd_piter<complex_bkd_iter, G, self_> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
@@ -125,16 +125,16 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- complex_higher_window_p<D, P>::is_empty() const
+ complex_higher_window_p<D, G>::is_empty() const
{
return false;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- complex_higher_window_p<D, P>::is_centered() const
+ complex_higher_window_p<D, G>::is_centered() const
{
return true;
}
diff --git a/milena/mln/core/image/complex_image.hh b/milena/mln/core/image/complex_image.hh
index 1cc5fe6..966f95d 100644
--- a/milena/mln/core/image/complex_image.hh
+++ b/milena/mln/core/image/complex_image.hh
@@ -51,20 +51,20 @@ namespace mln
{
// Forward declaration.
- template <unsigned D, typename P, typename V> class complex_image;
+ template <unsigned D, typename G, typename V> class complex_image;
namespace internal
{
- /// Data structure for \c mln::complex_image<P,V>.
- template <unsigned D, typename P, typename V>
- struct data< complex_image<D, P, V> >
+ /// Data structure for \c mln::complex_image.
+ template <unsigned D, typename G, typename V>
+ struct data< complex_image<D, G, V> >
{
- data(const p_complex<D, P>& pc,
+ data(const p_complex<D, G>& pc,
const metal::vec< D + 1, std::vector<V> >& values);
metal::vec< D + 1, std::vector<V> > values_;
- const p_complex<D, P> pc_;
+ const p_complex<D, G> pc_;
};
} // end of namespace mln::internal
@@ -73,9 +73,9 @@ namespace mln
namespace trait
{
- template <unsigned D, typename P, typename V>
- struct image_< complex_image<D, P, V> >
- : default_image_< V, complex_image<D, P, V> >
+ template <unsigned D, typename G, typename V>
+ struct image_< complex_image<D, G, V> >
+ : default_image_< V, complex_image<D, G, V> >
{
typedef trait::image::category::primary category;
@@ -92,8 +92,11 @@ namespace mln
// Site / domain.
typedef trait::image::localization::space localization;
- // FIXME: Likewise.
- typedef typename trait::image::space_from_point<P>::ret dimension;
+ /* FIXME: Depends on G. We could use
+ `trait::image::space_from_point<mln_site(G)>::ret' in most
+ cases (i.e., when G's site is a Point), but would not be
+ generic. */
+ typedef typename trait::image::dimension::none dimension;
// Extended domain.
typedef trait::image::ext_domain::none ext_domain;
@@ -106,11 +109,15 @@ namespace mln
/// \brief Image based on a complex.
///
- /// Values are stored on the vertices of the graph.
- template <unsigned D, typename P, typename V>
+ /// Values attached to each face of the complex.
+ ///
+ /// \arg p D The dimension of the complex.
+ /// \arg p G The geometry of the complex.
+ /// \arg p V The value type of the image.
+ template <unsigned D, typename G, typename V>
class complex_image
- : public internal::image_primary< V, p_complex<D, P>,
- complex_image<D, P, V> >
+ : public internal::image_primary< V, p_complex<D, G>,
+ complex_image<D, G, V> >
{
public:
/// Value associated type.
@@ -128,30 +135,30 @@ namespace mln
typedef typename std::vector<V>::const_reference rvalue;
/// Skeleton.
- typedef complex_image< D, tag::psite_<P>, tag::value_<V> > skeleton;
+ typedef complex_image< D, tag::psite_<G>, tag::value_<V> > skeleton;
public:
/// Constructors.
/// \{
complex_image();
- complex_image(const p_complex<D, P>& pc);
- complex_image(const p_complex<D, P>& pc,
+ complex_image(const p_complex<D, G>& pc);
+ complex_image(const p_complex<D, G>& pc,
const metal::vec< D + 1, std::vector<V> >& values);
/// \}
/// Initialize an empty image.
- void init_(const p_complex<D, P>& pc,
+ void init_(const p_complex<D, G>& pc,
const metal::vec< D + 1, std::vector<V> >& values);
/// Read-only access of face value at point site \p p.
- rvalue operator()(const complex_psite<D, P>& p) const;
+ rvalue operator()(const complex_psite<D, G>& p) const;
/// Read-write access of face value at point site \p p.
- lvalue operator()(const complex_psite<D, P>& p);
+ lvalue operator()(const complex_psite<D, G>& p);
/// Accessors.
/// \{
/// Return the domain of psites od the image.
- const p_complex<D, P>& domain() const;
+ const p_complex<D, G>& domain() const;
/// Return the array of values associated to the faces.
const metal::vec<D + 1, std::vector<V> >& values() const;
@@ -159,10 +166,10 @@ namespace mln
};
// Fwd decl.
- template <unsigned D, typename P, typename V, typename W>
+ template <unsigned D, typename G, typename V, typename W>
void init_(tag::image_t,
- complex_image<D, P, V>& target,
- const complex_image<D, P, W>& model);
+ complex_image<D, G, V>& target,
+ const complex_image<D, G, W>& model);
# ifndef MLN_INCLUDE_ONLY
@@ -171,11 +178,11 @@ namespace mln
| Initialization. |
`-----------------*/
- template <unsigned D, typename P, typename V, typename W>
+ template <unsigned D, typename G, typename V, typename W>
inline
void init_(tag::image_t,
- complex_image<D, P, V>& target,
- const complex_image<D, P, W>& model)
+ complex_image<D, G, V>& target,
+ const complex_image<D, G, W>& model)
{
metal::vec<D + 1, std::vector<V> > values;
for (unsigned i = 0; i <= D; ++i)
@@ -189,9 +196,9 @@ namespace mln
namespace internal
{
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- data< complex_image<D, P, V> >::data(const p_complex<D, P>& pc,
+ data< complex_image<D, G, V> >::data(const p_complex<D, G>& pc,
const metal::vec< D + 1, std::vector<V> >& values)
: values_(values),
pc_(pc)
@@ -211,15 +218,15 @@ namespace mln
| Construction. |
`---------------*/
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- complex_image<D, P, V>::complex_image()
+ complex_image<D, G, V>::complex_image()
{
}
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- complex_image<D, P, V>::complex_image(const p_complex<D, P>& pc)
+ complex_image<D, G, V>::complex_image(const p_complex<D, G>& pc)
{
metal::vec<D + 1, std::vector<V> > values;
for (unsigned i = 0; i <= D; ++i)
@@ -227,60 +234,60 @@ namespace mln
init_(pc, values);
}
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- complex_image<D, P, V>::complex_image(const p_complex<D, P>& pc,
+ complex_image<D, G, V>::complex_image(const p_complex<D, G>& pc,
const metal::vec< D + 1,
std::vector<V> >& values)
{
init_(pc, values);
}
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
void
- complex_image<D, P, V>::init_(const p_complex<D, P>& pc,
+ complex_image<D, G, V>::init_(const p_complex<D, G>& pc,
const metal::vec< D + 1, std::vector<V> >& values)
{
mln_precondition(! this->has_data());
this->data_ =
- new internal::data< complex_image<D, P, V> >(pc, values);
+ new internal::data< complex_image<D, G, V> >(pc, values);
}
/*---------------.
| Manipulation. |
`---------------*/
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- typename complex_image<D, P, V>::rvalue
- complex_image<D, P, V>::operator()(const complex_psite<D, P>& p) const
+ typename complex_image<D, G, V>::rvalue
+ complex_image<D, G, V>::operator()(const complex_psite<D, G>& p) const
{
mln_precondition(this->data_->pc_.has(p));
return this->data_->values_[p.n()][p.face_id()];
}
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- typename complex_image<D, P, V>::lvalue
- complex_image<D, P, V>::operator()(const complex_psite<D, P>& p)
+ typename complex_image<D, G, V>::lvalue
+ complex_image<D, G, V>::operator()(const complex_psite<D, G>& p)
{
mln_precondition(this->data_->pc_.has(p));
return this->data_->values_[p.n()][p.face_id()];
}
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
const metal::vec< D + 1, std::vector<V> >&
- complex_image<D, P, V>::values() const
+ complex_image<D, G, V>::values() const
{
return this->data_->values_;
}
- template <unsigned D, typename P, typename V>
+ template <unsigned D, typename G, typename V>
inline
- const p_complex<D, P>&
- complex_image<D, P, V>::domain() const
+ const p_complex<D, G>&
+ complex_image<D, G, V>::domain() const
{
mln_precondition(this->has_data());
return this->data_->pc_;
diff --git a/milena/mln/core/image/complex_lower_higher_neighborhood.hh b/milena/mln/core/image/complex_lower_higher_neighborhood.hh
index bb99e0e..459913a 100644
--- a/milena/mln/core/image/complex_lower_higher_neighborhood.hh
+++ b/milena/mln/core/image/complex_lower_higher_neighborhood.hh
@@ -46,19 +46,19 @@
namespace mln
{
// Forward declarations.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_fwd_piter;
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_bkd_piter;
/// \brief Neighborhood centered on a n-face of complex returning its
/// adjacent (n-1)-faces.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
class complex_lower_higher_neighborhood
- : public Neighborhood< complex_lower_higher_neighborhood<D, P> >
+ : public Neighborhood< complex_lower_higher_neighborhood<D, G> >
{
- typedef complex_lower_higher_neighborhood<D, P> self_;
+ typedef complex_lower_higher_neighborhood<D, G> self_;
public:
/// The associated complex iterators.
@@ -71,19 +71,19 @@ namespace mln
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// The type of site corresponding to the neighborhood.
typedef mln_site(psite) site;
/// \brief Site_Iterator type to browse the psites of the neighborhood
/// w.r.t. the ordering of vertices.
typedef
- complex_neighborhood_fwd_piter<complex_fwd_iter, P, self_> fwd_niter;
+ complex_neighborhood_fwd_piter<complex_fwd_iter, G, self_> fwd_niter;
/// \brief Site_Iterator type to browse the psites of the neighborhood
/// w.r.t. the reverse ordering of vertices.
typedef
- complex_neighborhood_bkd_piter<complex_bkd_iter, P, self_> bkd_niter;
+ complex_neighborhood_bkd_piter<complex_bkd_iter, G, self_> bkd_niter;
/// The default niter type.
typedef fwd_niter niter;
@@ -104,11 +104,11 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
// FIXME: Dummy.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
// FIXME: Change (dummy) type.
- const typename complex_lower_higher_neighborhood<D, P>::window&
- complex_lower_higher_neighborhood<D, P>::win() const
+ const typename complex_lower_higher_neighborhood<D, G>::window&
+ complex_lower_higher_neighborhood<D, G>::win() const
{
// FIXME: Dummy.
return *this;
diff --git a/milena/mln/core/image/complex_lower_higher_window_p.hh b/milena/mln/core/image/complex_lower_higher_window_p.hh
index 9b0d79d..f44a7c7 100644
--- a/milena/mln/core/image/complex_lower_higher_window_p.hh
+++ b/milena/mln/core/image/complex_lower_higher_window_p.hh
@@ -44,16 +44,16 @@
namespace mln
{
// Forward declarations.
- template <unsigned D, typename P> class complex_lower_higher_window_p;
- template <typename I, typename P, typename W> class complex_window_fwd_piter;
- template <typename I, typename P, typename W> class complex_window_bkd_piter;
+ template <unsigned D, typename G> class complex_lower_higher_window_p;
+ template <typename I, typename G, typename W> class complex_window_fwd_piter;
+ template <typename I, typename G, typename W> class complex_window_bkd_piter;
namespace trait
{
- template <unsigned D, typename P>
- struct window_< mln::complex_lower_higher_window_p<D,P> >
+ template <unsigned D, typename G>
+ struct window_< mln::complex_lower_higher_window_p<D,G> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::irregular support;
@@ -65,11 +65,11 @@ namespace mln
/// \brief Window centered on a n-face of complex returning its
/// adjacent (n-1)-faces as well as the center n-face.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
class complex_lower_higher_window_p
- : public Window< complex_lower_higher_window_p<D, P> >
+ : public Window< complex_lower_higher_window_p<D, G> >
{
- typedef complex_lower_higher_window_p<D, P> self_;
+ typedef complex_lower_higher_window_p<D, G> self_;
/// The complex iterators on the <em>adjacent</em> faces only
/// (without the center point).
/// \{
@@ -88,7 +88,7 @@ namespace mln
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// The type of site corresponding to the window.
typedef mln_site(psite) site;
@@ -98,12 +98,12 @@ namespace mln
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
typedef
- complex_window_fwd_piter<complex_fwd_iter, P, self_> fwd_qiter;
+ complex_window_fwd_piter<complex_fwd_iter, G, self_> fwd_qiter;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the reverse ordering of vertices.
typedef
- complex_window_bkd_piter<complex_bkd_iter, P, self_> bkd_qiter;
+ complex_window_bkd_piter<complex_bkd_iter, G, self_> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
@@ -126,16 +126,16 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- complex_lower_higher_window_p<D, P>::is_empty() const
+ complex_lower_higher_window_p<D, G>::is_empty() const
{
return false;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- complex_lower_higher_window_p<D, P>::is_centered() const
+ complex_lower_higher_window_p<D, G>::is_centered() const
{
return true;
}
diff --git a/milena/mln/core/image/complex_lower_neighborhood.hh b/milena/mln/core/image/complex_lower_neighborhood.hh
index 0c17bf5..a93298b 100644
--- a/milena/mln/core/image/complex_lower_neighborhood.hh
+++ b/milena/mln/core/image/complex_lower_neighborhood.hh
@@ -44,19 +44,19 @@
namespace mln
{
// Forward declarations.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_fwd_piter;
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_bkd_piter;
/// \brief Neighborhood centered on a n-face of complex returning its
/// adjacent (n-1)-faces.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
class complex_lower_neighborhood
- : public Neighborhood< complex_lower_neighborhood<D, P> >
+ : public Neighborhood< complex_lower_neighborhood<D, G> >
{
- typedef complex_lower_neighborhood<D, P> self_;
+ typedef complex_lower_neighborhood<D, G> self_;
public:
/// The associated complex iterators.
@@ -69,19 +69,19 @@ namespace mln
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// The type of site corresponding to the neighborhood.
typedef mln_site(psite) site;
/// \brief Site_Iterator type to browse the psites of the neighborhood
/// w.r.t. the ordering of vertices.
typedef
- complex_neighborhood_fwd_piter<complex_fwd_iter, P, self_> fwd_niter;
+ complex_neighborhood_fwd_piter<complex_fwd_iter, G, self_> fwd_niter;
/// \brief Site_Iterator type to browse the psites of the neighborhood
/// w.r.t. the reverse ordering of vertices.
typedef
- complex_neighborhood_bkd_piter<complex_bkd_iter, P, self_> bkd_niter;
+ complex_neighborhood_bkd_piter<complex_bkd_iter, G, self_> bkd_niter;
/// The default niter type.
typedef fwd_niter niter;
@@ -102,11 +102,11 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
// FIXME: Dummy.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
// FIXME: Change (dummy) type.
- const typename complex_lower_neighborhood<D, P>::window&
- complex_lower_neighborhood<D, P>::win() const
+ const typename complex_lower_neighborhood<D, G>::window&
+ complex_lower_neighborhood<D, G>::win() const
{
// FIXME: Dummy.
return *this;
diff --git a/milena/mln/core/image/complex_lower_window_p.hh b/milena/mln/core/image/complex_lower_window_p.hh
index aaa1e1e..1a50d8f 100644
--- a/milena/mln/core/image/complex_lower_window_p.hh
+++ b/milena/mln/core/image/complex_lower_window_p.hh
@@ -43,16 +43,16 @@
namespace mln
{
// Forward declarations.
- template <unsigned D, typename P> class complex_lower_window_p;
- template <typename I, typename P, typename W> class complex_window_fwd_piter;
- template <typename I, typename P, typename W> class complex_window_bkd_piter;
+ template <unsigned D, typename G> class complex_lower_window_p;
+ template <typename I, typename G, typename W> class complex_window_fwd_piter;
+ template <typename I, typename G, typename W> class complex_window_bkd_piter;
namespace trait
{
- template <unsigned D, typename P>
- struct window_< mln::complex_lower_window_p<D,P> >
+ template <unsigned D, typename G>
+ struct window_< mln::complex_lower_window_p<D,G> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::irregular support;
@@ -64,11 +64,11 @@ namespace mln
/// \brief Window centered on a n-face of complex returning its
/// adjacent (n-1)-faces as well as the center n-face.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
class complex_lower_window_p
- : public Window< complex_lower_window_p<D, P> >
+ : public Window< complex_lower_window_p<D, G> >
{
- typedef complex_lower_window_p<D, P> self_;
+ typedef complex_lower_window_p<D, G> self_;
/// The complex iterators on the <em>adjacent</em> faces only
/// (without the center point).
/// \{
@@ -87,7 +87,7 @@ namespace mln
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// The type of site corresponding to the window.
typedef mln_site(psite) site;
@@ -97,12 +97,12 @@ namespace mln
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
typedef
- complex_window_fwd_piter<complex_fwd_iter, P, self_> fwd_qiter;
+ complex_window_fwd_piter<complex_fwd_iter, G, self_> fwd_qiter;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the reverse ordering of vertices.
typedef
- complex_window_bkd_piter<complex_bkd_iter, P, self_> bkd_qiter;
+ complex_window_bkd_piter<complex_bkd_iter, G, self_> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
@@ -125,16 +125,16 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- complex_lower_window_p<D, P>::is_empty() const
+ complex_lower_window_p<D, G>::is_empty() const
{
return false;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- complex_lower_window_p<D, P>::is_centered() const
+ complex_lower_window_p<D, G>::is_centered() const
{
return true;
}
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index ed9474d..f155794 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -48,16 +48,16 @@ namespace mln
{
/*------------------------------------------.
- | complex_neighborhood_fwd_piter<I, P, N>. |
+ | complex_neighborhood_fwd_piter<I, G, N>. |
`------------------------------------------*/
/// \brief Forward iterator on complex neighborhood.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_fwd_piter
: public internal::site_relative_iterator_base< N,
- complex_neighborhood_fwd_piter<I, P, N> >
+ complex_neighborhood_fwd_piter<I, G, N> >
{
- typedef complex_neighborhood_fwd_piter<I, P, N> self_;
+ typedef complex_neighborhood_fwd_piter<I, G, N> self_;
typedef internal::site_relative_iterator_base< N, self_ > super_;
public:
@@ -104,23 +104,23 @@ namespace mln
/// Print an mln::complex_neighborhood_fwd_piter.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
std::ostream&
operator<<(std::ostream& ostr,
- const complex_neighborhood_fwd_piter<I, P, N>& p);
+ const complex_neighborhood_fwd_piter<I, G, N>& p);
/*------------------------------------------.
- | complex_neighborhood_bkd_piter<I, P, N>. |
+ | complex_neighborhood_bkd_piter<I, G, N>. |
`------------------------------------------*/
/// \brief Backward iterator on complex neighborhood.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
class complex_neighborhood_bkd_piter
: public internal::site_relative_iterator_base< N,
- complex_neighborhood_bkd_piter<I, P, N> >
+ complex_neighborhood_bkd_piter<I, G, N> >
{
- typedef complex_neighborhood_bkd_piter<I, P, N> self_;
+ typedef complex_neighborhood_bkd_piter<I, G, N> self_;
typedef internal::site_relative_iterator_base< N, self_ > super_;
public:
@@ -167,29 +167,29 @@ namespace mln
/// Print an mln::complex_neighborhood_bkd_piter.
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
std::ostream&
operator<<(std::ostream& ostr,
- const complex_neighborhood_bkd_piter<I, P, N>& p);
+ const complex_neighborhood_bkd_piter<I, G, N>& p);
# ifndef MLN_INCLUDE_ONLY
/*------------------------------------------.
- | complex_neighborhood_fwd_piter<I, P, N>. |
+ | complex_neighborhood_fwd_piter<I, G, N>. |
`------------------------------------------*/
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
- complex_neighborhood_fwd_piter<I, P, N>::complex_neighborhood_fwd_piter()
+ complex_neighborhood_fwd_piter<I, G, N>::complex_neighborhood_fwd_piter()
{
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
template <typename Pref>
inline
- complex_neighborhood_fwd_piter<I, P, N>::complex_neighborhood_fwd_piter(const Neighborhood<N>& nbh,
+ complex_neighborhood_fwd_piter<I, G, N>::complex_neighborhood_fwd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref)
{
this->change_target(exact(nbh));
@@ -197,81 +197,81 @@ namespace mln
mln_postcondition(!this->is_valid());
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
bool
- complex_neighborhood_fwd_piter<I, P, N>::is_valid_() const
+ complex_neighborhood_fwd_piter<I, G, N>::is_valid_() const
{
return iter_.is_valid();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
void
- complex_neighborhood_fwd_piter<I, P, N>::invalidate_()
+ complex_neighborhood_fwd_piter<I, G, N>::invalidate_()
{
iter_.invalidate();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
void
- complex_neighborhood_fwd_piter<I, P, N>::do_start_()
+ complex_neighborhood_fwd_piter<I, G, N>::do_start_()
{
iter_.start();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
void
- complex_neighborhood_fwd_piter<I, P, N>::do_next_()
+ complex_neighborhood_fwd_piter<I, G, N>::do_next_()
{
iter_.next();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
template <typename Pref>
inline
void
- complex_neighborhood_fwd_piter<I, P, N>::center_at(const Pref& c)
+ complex_neighborhood_fwd_piter<I, G, N>::center_at(const Pref& c)
{
super_::center_at(c);
iter_.center_at(this->center().face());
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
mln_psite(N)
- complex_neighborhood_fwd_piter<I, P, N>::compute_p_() const
+ complex_neighborhood_fwd_piter<I, G, N>::compute_p_() const
{
return psite(this->center().site_set(), iter_);
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
std::ostream&
operator<<(std::ostream& ostr,
- const complex_neighborhood_fwd_piter<I, P, N>& p)
+ const complex_neighborhood_fwd_piter<I, G, N>& p)
{
return ostr << p.unproxy_();
}
/*------------------------------------------.
- | complex_neighborhood_bkd_piter<I, P, N>. |
+ | complex_neighborhood_bkd_piter<I, G, N>. |
`------------------------------------------*/
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
- complex_neighborhood_bkd_piter<I, P, N>::complex_neighborhood_bkd_piter()
+ complex_neighborhood_bkd_piter<I, G, N>::complex_neighborhood_bkd_piter()
{
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
template <typename Pref>
inline
- complex_neighborhood_bkd_piter<I, P, N>::complex_neighborhood_bkd_piter(const Neighborhood<N>& nbh,
+ complex_neighborhood_bkd_piter<I, G, N>::complex_neighborhood_bkd_piter(const Neighborhood<N>& nbh,
const Pref& p_ref)
{
this->change_target(exact(nbh));
@@ -279,62 +279,62 @@ namespace mln
mln_postcondition(!this->is_valid());
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
bool
- complex_neighborhood_bkd_piter<I, P, N>::is_valid_() const
+ complex_neighborhood_bkd_piter<I, G, N>::is_valid_() const
{
return iter_.is_valid();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
void
- complex_neighborhood_bkd_piter<I, P, N>::invalidate_()
+ complex_neighborhood_bkd_piter<I, G, N>::invalidate_()
{
iter_.invalidate();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
void
- complex_neighborhood_bkd_piter<I, P, N>::do_start_()
+ complex_neighborhood_bkd_piter<I, G, N>::do_start_()
{
iter_.start();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
void
- complex_neighborhood_bkd_piter<I, P, N>::do_next_()
+ complex_neighborhood_bkd_piter<I, G, N>::do_next_()
{
iter_.next();
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
template <typename Pref>
inline
void
- complex_neighborhood_bkd_piter<I, P, N>::center_at(const Pref& c)
+ complex_neighborhood_bkd_piter<I, G, N>::center_at(const Pref& c)
{
super_::center_at(c);
iter_.center_at(this->center().face());
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
mln_psite(N)
- complex_neighborhood_bkd_piter<I, P, N>::compute_p_() const
+ complex_neighborhood_bkd_piter<I, G, N>::compute_p_() const
{
return psite(this->center().site_set(), iter_);
}
- template <typename I, typename P, typename N>
+ template <typename I, typename G, typename N>
inline
std::ostream&
operator<<(std::ostream& ostr,
- const complex_neighborhood_bkd_piter<I, P, N>& p)
+ const complex_neighborhood_bkd_piter<I, G, N>& p)
{
return ostr << p.unproxy_();
}
diff --git a/milena/mln/core/image/complex_window_piter.hh b/milena/mln/core/image/complex_window_piter.hh
index 62c6f86..085c18a 100644
--- a/milena/mln/core/image/complex_window_piter.hh
+++ b/milena/mln/core/image/complex_window_piter.hh
@@ -49,16 +49,16 @@ namespace mln
{
/*------------------------------------.
- | complex_window_fwd_piter<I, P, W>. |
+ | complex_window_fwd_piter<I, G, W>. |
`------------------------------------*/
/// \brief Forward iterator on complex window.
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
class complex_window_fwd_piter
: public internal::site_relative_iterator_base< W,
- complex_window_fwd_piter<I, P, W> >
+ complex_window_fwd_piter<I, G, W> >
{
- typedef complex_window_fwd_piter<I, P, W> self_;
+ typedef complex_window_fwd_piter<I, G, W> self_;
typedef internal::site_relative_iterator_base< W, self_ > super_;
public:
@@ -104,23 +104,23 @@ namespace mln
/// Print an mln::complex_window_fwd_piter.
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
std::ostream&
operator<<(std::ostream& ostr,
- const complex_window_fwd_piter<I, P, W>& p);
+ const complex_window_fwd_piter<I, G, W>& p);
/*------------------------------------.
- | complex_window_bkd_piter<I, P, W>. |
+ | complex_window_bkd_piter<I, G, W>. |
`------------------------------------*/
/// \brief Backward iterator on complex window.
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
class complex_window_bkd_piter
: public internal::site_relative_iterator_base< W,
- complex_window_bkd_piter<I, P, W> >
+ complex_window_bkd_piter<I, G, W> >
{
- typedef complex_window_bkd_piter<I, P, W> self_;
+ typedef complex_window_bkd_piter<I, G, W> self_;
typedef internal::site_relative_iterator_base< W, self_ > super_;
public:
@@ -166,29 +166,29 @@ namespace mln
/// Print an mln::complex_window_bkd_piter.
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
std::ostream&
operator<<(std::ostream& ostr,
- const complex_window_bkd_piter<I, P, W>& p);
+ const complex_window_bkd_piter<I, G, W>& p);
# ifndef MLN_INCLUDE_ONLY
/*------------------------------------.
- | complex_window_fwd_piter<I, P, W>. |
+ | complex_window_fwd_piter<I, G, W>. |
`------------------------------------*/
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
- complex_window_fwd_piter<I, P, W>::complex_window_fwd_piter()
+ complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter()
{
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
template <typename Pref>
inline
- complex_window_fwd_piter<I, P, W>::complex_window_fwd_piter(const Window<W>& win,
+ complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter(const Window<W>& win,
const Pref& p_ref)
{
this->change_target(exact(win));
@@ -196,81 +196,81 @@ namespace mln
mln_postcondition(!this->is_valid());
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
bool
- complex_window_fwd_piter<I, P, W>::is_valid_() const
+ complex_window_fwd_piter<I, G, W>::is_valid_() const
{
return iter_.is_valid();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
void
- complex_window_fwd_piter<I, P, W>::invalidate_()
+ complex_window_fwd_piter<I, G, W>::invalidate_()
{
iter_.invalidate();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
void
- complex_window_fwd_piter<I, P, W>::do_start_()
+ complex_window_fwd_piter<I, G, W>::do_start_()
{
iter_.start();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
void
- complex_window_fwd_piter<I, P, W>::do_next_()
+ complex_window_fwd_piter<I, G, W>::do_next_()
{
iter_.next();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
template <typename Pref>
inline
void
- complex_window_fwd_piter<I, P, W>::center_at(const Pref& c)
+ complex_window_fwd_piter<I, G, W>::center_at(const Pref& c)
{
super_::center_at(c);
iter_.center_at(this->center().face());
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
mln_psite(W)
- complex_window_fwd_piter<I, P, W>::compute_p_() const
+ complex_window_fwd_piter<I, G, W>::compute_p_() const
{
return psite(this->center().site_set(), iter_);
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
std::ostream&
operator<<(std::ostream& ostr,
- const complex_window_fwd_piter<I, P, W>& p)
+ const complex_window_fwd_piter<I, G, W>& p)
{
return ostr << p.unproxy_();
}
/*------------------------------------.
- | complex_window_bkd_piter<I, P, W>. |
+ | complex_window_bkd_piter<I, G, W>. |
`------------------------------------*/
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
- complex_window_bkd_piter<I, P, W>::complex_window_bkd_piter()
+ complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter()
{
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
template <typename Pref>
inline
- complex_window_bkd_piter<I, P, W>::complex_window_bkd_piter(const Window<W>& win,
+ complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter(const Window<W>& win,
const Pref& p_ref)
{
this->change_target(exact(win));
@@ -278,62 +278,62 @@ namespace mln
mln_postcondition(!this->is_valid());
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
bool
- complex_window_bkd_piter<I, P, W>::is_valid_() const
+ complex_window_bkd_piter<I, G, W>::is_valid_() const
{
return iter_.is_valid();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
void
- complex_window_bkd_piter<I, P, W>::invalidate_()
+ complex_window_bkd_piter<I, G, W>::invalidate_()
{
iter_.invalidate();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
void
- complex_window_bkd_piter<I, P, W>::do_start_()
+ complex_window_bkd_piter<I, G, W>::do_start_()
{
iter_.start();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
void
- complex_window_bkd_piter<I, P, W>::do_next_()
+ complex_window_bkd_piter<I, G, W>::do_next_()
{
iter_.next();
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
template <typename Pref>
inline
void
- complex_window_bkd_piter<I, P, W>::center_at(const Pref& c)
+ complex_window_bkd_piter<I, G, W>::center_at(const Pref& c)
{
super_::center_at(c);
iter_.center_at(this->center().face());
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
mln_psite(W)
- complex_window_bkd_piter<I, P, W>::compute_p_() const
+ complex_window_bkd_piter<I, G, W>::compute_p_() const
{
return psite(this->center().site_set(), iter_);
}
- template <typename I, typename P, typename W>
+ template <typename I, typename G, typename W>
inline
std::ostream&
operator<<(std::ostream& ostr,
- const complex_window_bkd_piter<I, P, W>& p)
+ const complex_window_bkd_piter<I, G, W>& p)
{
return ostr << p.unproxy_();
}
diff --git a/milena/mln/core/site_set/complex_psite.hh b/milena/mln/core/site_set/complex_psite.hh
index 5dd476b..87aa5ce 100644
--- a/milena/mln/core/site_set/complex_psite.hh
+++ b/milena/mln/core/site_set/complex_psite.hh
@@ -50,31 +50,30 @@
namespace mln
{
// Forward declaration.
- template <unsigned D, typename P> class p_complex;
+ template <unsigned D, typename G> class p_complex;
/// \brief Point site associated to a mln::p_complex.
///
/// \arg \p D The dimension of the complex this psite belongs to.
- /// \arg \p P The type of point associated to this psite.
- template <unsigned D, typename P>
+ /// \arg \p G The geometry of the complex.
+ template <unsigned D, typename G>
class complex_psite
- : public internal::pseudo_site_base_< const P&,
- complex_psite<D, P> >
+ : public internal::pseudo_site_base_< const mln_site(G)&, complex_psite<D, G> >
{
public:
// This associated type is important to know that this particular
// pseudo site knows the site set it refers to.
- typedef p_complex<D, P> target;
+ typedef p_complex<D, G> target;
// FIXME: Document.
/// Construction and assignment.
/// \{
complex_psite();
/// \pre pc.cplx() == face.cplx().
- complex_psite(const p_complex<D, P>& pc,
+ complex_psite(const p_complex<D, G>& pc,
const topo::face<D>& face);
- complex_psite(const p_complex<D, P>& pc, unsigned n, unsigned face_id);
+ complex_psite(const p_complex<D, G>& pc, unsigned n, unsigned face_id);
/// \}
/// Psite manipulators.
@@ -101,7 +100,7 @@ namespace mln
/// Proxy manipulators.
/// \{
/// Return the site corresponding to this psite.
- const P& subj_();
+ const mln_site(G)& subj_();
/// \}
/// Face handle manipulators.
@@ -121,7 +120,7 @@ namespace mln
/// Update the site corresponding to this psite.
void update_();
// The site corresponding to this psite.
- P p_;
+ mln_site(G) p_;
/// \}
/* FIXME: Attributes pc_ and face_ share a common information: the
@@ -158,10 +157,10 @@ namespace mln
/// mln::p_complex.
/* FIXME: We probably want to relax this precondition: p_complex
equality is too strong; prefer complex equality. */
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator==(const complex_psite<D, P>& lhs,
- const complex_psite<D, P>& rhs);
+ operator==(const complex_psite<D, G>& lhs,
+ const complex_psite<D, G>& rhs);
/// \brief Is \a lhs not equal to \a rhs?
///
@@ -169,10 +168,10 @@ namespace mln
/// mln::p_complex.
/* FIXME: We probably want to relax this precondition: p_complex
equality is too strong; prefer complex equality. */
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator!=(const complex_psite<D, P>& lhs,
- const complex_psite<D, P>& rhs);
+ operator!=(const complex_psite<D, G>& lhs,
+ const complex_psite<D, G>& rhs);
/// \brief Is \a lhs ``less'' than \a rhs?
///
@@ -182,91 +181,102 @@ namespace mln
/// mln::p_complex.
/* FIXME: We probably want to relax this precondition: p_complex
equality is too strong; prefer complex equality. */
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator< (const complex_psite<D, P>& lhs,
- const complex_psite<D, P>& rhs);
+ operator< (const complex_psite<D, G>& lhs,
+ const complex_psite<D, G>& rhs);
/// \}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
std::ostream&
- operator<<(std::ostream& ostr, const complex_psite<D, P>& p);
+ operator<<(std::ostream& ostr, const complex_psite<D, G>& p);
# ifndef MLN_INCLUDE_ONLY
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- complex_psite<D, P>::complex_psite()
+ complex_psite<D, G>::complex_psite()
: pc_(0)
{
invalidate();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- complex_psite<D, P>::complex_psite(const p_complex<D, P>& pc,
+ complex_psite<D, G>::complex_psite(const p_complex<D, G>& pc,
const topo::face<D>& face)
: pc_(&pc),
face_(face)
{
// Check arguments consistency.
-// mln_precondition(pc.cplx() == face.cplx());
- update_();
+ // FIXME: Re-enable when the cyclic dependencies are fixed.
+#if 0
+ mln_precondition(pc.cplx() == face.cplx());
+#endif
+ if (is_valid())
+ update_();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- complex_psite<D, P>::complex_psite(const p_complex<D, P>& pc,
+ complex_psite<D, G>::complex_psite(const p_complex<D, G>& pc,
unsigned n, unsigned face_id)
: pc_(&pc),
face_(pc.cplx(), n, face_id)
{
- update_();
+ if (is_valid())
+ update_();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
bool
- complex_psite<D, P>::is_valid() const
+ complex_psite<D, G>::is_valid() const
{
-// mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+ // FIXME: Re-enable when the cyclic dependencies are fixed.
+#if 0
+ mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+#endif
return face_.is_valid();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
void
- complex_psite<D, P>::invalidate()
+ complex_psite<D, G>::invalidate()
{
return face_.invalidate();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- const p_complex<D, P>&
- complex_psite<D, P>::site_set() const
+ const p_complex<D, G>&
+ complex_psite<D, G>::site_set() const
{
mln_precondition(target_());
return *target_();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- const p_complex<D, P>*
- complex_psite<D, P>::target_() const
+ const p_complex<D, G>*
+ complex_psite<D, G>::target_() const
{
-// mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+ // FIXME: Re-enable when the cyclic dependencies are fixed.
+#if 0
+ mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+#endif
return pc_;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
void
- complex_psite<D, P>::change_target(const target& new_target)
+ complex_psite<D, G>::change_target(const target& new_target)
{
// Update both pc_ and face_.
pc_ = &new_target;
@@ -275,50 +285,52 @@ namespace mln
}
// FIXME: Write or extend a test to exercise this method (when the
- // handling of P is done, i.e., when update_ is complete).
- template <unsigned D, typename P>
+ // handling of G is done, i.e., when update_ is complete).
+ template <unsigned D, typename G>
inline
- const P&
- complex_psite<D, P>::subj_()
+ const mln_site(G)&
+ complex_psite<D, G>::subj_()
{
- // FIXME: Member p_ is not updated correctly yet; do not use this
- // method for now.
- abort();
return p_;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
const topo::face<D>&
- complex_psite<D, P>::face() const
+ complex_psite<D, G>::face() const
{
return face_;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
unsigned
- complex_psite<D, P>::n() const
+ complex_psite<D, G>::n() const
{
return face_.n();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
unsigned
- complex_psite<D, P>::face_id() const
+ complex_psite<D, G>::face_id() const
{
return face_.face_id();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
void
- complex_psite<D, P>::update_()
+ complex_psite<D, G>::update_()
{
mln_precondition(is_valid());
-// mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
- // FIXME: Implement (update p_).
+ // FIXME: Re-enable when the cyclic dependencies are fixed.
+#if 0
+ mln_invariant(!pc_ || pc_.cplx() == face_.cplx());
+#endif
+ // FIXME: Simplify? (I.e., add accessors to shorten the following
+ // line?)
+ p_ = site_set().geom()(face_);
}
@@ -326,28 +338,28 @@ namespace mln
| Comparisons. |
`--------------*/
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator==(const complex_psite<D, P>& lhs,
- const complex_psite<D, P>& rhs)
+ operator==(const complex_psite<D, G>& lhs,
+ const complex_psite<D, G>& rhs)
{
mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() == rhs.face();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator!=(const complex_psite<D, P>& lhs,
- const complex_psite<D, P>& rhs)
+ operator!=(const complex_psite<D, G>& lhs,
+ const complex_psite<D, G>& rhs)
{
mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() != rhs.face();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator< (const complex_psite<D, P>& lhs,
- const complex_psite<D, P>& rhs)
+ operator< (const complex_psite<D, G>& lhs,
+ const complex_psite<D, G>& rhs)
{
mln_precondition(&lhs.site_set() == &rhs.site_set());
return lhs.face() < rhs.face();
@@ -358,10 +370,10 @@ namespace mln
| Pretty-printing. |
`------------------*/
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
std::ostream&
- operator<<(std::ostream& ostr, const complex_psite<D, P>& p)
+ operator<<(std::ostream& ostr, const complex_psite<D, G>& p)
{
return ostr << p.face();
}
diff --git a/milena/mln/core/site_set/p_complex.hh b/milena/mln/core/site_set/p_complex.hh
index 9613bd6..8f79961 100644
--- a/milena/mln/core/site_set/p_complex.hh
+++ b/milena/mln/core/site_set/p_complex.hh
@@ -43,31 +43,36 @@
# include <mln/core/site_set/p_complex_faces_piter.hh>
# endif
+# include <mln/geom/complex_geometry.hh>
+
+// FIXME: Have G default to mln::geom::complex_geom<D, P>? But we
+// don't know P...
+
namespace mln
{
// Forward declarations.
- template <unsigned D, typename P> class p_complex;
+ template <unsigned D, typename G> class p_complex;
- template <unsigned D, typename P> class p_complex_fwd_piter_;
- template <unsigned D, typename P> class p_complex_bkd_piter_;
+ template <unsigned D, typename G> class p_complex_fwd_piter_;
+ template <unsigned D, typename G> class p_complex_bkd_piter_;
// FIXME: Disabled (moved to the attic).
# if 0
- template <unsigned N, unsigned D, typename P>
+ template <unsigned N, unsigned D, typename G>
class p_complex_faces_fwd_piter_;
- template <unsigned N, unsigned D, typename P>
+ template <unsigned N, unsigned D, typename G>
class p_complex_faces_bkd_piter_;
# endif
namespace trait
{
- template <unsigned D, typename P>
- struct site_set_< p_complex<D, P> >
+ template <unsigned D, typename G>
+ struct site_set_< p_complex<D, G> >
{
typedef trait::site_set::nsites::known nsites;
- // FIXME: Depends on P!
+ // FIXME: Depends on G!
typedef trait::site_set::bbox::unknown bbox;
typedef trait::site_set::contents::fixed contents;
typedef trait::site_set::arity::unique arity;
@@ -75,7 +80,7 @@ namespace mln
} // end of namespace mln::trait
- /* FIXME: We should decide was P represents:
+ /* FIXME: We should decide was G represents:
- a unique site type for all faces of all dimensions?
(Acceptable for a first implementation -- the one currently
@@ -98,20 +103,25 @@ namespace mln
/* FIXME: Aggregate site data (location). */
- /// A complex psite set based on a the N-faces of a complex of
- /// dimension \tparam D (a \p D-complex).
- template <unsigned D, typename P>
+ /** \brief A complex psite set based on a the \N-faces of a complex
+ of dimension \tparam D (a \p D-complex).
+
+ \arg \p D The dimension of the complex.
+ \arg \p G A function object type, associating localization
+ information (geometry) to each face of the complex.
+ \see mln::geom::complex_geometry. */
+ template <unsigned D, typename G>
class p_complex
- : public internal::site_set_base_< complex_psite<D, P>, p_complex<D, P> >
+ : public internal::site_set_base_< complex_psite<D, G>, p_complex<D, G> >
{
- typedef p_complex<D, P> self_;
- typedef internal::site_set_base_< complex_psite<D, P>, self_ > super_;
+ typedef p_complex<D, G> self_;
+ typedef internal::site_set_base_< complex_psite<D, G>, self_ > super_;
public:
/// \brief Construct a complex psite set from a complex.
///
/// \param cplx The complex upon which the complex psite set is built.
- p_complex (const topo::complex<D>& cplx);
+ p_complex(const topo::complex<D>& cplx, const G& geom);
/// Associated types.
/// \{
@@ -119,13 +129,13 @@ namespace mln
typedef mln_site(super_) element;
/// Point_Site associated type.
- typedef complex_psite<D, P> psite;
+ typedef complex_psite<D, G> psite;
/// Forward Site_Iterator associated type.
- typedef p_complex_fwd_piter_<D, P> fwd_piter;
+ typedef p_complex_fwd_piter_<D, G> fwd_piter;
/// Backward Site_Iterator associated type.
- typedef p_complex_bkd_piter_<D, P> bkd_piter;
+ typedef p_complex_bkd_piter_<D, G> bkd_piter;
/// Site_Iterator associated type.
typedef fwd_piter piter;
@@ -168,6 +178,9 @@ namespace mln
/// Return the complex associated to the p_complex domain (mutable
/// version).
topo::complex<D>& cplx();
+
+ /// Return the geometry of the complex.
+ const G& geom() const;
/// \}
private:
@@ -185,6 +198,8 @@ namespace mln
where vertex and edge handles (named `id's) are not tied to a
specific graph. */
mutable topo::complex<D> cplx_;
+ /// Geometry of the complex.
+ G geom_;
};
@@ -192,9 +207,9 @@ namespace mln
///
/// Two mln::p_complex's are considered equal if they share the
/// same complex.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator==(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs);
+ operator==(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs);
/// \brief Inclusion of a mln::p_complex in another one.
///
@@ -204,49 +219,49 @@ namespace mln
///
/// \todo Refine this later, when we are able to express subcomplex
/// relations.
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator<=(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs);
+ operator<=(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs);
# ifndef MLN_INCLUDE_ONLY
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- p_complex<D, P>::p_complex(const topo::complex<D>& cplx)
- : cplx_(cplx)
+ p_complex<D, G>::p_complex(const topo::complex<D>& cplx, const G& geom)
+ : cplx_(cplx), geom_(geom)
{
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
unsigned
- p_complex<D, P>::nsites() const
+ p_complex<D, G>::nsites() const
{
return nfaces();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
std::size_t
- p_complex<D, P>::nfaces() const
+ p_complex<D, G>::nfaces() const
{
return cplx_.nfaces();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
bool
- p_complex<D, P>::is_valid() const
+ p_complex<D, G>::is_valid() const
{
return true;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
bool
- p_complex<D, P>::has(const psite& p) const
+ p_complex<D, G>::has(const psite& p) const
{
mln_precondition(is_valid());
return
@@ -256,49 +271,56 @@ namespace mln
(p.is_valid());
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
std::size_t
- p_complex<D, P>::memory_size() const
+ p_complex<D, G>::memory_size() const
{
// FIXME: Dummy; implement (see other site sets).
abort();
return 0;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
topo::complex<D>&
- p_complex<D, P>::cplx() const
+ p_complex<D, G>::cplx() const
{
mln_precondition(is_valid());
return cplx_;
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
topo::complex<D>&
- p_complex<D, P>::cplx()
+ p_complex<D, G>::cplx()
{
mln_precondition(is_valid());
return cplx_;
}
+ template <unsigned D, typename G>
+ const G&
+ p_complex<D, G>::geom() const
+ {
+ return geom_;
+ }
+
/*--------------.
| Comparisons. |
`--------------*/
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator==(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs)
+ operator==(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs)
{
/* FIXME: When actual location data is attached to a p_complex,
check also the equlity w.r.t. to these data. */
return lhs.cplx() == rhs.cplx();
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
bool
- operator<=(const p_complex<D, P>& lhs, const p_complex<D, P>& rhs)
+ operator<=(const p_complex<D, G>& lhs, const p_complex<D, G>& rhs)
{
/* FIXME: When actual location data is attached to a p_complex,
check also the equality w.r.t. to these data. */
diff --git a/milena/mln/core/site_set/p_complex_piter.hh b/milena/mln/core/site_set/p_complex_piter.hh
index b9ec30e..f2304a2 100644
--- a/milena/mln/core/site_set/p_complex_piter.hh
+++ b/milena/mln/core/site_set/p_complex_piter.hh
@@ -42,62 +42,62 @@ namespace mln
{
// Forward declarations.
- template <unsigned D, typename P> class p_complex;
+ template <unsigned D, typename G> class p_complex;
template <unsigned D> class complex_fwd_iter_;
template <unsigned D> class complex_bkd_iter_;
/*-----------------------------.
- | p_complex_fwd_piter_<D, P>. |
+ | p_complex_fwd_piter_<D, G>. |
`-----------------------------*/
- /// \brief Forward iterator on (all) the faces of an mln::p_complex<D, P>.
- template <unsigned D, typename P>
+ /// \brief Forward iterator on (all) the faces of an mln::p_complex<D, G>.
+ template <unsigned D, typename G>
class p_complex_fwd_piter_
: public internal::p_complex_piter_base_< topo::face_fwd_iter<D>,
- p_complex<D, P>,
- P,
- p_complex_fwd_piter_<D, P> >
+ p_complex<D, G>,
+ mln_site(G),
+ p_complex_fwd_piter_<D, G> >
{
- typedef p_complex_fwd_piter_<D, P> self_;
+ typedef p_complex_fwd_piter_<D, G> self_;
typedef internal::p_complex_piter_base_< topo::face_fwd_iter<D>,
- p_complex<D, P>,
- P,
+ p_complex<D, G>,
+ mln_site(G),
self_ > super_;
public:
/// Construction and assignment.
/// \{
p_complex_fwd_piter_();
- p_complex_fwd_piter_(const p_complex<D, P>& pc);
+ p_complex_fwd_piter_(const p_complex<D, G>& pc);
/// \}
};
/*-----------------------------.
- | p_complex_bkd_piter_<D, P>. |
+ | p_complex_bkd_piter_<D, G>. |
`-----------------------------*/
- /// \brief Backward iterator on (all) the faces of an mln::p_complex<D, P>.
- template <unsigned D, typename P>
+ /// \brief Backward iterator on (all) the faces of an mln::p_complex<D, G>.
+ template <unsigned D, typename G>
class p_complex_bkd_piter_
: public internal::p_complex_piter_base_< topo::face_bkd_iter<D>,
- p_complex<D, P>,
- P,
- p_complex_bkd_piter_<D, P> >
+ p_complex<D, G>,
+ mln_site(G),
+ p_complex_bkd_piter_<D, G> >
{
- typedef p_complex_bkd_piter_<D, P> self_;
+ typedef p_complex_bkd_piter_<D, G> self_;
typedef internal::p_complex_piter_base_< topo::face_bkd_iter<D>,
- p_complex<D, P>,
- P,
+ p_complex<D, G>,
+ mln_site(G),
self_ > super_;
public:
/// Construction and assignment.
/// \{
p_complex_bkd_piter_();
- p_complex_bkd_piter_(const p_complex<D, P>& pc);
+ p_complex_bkd_piter_(const p_complex<D, G>& pc);
/// \}
};
@@ -106,36 +106,36 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
/*-----------------------------.
- | p_complex_fwd_piter_<D, P>. |
+ | p_complex_fwd_piter_<D, G>. |
`-----------------------------*/
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_()
+ p_complex_fwd_piter_<D, G>::p_complex_fwd_piter_()
{
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- p_complex_fwd_piter_<D, P>::p_complex_fwd_piter_(const p_complex<D, P>& pc)
+ p_complex_fwd_piter_<D, G>::p_complex_fwd_piter_(const p_complex<D, G>& pc)
: super_(pc)
{
}
/*-----------------------------.
- | p_complex_bkd_piter_<D, P>. |
+ | p_complex_bkd_piter_<D, G>. |
`-----------------------------*/
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_()
+ p_complex_bkd_piter_<D, G>::p_complex_bkd_piter_()
{
}
- template <unsigned D, typename P>
+ template <unsigned D, typename G>
inline
- p_complex_bkd_piter_<D, P>::p_complex_bkd_piter_(const p_complex<D, P>& pc)
+ p_complex_bkd_piter_<D, G>::p_complex_bkd_piter_(const p_complex<D, G>& pc)
: super_(pc)
{
}
--
1.6.0.1
1
0
2580: Add a functor encoding the geometry of a complex using its 0-faces.
by Roland Levillain 16 Oct '08
by Roland Levillain 16 Oct '08
16 Oct '08
* mln/geom/complex_geometry.hh: New.
---
milena/ChangeLog | 6 +
milena/mln/geom/complex_geometry.hh | 217 +++++++++++++++++++++++++++++++++++
2 files changed, 223 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/geom/complex_geometry.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 36dd95d..afe3d11 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+ Add a functor encoding the geometry of a complex using its 0-faces.
+
+ * mln/geom/complex_geometry.hh: New.
+
+2008-10-16 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a multiple-site type.
* mln/util/multi_site.hh: New.
diff --git a/milena/mln/geom/complex_geometry.hh b/milena/mln/geom/complex_geometry.hh
new file mode 100644
index 0000000..2e44ad4
--- /dev/null
+++ b/milena/mln/geom/complex_geometry.hh
@@ -0,0 +1,217 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License.
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_GEOM_COMPLEX_GEOMETRY_HH
+# define MLN_GEOM_COMPLEX_GEOMETRY_HH
+
+/// \file mln/geom/complex_geometry.hh
+/// \brief A functor associating geometry (location) data to the faces
+/// of a complex.
+///
+/// \see mln::topo::complex.
+
+# include <vector>
+# include <set>
+
+# include <mln/topo/face.hh>
+
+# include <mln/util/multi_site.hh>
+# include <mln/util/tracked_ptr.hh>
+
+
+/* FIXME: Also provide functors where the locations are computed using
+ a function (useful for a complex on a regular grid/support. */
+
+/* FIXME: This class could probably be turned into something more
+ generic, usable for other other purpose, e.g. attaching sites to
+ graphs. */
+
+/* FIXME: Also provide another geometry type where everything is
+ stored even for n-face with n > 0. */
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ // Forward declaration.
+ namespace internal
+ {
+ template <typename P> struct complex_geometry_data;
+ }
+
+
+ /** \brief A functor returning the sites of the faces of a complex
+ where the locations of each 0-face is stored. Faces of higher
+ dimensions are computed.
+
+ \arg \p D The dimension of the complex.
+ \arg \p P The type of the location of a 0-face.
+
+ Locations of 0-face are usually points (hence the \p P above),
+ but can possibly be any (default-constructible) values.
+
+ The functor returns a std::vector of locations: 0-faces are
+ singletons, 1-faces are (usually) pairs, faces of higher
+ dimensions are arrays of locations.
+
+ Note that for consistency reasons w.r.t. the return type of
+ operator(), returned sites are always <em>arrays</em> of
+ locations attached to 0-faces; hence the returned singletons
+ (of locations) for 0-faces. */
+ template <unsigned D, typename P>
+ class complex_geometry
+ {
+ public:
+ typedef P location;
+ typedef util::multi_site<P> site;
+
+ public:
+ /// \brief Build a complex geometry object.
+ complex_geometry();
+
+ public:
+ /// \brief Populate the set of locations.
+ ///
+ /// Append a new location \a p. Return the index of the newly
+ /// created location (which should semantically match the id of
+ /// the corresonding 0-face in the complex).
+ unsigned add_location(const P& p);
+
+ /// \brief Retrieve the site associated to \a f.
+ site operator()(const mln::topo::face<D>& f) const;
+
+ private:
+ mln::util::tracked_ptr< internal::complex_geometry_data<P> > data_;
+ };
+
+
+ namespace internal
+ {
+ /// \brief The data stored in a complex_geometry object.
+ ///
+ /// \arg \p P The type of the location of a 0-face.
+ template <typename P>
+ struct complex_geometry_data
+ {
+ util::multi_site<P> zero_faces;
+ };
+ }
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <unsigned D, typename P>
+ inline
+ complex_geometry<D, P>::complex_geometry()
+ : data_(new internal::complex_geometry_data<P>())
+ {
+ }
+
+ template <unsigned D, typename P>
+ inline
+ unsigned
+ complex_geometry<D, P>::add_location(const P& p)
+ {
+ mln_precondition(data_);
+ // FIXME: These two lines are not thread safe.
+ data_->zero_faces.push_back(p);
+ return data_->zero_faces.size();
+ }
+
+ template <unsigned D, typename P>
+ inline
+ util::multi_site<P>
+ complex_geometry<D, P>::operator()(const mln::topo::face<D>& f) const
+ {
+ mln_precondition(data_);
+ site s;
+ s.reserve(1);
+ if (f.n() == 0)
+ {
+ // F is a 0-face.
+ mln_assertion(f.face_id() < data_->zero_faces.size());
+ s.push_back(data_->zero_faces[f.face_id()]);
+ }
+ else
+ {
+ // F is an n-face, with n > 0.
+ typedef std::vector < topo::face<D> > faces_t;
+ typedef std::set < topo::face<D> > faces_set_t;
+
+ // The adjacent m-faces.
+ faces_t m_faces = f.lower_dim_adj_faces();
+ // The set of (m-1)-face being built.
+ /* FIXME: This pattern is recurring in Milena---using an
+ std::set (or any fast associative container) to improve
+ the lookup speed of an std::vector; we should create a
+ class for this, a bit like mln::util::set, but with a
+ garantee on the order of insertion. */
+ faces_t work_faces;
+ faces_set_t work_faces_set;
+
+ // Iteratively compute the set of locations.
+ for (unsigned m = f.n() - 1; m > 0; --m)
+ {
+ for (typename faces_t::const_iterator g = m_faces.begin();
+ g != m_faces.end(); ++g)
+ {
+ faces_t m_minus_one_faces = g->lower_dim_adj_faces();
+ // Don't insert a face twice.
+ for (typename faces_t::const_iterator h =
+ m_minus_one_faces.begin();
+ h != m_minus_one_faces.end(); ++h)
+ if (work_faces_set.find(*h) == work_faces_set.end())
+ {
+ work_faces.push_back(*h);
+ work_faces_set.insert(*h);
+ }
+ }
+ work_faces.swap(m_faces);
+ work_faces.clear();
+ work_faces_set.clear();
+ }
+ for (typename faces_t::const_iterator g = m_faces.begin();
+ g != m_faces.end(); ++g)
+ {
+ mln_assertion(g->face_id() < data_->zero_faces.size());
+ s.push_back(data_->zero_faces[g->face_id()]);
+ }
+ }
+ return s;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of mln::geom
+
+ } // end of mln
+
+#endif // MLN_GEOM_COMPLEX_GEOMETRY_HH
--
1.6.0.1
1
0