34 #include <vtkPolyData.h> 73 "Bronchoscopy Registration"),
76 mRecordTrackingWidget(NULL)
78 mVerticalLayout =
new QVBoxLayout(
this);
83 if (!mRecordTrackingWidget)
89 void BronchoscopyRegistrationWidget::setup()
91 mOptions =
profile()->getXmlSettings().descend(
"bronchoscopyregistrationwidget");
94 mSelectMeshWidget->setValueName(
"Centerline: ");
100 mProcessCenterlineButton =
new QPushButton(
"Process centerline");
101 connect(mProcessCenterlineButton, SIGNAL(clicked()),
this, SLOT(processCenterlineSlot()));
107 mRegisterButton =
new QPushButton(
"Register");
108 connect(mRegisterButton, SIGNAL(clicked()),
this, SLOT(registerSlot()));
112 mServices->acquisition(), mServices,
115 mRecordTrackingWidget->
getSessionSelector()->setHelp(
"Select bronchoscope path for registration");
118 mVerticalLayout->setMargin(0);
119 mVerticalLayout->addWidget(
new DataSelectWidget(mServices->view(), mServices->patient(),
this, mSelectMeshWidget));
121 this->selectSubsetOfBranches(mOptions.
getElement());
122 this->createMaxNumberOfGenerations(mOptions.
getElement());
123 this->useLocalRegistration(mOptions.
getElement());
124 this->createMaxLocalRegistrationDistance(mOptions.
getElement());
128 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseSubsetOfGenerations));
129 mVerticalLayout->addWidget(
createDataWidget(mServices->view(), mServices->patient(),
this, mMaxNumberOfGenerations));
130 mVerticalLayout->addWidget(mProcessCenterlineButton);
131 mVerticalLayout->addWidget(mRecordTrackingWidget);
132 mVerticalLayout->addWidget(
new CheckBoxWidget(
this, mUseLocalRegistration));
133 mVerticalLayout->addWidget(
createDataWidget(mServices->view(), mServices->patient(),
this, mMaxLocalRegistrationDistance));
134 mVerticalLayout->addWidget(mRegisterButton);
136 mVerticalLayout->addStretch();
144 void BronchoscopyRegistrationWidget::initializeTrackingService()
150 void BronchoscopyRegistrationWidget::processCenterlineSlot()
152 this->initializeTrackingService();
154 if(!mSelectMeshWidget->getMesh())
159 vtkPolyDataPtr centerline = mSelectMeshWidget->getMesh()->getVtkPolyData();
160 Transform3D rMd = mSelectMeshWidget->getMesh()->get_rMd();
162 if (mUseSubsetOfGenerations->getValue())
163 processedCenterline = mBronchoscopyRegistration->processCenterline(centerline, rMd, mMaxNumberOfGenerations->getValue());
165 processedCenterline = mBronchoscopyRegistration->processCenterline(centerline, rMd);
169 QString uid = mSelectMeshWidget->getMesh()->getUid() +
"_cl%1";
170 QString name = mSelectMeshWidget->getMesh()->getName()+
" cl_processed%1";
171 std::cout <<
"name: " << name << std::endl;
172 std::cout <<
"uid: " << uid << std::endl;
173 mMesh = mServices->patient()->createSpecificData<
Mesh>(uid, name);
175 mMesh->setVtkPolyData(processedCenterline);
176 mMesh->setColor(QColor(0, 0, 255, 255));
177 mServices->patient()->insertData(mMesh);
178 mServices->view()->autoShowData(mMesh);
181 void BronchoscopyRegistrationWidget::registerSlot()
183 if(!mBronchoscopyRegistration->isCenterlineProcessed())
189 Transform3D old_rMpr = mServices->patient()->get_rMpr();
195 if(trackerRecordedData_prMt.empty())
203 if(mUseLocalRegistration->getValue()){
204 std::cout <<
"Running local registration with max distance " << mMaxLocalRegistrationDistance->getValue() <<
" mm." << std::endl;
205 new_rMpr =
Transform3D(mBronchoscopyRegistration->runBronchoscopyRegistration(trackerRecordedData_prMt,old_rMpr,mMaxLocalRegistrationDistance->getValue()));
208 std::cout <<
"Running global registration." << std::endl;
209 new_rMpr =
Transform3D(mBronchoscopyRegistration->runBronchoscopyRegistration(trackerRecordedData_prMt,old_rMpr,0));
212 new_rMpr = new_rMpr*old_rMpr;
213 mServices->registration()->addPatientRegistration(new_rMpr,
"Bronchoscopy centerline to tracking data");
215 Eigen::Matrix4d display_rMpr = Eigen::Matrix4d::Identity();
216 display_rMpr = new_rMpr*display_rMpr;
217 std::cout <<
"New prMt: " << std::endl;
218 for (
int i = 0; i < 4; i++)
219 std::cout << display_rMpr.row(i) << std::endl;
225 void BronchoscopyRegistrationWidget::createMaxNumberOfGenerations(QDomElement root)
228 "Set max number of generations centerline", 4,
DoubleRange(0, 10, 1), 0,
233 void BronchoscopyRegistrationWidget::selectSubsetOfBranches(QDomElement root)
236 "Select branch generations to be used in registration",
false,
240 void BronchoscopyRegistrationWidget::useLocalRegistration(QDomElement root)
243 "Use local registration",
false,
247 void BronchoscopyRegistrationWidget::createMaxLocalRegistrationDistance(QDomElement root)
250 "Set max distance for local registration in mm", 30,
DoubleRange(1, 200, 1), 0,
255 void BronchoscopyRegistrationWidget::clearDataOnNewPatient()
cxResource_EXPORT ProfilePtr profile()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void reportError(QString msg)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Utility class for describing a bounded numeric range.
QDomElement getElement()
return the current element
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
boost::shared_ptr< class RegServices > RegServicesPtr
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
static StringPropertySelectMeshPtr New(PatientModelServicePtr patientModelService)
std::map< double, Transform3D > TimedTransformMap
XmlOptionFile descend(QString element) const
step one level down in the xml tree
Namespace for all CustusX production code.