Commit 949f3006 authored by Michel Pellegrin's avatar Michel Pellegrin
Browse files

Commit of Sandbox.

	* mln/core/internal/point_set_base.hh: Header.
	* mln/core/line2d.hh: No append in line2d.
	* mln/core/p_graph.hh: Typos.
	* mln/util/lazy_set.hh: Disambiguization.
	* sandbox/pellegrin/cond_inheritance/Makefile: .
	* sandbox/pellegrin/cond_inheritance/concept/point_set.hh: .
	* sandbox/pellegrin/cond_inheritance/internal/multi_set.hh: .
	* sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh: .
	* sandbox/pellegrin/cond_inheritance/internal/uni_set.hh: .
	* sandbox/pellegrin/cond_inheritance/p_array.hh: .
	* sandbox/pellegrin/cond_inheritance/p_set.hh: .
	* sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc: .
	* sandbox/pellegrin/first_test.cc: .
	* sandbox/pellegrin/set/Makefile: .
	* sandbox/pellegrin/set/core/concept/point_set.hh: New.
	* sandbox/pellegrin/set/core/concept: New.
	* sandbox/pellegrin/set/core/internal: New.
	* sandbox/pellegrin/set/core/line2d.hh: New.
	* sandbox/pellegrin/set/core/p_array.hh: New.
	* sandbox/pellegrin/set/core/p_bgraph.hh: New.
	* sandbox/pellegrin/set/core/p_graph.hh: New.
	* sandbox/pellegrin/set/core/p_line_graph.hh: New.
	* sandbox/pellegrin/set/core/p_priority_queue.hh: New.
	* sandbox/pellegrin/set/core/p_priority_queue_fast.hh: New.
	* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh: New.
	* sandbox/pellegrin/set/core/p_queue.hh: New.
	* sandbox/pellegrin/set/core/p_queue_fast.hh: New.
	* sandbox/pellegrin/set/core/p_set.hh: New.
	* sandbox/pellegrin/set/core/pset_if.hh: New.
	* sandbox/pellegrin/set/core/runs_psite.hh: New.
	* sandbox/pellegrin/set/core: New.
	* sandbox/pellegrin/set/multi_set.hh: .
	* sandbox/pellegrin/set/test_set.cc: .
	* sandbox/pellegrin/set/trait/point_set.hh: New.
	* sandbox/pellegrin/set/trait: New.
	* sandbox/pellegrin/set/types_de_points.txt: New.
	* sandbox/pellegrin/set/uni_set.hh: .

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1788 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 4b22e3bb
2008-03-19 Michel Pellegrin <pellegrin@lrde.epita.fr>
Commit of Sandbox.
* mln/core/internal/point_set_base.hh: Header.
* mln/core/line2d.hh: No append in line2d.
* mln/core/p_graph.hh: Typos.
* mln/util/lazy_set.hh: Disambiguization.
* sandbox/pellegrin/cond_inheritance/Makefile: .
* sandbox/pellegrin/cond_inheritance/concept/point_set.hh: .
* sandbox/pellegrin/cond_inheritance/internal/multi_set.hh: .
* sandbox/pellegrin/cond_inheritance/internal/point_set_base.hh: .
* sandbox/pellegrin/cond_inheritance/internal/uni_set.hh: .
* sandbox/pellegrin/cond_inheritance/p_array.hh: .
* sandbox/pellegrin/cond_inheritance/p_set.hh: .
* sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc: .
* sandbox/pellegrin/first_test.cc: .
* sandbox/pellegrin/set/Makefile: .
* sandbox/pellegrin/set/core/concept/point_set.hh: New.
* sandbox/pellegrin/set/core/concept: New.
* sandbox/pellegrin/set/core/internal: New.
* sandbox/pellegrin/set/core/line2d.hh: New.
* sandbox/pellegrin/set/core/p_array.hh: New.
* sandbox/pellegrin/set/core/p_bgraph.hh: New.
* sandbox/pellegrin/set/core/p_graph.hh: New.
* sandbox/pellegrin/set/core/p_line_graph.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh: New.
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh: New.
* sandbox/pellegrin/set/core/p_queue.hh: New.
* sandbox/pellegrin/set/core/p_queue_fast.hh: New.
* sandbox/pellegrin/set/core/p_set.hh: New.
* sandbox/pellegrin/set/core/pset_if.hh: New.
* sandbox/pellegrin/set/core/runs_psite.hh: New.
* sandbox/pellegrin/set/core: New.
* sandbox/pellegrin/set/multi_set.hh: .
* sandbox/pellegrin/set/test_set.cc: .
* sandbox/pellegrin/set/trait/point_set.hh: New.
* sandbox/pellegrin/set/trait: New.
* sandbox/pellegrin/set/types_de_points.txt: New.
* sandbox/pellegrin/set/uni_set.hh: .
2008-03-19 Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr>
Fix auto name substitution for vec and metal::math.
......
......@@ -45,7 +45,6 @@ namespace mln
/*! \internal A base class for point set classes.
* \p P is a point site type.
*
*/
template <typename P, typename E>
struct point_set_base_ : public Point_Set<E>
......
......@@ -71,9 +71,6 @@ namespace mln
/// Give the exact bounding box.
const box_<point2d>& bbox() const;
/// Append a point \p p.
line2d& append(const point2d& p);
/// Return the corresponding std::vector of points.
const std::vector<point2d>& vect() const;
......
......@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_CORE_GRAPH_P_HH
# define MLN_CORE_GRAPH_P_HH
#ifndef MLN_CORE_P_GRAPH_HH
# define MLN_CORE_P_GRAPH_HH
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
......
......@@ -220,7 +220,7 @@ namespace mln
s_.insert(elt);
if (needs_update_ == false)
needs_update_ = true;
return internal::force_exact< lazy_set_<E> >(*this);
return mln::internal::force_exact< lazy_set_<E> >(*this);
}
template <typename E>
......@@ -233,7 +233,7 @@ namespace mln
std::remove(s_.begin(), s_.end(), elt);
if (needs_update_ == false)
needs_update_ = true;
return internal::force_exact< lazy_set_<E> >(*this);
return mln::internal::force_exact< lazy_set_<E> >(*this);
}
template <typename E>
......
All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
-Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
-Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
-w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
-Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
-Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
-Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
-Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
-Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
-Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
-Wmissing-braces -Wmissing-field-initializers \
-Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
-Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
-Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
-Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
-Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
-Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
-Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
-Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
-Wwrite-strings \
all:
g++-4.2 -ansi -pedantic -I../../.. -I. test_cond_inherit.cc -o test
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -43,9 +43,8 @@ namespace mln
/*! \brief Point set class.
*
* This is a mathematical multi-set of points. The
* parameter \p P shall be a Point type.
* parameter \p E shall be a Point type.
*
* \todo All.
*/
template <typename E>
class p_array : public internal::point_set_base<p_array<E>, E>
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -42,10 +42,9 @@ namespace mln
/*! \brief Point set class.
*
* This is a mathematical uni-set of points. The
* parameter \p P shall be a Point type.
* This is a mathematical uni-set of points. The
* parameter \p E shall be a Point type.
*
* \todo All.
*/
template <typename E>
class p_set: public internal::point_set_base<p_set<E>, E>
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -27,7 +27,7 @@
/*! \file sandbox/pellegrin/cond_inheritance/test_cond_inherit.cc
*
* \brief test my work on conditional inheritance.
* \brief Test my work on conditional inheritance.
*/
#include <iostream>
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......
All_warnings = -ansi -pedantic -Wabi -Wctor-dtor-privacy -Wnon-virtual-dtor \
-Wreorder -Weffc++ -Wno-deprecated -Wstrict-null-sentinel \
-Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual \
-Wno-pmf-conversions -Wsign-promo -fsyntax-only-pedantic-errors \
-w -Wextra -Wall -Waddress -Waggregate-return -Wno-attributes \
-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
-Wno-deprecated-declarations -Wdisabled-optimization -Wno-div-by-zero \
-Wno-endif-labels -Werror -Wfatal-errors -Wfloat-equal -Wformat \
-Wformat=2 -Wno-format-extra-args -Wformat-nonliteral \
-Wformat-security -Wformat-y2k -Wimplicit -Wimport -Wno-import \
-Winit-self -Winline -Wno-invalid-offsetof -Winvalid-pch \
-Wlarger-than-1 -Wunsafe-loop-optimizations -Wlong-long \
-Wmissing-braces -Wmissing-field-initializers \
-Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
-Wno-multichar -Wno-overflow -Woverlength-strings -Wpacked -Wpadded \
-Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type \
-Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \
-Wstrict-aliasing -Wstrict-overflow -Wswitch -Wswitch-default \
-Wswitch-enum -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized \
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code -Wunused \
-Wunused-function -Wunused-label -Wunused-parameter -Wunused-value \
-Wunused-variable -Wvariadic-macros -Wvolatile-register-var \
-Wwrite-strings \
all:
g++-4.2 -ansi -pedantic -I../.. first_test.cc -o first_test
g++-4.2 -ansi -pedantic -I../../.. test_has.cc -o test_has
// Copyright (C) 2008 EPITA Research and Development Laboratory
//
// 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_CORE_CONCEPT_POINT_SET_HH
# define MLN_CORE_CONCEPT_POINT_SET_HH
/*! \file mln/core/concept/point_set.hh
*
* \brief Definition of the concept of mln::Point_Set.
*
* \todo Think about adding an 'insert' method (not so easy because of
* pset_if...)
*/
# include <mln/core/concept/point_site.hh>
# include <mln/core/concept/point_iterator.hh>
# include <mln/trait/point_set.hh>
namespace mln
{
// Fwd decl.
template <typename E> struct Point_Set;
/// Point_Set category flag type.
template <>
struct Point_Set<void>
{
typedef Object<void> super;
};
/*! \brief Base class for implementation classes of point sets.
*
* \see mln::doc::Point_Set for a complete documentation of this
* class contents.
*/
template <typename E>
struct Point_Set : public Object<E>
{
typedef Point_Set<void> category;
/*
typedef mesh;
typedef point;
typedef psite;
typedef fwd_piter;
typedef bkd_piter;
bool has(const psite& p) const;
const box_<point>& bbox() const;
std::size_t npoints() const;
*/
protected:
Point_Set();
};
/*! \brief Equality test between point sets \p lhs and \p rhs.
*
* \param[in] lhs A point set.
* \param[in] rhs Another point set.
*
* \relates mln::Point_Set
*/
template <typename Sl, typename Sr>
bool operator==(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
/*! \brief Inclusion test between point sets \p lhs and \p rhs.
*
* \param[in] lhs A point set (included?).
* \param[in] rhs Another point set (includer?).
*
* \relates mln::Point_Set
*/
template <typename Sl, typename Sr>
bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
/*! \brief Strict inclusion test between point sets \p lhs and \p
* rhs.
*
* \param[in] lhs A point set (strictly included?).
* \param[in] rhs Another point set (includer?).
*
* \relates mln::Point_Set
*/
template <typename Sl, typename Sr>
bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
/*! \brief Print a point set \p pset into the output stream \p
* ostr.
*
* \param[in,out] ostr An output stream.
* \param[in] pset A point set.
*
* \return The modified output stream \p ostr.
*
* \relates mln::Point_Set
*/
template <typename S>
std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
# ifndef MLN_INCLUDE_ONLY
// fwd decl
template <typename P> struct box_;
template <typename E>
inline
Point_Set<E>::Point_Set()
{
typedef mln_mesh(E) mesh;
typedef mln_point(E) point;
typedef mln_psite(E) psite;
typedef mln_fwd_piter(E) fwd_piter;
typedef mln_bkd_piter(E) bkd_piter;
typedef mln_trait_point_set_arity(P) arity;
typedef mln_trait_point_set_has_speed(P) has_speed;
bool (E::*m1)(const psite& p) const = & E::has;
m1 = 0;
const box_<point>& (E::*m2)() const = & E::bbox;
m2 = 0;
std::size_t (E::*m3)() const = & E::npoints;
m3 = 0;
}
// operators
template <typename Sl, typename Sr>
inline
bool operator==(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
{
// FIXME: Same grid!
const Sl& lhs = exact(lhs_);
const Sr& rhs = exact(rhs_);
// easy test:
if (lhs.npoints() != rhs.npoints())
return false;
// exhaustive test:
mln_fwd_piter(Sl) pl(lhs);
mln_fwd_piter(Sr) pr(rhs);
for (pl.start(), pr.start();
pl.is_valid() && pr.is_valid();
pl.next(), pr.next())
if (pl != pr)
return false; // difference found
// both sets are equal only if both browsings are completed
// at the same time:
return ! pl.is_valid() && ! pr.is_valid();
}
template <typename Sl, typename Sr>
inline
bool operator<=(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
{
// FIXME: Same grid!
const Sl& lhs = exact(lhs_);
const Sr& rhs = exact(rhs_);
// easy test:
if (lhs.npoints() > rhs.npoints())
return false;
// exhaustive test:
mln_piter(Sl) pl(lhs);
for_all(pl)
if (! rhs.has(pl))
return false;
return true;
}
template <typename Sl, typename Sr>
inline
bool operator<(const Point_Set<Sl>& lhs_, const Point_Set<Sr>& rhs_)
{
// FIXME: Same grid!
const Sl& lhs = exact(lhs_);
const Sr& rhs = exact(rhs_);
return lhs <= rhs && lhs.npoints() != rhs.npoints();
}
template <typename S>
inline
std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset_)
{
const S& pset = exact(pset_);
ostr << '{';
mln_piter(S) p(pset);
for_all(p)
ostr << p;
return ostr << '}';
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
# include <mln/core/ops.hh>
#endif // ! MLN_CORE_CONCEPT_POINT_SET_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// 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_CORE_LINE2D_HH
# define MLN_CORE_LINE2D_HH
/*! \file mln/core/line2d.hh
*
* \brief Definition of a point set class based on std::vector.
*/
# include <vector>
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
namespace mln
{
namespace trait
{
template <typename P>
struct point_set_<line2d> : public default_point_set_<P>
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
}
}
/*! \brief 2D line point set class.
*/
class line2d : public internal::point_set_base_< point2d, line2d >
{
public:
/// Forward Point_Iterator associated type.
typedef p_array_fwd_piter_<point2d> fwd_piter;
/// Backward Point_Iterator associated type.
typedef p_array_bkd_piter_<point2d> bkd_piter;
/// Constructor from point \p beg to point \p end.
line2d(const point2d& beg, const point2d& end);
/// Test is \p p belongs to this point set.
bool has(const point2d& p) const;
/// Give the number of points.
std::size_t npoints() const;
/// Give the exact bounding box.
const box_<point2d>& bbox() const;
/// Return the corresponding std::vector of points.
const std::vector<point2d>& vect() const;
/// Return the \p i-th point.
const point2d& operator[](unsigned i) const;
protected:
point2d beg_, end_;
std::vector<point2d> vect_;
box2d bb_;
void compute_();
};
# ifndef MLN_INCLUDE_ONLY
inline
line2d::line2d(const point2d& beg, const point2d& end)
: beg_(beg),
end_(end)
{
compute_();
}
inline
void
line2d::compute_()
{
// vect_
dpoint2d dp = end_ - beg_;
int