FilterType::Pointer filter = FilterType::New();
filter->SetArgsInfo(args_info);
- filter->Update();
-
- if (filter->HasError()) {
- std::cout << filter->GetLastError() << std::endl;
+
+ try {
+ filter->Update();
+ } catch(std::runtime_error e) {
+ std::cout << e.what() << std::endl;
}
return EXIT_SUCCESS;
// Get results
itkGetConstMacro(FirstTracheaPoint, ImagePointType);
+ itkGetConstMacro(CarinaPoint, ImagePointType);
protected:
ExtractAirwayTreeInfoFilter();
// Results
ImagePointType m_FirstTracheaPoint;
+ ImagePointType m_CarinaPoint;
virtual void GenerateOutputInformation();
virtual void GenerateData();
// Get input pointer
input = dynamic_cast<const ImageType*>(itk::ProcessObject::GetInput(0));
- StartNewStepOrStop("Find bronchial bifurcations");
+ StartNewStep("Find bronchial bifurcations");
// Step 1 : extract skeleton
// Define the thinning filter
typedef itk::BinaryThinningImageFilter3D<ImageType, ImageType> ThinningFilterType;
--it;
}
if (it.IsAtEnd()) {
- this->SetLastError("ERROR: first point in the skeleton not found ! Abort");
+ throw clitk::ExceptionObject("ERROR: first point in the skeleton not found ! Abort");
return;
}
DD(skeleton->GetLargestPossibleRegion().GetIndex());
skeleton->TransformIndexToPhysicalPoint(listOfBifurcations[i].index, p);
DD(p);
}
-
+
+ // The first bifurcation is supposed to be the carina
+ skeleton->TransformIndexToPhysicalPoint(listOfBifurcations[0].index, m_CarinaPoint);
+ DD(listOfBifurcations[0].index);
+ DD(m_CarinaPoint);
}
//--------------------------------------------------------------------
clitk::ExtractAirwayTreeInfoFilter<ImageType>::
GenerateData()
{
- // Do not put some "startnewstep" here, because the object if
- // modified and the filter's pipeline it do two times. But it is
- // required to quit if MustStop was set before.
- if (GetMustStop()) return;
-
// If everything goes well, set the output
this->GraftOutput(skeleton); // not SetNthOutput
}
this->SetFilterBase(filter);
// Set global Options
- filter->SetStopOnError(this->GetStopOnError());
filter->SetArgsInfo(mArgsInfo);
filter->SetInput(input);
// Go !
filter->Update();
-
- // Check if error
- if (filter->HasError()) {
- SetLastError(filter->GetLastError());
- // No output
- return;
- }
// Write/Save results
typename ImageType::Pointer output = filter->GetOutput();