@@ -48,6 +48,15 @@ using sofa::helper::system::PluginRepository;
4848using sofa::simulation::SceneLoaderFactory;
4949using sofa::simulation::SceneLoader;
5050
51+ //
52+ #include < pybind11/stl.h>
53+ #include < sofa/core/ObjectFactory.h>
54+ using sofa::core::ObjectFactory;
55+ #include < sofa/core/CategoryLibrary.h>
56+ using sofa::core::CategoryLibrary;
57+ //
58+
59+
5160#include < SofaPython3/SceneLoaderPY3.h>
5261using sofapython3::SceneLoaderPY3;
5362
@@ -68,6 +77,7 @@ using sofapython3::SceneLoaderPY3;
6877namespace sofapython3
6978{
7079
80+
7181class SofaInitializer
7282{
7383public:
@@ -85,7 +95,25 @@ class SofaInitializer
8595 }
8696};
8797
98+ static std::vector<std::string> getCategories (std::string className)
99+ {
100+ std::vector<std::string> categories;
101+ ObjectFactory* factory = ObjectFactory::getInstance ();
88102
103+ if (factory->hasCreator (className))
104+ {
105+ ObjectFactory::ClassEntry entry = factory->getEntry (className);
106+ ObjectFactory::CreatorMap::iterator it2 = entry.creatorMap .begin ();
107+
108+ if ( it2 != entry.creatorMap .end ())
109+ {
110+ ObjectFactory::Creator::SPtr c = it2->second ;
111+ const sofa::core::objectmodel::BaseClass* objClass = c->getClass ();
112+ CategoryLibrary::getCategories (objClass,categories);
113+ }
114+ }
115+ return categories ;
116+ }
89117
90118static SofaInitializer s;
91119
@@ -132,6 +160,7 @@ PYBIND11_MODULE(SofaRuntime, m) {
132160
133161 m.add_object (" DataRepository" , py::cast (&sofa::helper::system::DataRepository));
134162 m.add_object (" PluginRepository" , py::cast (&sofa::helper::system::PluginRepository));
163+ m.def (" getCategories" , &getCategories);
135164
136165 addSubmoduleTimer (m);
137166}
0 commit comments