From c2d68e75582c6f253568bd86cddca7368d56086a Mon Sep 17 00:00:00 2001 From: epernod Date: Sat, 27 Aug 2022 00:45:17 +0200 Subject: [PATCH 01/13] =?UTF-8?q?=EF=BB=BF[Topology]=20rename=20method=20i?= =?UTF-8?q?nitTpology=20into=20initContainers=20and=20provide=20access=20t?= =?UTF-8?q?o=20it=20from=20BaseMeshTopology?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../topology/container/constant/MeshTopology.cpp | 12 +++++++++++- .../topology/container/constant/MeshTopology.h | 3 +++ .../container/dynamic/EdgeSetTopologyContainer.cpp | 4 ++-- .../container/dynamic/EdgeSetTopologyContainer.h | 2 +- .../dynamic/HexahedronSetTopologyContainer.cpp | 6 +++--- .../dynamic/HexahedronSetTopologyContainer.h | 4 ++-- .../container/dynamic/QuadSetTopologyContainer.cpp | 6 +++--- .../container/dynamic/QuadSetTopologyContainer.h | 4 ++-- .../dynamic/TetrahedronSetTopologyContainer.cpp | 6 +++--- .../dynamic/TetrahedronSetTopologyContainer.h | 4 ++-- .../dynamic/TriangleSetTopologyContainer.cpp | 6 +++--- .../container/dynamic/TriangleSetTopologyContainer.h | 4 ++-- .../Core/src/sofa/core/topology/BaseMeshTopology.cpp | 1 - .../Core/src/sofa/core/topology/BaseMeshTopology.h | 3 +++ 14 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 5ae461075e0..8061b91a079 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -524,7 +524,6 @@ MeshTopology::MeshTopology() void MeshTopology::init() { - BaseMeshTopology::init(); const auto hexahedra = sofa::helper::getReadAccessor(d_seqHexahedra); @@ -549,6 +548,17 @@ void MeshTopology::init() m_upperElementType = sofa::geometry::ElementType::POINT; + initContainers(); +} + +void MeshTopology::initContainers() +{ + const auto hexahedra = sofa::helper::getReadAccessor(seqHexahedra); + const auto tetrahedra = sofa::helper::getReadAccessor(seqTetrahedra); + const auto quads = sofa::helper::getReadAccessor(seqQuads); + const auto triangles = sofa::helper::getReadAccessor(seqTriangles); + const auto edges = sofa::helper::getReadAccessor(seqEdges); + // compute the number of points, if the topology is charged from the scene or if it was loaded from a MeshLoader without any points data. if (nbPoints==0) { diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h index d4b0d37e717..e717f271a29 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h @@ -86,6 +86,9 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_CONSTANT_API MeshTopology : public core: public: void init() override; + /// Method called by component Init method. Will create all the topology buffers + void initContainers() override; + Size getNbPoints() const override; void setNbPoints(Size n) override; diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp index 15ddadbc529..b96ff63beae 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp @@ -77,10 +77,10 @@ void EdgeSetTopologyContainer::init() // only init if edges are present at init. if (!m_edge.empty()) - initTopology(); + initContainers(); } -void EdgeSetTopologyContainer::initTopology() +void EdgeSetTopologyContainer::initContainers() { // force computation of neighborhood elements createEdgesAroundVertexArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h index 2cf809bbe3a..6c43225835f 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h @@ -100,7 +100,7 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetTopologyContainer : p /// Dynamic Topology API /// @{ /// Method called by component Init method. Will create all the topology neighborhood buffers. - void initTopology(); + void initContainers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp index b8fb2b1c268..6a162d91bdd 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp @@ -83,12 +83,12 @@ void HexahedronSetTopologyContainer::init() } if (!m_hexahedron.empty()) - initTopology(); + initContainers(); } -void HexahedronSetTopologyContainer::initTopology() +void HexahedronSetTopologyContainer::initContainers() { - QuadSetTopologyContainer::initTopology(); + QuadSetTopologyContainer::initContainers(); // Create tetrahedron cross element buffers. createQuadsInHexahedronArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h index 65238e957a2..4a7004afe76 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h @@ -222,8 +222,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API HexahedronSetTopologyContain /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighborhood buffers and call @see TriangleSetTopologyContainer::initTopology() - void initTopology(); + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see QuadSetTopologyContainer::initContainers() + void initContainers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp index b9434772f7f..4cc2d197f66 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp @@ -72,13 +72,13 @@ void QuadSetTopologyContainer::init() // only init if triangles are present at init. if (!m_quads.empty()) - initTopology(); + initContainers(); } -void QuadSetTopologyContainer::initTopology() +void QuadSetTopologyContainer::initContainers() { // Force creation of Edge Neighborhood buffers. - EdgeSetTopologyContainer::initTopology(); + EdgeSetTopologyContainer::initContainers(); // Create triangle cross element buffers. createEdgesInQuadArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h index 54a78981e3a..653a392e745 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h @@ -144,8 +144,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API QuadSetTopologyContainer : p /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighborhood buffers and call @see EdgeSetTopologyContainer::initTopology() - void initTopology(); + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see EdgeSetTopologyContainer::initContainers() + void initContainers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp index d8fbe58adcd..409ed753f79 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp @@ -79,12 +79,12 @@ void TetrahedronSetTopologyContainer::init() } if (!m_tetrahedron.empty()) - initTopology(); + initContainers(); } -void TetrahedronSetTopologyContainer::initTopology() +void TetrahedronSetTopologyContainer::initContainers() { - TriangleSetTopologyContainer::initTopology(); + TriangleSetTopologyContainer::initContainers(); // Create tetrahedron cross element buffers. createTrianglesInTetrahedronArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h index 089d3e6f7f2..93d96fbc107 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h @@ -193,8 +193,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API TetrahedronSetTopologyContai /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighborhood buffers and call @see TriangleSetTopologyContainer::initTopology() - void initTopology(); + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see TriangleSetTopologyContainer::initContainers() + void initContainers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp index cfc69119e8c..c577417c949 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp @@ -73,13 +73,13 @@ void TriangleSetTopologyContainer::init() // only init if triangles are present at init. if (!m_triangle.empty()) - initTopology(); + initContainers(); } -void TriangleSetTopologyContainer::initTopology() +void TriangleSetTopologyContainer::initContainers() { // Force creation of Edge Neighborhood buffers. - EdgeSetTopologyContainer::initTopology(); + EdgeSetTopologyContainer::initContainers(); // Create triangle cross element buffers. createEdgesInTriangleArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h index 8c41f4a5ecd..8b81d44715a 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h @@ -151,8 +151,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API TriangleSetTopologyContainer /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighborhood buffers and call @see EdgeSetTopologyContainer::initTopology() - void initTopology(); + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see EdgeSetTopologyContainer::initContainers() + void initContainers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.cpp b/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.cpp index f1fbc45235f..7eb1494c17d 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.cpp +++ b/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.cpp @@ -23,7 +23,6 @@ #include #include #include - namespace sofa::core::topology { diff --git a/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h b/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h index 2a5348f3eb3..a839ce10f2d 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h +++ b/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h @@ -85,6 +85,9 @@ class SOFA_CORE_API BaseMeshTopology : public core::topology::Topology public: void init() override; + /// Method to be overriden by child class to create all the topology buffers + virtual void initContainers() {} + /// Load the topology from a file. /// /// The default implementation supports the following formats: obj, gmsh, mesh (custom simple text file), xs3 (deprecated description of mass-springs networks). From 66b7e90adfae0e9ef50eb8df8eb040df3fc5caab Mon Sep 17 00:00:00 2001 From: epernod Date: Sat, 27 Aug 2022 00:46:03 +0200 Subject: [PATCH 02/13] [MultiThreading] Replace call to getter to init topology by call to initContainers --- .../algorithm/ParallelBVHNarrowPhase.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp index db0659a8504..a46aa5b2b86 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp @@ -132,22 +132,7 @@ void ParallelBVHNarrowPhase::initializeTopology(sofa::core::topology::BaseMeshTo auto insertionIt = m_initializedTopology.insert(topology); if (insertionIt.second) { - // The following calls force the creation of some topology arrays before the concurrent computing. - // Those arrays cannot be created on the fly, in a concurrent environment, - // due to possible race conditions. - // Depending on the scene graph, it is possible that those calls are not enough. - if (topology->getNbPoints()) - { - topology->getTrianglesAroundVertex(0); - } - if (topology->getNbTriangles()) - { - topology->getEdgesInTriangle(0); - } - if (topology->getNbEdges()) - { - topology->getTrianglesAroundEdge(0); - } + topology->initContainers(); } } From 0e9c1ea0486ec57d82ca3ef2e00fadd2137414a5 Mon Sep 17 00:00:00 2001 From: epernod Date: Mon, 31 Oct 2022 21:34:28 +0100 Subject: [PATCH 03/13] Fix MeshTopology initContainer --- .../container/constant/MeshTopology.cpp | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 8061b91a079..653b8a5969f 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -532,7 +532,6 @@ void MeshTopology::init() const auto triangles = sofa::helper::getReadAccessor(d_seqTriangles); const auto edges = sofa::helper::getReadAccessor(d_seqEdges); - // looking for upper topology if (!hexahedra.empty()) m_upperElementType = geometry::ElementType::HEXAHEDRON; @@ -586,6 +585,65 @@ void MeshTopology::initContainers() nbPoints = n; } + + if (!hexahedra.empty()) // Create hexahedron cross element buffers. + { + createHexahedraAroundVertexArray(); + + if (!quads.empty()) + { + createQuadsInHexahedronArray(); + createHexahedraAroundQuadArray(); + } + + if (!edges.empty()) + { + createEdgesInHexahedronArray(); + createHexahedraAroundEdgeArray(); + } + } + if (!tetrahedra.empty()) // Create tetrahedron cross element buffers. + { + createTetrahedraAroundVertexArray(); + + if (!triangles.empty()) + { + createTrianglesInTetrahedronArray(); + createTetrahedraAroundTriangleArray(); + } + + if (!edges.empty()) + { + createEdgesInTetrahedronArray(); + createTetrahedraAroundEdgeArray(); + } + } + if (!quads.empty()) // Create triangle cross element buffers. + { + createQuadsAroundVertexArray(); + + if (!edges.empty()) + { + createEdgesInQuadArray(); + createQuadsAroundEdgeArray(); + } + } + if (!triangles.empty()) // Create triangle cross element buffers. + { + createTrianglesAroundVertexArray(); + + if (!edges.empty()) + { + createEdgesInTriangleArray(); + createTrianglesAroundEdgeArray(); + } + } + if (!edges.empty()) + { + createEdgesAroundVertexArray(); + } + + if(edges.empty() ) { if(d_seqEdges.getParent() != nullptr ) From 45c0b7863fc0fffd2d3a1279578c1623f47e7d03 Mon Sep 17 00:00:00 2001 From: epernod Date: Thu, 3 Nov 2022 12:07:07 +0100 Subject: [PATCH 04/13] =?UTF-8?q?=EF=BB=BFREname=20initContainers=20into?= =?UTF-8?q?=20computeCrossElementBuffers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/topology/container/constant/MeshTopology.cpp | 4 ++-- .../component/topology/container/constant/MeshTopology.h | 2 +- .../topology/container/dynamic/EdgeSetTopologyContainer.cpp | 4 ++-- .../topology/container/dynamic/EdgeSetTopologyContainer.h | 2 +- .../container/dynamic/HexahedronSetTopologyContainer.cpp | 6 +++--- .../container/dynamic/HexahedronSetTopologyContainer.h | 4 ++-- .../topology/container/dynamic/QuadSetTopologyContainer.cpp | 6 +++--- .../topology/container/dynamic/QuadSetTopologyContainer.h | 4 ++-- .../container/dynamic/TetrahedronSetTopologyContainer.cpp | 6 +++--- .../container/dynamic/TetrahedronSetTopologyContainer.h | 4 ++-- .../container/dynamic/TriangleSetTopologyContainer.cpp | 6 +++--- .../container/dynamic/TriangleSetTopologyContainer.h | 4 ++-- .../Core/src/sofa/core/topology/BaseMeshTopology.h | 2 +- .../detection/algorithm/ParallelBVHNarrowPhase.cpp | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 653b8a5969f..9454f1b9747 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -547,10 +547,10 @@ void MeshTopology::init() m_upperElementType = sofa::geometry::ElementType::POINT; - initContainers(); + computeCrossElementBuffers(); } -void MeshTopology::initContainers() +void MeshTopology::computeCrossElementBuffers() { const auto hexahedra = sofa::helper::getReadAccessor(seqHexahedra); const auto tetrahedra = sofa::helper::getReadAccessor(seqTetrahedra); diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h index e717f271a29..d2d58fb186f 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h @@ -87,7 +87,7 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_CONSTANT_API MeshTopology : public core: void init() override; /// Method called by component Init method. Will create all the topology buffers - void initContainers() override; + void computeCrossElementBuffers() override; Size getNbPoints() const override; diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp index b96ff63beae..4e212ff7696 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp @@ -77,10 +77,10 @@ void EdgeSetTopologyContainer::init() // only init if edges are present at init. if (!m_edge.empty()) - initContainers(); + computeCrossElementBuffers(); } -void EdgeSetTopologyContainer::initContainers() +void EdgeSetTopologyContainer::computeCrossElementBuffers() { // force computation of neighborhood elements createEdgesAroundVertexArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h index 6c43225835f..ee9d4404c18 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.h @@ -100,7 +100,7 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetTopologyContainer : p /// Dynamic Topology API /// @{ /// Method called by component Init method. Will create all the topology neighborhood buffers. - void initContainers() override; + void computeCrossElementBuffers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp index 6a162d91bdd..554a87f9352 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.cpp @@ -83,12 +83,12 @@ void HexahedronSetTopologyContainer::init() } if (!m_hexahedron.empty()) - initContainers(); + computeCrossElementBuffers(); } -void HexahedronSetTopologyContainer::initContainers() +void HexahedronSetTopologyContainer::computeCrossElementBuffers() { - QuadSetTopologyContainer::initContainers(); + QuadSetTopologyContainer::computeCrossElementBuffers(); // Create tetrahedron cross element buffers. createQuadsInHexahedronArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h index 4a7004afe76..9bb8f012910 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/HexahedronSetTopologyContainer.h @@ -222,8 +222,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API HexahedronSetTopologyContain /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see QuadSetTopologyContainer::initContainers() - void initContainers() override; + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see QuadSetTopologyContainer::computeCrossElementBuffers() + void computeCrossElementBuffers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp index 4cc2d197f66..d861dfc5ea2 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.cpp @@ -72,13 +72,13 @@ void QuadSetTopologyContainer::init() // only init if triangles are present at init. if (!m_quads.empty()) - initContainers(); + computeCrossElementBuffers(); } -void QuadSetTopologyContainer::initContainers() +void QuadSetTopologyContainer::computeCrossElementBuffers() { // Force creation of Edge Neighborhood buffers. - EdgeSetTopologyContainer::initContainers(); + EdgeSetTopologyContainer::computeCrossElementBuffers(); // Create triangle cross element buffers. createEdgesInQuadArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h index 653a392e745..58efedcc105 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h @@ -144,8 +144,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API QuadSetTopologyContainer : p /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see EdgeSetTopologyContainer::initContainers() - void initContainers() override; + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see EdgeSetTopologyContainer::computeCrossElementBuffers() + void computeCrossElementBuffers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp index 409ed753f79..5ad91e53519 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.cpp @@ -79,12 +79,12 @@ void TetrahedronSetTopologyContainer::init() } if (!m_tetrahedron.empty()) - initContainers(); + computeCrossElementBuffers(); } -void TetrahedronSetTopologyContainer::initContainers() +void TetrahedronSetTopologyContainer::computeCrossElementBuffers() { - TriangleSetTopologyContainer::initContainers(); + TriangleSetTopologyContainer::computeCrossElementBuffers(); // Create tetrahedron cross element buffers. createTrianglesInTetrahedronArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h index 93d96fbc107..2376324fbb2 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TetrahedronSetTopologyContainer.h @@ -193,8 +193,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API TetrahedronSetTopologyContai /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see TriangleSetTopologyContainer::initContainers() - void initContainers() override; + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see TriangleSetTopologyContainer::computeCrossElementBuffers() + void computeCrossElementBuffers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp index c577417c949..577727a1c01 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp @@ -73,13 +73,13 @@ void TriangleSetTopologyContainer::init() // only init if triangles are present at init. if (!m_triangle.empty()) - initContainers(); + computeCrossElementBuffers(); } -void TriangleSetTopologyContainer::initContainers() +void TriangleSetTopologyContainer::computeCrossElementBuffers() { // Force creation of Edge Neighborhood buffers. - EdgeSetTopologyContainer::initContainers(); + EdgeSetTopologyContainer::computeCrossElementBuffers(); // Create triangle cross element buffers. createEdgesInTriangleArray(); diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h index 8b81d44715a..ba0bfa3c8f9 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.h @@ -151,8 +151,8 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API TriangleSetTopologyContainer /// Dynamic Topology API /// @{ - /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see EdgeSetTopologyContainer::initContainers() - void initContainers() override; + /// Method called by component Init method. Will create all the topology neighboorhood buffers and call @see EdgeSetTopologyContainer::computeCrossElementBuffers() + void computeCrossElementBuffers() override; /** \brief Checks if the topology is coherent * diff --git a/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h b/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h index a839ce10f2d..b8b36581ab4 100644 --- a/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h +++ b/Sofa/framework/Core/src/sofa/core/topology/BaseMeshTopology.h @@ -86,7 +86,7 @@ class SOFA_CORE_API BaseMeshTopology : public core::topology::Topology void init() override; /// Method to be overriden by child class to create all the topology buffers - virtual void initContainers() {} + virtual void computeCrossElementBuffers() {} /// Load the topology from a file. /// diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp index a46aa5b2b86..e197fe3e665 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp @@ -132,7 +132,7 @@ void ParallelBVHNarrowPhase::initializeTopology(sofa::core::topology::BaseMeshTo auto insertionIt = m_initializedTopology.insert(topology); if (insertionIt.second) { - topology->initContainers(); + topology->computeCrossElementBuffers(); } } From 086b7d99478be1001f1d7c201af1a67061898d62 Mon Sep 17 00:00:00 2001 From: epernod Date: Thu, 3 Nov 2022 12:07:21 +0100 Subject: [PATCH 05/13] restore comment --- .../collision/detection/algorithm/ParallelBVHNarrowPhase.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp index e197fe3e665..5d9f410c2e1 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp @@ -132,6 +132,9 @@ void ParallelBVHNarrowPhase::initializeTopology(sofa::core::topology::BaseMeshTo auto insertionIt = m_initializedTopology.insert(topology); if (insertionIt.second) { + // We need to make sure All topology buffers are well created. + // Those arrays cannot be created on the fly later, in a concurrent environment, + // due to possible race conditions. topology->computeCrossElementBuffers(); } } From 1d10f880af1d63cada0216714e81edf7d0ab3af8 Mon Sep 17 00:00:00 2001 From: epernod Date: Mon, 28 Oct 2024 10:48:15 +0100 Subject: [PATCH 06/13] Fix compilation --- .../topology/container/constant/MeshTopology.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 9454f1b9747..fcf91ae8e06 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -552,11 +552,11 @@ void MeshTopology::init() void MeshTopology::computeCrossElementBuffers() { - const auto hexahedra = sofa::helper::getReadAccessor(seqHexahedra); - const auto tetrahedra = sofa::helper::getReadAccessor(seqTetrahedra); - const auto quads = sofa::helper::getReadAccessor(seqQuads); - const auto triangles = sofa::helper::getReadAccessor(seqTriangles); - const auto edges = sofa::helper::getReadAccessor(seqEdges); + const auto hexahedra = sofa::helper::getReadAccessor(d_seqHexahedra); + const auto tetrahedra = sofa::helper::getReadAccessor(d_seqTetrahedra); + const auto quads = sofa::helper::getReadAccessor(d_seqQuads); + const auto triangles = sofa::helper::getReadAccessor(d_seqTriangles); + const auto edges = sofa::helper::getReadAccessor(d_seqEdges); // compute the number of points, if the topology is charged from the scene or if it was loaded from a MeshLoader without any points data. if (nbPoints==0) From 8a1ed13c686a4203880138ab30465596d965db79 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Thu, 26 Dec 2024 17:28:10 +0100 Subject: [PATCH 07/13] Update MeshTopology.cpp --- .../component/topology/container/constant/MeshTopology.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index fcf91ae8e06..11a1f815244 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -545,9 +545,6 @@ void MeshTopology::init() m_upperElementType = sofa::geometry::ElementType::EDGE; else m_upperElementType = sofa::geometry::ElementType::POINT; - - - computeCrossElementBuffers(); } void MeshTopology::computeCrossElementBuffers() From bca0215a5d07fb8d39405919b936d72bedc3b444 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Thu, 26 Dec 2024 22:07:46 +0100 Subject: [PATCH 08/13] Update MeshTopology.cpp --- .../sofa/component/topology/container/constant/MeshTopology.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 11a1f815244..db4942a8d68 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -545,6 +545,8 @@ void MeshTopology::init() m_upperElementType = sofa::geometry::ElementType::EDGE; else m_upperElementType = sofa::geometry::ElementType::POINT; + + computeCrossElementBuffers(); } void MeshTopology::computeCrossElementBuffers() From 650d989b4c816bf43287e0d5bf4c83369f6a245e Mon Sep 17 00:00:00 2001 From: erik pernod Date: Mon, 6 Jan 2025 11:33:22 +0100 Subject: [PATCH 09/13] Update applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp Co-authored-by: Hugo --- .../collision/detection/algorithm/ParallelBVHNarrowPhase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp index 5d9f410c2e1..3c1a0a06af7 100644 --- a/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp +++ b/applications/plugins/MultiThreading/src/MultiThreading/component/collision/detection/algorithm/ParallelBVHNarrowPhase.cpp @@ -132,7 +132,7 @@ void ParallelBVHNarrowPhase::initializeTopology(sofa::core::topology::BaseMeshTo auto insertionIt = m_initializedTopology.insert(topology); if (insertionIt.second) { - // We need to make sure All topology buffers are well created. + // We need to make sure all topology buffers are well created. // Those arrays cannot be created on the fly later, in a concurrent environment, // due to possible race conditions. topology->computeCrossElementBuffers(); From 2e33c9d57c37b759b5bd0f80c857be680e527988 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Mon, 6 Jan 2025 11:36:07 +0100 Subject: [PATCH 10/13] Update MeshTopology, Keep method ComputeCorssElementBuffer to be call only if needed. Not called at init --- .../container/constant/MeshTopology.cpp | 83 +++++++++---------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index db4942a8d68..55a80b28cdb 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -546,17 +546,6 @@ void MeshTopology::init() else m_upperElementType = sofa::geometry::ElementType::POINT; - computeCrossElementBuffers(); -} - -void MeshTopology::computeCrossElementBuffers() -{ - const auto hexahedra = sofa::helper::getReadAccessor(d_seqHexahedra); - const auto tetrahedra = sofa::helper::getReadAccessor(d_seqTetrahedra); - const auto quads = sofa::helper::getReadAccessor(d_seqQuads); - const auto triangles = sofa::helper::getReadAccessor(d_seqTriangles); - const auto edges = sofa::helper::getReadAccessor(d_seqEdges); - // compute the number of points, if the topology is charged from the scene or if it was loaded from a MeshLoader without any points data. if (nbPoints==0) { @@ -585,6 +574,46 @@ void MeshTopology::computeCrossElementBuffers() } + if(edges.empty() ) + { + if(d_seqEdges.getParent() != nullptr ) + { + d_seqEdges.delInput(d_seqEdges.getParent()); + } + const EdgeUpdate::SPtr edgeUpdate = sofa::core::objectmodel::New(this); + edgeUpdate->setName("edgeUpdate"); + this->addSlave(edgeUpdate); + } + if(triangles.empty() ) + { + if(d_seqTriangles.getParent() != nullptr) + { + d_seqTriangles.delInput(d_seqTriangles.getParent()); + } + const TriangleUpdate::SPtr triangleUpdate = sofa::core::objectmodel::New(this); + triangleUpdate->setName("triangleUpdate"); + this->addSlave(triangleUpdate); + } + if(quads.empty() ) + { + if(d_seqQuads.getParent() != nullptr ) + { + d_seqQuads.delInput(d_seqQuads.getParent()); + } + const QuadUpdate::SPtr quadUpdate = sofa::core::objectmodel::New(this); + quadUpdate->setName("quadUpdate"); + this->addSlave(quadUpdate); + } +} + +void MeshTopology::computeCrossElementBuffers() +{ + const auto hexahedra = sofa::helper::getReadAccessor(d_seqHexahedra); + const auto tetrahedra = sofa::helper::getReadAccessor(d_seqTetrahedra); + const auto quads = sofa::helper::getReadAccessor(d_seqQuads); + const auto triangles = sofa::helper::getReadAccessor(d_seqTriangles); + const auto edges = sofa::helper::getReadAccessor(d_seqEdges); + if (!hexahedra.empty()) // Create hexahedron cross element buffers. { createHexahedraAroundVertexArray(); @@ -641,38 +670,6 @@ void MeshTopology::computeCrossElementBuffers() { createEdgesAroundVertexArray(); } - - - if(edges.empty() ) - { - if(d_seqEdges.getParent() != nullptr ) - { - d_seqEdges.delInput(d_seqEdges.getParent()); - } - const EdgeUpdate::SPtr edgeUpdate = sofa::core::objectmodel::New(this); - edgeUpdate->setName("edgeUpdate"); - this->addSlave(edgeUpdate); - } - if(triangles.empty() ) - { - if(d_seqTriangles.getParent() != nullptr) - { - d_seqTriangles.delInput(d_seqTriangles.getParent()); - } - const TriangleUpdate::SPtr triangleUpdate = sofa::core::objectmodel::New(this); - triangleUpdate->setName("triangleUpdate"); - this->addSlave(triangleUpdate); - } - if(quads.empty() ) - { - if(d_seqQuads.getParent() != nullptr ) - { - d_seqQuads.delInput(d_seqQuads.getParent()); - } - const QuadUpdate::SPtr quadUpdate = sofa::core::objectmodel::New(this); - quadUpdate->setName("quadUpdate"); - this->addSlave(quadUpdate); - } } void MeshTopology::clear() From 1ae983fa100eed6fa3b8dca240e0c022f51743d8 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Wed, 8 Jan 2025 10:44:36 +0100 Subject: [PATCH 11/13] Update MeshTopology.h --- .../sofa/component/topology/container/constant/MeshTopology.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h index d2d58fb186f..ef81298becb 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h @@ -351,6 +351,7 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_CONSTANT_API MeshTopology : public core: Data d_seqTetrahedra; ///< List of tetrahedron indices Data d_seqHexahedra; ///< List of hexahedron indices Data d_seqUVs; ///< List of uv coordinates + Data d_computeAllBuffers ///< Option to call method computeCrossElementBuffers. False by default protected: Size nbPoints; From 4bdc5dbe003eee4a70fefe38944a85913a3655ef Mon Sep 17 00:00:00 2001 From: erik pernod Date: Wed, 8 Jan 2025 10:49:07 +0100 Subject: [PATCH 12/13] Update MeshTopology.cpp --- .../component/topology/container/constant/MeshTopology.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp index 55a80b28cdb..d41efbaed97 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.cpp @@ -492,6 +492,7 @@ MeshTopology::MeshTopology() , d_seqTetrahedra(initData(&d_seqTetrahedra, "tetrahedra", "List of tetrahedron indices")) , d_seqHexahedra(initData(&d_seqHexahedra, "hexahedra", "List of hexahedron indices")) , d_seqUVs(initData(&d_seqUVs, "uv", "List of uv coordinates")) + , d_computeAllBuffers(initData(&d_computeAllBuffers, false, "computeAllBuffers", "Option to compute all crossed topology buffers at init. False by default")) , nbPoints(0) , validTetrahedra(false), validHexahedra(false) , revision(0) @@ -546,6 +547,12 @@ void MeshTopology::init() else m_upperElementType = sofa::geometry::ElementType::POINT; + // If true, will compute all crossed element buffers such as triangleAroundEdges, EdgesIntriangle, etc. + if (d_computeAllBuffers.getValue()) + { + computeCrossElementBuffers(); + } + // compute the number of points, if the topology is charged from the scene or if it was loaded from a MeshLoader without any points data. if (nbPoints==0) { From 81da121813c4c6640dec91d0e8cfc2f632c24d42 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Wed, 8 Jan 2025 11:03:54 +0100 Subject: [PATCH 13/13] Update MeshTopology.h --- .../sofa/component/topology/container/constant/MeshTopology.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h index ef81298becb..4d79f8cff17 100644 --- a/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h +++ b/Sofa/Component/Topology/Container/Constant/src/sofa/component/topology/container/constant/MeshTopology.h @@ -351,7 +351,7 @@ class SOFA_COMPONENT_TOPOLOGY_CONTAINER_CONSTANT_API MeshTopology : public core: Data d_seqTetrahedra; ///< List of tetrahedron indices Data d_seqHexahedra; ///< List of hexahedron indices Data d_seqUVs; ///< List of uv coordinates - Data d_computeAllBuffers ///< Option to call method computeCrossElementBuffers. False by default + Data d_computeAllBuffers; ///< Option to call method computeCrossElementBuffers. False by default protected: Size nbPoints;