Skip to content

Commit

Permalink
Merge branch 'master' into pluginmanager_support_multiconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod authored Dec 27, 2024
2 parents 5a404ab + 238851c commit 419fc86
Show file tree
Hide file tree
Showing 75 changed files with 426 additions and 8,977 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ namespace sofa::component::constraint::lagrangian::model
using namespace sofa::defaulttype;
using namespace sofa::helper;

int AugmentedLagrangianConstraintClass = core::RegisterObject("AugmentedLagrangianConstraint")
.add< AugmentedLagrangianConstraint<Vec3Types> >()

;

void registerAugmentedLagrangianConstraint(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("AugmentedLagrangianConstraint")
.add< AugmentedLagrangianConstraint<Vec3Types> >());
}

template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BaseContactLagrangianConstraint<Vec3Types,AugmentedLagrangianContactParameters>;
template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API AugmentedLagrangianConstraint<Vec3Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class BilateralLagrangianConstraintSpecialization<RigidImpl>
static void getConstraintResolution(BilateralLagrangianConstraint<T>& self,
const ConstraintParams* cParams,
std::vector<ConstraintResolution*>& resTab,
unsigned int& offset, SReal tolerance)
unsigned int& offset)
{
SOFA_UNUSED(cParams);
const unsigned minp = std::min(self.d_m1.getValue().size(),
Expand All @@ -100,7 +100,6 @@ class BilateralLagrangianConstraintSpecialization<RigidImpl>
resTab[offset] = new BilateralConstraintResolution3Dof();
offset += 3;
BilateralConstraintResolution3Dof* temp = new BilateralConstraintResolution3Dof();
temp->setTolerance(tolerance); // specific (smaller) tolerance for the rotation
resTab[offset] = temp;
offset += 3;
}
Expand Down Expand Up @@ -276,8 +275,7 @@ void BilateralLagrangianConstraint<Rigid3Types>::getConstraintResolution(
unsigned int& offset)
{
RigidBilateralLagrangianConstraint::getConstraintResolution(*this,
cParams, resTab, offset,
d_numericalTolerance.getValue());
cParams, resTab, offset);
}

template <> SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class BilateralLagrangianConstraint : public PairInteractionConstraint<DataTypes
Data<VecDeriv> d_restVector; ///< Relative position to maintain between attached points (optional)
VecCoord initialDifference;

Data<SReal> d_numericalTolerance; ///< a real value specifying the tolerance during the constraint solving. (default=0.0001
SOFA_ATTRIBUTE_DEPRECATED__BILATERALREMOVEUNUSEDTOLERANCE() DeprecatedAndRemoved d_numericalTolerance; ///< a real value specifying the tolerance during the constraint solving. (default=0.0001

