From 25233edb93bf9bb6ef239bd4c825de2e555c2770 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 08:50:52 +0100 Subject: [PATCH 01/12] move files --- Sofa/Component/Visual/CMakeLists.txt | 2 ++ .../Visual/src/sofa/component/visual/CylinderVisualModel.cpp} | 0 .../Visual/src/sofa/component/visual/CylinderVisualModel.h} | 0 3 files changed, 2 insertions(+) rename Sofa/{GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.cpp => Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp} (100%) rename Sofa/{GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h => Component/Visual/src/sofa/component/visual/CylinderVisualModel.h} (100%) diff --git a/Sofa/Component/Visual/CMakeLists.txt b/Sofa/Component/Visual/CMakeLists.txt index 8dd7b074047..d1a525f0c29 100644 --- a/Sofa/Component/Visual/CMakeLists.txt +++ b/Sofa/Component/Visual/CMakeLists.txt @@ -8,6 +8,7 @@ set(HEADER_FILES ${SOFACOMPONENTVISUAL_SOURCE_DIR}/init.h ${SOFACOMPONENTVISUAL_SOURCE_DIR}/BaseCamera.h ${SOFACOMPONENTVISUAL_SOURCE_DIR}/Camera.h + ${SOFACOMPONENTVISUAL_SOURCE_DIR}/CylinderVisualModel.h ${SOFACOMPONENTVISUAL_SOURCE_DIR}/InteractiveCamera.h ${SOFACOMPONENTVISUAL_SOURCE_DIR}/LineAxis.h ${SOFACOMPONENTVISUAL_SOURCE_DIR}/RecordedCamera.h @@ -24,6 +25,7 @@ set(SOURCE_FILES ${SOFACOMPONENTVISUAL_SOURCE_DIR}/init.cpp ${SOFACOMPONENTVISUAL_SOURCE_DIR}/BaseCamera.cpp ${SOFACOMPONENTVISUAL_SOURCE_DIR}/Camera.cpp + ${SOFACOMPONENTVISUAL_SOURCE_DIR}/CylinderVisualModel.cpp ${SOFACOMPONENTVISUAL_SOURCE_DIR}/InteractiveCamera.cpp ${SOFACOMPONENTVISUAL_SOURCE_DIR}/LineAxis.cpp ${SOFACOMPONENTVISUAL_SOURCE_DIR}/RecordedCamera.cpp diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp similarity index 100% rename from Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.cpp rename to Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h similarity index 100% rename from Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h rename to Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h From abbed2d6ea1eae9a67b950dc488492ff2d361a24 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 08:54:40 +0100 Subject: [PATCH 02/12] depreciation --- Sofa/GL/Component/Rendering3D/CMakeLists.txt | 1 - .../component/rendering3d/OglCylinderModel.h | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h diff --git a/Sofa/GL/Component/Rendering3D/CMakeLists.txt b/Sofa/GL/Component/Rendering3D/CMakeLists.txt index 112674f2623..948bc3ac2b8 100644 --- a/Sofa/GL/Component/Rendering3D/CMakeLists.txt +++ b/Sofa/GL/Component/Rendering3D/CMakeLists.txt @@ -21,7 +21,6 @@ set(SOURCE_FILES ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/ClipPlane.cpp ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/DataDisplay.cpp ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/MergeVisualModels.cpp - ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/OglCylinderModel.cpp ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/OglModel.cpp ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/OglSceneFrame.cpp ${SOFAGLCOMPONENTRENDERING3D_SOURCE_DIR}/PointSplatModel.cpp diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h new file mode 100644 index 00000000000..0516b13741a --- /dev/null +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h @@ -0,0 +1,27 @@ +/****************************************************************************** +* 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 + +SOFA_HEADER_DEPRECATED("v24.12", "v25.06", "sofa/component/visual/CylinderVisualModel.h") + +#include From e6333c1d6c978bfc555570c14c7c7690d9c9ab80 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 09:21:24 +0100 Subject: [PATCH 03/12] rename --- .../component/visual/CylinderVisualModel.cpp | 27 +++++++++---------- .../component/visual/CylinderVisualModel.h | 16 +++++------ .../Visual/src/sofa/component/visual/init.cpp | 2 ++ .../component/rendering3d/OglCylinderModel.h | 5 ++++ ...inderModel.scn => CylinderVisualModel.scn} | 4 +-- 5 files changed, 30 insertions(+), 24 deletions(-) rename examples/Component/Visual/{OglCylinderModel.scn => CylinderVisualModel.scn} (81%) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index 9067ba2522b..e3755ca5e7c 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -19,8 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#include -#include +#include #include #include #include @@ -28,19 +27,19 @@ #include #include -namespace sofa::gl::component::rendering3d +namespace sofa::component::visual { -void registerOglCylinderModel(sofa::core::ObjectFactory* factory) +void registerCylinderVisualModel(sofa::core::ObjectFactory* factory) { - factory->registerObjects(core::ObjectRegistrationData("OpenGL-based visualization for a cylinders over edges.") - .add< OglCylinderModel >()); + factory->registerObjects(core::ObjectRegistrationData("A simple visualization for set of cylinder.") + .add< CylinderVisualModel >()); } using namespace sofa::defaulttype; using namespace sofa::core::topology; -OglCylinderModel::OglCylinderModel() +CylinderVisualModel::CylinderVisualModel() : radius(initData(&radius, 1.0f, "radius", "Radius of the cylinder.")), color(initData(&color, sofa::type::RGBAColor(1.0,1.0,1.0,1.0), "color", "Color of the cylinders.")) , d_edges(initData(&d_edges,"edges","List of edge indices")) @@ -48,18 +47,18 @@ OglCylinderModel::OglCylinderModel() { } -OglCylinderModel::~OglCylinderModel() +CylinderVisualModel::~CylinderVisualModel() { } -void OglCylinderModel::init() +void CylinderVisualModel::init() { VisualModel::init(); reinit(); } -void OglCylinderModel::doDrawVisual(const core::visual::VisualParams* vparams) +void CylinderVisualModel::doDrawVisual(const core::visual::VisualParams* vparams) { const VecCoord& pos = this->read( core::vec_id::read_access::position )->getValue(); @@ -80,7 +79,7 @@ void OglCylinderModel::doDrawVisual(const core::visual::VisualParams* vparams) } -void OglCylinderModel::setColor(float r, float g, float b, float a) +void CylinderVisualModel::setColor(float r, float g, float b, float a) { this->r = r; this->g = g; @@ -96,7 +95,7 @@ static int hexval(char c) else return 0; } -void OglCylinderModel::setColor(std::string color) +void CylinderVisualModel::setColor(std::string color) { if (color.empty()) return; float r = 1.0f; @@ -140,7 +139,7 @@ void OglCylinderModel::setColor(std::string color) setColor(r,g,b,a); } -void OglCylinderModel::exportOBJ(std::string name, std::ostream* out, std::ostream* /*mtl*/, Index& vindex, Index& /*nindex*/, Index& /*tindex*/, int& /*count*/) +void CylinderVisualModel::exportOBJ(std::string name, std::ostream* out, std::ostream* /*mtl*/, Index& vindex, Index& /*nindex*/, Index& /*tindex*/, int& /*count*/) { const VecCoord& x = this->read( core::vec_id::read_access::position )->getValue(); const SeqEdges& edges = d_edges.getValue(); @@ -160,4 +159,4 @@ void OglCylinderModel::exportOBJ(std::string name, std::ostream* out, std::ostre vindex += nbv; } -} // namespace sofa::gl::component::rendering3d +} // namespace sofa::component::visual diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h index bf7edeebf1b..0fcbeafa821 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h @@ -20,7 +20,7 @@ * Contact information: contact@sofa-framework.org * ******************************************************************************/ #pragma once -#include +#include #include #include @@ -39,20 +39,20 @@ namespace sofa::core::behavior class BaseMechanicalState; } // namespace sofa::core::behavior -namespace sofa::gl::component::rendering3d +namespace sofa::component::visual { -// I have no idea what is Ogl in this component ?... -class SOFA_GL_COMPONENT_RENDERING3D_API OglCylinderModel : public core::visual::VisualModel, public sofa::core::visual::VisualState +class SOFA_COMPONENT_VISUAL_API CylinderVisualModel : + public core::visual::VisualModel, public sofa::core::visual::VisualState { public: using Vec3State = sofa::core::visual::VisualState; - SOFA_CLASS2(OglCylinderModel,core::visual::VisualModel, Vec3State); + SOFA_CLASS2(CylinderVisualModel,core::visual::VisualModel, Vec3State); using Index = sofa::Index; protected: - OglCylinderModel(); - ~OglCylinderModel() override; + CylinderVisualModel(); + ~CylinderVisualModel() override; public: void init() override; @@ -85,4 +85,4 @@ class SOFA_GL_COMPONENT_RENDERING3D_API OglCylinderModel : public core::visual:: bool removeInNode( core::objectmodel::BaseNode* node ) override { Inherit1::removeInNode(node); Inherit2::removeInNode(node); return true; } }; -} // namespace sofa::gl::component::rendering3d +} // namespace sofa::component::visual diff --git a/Sofa/Component/Visual/src/sofa/component/visual/init.cpp b/Sofa/Component/Visual/src/sofa/component/visual/init.cpp index b2f8a2c08eb..c4060d561ac 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/init.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/init.cpp @@ -27,6 +27,7 @@ namespace sofa::component::visual { extern void registerCamera(sofa::core::ObjectFactory* factory); +extern void registerCylinderVisualModel(sofa::core::ObjectFactory* factory); extern void registerInteractiveCamera(sofa::core::ObjectFactory* factory); extern void registerLineAxis(sofa::core::ObjectFactory* factory); extern void registerRecordedCamera(sofa::core::ObjectFactory* factory); @@ -63,6 +64,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) { registerCamera(factory); registerInteractiveCamera(factory); + registerCylinderVisualModel(factory); registerLineAxis(factory); registerRecordedCamera(factory); registerTrailRenderer(factory); diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h index 0516b13741a..bcbd1d60cfa 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/OglCylinderModel.h @@ -25,3 +25,8 @@ SOFA_HEADER_DEPRECATED("v24.12", "v25.06", "sofa/component/visual/CylinderVisualModel.h") #include + +namespace sofa::gl::component::rendering3d +{ +using OglCylinderModel = sofa::component::visual::CylinderVisualModel; +} diff --git a/examples/Component/Visual/OglCylinderModel.scn b/examples/Component/Visual/CylinderVisualModel.scn similarity index 81% rename from examples/Component/Visual/OglCylinderModel.scn rename to examples/Component/Visual/CylinderVisualModel.scn index 0db4bc72a6c..b0c910782a1 100644 --- a/examples/Component/Visual/OglCylinderModel.scn +++ b/examples/Component/Visual/CylinderVisualModel.scn @@ -4,6 +4,6 @@ - + - \ No newline at end of file + From 632494cc240cf3409ad8653548d3e7ee4712dedc Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 09:29:42 +0100 Subject: [PATCH 04/12] fix color management --- .../src/sofa/component/visual/CylinderVisualModel.cpp | 9 +++------ .../src/sofa/component/visual/CylinderVisualModel.h | 1 - examples/Component/Visual/CylinderVisualModel.scn | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index e3755ca5e7c..5a6e4a3e2bb 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -41,7 +41,7 @@ using namespace sofa::core::topology; CylinderVisualModel::CylinderVisualModel() : radius(initData(&radius, 1.0f, "radius", "Radius of the cylinder.")), - color(initData(&color, sofa::type::RGBAColor(1.0,1.0,1.0,1.0), "color", "Color of the cylinders.")) + color(initData(&color, sofa::type::RGBAColor::white(), "color", "Color of the cylinders.")) , d_edges(initData(&d_edges,"edges","List of edge indices")) // , pointData(initData(&pointData, "pointData", "scalar field modulating point colors")) { @@ -65,7 +65,7 @@ void CylinderVisualModel::doDrawVisual(const core::visual::VisualParams* vparams vparams->drawTool()->setLightingEnabled(true); const float _radius = radius.getValue(); - const sofa::type::RGBAColor col( r, g, b, a ); + const sofa::type::RGBAColor& col = color.getValue(); const SeqEdges& edges = d_edges.getValue(); @@ -81,10 +81,7 @@ void CylinderVisualModel::doDrawVisual(const core::visual::VisualParams* vparams void CylinderVisualModel::setColor(float r, float g, float b, float a) { - this->r = r; - this->g = g; - this->b = b; - this->a = a; + color.setValue(type::RGBAColor(r,g,b,a)); } static int hexval(char c) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h index 0fcbeafa821..4ab295422e6 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h @@ -73,7 +73,6 @@ class SOFA_COMPONENT_VISUAL_API CylinderVisualModel : Data d_edges; ///< List of edge indices - float r,g,b,a; // sofa::core::topology::PointData > pointData; typedef Vec3State::Coord Coord; diff --git a/examples/Component/Visual/CylinderVisualModel.scn b/examples/Component/Visual/CylinderVisualModel.scn index b0c910782a1..de585f084c1 100644 --- a/examples/Component/Visual/CylinderVisualModel.scn +++ b/examples/Component/Visual/CylinderVisualModel.scn @@ -4,6 +4,6 @@ - + From 896ba59061e5197da595863cbd79d30e15eeb2cd Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 09:33:14 +0100 Subject: [PATCH 05/12] remove string to color conversion and use the one from RGBAColor --- .../component/visual/CylinderVisualModel.cpp | 49 +------------------ 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index 5a6e4a3e2bb..5de9e7e3aba 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -84,56 +84,9 @@ void CylinderVisualModel::setColor(float r, float g, float b, float a) color.setValue(type::RGBAColor(r,g,b,a)); } -static int hexval(char c) -{ - if (c>='0' && c<='9') return c-'0'; - else if (c>='a' && c<='f') return (c-'a')+10; - else if (c>='A' && c<='F') return (c-'A')+10; - else return 0; -} - void CylinderVisualModel::setColor(std::string color) { - if (color.empty()) return; - float r = 1.0f; - float g = 1.0f; - float b = 1.0f; - float a = 1.0f; - if (color[0]>='0' && color[0]<='9') - { - sscanf(color.c_str(),"%f %f %f %f", &r, &g, &b, &a); - } - else if (color[0]=='#' && color.length()>=7) - { - r = (hexval(color[1])*16+hexval(color[2]))/255.0f; - g = (hexval(color[3])*16+hexval(color[4]))/255.0f; - b = (hexval(color[5])*16+hexval(color[6]))/255.0f; - if (color.length()>=9) - a = (hexval(color[7])*16+hexval(color[8]))/255.0f; - } - else if (color[0]=='#' && color.length()>=4) - { - r = (hexval(color[1])*17)/255.0f; - g = (hexval(color[2])*17)/255.0f; - b = (hexval(color[3])*17)/255.0f; - if (color.length()>=5) - a = (hexval(color[4])*17)/255.0f; - } - else if (color == "white") { r = 1.0f; g = 1.0f; b = 1.0f; } - else if (color == "black") { r = 0.0f; g = 0.0f; b = 0.0f; } - else if (color == "red") { r = 1.0f; g = 0.0f; b = 0.0f; } - else if (color == "green") { r = 0.0f; g = 1.0f; b = 0.0f; } - else if (color == "blue") { r = 0.0f; g = 0.0f; b = 1.0f; } - else if (color == "cyan") { r = 0.0f; g = 1.0f; b = 1.0f; } - else if (color == "magenta") { r = 1.0f; g = 0.0f; b = 1.0f; } - else if (color == "yellow") { r = 1.0f; g = 1.0f; b = 0.0f; } - else if (color == "gray") { r = 0.5f; g = 0.5f; b = 0.5f; } - else - { - msg_error() << "Unknown color " << color; - return; - } - setColor(r,g,b,a); + this->color.setValue(type::RGBAColor::fromString(color)); } void CylinderVisualModel::exportOBJ(std::string name, std::ostream* out, std::ostream* /*mtl*/, Index& vindex, Index& /*nindex*/, Index& /*tindex*/, int& /*count*/) From 672f48df8d8012ce71967acb5709bb9983ad87e4 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 09:34:00 +0100 Subject: [PATCH 06/12] remove unused private methods --- .../src/sofa/component/visual/CylinderVisualModel.cpp | 11 ----------- .../src/sofa/component/visual/CylinderVisualModel.h | 4 ---- 2 files changed, 15 deletions(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index 5de9e7e3aba..9b8e5c3963e 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -78,17 +78,6 @@ void CylinderVisualModel::doDrawVisual(const core::visual::VisualParams* vparams } } - -void CylinderVisualModel::setColor(float r, float g, float b, float a) -{ - color.setValue(type::RGBAColor(r,g,b,a)); -} - -void CylinderVisualModel::setColor(std::string color) -{ - this->color.setValue(type::RGBAColor::fromString(color)); -} - void CylinderVisualModel::exportOBJ(std::string name, std::ostream* out, std::ostream* /*mtl*/, Index& vindex, Index& /*nindex*/, Index& /*tindex*/, int& /*count*/) { const VecCoord& x = this->read( core::vec_id::read_access::position )->getValue(); diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h index 4ab295422e6..724b13acf3a 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h @@ -60,10 +60,6 @@ class SOFA_COMPONENT_VISUAL_API CylinderVisualModel : void exportOBJ(std::string /*name*/, std::ostream* /*out*/, std::ostream* /*mtl*/, Index& /*vindex*/, Index& /*nindex*/, Index& /*tindex*/, int& /*count*/) override; -private: - void setColor(float r, float g, float b, float a); - void setColor(std::string color); - private: Data radius; ///< Radius of the cylinder. // Data alpha; From bc6a0de12f39ea3b48329dab8b91ac7bcc887ed6 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 09:36:59 +0100 Subject: [PATCH 07/12] cleaning --- .../component/visual/CylinderVisualModel.cpp | 11 +--------- .../component/visual/CylinderVisualModel.h | 21 ------------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index 9b8e5c3963e..f85a2b87a2d 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -21,10 +21,7 @@ ******************************************************************************/ #include #include -#include -#include #include -#include #include namespace sofa::component::visual @@ -36,20 +33,14 @@ void registerCylinderVisualModel(sofa::core::ObjectFactory* factory) .add< CylinderVisualModel >()); } -using namespace sofa::defaulttype; -using namespace sofa::core::topology; - CylinderVisualModel::CylinderVisualModel() : radius(initData(&radius, 1.0f, "radius", "Radius of the cylinder.")), color(initData(&color, sofa::type::RGBAColor::white(), "color", "Color of the cylinders.")) , d_edges(initData(&d_edges,"edges","List of edge indices")) - // , pointData(initData(&pointData, "pointData", "scalar field modulating point colors")) { } -CylinderVisualModel::~CylinderVisualModel() -{ -} +CylinderVisualModel::~CylinderVisualModel() = default; void CylinderVisualModel::init() { diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h index 724b13acf3a..e4fbd307e62 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h @@ -24,21 +24,8 @@ #include #include -#include -#include -#include #include -namespace sofa::core::topology -{ - class BaseMeshTopology; -} // namespace sofa::core::topology - -namespace sofa::core::behavior -{ - class BaseMechanicalState; -} // namespace sofa::core::behavior - namespace sofa::component::visual { @@ -62,19 +49,11 @@ class SOFA_COMPONENT_VISUAL_API CylinderVisualModel : private: Data radius; ///< Radius of the cylinder. - // Data alpha; Data color; ///< Color of the cylinders. typedef sofa::type::vector SeqEdges; Data d_edges; ///< List of edge indices - - // sofa::core::topology::PointData > pointData; - - typedef Vec3State::Coord Coord; - typedef Vec3State::VecCoord VecCoord; - typedef Vec3State::Real Real; - public: bool insertInNode( core::objectmodel::BaseNode* node ) override { Inherit1::insertInNode(node); Inherit2::insertInNode(node); return true; } bool removeInNode( core::objectmodel::BaseNode* node ) override { Inherit1::removeInNode(node); Inherit2::removeInNode(node); return true; } From 4dbfb5fbb96be82604f9cd0e551c3104a9d0da9d Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Fri, 15 Nov 2024 09:44:52 +0100 Subject: [PATCH 08/12] component change --- Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp | 8 +++++--- examples/Component/Visual/CylinderVisualModel.scn | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index fa6c8375885..fcfb5e13734 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -622,7 +622,9 @@ const std::map > movedComponents = { { "SparseLUSolver", Moved("v23.12", "Sofa.Component.LinearSolver.Direct", "CSparseSolvers") }, // Moved to Sofa.Component.MechanicalLoad - { "Gravity", Moved("v24.12", "SofaGraphComponent", "Sofa.Component.Mechanicalload") } + { "Gravity", Moved("v24.12", "SofaGraphComponent", "Sofa.Component.Mechanicalload") }, + + { "OglCylinderModel", Moved("v24.12", "Sofa.GL.Component.Rendering3D", "Sofa.Component.Visual")} }; const std::map > uncreatableComponents = { @@ -760,8 +762,8 @@ const std::map< std::string, Renamed, std::less<> > renamedComponents = { {"UnilateralInteractionConstraint", Renamed("v24.06","v25.06","UnilateralLagrangianConstraint")}, {"StiffSpringForceField", Renamed("v24.06","v25.06","SpringForceField")}, {"ParallelStiffSpringForceField", Renamed("v24.06","v25.06","ParallelSpringForceField")}, - {"ShewchukPCGLinearSolver", Renamed("v24.12","v25.12","PCGLinearSolver")} - + {"ShewchukPCGLinearSolver", Renamed("v24.12","v25.12","PCGLinearSolver")}, + {"OglCylinderModel", Renamed("v24.12", "v25.06", "CylinderVisualModel")} }; diff --git a/examples/Component/Visual/CylinderVisualModel.scn b/examples/Component/Visual/CylinderVisualModel.scn index de585f084c1..65191fc0e44 100644 --- a/examples/Component/Visual/CylinderVisualModel.scn +++ b/examples/Component/Visual/CylinderVisualModel.scn @@ -1,7 +1,6 @@ - - + From be412a9a0c6da84057396e2016188be8c6525e9c Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 12 Dec 2024 10:58:44 +0100 Subject: [PATCH 09/12] remove Index alias --- .../Visual/src/sofa/component/visual/CylinderVisualModel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h index e4fbd307e62..f61b021977f 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.h @@ -36,7 +36,6 @@ class SOFA_COMPONENT_VISUAL_API CylinderVisualModel : using Vec3State = sofa::core::visual::VisualState; SOFA_CLASS2(CylinderVisualModel,core::visual::VisualModel, Vec3State); - using Index = sofa::Index; protected: CylinderVisualModel(); ~CylinderVisualModel() override; From 0e256ea7b811c2a21b25b1532e14eb2c6bf2d02b Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 12 Dec 2024 10:59:59 +0100 Subject: [PATCH 10/12] change the description --- .../Visual/src/sofa/component/visual/CylinderVisualModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index f85a2b87a2d..ab5496f586d 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -29,7 +29,7 @@ namespace sofa::component::visual void registerCylinderVisualModel(sofa::core::ObjectFactory* factory) { - factory->registerObjects(core::ObjectRegistrationData("A simple visualization for set of cylinder.") + factory->registerObjects(core::ObjectRegistrationData("Visualize a set of cylinders.") .add< CylinderVisualModel >()); } From eb247a1fe2b2dddc9411dd3295e3a74ec03ce687 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 12 Dec 2024 11:03:19 +0100 Subject: [PATCH 11/12] cache drawTool --- .../src/sofa/component/visual/CylinderVisualModel.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp index ab5496f586d..98d778731bd 100644 --- a/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp +++ b/Sofa/Component/Visual/src/sofa/component/visual/CylinderVisualModel.cpp @@ -53,19 +53,21 @@ void CylinderVisualModel::doDrawVisual(const core::visual::VisualParams* vparams { const VecCoord& pos = this->read( core::vec_id::read_access::position )->getValue(); - vparams->drawTool()->setLightingEnabled(true); - const float _radius = radius.getValue(); + auto* drawTool = vparams->drawTool(); + + drawTool->setLightingEnabled(true); + const float _radius = radius.getValue(); const sofa::type::RGBAColor& col = color.getValue(); const SeqEdges& edges = d_edges.getValue(); - for(auto edge : edges) + for(const auto& edge : edges) { const Coord& p1 = pos[edge[0]]; const Coord& p2 = pos[edge[1]]; - vparams->drawTool()->drawCylinder(p1,p2,_radius,col); + drawTool->drawCylinder(p1, p2, _radius, col); } } From c8ab58a4300ed561144b8475c640c150a9977d1a Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Mon, 16 Dec 2024 10:28:23 +0100 Subject: [PATCH 12/12] remove calls to removed functions --- .../Rendering3D/src/sofa/gl/component/rendering3d/init.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/init.cpp b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/init.cpp index a4096afa836..61a827c7dea 100644 --- a/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/init.cpp +++ b/Sofa/GL/Component/Rendering3D/src/sofa/gl/component/rendering3d/init.cpp @@ -29,7 +29,6 @@ namespace sofa::gl::component::rendering3d extern void registerClipPlane(sofa::core::ObjectFactory* factory); extern void registerDataDisplay(sofa::core::ObjectFactory* factory); extern void registerMergeVisualModels(sofa::core::ObjectFactory* factory); -extern void registerOglCylinderModel(sofa::core::ObjectFactory* factory); extern void registerOglModel(sofa::core::ObjectFactory* factory); extern void registerOglSceneFrame(sofa::core::ObjectFactory* factory); extern void registerPointSplatModel(sofa::core::ObjectFactory* factory); @@ -62,7 +61,6 @@ void registerObjects(sofa::core::ObjectFactory* factory) registerClipPlane(factory); registerDataDisplay(factory); registerMergeVisualModels(factory); - registerOglCylinderModel(factory); registerOglModel(factory); registerOglSceneFrame(factory); registerPointSplatModel(factory);