Assembly: Solver messages (#24623)

* Assembly: Solver messages

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update ViewProviderAssembly.cpp

* Update src/Mod/Assembly/App/AssemblyUtils.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Update src/Mod/Assembly/App/AssemblyUtils.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Update src/Mod/Assembly/App/AssemblyUtils.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Update src/Mod/Assembly/Gui/Commands.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Update ViewProviderAssembly.cpp

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update src/Mod/Assembly/Gui/TaskAssemblyMessages.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Update AssemblyObject.h

* Update AssemblyObject.cpp

* Update Commands.cpp

* Update ViewProviderAssembly.cpp

* Update AssemblyObject.cpp

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Thank you

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kacper Donat <kadet1090@gmail.com>
This commit is contained in:
PaddleStroke
2026-01-22 15:21:13 +01:00
committed by GitHub
parent 54d235f8a5
commit bb6832897a
13 changed files with 552 additions and 101 deletions

View File

@@ -756,5 +756,67 @@ void syncPlacements(App::DocumentObject* src, App::DocumentObject* to)
}
}
}
namespace
{
// Helper function to perform the recursive traversal. Kept in an anonymous
// namespace as it's an implementation detail of getAssemblyComponents.
void collectComponentsRecursively(
const std::vector<App::DocumentObject*>& objects,
std::vector<App::DocumentObject*>& results
)
{
for (auto* obj : objects) {
if (!obj) {
continue;
}
if (auto* asmLink = freecad_cast<Assembly::AssemblyLink*>(obj)) {
// If the sub-assembly is rigid, treat it as a single movable part.
// If it's flexible, we need to check its individual components.
if (asmLink->isRigid()) {
results.push_back(asmLink);
}
else {
collectComponentsRecursively(asmLink->Group.getValues(), results);
}
continue;
}
else if (obj->isLinkGroup()) {
auto* linkGroup = static_cast<App::Link*>(obj);
for (auto* elt : linkGroup->ElementList.getValues()) {
results.push_back(elt);
}
continue;
}
else if (auto* group = freecad_cast<App::DocumentObjectGroup*>(obj)) {
collectComponentsRecursively(group->Group.getValues(), results);
continue;
}
else if (auto* link = freecad_cast<App::Link*>(obj)) {
obj = link->getLinkedObject();
if (obj->isDerivedFrom<App::GeoFeature>()
&& !obj->isDerivedFrom<App::LocalCoordinateSystem>()) {
results.push_back(link);
}
}
else if (obj->isDerivedFrom<App::GeoFeature>()
&& !obj->isDerivedFrom<App::LocalCoordinateSystem>()) {
results.push_back(obj);
}
}
}
} // namespace
std::vector<App::DocumentObject*> getAssemblyComponents(const AssemblyObject* assembly)
{
if (!assembly) {
return {};
}
std::vector<App::DocumentObject*> components;
collectComponentsRecursively(assembly->Group.getValues(), components);
return components;
}
} // namespace Assembly