Data<bool> d_activate; ///< control constraint activation (true by default)
Data<bool> d_keepOrientDiff; ///< keep the initial difference in orientation (only for rigids)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ BilateralLagrangianConstraint<DataTypes>::BilateralLagrangianConstraint(Mechanic
, d_m1(initData(&d_m1, "first_point","index of the constraint on the first model (object1)"))
, d_m2(initData(&d_m2, "second_point","index of the constraint on the second model (object2)"))
, d_restVector(initData(&d_restVector, "rest_vector","Relative position to maintain between attached points (optional)"))
, d_numericalTolerance(initData(&d_numericalTolerance, 1e-4_sreal, "numericalTolerance",
"a real value specifying the tolerance during the constraint solving.") )
, d_activate( initData(&d_activate, true, "activate", "control constraint activation (true by default)"))
, d_keepOrientDiff(initData(&d_keepOrientDiff, false, "keepOrientationDifference", "keep the initial difference in orientation (only for rigids)"))
, l_topology1(initLink("topology1", "link to the first topology container"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@ namespace sofa::component::constraint::lagrangian::model
SOFA_ATTRIBUTE_DEPRECATED( \
"v24.06", "v24.12", \
"Data renamed according to the guidelines")
#endif


#ifdef SOFA_BUILD_SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL
#define SOFA_ATTRIBUTE_DEPRECATED__BILATERALREMOVEUNUSEDTOLERANCE()
#else
#define SOFA_ATTRIBUTE_DEPRECATED__BILATERALREMOVEUNUSEDTOLERANCE() \
SOFA_ATTRIBUTE_DEPRECATED( \
"v25.06", "v25.12", \
"Data \'d_numericalTolerance\' has been removed since it was actually not taken into account")
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace sofa::component::constraint::lagrangian::model
{

extern void registerAugmentedLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerBilateralLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerFixedLagrangianConstraint(sofa::core::ObjectFactory* factory);
extern void registerSlidingLagrangianConstraint(sofa::core::ObjectFactory* factory);
Expand Down Expand Up @@ -57,6 +58,7 @@ const char* getModuleVersion()

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerAugmentedLagrangianConstraint(factory);
registerBilateralLagrangianConstraint(factory);
registerFixedLagrangianConstraint(factory);
registerSlidingLagrangianConstraint(factory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ void MeshROI<DataTypes>::roiComputeBBox(const core::ExecParams* params, type::Bo

for (const auto& p : roiPositions)
{
bbox.include(DataTypes::getCPos(p));
Real x, y, z;
DataTypes::get(x, y, z, p);
bbox.include({x, y, z});
}
}

Expand Down
11 changes: 6 additions & 5 deletions Sofa/Component/Engine/Select/tests/BoxROI_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ struct BoxROITest : public sofa::testing::BaseTest
Node::SPtr m_node;
typename TheBoxROI::SPtr m_boxroi;

void SetUp() override
void onSetUp() override
{
sofa::simpleapi::importPlugin("Sofa.Component.StateContainer");
sofa::simpleapi::importPlugin("Sofa.Component.Topology.Container.Dynamic");
sofa::simpleapi::importPlugin("Sofa.Component.Engine.Select");
this->loadPlugins({
"Sofa.Component.StateContainer",
"Sofa.Component.Topology.Container.Dynamic",
"Sofa.Component.Engine.Select"});

m_simu = sofa::simulation::getSimulation();
ASSERT_NE(m_simu, nullptr);
Expand All @@ -86,7 +87,7 @@ struct BoxROITest : public sofa::testing::BaseTest
m_node->addObject(m_boxroi);
}

void TearDown() override
void onTearDown() override
{
if (m_root != nullptr){
sofa::simulation::node::unload(m_root);
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class STLExporter_test : public BaseSimulationTest {
{
sofa::simpleapi::importPlugin("Sofa.Component.StateContainer");
sofa::simpleapi::importPlugin("Sofa.Component.Visual");
sofa::simpleapi::importPlugin("Sofa.Component.IO.Mesh");
}

void TearDown() override
Expand Down Expand Up @@ -98,7 +99,6 @@ class STLExporter_test : public BaseSimulationTest {
"<?xml version='1.0'?> \n"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > \n"
" <DefaultAnimationLoop/> \n"
" <RequiredPlugin name='Sofa.Component.IO.Mesh' /> \n"
" <MechanicalObject position='0 1 2 3 4 5 6 7 8 9'/> \n"
" <MeshOBJLoader name='loader' filename='mesh/liver-smooth.obj'/> \n"
" <VisualModel src='@loader'/> \n"
Expand Down
22 changes: 12 additions & 10 deletions Sofa/Component/LinearSolver/Direct/tests/SparseLDLSolver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ TEST(SparseLDLSolver, EmptyMState)

const sofa::simulation::Node::SPtr root = sofa::simulation::getSimulation()->createNewGraph("root");

sofa::simpleapi::importPlugin("Sofa.Component.LinearSolver.Direct");
sofa::simpleapi::importPlugin("Sofa.Component.ODESolver.Backward");
sofa::simpleapi::importPlugin("Sofa.Component.StateContainer");
const auto plugins = sofa::testing::makeScopedPlugin({
"Sofa.Component.LinearSolver.Direct",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.StateContainer"});

sofa::simpleapi::createObject(root, "DefaultAnimationLoop");
sofa::simpleapi::createObject(root, "EulerImplicitSolver");
Expand All @@ -83,14 +84,15 @@ TEST(SparseLDLSolver, TopologyChangeEmptyMState)
// required to be able to use EXPECT_MSG_NOEMIT and EXPECT_MSG_EMIT
sofa::helper::logging::MessageDispatcher::addHandler(sofa::testing::MainGtestMessageHandler::getInstance() ) ;

const sofa::simulation::Node::SPtr root = sofa::simulation::getSimulation()->createNewGraph("root");
const sofa::simulation::Node::SPtr root = sofa::simulation::getSimulation()->createNewGraph("root");

sofa::simpleapi::importPlugin("Sofa.Component.LinearSolver.Direct");
sofa::simpleapi::importPlugin("Sofa.Component.Mass");
sofa::simpleapi::importPlugin("Sofa.Component.ODESolver.Backward");
sofa::simpleapi::importPlugin("Sofa.Component.StateContainer");
sofa::simpleapi::importPlugin("Sofa.Component.Topology.Container.Dynamic");
sofa::simpleapi::importPlugin("Sofa.Component.Topology.Utility");
const auto plugins = sofa::testing::makeScopedPlugin({
"Sofa.Component.LinearSolver.Direct",
"Sofa.Component.Mass",
"Sofa.Component.ODESolver.Backward",
"Sofa.Component.StateContainer",
"Sofa.Component.Topology.Container.Dynamic",
"Sofa.Component.Topology.Utility"});

sofa::simpleapi::createObject(root, "DefaultAnimationLoop");
sofa::simpleapi::createObject(root, "EulerImplicitSolver");
Expand Down
4 changes: 2 additions & 2 deletions Sofa/framework/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND SOFA_USE_DEPENDENCY_PACK)
endif()

# Compile options
# Set C++17
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
# Set C++20
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)

set(SOFACONFIG_COMPILE_OPTIONS_DEBUG "")
set(SOFACONFIG_COMPILE_OPTIONS_RELEASE "")
Expand Down
7 changes: 4 additions & 3 deletions Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ bool ObjectFactory::registerObjectsFromPlugin(const std::string& pluginName)
// do not register if it was already done before
if(m_registeredPluginSet.count(pluginName) > 0)
{
// msg_warning("ObjectFactory") << pluginName << " has already registered its components.";
// This warning should be generalized (i.e not only in dev mode) when runSofa will not auto-load modules/plugins by default anymore
dmsg_warning("ObjectFactory") << pluginName << " has already registered its components.";
return false;
}

Expand Down Expand Up @@ -837,8 +838,8 @@ RegisterObject& RegisterObject::addCreator(std::string classname, std::string te

RegisterObject::operator int() const
{
//std::cout << "Implicit object registration is deprecrated since v24.06. Check #4429 for more information." << std::endl;
// msg_warning("RegisterObject") << "Implicit object registration is deprecrated since v24.06. Check #4429 for more information.";
dmsg_warning("RegisterObject") << m_objectRegistrationdata.entry.className
<< ": Implicit object registration is deprecated since v24.12. Check #4429 for more information.";
return commitTo(ObjectFactory::getInstance());
}

Expand Down
4 changes: 3 additions & 1 deletion Sofa/framework/Core/src/sofa/core/ObjectFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,14 @@ class SOFA_CORE_API ObjectRegistrationData

/// This is the final operation that will actually commit the additions to the ObjectFactory.
bool commitTo(sofa::core::ObjectFactory* objectFactory) const;

friend class RegisterObject;
};


// Legacy structure, to keep compatibility with olden code
// using the singleton to get the instance of ObjectFactory
class /* SOFA_ATTRIBUTE_DEPRECATED__REGISTEROBJECT() */ SOFA_CORE_API RegisterObject
class SOFA_ATTRIBUTE_DEPRECATED__REGISTEROBJECT() SOFA_CORE_API RegisterObject
{
private:
ObjectRegistrationData m_objectRegistrationdata;
Expand Down
18 changes: 14 additions & 4 deletions Sofa/framework/Helper/test/system/PluginManager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,22 @@ TEST_F(PluginManager_test, loadTestPluginAByPath)
/// Check that existing plugins are correctly handled and returns no
/// error/warning message.
{
EXPECT_MSG_NOEMIT(Warning, Error);

EXPECT_MSG_NOEMIT(Error, Warning);
std::cout << "PluginManager_test.loadTestPluginAByPath: "
<< "pm.getPluginMap().size() = " << pm.getPluginMap().size()
<< std::endl;
<< "pm.getPluginMap().size() = " << pm.getPluginMap().size()
<< std::endl;
}
{
EXPECT_MSG_NOEMIT(Error);
// Plugin A still uses the deprecated registration mechanism
// and is expected to throw a warning when loaded
EXPECT_MSG_EMIT(Warning);

ASSERT_EQ(pm.loadPluginByPath(pluginPath), PluginManager::PluginLoadStatus::SUCCESS);
}
{
EXPECT_MSG_NOEMIT(Error, Warning);
ASSERT_GT(pm.findPlugin(pluginAName).size(), 0u);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,16 @@ bool RequiredPlugin::loadPlugin()
objectFactory->registerObjectsFromPlugin(name);

// fail-safe to check if potential components have been registered (implicitly or explicitly)
// SOFA_ATTRIBUTE_DEPRECATED__REGISTEROBJECT()
std::vector<sofa::core::ObjectFactory::ClassEntry::SPtr> entries;
objectFactory->getEntriesFromTarget(entries, name);

if (entries.empty())
{
// msg_warning() << "No component has been registered from " << name << ".\n"
// << "It could be because: \n"
// << " - the entrypoint registerObjects() has not been implemented;\n"
// << " - (deprecated) no sofa::core::RegisterObject() has been called;\n"
// << " - your plugin does not add any component (i.e BaseObject) into the factory. In that case, RequiredPlugin is not useful for this kind of plugin.";
msg_warning() << "No component has been registered from " << name << ".\n"
<< "It could be because: \n"
<< " - the entrypoint registerObjects() has not been implemented;\n"
<< " - (deprecated since v24.12) no sofa::core::RegisterObject() has been called;\n"
<< " - your plugin does not add any component (i.e BaseObject) into the factory. In that case, RequiredPlugin is not useful for this kind of plugin.";
}

if (d_stopAfterFirstSuffixFound.getValue()) break;
Expand Down
8 changes: 4 additions & 4 deletions Sofa/framework/Simulation/Core/test/RequiredPlugin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct RequiredPlugin_test : public BaseSimulationTest

void testLoadPluginB()
{
EXPECT_MSG_EMIT(Warning); // // TestPluginB does not register any component
EXPECT_MSG_EMIT(Warning); // TestPluginB does not register any component

std::stringstream scene;
scene << "<?xml version='1.0'?>"
Expand All @@ -101,7 +101,7 @@ struct RequiredPlugin_test : public BaseSimulationTest

void testLoadPluginC()
{
EXPECT_MSG_NOEMIT(Warning); // // TestPluginC registers its component explicitly
EXPECT_MSG_NOEMIT(Warning); // TestPluginC registers its component explicitly

std::stringstream scene;
scene << "<?xml version='1.0'?>"
Expand All @@ -118,8 +118,8 @@ struct RequiredPlugin_test : public BaseSimulationTest

TEST_F(RequiredPlugin_test, testNotExistingPlugin ) { testNotExistingPlugin(); }
TEST_F(RequiredPlugin_test, testNoParameter ) { testNoParameter(); }
TEST_F(RequiredPlugin_test, DISABLED_testLoadPluginA) { testLoadPluginA(); } // disabled because testLoadPluginA() should throw a warning (but this warning is commented for the moment)
TEST_F(RequiredPlugin_test, DISABLED_testLoadPluginB) { testLoadPluginB(); }// disabled because testLoadPluginB() should throw a warning (but this warning is commented for the moment)
TEST_F(RequiredPlugin_test, testLoadPluginA) { testLoadPluginA(); }
TEST_F(RequiredPlugin_test, testLoadPluginB) { testLoadPluginB(); }
TEST_F(RequiredPlugin_test, testLoadPluginC) { testLoadPluginC(); }

}
Loading

0 comments on commit 419fc86

Please sign in to comment.