Skip to content

Commit cf46ccd

Browse files
authored
Merge pull request #175 from fredroy/cleanup_interpol
[All] Clean types
2 parents e83775b + 2e7e9ec commit cf46ccd

18 files changed

Lines changed: 145 additions & 169 deletions

BeamAdapter_test/component/model/WireRestShape_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ void WireRestShape_test::testParameterInit()
163163
Real straightLength = 95.0;
164164
EXPECT_EQ(fullLength, 100.0);
165165

166-
int nbrE0 = 50;
167-
int nbrE1 = 10;
166+
sofa::Size nbrE0 = 50;
167+
sofa::Size nbrE1 = 10;
168168
vector<Real> keysPoints, keysPoints_ref = { 0, straightLength, fullLength };
169-
vector<int> nbP_density, nbP_density_ref = { nbrE0, nbrE1 };
169+
vector<sofa::Size> nbP_density, nbP_density_ref = { nbrE0, nbrE1 };
170170

171171
wire->getSamplingParameters(keysPoints, nbP_density);
172172
EXPECT_EQ(keysPoints.size(), 3);

src/BeamAdapter/component/BaseBeamInterpolation.h

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
9090

9191
static void getControlPointsFromFrame(
9292
const Transform& global_H_local0, const Transform& global_H_local1,
93-
const Real& L,
93+
const Real L,
9494
Vec3& P0, Vec3& P1,
9595
Vec3& P2, Vec3& P3);
9696

@@ -103,99 +103,98 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
103103
virtual void clear();
104104

105105
public:
106-
virtual void addBeam(const BaseMeshTopology::EdgeID& eID, const Real& length, const Real& x0, const Real& x1, const Real& angle);
107-
unsigned int getNumBeams() { return this->d_edgeList.getValue().size(); }
106+
virtual void addBeam(const EdgeID eID, const Real length, const Real x0, const Real x1, const Real angle);
107+
sofa::Size getNumBeams() const { return static_cast<sofa::Size>(this->d_edgeList.getValue().size()); }
108108

109-
void getAbsCurvXFromBeam(int beam, Real& x_curv);
110-
void getAbsCurvXFromBeam(int beam, Real& x_curv_start, Real& x_curv_end);
109+
void getAbsCurvXFromBeam(const sofa::Index beam, Real& x_curv);
110+
void getAbsCurvXFromBeam(const sofa::Index beam, Real& x_curv_start, Real& x_curv_end);
111111

112112
/// getLength / setLength => provides the rest length of each spline using @sa d_lengthList
113113
virtual Real getRestTotalLength() = 0;
114-
Real getLength(unsigned int edgeInList);
115-
void setLength(unsigned int edgeInList, Real& length);
114+
Real getLength(const EdgeID edgeInList);
115+
void setLength(const EdgeID edgeInList, Real& length);
116116

117117
/// Collision information using @sa d_beamCollision
118-
virtual void getCollisionSampling(Real& dx, const Real& x_localcurv_abs) = 0;
119-
void addCollisionOnBeam(unsigned int b);
118+
virtual void getCollisionSampling(Real& dx, const Real x_localcurv_abs) = 0;
119+
void addCollisionOnBeam(const sofa::Index beam);
120120
void clearCollisionOnBeam();
121121

122122
virtual void getSamplingParameters(type::vector<Real>& xP_noticeable,
123-
type::vector<int>& nbP_density) = 0;
124-
virtual void getNumberOfCollisionSegment(Real& dx, unsigned int& numLines) = 0;
123+
type::vector<sofa::Size>& nbP_density) = 0;
124+
virtual void getNumberOfCollisionSegment(Real& dx, sofa::Size& numLines) = 0;
125125

126-
127-
virtual void getCurvAbsAtBeam(const unsigned int& edgeInList_input, const Real& baryCoord_input, Real& x_output) = 0;
128-
virtual void getSplineRestTransform(unsigned int edgeInList, Transform& local_H_local0_rest, Transform& local_H_local1_rest) = 0;
126+
virtual void getCurvAbsAtBeam(const EdgeID edgeInList_input, const Real baryCoord_input, Real& x_output) = 0;
127+
virtual void getSplineRestTransform(const EdgeID edgeInList, Transform& local_H_local0_rest, Transform& local_H_local1_rest) = 0;
129128

