OpenWalnut  1.5.0dev
WSegmentationAlgo.cpp
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 #include <memory>
26 
27 #include "WSegmentationAlgo.h"
28 #include "core/common/exceptions/WPreconditionNotMet.h"
29 
31  : m_properties(),
32  m_propCondition( new WCondition() ),
33  m_dataSet()
34 {
35 }
36 
38 {
39 }
40 
41 std::shared_ptr< WCondition > WSegmentationAlgo::getCondition()
42 {
43  return m_propCondition;
44 }
45 
46 void WSegmentationAlgo::initProperties( WPropGroup group )
47 {
48  if( !m_properties )
49  {
50  m_properties = group;
51  properties();
52  }
53 }
54 
56 {
57  WPrecond( dataset, "Invalid dataset." );
58  m_dataSet = dataset;
59  DataSetPtr result = applyOperation();
61  return result;
62 }
63 
65 {
66  WPrecond( m_properties, "Missing properties." );
67  m_properties->setHidden( hide );
68 }
Class to encapsulate boost::condition_variable_any.
Definition: WCondition.h:42
virtual void properties()=0
Initialize your algorithms properties here.
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.
std::shared_ptr< WCondition > m_propCondition
The condition indicating changed to the properties.
DataSetPtr m_dataSet
A pointer to the currently processed dataset.
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.