Skip to content

Commit

Permalink
Add bemSection getter for WireBeamInterpolation and therefor WireRest…
Browse files Browse the repository at this point in the history
…Shape
  • Loading branch information
epernod committed May 6, 2024
1 parent 104a248 commit 45e7c45
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/BeamAdapter/component/BaseBeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
using VecEdgeID = type::vector<BaseMeshTopology::EdgeID>;
using VecEdges = type::vector<BaseMeshTopology::Edge>;

using BeamSection = sofa::beamadapter::BeamSection;

BaseBeamInterpolation(/*sofa::component::engine::WireRestShape<DataTypes> *_restShape = nullptr*/);

virtual ~BaseBeamInterpolation() = default;
Expand Down Expand Up @@ -132,6 +134,7 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
virtual void getSplineRestTransform(unsigned int edgeInList, Transform& local_H_local0_rest, Transform& local_H_local1_rest) = 0;
virtual void getInterpolationParam(unsigned int edgeInList, Real& _L, Real& _A, Real& _Iy, Real& _Iz,
Real& _Asy, Real& _Asz, Real& J) = 0;
virtual const BeamSection& getBeamSection(int edgeIndex) = 0;


int computeTransform(const EdgeID edgeInList, Transform& global_H_local0, Transform& global_H_local1, const VecCoord& x);
Expand Down
6 changes: 2 additions & 4 deletions src/BeamAdapter/component/BeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ class BeamInterpolation : public virtual BaseBeamInterpolation<DataTypes>
using PointID = BaseMeshTopology::PointID;
using ElementID = BaseMeshTopology::EdgeID;
using VecElementID = type::vector<BaseMeshTopology::EdgeID>;
using VecEdges = type::vector<BaseMeshTopology::Edge>;

using BeamSection = sofa::beamadapter::BeamSection;
using VecEdges = type::vector<BaseMeshTopology::Edge>;

public:
BeamInterpolation() ;
Expand Down Expand Up @@ -150,7 +148,7 @@ class BeamInterpolation : public virtual BaseBeamInterpolation<DataTypes>
/// computeActualLength => given the 4 control points of the spline, it provides an estimate of the length (using gauss points integration)


BeamSection &getBeamSection(int /*edgeIndex*/ ){return this->m_constantSection;}
const BeamSection &getBeamSection(int /*edgeIndex*/ ) override {return this->m_constantSection;}

virtual void getCurvAbsAtBeam(const unsigned int& edgeInList_input, const Real& baryCoord_input, Real& x_output) {}
virtual void getBeamAtCurvAbs(const Real& x_input, unsigned int& edgeInList_output, Real& baryCoord_output, unsigned int start = 0) {}
Expand Down
1 change: 1 addition & 0 deletions src/BeamAdapter/component/WireBeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class WireBeamInterpolation : public virtual BaseBeamInterpolation<DataTypes>
void getSplineRestTransform(unsigned int edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest) override;
void getInterpolationParam(unsigned int edgeInList, Real& _L, Real& _A, Real& _Iy, Real& _Iz,
Real& _Asy, Real& _Asz, Real& _J) override;
const BeamSection& getBeamSection(int edgeIndex) override;
bool getApproximateCurvAbs(const Vec3& x_input, const VecCoord& x, Real& x_output); // Project a point on the segments, return false if cant project


Expand Down
13 changes: 12 additions & 1 deletion src/BeamAdapter/component/WireBeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace sofa::component::fem::_wirebeaminterpolation_
{

using sofa::component::engine::WireRestShape ;

using namespace sofa::beamadapter;

template <class DataTypes>
WireBeamInterpolation<DataTypes>::WireBeamInterpolation(sofa::component::engine::WireRestShape<DataTypes> *_restShape)
Expand Down Expand Up @@ -175,6 +175,17 @@ void WireBeamInterpolation<DataTypes>::getInterpolationParam(unsigned int edgeIn
restShape->getInterpolationParam(x_curv, _rho, _A, _Iy, _Iz, _Asy, _Asz, _J);
}


template<class DataTypes>
const BeamSection& WireBeamInterpolation<DataTypes>::getBeamSection(int edgeIndex)
{
Real x_curv = 0;
this->getAbsCurvXFromBeam(edgeIndex, x_curv);

auto restShape = this->m_restShape.get();
return restShape->getBeamSection(x_curv);
}

template<class DataTypes>
bool WireBeamInterpolation<DataTypes>::getApproximateCurvAbs(const Vec3& x_input, const VecCoord& x, Real& x_output)
{
Expand Down
3 changes: 3 additions & 0 deletions src/BeamAdapter/component/engine/WireRestShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class WireRestShape : public core::objectmodel::BaseObject
/// This function gives the mass density and the BeamSection data depending on the beam position
void getInterpolationParam(const Real& x_curv, Real &_rho, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) const;

/// This function returns the BeamSection data depending on the beam position
const BeamSection& getBeamSection(const Real& x_curv) const;

/**
* This function provides a type::vector with the curviliar abscissa of the noticeable point(s)
* and the minimum density (number of points) between them. (Nb. nbP_density.size() == xP_noticeable.size() - 1)
Expand Down
20 changes: 20 additions & 0 deletions src/BeamAdapter/component/engine/WireRestShape.inl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,26 @@ void WireRestShape<DataTypes>::getInterpolationParam(const Real& x_curv, Real &_
}



template <class DataTypes>
const BeamSection& WireRestShape<DataTypes>::getBeamSection(const Real& x_curv) const
{
const Real x_used = x_curv - Real(EPSILON);
const type::vector<Real>& keyPts = d_keyPoints.getValue();

// Check in which section x_used belongs to and get access to this section material
for (sofa::Size i = 1; i < keyPts.size(); ++i)
{
if (x_used <= keyPts[i])
{
return l_sectionMaterials.get(i - 1)->getBeamSection();
}
}

msg_error() << " problem in getBeamSection : x_curv " << x_curv << " is not between keyPoints" << keyPts;
}


template <class DataTypes>
typename WireRestShape<DataTypes>::Real WireRestShape<DataTypes>::getLength()
{
Expand Down
3 changes: 3 additions & 0 deletions src/BeamAdapter/component/model/BaseRodSectionMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class BaseRodSectionMaterial : public core::objectmodel::BaseObject
/// Returns the mass density and the BeamSection of this section
void getInterpolationParam(Real& _rho, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) const;

/// Returns the BeamSection data structure of this section
const BeamSection& getBeamSection() const { return beamSection; };

/// This function is called to get the rest position of the beam depending on the current curved abscisse given in parameter
virtual void getRestTransformOnX(Transform& global_H_local, const Real& x_used, const Real& x_start)
{
Expand Down

0 comments on commit 45e7c45

Please sign in to comment.