/* -*- mona-c++ -*-
* Copyright (c) Leipzig, Madrid 2004 - 2008
* Max-Planck-Institute for Human Cognitive and Brain Science
* Max-Planck-Institute for Evolutionary Anthropology
* BIT, ETSI Telecomunicacion, UPM
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __mona2d_shapes_hh
#define __mona2d_shapes_hh
#include <set>
#include <libmona/defines.hh>
#include <libmona/factory.hh>
#include <libmona/plugin_handler.hh>
#include <libmona/2DVector.hh>
#include <libmona/3DVector.hh>
#include <libmona/2DImage.hh>
#include <libmona/3DImage.hh>
MONA_NAMESPACE_BEGIN
template <typename T>
struct less_then {
};
template <template <typename> class T, typename M>
class CShape {
public:
typedef std::set< T<int>, less_then<T<int> > > Flat;
typedef typename Flat::const_iterator const_iterator;
typedef M Mask;
typedef T<unsigned int> Size;
CShape();
virtual ~CShape();
const_iterator begin() const;
const_iterator end() const;
Mask get_mask()const;
Size get_size()const;
protected:
void insert(const T<int>& p);
private:
Flat _M_shape;
T<int> _M_size;
};
typedef CShape<T2DVector, C2DBitImage> C2DShape;
typedef CShape<T3DVector, C3DBitImage> C3DShape;
//typedef boost::shared_ptr<C2DShape> C2DShapePtr;
template <typename S, const char *P, const char *D>
class CShapeFactory: public TFactory<S> {
public:
CShapeFactory(char const *name);
virtual ~CShapeFactory();
virtual typename CShapeFactory::ProductPtr create(const CParsedOptions& options) const = 0;
static const std::string get_plugin_searchpattern(){
return std::string(P);
}
};
extern char const image2d_data[];
extern char const image3d_data[];
extern const char plugin_shape_pattern_2d[];
extern const char plugin_shape_pattern_3d[];
typedef CShapeFactory<C2DShape, plugin_shape_pattern_2d, image2d_data> C2DShapeFactory;
typedef CShapeFactory<C3DShape, plugin_shape_pattern_3d, image3d_data> C3DShapeFactory;
typedef TPluginHandler<C2DShapeFactory> C2DShapeHandler;
typedef TPluginHandler<C3DShapeFactory> C3DShapeHandler;
MONA_NAMESPACE_END
#endif