|
51 | 51 | #include <sofa/core/collision/Pipeline.h> |
52 | 52 | #include <sofa/core/collision/Intersection.h> |
53 | 53 | #include <sofa/core/objectmodel/ConfigurationSetting.h> |
54 | | - |
55 | 54 | #include <sofa/core/ExecParams.h> |
| 55 | +#include <sofa/core/CategoryLibrary.h> |
| 56 | +#include <pybind11/stl.h> |
56 | 57 |
|
57 | 58 | /// Makes an alias for the pybind11 namespace to increase readability. |
58 | 59 | namespace py { using namespace pybind11; } |
@@ -133,69 +134,11 @@ py::object getTarget(BaseObject *self) |
133 | 134 |
|
134 | 135 | py::object getCategories(BaseObject *self) |
135 | 136 | { |
136 | | - const sofa::core::objectmodel::BaseClass* mclass=self->getClass(); |
137 | 137 | std::vector<std::string> categories; |
138 | | - if (mclass->hasParent(sofa::core::objectmodel::ContextObject::GetClass())) |
139 | | - categories.push_back("ContextObject"); |
140 | | - if (mclass->hasParent(sofa::core::visual::VisualModel::GetClass())) |
141 | | - categories.push_back("VisualModel"); |
142 | | - if (mclass->hasParent(sofa::core::BehaviorModel::GetClass())) |
143 | | - categories.push_back("BehaviorModel"); |
144 | | - if (mclass->hasParent(sofa::core::CollisionModel::GetClass())) |
145 | | - categories.push_back("CollisionModel"); |
146 | | - if (mclass->hasParent(sofa::core::behavior::BaseMechanicalState::GetClass())) |
147 | | - categories.push_back("MechanicalState"); |
148 | | - // A Mass is a technically a ForceField, but we don't want it to appear in the ForceField category |
149 | | - if (mclass->hasParent(sofa::core::behavior::BaseForceField::GetClass()) && !mclass->hasParent(sofa::core::behavior::BaseMass::GetClass())) |
150 | | - categories.push_back("ForceField"); |
151 | | - if (mclass->hasParent(sofa::core::behavior::BaseInteractionForceField::GetClass())) |
152 | | - categories.push_back("InteractionForceField"); |
153 | | - if (mclass->hasParent(sofa::core::behavior::BaseProjectiveConstraintSet::GetClass())) |
154 | | - categories.push_back("ProjectiveConstraintSet"); |
155 | | - if (mclass->hasParent(sofa::core::behavior::BaseConstraintSet::GetClass())) |
156 | | - categories.push_back("ConstraintSet"); |
157 | | - if (mclass->hasParent(sofa::core::BaseMapping::GetClass())) |
158 | | - categories.push_back("Mapping"); |
159 | | - if (mclass->hasParent(sofa::core::DataEngine::GetClass())) |
160 | | - categories.push_back("Engine"); |
161 | | - if (mclass->hasParent(sofa::core::topology::TopologicalMapping::GetClass())) |
162 | | - categories.push_back("TopologicalMapping"); |
163 | | - if (mclass->hasParent(sofa::core::behavior::BaseMass::GetClass())) |
164 | | - categories.push_back("Mass"); |
165 | | - if (mclass->hasParent(sofa::core::behavior::OdeSolver::GetClass())) |
166 | | - categories.push_back("OdeSolver"); |
167 | | - if (mclass->hasParent(sofa::core::behavior::ConstraintSolver::GetClass())) |
168 | | - categories.push_back("ConstraintSolver"); |
169 | | - if (mclass->hasParent(sofa::core::behavior::BaseConstraintCorrection::GetClass())) |
170 | | - categories.push_back("ConstraintSolver"); |
171 | | - if (mclass->hasParent(sofa::core::behavior::LinearSolver::GetClass())) |
172 | | - categories.push_back("LinearSolver"); |
173 | | - if (mclass->hasParent(sofa::core::behavior::BaseAnimationLoop::GetClass())) |
174 | | - categories.push_back("AnimationLoop"); |
175 | | - // Just like Mass and ForceField, we don't want TopologyObject to appear in the Topology category |
176 | | - if (mclass->hasParent(sofa::core::topology::Topology::GetClass()) && !mclass->hasParent(sofa::core::topology::BaseTopologyObject::GetClass())) |
177 | | - categories.push_back("Topology"); |
178 | | - if (mclass->hasParent(sofa::core::topology::BaseTopologyObject::GetClass())) |
179 | | - categories.push_back("TopologyObject"); |
180 | | - if (mclass->hasParent(sofa::core::behavior::BaseController::GetClass())) |
181 | | - categories.push_back("Controller"); |
182 | | - if (mclass->hasParent(sofa::core::loader::BaseLoader::GetClass())) |
183 | | - categories.push_back("Loader"); |
184 | | - if (mclass->hasParent(sofa::core::collision::CollisionAlgorithm::GetClass())) |
185 | | - categories.push_back("CollisionAlgorithm"); |
186 | | - if (mclass->hasParent(sofa::core::collision::Pipeline::GetClass())) |
187 | | - categories.push_back("CollisionAlgorithm"); |
188 | | - if (mclass->hasParent(sofa::core::collision::Intersection::GetClass())) |
189 | | - categories.push_back("CollisionAlgorithm"); |
190 | | - if (mclass->hasParent(sofa::core::objectmodel::ConfigurationSetting::GetClass())) |
191 | | - categories.push_back("ConfigurationSetting"); |
192 | | - if (categories.empty()) |
193 | | - categories.push_back("Miscellaneous"); |
194 | | - |
195 | | - py::list list; |
196 | | - for (unsigned int i=0; i<categories.size(); ++i) |
197 | | - list.append(py::cast(categories[i].c_str())) ; |
198 | | - return list; |
| 138 | + const sofa::core::objectmodel::BaseClass* c=self->getClass(); |
| 139 | + sofa::core::CategoryLibrary::getCategories(c, categories); |
| 140 | + py::list l = py::cast(categories); |
| 141 | + return std::move(l); |
199 | 142 | } |
200 | 143 |
|
201 | 144 | std::string getAsACreateObjectParameter(BaseObject *self) |
|
0 commit comments