From 6b3f7e220d10f248d6d1d7019d6e9fde9bea37e1 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Mon, 23 Sep 2024 09:33:24 +0200 Subject: [PATCH] [Mapping.Linear] Use links instead of raw pointers (#4996) * [Mapping.Linear] Use links instead of raw pointers * fix non-Windows compilation --- .../linear/Mesh2PointMechanicalMapping.cpp | 4 - .../linear/Mesh2PointMechanicalMapping.h | 7 +- .../linear/Mesh2PointMechanicalMapping.inl | 268 ++++++++++-------- 3 files changed, 153 insertions(+), 126 deletions(-) diff --git a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.cpp b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.cpp index e8a3e2da6c4..1655148689e 100644 --- a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.cpp +++ b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.cpp @@ -33,10 +33,6 @@ using namespace sofa::defaulttype; int Mesh2PointMechanicalMappingClass = core::RegisterObject("Mechanical mapping between a set of mesh primitives (point, edge, triangle...) and a set of points generated by Mesh2PointTopologicalMapping") .add< Mesh2PointMechanicalMapping< Vec3Types, Vec3Types > >() - - - -//.addAlias("SimpleTesselatedTetraMechanicalMapping") ; diff --git a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.h b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.h index 0e8a1b0e3f1..10aea9ea318 100644 --- a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.h +++ b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.h @@ -76,10 +76,9 @@ class Mesh2PointMechanicalMapping : public LinearMapping void applyJT(const core::ConstraintParams *cparams, Data& out, const Data& in) override; -protected: - Mesh2PointTopologicalMapping* topoMap; - core::topology::BaseMeshTopology* inputTopo; - core::topology::BaseMeshTopology* outputTopo; + SingleLink l_topologicalMapping; + SingleLink l_inputTopology; + SingleLink l_outputTopology; }; diff --git a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.inl b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.inl index 1bca9ae1855..c7b854648da 100644 --- a/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.inl +++ b/Sofa/Component/Mapping/Linear/src/sofa/component/mapping/linear/Mesh2PointMechanicalMapping.inl @@ -32,9 +32,9 @@ namespace sofa::component::mapping::linear template Mesh2PointMechanicalMapping::Mesh2PointMechanicalMapping(core::State* from, core::State* to) : Inherit(from, to) - , topoMap(nullptr) - , inputTopo(nullptr) - , outputTopo(nullptr) + , l_topologicalMapping(initLink("topologicalMapping", "Link to a Mesh2PointTopologicalMapping")) + , l_inputTopology(initLink("inputTopology", "Link to the input topology")) + , l_outputTopology(initLink("outputTopology", "Link to the output topology")) { } @@ -47,44 +47,76 @@ template void Mesh2PointMechanicalMapping::init() { this->Inherit::init(); - this->getContext()->get(topoMap); - inputTopo = this->fromModel->getContext()->getMeshTopology(); - outputTopo = this->toModel->getContext()->getMeshTopology(); + + if (!l_topologicalMapping) + { + l_topologicalMapping.set(this->getContext()->template get()); + if (!l_topologicalMapping) + { + msg_error() << "Cannot find a component " << l_topologicalMapping->getClassName() << " in the current context"; + this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); + return; + } + } + + if (!l_inputTopology) + { + l_inputTopology.set(this->fromModel->getContext()->getMeshTopology()); + if (!l_inputTopology) + { + msg_error() << "Cannot find a component " << l_inputTopology->getClassName() << " in the context of " << this->fromModel->getPathName(); + this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); + return; + } + } + + if (!l_outputTopology) + { + l_outputTopology.set(this->toModel->getContext()->getMeshTopology()); + if (!l_outputTopology) + { + msg_error() << "Cannot find a component " << l_outputTopology->getClassName() << " in the context of " << this->toModel->getPathName(); + this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); + return; + } + } + + this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid); } template void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams * /*mparams*/, Data& dOut, const Data& dIn) { - if (!topoMap) return; + if (!l_topologicalMapping) return; using sofa::InvalidID; helper::WriteAccessor< Data > out = dOut; helper::ReadAccessor< Data > in = dIn; - const auto& pointMap = topoMap->getPointsMappedFromPoint(); - const auto& edgeMap = topoMap->getPointsMappedFromEdge(); - const auto& triangleMap = topoMap->getPointsMappedFromTriangle(); - const auto& quadMap = topoMap->getPointsMappedFromQuad(); - const auto& tetraMap = topoMap->getPointsMappedFromTetra(); - const auto& hexaMap = topoMap->getPointsMappedFromHexa(); + const auto& pointMap = l_topologicalMapping->getPointsMappedFromPoint(); + const auto& edgeMap = l_topologicalMapping->getPointsMappedFromEdge(); + const auto& triangleMap = l_topologicalMapping->getPointsMappedFromTriangle(); + const auto& quadMap = l_topologicalMapping->getPointsMappedFromQuad(); + const auto& tetraMap = l_topologicalMapping->getPointsMappedFromTetra(); + const auto& hexaMap = l_topologicalMapping->getPointsMappedFromHexa(); if (pointMap.empty() && edgeMap.empty() && triangleMap.empty() && quadMap.empty() && tetraMap.empty() && hexaMap.empty()) return; - const core::topology::BaseMeshTopology::SeqEdges& edges = inputTopo->getEdges(); - const core::topology::BaseMeshTopology::SeqTriangles& triangles = inputTopo->getTriangles(); - const core::topology::BaseMeshTopology::SeqQuads& quads = inputTopo->getQuads(); - const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = inputTopo->getTetrahedra(); - const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = inputTopo->getHexahedra(); + const core::topology::BaseMeshTopology::SeqEdges& edges = l_inputTopology->getEdges(); + const core::topology::BaseMeshTopology::SeqTriangles& triangles = l_inputTopology->getTriangles(); + const core::topology::BaseMeshTopology::SeqQuads& quads = l_inputTopology->getQuads(); + const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = l_inputTopology->getTetrahedra(); + const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = l_inputTopology->getHexahedra(); - out.resize(outputTopo->getNbPoints()); + out.resize(l_outputTopology->getNbPoints()); for(unsigned int i = 0; i < pointMap.size(); ++i) { for(unsigned int j = 0; j < pointMap[i].size(); ++j) { if (pointMap[i][j] == InvalidID) continue; - out[pointMap[i][j]] = in[i]+topoMap->getPointBaryCoords()[j]; + out[pointMap[i][j]] = in[i]+l_topologicalMapping->getPointBaryCoords()[j]; } } @@ -93,7 +125,7 @@ void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams for(unsigned int j = 0; j < edgeMap[i].size(); ++j) { if (edgeMap[i][j] == InvalidID) continue; - double fx = topoMap->getEdgeBaryCoords()[j][0]; + double fx = l_topologicalMapping->getEdgeBaryCoords()[j][0]; out[edgeMap[i][j]] = in[ edges[i][0] ] * (1-fx) +in[ edges[i][1] ] * fx; } @@ -104,8 +136,8 @@ void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams for(unsigned int j = 0; j < triangleMap[i].size(); ++j) { if (triangleMap[i][j] == InvalidID) continue; - double fx = topoMap->getTriangleBaryCoords()[j][0]; - double fy = topoMap->getTriangleBaryCoords()[j][1]; + double fx = l_topologicalMapping->getTriangleBaryCoords()[j][0]; + double fy = l_topologicalMapping->getTriangleBaryCoords()[j][1]; out[triangleMap[i][j]] = in[ triangles[i][0] ] * (1-fx-fy) + in[ triangles[i][1] ] * fx + in[ triangles[i][2] ] * fy; @@ -117,8 +149,8 @@ void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams for(unsigned int j = 0; j < quadMap[i].size(); ++j) { if (quadMap[i][j] == InvalidID) continue; - const double fx = topoMap->getQuadBaryCoords()[j][0]; - const double fy = topoMap->getQuadBaryCoords()[j][1]; + const double fx = l_topologicalMapping->getQuadBaryCoords()[j][0]; + const double fy = l_topologicalMapping->getQuadBaryCoords()[j][1]; out[quadMap[i][j]] = in[ quads[i][0] ] * ((1-fx) * (1-fy)) + in[ quads[i][1] ] * (( fx) * (1-fy)) + in[ quads[i][2] ] * ((1-fx) * ( fy)) @@ -131,9 +163,9 @@ void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams for(unsigned int j = 0; j < tetraMap[i].size(); ++j) { if (tetraMap[i][j] == InvalidID) continue; - double fx = topoMap->getTetraBaryCoords()[j][0]; - double fy = topoMap->getTetraBaryCoords()[j][1]; - double fz = topoMap->getTetraBaryCoords()[j][2]; + double fx = l_topologicalMapping->getTetraBaryCoords()[j][0]; + double fy = l_topologicalMapping->getTetraBaryCoords()[j][1]; + double fz = l_topologicalMapping->getTetraBaryCoords()[j][2]; out[tetraMap[i][j]] = in[ tetrahedra[i][0] ] * (1-fx-fy-fz) + in[ tetrahedra[i][1] ] * fx + in[ tetrahedra[i][2] ] * fy @@ -146,9 +178,9 @@ void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams for(unsigned int j = 0; j < hexaMap[i].size(); ++j) { if (hexaMap[i][j] == InvalidID) continue; - const double fx = topoMap->getHexaBaryCoords()[j][0]; - const double fy = topoMap->getHexaBaryCoords()[j][1]; - const double fz = topoMap->getHexaBaryCoords()[j][2]; + const double fx = l_topologicalMapping->getHexaBaryCoords()[j][0]; + const double fy = l_topologicalMapping->getHexaBaryCoords()[j][1]; + const double fz = l_topologicalMapping->getHexaBaryCoords()[j][2]; out[hexaMap[i][j]] = in[ hexahedra[i][0] ] * ((1-fx) * (1-fy) * (1-fz)) + in[ hexahedra[i][1] ] * (( fx) * (1-fy) * (1-fz)) + in[ hexahedra[i][3] ] * ((1-fx) * ( fy) * (1-fz)) @@ -164,29 +196,29 @@ void Mesh2PointMechanicalMapping::apply(const core::MechanicalParams template void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams * /*mparams*/, Data& dOut, const Data& dIn) { - if (!topoMap) return; + if (!l_topologicalMapping) return; using sofa::InvalidID; helper::WriteAccessor< Data > out = dOut; helper::ReadAccessor< Data > in = dIn; - const auto& pointMap = topoMap->getPointsMappedFromPoint(); - const auto& edgeMap = topoMap->getPointsMappedFromEdge(); - const auto& triangleMap = topoMap->getPointsMappedFromTriangle(); - const auto& quadMap = topoMap->getPointsMappedFromQuad(); - const auto& tetraMap = topoMap->getPointsMappedFromTetra(); - const auto& hexaMap = topoMap->getPointsMappedFromHexa(); + const auto& pointMap = l_topologicalMapping->getPointsMappedFromPoint(); + const auto& edgeMap = l_topologicalMapping->getPointsMappedFromEdge(); + const auto& triangleMap = l_topologicalMapping->getPointsMappedFromTriangle(); + const auto& quadMap = l_topologicalMapping->getPointsMappedFromQuad(); + const auto& tetraMap = l_topologicalMapping->getPointsMappedFromTetra(); + const auto& hexaMap = l_topologicalMapping->getPointsMappedFromHexa(); if (pointMap.empty() && edgeMap.empty() && triangleMap.empty() && quadMap.empty() && tetraMap.empty() && hexaMap.empty()) return; - const core::topology::BaseMeshTopology::SeqEdges& edges = inputTopo->getEdges(); - const core::topology::BaseMeshTopology::SeqTriangles& triangles = inputTopo->getTriangles(); - const core::topology::BaseMeshTopology::SeqQuads& quads = inputTopo->getQuads(); - const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = inputTopo->getTetrahedra(); - const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = inputTopo->getHexahedra(); + const core::topology::BaseMeshTopology::SeqEdges& edges = l_inputTopology->getEdges(); + const core::topology::BaseMeshTopology::SeqTriangles& triangles = l_inputTopology->getTriangles(); + const core::topology::BaseMeshTopology::SeqQuads& quads = l_inputTopology->getQuads(); + const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = l_inputTopology->getTetrahedra(); + const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = l_inputTopology->getHexahedra(); - out.resize(outputTopo->getNbPoints()); + out.resize(l_outputTopology->getNbPoints()); for(unsigned int i = 0; i < pointMap.size(); ++i) { for(unsigned int j = 0; j < pointMap[i].size(); ++j) @@ -201,7 +233,7 @@ void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams for(unsigned int j = 0; j < edgeMap[i].size(); ++j) { if (edgeMap[i][j] == InvalidID) continue; - double fx = topoMap->getEdgeBaryCoords()[j][0]; + double fx = l_topologicalMapping->getEdgeBaryCoords()[j][0]; out[edgeMap[i][j]] = in[ edges[i][0] ] * (1-fx) +in[ edges[i][1] ] * fx; } @@ -212,8 +244,8 @@ void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams for(unsigned int j = 0; j < triangleMap[i].size(); ++j) { if (triangleMap[i][j] == InvalidID) continue; - double fx = topoMap->getTriangleBaryCoords()[j][0]; - double fy = topoMap->getTriangleBaryCoords()[j][1]; + double fx = l_topologicalMapping->getTriangleBaryCoords()[j][0]; + double fy = l_topologicalMapping->getTriangleBaryCoords()[j][1]; out[triangleMap[i][j]] = in[ triangles[i][0] ] * (1-fx-fy) + in[ triangles[i][1] ] * fx + in[ triangles[i][2] ] * fy; @@ -225,8 +257,8 @@ void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams for(unsigned int j = 0; j < quadMap[i].size(); ++j) { if (quadMap[i][j] == InvalidID) continue; - const double fx = topoMap->getQuadBaryCoords()[j][0]; - const double fy = topoMap->getQuadBaryCoords()[j][1]; + const double fx = l_topologicalMapping->getQuadBaryCoords()[j][0]; + const double fy = l_topologicalMapping->getQuadBaryCoords()[j][1]; out[quadMap[i][j]] = in[ quads[i][0] ] * ((1-fx) * (1-fy)) + in[ quads[i][1] ] * (( fx) * (1-fy)) + in[ quads[i][2] ] * ((1-fx) * ( fy)) @@ -239,9 +271,9 @@ void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams for(unsigned int j = 0; j < tetraMap[i].size(); ++j) { if (tetraMap[i][j] == InvalidID) continue; - double fx = topoMap->getTetraBaryCoords()[j][0]; - double fy = topoMap->getTetraBaryCoords()[j][1]; - double fz = topoMap->getTetraBaryCoords()[j][2]; + double fx = l_topologicalMapping->getTetraBaryCoords()[j][0]; + double fy = l_topologicalMapping->getTetraBaryCoords()[j][1]; + double fz = l_topologicalMapping->getTetraBaryCoords()[j][2]; out[tetraMap[i][j]] = in[ tetrahedra[i][0] ] * (1-fx-fy-fz) + in[ tetrahedra[i][1] ] * fx + in[ tetrahedra[i][2] ] * fy @@ -254,9 +286,9 @@ void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams for(unsigned int j = 0; j < hexaMap[i].size(); ++j) { if (hexaMap[i][j] == InvalidID) continue; - const double fx = topoMap->getHexaBaryCoords()[j][0]; - const double fy = topoMap->getHexaBaryCoords()[j][1]; - const double fz = topoMap->getHexaBaryCoords()[j][2]; + const double fx = l_topologicalMapping->getHexaBaryCoords()[j][0]; + const double fy = l_topologicalMapping->getHexaBaryCoords()[j][1]; + const double fz = l_topologicalMapping->getHexaBaryCoords()[j][2]; out[hexaMap[i][j]] = in[ hexahedra[i][0] ] * ((1-fx) * (1-fy) * (1-fz)) + in[ hexahedra[i][1] ] * (( fx) * (1-fy) * (1-fz)) + in[ hexahedra[i][3] ] * ((1-fx) * ( fy) * (1-fz)) @@ -272,29 +304,29 @@ void Mesh2PointMechanicalMapping::applyJ(const core::MechanicalParams template void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParams * /*mparams*/, Data& dOut, const Data& dIn) { - if (!topoMap) return; + if (!l_topologicalMapping) return; using sofa::InvalidID; helper::WriteAccessor< Data > out = dOut; helper::ReadAccessor< Data > in = dIn; - const auto& pointMap = topoMap->getPointsMappedFromPoint(); - const auto& edgeMap = topoMap->getPointsMappedFromEdge(); - const auto& triangleMap = topoMap->getPointsMappedFromTriangle(); - const auto& quadMap = topoMap->getPointsMappedFromQuad(); - const auto& tetraMap = topoMap->getPointsMappedFromTetra(); - const auto& hexaMap = topoMap->getPointsMappedFromHexa(); + const auto& pointMap = l_topologicalMapping->getPointsMappedFromPoint(); + const auto& edgeMap = l_topologicalMapping->getPointsMappedFromEdge(); + const auto& triangleMap = l_topologicalMapping->getPointsMappedFromTriangle(); + const auto& quadMap = l_topologicalMapping->getPointsMappedFromQuad(); + const auto& tetraMap = l_topologicalMapping->getPointsMappedFromTetra(); + const auto& hexaMap = l_topologicalMapping->getPointsMappedFromHexa(); if (pointMap.empty() && edgeMap.empty() && triangleMap.empty() && quadMap.empty() && tetraMap.empty() && hexaMap.empty()) return; - const core::topology::BaseMeshTopology::SeqEdges& edges = inputTopo->getEdges(); - const core::topology::BaseMeshTopology::SeqTriangles& triangles = inputTopo->getTriangles(); - const core::topology::BaseMeshTopology::SeqQuads& quads = inputTopo->getQuads(); - const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = inputTopo->getTetrahedra(); - const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = inputTopo->getHexahedra(); + const core::topology::BaseMeshTopology::SeqEdges& edges = l_inputTopology->getEdges(); + const core::topology::BaseMeshTopology::SeqTriangles& triangles = l_inputTopology->getTriangles(); + const core::topology::BaseMeshTopology::SeqQuads& quads = l_inputTopology->getQuads(); + const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = l_inputTopology->getTetrahedra(); + const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = l_inputTopology->getHexahedra(); - out.resize(inputTopo->getNbPoints()); + out.resize(l_inputTopology->getNbPoints()); for(unsigned int i = 0; i < pointMap.size(); ++i) { for(unsigned int j = 0; j < pointMap[i].size(); ++j) @@ -309,7 +341,7 @@ void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParam for(unsigned int j = 0; j < edgeMap[i].size(); ++j) { if (edgeMap[i][j] == InvalidID) continue; - double fx = topoMap->getEdgeBaryCoords()[j][0]; + double fx = l_topologicalMapping->getEdgeBaryCoords()[j][0]; out[edges[i][0]] += in[ edgeMap[i][j] ] * (1-fx); out[edges[i][1]] += in[ edgeMap[i][j] ] * fx; } @@ -320,8 +352,8 @@ void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParam for(unsigned int j = 0; j < triangleMap[i].size(); ++j) { if (triangleMap[i][j] == InvalidID) continue; - double fx = topoMap->getTriangleBaryCoords()[j][0]; - double fy = topoMap->getTriangleBaryCoords()[j][1]; + double fx = l_topologicalMapping->getTriangleBaryCoords()[j][0]; + double fy = l_topologicalMapping->getTriangleBaryCoords()[j][1]; out[ triangles[i][0] ] += in[triangleMap[i][j]] * (1-fx-fy); out[ triangles[i][1] ] += in[triangleMap[i][j]] * fx; out[ triangles[i][2] ] += in[triangleMap[i][j]] * fy; @@ -333,8 +365,8 @@ void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParam for(unsigned int j = 0; j < quadMap[i].size(); ++j) { if (quadMap[i][j] == InvalidID) continue; - const double fx = topoMap->getQuadBaryCoords()[j][0]; - const double fy = topoMap->getQuadBaryCoords()[j][1]; + const double fx = l_topologicalMapping->getQuadBaryCoords()[j][0]; + const double fy = l_topologicalMapping->getQuadBaryCoords()[j][1]; out[ quads[i][0] ] += in[quadMap[i][j]] * ((1-fx) * (1-fy)); out[ quads[i][1] ] += in[quadMap[i][j]] * (( fx) * (1-fy)); out[ quads[i][2] ] += in[quadMap[i][j]] * ((1-fx) * ( fy)); @@ -347,9 +379,9 @@ void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParam for(unsigned int j = 0; j < tetraMap[i].size(); ++j) { if (tetraMap[i][j] == InvalidID) continue; - double fx = topoMap->getTetraBaryCoords()[j][0]; - double fy = topoMap->getTetraBaryCoords()[j][1]; - double fz = topoMap->getTetraBaryCoords()[j][2]; + double fx = l_topologicalMapping->getTetraBaryCoords()[j][0]; + double fy = l_topologicalMapping->getTetraBaryCoords()[j][1]; + double fz = l_topologicalMapping->getTetraBaryCoords()[j][2]; out[ tetrahedra[i][0] ] += in[tetraMap[i][j]] * (1-fx-fy-fz); out[ tetrahedra[i][1] ] += in[tetraMap[i][j]] * fx; out[ tetrahedra[i][2] ] += in[tetraMap[i][j]] * fy; @@ -362,9 +394,9 @@ void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParam for(unsigned int j = 0; j < hexaMap[i].size(); ++j) { if (hexaMap[i][j] == InvalidID) continue; - const double fx = topoMap->getHexaBaryCoords()[j][0]; - const double fy = topoMap->getHexaBaryCoords()[j][1]; - const double fz = topoMap->getHexaBaryCoords()[j][2]; + const double fx = l_topologicalMapping->getHexaBaryCoords()[j][0]; + const double fy = l_topologicalMapping->getHexaBaryCoords()[j][1]; + const double fz = l_topologicalMapping->getHexaBaryCoords()[j][2]; out[ hexahedra[i][0] ] += in[hexaMap[i][j]] * ((1-fx) * (1-fy) * (1-fz)); out[ hexahedra[i][1] ] += in[hexaMap[i][j]] * (( fx) * (1-fy) * (1-fz)); out[ hexahedra[i][3] ] += in[hexaMap[i][j]] * ((1-fx) * ( fy) * (1-fz)); @@ -381,10 +413,10 @@ void Mesh2PointMechanicalMapping::applyJT(const core::MechanicalParam template void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParams * /*cparams*/, Data& dOut, const Data& dIn) { - if (!topoMap) + if (!l_topologicalMapping) return; - const sofa::type::vector< std::pair< Mesh2PointTopologicalMapping::Element, sofa::Index> >& pointSource = topoMap->getPointSource(); + const sofa::type::vector< std::pair< Mesh2PointTopologicalMapping::Element, sofa::Index> >& pointSource = l_topologicalMapping->getPointSource(); if (pointSource.empty()) return; @@ -392,11 +424,11 @@ void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParam InMatrixDeriv& out = *dOut.beginEdit(); const OutMatrixDeriv& in = dIn.getValue(); - const core::topology::BaseMeshTopology::SeqEdges& edges = inputTopo->getEdges(); - const core::topology::BaseMeshTopology::SeqTriangles& triangles = inputTopo->getTriangles(); - const core::topology::BaseMeshTopology::SeqQuads& quads = inputTopo->getQuads(); - const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = inputTopo->getTetrahedra(); - const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = inputTopo->getHexahedra(); + const core::topology::BaseMeshTopology::SeqEdges& edges = l_inputTopology->getEdges(); + const core::topology::BaseMeshTopology::SeqTriangles& triangles = l_inputTopology->getTriangles(); + const core::topology::BaseMeshTopology::SeqQuads& quads = l_inputTopology->getQuads(); + const core::topology::BaseMeshTopology::SeqTetrahedra& tetrahedra = l_inputTopology->getTetrahedra(); + const core::topology::BaseMeshTopology::SeqHexahedra& hexahedra = l_inputTopology->getHexahedra(); typename Out::MatrixDeriv::RowConstIterator rowItEnd = in.end(); @@ -432,19 +464,19 @@ void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParam double fx = 0; - if (topoMap->getEdgeBaryCoords().size() == 1) + if (l_topologicalMapping->getEdgeBaryCoords().size() == 1) { - fx = topoMap->getEdgeBaryCoords()[0][0]; + fx = l_topologicalMapping->getEdgeBaryCoords()[0][0]; } else { - const auto& edgeMap = topoMap->getPointsMappedFromEdge(); + const auto& edgeMap = l_topologicalMapping->getPointsMappedFromEdge(); bool err = true; for(Size i = 0; i < edgeMap[source.second].size(); ++i) { if (edgeMap[source.second][i] == indexIn) { - fx = topoMap->getEdgeBaryCoords()[i][0]; + fx = l_topologicalMapping->getEdgeBaryCoords()[i][0]; err = false; break; } @@ -468,21 +500,21 @@ void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParam double fx = 0; double fy = 0; - if (topoMap->getTriangleBaryCoords().size() == 1) + if (l_topologicalMapping->getTriangleBaryCoords().size() == 1) { - fx = topoMap->getTriangleBaryCoords()[0][0]; - fy = topoMap->getTriangleBaryCoords()[0][1]; + fx = l_topologicalMapping->getTriangleBaryCoords()[0][0]; + fy = l_topologicalMapping->getTriangleBaryCoords()[0][1]; } else { - const auto& triangleMap = topoMap->getPointsMappedFromTriangle(); + const auto& triangleMap = l_topologicalMapping->getPointsMappedFromTriangle(); bool err = true; for(Size i = 0; i < triangleMap[source.second].size(); ++i) { if (triangleMap[source.second][i] == indexIn) { - fx = topoMap->getTriangleBaryCoords()[i][0]; - fy = topoMap->getTriangleBaryCoords()[i][1]; + fx = l_topologicalMapping->getTriangleBaryCoords()[i][0]; + fy = l_topologicalMapping->getTriangleBaryCoords()[i][1]; err = false; break; } @@ -507,21 +539,21 @@ void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParam double fx = 0; double fy = 0; - if (topoMap->getQuadBaryCoords().size() == 1) + if (l_topologicalMapping->getQuadBaryCoords().size() == 1) { - fx = topoMap->getQuadBaryCoords()[0][0]; - fy = topoMap->getQuadBaryCoords()[0][1]; + fx = l_topologicalMapping->getQuadBaryCoords()[0][0]; + fy = l_topologicalMapping->getQuadBaryCoords()[0][1]; } else { - const auto& quadMap = topoMap->getPointsMappedFromQuad(); + const auto& quadMap = l_topologicalMapping->getPointsMappedFromQuad(); bool err = true; for(Size i = 0; i < quadMap[source.second].size(); ++i) { if (quadMap[source.second][i] == indexIn) { - fx = topoMap->getQuadBaryCoords()[i][0]; - fy = topoMap->getQuadBaryCoords()[i][1]; + fx = l_topologicalMapping->getQuadBaryCoords()[i][0]; + fy = l_topologicalMapping->getQuadBaryCoords()[i][1]; err = false; break; } @@ -548,23 +580,23 @@ void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParam double fy = 0; double fz = 0; - if (topoMap->getTetraBaryCoords().size() == 1) + if (l_topologicalMapping->getTetraBaryCoords().size() == 1) { - fx = topoMap->getTetraBaryCoords()[0][0]; - fy = topoMap->getTetraBaryCoords()[0][1]; - fz = topoMap->getTetraBaryCoords()[0][2]; + fx = l_topologicalMapping->getTetraBaryCoords()[0][0]; + fy = l_topologicalMapping->getTetraBaryCoords()[0][1]; + fz = l_topologicalMapping->getTetraBaryCoords()[0][2]; } else { - const auto& tetraMap = topoMap->getPointsMappedFromTetra(); + const auto& tetraMap = l_topologicalMapping->getPointsMappedFromTetra(); bool err = true; for(Size i = 0; i < tetraMap[source.second].size(); ++i) { if (tetraMap[source.second][i] == indexIn) { - fx = topoMap->getTetraBaryCoords()[i][0]; - fy = topoMap->getTetraBaryCoords()[i][1]; - fz = topoMap->getTetraBaryCoords()[i][2]; + fx = l_topologicalMapping->getTetraBaryCoords()[i][0]; + fy = l_topologicalMapping->getTetraBaryCoords()[i][1]; + fz = l_topologicalMapping->getTetraBaryCoords()[i][2]; err = false; break; } @@ -590,23 +622,23 @@ void Mesh2PointMechanicalMapping::applyJT(const core::ConstraintParam double fx = 0; double fy = 0; double fz = 0; - if (topoMap->getHexaBaryCoords().size() == 1) + if (l_topologicalMapping->getHexaBaryCoords().size() == 1) { - fx = topoMap->getHexaBaryCoords()[0][0]; - fy = topoMap->getHexaBaryCoords()[0][1]; - fz = topoMap->getHexaBaryCoords()[0][2]; + fx = l_topologicalMapping->getHexaBaryCoords()[0][0]; + fy = l_topologicalMapping->getHexaBaryCoords()[0][1]; + fz = l_topologicalMapping->getHexaBaryCoords()[0][2]; } else { - const auto& hexaMap = topoMap->getPointsMappedFromHexa(); + const auto& hexaMap = l_topologicalMapping->getPointsMappedFromHexa(); bool err = true; for(Size i = 0; i < hexaMap[source.second].size(); ++i) { if (hexaMap[source.second][i] == indexIn) { - fx = topoMap->getHexaBaryCoords()[i][0]; - fy = topoMap->getHexaBaryCoords()[i][1]; - fz = topoMap->getHexaBaryCoords()[i][2]; + fx = l_topologicalMapping->getHexaBaryCoords()[i][0]; + fy = l_topologicalMapping->getHexaBaryCoords()[i][1]; + fz = l_topologicalMapping->getHexaBaryCoords()[i][2]; err = false; break; }