Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleaning #278

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class SOFA_SOFTROBOTS_API SurfacePressureConstraint : public SurfacePressureMode

private:
void initData();
void setUpVolumeLimits(double& imposedValue, double& minPressure, double& maxPressure);
void setUpPressureLimits(double& imposedValue, double& minVolumeGrowth, double& maxVolumeGrowth);
void setUpVolumeLimits(Real& imposedValue, Real& minPressure, Real& maxPressure);
void setUpPressureLimits(Real& imposedValue, Real& minVolumeGrowth, Real& maxVolumeGrowth);

};

Expand Down
34 changes: 18 additions & 16 deletions src/SoftRobots/component/constraint/SurfacePressureConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ SurfacePressureConstraint<DataTypes>::SurfacePressureConstraint(MechanicalState*
"If unspecified the default value is {0}"))

, d_valueType(initData(&d_valueType, {"pressure","volumeGrowth"}, "valueType",
"volumeGrowth = the contstraint will impose the volume growth provided in data value[valueIndex] \n"
"pressure = the contstraint will impose the pressure provided in data value[valueIndex] \n"
"volumeGrowth = the constraint will impose the volume growth provided in data value[valueIndex] \n"
"pressure = the constraint will impose the pressure provided in data value[valueIndex] \n"
"If unspecified, the default value is pressure"))
{
d_eqVolumeGrowth.setDisplayed(false);
Expand Down Expand Up @@ -93,14 +93,14 @@ void SurfacePressureConstraint<DataTypes>::reset()
template<class DataTypes>
void SurfacePressureConstraint<DataTypes>::initData()
{
if(d_value.getValue().size()==0)
if (d_value.getValue().empty())
{
WriteAccessor<Data<vector<Real>>> value = d_value;
value.resize(1);
}

// check for errors in the initialization
if(d_value.getValue().size()<d_valueIndex.getValue())
if (d_value.getValue().size() < d_valueIndex.getValue())
{
msg_warning() <<"Bad size for data value (size="<< d_value.getValue().size()<<"), or wrong value for data valueIndex (valueIndex="<<d_valueIndex.getValue()<<"). Set default valueIndex=0.";
d_valueIndex.setValue(0);
Expand All @@ -112,24 +112,26 @@ template<class DataTypes>
void SurfacePressureConstraint<DataTypes>::getConstraintResolution(std::vector<ConstraintResolution*>& resTab,
unsigned int& offset)
{
if(d_componentState.getValue() != ComponentState::Valid)
return ;
if (!this->isComponentStateValid())
{
return;
}

double imposedValue = d_value.getValue()[d_valueIndex.getValue()];
Real imposedValue = d_value.getValue()[d_valueIndex.getValue()];

if(d_valueType.getValue().getSelectedItem() == "volumeGrowth")
if (d_valueType.getValue().getSelectedItem() == "volumeGrowth")
{
double maxPressure = std::numeric_limits<double>::max();
double minPressure = -maxPressure;
setUpVolumeLimits(imposedValue,minPressure,maxPressure);
Real maxPressure = std::numeric_limits<Real>::max();
Real minPressure = -maxPressure;
setUpVolumeLimits(imposedValue, minPressure, maxPressure);

VolumeGrowthConstraintResolution *cr= new VolumeGrowthConstraintResolution(imposedValue, minPressure, maxPressure);
resTab[offset++] =cr;
resTab[offset++] = cr;
}
else // pressure
{
double maxVolumeGrowth = std::numeric_limits<double>::max();
double minVolumeGrowth = -maxVolumeGrowth;
Real maxVolumeGrowth = std::numeric_limits<Real>::max();
Real minVolumeGrowth = -maxVolumeGrowth;
setUpPressureLimits(imposedValue,minVolumeGrowth,maxVolumeGrowth);

SurfacePressureConstraintResolution *cr= new SurfacePressureConstraintResolution(imposedValue, minVolumeGrowth, maxVolumeGrowth);
Expand All @@ -139,7 +141,7 @@ void SurfacePressureConstraint<DataTypes>::getConstraintResolution(std::vector<C


template<class DataTypes>
void SurfacePressureConstraint<DataTypes>::setUpVolumeLimits(double& imposedValue, double& minPressure, double& maxPressure)
void SurfacePressureConstraint<DataTypes>::setUpVolumeLimits(Real& imposedValue, Real& minPressure, Real& maxPressure)
{
if(d_maxVolumeGrowthVariation.isSet())
{
Expand All @@ -166,7 +168,7 @@ void SurfacePressureConstraint<DataTypes>::setUpVolumeLimits(double& imposedValu


template<class DataTypes>
void SurfacePressureConstraint<DataTypes>::setUpPressureLimits(double& imposedValue, double& minVolumeGrowth, double& maxVolumeGrowth)
void SurfacePressureConstraint<DataTypes>::setUpPressureLimits(Real& imposedValue, Real& minVolumeGrowth, Real& maxVolumeGrowth)
{
if (d_maxPressureVariation.isSet())
{
Expand Down
Loading