diff --git a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceFromTargetMapping.inl b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceFromTargetMapping.inl index cd8dbb3d6fa..ab28f996330 100644 --- a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceFromTargetMapping.inl +++ b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceFromTargetMapping.inl @@ -205,9 +205,9 @@ template void DistanceFromTargetMapping::applyJT(const core::ConstraintParams* cparams, Data& out, const Data& in) { SOFA_UNUSED(cparams); - const OutMatrixDeriv& childMat = sofa::helper::getReadAccessor(in).ref(); - InMatrixDeriv& parentMat = sofa::helper::getWriteAccessor(out).wref(); - addMultTransposeEigen(parentMat, jacobian.compressedMatrix, childMat); + auto childMatRa = sofa::helper::getReadAccessor(in); + auto parentMatWa = sofa::helper::getWriteAccessor(out); + addMultTransposeEigen(parentMatWa.wref(), jacobian.compressedMatrix, childMatRa.ref()); } diff --git a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMapping.inl b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMapping.inl index be1d82d1c83..fe824980a28 100644 --- a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMapping.inl +++ b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMapping.inl @@ -274,9 +274,9 @@ template void DistanceMapping::applyJT(const core::ConstraintParams* cparams, Data& out, const Data& in) { SOFA_UNUSED(cparams); - const OutMatrixDeriv& childMat = sofa::helper::getReadAccessor(in).ref(); - InMatrixDeriv& parentMat = sofa::helper::getWriteAccessor(out).wref(); - addMultTransposeEigen(parentMat, jacobian.compressedMatrix, childMat); + auto childMatRa = sofa::helper::getReadAccessor(in); + auto parentMatWa = sofa::helper::getWriteAccessor(out); + addMultTransposeEigen(parentMatWa.wref(), jacobian.compressedMatrix, childMatRa.ref()); } diff --git a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMultiMapping.inl b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMultiMapping.inl index 063de8eb7a8..2cec03bbe40 100644 --- a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMultiMapping.inl +++ b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/DistanceMultiMapping.inl @@ -112,8 +112,11 @@ void DistanceMultiMapping::init() const type::Vec2i& pair0 = pairs[ links[i][0] ]; const type::Vec2i& pair1 = pairs[ links[i][1] ]; - const InCoord& pos0 = this->getFromModels()[pair0[0]]->readPositions()[pair0[1]]; - const InCoord& pos1 = this->getFromModels()[pair1[0]]->readPositions()[pair1[1]]; + auto posPair0 = this->getFromModels()[pair0[0]]->readPositions(); + auto posPair1 = this->getFromModels()[pair1[0]]->readPositions(); + + const InCoord& pos0 = posPair0[pair0[1]]; + const InCoord& pos1 = posPair1[pair1[1]]; restLengths[i] = (pos0 - pos1).norm(); @@ -268,7 +271,8 @@ void DistanceMultiMapping::applyDJT(const core::MechanicalParams* mpa if( !geometricStiffness ) return; const SReal kfactor = mparams->kFactor(); - const OutVecDeriv& childForce = this->getToModels()[0]->readForces().ref(); + auto childForceRa = this->getToModels()[0]->readForces(); + const OutVecDeriv& childForce = childForceRa.ref(); const SeqEdges& links = l_topology->getEdges(); const type::vector& pairs = d_indexPairs.getValue(); @@ -481,8 +485,11 @@ void DistanceMultiMapping::draw(const core::visual::VisualParams* vpa const type::Vec2i& pair0 = pairs[ links[i][0] ]; const type::Vec2i& pair1 = pairs[ links[i][1] ]; - const InCoord& pos0 = this->getFromModels()[pair0[0]]->readPositions()[pair0[1]]; - const InCoord& pos1 = this->getFromModels()[pair1[0]]->readPositions()[pair1[1]]; + auto posPair0 = this->getFromModels()[pair0[0]]->readPositions(); + auto posPair1 = this->getFromModels()[pair1[0]]->readPositions(); + + const InCoord& pos0 = posPair0[pair0[1]]; + const InCoord& pos1 = posPair1[pair1[1]]; points.push_back( type::Vec3( TIn::getCPos(pos0) ) ); points.push_back( type::Vec3( TIn::getCPos(pos1) ) ); @@ -496,8 +503,11 @@ void DistanceMultiMapping::draw(const core::visual::VisualParams* vpa const type::Vec2i& pair0 = pairs[ links[i][0] ]; const type::Vec2i& pair1 = pairs[ links[i][1] ]; - const InCoord& pos0 = this->getFromModels()[pair0[0]]->readPositions()[pair0[1]]; - const InCoord& pos1 = this->getFromModels()[pair1[0]]->readPositions()[pair1[1]]; + auto posPair0 = this->getFromModels()[pair0[0]]->readPositions(); + auto posPair1 = this->getFromModels()[pair1[0]]->readPositions(); + + const InCoord& pos0 = posPair0[pair0[1]]; + const InCoord& pos1 = posPair1[pair1[1]]; type::Vec3 p0 = TIn::getCPos(pos0); type::Vec3 p1 = TIn::getCPos(pos1); diff --git a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareDistanceMapping.inl b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareDistanceMapping.inl index 38c371333f8..3cf53cb12a2 100644 --- a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareDistanceMapping.inl +++ b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareDistanceMapping.inl @@ -210,9 +210,9 @@ template void SquareDistanceMapping::applyJT(const core::ConstraintParams* cparams, Data& out, const Data& in) { SOFA_UNUSED(cparams); - const OutMatrixDeriv& childMat = sofa::helper::getReadAccessor(in).ref(); - InMatrixDeriv& parentMat = sofa::helper::getWriteAccessor(out).wref(); - addMultTransposeEigen(parentMat, jacobian.compressedMatrix, childMat); + auto childMatRa = sofa::helper::getReadAccessor(in); + auto parentMatWa = sofa::helper::getWriteAccessor(out); + addMultTransposeEigen(parentMatWa.wref(), jacobian.compressedMatrix, childMatRa.ref()); } diff --git a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareMapping.inl b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareMapping.inl index 791d5090e53..3f7eb33a74d 100644 --- a/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareMapping.inl +++ b/Sofa/Component/Mapping/NonLinear/src/sofa/component/mapping/nonlinear/SquareMapping.inl @@ -135,9 +135,9 @@ template void SquareMapping::applyJT(const core::ConstraintParams* cparams, Data& out, const Data& in) { SOFA_UNUSED(cparams); - const OutMatrixDeriv& childMat = sofa::helper::getReadAccessor(in).ref(); - InMatrixDeriv& parentMat = sofa::helper::getWriteAccessor(out).wref(); - addMultTransposeEigen(parentMat, jacobian.compressedMatrix, childMat); + auto childMatRa = sofa::helper::getReadAccessor(in); + auto parentMatWa = sofa::helper::getWriteAccessor(out); + addMultTransposeEigen(parentMatWa.wref(), jacobian.compressedMatrix, childMatRa.ref()); } diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetGeometryAlgorithms.inl b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetGeometryAlgorithms.inl index abec1b27a3b..7d5a013b9e6 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetGeometryAlgorithms.inl +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetGeometryAlgorithms.inl @@ -944,11 +944,12 @@ bool TriangleSetGeometryAlgorithms< DataTypes >::isQuadDeulaunayOriented(const t const typename DataTypes::Coord& p3, const typename DataTypes::Coord& p4) { - // use formula with angles - // A----B p1----p2 - // \ \ \ \ - // D----C p4----p3 - // if the sum of opposites angles (not on the common edge) is < 180deg, the triangles meet the Delaunay condition + /* use formula with angles + * A----B p1----p2 + * \ \ \ \ + * D----C p4----p3 + * if the sum of opposites angles (not on the common edge) is < 180deg, the triangles meet the Delaunay condition + */ sofa::type::Vec<3, Real> AB = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] }; sofa::type::Vec<3, Real> AD = { p4[0] - p1[0], p4[1] - p1[1], p4[2] - p1[2] }; diff --git a/Sofa/GUI/Common/src/sofa/gui/common/PickHandler.cpp b/Sofa/GUI/Common/src/sofa/gui/common/PickHandler.cpp index dcda3be101c..f4ae3fdfc31 100644 --- a/Sofa/GUI/Common/src/sofa/gui/common/PickHandler.cpp +++ b/Sofa/GUI/Common/src/sofa/gui/common/PickHandler.cpp @@ -385,9 +385,9 @@ BodyPicked PickHandler::findCollisionUsingPipeline() return result; } - const type::Vec3& origin = mouseCollision->getRay(0).origin(); - const type::Vec3& direction = mouseCollision->getRay(0).direction(); - const double& maxLength = mouseCollision->getRay(0).l(); + const type::Vec3 origin = mouseCollision->getRay(0).origin(); + const type::Vec3 direction = mouseCollision->getRay(0).direction(); + const double maxLength = mouseCollision->getRay(0).l(); const auto &contacts = mouseCollision->getContacts(); for (auto it=contacts.cbegin(); it != contacts.cend(); ++it) @@ -438,17 +438,17 @@ BodyPicked PickHandler::findCollisionUsingPipeline() BodyPicked PickHandler::findCollisionUsingBruteForce() { - const type::Vec3& origin = mouseCollision->getRay(0).origin(); - const type::Vec3& direction = mouseCollision->getRay(0).direction(); - const double& maxLength = mouseCollision->getRay(0).l(); + const type::Vec3 origin = mouseCollision->getRay(0).origin(); + const type::Vec3 direction = mouseCollision->getRay(0).direction(); + const double maxLength = mouseCollision->getRay(0).l(); return findCollisionUsingBruteForce(origin, direction, maxLength, mouseNode->getRoot()); } BodyPicked PickHandler::findCollisionUsingColourCoding() { - const type::Vec3& origin = mouseCollision->getRay(0).origin(); - const type::Vec3& direction = mouseCollision->getRay(0).direction(); + const type::Vec3 origin = mouseCollision->getRay(0).origin(); + const type::Vec3 direction = mouseCollision->getRay(0).direction(); return findCollisionUsingColourCoding(origin, direction); diff --git a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/SparseMatrixProduct.inl b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/SparseMatrixProduct.inl index d8532e38b3b..668ab3c26e8 100644 --- a/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/SparseMatrixProduct.inl +++ b/Sofa/framework/LinearAlgebra/src/sofa/linearalgebra/SparseMatrixProduct.inl @@ -291,8 +291,8 @@ void SparseMatrixProduct::computeProductFromIntersection() auto* rhs_ptr = m_rhs->valuePtr(); auto* product_ptr = m_productResult.valuePtr(); - const auto lhsNonZeros = m_lhs->nonZeros(); - const auto rhsNonZeros = m_rhs->nonZeros(); + [[maybe_unused]] const auto lhsNonZeros = m_lhs->nonZeros(); + [[maybe_unused]] const auto rhsNonZeros = m_rhs->nonZeros(); for (const auto& pairs : m_intersectionAB.intersection) { diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateMappingVisitor.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateMappingVisitor.cpp index bba00f8c502..328b1076752 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateMappingVisitor.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateMappingVisitor.cpp @@ -29,14 +29,18 @@ namespace sofa::simulation { -void UpdateMappingVisitor::processMapping(simulation::Node* /*n*/, core::BaseMapping* obj) +void UpdateMappingVisitor::processMapping(simulation::Node* n, core::BaseMapping* obj) { + SOFA_UNUSED(n); obj->apply(core::mechanicalparams::defaultInstance(), core::VecCoordId::position(), core::ConstVecCoordId::position()); obj->applyJ(core::mechanicalparams::defaultInstance(), core::VecDerivId::velocity(), core::ConstVecDerivId::velocity()); } -void UpdateMappingVisitor::processMechanicalMapping(simulation::Node* /*n*/, core::BaseMapping* obj) -{} +void UpdateMappingVisitor::processMechanicalMapping(simulation::Node* n, core::BaseMapping* obj) +{ + SOFA_UNUSED(n); + SOFA_UNUSED(obj); +} Visitor::Result UpdateMappingVisitor::processNodeTopDown(simulation::Node* node) {