36 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3) 37 #include <vtkDoubleArray.h> 38 #include <vtkCellData.h> 39 #include <vtkCellArray.h> 40 #include <vtkPointData.h> 41 #include <vtkPolyData.h> 43 #include <vtkXMLPolyDataReader.h> 44 #include <vtkSmartPointer.h> 45 #include <vtkCleanPolyData.h> 46 #include <vtkSplineFilter.h> 47 #include <vtkVersion.h> 48 #include "Exception.hpp" 49 #include "VesselNetworkReader.hpp" 51 template<
unsigned DIM>
54 mRadiusLabel(
"Node Radius"),
55 mRadiusConversionFactor(1.0),
56 mMergeCoincidentPoints(false),
57 mTargetSegmentLength(0.0*
unit::metres),
58 mReferenceLength(1.e-6 *
unit::metres)
63 template<
unsigned DIM>
68 template <
unsigned DIM>
75 template <
unsigned DIM>
81 template <
unsigned DIM>
87 template <
unsigned DIM>
93 template <
unsigned DIM>
99 template<
unsigned DIM>
104 EXCEPTION(
"File name not set in vessel network reader");
111 vtkSmartPointer<vtkXMLPolyDataReader> p_reader = vtkSmartPointer<vtkXMLPolyDataReader>::New();
112 p_reader->SetFileName(
mFileName.c_str());
115 vtkSmartPointer<vtkPolyData> p_polydata = p_reader->GetOutput();
119 vtkSmartPointer<vtkCleanPolyData> p_cleaner = vtkSmartPointer<vtkCleanPolyData>::New();
120 #if VTK_MAJOR_VERSION <= 5 121 p_cleaner->SetInput(p_polydata);
123 p_cleaner->SetInputData(p_polydata);
126 p_polydata = p_cleaner->GetOutput();
131 vtkSmartPointer<vtkSplineFilter> p_spline_filter = vtkSmartPointer<vtkSplineFilter>::New();
132 #if VTK_MAJOR_VERSION <= 5 133 p_spline_filter->SetInput(p_polydata);
135 p_spline_filter->SetInputData(p_polydata);
137 p_spline_filter->SetSubdivideToLength();
139 p_spline_filter->Update();
140 p_polydata = p_spline_filter->GetOutput();
144 vtkSmartPointer<vtkPointData> p_point_data = vtkSmartPointer<vtkPointData>::New();
145 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes;
146 for (vtkIdType i = 0; i < p_polydata->GetNumberOfPoints(); i++)
148 double point_coords[3];
149 p_polydata->GetPoint(i, point_coords);
161 p_point_data = p_polydata->GetPointData();
162 std::vector<double> radii;
163 for (vtkIdType i = 0; i < p_point_data->GetNumberOfArrays(); i++)
165 std::string array_name = p_point_data->GetArrayName(i);
168 for (vtkIdType j = 0; j < p_point_data->GetArray(i)->GetNumberOfTuples(); j++)
170 radii.push_back(p_point_data->GetArray(i)->GetTuple1(j));
178 vtkSmartPointer<vtkCellArray> pCellArray = vtkSmartPointer<vtkCellArray>::New();
179 pCellArray = p_polydata->GetLines();
180 for (
int i = 0; i < p_polydata->GetNumberOfLines(); i++)
183 vtkIdType num_segments;
184 vtkIdType* pSegmentList;
185 pCellArray->GetNextCell(num_segments, pSegmentList);
186 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments;
188 for (
int j = 1; j < num_segments; j++)
190 boost::shared_ptr<VesselSegment<DIM> > p_segment =
VesselSegment<DIM>::Create(nodes[pSegmentList[j - 1]],nodes[pSegmentList[j]]);
191 if(
unsigned(radii.size())> pSegmentList[j])
195 segments.push_back(p_segment);
203 template<
unsigned DIM>
void SetMergeCoincidentPoints(bool mergePoints)
static boost::shared_ptr< VesselNetworkReader< DIM > > Create()
void SetReferenceLengthScale(units::quantity< unit::length > rReferenceLength)
units::quantity< unit::length > mReferenceLength
bool mMergeCoincidentPoints
static boost::shared_ptr< VesselNetwork< DIM > > Create()
units::quantity< unit::length > mTargetSegmentLength
boost::shared_ptr< VesselNetwork< DIM > > Read()
static boost::shared_ptr< VesselSegment< DIM > > Create(boost::shared_ptr< VesselNode< DIM > > pNode1, boost::shared_ptr< VesselNode< DIM > > pNode2)
void SetRadiusArrayName(const std::string &rRadius)
void SetTargetSegmentLength(units::quantity< unit::length > targetSegmentLength)
void SetFileName(const std::string &rFileName)