BeamAdapter
Loading...
Searching...
No Matches
BaseBeamInterpolation< DataTypes > Class Template Referenceabstract
Inheritance diagram for BaseBeamInterpolation< DataTypes >:
BeamInterpolation< DataTypes > WireBeamInterpolation< DataTypes >

Public Types

using Inherit = sofa::core::behavior::SingleStateAccessor<DataTypes>
using Coord = typename DataTypes::Coord
using VecCoord = typename DataTypes::VecCoord
using Real = typename Coord::value_type
using Deriv = typename DataTypes::Deriv
using VecDeriv = typename DataTypes::VecDeriv
using Transform = sofa::type::Transform<Real>
using SpatialVector = sofa::type::SpatialVector<Real>
using Vec2 = sofa::type::Vec<2, Real>
using Vec3 = sofa::type::Vec<3, Real>
using Vec3NoInit = sofa::type::VecNoInit<3, Real>
using Quat = sofa::type::Quat<Real>
using VectorVec3 = type::vector <Vec3>
using PointID = BaseMeshTopology::PointID
using EdgeID = BaseMeshTopology::EdgeID
using VecEdgeID = type::vector<BaseMeshTopology::EdgeID>
using VecEdges = type::vector<BaseMeshTopology::Edge>
using StateDataTypes = sofa::defaulttype::StdVectorTypes< sofa::type::Vec<DataTypes::spatial_dimensions, Real>, sofa::type::Vec<DataTypes::spatial_dimensions, Real>, Real >
 DATA INPUT (that could change in real-time).

Public Member Functions

 SOFA_CLASS (SOFA_TEMPLATE(BaseBeamInterpolation, DataTypes), SOFA_TEMPLATE(sofa::core::behavior::SingleStateAccessor, DataTypes))
void init () override
virtual void clear ()
virtual void addBeam (const EdgeID eID, const Real length, const Real x0, const Real x1, const Real angle)
sofa::Size getNumBeams () const
void getAbsCurvXFromBeam (const sofa::Index beam, Real &x_curv)
void getAbsCurvXFromBeam (const sofa::Index beam, Real &x_curv_start, Real &x_curv_end)
virtual Real getRestTotalLength ()=0
 getLength / setLength => provides the rest length of each spline using
Real getLength (const EdgeID edgeInList)
void setLength (const EdgeID edgeInList, Real &length)
virtual void getMechanicalSampling (Real &dx, const Real x_localcurv_abs)=0
virtual void getCollisionSampling (Real &dx, const Real x_localcurv_abs)=0
 Collision information using.
void addCollisionOnBeam (const sofa::Index beam)
 Set collision information.
void clearCollisionOnBeam ()
virtual void getSamplingParameters (type::vector< Real > &xP_noticeable, type::vector< sofa::Size > &nbP_density)=0
virtual void getNumberOfCollisionSegment (Real &dx, sofa::Size &numLines)=0
virtual void getCurvAbsAtBeam (const EdgeID edgeInList_input, const Real baryCoord_input, Real &x_output)=0
virtual void getSplineRestTransform (const EdgeID edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest)=0
virtual const BeamSection & getBeamSection (const sofa::Index beamId)=0
 Returns the BeamSection.
virtual void getInterpolationParameters (const sofa::Index beamId, Real &_L, Real &_A, Real &_Iy, Real &_Iz, Real &_Asy, Real &_Asz, Real &J)=0
 Returns the BeamSection data depending on the beam position at the given beam, similar to @getBeamSection.
virtual void getMechanicalParameters (const sofa::Index beamId, Real &youngModulus, Real &cPoisson, Real &massDensity)=0
 Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa.
