OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
composite_mask.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  Authors: Andreas Schenk, Ansgar Philippsen
23 */
24 
25 #ifndef COMPOSITE_MASK_HH_
26 #define COMPOSITE_MASK_HH_
27 
28 #include "mask_base.hh"
29 
30 namespace ost { namespace img {
31 
32 class OpBase
33 {
34 public:
35  virtual ~OpBase() {}
36  virtual OpBase* Clone()=0;
37  virtual bool operator()(const MaskPtr& lhs,const MaskPtr& rhs, const Vec2& v) const =0;
38  virtual String GetName() const =0;
39 };
40 
41 class AndOp:public OpBase
42 {
43 public:
44  virtual OpBase* Clone(){return new AndOp();}
45  virtual bool operator()(const MaskPtr& lhs,const MaskPtr& rhs, const Vec2& v) const;
46  virtual String GetName() const {return "AND";}
47 };
48 
49 class OrOp:public OpBase
50 {
51 public:
52  virtual OpBase* Clone(){return new OrOp();}
53  virtual bool operator()(const MaskPtr& lhs,const MaskPtr& rhs, const Vec2& v) const;
54  virtual String GetName() const {return "OR";}
55 };
56 
57 class XorOp:public OpBase
58 {
59 public:
60  virtual OpBase* Clone(){return new XorOp();}
61  virtual bool operator()(const MaskPtr& lhs,const MaskPtr& rhs, const Vec2& v) const;
62  virtual String GetName() const {return "XOR";}
63 };
64 typedef boost::shared_ptr<OpBase> OpPtr;
65 
66 
68 {
69 public:
70  CompositeMask(const MaskPtr& lhs, const MaskPtr& rhs,const String& op);
71  CompositeMask(const CompositeMask& m);
72 
74  return op_->GetName();
75  }
76 
77  virtual ~CompositeMask();
78  virtual MaskPtr Clone();
79  virtual bool IsInside(const Vec2& v);
80 
81  virtual void Shift(const Vec2& v);
82  virtual void Expand(Real d);
83  virtual void Scale(Real d);
84 
85  // traverse mask hierarchy with a visitor
86  virtual void Apply(MaskVisitor& v);
87 
88 
89 protected:
90  static OpBase* create_op_(const String& name);
94 };
95 
96 }}//ns
97 
98 
99 #endif /*COMPOSITE_MASK_HH_*/
ImageStateConstModOPAlgorithm< ShiftFnc > Shift
Definition: alg_shift.hh:73
virtual String GetName() const
virtual OpBase * Clone()
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const
virtual String GetName() const
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const =0
virtual String GetName() const =0
boost::shared_ptr< MaskBase > MaskPtr
Definition: mask_base_fw.hh:28
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const
virtual String GetName() const
boost::shared_ptr< OpBase > OpPtr
virtual OpBase * Clone()=0
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const
virtual OpBase * Clone()
virtual OpBase * Clone()
#define DLLEXPORT_OST_IMG_BASE