[go: up one dir, main page]

Menu

[r999]: / libmona / libmona / shapes.hh  Maximize  Restore  History

Download this file

104 lines (77 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
/* -*- 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