Skip to content

Commit

Permalink
[VolumetricRendering][SofaCUDA] Move CUDA files related to Volumetric…
Browse files Browse the repository at this point in the history
…Rendering (#4487)

* New plugin for VolumetricRendering.CUDA

* Move files from SofaCUDA to VolumetricRendering

---------

Co-authored-by: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
  • Loading branch information
alxbilger and bakpaul committed Feb 14, 2024
1 parent 86471da commit 0fe228f
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 20 deletions.
4 changes: 2 additions & 2 deletions applications/plugins/CMakeLists.txt
Expand Up @@ -60,12 +60,12 @@ if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") AND (${CMAKE_SYSTEM_NAME} MATCHES "
sofa_add_subdirectory(plugin SofaPardisoSolver SofaPardisoSolver) # SofaPardisoSolver is only available under linux with gcc
endif()

sofa_add_subdirectory(plugin SofaCUDA SofaCUDA)

sofa_find_package(Sofa.GL QUIET)
if(Sofa.GL_FOUND)
sofa_add_subdirectory(plugin SofaSimpleGUI SofaSimpleGUI) # SofaSimpleGUI plugin can't work without OPENGL
sofa_add_subdirectory(plugin VolumetricRendering VolumetricRendering) # VolumetricRendering plugin can't work without OPENGL
else()
message("Sofa.GL not found; disabling SofaSimpleGUI and VolumetricRendering plugins")
endif()

sofa_add_subdirectory(plugin SofaCUDA SofaCUDA)
13 changes: 0 additions & 13 deletions applications/plugins/SofaCUDA/CMakeLists.txt
Expand Up @@ -321,16 +321,6 @@ sofa_find_package(Sofa.Component.Engine.Select REQUIRED)
sofa_find_package(Sofa.Component.Engine.Transform REQUIRED)
sofa_find_package(Sofa.Component.MechanicalLoad REQUIRED)

sofa_find_package(VolumetricRendering QUIET)
if(VolumetricRendering_FOUND)
list(APPEND HEADER_FILES sofa/gpu/cuda/CudaTetrahedralVisualModel.h)
list(APPEND HEADER_FILES sofa/gpu/cuda/CudaTetrahedralVisualModel.inl)
list(APPEND SOURCE_FILES sofa/gpu/cuda/CudaTetrahedralVisualModel.cpp)
add_definitions("-DSOFACUDA_ENABLE_VOLUMETRICRENDERING")
else()
message(STATUS "SofaCUDA: Plugin VolumetricRendering was not enabled/found, therefore CudaTetrahedralVisualModel will not be compiled.")
endif()

sofa_find_package(Sofa.GUI QUIET)
if(Sofa.GUI_FOUND)
list(APPEND SOURCE_FILES sofa/gpu/gui/CudaMouseInteraction.cpp)
Expand Down Expand Up @@ -520,9 +510,6 @@ if(SofaValidation_FOUND)
target_link_libraries(${PROJECT_NAME} SofaValidation)
endif()

if(VolumetricRendering_FOUND)
target_link_libraries(${PROJECT_NAME} VolumetricRendering)
endif()
if(SofaSphFluid_FOUND)
target_link_libraries(${PROJECT_NAME} SofaSphFluid)
endif()
Expand Down
5 changes: 0 additions & 5 deletions applications/plugins/SofaCUDA/SofaCUDAConfig.cmake.in
Expand Up @@ -31,11 +31,6 @@ if(SOFACUDA_HAVE_SOFA_GL)
find_package(Sofa.GL QUIET REQUIRED)
endif()

set(SOFACUDA_HAVE_VOLUMETRICRENDERING @SOFACUDA_HAVE_VOLUMETRICRENDERING@)
if(SOFACUDA_HAVE_VOLUMETRICRENDERING)
find_package(VolumetricRendering QUIET REQUIRED)
endif()

set(SOFACUDA_HAVE_SOFA_GUI_QT @SOFACUDA_HAVE_SOFA_GUI_QT@)
if(SOFACUDA_HAVE_SOFA_GUI_QT)
find_package(Sofa.GUI.Qt QUIET REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions applications/plugins/VolumetricRendering/CMakeLists.txt
Expand Up @@ -30,3 +30,5 @@ sofa_create_package_with_targets(
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

sofa_add_subdirectory(plugin extensions/CUDA VolumetricRendering.CUDA)
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.12)
project(VolumetricRendering.CUDA)

set(HEADER_FILES
src/VolumetricRendering/CUDA/init.h
src/VolumetricRendering/CUDA/config.h.in

src/VolumetricRendering/CUDA/CudaTetrahedralVisualModel.h
src/VolumetricRendering/CUDA/CudaTetrahedralVisualModel.inl
)

set(SOURCE_FILES
src/VolumetricRendering/CUDA/init.cpp

src/VolumetricRendering/CUDA/CudaTetrahedralVisualModel.cpp
)

sofa_find_package(VolumetricRendering REQUIRED)
sofa_find_package(SofaCUDA REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} VolumetricRendering)
target_link_libraries(${PROJECT_NAME} SofaCUDA)

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${Sofa_VERSION}
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
RELOCATABLE "plugins"
)
@@ -0,0 +1,9 @@
# CMake package configuration file for the VolumetricRendering.CUDA library

@PACKAGE_GUARD@
@PACKAGE_INIT@

find_package(VolumetricRendering QUIET REQUIRED)
find_package(SofaCUDA QUIET REQUIRED)

check_required_components(VolumetricRendering.CUDA)
@@ -0,0 +1,37 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once

#include <sofa/config.h>

#ifdef SOFA_BUILD_VOLUMETRICRENDERING_CUDA
# define SOFA_TARGET @PROJECT_NAME@
# define SOFA_VOLUMETRICRENDERING_CUDA_API SOFA_EXPORT_DYNAMIC_LIBRARY
#else
# define SOFA_VOLUMETRICRENDERING_CUDA_API SOFA_IMPORT_DYNAMIC_LIBRARY
#endif

namespace volumetricrendering::cuda
{
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
} // namespace volumetricrendering::cuda
@@ -0,0 +1,67 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <VolumetricRendering/CUDA/init.h>
#include <VolumetricRendering/initVolumetricRendering.h>
#include <sofa/core/ObjectFactory.h>
namespace volumetricrendering::cuda
{

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleVersion();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleComponentList();
}

void initExternalModule()
{
init();
}

const char* getModuleName()
{
return MODULE_NAME;
}

const char* getModuleVersion()
{
return MODULE_VERSION;
}

void init()
{
static bool first = true;
if (first)
{
volumetricrendering::init();
first = false;
}
}

const char* getModuleComponentList()
{
/// string containing the names of the classes provided by the plugin
static std::string classes = sofa::core::ObjectFactory::getInstance()->listClassesFromTarget(MODULE_NAME);
return classes.c_str();
}

} // namespace volumetricrendering::cuda
@@ -0,0 +1,29 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once

#include <VolumetricRendering/CUDA/config.h>

namespace volumetricrendering::cuda
{
SOFA_VOLUMETRICRENDERING_CUDA_API void init();
} // namespace volumetricrendering::cuda

0 comments on commit 0fe228f

Please sign in to comment.