CustusX  16.5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxTubeSegmentationFilterService.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXTUBESEGMENTATIONFILTERSERVICE_H_
34 #define CXTUBESEGMENTATIONFILTERSERVICE_H_
35 
36 #include "org_custusx_filter_tubesegmentation_Export.h"
37 
38 //#include "C:\Dev\cx\CustusX\CustusX\source\resource\filter\cxFilter.h"
39 //#include "C:\Dev\cx\CustusX\CustusX\source\resource\filter\cxFilterImpl.h"
40 #include "cxFilter.h"
41 #include "cxFilterImpl.h"
42 
43 #include <boost/unordered_map.hpp>
44 #include <boost/shared_ptr.hpp>
45 
46 #include "parameters.hpp"
47 #include "cxPatientModelService.h"
48 
49 #include "cxStringProperty.h"
50 #include "cxBoolProperty.h"
51 
52 class TSFOutput;
53 class ctkPluginContext;
54 
55 typedef vtkSmartPointer<class vtkImageData> vtkImageDataPtr;
56 typedef vtkSmartPointer<class vtkImageImport> vtkImageImportPtr;
57 
58 namespace cx {
59 typedef boost::shared_ptr<class TSFPresets> TSFPresetsPtr;
60 
73 class org_custusx_filter_tubesegmentation_EXPORT TubeSegmentationFilter : public FilterImpl
74 {
75 Q_OBJECT
76 Q_INTERFACES(cx::Filter)
77 
78 public:
79  TubeSegmentationFilter(ctkPluginContext *pluginContext);
80  virtual ~TubeSegmentationFilter();
81 
82  virtual QString getType() const;
83  virtual QString getName() const;
84  virtual QString getHelp() const;
85 
86  virtual bool hasPresets();
87  virtual PresetsPtr getPresets();
88  virtual QDomElement generatePresetFromCurrentlySetOptions(QString name);
89  virtual void requestSetPresetSlot(QString name);
90 
91  virtual bool execute();
92  virtual bool postProcess();
93 
94 protected:
95  virtual void createOptions();
96  virtual void createInputTypes();
97  virtual void createOutputTypes();
98 
99 private slots:
100  void patientChangedSlot();
101  void inputChangedSlot();
102  void loadNewParametersSlot();
103  void resetOptionsAdvancedSlot();
104  void resetOptionsSlot();
105  void setOptionsSlot(paramList& list);
106 
107 private:
108  vtkImageDataPtr convertToVtkImageData(char * data, int size_x, int size_y, int size_z, ImagePtr input);
109  vtkImageDataPtr convertToVtkImageData(float * data, int size_x, int size_y, int size_z, ImagePtr input);
110  vtkImageDataPtr importRawImageData(void * data, int size_x, int size_y, int size_z, ImagePtr input, int type);
111  MeshPtr loadVtkFile(QString pathToFile, QString newDatasUid);
112 
113  void createDefaultOptions(QDomElement root);
114  paramList getParametersFromOptions();
115  void setParamtersToOptions(paramList& parameters);
116 
117  StringPropertyPtr getStringOption(QString valueName);
118  BoolPropertyPtr getBoolOption(QString valueName);
119  DoublePropertyPtr getDoubleOption(QString valueName);
120  PropertyPtr getOption(QString valueName);
121  void setOptionAdvanced(QString valueName, bool advanced);
122  void setOptionValue(QString valueName, QString value);
123 
124  std::vector<std::string> getNotDefault(paramList list);
125  std::vector<std::string> getDifference(paramList list1, paramList list2);
126  std::vector<PropertyPtr> getNotDefaultOptions();
127  paramList getDefaultParameters();
128  void printParameters(paramList params);
129 
130  StringPropertyPtr makeStringOption(QDomElement root, std::string name, StringParameter parameter);
131  BoolPropertyPtr makeBoolOption(QDomElement root, std::string name, BoolParameter parameter);
132  DoublePropertyPtr makeDoubleOption(QDomElement root, std::string name, NumericParameter parameter);
133 
134  TSFPresetsPtr populatePresets();
135 
136  QString mParameterFile;
137 
138  std::vector<StringPropertyPtr> mStringOptions;
139  std::vector<BoolPropertyPtr> mBoolOptions;
140  std::vector<DoublePropertyPtr> mDoubleOptions;
141 
142  TSFOutput* mOutput;
143  paramList mParameters;
144 
145  TSFPresetsPtr mPresets;
146 
147 };
148 typedef boost::shared_ptr<class TubeSegmentationFilter> TubeSegmentationFilterPtr;
149 
150 } /* namespace cx */
151 #endif /* CXTUBESEGMENTATIONFILTERSERVICE_H_ */
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
boost::shared_ptr< class StringProperty > StringPropertyPtr
boost::shared_ptr< class TSFPresets > TSFPresetsPtr
Definition: cxTSFPresets.h:79
boost::shared_ptr< class Property > PropertyPtr
boost::shared_ptr< class Presets > PresetsPtr
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
boost::shared_ptr< class Mesh > MeshPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
boost::shared_ptr< class TubeSegmentationFilter > TubeSegmentationFilterPtr