diff --git a/.github/workflows/test-vtk.yml b/.github/workflows/test-vtk.yml index 6b6e0b40..ce590c2d 100644 --- a/.github/workflows/test-vtk.yml +++ b/.github/workflows/test-vtk.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - vtk-version: ["8.2", "9.2"] + vtk-version: ["7.1", "8.2", "9.2"] steps: - name: checkout chaste @@ -56,12 +56,12 @@ jobs: notebook numpy parmetis - petsc - petsc4py + petsc<3.19 + petsc4py<3.19 pip setuptools six - sundials + sundials<7.0 tbb-devel vtk=${{ matrix.vtk-version }} wheel diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b58848c..829ed34e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,10 +30,30 @@ # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +#======================================== +# Setup PyChaste project +#======================================== + +# PyChaste needs the cell_based component (and its dependencies) find_package(Chaste COMPONENTS cell_based) +# Do Chaste project preprocessing, which does something like: +# add_custom_target(project_PyChaste) +# set(Chaste_project_PyChaste_SOURCE_DIR ...) +# set(Chaste_project_PyChaste_INCLUDE_DIRS ...) +# include_directories("${Chaste_THIRD_PARTY_INCLUDE_DIRS}") +# include_directories("${Chaste_project_PyChaste_INCLUDE_DIRS}") +# include_directories("${Chaste_INCLUDE_DIRS}") +# add_library(chaste_project_PyChaste ...) +# target_link_libraries(chaste_project_PyChaste ...) +chaste_do_project(PyChaste) + +# PyChaste needs the Python3 development libraries +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +target_link_libraries(Chaste_COMMON_DEPS INTERFACE Python3::Module Python3::Python) + # PyChaste needs some additional VTK libraries -if(VTK_MAJOR_VERSION LESS_EQUAL 6) +if(VTK_MAJOR_VERSION LESS 7) find_package(VTK REQUIRED COMPONENTS vtkInteractionStyle vtkIOImage @@ -44,7 +64,7 @@ if(VTK_MAJOR_VERSION LESS_EQUAL 6) vtkRenderingOpenGL vtkWrappingPythonCore ) -else() +elseif(VTK_MAJOR_VERSION LESS 9) find_package(VTK REQUIRED COMPONENTS vtkFiltersProgrammable vtkFiltersVerdict @@ -57,12 +77,156 @@ else() vtkRenderingOpenGL2 vtkWrappingPythonCore ) +else() + find_package(VTK REQUIRED COMPONENTS + FiltersProgrammable + FiltersVerdict + InteractionStyle + IOImage + IOMovie + IOOggTheora + RenderingAnnotation + RenderingCore + RenderingFreeType # needs Freetype::Freetype + RenderingOpenGL2 # needs X11::X11 and GLEW::GLEW + WrappingPythonCore # needs Python3::Module + ) endif() -list(APPEND Chaste_INCLUDES ${VTK_INCLUDE_DIRS}) -list(APPEND Chaste_project_PyChaste_INCLUDE_DIRS ${VTK_INCLUDE_DIRS}) -list(APPEND Chaste_THIRD_PARTY_LIBRARIES ${VTK_LIBRARIES}) -chaste_do_project(PyChaste) +if (VTK_MAJOR_VERSION LESS 9) + list(APPEND Chaste_INCLUDES "${VTK_INCLUDE_DIRS}") + list(APPEND Chaste_project_PyChaste_INCLUDE_DIRS "${VTK_INCLUDE_DIRS}") + list(APPEND Chaste_THIRD_PARTY_LIBRARIES "${VTK_LIBRARIES}") +else() + target_link_libraries(Chaste_COMMON_DEPS INTERFACE ${VTK_LIBRARIES}) +endif () + +#======================================== +# Compiler options +#======================================== +add_compile_options(-Wno-unused-local-typedefs) + +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # https://stackoverflow.com/questions/25365160/boostmultiprecisionfloat128-and-c11 + add_compile_options(-fext-numeric-literals) +endif() + +#======================================== +# PyChaste non-wrapper C++ code +#======================================== + +# Non-wrapper code locations +set(PYCHASTE_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR}/src/ + ${CMAKE_CURRENT_SOURCE_DIR}/src/cell_based/ + ${CMAKE_CURRENT_SOURCE_DIR}/src/ode/ + ${CMAKE_CURRENT_SOURCE_DIR}/src/tutorial/ + ${CMAKE_CURRENT_SOURCE_DIR}/src/visualization/) + +# Non-wrapper code needs to be put in a separate shared library +set(PYCHASTE_SHARED_LIB + "${CMAKE_CURRENT_BINARY_DIR}/libchaste_project_PyChaste${CMAKE_SHARED_LIBRARY_SUFFIX}") + +#======================================== +# Target for wrapper auto-generation +#======================================== +add_custom_target(project_PyChaste_Python_Bindings) +add_custom_command(TARGET project_PyChaste_Python_Bindings + COMMAND cppwg ${CMAKE_SOURCE_DIR} + -w ${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrappers + -p ${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrapper_generators/package_info.yaml + -i ${PYCHASTE_INCLUDE_DIRS} ${Chaste_INCLUDE_DIRS} ${Chaste_THIRD_PARTY_INCLUDE_DIRS} + --std c++17 +) + +#======================================== +# Build python modules from wrappers +#======================================== +include_directories(${PYCHASTE_INCLUDE_DIRS}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrappers) +include_directories(${PYTHON3_INCLUDE_DIRS}) + +add_subdirectory(dynamic/pybind11) + +# Copy python package structure to build directory, ignoring existing shared libraries +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/python/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/ + PATTERN "*${CMAKE_SHARED_LIBRARY_SUFFIX}" EXCLUDE) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/python/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/test/) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc/ + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/doc/) + +# List of modules to build into shared libraries +set (PYCHASTE_PYTHON_MODULES + # Modules with auto-generated wrappers + core + ode + pde + mesh + cell_based + visualization + tutorial + # Modules with manual wrappers + preload + tutorial_manual) + +# Locations to put each module library +set (PYCHASTE_PYTHON_MODULE_LOCATIONS + # Modules with auto-generated wrappers + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/core/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/ode/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/pde/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/mesh/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/cell_based/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/visualization/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/tutorial/ + # Modules with manual wrappers + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/ + ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/tutorial/) + +# The module library name must be the same as the pybind11 module name +# defined in the main wrapper e.g. `dynamic/wrappers/ode/ode.main.cpp` +# defines a pybind11 module `_chaste_project_PyChaste_ode`. By convention, +# the name starts with an underscore. The usual 'lib' prefix is disabled. +set(PYCHASTE_PYTHON_MODULE_PREFIX "_chaste_project_PyChaste_") + +# Create a shared library target for each module +list(LENGTH PYCHASTE_PYTHON_MODULES max_idx) +math(EXPR max_idx "${max_idx} - 1") + +foreach(idx RANGE ${max_idx}) + list(GET PYCHASTE_PYTHON_MODULES ${idx} module) + list(GET PYCHASTE_PYTHON_MODULE_LOCATIONS ${idx} module_dir) + + # Glob the module's wrapper code from the `dynamic` directory + file(GLOB module_sources ${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrappers/${module}/*.cpp) + + set(module_library_name ${PYCHASTE_PYTHON_MODULE_PREFIX}${module}) + add_library(${module_library_name} SHARED ${module_sources}) + + set_target_properties(${module_library_name} + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${module_dir} + PREFIX "${PYTHON_MODULE_PREFIX}" + SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}") + + # The order here is important - pybind11 and python come first + target_link_libraries(${module_library_name} + pybind11::module + ${Python3_LIBRARIES} + ${Chaste_THIRD_PARTY_LIBRARIES} + Chaste_COMMON_DEPS + ${Chaste_LIBRARIES} + ${PYCHASTE_SHARED_LIB}) + + add_dependencies(${module_library_name} chaste_project_PyChaste) +endforeach() -# Include the Python wrapping build logic -include(${CMAKE_CURRENT_SOURCE_DIR}/WrapPython.cmake) +# Target for building all module shared libraries +add_custom_target(project_PyChaste_Python) +foreach(module IN LISTS PYCHASTE_PYTHON_MODULES) + add_dependencies(project_PyChaste_Python ${PYCHASTE_PYTHON_MODULE_PREFIX}${module}) +endforeach() diff --git a/ProjectIncludes.cmake b/ProjectIncludes.cmake deleted file mode 100644 index a919baef..00000000 --- a/ProjectIncludes.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2005-2024, University of Oxford. -# All rights reserved. -# -# University of Oxford means the Chancellor, Masters and Scholars of the -# University of Oxford, having an administrative office at Wellington -# Square, Oxford OX1 2JD, UK. -# -# This file is part of Chaste. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * Neither the name of the University of Oxford nor the names of its -# contributors may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -######### Collect the include directories for the project. ###################### -set(PYCHASTE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/) -list (APPEND PYCHASTE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/cell_based) -list (APPEND PYCHASTE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/ode) -list (APPEND PYCHASTE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/tutorial) -list (APPEND PYCHASTE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/visualization) -list (APPEND PYCHASTE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dynamic) \ No newline at end of file diff --git a/WrapPython.cmake b/WrapPython.cmake deleted file mode 100644 index 376976e6..00000000 --- a/WrapPython.cmake +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (c) 2005-2024, University of Oxford. -# All rights reserved. -# -# University of Oxford means the Chancellor, Masters and Scholars of the -# University of Oxford, having an administrative office at Wellington -# Square, Oxford OX1 2JD, UK. -# -# This file is part of Chaste. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * Neither the name of the University of Oxford nor the names of its -# contributors may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -add_compile_options(-Wno-unused-local-typedefs) - -######### Find the dependencies for wrapper building ###################### -# Add any cmake modules defined in this project -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) - -# Find the Chaste and third party dependency header files. -include_directories(${Chaste_INCLUDE_DIRS} ${Chaste_THIRD_PARTY_INCLUDE_DIRS}) - -# Any non-wrapper code (code in the src folder) in this project needs to be put in its own shared library. -if(APPLE) - set(PYCHASTE_SHARED_LIB ${CMAKE_CURRENT_BINARY_DIR}/libchaste_project_PyChaste.dylib) -elseif(WIN32) - set(PYCHASTE_SHARED_LIB ${CMAKE_CURRENT_BINARY_DIR}/libchaste_project_PyChaste.dll) -else() - set(PYCHASTE_SHARED_LIB ${CMAKE_CURRENT_BINARY_DIR}/libchaste_project_PyChaste.so) -endif() - -# Collect the header directories for this project -include(${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludes.cmake) -include_directories(${PYCHASTE_INCLUDE_DIRS}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dynamic/) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrappers) - -if(CMAKE_COMPILER_IS_GNUCXX) - # https://svn.boost.org/trac/boost/ticket/9240 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") -endif() -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dynamic/pybind11/include) - -add_subdirectory(dynamic/pybind11) -include_directories(${PYTHON3_INCLUDE_DIRS}) - -######### Build the Python modules ###################### -set (PYCHASTE_PYTHON_AUTO_MODULES "") -set (PYCHASTE_PYTHON_MODULES "") -# The shared library corresponding to this module needs to be put in the correct place in the package tree after it is built, put the location here. -set (PYCHASTE_PYTHON_MODULE_LOCATIONS "") - -# Add each module to be built to this list. -# Modules with auto wrapping -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES core) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/core) -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES ode) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/ode) -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES pde) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/pde) -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES mesh) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/mesh) -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES cell_based) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/cell_based) -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES visualization) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/visualization) -list (APPEND PYCHASTE_PYTHON_AUTO_MODULES tutorial) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/tutorial) -list (APPEND PYCHASTE_PYTHON_MODULES ${PYCHASTE_PYTHON_AUTO_MODULES}) - -# Modules with manual wrapping -list (APPEND PYCHASTE_PYTHON_MODULES preload) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/) -list (APPEND PYCHASTE_PYTHON_MODULES tutorial_manual) -list (APPEND PYCHASTE_PYTHON_MODULE_LOCATIONS ${CMAKE_CURRENT_BINARY_DIR}/python/chaste/tutorial/) - -# Copy the Python package (i.e. all source files etc) to the build folder, ignore any shared libraries that might be in there. -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/python/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/ PATTERN "*.so" EXCLUDE) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test/python/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/test/) -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/python/doc/) - -# Target to generate bindings -add_custom_target(project_PyChaste_Python_Bindings) -add_custom_command( - TARGET project_PyChaste_Python_Bindings - COMMAND cppwg ${CMAKE_SOURCE_DIR} - -w ${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrappers - -p ${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrapper_generators/package_info.yaml - -i ${PYCHASTE_INCLUDE_DIRS} ${Chaste_INCLUDE_DIRS} ${Chaste_THIRD_PARTY_INCLUDE_DIRS} - --std c++17 -) - -# Loop through each module and create the shared library targets -list(LENGTH PYCHASTE_PYTHON_MODULES len1) -math(EXPR len2 "${len1} - 1") -foreach(val RANGE ${len2}) - list(GET PYCHASTE_PYTHON_MODULES ${val} python_module) - list(GET PYCHASTE_PYTHON_MODULE_LOCATIONS ${val} python_module_location) - - file(GLOB MODULE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/dynamic/wrappers/${python_module}/*.cpp) - - # each module is in the 'dynamic' directory. The library name must be the same as that defined in the cpp file. It is customary - # to start the name with an underscore. The usual 'lib' prefix is disabled. - add_library(_chaste_project_PyChaste_${python_module} SHARED ${MODULE_SOURCES}) - set_target_properties(_chaste_project_PyChaste_${python_module} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${python_module_location} - PREFIX "${PYTHON_MODULE_PREFIX}" SUFFIX ".so") - target_compile_features(_chaste_project_PyChaste_${python_module} PRIVATE cxx_range_for) - # order is important, pybind and python come first - target_link_libraries(_chaste_project_PyChaste_${python_module} pybind11::module ${PYTHON3_LIBRARIES} ${Chaste_THIRD_PARTY_LIBRARIES} ${Chaste_LIBRARIES} ${PYCHASTE_SHARED_LIB}) - add_dependencies(_chaste_project_PyChaste_${python_module} chaste_project_PyChaste) -endforeach() - -# Add a target so all the libraries are built with a single command -add_custom_target(project_PyChaste_Python) -foreach(val RANGE ${len2}) - list(GET PYCHASTE_PYTHON_MODULES ${val} python_module) - add_dependencies(project_PyChaste_Python _chaste_project_PyChaste_${python_module}) -endforeach() diff --git a/src/visualization/CellPopulationPyChasteActorGenerator.cpp b/src/visualization/CellPopulationPyChasteActorGenerator.cpp index 94d8cd0b..828148b5 100644 --- a/src/visualization/CellPopulationPyChasteActorGenerator.cpp +++ b/src/visualization/CellPopulationPyChasteActorGenerator.cpp @@ -106,15 +106,15 @@ CellPopulationPyChasteActorGenerator::~CellPopulationPyChasteActorGenerator template void CellPopulationPyChasteActorGenerator::AddCaBasedCellPopulationActor(vtkSmartPointer pRenderer) { - vtkSmartPointer p_potts_grid = vtkSmartPointer::New(); - vtkSmartPointer p_geom_filter = vtkSmartPointer::New(); + auto p_potts_grid = vtkSmartPointer::New(); + auto p_geom_filter = vtkSmartPointer::New(); boost::shared_ptr > p_ca_population = boost::dynamic_pointer_cast >(mpCellPopulation); if(p_ca_population && mShowPottsMeshEdges) { - vtkSmartPointer p_points = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); p_points->GetData()->SetName("Vertex positions"); unsigned counter = 0; @@ -148,28 +148,24 @@ void CellPopulationPyChasteActorGenerator::AddCaBasedCellPopulationActor(vt counter ++; } - vtkSmartPointer p_temp_polydata = vtkSmartPointer::New(); + auto p_temp_polydata = vtkSmartPointer::New(); p_temp_polydata->SetPoints(p_points); double bounds[6]; p_temp_polydata->GetBounds(bounds); - vtkSmartPointer p_ca_image = vtkSmartPointer::New(); + auto p_ca_image = vtkSmartPointer::New(); p_ca_image->SetDimensions(std::floor((bounds[1]-bounds[0])/spacing) + 1, std::floor((bounds[3]-bounds[2])/spacing) + 1, std::floor((bounds[5]-bounds[4])/spacing) + 1); p_ca_image->SetOrigin(bounds[0], bounds[2], bounds[4]); p_ca_image->SetSpacing(spacing, spacing, spacing); - #if VTK_MAJOR_VERSION <= 5 - p_geom_filter->SetInput(p_ca_image); - #else - p_geom_filter->SetInputData(p_ca_image); - #endif + p_geom_filter->SetInputData(p_ca_image); - vtkSmartPointer p_mapper = vtkSmartPointer::New(); + auto p_mapper = vtkSmartPointer::New(); p_mapper->SetInputConnection(p_geom_filter->GetOutputPort()); - vtkSmartPointer p_volume_actor = vtkSmartPointer::New(); + auto p_volume_actor = vtkSmartPointer::New(); p_volume_actor->SetMapper(p_mapper); p_volume_actor->GetProperty()->SetEdgeVisibility(this->mShowEdges); p_volume_actor->GetProperty()->SetLineWidth(this->mEdgeSize); @@ -181,14 +177,14 @@ void CellPopulationPyChasteActorGenerator::AddCaBasedCellPopulationActor(vt template void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor(vtkSmartPointer pRenderer) { - vtkSmartPointer p_potts_grid = vtkSmartPointer::New(); + auto p_potts_grid = vtkSmartPointer::New(); boost::shared_ptr > p_potts_population = boost::dynamic_pointer_cast >(mpCellPopulation); if(p_potts_population && mShowPottsMeshEdges) { - vtkSmartPointer p_points = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); p_points->GetData()->SetName("Vertex positions"); unsigned counter = 0; @@ -223,7 +219,7 @@ void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor counter ++; } - vtkSmartPointer p_temp_polydata = vtkSmartPointer::New(); + auto p_temp_polydata = vtkSmartPointer::New(); p_temp_polydata->SetPoints(p_points); double bounds[6]; @@ -237,11 +233,11 @@ void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor p_potts_grid->SetOrigin(bounds[0]-spacing/2.0, bounds[2]-spacing/2.0, bounds[4]-spacing/2.0); p_potts_grid->SetSpacing(spacing, spacing, spacing); - vtkSmartPointer p_element_ids = vtkSmartPointer::New(); + auto p_element_ids = vtkSmartPointer::New(); p_element_ids->SetNumberOfTuples(p_potts_grid->GetNumberOfPoints()); p_element_ids->SetName("Cell Id"); - vtkSmartPointer p_element_base_ids = vtkSmartPointer::New(); + auto p_element_base_ids = vtkSmartPointer::New(); p_element_base_ids->SetNumberOfTuples(p_potts_grid->GetNumberOfPoints()); p_element_base_ids->SetName("Cell Base Id"); for(unsigned idx=0; idxGetNumberOfPoints(); idx++) @@ -311,7 +307,7 @@ void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor p_potts_grid->GetCellData()->AddArray(p_element_ids); p_potts_grid->GetCellData()->AddArray(p_element_base_ids); - vtkSmartPointer p_scaled_ctf = vtkSmartPointer::New(); + auto p_scaled_ctf = vtkSmartPointer::New(); if(!mColorByCellData) { double range[2]; @@ -324,23 +320,23 @@ void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor } } - vtkSmartPointer p_geometry_filter_pre = - vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_geometry_filter_pre->SetInput(p_potts_grid); - #else - p_geometry_filter_pre->SetInputData(p_potts_grid); - #endif + auto p_geometry_filter_pre = vtkSmartPointer::New(); + p_geometry_filter_pre->SetInputData(p_potts_grid); - vtkSmartPointer p_threshold = vtkSmartPointer::New(); + auto p_threshold = vtkSmartPointer::New(); p_threshold->SetInputConnection(p_geometry_filter_pre->GetOutputPort()); + +#if VTK_MAJOR_VERSION < 9 p_threshold->ThresholdByUpper(0.0); +#else + p_threshold->SetUpperThreshold(0.0); +#endif p_threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "Cell Id"); - vtkSmartPointer p_geom_filter = vtkSmartPointer::New(); + auto p_geom_filter = vtkSmartPointer::New(); p_geom_filter->SetInputConnection(p_threshold->GetOutputPort()); - vtkSmartPointer p_mapper = vtkSmartPointer::New(); + auto p_mapper = vtkSmartPointer::New(); p_mapper->SetInputConnection(p_geom_filter->GetOutputPort()); p_mapper->SetLookupTable(p_scaled_ctf); p_mapper->ScalarVisibilityOn(); @@ -348,7 +344,7 @@ void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor p_mapper->SetScalarModeToUseCellData(); p_mapper->SetColorModeToMapScalars(); - vtkSmartPointer p_volume_actor = vtkSmartPointer::New(); + auto p_volume_actor = vtkSmartPointer::New(); p_volume_actor->SetMapper(p_mapper); //p_volume_actor->GetProperty()->SetEdgeVisibility(this->mShowEdges); p_volume_actor->GetProperty()->SetLineWidth(this->mEdgeSize); @@ -361,46 +357,41 @@ void CellPopulationPyChasteActorGenerator::AddPottsBasedCellPopulationActor if(mShowPottsMeshOutlines) { - vtkSmartPointer p_bounds = vtkSmartPointer::New(); + auto p_bounds = vtkSmartPointer::New(); for(unsigned idx=0; idxGetNumberOfCells(); idx++) { - vtkSmartPointer p_local_threshold = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_local_threshold->SetInput(p_geom_filter->GetOutput()); - #else - p_local_threshold->SetInputData(p_geom_filter->GetOutput()); - #endif - p_local_threshold->ThresholdBetween(p_element_base_ids->GetTuple1(idx), p_element_base_ids->GetTuple1(idx)); + auto p_local_threshold = vtkSmartPointer::New(); + p_local_threshold->SetInputData(p_geom_filter->GetOutput()); + +#if VTK_MAJOR_VERSION < 9 + p_local_threshold->ThresholdBetween(p_element_base_ids->GetTuple1(idx), + p_element_base_ids->GetTuple1(idx)); +#else + p_local_threshold->SetLowerThreshold(p_element_base_ids->GetTuple1(idx)); + p_local_threshold->SetUpperThreshold(p_element_base_ids->GetTuple1(idx)); +#endif + p_local_threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "Cell Base Id"); - vtkSmartPointer p_local_geom_filter = vtkSmartPointer::New(); + auto p_local_geom_filter = vtkSmartPointer::New(); p_local_geom_filter->SetInputConnection(p_local_threshold->GetOutputPort()); - vtkSmartPointer p_features = vtkSmartPointer::New(); + auto p_features = vtkSmartPointer::New(); p_features->SetInputConnection(p_local_geom_filter->GetOutputPort()); p_features->Update(); - vtkSmartPointer p_append = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_append->AddInput(p_bounds); - p_append->AddInput(p_features->GetOutput()); - #else - p_append->AddInputData(p_bounds); - p_append->AddInputData(p_features->GetOutput()); - #endif + auto p_append = vtkSmartPointer::New(); + p_append->AddInputData(p_bounds); + p_append->AddInputData(p_features->GetOutput()); p_append->Update(); p_bounds = p_append->GetOutput(); } - vtkSmartPointer p_mapper2 = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_mapper2->SetInput(p_bounds); - #else - p_mapper2->SetInputData(p_bounds); - #endif + auto p_mapper2 = vtkSmartPointer::New(); + p_mapper2->SetInputData(p_bounds); - vtkSmartPointer p_volume_actor2 = vtkSmartPointer::New(); + auto p_volume_actor2 = vtkSmartPointer::New(); p_volume_actor2->SetMapper(p_mapper2); p_volume_actor2->GetProperty()->SetEdgeVisibility(this->mShowEdges); p_volume_actor2->GetProperty()->SetLineWidth(this->mEdgeSize); @@ -423,10 +414,10 @@ void CellPopulationPyChasteActorGenerator::AddActor(vtkSmartPointer >(mpCellPopulation) || boost::dynamic_pointer_cast >(mpCellPopulation)) { - vtkSmartPointer p_points = vtkSmartPointer::New(); - vtkSmartPointer p_cell_color_reference_data = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); + auto p_cell_color_reference_data = vtkSmartPointer::New(); p_cell_color_reference_data->SetName("CellColors"); - vtkSmartPointer p_polydata = vtkSmartPointer::New(); + auto p_polydata = vtkSmartPointer::New(); for (typename AbstractCellPopulation::Iterator cell_iter = mpCellPopulation->Begin(); cell_iter != mpCellPopulation->End(); ++cell_iter) @@ -490,7 +481,7 @@ void CellPopulationPyChasteActorGenerator::AddActor(vtkSmartPointerSetPoints(p_points); p_polydata->GetPointData()->AddArray(p_cell_color_reference_data); - vtkSmartPointer p_scaled_ctf = vtkSmartPointer::New(); + auto p_scaled_ctf = vtkSmartPointer::New(); if(!mColorByCellData) { double range[2]; @@ -514,37 +505,28 @@ void CellPopulationPyChasteActorGenerator::AddActor(vtkSmartPointer p_spheres = vtkSmartPointer::New(); + auto p_spheres = vtkSmartPointer::New(); p_spheres->SetRadius(this->mPointSize); p_spheres->SetPhiResolution(16); p_spheres->SetThetaResolution(16); - vtkSmartPointer p_glyph = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_glyph->SetInput(p_polydata); - p_glyph->SetSource(p_spheres->GetOutput()); - #else - p_glyph->SetInputData(p_polydata); - p_glyph->SetSourceConnection(p_spheres->GetOutputPort()); - #endif + auto p_glyph = vtkSmartPointer::New(); + p_glyph->SetInputData(p_polydata); + p_glyph->SetSourceConnection(p_spheres->GetOutputPort()); p_glyph->ClampingOff(); p_glyph->SetScaleModeToScaleByScalar(); p_glyph->SetScaleFactor(1.0); p_glyph->Update(); - vtkSmartPointer p_mapper = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_mapper->SetInput(p_glyph->GetOutput()); - #else - p_mapper->SetInputData(p_glyph->GetOutput()); - #endif + auto p_mapper = vtkSmartPointer::New(); + p_mapper->SetInputData(p_glyph->GetOutput()); p_mapper->SetLookupTable(p_scaled_ctf); p_mapper->ScalarVisibilityOn(); p_mapper->SelectColorArray("CellColors"); p_mapper->SetScalarModeToUsePointFieldData(); p_mapper->SetColorModeToMapScalars(); - vtkSmartPointer p_actor = vtkSmartPointer::New(); + auto p_actor = vtkSmartPointer::New(); p_actor->SetMapper(p_mapper); p_actor->GetProperty()->SetOpacity(this->mVolumeOpacity); if(mColorCellByUserDefined) @@ -595,11 +577,11 @@ void CellPopulationPyChasteActorGenerator::AddVertexBasedCellPopulationActo if(mShowVoronoiMeshEdges) { - vtkSmartPointer p_voronoi_grid = vtkSmartPointer::New(); - vtkSmartPointer p_cell_color_reference_data = vtkSmartPointer::New(); + auto p_voronoi_grid = vtkSmartPointer::New(); + auto p_cell_color_reference_data = vtkSmartPointer::New(); p_cell_color_reference_data->SetName("CellColors"); - vtkSmartPointer p_points = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); p_points->GetData()->SetName("Vertex positions"); for (unsigned node_num=0; node_numrGetMesh().GetNumNodes(); node_num++) { @@ -690,7 +672,7 @@ void CellPopulationPyChasteActorGenerator::AddVertexBasedCellPopulationActo p_voronoi_grid->GetCellData()->AddArray(p_cell_color_reference_data); p_voronoi_grid->GetCellData()->SetScalars(p_cell_color_reference_data); - vtkSmartPointer p_scaled_ctf = vtkSmartPointer::New(); + auto p_scaled_ctf = vtkSmartPointer::New(); if(!mColorByCellData) { double range[2]; @@ -715,14 +697,10 @@ void CellPopulationPyChasteActorGenerator::AddVertexBasedCellPopulationActo } p_scaled_ctf->Build(); - vtkSmartPointer p_geom_filter = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_geom_filter->SetInput(p_voronoi_grid); - #else - p_geom_filter->SetInputData(p_voronoi_grid); - #endif + auto p_geom_filter = vtkSmartPointer::New(); + p_geom_filter->SetInputData(p_voronoi_grid); - vtkSmartPointer p_mapper = vtkSmartPointer::New(); + auto p_mapper = vtkSmartPointer::New(); p_mapper->SetInputConnection(p_geom_filter->GetOutputPort()); p_mapper->SetLookupTable(p_scaled_ctf); p_mapper->ScalarVisibilityOn(); @@ -730,7 +708,7 @@ void CellPopulationPyChasteActorGenerator::AddVertexBasedCellPopulationActo p_mapper->SetScalarModeToUseCellData(); p_mapper->SetColorModeToMapScalars(); - vtkSmartPointer p_actor = vtkSmartPointer::New(); + auto p_actor = vtkSmartPointer::New(); p_actor->SetMapper(p_mapper); p_actor->GetProperty()->SetOpacity(this->mVolumeOpacity); if(mColorCellByUserDefined) @@ -739,23 +717,23 @@ void CellPopulationPyChasteActorGenerator::AddVertexBasedCellPopulationActo } pRenderer->AddActor(p_actor); - vtkSmartPointer p_voronoi_extract_edges = vtkSmartPointer::New(); + auto p_voronoi_extract_edges = vtkSmartPointer::New(); p_voronoi_extract_edges->SetInputConnection(p_geom_filter->GetOutputPort()); p_voronoi_extract_edges->SetFeatureEdges(false); p_voronoi_extract_edges->SetBoundaryEdges(true); p_voronoi_extract_edges->SetManifoldEdges(true); p_voronoi_extract_edges->SetNonManifoldEdges(false); - vtkSmartPointer p_voronoi_tubes = vtkSmartPointer::New(); + auto p_voronoi_tubes = vtkSmartPointer::New(); p_voronoi_tubes->SetInputConnection(p_voronoi_extract_edges->GetOutputPort()); p_voronoi_tubes->SetRadius(this->mEdgeSize); p_voronoi_tubes->SetNumberOfSides(12); - vtkSmartPointer p_voronoi_tube_mapper = vtkSmartPointer::New(); + auto p_voronoi_tube_mapper = vtkSmartPointer::New(); p_voronoi_tube_mapper->SetInputConnection(p_voronoi_tubes->GetOutputPort()); p_voronoi_tube_mapper->ScalarVisibilityOff(); - vtkSmartPointer p_voronoi_tube_actor = vtkSmartPointer::New(); + auto p_voronoi_tube_actor = vtkSmartPointer::New(); p_voronoi_tube_actor->SetMapper(p_voronoi_tube_mapper); p_voronoi_tube_actor->GetProperty()->SetColor(this->mEdgeColor[0], this->mEdgeColor[1], this->mEdgeColor[2]); pRenderer->AddActor(p_voronoi_tube_actor); @@ -781,11 +759,11 @@ void CellPopulationPyChasteActorGenerator::AddImmersedBoundaryCellPopulatio if(mShowVoronoiMeshEdges) { - vtkSmartPointer p_voronoi_grid = vtkSmartPointer::New(); - vtkSmartPointer p_cell_color_reference_data = vtkSmartPointer::New(); + auto p_voronoi_grid = vtkSmartPointer::New(); + auto p_cell_color_reference_data = vtkSmartPointer::New(); p_cell_color_reference_data->SetName("CellColors"); - vtkSmartPointer p_points = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); p_points->GetData()->SetName("Vertex positions"); for (unsigned node_num=0; node_numrGetMesh().GetNumNodes(); node_num++) { @@ -876,7 +854,7 @@ void CellPopulationPyChasteActorGenerator::AddImmersedBoundaryCellPopulatio p_voronoi_grid->GetCellData()->AddArray(p_cell_color_reference_data); p_voronoi_grid->GetCellData()->SetScalars(p_cell_color_reference_data); - vtkSmartPointer p_scaled_ctf = vtkSmartPointer::New(); + auto p_scaled_ctf = vtkSmartPointer::New(); if(!mColorByCellData) { double range[2]; @@ -901,14 +879,10 @@ void CellPopulationPyChasteActorGenerator::AddImmersedBoundaryCellPopulatio } p_scaled_ctf->Build(); - vtkSmartPointer p_geom_filter = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_geom_filter->SetInput(p_voronoi_grid); - #else - p_geom_filter->SetInputData(p_voronoi_grid); - #endif + auto p_geom_filter = vtkSmartPointer::New(); + p_geom_filter->SetInputData(p_voronoi_grid); - vtkSmartPointer p_mapper = vtkSmartPointer::New(); + auto p_mapper = vtkSmartPointer::New(); p_mapper->SetInputConnection(p_geom_filter->GetOutputPort()); p_mapper->SetLookupTable(p_scaled_ctf); p_mapper->ScalarVisibilityOn(); @@ -916,7 +890,7 @@ void CellPopulationPyChasteActorGenerator::AddImmersedBoundaryCellPopulatio p_mapper->SetScalarModeToUseCellData(); p_mapper->SetColorModeToMapScalars(); - vtkSmartPointer p_actor = vtkSmartPointer::New(); + auto p_actor = vtkSmartPointer::New(); p_actor->SetMapper(p_mapper); p_actor->GetProperty()->SetOpacity(this->mVolumeOpacity); if(mColorCellByUserDefined) @@ -925,23 +899,23 @@ void CellPopulationPyChasteActorGenerator::AddImmersedBoundaryCellPopulatio } pRenderer->AddActor(p_actor); - vtkSmartPointer p_voronoi_extract_edges = vtkSmartPointer::New(); + auto p_voronoi_extract_edges = vtkSmartPointer::New(); p_voronoi_extract_edges->SetInputConnection(p_geom_filter->GetOutputPort()); p_voronoi_extract_edges->SetFeatureEdges(false); p_voronoi_extract_edges->SetBoundaryEdges(true); p_voronoi_extract_edges->SetManifoldEdges(true); p_voronoi_extract_edges->SetNonManifoldEdges(false); - vtkSmartPointer p_voronoi_tubes = vtkSmartPointer::New(); + auto p_voronoi_tubes = vtkSmartPointer::New(); p_voronoi_tubes->SetInputConnection(p_voronoi_extract_edges->GetOutputPort()); p_voronoi_tubes->SetRadius(this->mEdgeSize); p_voronoi_tubes->SetNumberOfSides(12); - vtkSmartPointer p_voronoi_tube_mapper = vtkSmartPointer::New(); + auto p_voronoi_tube_mapper = vtkSmartPointer::New(); p_voronoi_tube_mapper->SetInputConnection(p_voronoi_tubes->GetOutputPort()); p_voronoi_tube_mapper->ScalarVisibilityOff(); - vtkSmartPointer p_voronoi_tube_actor = vtkSmartPointer::New(); + auto p_voronoi_tube_actor = vtkSmartPointer::New(); p_voronoi_tube_actor->SetMapper(p_voronoi_tube_mapper); p_voronoi_tube_actor->GetProperty()->SetColor(this->mEdgeColor[0], this->mEdgeColor[1], this->mEdgeColor[2]); pRenderer->AddActor(p_voronoi_tube_actor); @@ -972,13 +946,13 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( if(mShowVoronoiMeshEdges) { p_cell_population->CreateVoronoiTessellation(); - vtkSmartPointer p_voronoi_grid = vtkSmartPointer::New(); - vtkSmartPointer p_cell_color_reference_data = vtkSmartPointer::New(); + auto p_voronoi_grid = vtkSmartPointer::New(); + auto p_cell_color_reference_data = vtkSmartPointer::New(); p_cell_color_reference_data->SetName("CellColors"); if(p_cell_population->GetVoronoiTessellation() != NULL) { - vtkSmartPointer p_points = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); p_points->GetData()->SetName("Vertex positions"); for (unsigned node_num=0; node_numGetVoronoiTessellation()->GetNumNodes(); node_num++) { @@ -1084,7 +1058,7 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( p_voronoi_grid->GetCellData()->AddArray(p_cell_color_reference_data); p_voronoi_grid->GetCellData()->SetScalars(p_cell_color_reference_data); - vtkSmartPointer p_scaled_ctf = vtkSmartPointer::New(); + auto p_scaled_ctf = vtkSmartPointer::New(); if(!mColorByCellData) { double range[2]; @@ -1109,19 +1083,19 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( } p_scaled_ctf->Build(); - vtkSmartPointer p_threshold = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_threshold->SetInput(p_voronoi_grid); - #else - p_threshold->SetInputData(p_voronoi_grid); - #endif + auto p_threshold = vtkSmartPointer::New(); + p_threshold->SetInputData(p_voronoi_grid); +#if VTK_MAJOR_VERSION < 9 p_threshold->ThresholdByUpper(0.0); +#else + p_threshold->SetUpperThreshold(0.0); +#endif p_threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "CellColors"); - vtkSmartPointer p_geom_filter = vtkSmartPointer::New(); + auto p_geom_filter = vtkSmartPointer::New(); p_geom_filter->SetInputConnection(p_threshold->GetOutputPort()); - vtkSmartPointer p_mapper = vtkSmartPointer::New(); + auto p_mapper = vtkSmartPointer::New(); p_mapper->SetInputConnection(p_geom_filter->GetOutputPort()); p_mapper->SetLookupTable(p_scaled_ctf); p_mapper->ScalarVisibilityOn(); @@ -1130,7 +1104,7 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( p_mapper->SetScalarModeToUseCellData(); p_mapper->SetColorModeToMapScalars(); - vtkSmartPointer p_actor = vtkSmartPointer::New(); + auto p_actor = vtkSmartPointer::New(); p_actor->SetMapper(p_mapper); p_actor->GetProperty()->SetOpacity(this->mVolumeOpacity); if(mColorCellByUserDefined) @@ -1139,23 +1113,23 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( } pRenderer->AddActor(p_actor); - vtkSmartPointer p_voronoi_extract_edges = vtkSmartPointer::New(); + auto p_voronoi_extract_edges = vtkSmartPointer::New(); p_voronoi_extract_edges->SetInputConnection(p_geom_filter->GetOutputPort()); p_voronoi_extract_edges->SetFeatureEdges(false); p_voronoi_extract_edges->SetBoundaryEdges(true); p_voronoi_extract_edges->SetManifoldEdges(true); p_voronoi_extract_edges->SetNonManifoldEdges(false); - vtkSmartPointer p_voronoi_tubes = vtkSmartPointer::New(); + auto p_voronoi_tubes = vtkSmartPointer::New(); p_voronoi_tubes->SetInputConnection(p_voronoi_extract_edges->GetOutputPort()); p_voronoi_tubes->SetRadius(this->mEdgeSize); p_voronoi_tubes->SetNumberOfSides(12); - vtkSmartPointer p_voronoi_tube_mapper = vtkSmartPointer::New(); + auto p_voronoi_tube_mapper = vtkSmartPointer::New(); p_voronoi_tube_mapper->SetInputConnection(p_voronoi_tubes->GetOutputPort()); p_voronoi_tube_mapper->ScalarVisibilityOff(); - vtkSmartPointer p_voronoi_tube_actor = vtkSmartPointer::New(); + auto p_voronoi_tube_actor = vtkSmartPointer::New(); p_voronoi_tube_actor->SetMapper(p_voronoi_tube_mapper); p_voronoi_tube_actor->GetProperty()->SetColor(this->mEdgeColor[0], this->mEdgeColor[1], this->mEdgeColor[2]); pRenderer->AddActor(p_voronoi_tube_actor); @@ -1172,8 +1146,8 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( { // Do the mutable mesh //Make the local mesh into a VtkMesh - vtkSmartPointer p_mutable_grid = vtkSmartPointer::New(); - vtkSmartPointer p_points = vtkSmartPointer::New(); + auto p_mutable_grid = vtkSmartPointer::New(); + auto p_points = vtkSmartPointer::New(); p_points->GetData()->SetName("Vertex positions"); for (typename AbstractMesh::NodeIterator node_iter = p_cell_population->rGetMesh().GetNodeIteratorBegin(); @@ -1224,29 +1198,25 @@ void CellPopulationPyChasteActorGenerator::AddMeshBasedCellPopulationActor( p_mutable_grid->InsertNextCell(p_cell->GetCellType(), p_cell_id_list); } - vtkSmartPointer p_mutable_geom_filter = vtkSmartPointer::New(); - #if VTK_MAJOR_VERSION <= 5 - p_mutable_geom_filter->SetInput(p_mutable_grid); - #else + auto p_mutable_geom_filter = vtkSmartPointer::New(); p_mutable_geom_filter->SetInputData(p_mutable_grid); - #endif - vtkSmartPointer p_extract_edges = vtkSmartPointer::New(); + auto p_extract_edges = vtkSmartPointer::New(); p_extract_edges->SetInputConnection(p_mutable_geom_filter->GetOutputPort()); p_extract_edges->SetFeatureEdges(false); p_extract_edges->SetBoundaryEdges(true); p_extract_edges->SetManifoldEdges(true); p_extract_edges->SetNonManifoldEdges(false); - vtkSmartPointer p_mutable_tubes = vtkSmartPointer::New(); + auto p_mutable_tubes = vtkSmartPointer::New(); p_mutable_tubes->SetInputConnection(p_extract_edges->GetOutputPort()); p_mutable_tubes->SetRadius(0.02); p_mutable_tubes->SetNumberOfSides(12); - vtkSmartPointer p_mutable_mapper = vtkSmartPointer::New(); + auto p_mutable_mapper = vtkSmartPointer::New(); p_mutable_mapper->SetInputConnection(p_mutable_tubes->GetOutputPort()); - vtkSmartPointer p_mutable_actor = vtkSmartPointer::New(); + auto p_mutable_actor = vtkSmartPointer::New(); p_mutable_actor->SetMapper(p_mutable_mapper); p_mutable_actor->GetProperty()->SetColor(1,1,1); pRenderer->AddActor(p_mutable_actor); diff --git a/src/visualization/VtkScene.cpp b/src/visualization/VtkScene.cpp index 2ea30cb7..d7b815c3 100644 --- a/src/visualization/VtkScene.cpp +++ b/src/visualization/VtkScene.cpp @@ -165,7 +165,7 @@ vtkSmartPointer VtkScene::GetSceneAsCharBuffer() mpRenderWindow->SetOffScreenRendering(1); mpRenderWindow->Render(); mWindowToImageFilter->Modified(); - vtkSmartPointer p_writer = vtkSmartPointer::New(); + auto p_writer = vtkSmartPointer::New(); p_writer->SetWriteToMemory(1); p_writer->SetInputConnection(mWindowToImageFilter->GetOutputPort()); p_writer->Write(); @@ -199,7 +199,7 @@ void VtkScene::ResetRenderer(unsigned time_step) mpRenderWindow->SetOffScreenRendering(1); mpRenderWindow->Render(); mWindowToImageFilter->Modified(); - vtkSmartPointer p_writer = vtkSmartPointer::New(); + auto p_writer = vtkSmartPointer::New(); p_writer->SetWriteToMemory(1); p_writer->SetInputConnection(mWindowToImageFilter->GetOutputPort()); if(!mOutputFilePath.empty()) diff --git a/test/visualization/TestVtkSceneWithCaBased.hpp b/test/visualization/TestVtkSceneWithCaBased.hpp index 31ee878c..650ca18d 100644 --- a/test/visualization/TestVtkSceneWithCaBased.hpp +++ b/test/visualization/TestVtkSceneWithCaBased.hpp @@ -130,16 +130,15 @@ class TestVtkSceneWithCaBasedPopulation : public AbstractCellBasedTestSuite cells_generator.GenerateBasic(cells, location_indices.size()); // Create cell population - boost::shared_ptr > p_cell_population = - boost::make_shared >(*p_mesh, cells, location_indices); + auto p_cell_population = boost::make_shared >(*p_mesh, cells, location_indices); - boost::shared_ptr > p_scene = boost::make_shared >(); + auto p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetSaveAsImages(true); p_scene->GetCellPopulationActorGenerator()->SetShowPottsMeshEdges(true); p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); - boost::shared_ptr > p_scene_modifier = boost::make_shared >(); + auto p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene->Start(); diff --git a/test/visualization/TestVtkSceneWithMeshBased.hpp b/test/visualization/TestVtkSceneWithMeshBased.hpp index 314a4499..47bb715c 100644 --- a/test/visualization/TestVtkSceneWithMeshBased.hpp +++ b/test/visualization/TestVtkSceneWithMeshBased.hpp @@ -87,16 +87,15 @@ class TestVtkSceneWithMeshBasedPopulation : public AbstractCellBasedTestSuite MAKE_PTR(TransitCellProliferativeType, p_transit_type); CellsGenerator cells_generator; cells_generator.GenerateBasicRandom(cells, location_indices.size(), p_transit_type); - boost::shared_ptr > p_cell_population = - boost::shared_ptr >(new MeshBasedCellPopulationWithGhostNodes<2> (*p_mesh, cells, location_indices)); + auto p_cell_population = boost::make_shared >(*p_mesh, cells, location_indices); p_cell_population->AddPopulationWriter(); - boost::shared_ptr > p_scene = boost::shared_ptr >(new VtkScene<2>); + auto p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetSaveAsImages(true); p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); - boost::shared_ptr > p_scene_modifier = boost::shared_ptr >(new VtkSceneModifier<2>); + auto p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene->Start(); @@ -128,17 +127,16 @@ class TestVtkSceneWithMeshBasedPopulation : public AbstractCellBasedTestSuite CellsGenerator cells_generator; cells_generator.GenerateBasicRandom(cells, mesh.GetNumNodes(), p_transit_type); - boost::shared_ptr > p_cell_population = - boost::shared_ptr >(new MeshBasedCellPopulation<3> (mesh, cells)); + auto p_cell_population = boost::make_shared >(mesh, cells); p_cell_population->SetAbsoluteMovementThreshold(DBL_MAX); p_cell_population->AddPopulationWriter(); - boost::shared_ptr > p_scene = boost::shared_ptr >(new VtkScene<3>); + auto p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetSaveAsImages(true); p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); - boost::shared_ptr > p_scene_modifier = boost::shared_ptr >(new VtkSceneModifier<3>); + auto p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene->Start(); diff --git a/test/visualization/TestVtkSceneWithPottsBased.hpp b/test/visualization/TestVtkSceneWithPottsBased.hpp index 3be3fea6..82e235a0 100644 --- a/test/visualization/TestVtkSceneWithPottsBased.hpp +++ b/test/visualization/TestVtkSceneWithPottsBased.hpp @@ -87,8 +87,7 @@ class TestVtkScene : public AbstractCellBasedTestSuite CellsGenerator cells_generator; cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumElements(), p_transit_type); - boost::shared_ptr > p_cell_population = - boost::shared_ptr >(new PottsBasedCellPopulation<2> (*p_mesh, cells)); + auto p_cell_population = boost::make_shared >(*p_mesh, cells); p_cell_population->SetTemperature(0.1); p_cell_population->SetNumSweepsPerTimestep(1); @@ -98,14 +97,14 @@ class TestVtkScene : public AbstractCellBasedTestSuite simulator.SetDt(0.1); simulator.SetSamplingTimestepMultiple(10); - boost::shared_ptr > p_scene = boost::shared_ptr >(new VtkScene<2>); + auto p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetIsInteractive(true); p_scene->SetSaveAsImages(false); p_scene->GetCellPopulationActorGenerator()->SetShowPottsMeshEdges(true); p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); - boost::shared_ptr > p_scene_modifier = boost::shared_ptr >(new VtkSceneModifier<2>); + auto p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene_modifier->SetUpdateFrequency(10); p_scene->Start(); @@ -132,8 +131,7 @@ class TestVtkScene : public AbstractCellBasedTestSuite CellsGenerator cells_generator; cells_generator.GenerateBasicRandom(cells, p_mesh->GetNumElements(), p_transit_type); - boost::shared_ptr > p_cell_population = - boost::shared_ptr >(new PottsBasedCellPopulation<3> (*p_mesh, cells)); + auto p_cell_population = boost::make_shared >(*p_mesh, cells); p_cell_population->SetTemperature(0.1); p_cell_population->SetNumSweepsPerTimestep(1); @@ -143,7 +141,7 @@ class TestVtkScene : public AbstractCellBasedTestSuite simulator.SetDt(0.1); simulator.SetSamplingTimestepMultiple(100); - boost::shared_ptr > p_scene = boost::shared_ptr >(new VtkScene<3>); + auto p_scene = boost::make_shared >(); p_scene->SetCellPopulation(p_cell_population); p_scene->SetIsInteractive(true); p_scene->SetSaveAsImages(false); @@ -151,7 +149,7 @@ class TestVtkScene : public AbstractCellBasedTestSuite p_scene->GetCellPopulationActorGenerator()->SetShowPottsMeshOutlines(true); p_scene->SetOutputFilePath(file_handler1.GetOutputDirectoryFullPath()+"/cell_population"); - boost::shared_ptr > p_scene_modifier = boost::shared_ptr >(new VtkSceneModifier<3>); + auto p_scene_modifier = boost::make_shared >(); p_scene_modifier->SetVtkScene(p_scene); p_scene->Start();