Skip to content

Commit

Permalink
[constraint] data renaming (d_constraintIndex) (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
EulalieCoevoet authored Jul 22, 2024
1 parent fae4074 commit 0f03c21
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SoftRobotsBaseConstraint::SoftRobotsBaseConstraint()
, m_hasLambdaInit(false)
, m_hasEpsilon(false)
{
m_constraintIndex.setReadOnly(true);
d_constraintIndex.setReadOnly(true);
}

bool SoftRobotsBaseConstraint::hasDeltaMax() const
Expand Down
2 changes: 1 addition & 1 deletion src/SoftRobots/component/behavior/SoftRobotsConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void SoftRobotsConstraint<DataTypes>::getConstraintViolation(const sofa::core::C
{
const DataVecCoord& xfree = *cParams->readX(m_state);
ReadAccessor<sofa::Data<VecCoord>> x = m_state->readPositions();
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);

VecDeriv dx;
dx.resize(m_state->getSize());
Expand Down
2 changes: 1 addition & 1 deletion src/SoftRobots/component/constraint/JointConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class JointConstraint : public SoftRobotsConstraint<DataTypes>

////////////////////////// Inherited attributes ////////////////////////////
using SoftRobotsConstraint<DataTypes>::m_state ;
using SoftRobotsConstraint<DataTypes>::m_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::m_nbLines ;
using SoftRobotsConstraint<DataTypes>::d_componentState ;
////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions src/SoftRobots/component/constraint/JointConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void JointConstraint<DataTypes>::buildConstraintMatrix(const ConstraintParams* c
if(!this->isComponentStateValid())
return ;

auto constraintIndex = sofa::helper::getWriteAccessor(m_constraintIndex);
auto constraintIndex = sofa::helper::getWriteAccessor(d_constraintIndex);
constraintIndex.wref() = cIndex;

MatrixDeriv& matrix = *cMatrix.beginEdit();
Expand All @@ -175,7 +175,7 @@ void JointConstraint<DataTypes>::getConstraintViolation(const ConstraintParams*
SOFA_UNUSED(cParams);

Real dFree = Jdx->element(0) - m_initDisplacement + m_currentDisplacement;
resV->set(m_constraintIndex.getValue(), dFree);
resV->set(d_constraintIndex.getValue(), dFree);
}

template<class DataTypes>
Expand Down Expand Up @@ -224,7 +224,7 @@ void JointConstraint<DataTypes>::storeLambda(const ConstraintParams* cParams,
return ;

// Update joint effort
d_force.setValue(lambda->element(m_constraintIndex.getValue()));
d_force.setValue(lambda->element(d_constraintIndex.getValue()));

// Update joint displacement
ReadAccessor<sofa::Data<VecCoord>> positions = m_state->readPositions();
Expand Down
2 changes: 1 addition & 1 deletion src/SoftRobots/component/constraint/PositionConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class PositionConstraint : public PositionModel<DataTypes>
using PositionModel<DataTypes>::d_useDirections ;
using PositionModel<DataTypes>::d_directions ;
using PositionModel<DataTypes>::d_weight ;
using PositionModel<DataTypes>::m_constraintIndex ;
using PositionModel<DataTypes>::d_constraintIndex ;
using PositionModel<DataTypes>::m_state ;
///////////////////////////////////////////////////////////////////////////

Expand Down
4 changes: 2 additions & 2 deletions src/SoftRobots/component/constraint/PositionConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void PositionConstraint<DataTypes>::getConstraintViolation(const ConstraintParam
const auto& weight = sofa::helper::getReadAccessor(d_weight);
const auto& indices = sofa::helper::getReadAccessor(d_indices);
sofa::Index sizeIndices = indices.size();
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);

int index = 0;
for (unsigned int i=0; i<sizeIndices; i++)
Expand Down Expand Up @@ -205,7 +205,7 @@ void PositionConstraint<DataTypes>::storeLambda(const ConstraintParams* cParams,
if(d_componentState.getValue() != ComponentState::Valid)
return ;

d_force.setValue(lambda->element(m_constraintIndex.getValue()));
d_force.setValue(lambda->element(d_constraintIndex.getValue()));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SOFA_SOFTROBOTS_API UnilateralPlaneConstraint : public SoftRobotsConstrain

////////////////////////// Inherited attributes ////////////////////////////
using SoftRobotsConstraint<DataTypes>::m_state ;
using SoftRobotsConstraint<DataTypes>::m_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::m_nbLines ;
using SoftRobotsConstraint<DataTypes>::d_componentState ;
////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ void UnilateralPlaneConstraint<DataTypes>::buildConstraintMatrix(const Constrain

SOFA_UNUSED(cParams);

m_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
d_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);

MatrixDeriv& column = *cMatrix.beginEdit();

Expand Down Expand Up @@ -164,7 +164,7 @@ void UnilateralPlaneConstraint<DataTypes>::getConstraintViolation(const Constrai
normal = -normal;

Real dfree = Jdx->element(0) + (p0-p1)*normal/normal.norm();
resV->set(m_constraintIndex.getValue(), dfree );
resV->set(d_constraintIndex.getValue(), dfree );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class SOFA_SOFTROBOTS_API AffineFunctionModel : virtual public SoftRobotsConstra

////////////////////////// Inherited attributes ////////////////////////////
using SoftRobotsConstraint<DataTypes>::m_nbLines ;
using SoftRobotsConstraint<DataTypes>::m_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::m_state ;
using SoftRobotsConstraint<DataTypes>::d_componentState ;
////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ void AffineFunctionModel<DataTypes>::buildConstraintMatrix(const ConstraintParam
SOFA_UNUSED(cParams);
SOFA_UNUSED(x);

m_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
d_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);

MatrixDeriv& matrix = *cMatrix.beginEdit();

Expand Down Expand Up @@ -224,7 +224,7 @@ void AffineFunctionModel<DataTypes>::getConstraintViolation(const ConstraintPara

d_functionValue.setValue(getAffineFunctionValue(m_state->readPositions().ref()));
Real dfree = Jdx->element(0) + d_functionValue.getValue();
resV->set(m_constraintIndex.getValue(), dfree);
resV->set(d_constraintIndex.getValue(), dfree);
}


Expand All @@ -240,7 +240,7 @@ void AffineFunctionModel<DataTypes>::storeLambda(const ConstraintParams* cParams
if(d_componentState.getValue() != ComponentState::Valid)
return ;

d_force.setValue(lambda->element(m_constraintIndex.getValue()));
d_force.setValue(lambda->element(d_constraintIndex.getValue()));

//Note: this is one step behind
d_displacement.setValue(d_functionValue.getValue());
Expand Down
2 changes: 1 addition & 1 deletion src/SoftRobots/component/constraint/model/CableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class SOFA_SOFTROBOTS_API CableModel : virtual public SoftRobotsConstraint<DataT
/// otherwise any access to the base::attribute would require
/// using the "this->" approach.
using SoftRobotsConstraint<DataTypes>::m_nbLines ;
using SoftRobotsConstraint<DataTypes>::m_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::m_state ;
using SoftRobotsConstraint<DataTypes>::d_componentState ;
////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions src/SoftRobots/component/constraint/model/CableModel.inl
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ void CableModel<DataTypes>::buildConstraintMatrix(const ConstraintParams* cParam

SOFA_UNUSED(cParams);

m_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
d_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);

MatrixDeriv& matrix = *cMatrix.beginEdit();

Expand Down Expand Up @@ -803,7 +803,7 @@ void CableModel<DataTypes>::getConstraintViolation(const ConstraintParams* cPara

d_cableLength.setValue(getCableLength(m_state->readPositions().ref()));
Real dfree = Jdx->element(0) + d_cableInitialLength.getValue() - d_cableLength.getValue();
resV->set(m_constraintIndex.getValue(), dfree);
resV->set(d_constraintIndex.getValue(), dfree);
}


Expand All @@ -820,7 +820,7 @@ void CableModel<DataTypes>::storeLambda(const ConstraintParams* cParams,
return ;
}

d_force.setValue(lambda->element(m_constraintIndex.getValue()));
d_force.setValue(lambda->element(d_constraintIndex.getValue()));

// Compute actual cable length and displacement from updated positions of mechanical
// Eulalie.C: For now the position of the mechanical state is not up to date when storeLambda() is called
Expand Down
2 changes: 1 addition & 1 deletion src/SoftRobots/component/constraint/model/PositionModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PositionModel : virtual public SoftRobotsConstraint<DataTypes>

////////////////////////// Inherited attributes ////////////////////////////
using SoftRobotsConstraint<DataTypes>::m_nbLines ;
using SoftRobotsConstraint<DataTypes>::m_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_componentState ;
using SoftRobotsConstraint<DataTypes>::m_state ;
////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/SoftRobots/component/constraint/model/PositionModel.inl
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ void PositionModel<DataTypes>::buildConstraintMatrix(const ConstraintParams* cPa
SOFA_UNUSED(cParams);
SOFA_UNUSED(x);

m_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
d_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);
MatrixDeriv& column = *cMatrix.beginEdit();
const auto& indices = sofa::helper::getReadAccessor(d_indices);
sofa::Index sizeIndices = indices.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class SOFA_SOFTROBOTS_API SurfacePressureModel : virtual public SoftRobotsConstr
using SoftRobotsConstraint<DataTypes>::m_state ;
using SoftRobotsConstraint<DataTypes>::getContext ;
using SoftRobotsConstraint<DataTypes>::m_nbLines ;
using SoftRobotsConstraint<DataTypes>::m_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_constraintIndex ;
using SoftRobotsConstraint<DataTypes>::d_componentState ;
////////////////////////////////////////////////////////////////////////////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ void SurfacePressureModel<DataTypes>::buildConstraintMatrix(const ConstraintPara

SOFA_UNUSED(cParams);

m_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(m_constraintIndex);
d_constraintIndex.setValue(cIndex);
const auto& constraintIndex = sofa::helper::getReadAccessor(d_constraintIndex);

ReadAccessor<Data<vector<Quad>>> quadList = d_quads;
ReadAccessor<Data<vector<Triangle>>> triList = d_triangles;
Expand Down Expand Up @@ -373,7 +373,7 @@ void SurfacePressureModel<DataTypes>::getConstraintViolation(const ConstraintPar

d_cavityVolume.setValue(getCavityVolume(m_state->readPositions().ref()));
Real dfree = Jdx->element(0) + d_cavityVolume.getValue() - d_initialCavityVolume.getValue();
resV->set(m_constraintIndex.getValue(), dfree);
resV->set(d_constraintIndex.getValue(), dfree);
}


Expand All @@ -388,7 +388,7 @@ void SurfacePressureModel<DataTypes>::storeLambda(const ConstraintParams* cParam
if(d_componentState.getValue() != ComponentState::Valid)
return ;

d_pressure.setValue(lambda->element(m_constraintIndex.getValue()));
d_pressure.setValue(lambda->element(d_constraintIndex.getValue()));

// Compute actual cavity volume and volume growth from updated positions of mechanical
// Eulalie.C: For now the position of the mechanical state is not up to date when storeLambda() is called
Expand Down

0 comments on commit 0f03c21

Please sign in to comment.