virtual void getBeamAtCurvAbs (const Real x_input, sofa::Index &edgeInList_output, Real &baryCoord_output, unsigned int start=0)
int computeTransform (const EdgeID edgeInList, Transform &global_H_local0, Transform &global_H_local1, const VecCoord &x)
int computeTransform (const EdgeID edgeInList, const PointID node0Idx, const PointID node1Idx, Transform &global_H_local0, Transform &global_H_local1, const VecCoord &x)
void getDOFtoLocalTransform (const EdgeID edgeInList, Transform &DOF0_H_local0, Transform &DOF1_H_local1)
void getDOFtoLocalTransformInGlobalFrame (const EdgeID edgeInList, Transform &DOF0Global_H_local0, Transform &DOF1Global_H_local1, const VecCoord &x)
void setTransformBetweenDofAndNode (const sofa::Index beam, const Transform &DOF_H_Node, unsigned int zeroORone)
void getTangent (Vec3 &t, const Real baryCoord, const Transform &global_H_local0, const Transform &global_H_local1, const Real L)
 getTangent : Computation of a Tangent for the beam (it is given by the derivative of the spline formulation)
int getNodeIndices (const EdgeID edgeInList, unsigned int &node0Idx, unsigned int &node1Idx)
void getSplinePoints (const EdgeID edgeInList, const VecCoord &x, Vec3 &P0, Vec3 &P1, Vec3 &P2, Vec3 &P3)
unsigned int getStateSize () const
void computeActualLength (Real &length, const Vec3 &P0, const Vec3 &P1, const Vec3 &P2, const Vec3 &P3)
void computeStrechAndTwist (const EdgeID edgeInList, const VecCoord &x, Vec3 &ResultNodeO, Vec3 &ResultNode1)
void updateBezierPoints (const VecCoord &x, sofa::core::VecCoordId &vId_Out)
 vId_Out provides the id of the multiVecId which stores the position of the Bezier Points
void updateBezierPoints (const VecCoord &x, sofa::Index index, VectorVec3 &v)
void interpolatePointUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, Vec3 &posResult)
 spline base interpolation of points and transformation
void interpolatePointUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, Vec3 &posResult, bool recompute, const sofa::core::ConstVecCoordId &vecXId)
void InterpolateTransformUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, Transform &global_H_localInterpol)
void InterpolateTransformUsingSpline (Transform &global_H_localResult, const Real baryCoord, const Transform &global_H_local0, const Transform &global_H_local1, const Real L)
void InterpolateTransformAndVelUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, const VecDeriv &v, Transform &global_H_localInterpol, Deriv &v_interpol)
Real ComputeTotalBendingRotationAngle (const Real dx_computation, const Transform &global_H_local0, const Transform &global_H_local1, const Real L, const Real baryCoordMin, const Real baryCoordMax)
 compute the total bending Rotation Angle while going through the Spline (to estimate the curvature)
void MapForceOnNodeUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, const Vec3 &finput, SpatialVector &FNode0output, SpatialVector &FNode1output)
 3DOF mapping
void MapForceOnNodeUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, const SpatialVector &f6DofInput, SpatialVector &FNode0output, SpatialVector &FNode1output)
 6DoF mapping

Static Public Member Functions

static void getControlPointsFromFrame (const Transform &global_H_local0, const Transform &global_H_local1, const Real L, Vec3 &P0, Vec3 &P1, Vec3 &P2, Vec3 &P3)
static void RotateFrameForAlignX (const Quat &input, Vec3 &x, Quat &output)
 Method to rotate a Frame define by a Quat.
static void RotateFrameForAlignNormalizedX (const Quat &input, const Vec3 &x, Quat &output)
 Method to rotate a Frame define by a Quat.

Public Attributes

MechanicalObject< StateDataTypes >::SPtr m_StateNodes
Data< VecEdgeID > d_edgeList
Data< type::vector< SReal > > d_lengthList
Data< type::vector< Transform > > d_DOF0TransformNode0
Data< type::vector< Transform > > d_DOF1TransformNode1
Data< type::vector< Vec2 > > d_curvAbsList
 Vector of 2 Real. absciss curv of first and second point defining the beam.
