Skip to content

Commit

Permalink
Merge branch 'master' into 202312_new_action_check_PR_age
Browse files Browse the repository at this point in the history
  • Loading branch information
hugtalbot authored Dec 20, 2023
2 parents c3a1c9f + b1c49a7 commit 1184556
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ BarycentricMapperEdgeSetTopology<In,Out>::BarycentricMapperEdgeSetTopology(sofa:
{}

template <class In, class Out>
typename BarycentricMapperEdgeSetTopology<In, Out>::Index BarycentricMapperEdgeSetTopology<In,Out>::addPointInLine ( const Index edgeIndex, const SReal* baryCoords )
auto BarycentricMapperEdgeSetTopology<In,Out>::addPointInLine ( const Index edgeIndex, const SReal* baryCoords ) -> Index
{
type::vector<MappingData>& vectorData = *(d_map.beginEdit());
vectorData.resize ( d_map.getValue().size() +1 );
d_map.endEdit();
MappingData& data = *vectorData.rbegin();
auto vectorData = sofa::helper::getWriteAccessor(d_map);
MappingData data;
data.in_index = edgeIndex;
data.baryCoords[0] = ( Real ) baryCoords[0];
return Size(d_map.getValue().size()-1);
data.baryCoords[0] = static_cast<Real>(baryCoords[0]);
vectorData->emplace_back(data);
return static_cast<Index>(vectorData.size() - 1u);
}

template <class In, class Out>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,31 @@ template <class In, class Out>
typename BarycentricMapperHexahedronSetTopology<In, Out>::Index
BarycentricMapperHexahedronSetTopology<In,Out>::addPointInCube ( const Index cubeIndex, const SReal* baryCoords )
{
type::vector<MappingData>& vectorData = *(d_map.beginEdit());
vectorData.resize ( d_map.getValue().size() +1 );
MappingData& data = *vectorData.rbegin();
d_map.endEdit();
auto vectorData = sofa::helper::getWriteAccessor(d_map);
MappingData data;
data.in_index = cubeIndex;
data.baryCoords[0] = ( Real ) baryCoords[0];
data.baryCoords[1] = ( Real ) baryCoords[1];
data.baryCoords[2] = ( Real ) baryCoords[2];
return (int)d_map.getValue().size()-1;
data.baryCoords[0] = static_cast<Real>(baryCoords[0]);
data.baryCoords[1] = static_cast<Real>(baryCoords[1]);
data.baryCoords[2] = static_cast<Real>(baryCoords[2]);
vectorData->emplace_back(data);
return static_cast<Index>(vectorData.size() - 1u);
}


template <class In, class Out>
typename BarycentricMapperHexahedronSetTopology<In, Out>::Index
BarycentricMapperHexahedronSetTopology<In,Out>::setPointInCube ( const Index pointIndex, const Index cubeIndex, const SReal* baryCoords )
{
if ( pointIndex >= d_map.getValue().size() )
auto vectorData = sofa::helper::getWriteAccessor(d_map);

if ( pointIndex >= vectorData.size() )
return sofa::InvalidID;

type::vector<MappingData>& vectorData = *(d_map.beginEdit());
MappingData& data = vectorData[pointIndex];
data.in_index = cubeIndex;
data.baryCoords[0] = ( Real ) baryCoords[0];
data.baryCoords[1] = ( Real ) baryCoords[1];
data.baryCoords[2] = ( Real ) baryCoords[2];
d_map.endEdit();
data.baryCoords[0] = static_cast<Real>(baryCoords[0]);
data.baryCoords[1] = static_cast<Real>(baryCoords[1]);
data.baryCoords[2] = static_cast<Real>(baryCoords[2]);

if(cubeIndex == sofa::InvalidID)
m_invalidIndex.insert(pointIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,11 @@ void BarycentricMapping<TIn, TOut>::applyJ (const core::MechanicalParams * mpara
{
SOFA_UNUSED(mparams);

typename Out::VecDeriv* out = _out.beginEdit();
if (d_mapper != nullptr)
{
d_mapper->applyJ(*out, in.getValue());
auto outWriteAccessor = sofa::helper::getWriteAccessor(_out);
d_mapper->applyJ(outWriteAccessor.wref(), in.getValue());
}
_out.endEdit();
}


Expand All @@ -323,8 +322,8 @@ void BarycentricMapping<TIn, TOut>::applyJT (const core::MechanicalParams * mpar

if (d_mapper != nullptr)
{
d_mapper->applyJT(*out.beginEdit(), in.getValue());
out.endEdit();
auto outWriteAccessor = sofa::helper::getWriteAccessor(out);
d_mapper->applyJT(outWriteAccessor.wref(), in.getValue());
}
}

Expand Down Expand Up @@ -376,8 +375,8 @@ void BarycentricMapping<TIn, TOut>::applyJT(const core::ConstraintParams * cpara

if (d_mapper!=nullptr )
{
d_mapper->applyJT(*out.beginEdit(), in.getValue());
out.endEdit();
auto outWriteAccessor = sofa::helper::getWriteAccessor(out);
d_mapper->applyJT(outWriteAccessor.wref(), in.getValue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
* *
* Contact information: [email protected] *
******************************************************************************/
#pragma once

#include <string>
#include <sofa/core/config.h>
#include <sofa/core/fwd.h>
Expand Down
Loading

0 comments on commit 1184556

Please sign in to comment.