130129
/// Returns the BeamSection @sa m_beamSection corresponding to the given beam
131-
virtual const BeamSection& getBeamSection(sofa::Index beamId) = 0;
130+
virtual const BeamSection& getBeamSection(const sofa::Index beamId) = 0;
132131
/// Returns the BeamSection data depending on the beam position at the given beam, similar to @getBeamSection
133-
virtual void getInterpolationParameters(sofa::Index beamId, Real& _L, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& J) = 0;
132+
virtual void getInterpolationParameters(const sofa::Index beamId, Real& _L, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& J) = 0;
134133
/// Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa
135-
virtual void getMechanicalParameters(sofa::Index beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) = 0;
134+
virtual void getMechanicalParameters(const sofa::Index beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) = 0;
136135

137136

138-
virtual void getBeamAtCurvAbs(const Real& x_input, unsigned int& edgeInList_output, Real& baryCoord_output, unsigned int start = 0);
137+
virtual void getBeamAtCurvAbs(const Real x_input, sofa::Index& edgeInList_output, Real& baryCoord_output, unsigned int start = 0);
139138

140139
int computeTransform(const EdgeID edgeInList, Transform& global_H_local0, Transform& global_H_local1, const VecCoord& x);
141140
int computeTransform(const EdgeID edgeInList, const PointID node0Idx, const PointID node1Idx, Transform& global_H_local0, Transform& global_H_local1, const VecCoord& x);
142141

143-
void getDOFtoLocalTransform(unsigned int edgeInList, Transform& DOF0_H_local0, Transform& DOF1_H_local1);
144-
void getDOFtoLocalTransformInGlobalFrame(unsigned int edgeInList, Transform& DOF0Global_H_local0, Transform& DOF1Global_H_local1, const VecCoord& x);
145-
void setTransformBetweenDofAndNode(int beam, const Transform& DOF_H_Node, unsigned int zeroORone);
142+
void getDOFtoLocalTransform(const EdgeID edgeInList, Transform& DOF0_H_local0, Transform& DOF1_H_local1);
143+
void getDOFtoLocalTransformInGlobalFrame(const EdgeID edgeInList, Transform& DOF0Global_H_local0, Transform& DOF1Global_H_local1, const VecCoord& x);
144+
void setTransformBetweenDofAndNode(const sofa::Index beam, const Transform& DOF_H_Node, unsigned int zeroORone);
146145

147-
void getTangent(Vec3& t, const Real& baryCoord,
148-
const Transform& global_H_local0, const Transform& global_H_local1, const Real& L);
146+
void getTangent(Vec3& t, const Real baryCoord,
147+
const Transform& global_H_local0, const Transform& global_H_local1, const Real L);
149148

150-
int getNodeIndices(unsigned int edgeInList, unsigned int& node0Idx, unsigned int& node1Idx);
149+
int getNodeIndices(const EdgeID edgeInList, unsigned int& node0Idx, unsigned int& node1Idx);
151150

152-
void getSplinePoints(unsigned int edgeInList, const VecCoord& x, Vec3& P0, Vec3& P1, Vec3& P2, Vec3& P3);
151+
void getSplinePoints(const EdgeID edgeInList, const VecCoord& x, Vec3& P0, Vec3& P1, Vec3& P2, Vec3& P3);
153152
unsigned int getStateSize() const;
154153

155154
void computeActualLength(Real& length, const Vec3& P0, const Vec3& P1, const Vec3& P2, const Vec3& P3);
156155

157-
void computeStrechAndTwist(unsigned int edgeInList, const VecCoord& x, Vec3& ResultNodeO, Vec3& ResultNode1);
156+
void computeStrechAndTwist(const EdgeID edgeInList, const VecCoord& x, Vec3& ResultNodeO, Vec3& ResultNode1);
158157

159158

160159

161160
///vId_Out provides the id of the multiVecId which stores the position of the Bezier Points
162161
void updateBezierPoints(const VecCoord& x, sofa::core::VecCoordId& vId_Out);
163-
void updateBezierPoints(const VecCoord& x, unsigned int index, VectorVec3& v);
162+
void updateBezierPoints(const VecCoord& x, sofa::Index index, VectorVec3& v);
164163

165164