Data< sofa::type::vector< EdgeID > > d_beamCollision
Data< bool > d_dofsAndBeamsAligned
Data< sofa::Index > d_wireTipIndex
 index of the beam extremity that is considered as the tip of the wire
SingleLink< BaseBeamInterpolation< DataTypes >, BaseMeshTopology, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK > l_topology
 link to the (edge) topology

Member Function Documentation

◆ computeActualLength()

template<class DataTypes>
void computeActualLength ( Real & length,
const Vec3 & P0,
const Vec3 & P1,
const Vec3 & P2,
const Vec3 & P3 )

the computation of integral Int[0,1]_||dP(x)||_ dx = length is done using Gauss Points

definition of the Gauss points

formula with 4 Gauss Points

◆ computeStrechAndTwist()

template<class DataTypes>
void computeStrechAndTwist ( const EdgeID edgeInList,
const VecCoord & x,
Vec3 & ResultNodeO,
Vec3 & ResultNode1 )

ResultNode = [half length of the beam (m), geometrical Twist angle (rad), additional mechanical Twist angle (rad)]

spline:

compute length

compute frame => Kenneth method

bx == 0.5 => frame of the beam (without mechanical twist)

computation of twist angle:

<<" Test : x_1 = "<<x_1<< " should be equal to ="<< globalRgeom1.rotate(Vec3(1.0,0.0,0.0))<<std::endl;

◆ ComputeTotalBendingRotationAngle()

template<class DataTypes>
BaseBeamInterpolation< DataTypes >::Real ComputeTotalBendingRotationAngle ( const Real dx_computation,
const Transform & global_H_local0,
const Transform & global_H_local1,
const Real L,
const Real baryCoordMin,
const Real baryCoordMax )

compute the total bending Rotation Angle while going through the Spline (to estimate the curvature)

ComputeTotalBendingRotationAngle This function compute a global bending angle value for the current position of the beam Principle: computation of several tangent between node0 to the node1 (given by numComputationPoints) and computation of an angle (acos) between these successive tangents

◆ computeTransform() [1/2]

template<class DataTypes>
int computeTransform ( const EdgeID edgeInList,
const PointID node0Idx,
const PointID node1Idx,
Transform & global_H_local0,
Transform & global_H_local1,
const VecCoord & x )
  1. Computes the optional rigid transformation of DOF0_Transform_node0 and DOF1_Transform_node1
  1. Computes the transformation global To local for both nodes
  • add a optional transformation

no error

◆ computeTransform() [2/2]

template<class DataTypes>
int computeTransform ( const EdgeID edgeInList,
Transform & global_H_local0,
Transform & global_H_local1,
const VecCoord & x )
  1. Get the indices of element and nodes

◆ getBeamAtCurvAbs()

template<class DataTypes>
void getBeamAtCurvAbs ( const Real x_input,
sofa::Index & edgeInList_output,
Real & baryCoord_output,
unsigned int start = 0 )
virtual

lTotalRest = total length of the

LTotal = length sum of the beams that are "out"

we find the length of the beam that is "out"

x_i = abs_curv from the begining of the instrument

we compute the x value of each node :the topology (stored in Edge_list) is supposed to be a regular seq of segment

◆ getBeamSection()

template<class DataTypes>
virtual const BeamSection & getBeamSection ( const sofa::Index beamId)
pure virtual

Returns the BeamSection.

See also
m_beamSection corresponding to the given beam

Implemented in BeamInterpolation< DataTypes >, BeamInterpolation< TIn >, and WireBeamInterpolation< DataTypes >.

◆ getCollisionSampling()

template<class DataTypes>
virtual void getCollisionSampling ( Real & dx,
const Real x_localcurv_abs )
pure virtual

◆ getCurvAbsAtBeam()

template<class DataTypes>
virtual void getCurvAbsAtBeam ( const EdgeID edgeInList_input,
const Real baryCoord_input,
Real & x_output )
pure virtual

◆ getInterpolationParameters()

