diff --git a/applications/projects/CMakeLists.txt b/applications/projects/CMakeLists.txt index 48eebc64ff8..8669b0a1415 100644 --- a/applications/projects/CMakeLists.txt +++ b/applications/projects/CMakeLists.txt @@ -16,3 +16,4 @@ sofa_add_subdirectory(application sofaOPENCL sofaOPENCL OFF) sofa_add_subdirectory(directory Regression Regression EXTERNAL) sofa_add_subdirectory(directory SofaGLFW SofaGLFW EXTERNAL) sofa_add_subdirectory(application sofaProjectExample sofaProjectExample) +sofa_add_subdirectory(application sofaInfo sofaInfo) diff --git a/applications/projects/sofaInfo/CMakeLists.txt b/applications/projects/sofaInfo/CMakeLists.txt index d3fe466de1b..6a8724633f7 100644 --- a/applications/projects/sofaInfo/CMakeLists.txt +++ b/applications/projects/sofaInfo/CMakeLists.txt @@ -1,10 +1,9 @@ cmake_minimum_required(VERSION 3.12) project(sofaInfo) -find_package(SofaGeneral) -find_package(SofaMisc) -find_package(SofaBase) -find_package(SofaCommon) +find_package(Sofa.Config) +sofa_find_package(Sofa.Component) +sofa_find_package(Sofa.Simulation.Graph) add_executable(${PROJECT_NAME} sofaInfo.cpp) -target_link_libraries(${PROJECT_NAME} SofaGeneral SofaBase SofaCommon SofaMisc) +target_link_libraries(${PROJECT_NAME} Sofa.Component Sofa.Simulation.Graph) diff --git a/applications/projects/sofaInfo/sofaInfo.cpp b/applications/projects/sofaInfo/sofaInfo.cpp index 0f816ec632d..0433fb89bad 100644 --- a/applications/projects/sofaInfo/sofaInfo.cpp +++ b/applications/projects/sofaInfo/sofaInfo.cpp @@ -19,32 +19,31 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#include -#include -#include #include +#include +#include +#include +#include +#include // --------------------------------------------------------------------- // --- // --------------------------------------------------------------------- int main(int /*argc*/, char** argv) { - sofa::simulation::tree::init(); - sofa::component::initSofaBase(); - sofa::component::initSofaCommon(); - sofa::component::initSofaGeneral(); + sofa::simulation::common::init(); + sofa::simulation::graph::init(); + sofa::component::init(); - if (argv[1] == NULL) + if (argv[1] == nullptr) { std::cout << "Usage: sofaInfo FILE" << std::endl; return -1; } - sofa::simulation::setSimulation(new sofa::simulation::tree::TreeSimulation()); + sofa::simulation::Node::SPtr groot = sofa::simulation::node::load(argv[1]); - sofa::simulation::Node::SPtr groot = sofa::core::objectmodel::SPtr_dynamic_cast( sofa::simulation::getSimulation()->load(argv[1])); - - if (groot==NULL) + if (groot == nullptr) { groot = sofa::simulation::getSimulation()->createNewGraph(""); } @@ -56,14 +55,14 @@ int main(int /*argc*/, char** argv) groot->getTreeObjects(&objects); // get the classes and targets of the scene - for (unsigned int i=0; igetEntry(objects[i]->getClassName()); - if (entry.creatorMap.empty()) + sofa::core::ObjectFactory::ClassEntry& entry = sofa::core::ObjectFactory::getInstance()->getEntry(object->getClassName()); + if (!entry.creatorMap.empty()) { classNames.insert(entry.className); - sofa::core::ObjectFactory::CreatorMap::iterator it = entry.creatorMap.find(objects[i]->getTemplateName()); + const auto it = entry.creatorMap.find(object->getTemplateName()); if (it != entry.creatorMap.end() && *it->second->getTarget()) { targets.insert(it->second->getTarget()); @@ -71,27 +70,18 @@ int main(int /*argc*/, char** argv) } } - std::set::const_iterator it = classNames.begin(); - std::set::const_iterator end = classNames.end(); std::cout << "=== CLASSES ===" << std::endl; - while (it != end) - { - std::cout << (*it) << std::endl; - it++; - } + std::cout << sofa::helper::join(classNames, "\n"); - it = targets.begin(); - end = targets.end(); std::cout << std::endl << "=== TARGETS ===" << std::endl; - while (it != end) + std::cout << sofa::helper::join(targets, "\n"); + + if (groot != nullptr) { - std::cout << (*it) << std::endl; - it++; + sofa::simulation::node::unload(groot); } - if (groot!=NULL) - sofa::simulation::getSimulation()->unload(groot); - - sofa::simulation::tree::cleanup(); + sofa::simulation::common::cleanup(); + sofa::simulation::graph::cleanup(); return 0; }