166165
/// spline base interpolation of points and transformation
167-
void interpolatePointUsingSpline(unsigned int edgeInList, const Real& baryCoord, const Vec3& localPos, const VecCoord& x, Vec3& posResult) {
166+
void interpolatePointUsingSpline(const EdgeID edgeInList, const Real baryCoord, const Vec3& localPos, const VecCoord& x, Vec3& posResult) {
168167
interpolatePointUsingSpline(edgeInList, baryCoord, localPos, x, posResult, true, sofa::core::vec_id::read_access::position);
169168
}
170169

171-
void interpolatePointUsingSpline(unsigned int edgeInList, const Real& baryCoord, const Vec3& localPos,
170+
void interpolatePointUsingSpline(const EdgeID edgeInList, const Real baryCoord, const Vec3& localPos,
172171
const VecCoord& x, Vec3& posResult, bool recompute, const sofa::core::ConstVecCoordId& vecXId);
173172

174173

175-
void InterpolateTransformUsingSpline(unsigned int edgeInList, const Real& baryCoord, const Vec3& localPos,
174+
void InterpolateTransformUsingSpline(const EdgeID edgeInList, const Real baryCoord, const Vec3& localPos,
176175
const VecCoord& x, Transform& global_H_localInterpol);
177176

178-
void InterpolateTransformUsingSpline(Transform& global_H_localResult, const Real& baryCoord,
179-
const Transform& global_H_local0, const Transform& global_H_local1, const Real& L);
177+
void InterpolateTransformUsingSpline(Transform& global_H_localResult, const Real baryCoord,
178+
const Transform& global_H_local0, const Transform& global_H_local1, const Real L);
180179

181-
void InterpolateTransformAndVelUsingSpline(unsigned int edgeInList, const Real& baryCoord, const Vec3& localPos,
180+
void InterpolateTransformAndVelUsingSpline(const EdgeID edgeInList, const Real baryCoord, const Vec3& localPos,
182181
const VecCoord& x, const VecDeriv& v,
183182
Transform& global_H_localInterpol, Deriv& v_interpol);
184183

185184

186185
/// compute the total bending Rotation Angle while going through the Spline (to estimate the curvature)
187-
Real ComputeTotalBendingRotationAngle(const Real& dx_computation, const Transform& global_H_local0,
188-
const Transform& global_H_local1, const Real& L,
189-
const Real& baryCoordMin, const Real& baryCoordMax);
186+
Real ComputeTotalBendingRotationAngle(const Real dx_computation, const Transform& global_H_local0,
187+
const Transform& global_H_local1, const Real L,
188+
const Real baryCoordMin, const Real baryCoordMax);
190189

191190

192191
/// 3DOF mapping
193-
void MapForceOnNodeUsingSpline(unsigned int edgeInList, const Real& baryCoord, const Vec3& localPos,
192+
void MapForceOnNodeUsingSpline(const EdgeID edgeInList, const Real baryCoord, const Vec3& localPos,
194193
const VecCoord& x, const Vec3& finput,
195194
SpatialVector& FNode0output, SpatialVector& FNode1output);
196195

197196
/// 6DoF mapping
198-
void MapForceOnNodeUsingSpline(unsigned int edgeInList, const Real& baryCoord, const Vec3& localPos,
197+
void MapForceOnNodeUsingSpline(const EdgeID edgeInList, const Real baryCoord, const Vec3& localPos,
199198
const VecCoord& x, const SpatialVector& f6DofInput,
200199
SpatialVector& FNode0output, SpatialVector& FNode1output);
201200

@@ -212,7 +211,7 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
212211
const VecEdges* m_topologyEdges{ nullptr };
213212

214213
///2. Vector of length of each beam. Same size as @sa d_edgeList
215-
Data< type::vector< double > > d_lengthList;
214+
Data< type::vector< Real > > d_lengthList;
216215

217216
///3. (optional) apply a rigid Transform between the degree of Freedom and the first node of the beam. Indexation based on the num of Edge
218217
Data< type::vector< Transform > > d_DOF0TransformNode0;
@@ -224,7 +223,7 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
224223
Data< type::vector< Vec2 > > d_curvAbsList;
225224

226225
///5. (optional) list of the beams in m_edgeList that need to be considered for collision
227-
Data< sofa::type::vector<int> > d_beamCollision;
226+
Data< sofa::type::vector<EdgeID> > d_beamCollision;
228227

229228
Data<bool> d_dofsAndBeamsAligned;
230229

0 commit comments

Comments
 (0)