Skip to content

Commit

Permalink
STYLE: rename variables as the convention sofa-framework#288
Browse files Browse the repository at this point in the history
  • Loading branch information
Younesssss authored and guparan committed Aug 23, 2017
1 parent 23f2434 commit 6c58d66
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 123 deletions.
36 changes: 18 additions & 18 deletions applications/plugins/SofaCUDA/sofa/gpu/cuda/CudaFixedConstraint.inl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes<TCoord,TDeriv,TReal
data.maxIndex = -1;
data.cudaIndices.clear();
m->core::behavior::template ProjectiveConstraintSet<DataTypes>::init();
const SetIndexArray& indices = m->f_indices.getValue();
const SetIndexArray& indices = m->d_indices.getValue();
if (!indices.empty())
{
// put indices in a set to sort them and remove duplicates
Expand Down Expand Up @@ -106,8 +106,8 @@ void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes<TCoord,TDeriv,TReal
{
Data& data = *m->data;
//std::cout << "CudaFixedConstraint::addConstraint("<<index<<")\n";
m->f_indices.beginEdit()->push_back(index);
m->f_indices.endEdit();
m->d_indices.beginEdit()->push_back(index);
m->d_indices.endEdit();
if (data.cudaIndices.empty())
{
if (data.minIndex == -1)
Expand Down Expand Up @@ -152,8 +152,8 @@ template<class TCoord, class TDeriv, class TReal>
void FixedConstraintInternalData< gpu::cuda::CudaVectorTypes<TCoord,TDeriv,TReal> >::removeConstraint(Main* m, unsigned int index)
{
Data& data = *m->data;
removeValue(*m->f_indices.beginEdit(),index);
m->f_indices.endEdit();
removeValue(*m->d_indices.beginEdit(),index);
m->d_indices.endEdit();
if (data.cudaIndices.empty())
{
if (data.minIndex <= (int)index && (int)index <= data.maxIndex)
Expand Down Expand Up @@ -205,7 +205,7 @@ void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes<N, real> >::init(Mai
data.maxIndex = -1;
data.cudaIndices.clear();
m->core::behavior::template ProjectiveConstraintSet<DataTypes>::init();
const SetIndexArray& indices = m->f_indices.getValue();
const SetIndexArray& indices = m->d_indices.getValue();
if (!indices.empty())
{
// put indices in a set to sort them and remove duplicates
Expand Down Expand Up @@ -234,8 +234,8 @@ void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes<N, real> >::addConst
{
Data& data = *m->data;
//std::cout << "CudaFixedConstraint::addConstraint("<<index<<")\n";
m->f_indices.beginEdit()->push_back(index);
m->f_indices.endEdit();
m->d_indices.beginEdit()->push_back(index);
m->d_indices.endEdit();
if (data.cudaIndices.empty())
{
if (data.minIndex == -1)
Expand Down Expand Up @@ -280,8 +280,8 @@ template<int N, class real>
void FixedConstraintInternalData< gpu::cuda::CudaRigidTypes<N, real> >::removeConstraint(Main* m, unsigned int index)
{
Data& data = *m->data;
removeValue(*m->f_indices.beginEdit(),index);
m->f_indices.endEdit();
removeValue(*m->d_indices.beginEdit(),index);
m->d_indices.endEdit();
if (data.cudaIndices.empty())
{
if (data.minIndex <= (int)index && (int)index <= data.maxIndex)
Expand Down Expand Up @@ -331,7 +331,7 @@ template <>
void FixedConstraintInternalData<gpu::cuda::CudaVec1fTypes>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCuda1f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCuda1f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+data.minIndex);
Expand All @@ -344,7 +344,7 @@ template <>
void FixedConstraintInternalData<gpu::cuda::CudaVec3fTypes>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCuda3f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCuda3f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+3*data.minIndex);
Expand All @@ -357,7 +357,7 @@ template <>
void FixedConstraintInternalData<gpu::cuda::CudaVec3f1Types>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCuda3f1_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCuda3f1_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+4*data.minIndex);
Expand All @@ -369,7 +369,7 @@ template <>
void FixedConstraintInternalData<gpu::cuda::CudaRigid3fTypes>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCudaRigid3f_projectResponseContiguous(dx.size(), ((float*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCudaRigid3f_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((float*)dx.deviceWrite())+6*data.minIndex);
Expand All @@ -387,15 +387,15 @@ void FixedConstraintInternalData<gpu::cuda::CudaRigid3fTypes>::projectResponse(M
// // std::list<const TopologyChange *>::const_iterator itBegin=topology->firstChange();
// // std::list<const TopologyChange *>::const_iterator itEnd=topology->lastChange();
// //
// // f_indices.beginEdit()->handleTopologyEvents(itBegin,itEnd,this->getMState()->getSize());
// // d_indices.beginEdit()->handleTopologyEvents(itBegin,itEnd,this->getMState()->getSize());
// //printf("WARNING handleTopologyChange<gpu::cuda::CudaVec3dTypes> not implemented\n");
// }

template <>
void FixedConstraintInternalData<gpu::cuda::CudaVec3dTypes>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCuda3d_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCuda3d_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+3*data.minIndex);
Expand All @@ -407,7 +407,7 @@ template <>
void FixedConstraintInternalData<gpu::cuda::CudaVec3d1Types>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCuda3d1_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCuda3d1_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+4*data.minIndex);
Expand All @@ -419,7 +419,7 @@ template <>
void FixedConstraintInternalData<gpu::cuda::CudaRigid3dTypes>::projectResponse(Main* m, VecDeriv& dx)
{
Data& data = *m->data;
if (m->f_fixAll.getValue())
if (m->d_fixAll.getValue())
FixedConstraintCudaRigid3d_projectResponseContiguous(dx.size(), ((double*)dx.deviceWrite()));
else if (data.minIndex >= 0)
FixedConstraintCudaRigid3d_projectResponseContiguous(data.maxIndex-data.minIndex+1, ((double*)dx.deviceWrite())+6*data.minIndex);
Expand Down
32 changes: 16 additions & 16 deletions modules/SofaBoundaryCondition/FixedConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ template <>
void FixedConstraint<Rigid3dTypes>::draw(const core::visual::VisualParams* vparams)
{
if (!vparams->displayFlags().getShowBehaviorModels()) return;
if (!f_showObject.getValue()) return;
if (!d_showObject.getValue()) return;
if (!this->isActive()) return;

const SetIndexArray & indices = f_indices.getValue();
const SetIndexArray & indices = d_indices.getValue();
if (!vparams->displayFlags().getShowBehaviorModels()) return;
std::vector< Vector3 > points;

const VecCoord& x =mstate->read(core::ConstVecCoordId::position())->getValue();
if( f_fixAll.getValue()==true )
if( d_fixAll.getValue()==true )
for (unsigned i=0; i<x.size(); i++ )
points.push_back(x[i].getCenter());
else
Expand All @@ -106,20 +106,20 @@ void FixedConstraint<Rigid3dTypes>::draw(const core::visual::VisualParams* vpara
}
}

if( f_drawSize.getValue() == 0) // old classical drawing by points
if( d_drawSize.getValue() == 0) // old classical drawing by points
vparams->drawTool()->drawPoints(points, 10, Vec<4,float>(1,0.5,0.5,1));
else
vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), Vec<4,float>(1.0f,0.35f,0.35f,1.0f));
vparams->drawTool()->drawSpheres(points, (float)d_drawSize.getValue(), Vec<4,float>(1.0f,0.35f,0.35f,1.0f));
}

template <>
void FixedConstraint<Rigid2dTypes>::draw(const core::visual::VisualParams* vparams)
{
if (!vparams->displayFlags().getShowBehaviorModels()) return;
if (!f_showObject.getValue()) return;
if (!d_showObject.getValue()) return;
if (!this->isActive()) return;

const SetIndexArray & indices = f_indices.getValue();
const SetIndexArray & indices = d_indices.getValue();
if (!vparams->displayFlags().getShowBehaviorModels()) return;

vparams->drawTool()->saveLastState();
Expand All @@ -129,7 +129,7 @@ void FixedConstraint<Rigid2dTypes>::draw(const core::visual::VisualParams* vpara
sofa::defaulttype::Vec4f color (1,0.5,0.5,1);
std::vector<sofa::defaulttype::Vector3> vertices;

if( f_fixAll.getValue()==true )
if( d_fixAll.getValue()==true )
{
for (unsigned i=0; i<x.size(); i++ )
vertices.push_back(sofa::defaulttype::Vector3(x[i].getCenter()[0],
Expand All @@ -154,35 +154,35 @@ template <>
void FixedConstraint<Rigid3fTypes>::draw(const core::visual::VisualParams* vparams)
{
if (!vparams->displayFlags().getShowBehaviorModels()) return;
if (!f_showObject.getValue()) return;
if (!d_showObject.getValue()) return;
if (!this->isActive()) return;

const SetIndexArray & indices = f_indices.getValue();
const SetIndexArray & indices = d_indices.getValue();
if (!vparams->displayFlags().getShowBehaviorModels()) return;
std::vector< Vector3 > points;

const VecCoord& x =mstate->read(core::ConstVecCoordId::position())->getValue();
if( f_fixAll.getValue()==true )
if( d_fixAll.getValue()==true )
for (unsigned i=0; i<x.size(); i++ )
points.push_back(x[i].getCenter());
else
for (SetIndex::const_iterator it = indices.begin(); it != indices.end(); ++it)
points.push_back(x[*it].getCenter());

if( f_drawSize.getValue() == 0) // old classical drawing by points
if( d_drawSize.getValue() == 0) // old classical drawing by points
vparams->drawTool()->drawPoints(points, 10, Vec<4,float>(1,0.5,0.5,1));
else
vparams->drawTool()->drawSpheres(points, (float)f_drawSize.getValue(), Vec<4,float>(1.0f,0.35f,0.35f,1.0f));
vparams->drawTool()->drawSpheres(points, (float)d_drawSize.getValue(), Vec<4,float>(1.0f,0.35f,0.35f,1.0f));
}

template <>
void FixedConstraint<Rigid2fTypes>::draw(const core::visual::VisualParams* vparams)
{
if (!vparams->displayFlags().getShowBehaviorModels()) return;
if (!f_showObject.getValue()) return;
if (!d_showObject.getValue()) return;
if (!this->isActive()) return;

const SetIndexArray & indices = f_indices.getValue();
const SetIndexArray & indices = d_indices.getValue();
if (!vparams->displayFlags().getShowBehaviorModels()) return;

vparams->drawTool()->saveLastState();
Expand All @@ -192,7 +192,7 @@ void FixedConstraint<Rigid2fTypes>::draw(const core::visual::VisualParams* vpara
sofa::defaulttype::Vec4f color (1,0.5,0.5,1);
std::vector<sofa::defaulttype::Vector3> vertices;

if( f_fixAll.getValue()==true )
if( d_fixAll.getValue()==true )
{
for (unsigned i=0; i<x.size(); i++ )
vertices.push_back(sofa::defaulttype::Vector3(x[i].getCenter()[0],
Expand Down
14 changes: 7 additions & 7 deletions modules/SofaBoundaryCondition/FixedConstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ class FixedConstraint : public core::behavior::ProjectiveConstraintSet<DataTypes
virtual ~FixedConstraint();

public:
SetIndex f_indices;
Data<bool> f_fixAll;
Data<bool> f_showObject;
Data<SReal> f_drawSize;
Data<bool> f_activate_projectVelocity;
SetIndex d_indices;
Data<bool> d_fixAll;
Data<bool> d_showObject;
Data<SReal> d_drawSize;
Data<bool> d_projectVelocity;


protected:
Expand All @@ -105,7 +105,7 @@ class FixedConstraint : public core::behavior::ProjectiveConstraintSet<DataTypes
virtual void reinit();

void projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData);
void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData);
void projectVelocity(const core::MechanicalParams* mparams, DataVecDeriv& vData);
void projectPosition(const core::MechanicalParams* mparams, DataVecCoord& xData);
void projectJacobianMatrix(const core::MechanicalParams* mparams, DataMatrixDeriv& cData);

Expand All @@ -121,7 +121,7 @@ class FixedConstraint : public core::behavior::ProjectiveConstraintSet<DataTypes

virtual void draw(const core::visual::VisualParams* vparams);

bool fixAllDOFs() const { return f_fixAll.getValue(); }
bool fixAllDOFs() const { return d_fixAll.getValue(); }

class FCPointHandler : public sofa::component::topology::TopologySubsetDataHandler<core::topology::BaseMeshTopology::Point, SetIndexArray >
{
Expand Down
Loading

0 comments on commit 6c58d66

Please sign in to comment.