Skip to content

Commit

Permalink
Updating Cosserat namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
adagolodjo committed Jun 10, 2024
1 parent 5042087 commit 6f6dbe6
Show file tree
Hide file tree
Showing 22 changed files with 46 additions and 71 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ set(HEADER_FILES
${SRC_ROOT_DIR}/mapping/DiscreteCosseratMapping.inl
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.h
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.inl
${SRC_ROOT_DIR}/mapping/ProjectionEngine.h
${SRC_ROOT_DIR}/mapping/ProjectionEngine.inl
${SRC_ROOT_DIR}/engine/ProjectionEngine.h
${SRC_ROOT_DIR}/engine/ProjectionEngine.inl
${SRC_ROOT_DIR}/mapping/DifferenceMultiMapping.h
${SRC_ROOT_DIR}/mapping/DifferenceMultiMapping.inl
${SRC_ROOT_DIR}/mapping/RigidDistanceMapping.h
Expand All @@ -53,7 +53,7 @@ set(SOURCE_FILES
${SRC_ROOT_DIR}/mapping/BaseCosserat.cpp
${SRC_ROOT_DIR}/mapping/DiscreteCosseratMapping.cpp
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.cpp
${SRC_ROOT_DIR}/mapping/ProjectionEngine.cpp
${SRC_ROOT_DIR}/engine/ProjectionEngine.cpp
${SRC_ROOT_DIR}/mapping/DifferenceMultiMapping.cpp
${SRC_ROOT_DIR}/mapping/RigidDistanceMapping.cpp
${SRC_ROOT_DIR}/engine/PointsManager.cpp
Expand Down
9 changes: 6 additions & 3 deletions src/Cosserat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ set(HEADER_FILES
mapping/DiscreteCosseratMapping.inl
mapping/DiscretDynamicCosseratMapping.h
mapping/DiscreteDynamicCosseratMapping.inl
mapping/ProjectionEngine.h
mapping/ProjectionEngine.inl
mapping/DifferenceMultiMapping.h
mapping/DifferenceMultiMapping.inl
mapping/RigidDistanceMapping.h
mapping/RigidDistanceMapping.inl
mapping/LegendrePolynomialsMapping.h
mapping/LegendrePolynomialsMapping.inl

engine/ProjectionEngine.h
engine/ProjectionEngine.inl



forcefield/BeamHookeLawForceField.h
Expand All @@ -41,12 +43,13 @@ set(SOURCE_FILES

mapping/BaseCosserat.cpp
mapping/DiscreteCosseratMapping.cpp
mapping/ProjectionEngine.cpp
mapping/DiscreteDynamicCosseratMapping.cpp
mapping/DifferenceMultiMapping.cpp
mapping/RigidDistanceMapping.cpp
mapping/LegendrePolynomialsMapping.cpp

engine/ProjectionEngine.cpp

forcefield/BeamHookeLawForceField.cpp
forcefield/BeamHookeLawForceFieldRigid.cpp
forcefield/CosseratInternalActuation.cpp
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
#ifndef COSSERAT_ProjectionEngine_H
#define COSSERAT_ProjectionEngine_H

#include <Cosserat/config.h>

#include <Cosserat/initCosserat.h>
#include <sofa/core/behavior/PairInteractionConstraint.h>
#include <sofa/core/behavior/MechanicalState.h>
#include <sofa/core/DataEngine.h>
#include <sofa/type/Vec.h>
#include <sofa/simulation/AnimateBeginEvent.h>

#include <iostream>


Expand Down Expand Up @@ -66,32 +64,19 @@ class ProjectionEngine : public core::DataEngine
Data<VecCoord> d_dest; ///< vector to substract to input
Data<VecCoord> d_output;


//Data<Deriv> d_force; ///< interaction force

// Real m_dist; // constraint violation
// Real m_thirdConstraint; // 0 if A<proj<B, -1 if proj<A, 1 if B<proj
// bool m_yetIntegrated;
// unsigned int m_cid;


ProjectionEngine();

virtual ~ProjectionEngine(){}

public:
void init() override;
void reinit() override;

void handleEvent(core::objectmodel::Event *ev) override;

void computeProximity();

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



private:
// storage of force
Deriv m_dirAxe, m_dirProj, m_dirOrtho;
Expand Down Expand Up @@ -119,11 +104,6 @@ class ProjectionEngine : public core::DataEngine

};

//#if !defined(SOFA_COSSERAT_CPP_ProjectionEngine)
//extern template class SOFA_CONSTRAINT_API ProjectionEngine< sofa::defaulttype::Vec3Types >;

//#endif

} // namespace sofa::component::constraintset


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ void ProjectionEngine<DataTypes>::init()

template<class DataTypes>
void ProjectionEngine<DataTypes>::reinit()
{

}
{}


template<class DataTypes>
Expand Down Expand Up @@ -218,24 +216,9 @@ void ProjectionEngine<DataTypes>::draw(const core::visual::VisualParams* vparams
vparams->drawTool()->disableLighting();

sofa::type::RGBAColor color;
// Constraint& c = m_constraints[0];

// if(c.thirdConstraint<0)
// color = sofa::defaulttype::RGBAColor::yellow();
// else if(c.thirdConstraint>0)
// color = sofa::defaulttype::RGBAColor::green();
// else
color = sofa::type::RGBAColor::magenta();

std::vector<sofa::type::Vec3> vertices;
// vertices.push_back(DataTypes::getCPos((this->mstate1->read(core::ConstVecCoordId::position())->getValue())[d_m1.getValue()]));

// vparams->drawTool()->drawPoints(vertices, 10, color);
// vertices.clear();

// color = sofa::defaulttype::RGBAColor::blue();
// vertices.push_back(DataTypes::getCPos((this->mstate2->read(core::ConstVecCoordId::position())->getValue())[d_m2a.getValue()]));
// vertices.push_back(DataTypes::getCPos((this->mstate2->read(core::ConstVecCoordId::position())->getValue())[d_m2b.getValue()]));
vparams->drawTool()->drawLines(vertices, 1, color);

for (size_t i =0 ; i < m_constraints.size(); i++) {
Expand All @@ -244,9 +227,7 @@ void ProjectionEngine<DataTypes>::draw(const core::visual::VisualParams* vparams
vertices.push_back(m_constraints[i].Q);
vparams->drawTool()->drawLines(vertices, 1, color);
}
//printf("ProjectionEngine<DataTypes>::draw(const core::visual::VisualParams* vparams) After \n");

//drawLinesBetweenPoints(vparams);
vparams->drawTool()->restoreLastState();
}

Expand All @@ -269,5 +250,4 @@ void ProjectionEngine<DataTypes>::drawLinesBetweenPoints(const core::visual::Vis

} // namespace sofa::component::constraintset


#endif
#endif
2 changes: 1 addition & 1 deletion src/Cosserat/forcefield/BeamHookeLawForceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* *
******************************************************************************/
#define SOFA_COSSERAT_CPP_BeamHookeLawForceField
#include "BeamHookeLawForceField.inl"
#include <Cosserat/forcefield/BeamHookeLawForceField.inl>

#include <sofa/core/ObjectFactory.h>

Expand Down
2 changes: 1 addition & 1 deletion src/Cosserat/forcefield/BeamHookeLawForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* *
******************************************************************************/
#pragma once
#include <Cosserat/config.h>
#include <Cosserat/initCosserat.h>

#include <sofa/type/Vec.h>
#include <sofa/type/Mat.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Cosserat/forcefield/BeamHookeLawForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* *
******************************************************************************/
#pragma once
#include "BeamHookeLawForceField.h"
#include <Cosserat/forcefield/BeamHookeLawForceField.h>

#include <sofa/linearalgebra/FullVector.h>
#include <sofa/core/behavior/MechanicalState.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Cosserat/forcefield/BeamHookeLawForceFieldRigid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* *
******************************************************************************/
#define SOFA_COSSERAT_BeamHookeLawForceFieldRigid_CPP
#include "BeamHookeLawForceFieldRigid.inl"
#include <Cosserat/forcefield/BeamHookeLawForceFieldRigid.inl>

#include <sofa/core/ObjectFactory.h>

Expand Down
2 changes: 1 addition & 1 deletion src/Cosserat/forcefield/BeamHookeLawForceFieldRigid.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* *
******************************************************************************/
#pragma once
#include <Cosserat/config.h>
#include <Cosserat/initCosserat.h>

#include <sofa/type/Vec.h>
#include <sofa/type/Mat.h>
Expand Down
1 change: 1 addition & 0 deletions src/Cosserat/forcefield/BeamHookeLawForceFieldRigid.inl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
******************************************************************************/
#pragma once
#include "BeamHookeLawForceFieldRigid.h"
#include <Cosserat/forcefield/BeamHookeLawForceFieldRigid.h>

#include <sofa/linearalgebra/FullVector.h>
#include <sofa/core/behavior/MechanicalState.h>
Expand Down
3 changes: 1 addition & 2 deletions src/Cosserat/forcefield/CosseratInternalActuation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
* *
******************************************************************************/
#define SOFA_COSSERAT_CPP_CosseratInternalActuation
#include "CosseratInternalActuation.inl"

#include <Cosserat/forcefield/CosseratInternalActuation.inl>
#include <sofa/core/ObjectFactory.h>

namespace sofa::component::forcefield
Expand Down
2 changes: 1 addition & 1 deletion src/Cosserat/forcefield/CosseratInternalActuation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* *
******************************************************************************/
#pragma once
#include <Cosserat/config.h>
#include <Cosserat/initCosserat.h>

#include <sofa/type/Vec.h>
#include <sofa/type/Mat.h>
Expand Down
3 changes: 2 additions & 1 deletion src/Cosserat/forcefield/CosseratInternalActuation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
* *
******************************************************************************/
#pragma once
#include "CosseratInternalActuation.h"
#include <Cosserat/initCosserat.h>
#include <Cosserat/forcefield/CosseratInternalActuation.h>

#include <sofa/linearalgebra/FullVector.h>
#include <sofa/core/behavior/ForceField.inl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
******************************************************************************/
#define SOFA_COMPONENT_FORCEFIELD_UNIFORMVELOCITYDAMPINGFORCEFIELD_CPP

#include "MyUniformVelocityDampingForceField.inl"
#include <Cosserat/initCosserat.h>
#include <Cosserat/forcefield/MyUniformVelocityDampingForceField.inl>
#include <sofa/core/ObjectFactory.h>
#include <sofa/defaulttype/VecTypes.h>
#include <sofa/defaulttype/RigidTypes.h>
Expand Down
10 changes: 4 additions & 6 deletions src/Cosserat/forcefield/MyUniformVelocityDampingForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <SofaBoundaryCondition/config.h>
#include <Cosserat/initCosserat.h>

#include <sofa/core/behavior/ForceField.h>

Expand All @@ -30,7 +30,7 @@ using sofa::type::Vec ;
using sofa::type::Mat ;
using sofa::type::vector;
using sofa::core::MechanicalParams;
using sofa::defaulttype::BaseMatrix;
using sofa::linearalgebra::BaseMatrix;
using sofa::core::behavior::ForceField ;
using sofa::core::behavior::MultiMatrixAccessor ;

Expand Down Expand Up @@ -68,19 +68,17 @@ class MyUniformVelocityDampingForceField : public core::behavior::ForceField<Dat

void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df , const DataVecDeriv& d_dx) override;

void addKToMatrix(sofa::defaulttype::BaseMatrix *, SReal, unsigned int &) override {}
void addKToMatrix(sofa::linearalgebra::BaseMatrix *, SReal, unsigned int &) override {}

void addBToMatrix(sofa::defaulttype::BaseMatrix * mat, SReal bFact, unsigned int& offset) override;
void addBToMatrix(sofa::linearalgebra::BaseMatrix * mat, SReal bFact, unsigned int& offset) override;

void addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override;

SReal getPotentialEnergy(const core::MechanicalParams* params, const DataVecCoord& x) const override;


};



#if !defined(SOFA_COMPONENT_FORCEFIELD_UNIFORMVELOCITYDAMPINGFORCEFIELD_CPP)
extern template class SOFA_SOFABOUNDARYCONDITION_API MyUniformVelocityDampingForceField<defaulttype::Vec3Types>;
extern template class SOFA_SOFABOUNDARYCONDITION_API MyUniformVelocityDampingForceField<defaulttype::Vec2Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once

#include <Cosserat/initCosserat.h>
#include <Cosserat/forcefield/MyUniformVelocityDampingForceField.h>
#include "MyUniformVelocityDampingForceField.h"
#include <sofa/defaulttype/BaseMatrix.h>
#include <sofa/core/MechanicalParams.h>
Expand Down
7 changes: 7 additions & 0 deletions src/Cosserat/initCosserat.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
*/

namespace Cosserat {

namespace type {
//using Vec3 = sofa::defaulttype::Vec3;
//using cosserat::type::SE3;
}


SOFA_COSSERAT_API void init();
constexpr const char *MODULE_NAME = "@PROJECT_NAME@";
constexpr const char *MODULE_VERSION = "@PROJECT_VERSION@";
Expand Down
4 changes: 3 additions & 1 deletion src/Cosserat/mapping/BaseCosserat.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ using sofa::type::vector;
using sofa::type::Vec3;
using sofa::type::Vec6;
using sofa::type::Mat;

typedef typename Eigen::Matrix4d _SE3;
} // namespace

/*!
Expand Down Expand Up @@ -132,7 +134,7 @@ class BaseCosserat : public virtual sofa::core::objectmodel::BaseObject {

typedef typename sofa::type::Matrix4 se3;
typedef typename sofa::type::Matrix4 SE3;
typedef typename Eigen::Matrix4d _SE3;

typedef typename Eigen::Matrix4d _se3;
typedef typename sofa::type::Mat<6, 6, SReal> Tangent;
typedef typename Eigen::Matrix3d RotMat;
Expand Down
6 changes: 3 additions & 3 deletions src/Cosserat/mapping/DiscreteCosseratMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class DiscreteCosseratMapping
: public sofa::core::Multi2Mapping<TIn1, TIn2, TOut>,
public Cosserat::mapping::BaseCosserat<TIn1, TIn2, TOut> {
public:
SOFA_CLASS(SOFA_TEMPLATE3(DiscreteCosseratMapping, TIn1, TIn2, TOut),
SOFA_TEMPLATE3(sofa::core::Multi2Mapping, TIn1, TIn2, TOut));
typedef sofa::core::Multi2Mapping<TIn1, TIn2, TOut> Inherit;
SOFA_CLASS2(SOFA_TEMPLATE3(DiscreteCosseratMapping, TIn1, TIn2, TOut),
SOFA_TEMPLATE3(sofa::core::Multi2Mapping, TIn1, TIn2, TOut),
SOFA_TEMPLATE3(Cosserat::mapping::BaseCosserat, TIn1, TIn2, TOut));

/// Input Model Type
typedef TIn1 In1;
Expand Down
1 change: 1 addition & 0 deletions src/Cosserat/mapping/DiscreteCosseratMapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void DiscreteCosseratMapping<TIn1, TIn2, TOut>::init() {
reinit();
// I call Init here since we build the mechanics only in the
Inherit1::init();
Inherit2::init();

m_colorMap.setColorScheme("Blue to Red");
m_colorMap.reinit();
Expand Down
3 changes: 2 additions & 1 deletion src/Cosserat/mapping/LegendrePolynomialsMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Created by younes on 17/11/2021.
//
#pragma once
#include <Cosserat/config.h>
#include <Cosserat/initCosserat.h>
#include <Cosserat/mapping/BaseCosserat.h>

#include <sofa/core/BaseMapping.h>
#include <sofa/core/config.h>
Expand Down

0 comments on commit 6f6dbe6

Please sign in to comment.