Fem: Move functions to Tools class

This commit is contained in:
marioalexis
2024-05-29 00:36:04 -03:00
parent 047b184df4
commit 25febcd7af
5 changed files with 144 additions and 93 deletions

View File

@@ -32,7 +32,7 @@
#include <Mod/Part/App/PartFeature.h>
#include "FemConstraintBearing.h"
#include "FemTools.h"
using namespace Fem;
@@ -74,9 +74,17 @@ void ConstraintBearing::onChanged(const App::Property* prop)
if (prop == &References) {
// Find data of cylinder
std::vector<App::DocumentObject*> ref = References.getValues();
std::vector<std::string> subRef = References.getSubValues();
if (ref.empty()) {
return;
}
Part::Feature* feat = static_cast<Part::Feature*>(ref.front());
TopoDS_Shape sh = Tools::getFeatureSubShape(feat, subRef.front().c_str(), true);
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis)) {
if (!Tools::getCylinderParams(sh, base, axis, height, radius)) {
return;
}
Radius.setValue(radius);
@@ -113,12 +121,19 @@ void ConstraintBearing::onChanged(const App::Property* prop)
}
}
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis)) {
std::vector<App::DocumentObject*> ref = References.getValues();
std::vector<std::string> subRef = References.getSubValues();
if (ref.empty()) {
return;
}
feat = static_cast<Part::Feature*>(ref.front());
sh = Tools::getFeatureSubShape(feat, subRef.front().c_str(), true);
double radius, height;
Base::Vector3d base, axis;
if (!Tools::getCylinderParams(sh, base, axis, height, radius)) {
return;
}
base = getBasePoint(base + axis * height / 2, axis, Location, Dist.getValue());
BasePoint.setValue(base);
BasePoint.touch();
}