36 #include <boost/filesystem.hpp> 37 #include <boost/lexical_cast.hpp> 38 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the vtk deprecated warning 39 #include <vtkPoints.h> 40 #include <vtkPolyData.h> 41 #include <vtkPolyDataMapper.h> 43 #include <vtkProperty.h> 44 #include <vtkUnsignedCharArray.h> 45 #if VTK_MAJOR_VERSION > 5 46 #include <vtkAutoInit.h> 47 VTK_MODULE_INIT(vtkRenderingOpenGL);
48 VTK_MODULE_INIT(vtkRenderingFreeType);
49 #include <vtkOggTheoraWriter.h> 51 #if VTK_MAJOR_VERSION > 5 52 #include <vtkNamedColors.h> 54 #include <vtkSphereSource.h> 55 #include <vtkGlyph3D.h> 56 #include <vtkGlyph2D.h> 57 #include <vtkCubeAxesActor2D.h> 58 #include <vtkImageData.h> 59 #include <vtkGeometryFilter.h> 60 #include <vtkTubeFilter.h> 61 #include <vtkExtractEdges.h> 62 #include <vtkUnstructuredGrid.h> 64 #include <vtkPolygon.h> 65 #include <vtkIdList.h> 66 #include <vtkCellData.h> 67 #include <vtkFeatureEdges.h> 68 #include <vtkPointData.h> 69 #include <vtkLookupTable.h> 70 #include <vtkScalarBarActor.h> 71 #include <vtkTextProperty.h> 72 #include "UblasIncludes.hpp" 73 #include "UblasVectorInclude.hpp" 74 #include "Exception.hpp" 75 #include "BaseUnits.hpp" 76 #include "VesselNetworkWriter.hpp" 78 #include "VesselNetworkActorGenerator.hpp" 81 template<
unsigned DIM>
89 template<
unsigned DIM>
95 template<
unsigned DIM>
102 vtkSmartPointer<vtkPolyData> p_polydata = network_writer.
GetOutput();
103 vtkSmartPointer<vtkColorTransferFunction> p_scaled_ctf = vtkSmartPointer<vtkColorTransferFunction>::New();
104 if(!this->mDataLabel.empty())
107 p_polydata->GetPointData()->GetArray(this->mDataLabel.c_str())->GetRange(range);
108 for(
unsigned idx=0; idx<256; idx++)
112 p_scaled_ctf->AddRGBPoint(range[0] +
double(idx)*(range[1]-range[0])/255.0, color[0], color[1], color[2]);
117 vtkSmartPointer<vtkSphereSource> p_sheres = vtkSmartPointer<vtkSphereSource>::New();
118 p_sheres->SetRadius(this->mPointSize);
119 p_sheres->SetPhiResolution(16);
120 p_sheres->SetThetaResolution(16);
122 vtkSmartPointer<vtkGlyph3D> p_shere_glyphs = vtkSmartPointer<vtkGlyph3D>::New();
123 #if VTK_MAJOR_VERSION <= 5 124 p_shere_glyphs->SetInput(p_polydata);
125 p_shere_glyphs->SetSource(p_sheres->GetOutput());
127 p_shere_glyphs->SetInputData(p_polydata);
128 p_shere_glyphs->SetSourceData(p_sheres->GetOutput());
130 p_shere_glyphs->ClampingOff();
131 p_shere_glyphs->SetScaleModeToScaleByScalar();
132 p_shere_glyphs->SetScaleFactor(1.0);
134 vtkSmartPointer<vtkPolyDataMapper> p_polydata_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
135 #if VTK_MAJOR_VERSION <= 5 136 p_polydata_mapper->SetInput(p_shere_glyphs->GetOutput());
138 p_polydata_mapper->SetInputData(p_shere_glyphs->GetOutput());
140 p_polydata_mapper->ScalarVisibilityOn();
142 vtkSmartPointer<vtkActor> p_actor = vtkSmartPointer<vtkActor>::New();
143 p_actor->SetMapper(p_polydata_mapper);
145 pRenderer->AddActor(p_actor);
150 vtkSmartPointer<vtkPolyDataMapper> p_polydata_mapper2 = vtkSmartPointer<vtkPolyDataMapper>::New();
151 #if VTK_MAJOR_VERSION <= 5 152 p_polydata_mapper2->SetInput(p_polydata);
154 p_polydata_mapper2->SetInputData(p_polydata);
156 p_polydata_mapper2->ScalarVisibilityOn();
157 if(!this->mDataLabel.empty())
159 p_polydata_mapper2->SetLookupTable(p_scaled_ctf);
162 vtkSmartPointer<vtkActor> p_actor2 = vtkSmartPointer<vtkActor>::New();
163 p_actor2->SetMapper(p_polydata_mapper2);
165 pRenderer->AddActor(p_actor2);
170 vtkSmartPointer<vtkTubeFilter> p_tubes = vtkSmartPointer<vtkTubeFilter>::New();
171 #if VTK_MAJOR_VERSION <= 5 172 p_tubes->SetInput(p_polydata);
174 p_tubes->SetInputData(p_polydata);
176 p_tubes->SetRadius(this->mEdgeSize);
177 p_tubes->SetNumberOfSides(12);
179 vtkSmartPointer<vtkPolyDataMapper> p_tube_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
180 p_tube_mapper->SetInputConnection(p_tubes->GetOutputPort());
181 if(!this->mDataLabel.empty())
183 p_tube_mapper->SetLookupTable(p_scaled_ctf);
184 p_tube_mapper->ScalarVisibilityOn();
185 p_tube_mapper->InterpolateScalarsBeforeMappingOn();
186 p_tube_mapper->SelectColorArray(this->mDataLabel.c_str());
187 p_tube_mapper->SetScalarModeToUsePointFieldData();
188 p_tube_mapper->SetColorModeToMapScalars();
191 vtkSmartPointer<vtkActor> p_tube_actor = vtkSmartPointer<vtkActor>::New();
192 p_tube_actor->SetMapper(p_tube_mapper);
193 if(this->mDataLabel.empty())
198 pRenderer->AddActor(p_tube_actor);
200 if(!this->mDataLabel.empty())
202 vtkSmartPointer<vtkScalarBarActor> p_scale_bar = vtkSmartPointer<vtkScalarBarActor>::New();
203 p_scale_bar->SetLookupTable(p_scaled_ctf);
204 p_scale_bar->SetTitle(this->mDataLabel.c_str());
205 p_scale_bar->SetOrientationToHorizontal();
206 p_scale_bar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
207 p_scale_bar->GetPositionCoordinate()->SetValue(0.25, 0.84);
208 p_scale_bar->SetWidth(0.5);
209 p_scale_bar->SetHeight(0.1);
210 p_scale_bar->GetTitleTextProperty()->ItalicOff();
211 p_scale_bar->GetLabelTextProperty()->ItalicOff();
212 p_scale_bar->GetTitleTextProperty()->BoldOff();
213 p_scale_bar->GetLabelTextProperty()->BoldOff();
214 p_scale_bar->SetLabelFormat(
"%.2g");
215 p_scale_bar->GetTitleTextProperty()->SetFontSize(5.0);
216 p_scale_bar->GetLabelTextProperty()->SetFontSize(5.0);
217 p_scale_bar->GetTitleTextProperty()->SetColor(0.0, 0.0, 0.0);
218 p_scale_bar->GetLabelTextProperty()->SetColor(0.0, 0.0, 0.0);
220 pRenderer->AddActor(p_scale_bar);
226 template<
unsigned DIM>
c_vector< double, 3 > mEdgeColor
void AddActor(vtkSmartPointer< vtkRenderer > pRenderer)
VesselNetworkActorGenerator()
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pNetwork)
boost::shared_ptr< VesselNetwork< DIM > > mpVesselNetwork
c_vector< double, 3 > mPointColor
vtkSmartPointer< vtkColorTransferFunction > mpColorTransferFunction
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pVesselNetwork)
c_vector< double, 3 > mVolumeColor
vtkSmartPointer< vtkPolyData > GetOutput()
~VesselNetworkActorGenerator()