NorMIT-nav  18.04
An IGT application
cxAccusurfFilterService.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
13 
14 #include <ctkPluginContext.h>
15 #include "cxImage.h"
16 
17 #include "cxAlgorithmHelpers.h"
19 
20 #include "cxUtilHelpers.h"
22 #include "cxStringProperty.h"
23 #include "cxDoubleProperty.h"
24 #include "cxBoolProperty.h"
25 #include "cxTypeConversions.h"
26 #include "cxVolumeHelpers.h"
27 #include "cxAccusurf.h"
28 #include "cxPatientModelService.h"
29 #include "cxPointMetric.h"
30 #include "cxVisServices.h"
33 #include "cxViewService.h"
34 #include "cxLog.h"
35 
36 
37 namespace cx
38 {
39 
41  FilterImpl(services)
42 {
43 }
44 
45 QString AccusurfFilter::getName() const
46 {
47  return "ACCuSurf";
48 }
49 
50 QString AccusurfFilter::getType() const
51 {
52  return "accusurf_filter";
53 }
54 
55 QString AccusurfFilter::getHelp() const
56 {
57  return "<html>"
58  "<h3>Accusurf</h3>"
59  "<p>Filter to generate an ACCuSurf volume to be usen in navigated bronchoscopy."
60  "The ACCuSurf is generated based on a standard thorax CT and a route-to-target centerline."
61  "</p>"
62  "</html>";
63 }
64 
65 
67 {
70 }
71 
73 {
74  StringPropertySelectMeshPtr centerline;
75  centerline = StringPropertySelectMesh::New(mServices->patient());
76  centerline->setValueName("Route-to-Target");
77  centerline->setHelp("Select centerline");
78  mInputTypes.push_back(centerline);
79 
81  image = StringPropertySelectImage::New(mServices->patient());
82  image->setValueName("Input image");
83  image->setHelp("Select image input for ACCuSurf.");
84  //connect(image.get(), SIGNAL(dataChanged(QString)), this, SLOT(imageChangedSlot(QString)));
85  mInputTypes.push_back(image);
86 
87 }
88 
90 {
92 
93  image = StringPropertySelectData::New(mServices->patient());
94  image->setValueName("Output");
95  image->setHelp("Output ACCuSurf");
96  mOutputTypes.push_back(image);
97 }
98 
99 
101 {
102  mAccusurf.reset(new Accusurf());
103 
104  MeshPtr mesh = boost::dynamic_pointer_cast<StringPropertySelectMesh>(mInputTypes[0])->getMesh();
105 
106  ImagePtr inputImage = this->getCopiedInputImage(1);
107  if (!inputImage)
108  return false;
109 
110  vtkPolyDataPtr route_d_image = mesh->getTransformedPolyDataCopy((inputImage->get_rMd().inverse())*mesh->get_rMd());
111  mAccusurf->setRoutePositions(route_d_image);
112  mAccusurf->setInputImage(inputImage);
113 
116  mAccusurf->setThickness(thicknessUp->getValue(), thicknessDown->getValue());
117 
118  mAccusurfImage = mAccusurf->createAccusurfImage();
119 
120  return true;
121 }
122 
124 {
125  if (!mAccusurfImage)
126  return false;
127 
128  ImagePtr input = this->getCopiedInputImage(1);
129 
130  if (!input)
131  return false;
132 
133  QString uid = input->getUid() + "_ACCuSurf%1";
134  QString name = input->getName()+" ACCuSurf%1";
135  ImagePtr output = createDerivedImage(mServices->patient(),
136  uid, name,
137  mAccusurfImage, input);
138  output->mergevtkSettingsIntosscTransform();
139 
140  mAccusurfImage = NULL;
141  if (!output)
142  return false;
143 
144  mServices->patient()->insertData(output);
145 
146  // set output
147  mOutputTypes.front()->setValue(output->getUid());
148 
149  return true;
150 }
151 
152 
154 {
155  DoublePropertyPtr retval = DoubleProperty::initialize("ACCuSurf thickness anterior/up (voxels)", "",
156  "Set slice thickness up in voxels", 0, DoubleRange(0, 50, 1), 0,
157  root);
158  retval->setGuiRepresentation(DoublePropertyBase::grSLIDER);
159  return retval;
160 }
161 
163 {
164  DoublePropertyPtr retval = DoubleProperty::initialize("ACCuSurf thickness posterior/down (voxels)", "",
165  "Set slice thickness down in voxels", 15, DoubleRange(0, 50, 1), 0,
166  root);
167  retval->setGuiRepresentation(DoublePropertyBase::grSLIDER);
168  return retval;
169 }
170 
171 
172 } // namespace cx
173 
std::vector< SelectDataStringPropertyBasePtr > mInputTypes
Definition: cxFilterImpl.h:73
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:40
virtual QString getName() const
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
AccusurfFilter(VisServicesPtr services)
virtual QString getHelp() const
std::vector< PropertyPtr > mOptionsAdapters
Definition: cxFilterImpl.h:75
VisServicesPtr mServices
Definition: cxFilterImpl.h:82
ImagePtr createDerivedImage(PatientModelServicePtr dataManager, QString uid, QString name, vtkImageDataPtr raw, ImagePtr parent)
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
DoublePropertyPtr getAccusurfThicknessDown(QDomElement root)
DoublePropertyPtr getAccusurfThicknessUp(QDomElement root)
ImagePtr getCopiedInputImage(int index=0)
virtual QString getType() const
QDomElement mOptions
Definition: cxFilterImpl.h:76
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
std::vector< SelectDataStringPropertyBasePtr > mOutputTypes
Definition: cxFilterImpl.h:74
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
static StringPropertySelectMeshPtr New(PatientModelServicePtr patientModelService)
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
boost::shared_ptr< class Mesh > MeshPtr
boost::shared_ptr< class StringPropertySelectMesh > StringPropertySelectMeshPtr
Namespace for all CustusX production code.