From 5ae17a91c51790cb3a584c6a859b70124f588da5 Mon Sep 17 00:00:00 2001 From: epernod Date: Wed, 17 Jul 2024 10:47:16 +0200 Subject: [PATCH] [src] Fix AdaptiveBeamMapping mapping at init with none deployed beam --- .../component/mapping/AdaptiveBeamMapping.inl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.inl b/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.inl index b555475b..869a4b01 100644 --- a/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.inl +++ b/src/BeamAdapter/component/mapping/AdaptiveBeamMapping.inl @@ -102,6 +102,8 @@ void AdaptiveBeamMapping< TIn, TOut>::init() { simulation::MainTaskSchedulerFactory::createInRegistry()->init(); } + + this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid); } @@ -273,6 +275,14 @@ void AdaptiveBeamMapping< TIn, TOut>::apply(const MechanicalParams* mparams, Dat }; + + // HACK for init: In case the number of output points is bigger to the number of distribution, set all points to 0 + for (int i = m_pointBeamDistribution.size(); i < d_points.getValue().size(); i++) + { + out[i] = Vec<3, InReal>(0.0, 0.0, 0.0); + } + + const bool multithreading = d_parallelMapping.getValue(); const simulation::ForEachExecutionPolicy execution = multithreading ?