template<class DataTypes>
virtual void getInterpolationParameters ( const sofa::Index beamId,
Real & _L,
Real & _A,
Real & _Iy,
Real & _Iz,
Real & _Asy,
Real & _Asz,
Real & J )
pure virtual

Returns the BeamSection data depending on the beam position at the given beam, similar to @getBeamSection.

Implemented in BeamInterpolation< DataTypes >, BeamInterpolation< TIn >, and WireBeamInterpolation< DataTypes >.

◆ getMechanicalParameters()

template<class DataTypes>
virtual void getMechanicalParameters ( const sofa::Index beamId,
Real & youngModulus,
Real & cPoisson,
Real & massDensity )
pure virtual

Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa.

Implemented in BeamInterpolation< DataTypes >, BeamInterpolation< TIn >, and WireBeamInterpolation< DataTypes >.

◆ getNodeIndices()

template<class DataTypes>
int getNodeIndices ( const EdgeID edgeInList,
unsigned int & node0Idx,
unsigned int & node1Idx )
  1. Get the indices of element and nodes

◆ getRestTotalLength()

template<class DataTypes>
virtual Real getRestTotalLength ( )
pure virtual

getLength / setLength => provides the rest length of each spline using

See also
d_lengthList

Implemented in BeamInterpolation< DataTypes >, BeamInterpolation< TIn >, and WireBeamInterpolation< DataTypes >.

◆ getSplineRestTransform()

template<class DataTypes>
virtual void getSplineRestTransform ( const EdgeID edgeInList,
Transform & local_H_local0_rest,
Transform & local_H_local1_rest )
pure virtual

◆ interpolatePointUsingSpline()

template<class DataTypes>
void interpolatePointUsingSpline ( const EdgeID edgeInList,
const Real baryCoord,
const Vec3 & localPos,
const VecCoord & x,
Vec3 & posResult,
bool recompute,
const sofa::core::ConstVecCoordId & vecXId )

<<" interpolatePointUsingSpline : "<< edgeInList<<" xbary="<<baryCoord<<" localPos"<<localPos<<std::endl;

Todo
remove call to computeTransform => make something faster !

no need to recompute the positions of the Spline => we will read their value in the vector which id is vecXId

◆ InterpolateTransformAndVelUsingSpline()

template<class DataTypes>
void InterpolateTransformAndVelUsingSpline ( const EdgeID edgeInList,
const Real baryCoord,
const Vec3 & localPos,
const VecCoord & x,
const VecDeriv & v,
Transform & global_H_localInterpol,
Deriv & v_interpol )
  1. Get the indices of element and nodes
  1. Computes the optional rigid transformation of DOF0_Transform_node0 and DOF1_Transform_node1
  1. Computes the transformation global To local for both nodes
  • add a optional transformation
  1. Computes the transformation

------------— compute velocity interpolation -----------------—//

  1. Computes the velocities of the dof (in their own reference frame...)
  1. Computes the velocities of the nodes (in their own reference frame...)
  1. Interpolate the result and put in "Deriv" vector...

◆ InterpolateTransformUsingSpline()

template<class DataTypes>
void InterpolateTransformUsingSpline ( Transform & global_H_localResult,
const Real baryCoord,
const Transform & global_H_local0,
const Transform & global_H_local1,
const Real L )

InterpolateTransformUsingSpline This function provide an interpolation of a frame that is placed between node0 and node1 the location of the frame is given by baryCoord

find the spline points

