OpenWalnut  1.5.0dev
WSegmentationAlgo.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WSEGMENTATIONALGO_H
26 #define WSEGMENTATIONALGO_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <boost/variant.hpp>
32 
33 #include "core/common/WCondition.h"
34 #include "core/common/WPropertyTypes.h"
35 #include "core/dataHandler/WDataSetScalar.h"
36 
37 /**
38  * A base class for segmentation alorithms.
39  *
40  * \class WSegmentationAlgo
41  */
42 class WSegmentationAlgo : public boost::static_visitor< std::shared_ptr< WDataSetScalar > >
43 {
44 public:
45  //! A conveniant typedef.
46  typedef std::shared_ptr< WDataSetScalar > DataSetPtr;
47 
48  /**
49  * Standard constructor.
50  */
52 
53  /**
54  * Destructor.
55  */
56  virtual ~WSegmentationAlgo();
57 
58  /**
59  * Return a condition that indicates changes to the properties.
60  *
61  * \return The condition.
62  */
63  std::shared_ptr< WCondition > getCondition();
64 
65  /**
66  * Return the name of this algorithm.
67  * \return The name.
68  */
69  virtual std::string getName() = 0;
70 
71  /**
72  * Return a description of this algorithm.
73  * \return A description.
74  */
75  virtual std::string getDescription() = 0;
76 
77  /**
78  * Initialize all properties for this algorithm. This will call
79  * the respective properties() function.
80  *
81  * \param group The property group all new properties should be added to.
82  */
83  void initProperties( WPropGroup group );
84 
85  /**
86  * This is called to trigger the actual segmentation in the segmentation module.
87  *
88  * \param dataset The input dataset for segmentation.
89  * \return The segmentation result.
90  */
91  DataSetPtr segment( DataSetPtr dataset );
92 
93  /**
94  * Checks if any properties were changed.
95  * \return True, iff any properties were changed.
96  */
97  virtual bool propChanged() = 0;
98 
99  /**
100  * Tell the property group to hide itself.
101  *
102  * \param hide If true, the group will be hidden.
103  */
104  void hideProperties( bool hide );
105 
106 protected:
107  /**
108  * A virtual function that calls the correct segmentation operation.
109  * \return The resulting dataset.
110  */
111  virtual DataSetPtr applyOperation() = 0;
112 
113  /**
114  * Initialize your algorithms properties here.
115  */
116  virtual void properties() = 0;
117 
118  //! The property group of this segmentation algorithm.
119  WPropGroup m_properties;
120 
121  //! The condition indicating changed to the properties.
122  std::shared_ptr< WCondition > m_propCondition;
123 
124  //! A pointer to the currently processed dataset.
126 };
127 
128 #endif // WSEGMENTATIONALGO_H
A base class for segmentation alorithms.
virtual void properties()=0
Initialize your algorithms properties here.
virtual std::string getName()=0
Return the name of this algorithm.
std::shared_ptr< WDataSetScalar > DataSetPtr
A conveniant typedef.
std::shared_ptr< WCondition > getCondition()
Return a condition that indicates changes to the properties.
virtual ~WSegmentationAlgo()
Destructor.
virtual DataSetPtr applyOperation()=0
A virtual function that calls the correct segmentation operation.
DataSetPtr segment(DataSetPtr dataset)
This is called to trigger the actual segmentation in the segmentation module.
virtual bool propChanged()=0
Checks if any properties were changed.
std::shared_ptr< WCondition > m_propCondition
The condition indicating changed to the properties.
DataSetPtr m_dataSet
A pointer to the currently processed dataset.
virtual std::string getDescription()=0
Return a description of this algorithm.
WSegmentationAlgo()
Standard constructor.
void initProperties(WPropGroup group)
Initialize all properties for this algorithm.
void hideProperties(bool hide)
Tell the property group to hide itself.
WPropGroup m_properties
The property group of this segmentation algorithm.