OpenStructure
Loading...
Searching...
No Matches
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-2020 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
30namespace ost { namespace img {
31
32class OpBase
33{
34public:
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
41class AndOp:public OpBase
42{
43public:
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
49class OrOp:public OpBase
50{
51public:
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
57class XorOp:public OpBase
58{
59public:
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};
64typedef boost::shared_ptr<OpBase> OpPtr;
65
66
68{
69public:
70 CompositeMask(const MaskPtr& lhs, const MaskPtr& rhs,const String& op);
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
89protected:
90 static OpBase* create_op_(const String& name);
94};
95
96}}//ns
97
98
99#endif /*COMPOSITE_MASK_HH_*/
virtual OpBase * Clone()
virtual String GetName() const
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const
static OpBase * create_op_(const String &name)
virtual void Shift(const Vec2 &v)
virtual void Expand(Real d)
virtual MaskPtr Clone()
virtual void Scale(Real d)
CompositeMask(const MaskPtr &lhs, const MaskPtr &rhs, const String &op)
CompositeMask(const CompositeMask &m)
virtual void Apply(MaskVisitor &v)
virtual bool IsInside(const Vec2 &v)
virtual String GetName() const =0
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const =0
virtual OpBase * Clone()=0
virtual OpBase * Clone()
virtual String GetName() const
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const
virtual OpBase * Clone()
virtual String GetName() const
virtual bool operator()(const MaskPtr &lhs, const MaskPtr &rhs, const Vec2 &v) const
#define DLLEXPORT_OST_IMG_BASE
float Real
Definition base.hh:44
std::string String
Definition base.hh:54
boost::shared_ptr< OpBase > OpPtr
boost::shared_ptr< MaskBase > MaskPtr
Definition base.dox:1