Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/BeamMaterial' into LnRobotics
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/BeamAdapter/component/engine/WireRestShape.inl
  • Loading branch information
epernod committed Jan 4, 2023
2 parents 8266631 + 7c4ec9f commit fdd1dfe
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 173 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ set(HEADER_FILES
${BEAMADAPTER_SRC}/component/mapping/AdaptiveBeamMapping.inl
${BEAMADAPTER_SRC}/component/mapping/MultiAdaptiveBeamMapping.h
${BEAMADAPTER_SRC}/component/mapping/MultiAdaptiveBeamMapping.inl


${BEAMADAPTER_SRC}/component/model/WireSectionMaterial.h

${BEAMADAPTER_SRC}/utils/BeamSection.h
${BEAMADAPTER_SRC}/utils/BeamActions.h
${BEAMADAPTER_SRC}/utils/deprecatedcomponent.h
Expand Down Expand Up @@ -83,6 +85,8 @@ set(SOURCE_FILES

${BEAMADAPTER_SRC}/component/mapping/AdaptiveBeamMapping.cpp
${BEAMADAPTER_SRC}/component/mapping/MultiAdaptiveBeamMapping.cpp

${BEAMADAPTER_SRC}/component/model/WireSectionMaterial.cpp
)

if(SofaImplicitField_FOUND)
Expand Down
11 changes: 6 additions & 5 deletions examples/SingleBeamDeployment.scn
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
<DefaultVisualManagerLoop />

<Node name="EdgeTopology">
<WireRestShape name="BeamRestShape" straightLength="980.0" length="1000.0"
numEdges="200" youngModulus="20000"
spireDiameter="25" numEdgesCollis="50 10"
printLog="1" template="Rigid3d" spireHeight="0.0"
densityOfBeams="30 5" youngModulusExtremity="20000" />
<WireSectionMaterial name="WireMat1" youngModulus="20000" radius="1" massDensity="0.1" poissonRatio="0.3" nbEdgesCollis="50" nbEdgesVisu="200"/>
<WireSectionMaterial name="WireMat2" youngModulus="20000" radius="1" massDensity="0.1" poissonRatio="0.3" nbEdgesCollis="10" nbEdgesVisu="200"/>
<WireRestShape name="BeamRestShape" printLog="1" straightLength="980.0" length="1000.0"
spireDiameter="25" spireHeight="0.0"
template="Rigid3d" densityOfBeams="30 5"
wireMaterials="@WireMat1 @WireMat2"/>
<EdgeSetTopologyContainer name="meshLinesBeam"/>
<EdgeSetTopologyModifier name="Modifier"/>
<EdgeSetGeometryAlgorithms name="GeomAlgo" template="Rigid3d" />
Expand Down
43 changes: 19 additions & 24 deletions src/BeamAdapter/component/engine/WireRestShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

#include <BeamAdapter/config.h>
#include <BeamAdapter/utils/BeamSection.h>
#include <BeamAdapter/component/model/WireSectionMaterial.h>

#include <sofa/defaulttype/SolidTypes.h>
#include <sofa/core/objectmodel/BaseObject.h>
#include <sofa/component/topology/container/dynamic/EdgeSetTopologyModifier.h>
Expand All @@ -51,11 +53,14 @@ using sofa::component::topology::container::dynamic::EdgeSetTopologyModifier;
using sofa::component::topology::mapping::Edge2QuadTopologicalMapping;
using sofa::core::loader::MeshLoader;

using namespace sofa::beamadapter;

/**
* \class WireRestShape
* \brief Describe the shape functions on multiple segments
*
* Describe the shape functions on multiple segments using curvilinear abscissa
*
* Describe the full shape of a Wire with a given length and radius. The wire is discretized by a set of beams (given by the keyPoints and the relatives Beam density)
* This component compute the beam discretization and the shape functions on multiple segments using curvilinear abscissa.
*/
template <class DataTypes>
class WireRestShape : public core::objectmodel::BaseObject
Expand Down Expand Up @@ -84,7 +89,7 @@ class WireRestShape : public core::objectmodel::BaseObject
/////////////////////////// Inherited from BaseObject //////////////////////////////////////////
void parse(core::objectmodel::BaseObjectDescription* arg) override;
void init() override ;

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


Expand All @@ -97,10 +102,10 @@ class WireRestShape : public core::objectmodel::BaseObject
void getRestTransformOnX(Transform &global_H_local, const Real &x);

/// This function gives the Young modulus and Poisson's coefficient of the beam depending on the beam position
void getYoungModulusAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson);
void getYoungModulusAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson) const;

/// 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);
void getInterpolationParam(const Real& x_curv, Real &_rho, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) const;

/**
* This function provides a type::vector with the curviliar abscissa of the noticeable point(s)
Expand Down Expand Up @@ -128,6 +133,12 @@ class WireRestShape : public core::objectmodel::BaseObject

void rotateFrameForAlignX(const Quat &input, Vec3 &x, Quat &output);

protected:
/// Internal method to init Lengths vector @sa d_keyPoints if not set using @sa d_length and @sa d_straightLength. Returns false if init can't be performed.
bool initLengths();
/// Internal method to init Edge Topology @sa _topology using the list of materials @sa l_sectionMaterials. Returns false if init can't be performed.
bool initTopology();


public:
/// Analitical creation of wire shape...
Expand All @@ -139,26 +150,13 @@ class WireRestShape : public core::objectmodel::BaseObject
Data<Real> d_spireHeight;
Data<type::vector<int> > d_density;
Data<type::vector<Real> > d_keyPoints;
Data< int > d_numEdges;
Data<type::vector<int> > d_numEdgesCollis;

/// User Data about the Young modulus
Data<Real> d_poissonRatio;
Data<Real> d_youngModulus1;
Data<Real> d_youngModulus2;

/// Radius
Data<Real> d_radius1;
Data<Real> d_radius2;
Data<Real> d_innerRadius1;
Data<Real> d_innerRadius2;

Data<Real> d_massDensity1;
Data<Real> d_massDensity2;

/// broken in 2 case
Data<bool> d_brokenIn2;
Data<bool> d_drawRestShape;

/// Vector or links to the Wire section material. The order of the linked material will define the WireShape structure.
MultiLink<WireRestShape<DataTypes>, WireSectionMaterial, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_sectionMaterials;

private:
/// Data required for the File loading
Expand All @@ -167,9 +165,6 @@ class WireRestShape : public core::objectmodel::BaseObject
type::vector<Real> m_curvAbs ;
double m_absOfGeometry {0};

BeamSection beamSection1;
BeamSection beamSection2;

/// Link to be set to the topology container in the component graph.
SingleLink<WireRestShape<DataTypes>, TopologyContainer, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
/// Pointer to the topology container, should be set using @sa l_topology, otherwise will search for one in current Node.
Expand Down
Loading

0 comments on commit fdd1dfe

Please sign in to comment.