From c473a66f0b2e640fed1ad3740008b05ab5f15e52 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 20 Dec 2023 12:17:06 +0100 Subject: [PATCH] [VolumetricRendering] Fix the compilation But scenes crash --- .../gpu/cuda/CudaTetrahedralVisualModel.inl | 4 +-- .../VolumetricRendering/CMakeLists.txt | 17 ++++------ .../examples/OglTetrahedralModel.scn | 32 ++++++++++++------- .../examples/OglVolumetricModel_hexa.scn | 27 +++++++++------- .../examples/OglVolumetricModel_hexa_link.scn | 24 +++++++------- .../VolumetricRendering/OglTetrahedralModel.h | 16 ++-------- .../OglTetrahedralModel.inl | 10 +++--- .../OglVolumetricModel.cpp | 18 +++++------ .../VolumetricRendering/OglVolumetricModel.h | 2 +- .../src/VolumetricRendering/config.h.in | 6 ++++ .../initVolumetricRendering.cpp | 21 +++++++----- .../initVolumetricRendering.h | 29 +++++++++++++++++ 12 files changed, 121 insertions(+), 85 deletions(-) create mode 100644 applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.h diff --git a/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaTetrahedralVisualModel.inl b/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaTetrahedralVisualModel.inl index e5e866f3b1e..db7a13e0020 100644 --- a/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaTetrahedralVisualModel.inl +++ b/applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaTetrahedralVisualModel.inl @@ -59,13 +59,13 @@ void OglTetrahedralModel< gpu::cuda::CudaVectorTypes >::ini if (!nodes) { - serr << "No mecha." << sendl; + msg_error() << "No mecha."; return; } if (!topo) { - serr << "No topo." << sendl; + msg_error() << "No topo."; return; } diff --git a/applications/plugins/VolumetricRendering/CMakeLists.txt b/applications/plugins/VolumetricRendering/CMakeLists.txt index 0f13f8e0ee6..b02f7146d1f 100644 --- a/applications/plugins/VolumetricRendering/CMakeLists.txt +++ b/applications/plugins/VolumetricRendering/CMakeLists.txt @@ -1,11 +1,12 @@ cmake_minimum_required(VERSION 3.12) -project(VolumetricRendering VERSION 0.1) +project(VolumetricRendering) -find_package(Sofa.Helper REQUIRED) +find_package(Sofa.Config REQUIRED) sofa_find_package(Sofa.GL.Component REQUIRED) set(HEADER_FILES src/VolumetricRendering/config.h.in + src/VolumetricRendering/initVolumetricRendering.cpp src/VolumetricRendering/OglTetrahedralModel.h src/VolumetricRendering/OglTetrahedralModel.inl src/VolumetricRendering/OglVolumetricModel.h @@ -19,17 +20,13 @@ set(SOURCE_FILES add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} Sofa.Helper Sofa.GL.Component) - -# Add the include DIR from OpenHaptics to target -target_include_directories(${PROJECT_NAME} PUBLIC "$") +target_link_libraries(${PROJECT_NAME} Sofa.GL.Component) # Install rules for the library and the headers; CMake package configurations files sofa_create_package_with_targets( PACKAGE_NAME ${PROJECT_NAME} + PACKAGE_VERSION ${Sofa_VERSION} TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES - PACKAGE_VERSION ${PROJECT_VERSION} INCLUDE_SOURCE_DIR "src" - INCLUDE_INSTALL_DIR "VolumetricRendering" - RELOCATABLE "plugins" - ) + INCLUDE_INSTALL_DIR "${PROJECT_NAME}" +) diff --git a/applications/plugins/VolumetricRendering/examples/OglTetrahedralModel.scn b/applications/plugins/VolumetricRendering/examples/OglTetrahedralModel.scn index d0e0e6dbe73..2584b9a2401 100644 --- a/applications/plugins/VolumetricRendering/examples/OglTetrahedralModel.scn +++ b/applications/plugins/VolumetricRendering/examples/OglTetrahedralModel.scn @@ -1,16 +1,24 @@ - - - - - - - - - - - + + + + + + - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa.scn b/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa.scn index 6947acd4725..7ddea1884d8 100644 --- a/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa.scn +++ b/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa.scn @@ -1,18 +1,23 @@ + + + + - + + - - + + - - - - - - + + + + + + - \ No newline at end of file + diff --git a/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa_link.scn b/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa_link.scn index e6a93625208..34048c30a8b 100644 --- a/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa_link.scn +++ b/applications/plugins/VolumetricRendering/examples/OglVolumetricModel_hexa_link.scn @@ -3,18 +3,18 @@ - + - - - + + + - - - - - - + + + + + + - \ No newline at end of file + diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.h b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.h index 43b29a359af..0fd1ca8244a 100644 --- a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.h +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace sofa { @@ -76,8 +76,8 @@ class OglTetrahedralModel : public core::visual::VisualModel void updateVertexBuffer(); //Tables - sofa::component::visual::OglFloatVector4Variable::SPtr m_mappingTableValues; - sofa::component::visual::OglFloatVector4Variable::SPtr m_runSelectTableValues; + sofa::gl::component::shader::OglFloatVector4Variable::SPtr m_mappingTableValues; + sofa::gl::component::shader::OglFloatVector4Variable::SPtr m_runSelectTableValues; protected: OglTetrahedralModel(); @@ -90,16 +90,6 @@ class OglTetrahedralModel : public core::visual::VisualModel void updateVisual() override; virtual void computeMesh(); - - virtual std::string getTemplateName() const - { - return templateName(this); - } - - static std::string templateName(const OglTetrahedralModel* = NULL) - { - return DataTypes::Name(); - } }; #if !defined(SOFA_COMPONENT_VISUALMODEL_OGLTETRAHEDRALMODEL_CPP) diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.inl b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.inl index 6d8f5216bb1..057be3f3e56 100644 --- a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.inl +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglTetrahedralModel.inl @@ -28,7 +28,6 @@ #include #include #include -#include #include namespace sofa @@ -63,8 +62,8 @@ void OglTetrahedralModel::init() //instanciate the mapping tables //Useful for the PT algorithm only - sofa::type::vector listVec4Variables; - this->getContext()->core::objectmodel::BaseContext::template get > + sofa::type::vector listVec4Variables; + this->getContext()->core::objectmodel::BaseContext::template get > (&listVec4Variables, core::objectmodel::BaseContext::Local); for (unsigned int i = 0; i::init() if (!m_mappingTableValues) { msg_info() << "No MappingTable found, instanciating one"; - m_mappingTableValues = sofa::core::objectmodel::New(); + m_mappingTableValues = sofa::core::objectmodel::New(); m_mappingTableValues->setName("MappingTable"); m_mappingTableValues->setID("MappingTable"); @@ -109,7 +108,7 @@ void OglTetrahedralModel::init() { msg_info() << "No RunSelectTable found, instanciating one"; - m_runSelectTableValues = sofa::core::objectmodel::New(); + m_runSelectTableValues = sofa::core::objectmodel::New(); m_runSelectTableValues->setName("RunSelectTable"); m_runSelectTableValues->setID("RunSelectTable"); @@ -255,7 +254,6 @@ void OglTetrahedralModel::computeMesh() template void OglTetrahedralModel::drawTransparent(const core::visual::VisualParams* vparams) { - using sofa::component::topology::TetrahedronSetTopologyContainer; if (!vparams->displayFlags().getShowVisualModels()) return; if (m_topology == NULL) return; if (m_topology->getNbTetrahedra() < 1) return; diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.cpp b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.cpp index a966e904856..9f370ad79a0 100644 --- a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.cpp +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.cpp @@ -28,9 +28,8 @@ #include #include -#include #include -#include +#include namespace sofa::component::visualmodel { @@ -74,8 +73,8 @@ void OglVolumetricModel::init() //instanciate the mapping tables //Useful for the PT algorithm only - sofa::type::vector listVec4Variables; - this->getContext()->core::objectmodel::BaseContext::template get > + sofa::type::vector listVec4Variables; + this->getContext()->core::objectmodel::BaseContext::template get > (&listVec4Variables, core::objectmodel::BaseContext::Local); for (unsigned int i = 0; i(); + m_mappingTableValues = sofa::core::objectmodel::New(); m_mappingTableValues->setName("MappingTable"); m_mappingTableValues->setID("MappingTable"); @@ -118,7 +117,7 @@ void OglVolumetricModel::init() { msg_info() << "No RunSelectTable found, instanciating one"; - m_runSelectTableValues = sofa::core::objectmodel::New(); + m_runSelectTableValues = sofa::core::objectmodel::New(); m_runSelectTableValues->setName("RunSelectTable"); m_runSelectTableValues->setID("RunSelectTable"); @@ -185,8 +184,8 @@ void OglVolumetricModel::initVisual() glBindBufferARB(GL_ARRAY_BUFFER, 0); //Check attributes - sofa::type::vector listVec4Attributes; - this->getContext()->core::objectmodel::BaseContext::template get > + sofa::type::vector listVec4Attributes; + this->getContext()->core::objectmodel::BaseContext::template get > (&listVec4Attributes, core::objectmodel::BaseContext::Local); for (unsigned int i = 0; i < listVec4Attributes.size(); i++) { @@ -201,7 +200,7 @@ void OglVolumetricModel::initVisual() if (!m_vertexColors) { msg_error() << "No attributes called a_vertexColor found, instanciating one with a default color"; - m_vertexColors = sofa::core::objectmodel::New(); + m_vertexColors = sofa::core::objectmodel::New(); m_vertexColors->setName("a_vertexColor"); m_vertexColors->setID("a_vertexColor"); m_vertexColors->setIndexShader(0); @@ -399,7 +398,6 @@ void OglVolumetricModel::handleTopologyChange() void OglVolumetricModel::drawTransparent(const core::visual::VisualParams* vparams) { - using sofa::component::topology::TetrahedronSetTopologyContainer; if (!vparams->displayFlags().getShowVisualModels()) return; glPushAttrib(GL_ALL_ATTRIB_BITS); diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.h b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.h index 84f9b2ae64f..9ba29bc4300 100644 --- a/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.h +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/OglVolumetricModel.h @@ -49,7 +49,7 @@ namespace visualmodel class SOFA_VOLUMETRICRENDERING_API OglVolumetricModel : public core::visual::VisualModel, public component::visual::Vec3State { public: - SOFA_CLASS2(OglVolumetricModel, core::visual::VisualModel, Vec3State); + SOFA_CLASS2(OglVolumetricModel, core::visual::VisualModel, component::visual::Vec3State); typedef sofa::core::topology::Tetrahedron Tetrahedron; typedef sofa::core::topology::Hexahedron Hexahedron; diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/config.h.in b/applications/plugins/VolumetricRendering/src/VolumetricRendering/config.h.in index 40f6cac6c86..bb9fb08d30a 100644 --- a/applications/plugins/VolumetricRendering/src/VolumetricRendering/config.h.in +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/config.h.in @@ -33,4 +33,10 @@ # define SOFA_VOLUMETRICRENDERING_API SOFA_IMPORT_DYNAMIC_LIBRARY #endif +namespace volumetricrendering +{ + constexpr const char* MODULE_NAME = "@PROJECT_NAME@"; + constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@"; +} + #endif diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.cpp b/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.cpp index 3008b366634..de1556a8deb 100644 --- a/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.cpp +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.cpp @@ -19,10 +19,10 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ +#include +#include -#include - -namespace sofa::component +namespace volumetricrendering { //Here are just several convenient functions to help user to know what contains the plugin @@ -36,6 +36,11 @@ extern "C" { SOFA_VOLUMETRICRENDERING_API const char* getModuleComponentList(); } +void init() +{ + initExternalModule(); +} + void initExternalModule() { static bool first = true; @@ -47,12 +52,12 @@ void initExternalModule() const char* getModuleName() { - return "VolumetricRendering"; + return volumetricrendering::MODULE_NAME; } const char* getModuleVersion() { - return "0.1"; + return volumetricrendering::MODULE_VERSION; } const char* getModuleLicense() @@ -68,9 +73,9 @@ const char* getModuleDescription() const char* getModuleComponentList() { - return "OglTetrahedralModel"; + static std::string classes = sofa::core::ObjectFactory::getInstance()->listClassesFromTarget(volumetricrendering::MODULE_NAME); + return classes.c_str(); } -} // namespace sofa::component - +} // namespace volumetricrendering diff --git a/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.h b/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.h new file mode 100644 index 00000000000..fb505e5a842 --- /dev/null +++ b/applications/plugins/VolumetricRendering/src/VolumetricRendering/initVolumetricRendering.h @@ -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 . * +******************************************************************************* +* Authors: The SOFA Team and external contributors (see Authors.txt) * +* * +* Contact information: contact@sofa-framework.org * +******************************************************************************/ +#pragma once + +#include + +namespace volumetricrendering +{ +SOFA_VOLUMETRICRENDERING_API void init(); +}