Commit c8b45f16 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-09-20 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Add classes for classical 2d neighborhood.
	
	* oln/core/neighborhood_entry.hh: New.
	* oln/core/abstract/neighborhood.hh: New.
	* oln/core/2d/neighb2d.hh: New.
	* oln/core/gen/neighb.hh: New.
	* oln/core/2d/aliases.hh (neighb2d): New.
	* oln/basics2d.hh: Update.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@553 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 7b62e266
2006-09-20 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add classes for classical 2d neighborhood.
* oln/core/neighborhood_entry.hh: New.
* oln/core/abstract/neighborhood.hh: New.
* oln/core/2d/neighb2d.hh: New.
* oln/core/gen/neighb.hh: New.
* oln/core/2d/aliases.hh (neighb2d): New.
* oln/basics2d.hh: Update.
2006-09-18 Roland Levillain <roland@lrde.epita.fr>
Add the first two morphers: identity and neighborhood addition.
......
......@@ -50,6 +50,10 @@ namespace oln { template class bbox_bkd_piter_<point2d>; }
# include <oln/core/gen/topo_bbox.hh>
namespace oln { template class topo_bbox_<point2d>; }
# include <oln/core/gen/neighb.hh>
namespace oln { template class neighb_<dpoint2d>; }
# include <oln/core/2d/neighb2d.hh>
# include <oln/core/2d/image2d.hh>
......
......@@ -37,6 +37,7 @@ namespace oln
/// Forward declarations.
template <typename C> class point2d_;
template <typename C> class dpoint2d_;
template <typename D> class neighb_;
template <typename P> class bbox_;
template <typename P> class topo_bbox_;
template <typename P> class bbox_fwd_piter_;
......@@ -50,6 +51,8 @@ namespace oln
typedef point2d_<int> point2d;
typedef dpoint2d_<int> dpoint2d;
typedef neighb_<dpoint2d> neighb2d;
typedef bbox_<point2d> bbox2d;
typedef bbox_fwd_piter_<point2d> fwd_piter2d;
typedef bbox_bkd_piter_<point2d> bkd_piter2d;
......
// Copyright (C) 2001, 2002, 2003, 2004, 2006 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 OLENA_CORE_2D_NEIGHB2D_HH
# define OLENA_CORE_2D_NEIGHB2D_HH
# include <oln/core/gen/neighb.hh>
# include <oln/core/2d/aliases.hh>
namespace oln
{
neighb2d c4()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
the_
.add(dpoint2d(0, 1))
.add(dpoint2d(1, 0));
flower = false;
}
return the_;
}
neighb2d c8()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
the_
.add(dpoint2d(0, 1))
.add(dpoint2d(1,-1))
.add(dpoint2d(1, 0))
.add(dpoint2d(1, 1));
flower = false;
}
return the_;
}
neighb2d c2_row()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
the_
.add(dpoint2d(0, 1));
flower = false;
}
return the_;
}
neighb2d c2_col()
{
static bool flower = true;
static neighb2d the_;
if (flower)
{
the_
.add(dpoint2d(1, 0));
flower = false;
}
return the_;
}
} // end of namespace oln
#endif // ! OLENA_CORE_2D_NEIGHB2D_HH
// Copyright (C) 2006 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 OLENA_CORE_ABSTRACT_NEIGHBORHOOD_HH
# define OLENA_CORE_ABSTRACT_NEIGHBORHOOD_HH
# include <oln/core/typedefs.hh>
namespace oln
{
namespace abstract
{
/// Abstract neighborhood class.
template <typename E>
class neighborhood : public virtual stc::any__simple<E>,
public virtual oln::type
{
public:
bool is_valid() const
{
return this->exact().impl_is_valid();
}
struct decl
{
stc_virtual_typedef(grid);
decl() {
}
};
protected:
neighborhood()
{}
~neighborhood() { decl(); }
}; // end of class oln::abstract::neighborhood<E>
} // end of namespace oln::abstract
} // end of namespace oln
// # include <oln/core/abstract/neighborhood_hierarchies.hh>
#endif // ! OLENA_CORE_ABSTRACT_NEIGHBORHOOD_HH
// Copyright (C) 2001, 2003, 2004, 2005, 2006 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 OLENA_CORE_GEN_NEIGHB_HH
# define OLENA_CORE_GEN_NEIGHB_HH
# include <set>
# include <vector>
# include <oln/core/neighborhood_entry.hh>
namespace oln
{
// Forward declaration.
template <typename dpoint> class neighb_;
// Super type declaration.
template <typename dpoint>
struct set_super_type< neighb_<dpoint> >
{
typedef neighb_<dpoint> self_t;
typedef neighborhood_entry<self_t> ret;
};
/// Virtual types associated to oln::neighb_<dpoint>.
template <typename dpoint>
struct vtypes< neighb_<dpoint> >
{
typedef oln_type_of(dpoint, grid) grid_type;
};
/// Abstract forward dpoint iterator class.
template <typename dpoint>
class neighb_ : public neighborhood_entry< neighb_<dpoint> >,
private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
{
typedef neighb_<dpoint> self_t;
typedef neighborhood_entry<self_t> super_t;
public:
neighb_()
{
}
self_t& add(const dpoint& dp)
{
s_.insert(dp);
s_.insert(-dp);
update_();
return *this;
}
template <typename D>
self_t& add(const abstract::dpoint<D>& dp)
{
return this->add(dp.exact());
}
unsigned card() const
{
return v_.size();
}
dpoint dp(unsigned i) const
{
precondition(i < v_.size());
return v_[i];
}
// void print(std::ostream& ostr) const;
// friend std::ostream& operator<<(std::ostream& ostr, const neighb_<dpoint>& nbh);
protected:
std::set<dpoint> s_;
std::vector<dpoint> v_;
void update_()
{
v_.clear();
std::copy(s_.begin(), s_.end(),
std::back_inserter(v_));
}
}; // end of class oln::neighb_<dpoint>
} // end of namespace oln
#endif // ! OLENA_CORE_GEN_NEIGHB_HH
// Copyright (C) 2006 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 OLENA_CORE_NEIGHBORHOOD_ENTRY_HH
# define OLENA_CORE_NEIGHBORHOOD_ENTRY_HH
# include <oln/core/abstract/entry.hh>
# include <oln/core/abstract/neighborhood.hh>
namespace oln
{
/// Entry class for point sets: neighborhood_entry<E> is an alias for
/// entry< abstract::neighborhood, E>.
template <typename E>
struct neighborhood_entry : public entry< abstract::neighborhood, E>
{
protected:
neighborhood_entry() {}
};
/// Virtual types associated to neighborhood_entry<E>.
template <typename E>
struct vtypes< neighborhood_entry<E> >
{
typedef mlc::undefined grid_type;
};
} // end of namespace oln
#endif // ! OLENA_CORE_NEIGHBORHOOD_ENTRY_HH
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment