[Mod] assembly clean
clean code
This commit is contained in:
@@ -159,7 +159,6 @@ void AssemblyLink::onChanged(const App::Property* prop)
|
||||
propPlc->setValue(movePlc);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
App::Part::onChanged(prop);
|
||||
@@ -175,7 +174,6 @@ void AssemblyLink::updateContents()
|
||||
else {
|
||||
synchronizeJoints();
|
||||
}
|
||||
|
||||
purgeTouched();
|
||||
}
|
||||
|
||||
@@ -220,7 +218,6 @@ void AssemblyLink::synchronizeComponents()
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (linkedObj == obj) {
|
||||
found = true;
|
||||
link = obj2;
|
||||
@@ -272,24 +269,6 @@ void AssemblyLink::synchronizeComponents()
|
||||
if (objLinkMap.find(link) != objLinkMap.end()) {
|
||||
doc->removeObject(link->getNameInDocument());
|
||||
}
|
||||
|
||||
/*if (!link->isDerivedFrom<App::Link>() && !link->isDerivedFrom<AssemblyLink>()) {
|
||||
// AssemblyLink should contain only Links or assembly links.
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* linkedObj = link->getLinkedObject(false); // not recursive
|
||||
|
||||
bool found = false;
|
||||
for (auto* obj2 : assemblyGroup) {
|
||||
if (obj2 == linkedObj) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
doc->removeObject(link->getNameInDocument());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,7 +546,6 @@ bool AssemblyLink::isRigid()
|
||||
if (!prop) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return prop->getValue();
|
||||
}
|
||||
|
||||
@@ -578,6 +556,5 @@ std::vector<App::DocumentObject*> AssemblyLink::getJoints()
|
||||
if (!jointGroup) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return jointGroup->getJoints();
|
||||
}
|
||||
|
||||
@@ -158,7 +158,6 @@ int AssemblyObject::solve(bool enableRedo, bool updateJCS)
|
||||
}
|
||||
|
||||
try {
|
||||
// mbdAssembly->runPreDrag(); // solve() is causing some issues with limits.
|
||||
mbdAssembly->runKINEMATIC();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -198,7 +197,6 @@ int AssemblyObject::generateSimulation(App::DocumentObject* sim)
|
||||
|
||||
create_mbdSimulationParameters(sim);
|
||||
|
||||
|
||||
try {
|
||||
mbdAssembly->runKINEMATIC();
|
||||
}
|
||||
@@ -384,7 +382,6 @@ bool AssemblyObject::validateNewPlacements()
|
||||
|
||||
// TODO: We could do further tests
|
||||
// For example check if the joints connectors are correctly aligned.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -593,7 +590,6 @@ App::DocumentObject* AssemblyObject::getJointOfPartConnectingToGround(App::Docum
|
||||
return joint;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -753,7 +749,6 @@ std::vector<App::DocumentObject*> AssemblyObject::getJointsOfPart(App::DocumentO
|
||||
jointsOf.push_back(joint);
|
||||
}
|
||||
}
|
||||
|
||||
return jointsOf;
|
||||
}
|
||||
|
||||
@@ -1804,7 +1799,6 @@ AssemblyObject::MbDPartData AssemblyObject::getMbDData(App::DocumentObject* part
|
||||
|
||||
addConnectedFixedParts(part, addConnectedFixedParts);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1813,7 +1807,6 @@ std::shared_ptr<ASMTPart> AssemblyObject::getMbDPart(App::DocumentObject* part)
|
||||
if (!part) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return getMbDData(part).part;
|
||||
}
|
||||
|
||||
@@ -1831,7 +1824,6 @@ AssemblyObject::makeMbdPart(std::string& name, Base::Placement plc, double mass)
|
||||
|
||||
Base::Vector3d pos = plc.getPosition();
|
||||
mbdPart->setPosition3D(pos.x, pos.y, pos.z);
|
||||
// Base::Console().Warning("MbD Part placement : (%f, %f, %f)\n", pos.x, pos.y, pos.z);
|
||||
|
||||
// TODO : replace with quaternion to simplify
|
||||
Base::Rotation rot = plc.getRotation();
|
||||
|
||||
@@ -200,12 +200,8 @@ private:
|
||||
std::vector<std::pair<App::DocumentObject*, Base::Placement>> previousPositions;
|
||||
|
||||
bool bundleFixed;
|
||||
// void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property
|
||||
// *prop) override;
|
||||
};
|
||||
|
||||
// using AssemblyObjectPython = App::FeaturePythonT<AssemblyObject>;
|
||||
|
||||
} // namespace Assembly
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,8 @@
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
// #include <App/DocumentObjectGroup.h>
|
||||
#include <App/Link.h>
|
||||
// #include <Base/Console.h>
|
||||
|
||||
#include <Base/Placement.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Interpreter.h>
|
||||
@@ -695,7 +694,6 @@ App::DocumentObject* getMovingPartFromRef(const AssemblyObject* assemblyObject,
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -715,7 +713,6 @@ App::DocumentObject* getMovingPartFromRef(const AssemblyObject* assemblyObject,
|
||||
if (subs.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return getMovingPartFromRef(assemblyObject, obj, subs[0]);
|
||||
}
|
||||
|
||||
@@ -731,102 +728,5 @@ App::DocumentObject* getMovingPartFromRef(const AssemblyObject* assemblyObject,
|
||||
return getMovingPartFromRef(assemblyObject, prop);
|
||||
}
|
||||
|
||||
/*
|
||||
Base::Placement getPlacementFromProp(App::DocumentObject* obj, const char* propName)
|
||||
{
|
||||
Base::Placement plc = Base::Placement();
|
||||
auto* propPlacement = dynamic_cast<App::PropertyPlacement*>(obj->getPropertyByName(propName));
|
||||
if (propPlacement) {
|
||||
plc = propPlacement->getValue();
|
||||
}
|
||||
return plc;
|
||||
}
|
||||
|
||||
// Currently unused
|
||||
Base::Placement* getTargetPlacementRelativeTo(
|
||||
App::DocumentObject* targetObj, App::DocumentObject* part, App::DocumentObject* container,
|
||||
bool inContainerBranch, bool ignorePlacement = false)
|
||||
{
|
||||
inContainerBranch = inContainerBranch || (!ignorePlacement && part == container);
|
||||
|
||||
Base::Console().Warning("sub --------------\n");
|
||||
if (targetObj == part && inContainerBranch && !ignorePlacement) {
|
||||
Base::Console().Warning("found0\n");
|
||||
return &getPlacementFromProp(targetObj, "Placement");
|
||||
}
|
||||
|
||||
if (auto group = dynamic_cast<App::DocumentObjectGroup*>(part)) {
|
||||
for (auto& obj : group->getOutList()) {
|
||||
auto foundPlacement = getTargetPlacementRelativeTo(
|
||||
targetObj, obj, container, inContainerBranch, ignorePlacement
|
||||
);
|
||||
if (foundPlacement != nullptr) {
|
||||
return foundPlacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (auto assembly = dynamic_cast<AssemblyObject*>(part)) {
|
||||
Base::Console().Warning("h3\n");
|
||||
for (auto& obj : assembly->getOutList()) {
|
||||
auto foundPlacement = getTargetPlacementRelativeTo(
|
||||
targetObj, obj, container, inContainerBranch
|
||||
);
|
||||
if (foundPlacement == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ignorePlacement) {
|
||||
*foundPlacement = getPlacementFromProp(part, "Placement") * *foundPlacement;
|
||||
}
|
||||
|
||||
Base::Console().Warning("found\n");
|
||||
return foundPlacement;
|
||||
}
|
||||
}
|
||||
else if (auto link = dynamic_cast<App::Link*>(part)) {
|
||||
Base::Console().Warning("h4\n");
|
||||
auto linked_obj = link->getLinkedObject();
|
||||
|
||||
if (dynamic_cast<App::Part*>(linked_obj) || dynamic_cast<AssemblyObject*>(linked_obj)) {
|
||||
for (auto& obj : linked_obj->getOutList()) {
|
||||
auto foundPlacement = getTargetPlacementRelativeTo(
|
||||
targetObj, obj, container, inContainerBranch
|
||||
);
|
||||
if (foundPlacement == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*foundPlacement = getPlacementFromProp(link, "Placement") * *foundPlacement;
|
||||
return foundPlacement;
|
||||
}
|
||||
}
|
||||
|
||||
auto foundPlacement = getTargetPlacementRelativeTo(
|
||||
targetObj, linked_obj, container, inContainerBranch, true
|
||||
);
|
||||
|
||||
if (foundPlacement != nullptr && !ignorePlacement) {
|
||||
*foundPlacement = getPlacementFromProp(link, "Placement") * *foundPlacement;
|
||||
}
|
||||
|
||||
Base::Console().Warning("found2\n");
|
||||
return foundPlacement;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Placement getGlobalPlacement(App::DocumentObject* targetObj, App::DocumentObject* container =
|
||||
nullptr) { bool inContainerBranch = container == nullptr; auto rootObjects =
|
||||
App::GetApplication().getActiveDocument()->getRootObjects(); for (auto& part : rootObjects) { auto
|
||||
foundPlacement = getTargetPlacementRelativeTo(targetObj, part, container, inContainerBranch); if
|
||||
(foundPlacement != nullptr) { Base::Placement plc(foundPlacement->toMatrix()); return plc;
|
||||
}
|
||||
}
|
||||
|
||||
return Base::Placement();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
} // namespace Assembly
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#ifndef ASSEMBLY_AssemblyUtils_H
|
||||
#define ASSEMBLY_AssemblyUtils_H
|
||||
|
||||
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user