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 <vtkWindowToImageFilter.h> 40 #include <vtkPNGWriter.h> 41 #include <vtkPoints.h> 42 #include <vtkPolyData.h> 43 #include <vtkPolyDataMapper.h> 45 #include <vtkProperty.h> 46 #include <vtkUnsignedCharArray.h> 47 #if VTK_MAJOR_VERSION > 5 48 #include <vtkNamedColors.h> 50 #include <vtkSphereSource.h> 51 #include <vtkGlyph3D.h> 52 #include <vtkGlyph2D.h> 53 #include <vtkCubeAxesActor2D.h> 54 #include <vtkImageData.h> 55 #include <vtkInteractorStyleTrackballCamera.h> 56 #include <vtkObjectFactory.h> 57 #include <vtkActorCollection.h> 58 #include <vtkUnstructuredGrid.h> 59 #include <vtkGeometryFilter.h> 60 #include <vtkTubeFilter.h> 61 #include <vtkExtractEdges.h> 62 #include <vtkCamera.h> 63 #include <vtkVertexGlyphFilter.h> 64 #include <vtkUnstructuredGrid.h> 66 #include <vtkPolygon.h> 67 #include <vtkConvexPointSet.h> 68 #include <vtkIdList.h> 69 #include <vtkGeometryFilter.h> 71 #include <vtkTriangle.h> 73 #include <vtkFeatureEdges.h> 74 #include <vtkTextProperty.h> 75 #include <vtkCubeAxesActor.h> 76 #include "UblasIncludes.hpp" 77 #include "UblasVectorInclude.hpp" 78 #include "Exception.hpp" 79 #include "MicrovesselVtkScene.hpp" 80 #include "BaseUnits.hpp" 81 #include "VesselNetworkWriter.hpp" 90 virtual void OnLeftButtonDown()
93 vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
96 virtual void OnMiddleButtonDown()
99 vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
102 virtual void OnRightButtonDown()
105 vtkInteractorStyleTrackballCamera::OnRightButtonDown();
112 template<
unsigned DIM>
114 : mpRenderer(vtkSmartPointer<vtkRenderer>::New()),
115 mpRenderWindow(vtkSmartPointer<vtkRenderWindow>::New()),
116 mpRenderWindowInteractor(vtkSmartPointer<vtkRenderWindowInteractor>::New()),
118 mpColorLookUpTable(vtkSmartPointer<vtkLookupTable>::New()),
119 #if VTK_MAJOR_VERSION > 5
120 mAnimationWriter(vtkSmartPointer<vtkOggTheoraWriter>::New()),
122 mWindowToImageFilter(vtkSmartPointer<vtkWindowToImageFilter>::New()),
123 mIsInteractive(true),
124 mSaveAsAnimation(false),
125 mSaveAsImages(false),
127 mAddAnnotations(false),
135 mLengthScale(
BaseUnits::Instance()->GetReferenceLengthScale())
142 vtkSmartPointer<customMouseInteractorStyle> style = vtkSmartPointer<customMouseInteractorStyle>::New();
146 template<
unsigned DIM>
152 template<
unsigned DIM>
158 template<
unsigned DIM>
164 template<
unsigned DIM>
170 template<
unsigned DIM>
176 template<
unsigned DIM>
182 template<
unsigned DIM>
190 vtkSmartPointer<vtkActorCollection> p_actors =
mpRenderer->GetActors();
192 for( p_actors->InitTraversal(); (p_actor = p_actors->GetNextItem())!=NULL; )
222 vtkSmartPointer<vtkCubeAxesActor> p_cubeAxesActor = vtkSmartPointer<vtkCubeAxesActor>::New();
223 p_cubeAxesActor->SetBounds(
mpRenderer->ComputeVisiblePropBounds());
224 p_cubeAxesActor->SetCamera(
mpRenderer->GetActiveCamera());
225 p_cubeAxesActor->GetTitleTextProperty(0)->SetColor(0.0, 0.0, 0.0);
226 p_cubeAxesActor->GetLabelTextProperty(0)->SetColor(0.0, 0.0, 0.0);
227 p_cubeAxesActor->GetTitleTextProperty(1)->SetColor(0.0, 0.0, 0.0);
228 p_cubeAxesActor->GetLabelTextProperty(1)->SetColor(0.0, 0.0, 0.0);
229 p_cubeAxesActor->GetTitleTextProperty(2)->SetColor(0.0, 0.0, 0.0);
230 p_cubeAxesActor->GetLabelTextProperty(2)->SetColor(0.0, 0.0, 0.0);
231 p_cubeAxesActor->GetXAxesLinesProperty()->SetColor(0.0, 0.0, 0.0);
232 p_cubeAxesActor->GetYAxesLinesProperty()->SetColor(0.0, 0.0, 0.0);
233 p_cubeAxesActor->GetZAxesLinesProperty()->SetColor(0.0, 0.0, 0.0);
234 p_cubeAxesActor->DrawXGridlinesOff();
235 p_cubeAxesActor->DrawYGridlinesOff();
236 p_cubeAxesActor->DrawZGridlinesOff();
237 p_cubeAxesActor->XAxisMinorTickVisibilityOff();
238 p_cubeAxesActor->YAxisMinorTickVisibilityOff();
239 p_cubeAxesActor->ZAxisMinorTickVisibilityOff();
248 vtkSmartPointer<vtkPNGWriter> p_writer = vtkSmartPointer<vtkPNGWriter>::New();
249 p_writer->SetWriteToMemory(1);
253 p_writer->SetWriteToMemory(0);
254 p_writer->SetFileName((
mOutputFilePath+
"_"+boost::lexical_cast<std::string>(time_step)+
".png").c_str());
258 #if VTK_MAJOR_VERSION > 5 267 mAnimationWriter->Write();
277 template<
unsigned DIM>
283 template<
unsigned DIM>
289 template<
unsigned DIM>
295 template<
unsigned DIM>
301 template<
unsigned DIM>
307 template<
unsigned DIM>
313 template<
unsigned DIM>
319 template<
unsigned DIM>
325 template<
unsigned DIM>
331 template<
unsigned DIM>
334 #if VTK_MAJOR_VERSION > 5 337 mAnimationWriter->End();
342 template<
unsigned DIM>
360 #if VTK_MAJOR_VERSION > 5 363 mAnimationWriter->SetRate(1.0);
364 mAnimationWriter->Start();
378 template<
unsigned DIM>
vtkSmartPointer< vtkWindowToImageFilter > mWindowToImageFilter
vtkSmartPointer< vtkRenderWindowInteractor > mpRenderWindowInteractor
void SetOutputFilePath(const std::string &rPath)
boost::shared_ptr< VesselNetworkActorGenerator< DIM > > mpNetworkGenerator
vtkSmartPointer< vtkRenderer > mpRenderer
boost::shared_ptr< DiscreteContinuumMeshActorGenerator< DIM > > mpDiscreteContinuumMeshGenerator
void SetCellPopulation(boost::shared_ptr< AbstractCellPopulation< DIM > > pCellPopulation)
vtkSmartPointer< vtkRenderWindow > mpRenderWindow
boost::shared_ptr< CellPopulationActorGenerator< DIM > > mpCellPopulationGenerator
std::string mOutputFilePath
boost::shared_ptr< PartActorGenerator< DIM > > mpPartGenerator
void ResetRenderer(unsigned timeStep=0)
boost::shared_ptr< RegularGridActorGenerator< DIM > > mpGridGenerator