The beam is very compressed => it leads to a non correct interpolation using spline (the spline formulation is based on the rest length of the beam) For a correct result, we use linear interpolation instead... (for the quaternion, we use a "simple" slerp

The position of the frame is computed using the interpolation of the spline

the tangent is computed by derivating the spline

try to interpolate the "orientation" (especially the torsion) the best possible way... (but other ways should exit...)

  1. The frame at each node of the beam are rotated to align x along n_x
  1. We use the "slerp" interpolation to find a solution "in between" these 2 solution R0, R1
  1. The result is not necessarily alligned with n_x, so we re-aligned Rslerp to obtain a quatResult.

◆ MapForceOnNodeUsingSpline() [1/2]

template<class DataTypes>
void MapForceOnNodeUsingSpline ( const EdgeID edgeInList,
const Real baryCoord,
const Vec3 & localPos,
const VecCoord & x,
const SpatialVector & f6DofInput,
SpatialVector & FNode0output,
SpatialVector & FNode1output )

6DoF mapping

BeamInterpolation<DataTypes>::MapForceOnNodeUsingSpline 6DoF (reverse) mapping of a force (f6DofInput) that is positionned / to the centerline of a beam

  • point on the centerline given by edgeInList (num of the beam) and baryCoord
  • localPos provides the position shift / to the point on the centerline
  • x provides the positions of the nodes Result: Forces (and Torques) on the nodes of this beam
  1. get the curvilinear abs and spline parameters
  1. computes a force on the 4 points of the spline:
  1. influence of these forces on the nodes of the beam => TODO : simplify the computations !!!

rotate back to local frame

computes the torque created on DOF0 and DOF1 by f1 and f2

back to the DOF0 and DOF1 frame:

◆ MapForceOnNodeUsingSpline() [2/2]

template<class DataTypes>
void MapForceOnNodeUsingSpline ( const EdgeID edgeInList,
const Real baryCoord,
const Vec3 & localPos,
const VecCoord & x,
const Vec3 & finput,
SpatialVector & FNode0output,
SpatialVector & FNode1output )

3DOF mapping

BeamInterpolation<DataTypes>::MapForceOnNodeUsingSpline 3DoF (reverse) mapping of a force (finput) that is positionned / to the centerline of a beam

  • point on the centerline given by edgeInList (num of the beam) and baryCoord
  • localPos provides the position shift / to the point on the centerline
  • x provides the positions of the nodes Result: Forces (and Torques) on the nodes of this beam
  1. get the curvilinear abs and spline parameters
  1. computes a force on the 4 points of the spline:
  1. influence of these forces on the nodes of the beam => TODO : simplify the computations !!!

rotate back to local frame

computes the torque created on DOF0 and DOF1 by f1 and f2

back to the DOF0 and DOF1 frame:

◆ RotateFrameForAlignNormalizedX()

template<class DataTypes>
void RotateFrameForAlignNormalizedX ( const Quat & input,
const Vec3 & x,
Quat & output )
static

Method to rotate a Frame define by a Quat.

Parameters
inputaround an axis
x,xhas to be normalized. Output is return inside
output

◆ RotateFrameForAlignX()

template<class DataTypes>
void RotateFrameForAlignX ( const Quat & input,
Vec3 & x,
Quat & output )
static

Method to rotate a Frame define by a Quat.

Parameters
inputaround an axis
x,xwill be normalized in method. Output is return inside
output

◆ updateBezierPoints()

template<class DataTypes>
void updateBezierPoints ( const VecCoord & x,
sofa::core::VecCoordId & vId_Out )

vId_Out provides the id of the multiVecId which stores the position of the Bezier Points

Mechanical Object to stock Bezier points.

Member Data Documentation

◆ d_beamCollision

template<class DataTypes>
Data< sofa::type::vector<EdgeID> > d_beamCollision
  1. (optional) list of the beams in m_edgeList that need to be considered for collision

◆ d_DOF0TransformNode0

template<class DataTypes>
Data< type::vector< Transform > > d_DOF0TransformNode0
  1. (optional) apply a rigid Transform between the degree of Freedom and the first node of the beam. Indexation based on the num of Edge

◆ d_DOF1TransformNode1

template<class DataTypes>
Data< type::vector< Transform > > d_DOF1TransformNode1
  1. (optional) apply a rigid Transform between the degree of Freedom and the second node of the beam. Indexation based on the num of Edge

◆ d_lengthList

template<class DataTypes>
Data< type::vector< SReal > > d_lengthList
  1. Vector of length of each beam. Same size as
    See also
    d_edgeList