Move back the assembly util functions to AssemblyUtil (#18020)

* Move back util functions to AssemblyUtils again

* Add getPropertyByName<T>() helper

* Improve constness in AssemblyUtils

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

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Benjamin Nauck
2024-12-02 17:48:48 +01:00
committed by GitHub
parent 94a4727ce9
commit 32e339447a
8 changed files with 859 additions and 975 deletions

View File

@@ -26,9 +26,6 @@
#define ASSEMBLY_AssemblyObject_H
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Mod/Assembly/AssemblyGlobal.h>
#include <App/FeaturePython.h>
@@ -62,6 +59,8 @@ namespace Assembly
class AssemblyLink;
class JointGroup;
class ViewGroup;
enum class JointType;
struct ObjRef
{
@@ -69,72 +68,6 @@ struct ObjRef
App::PropertyXLinkSub* ref;
};
// This enum has to be the same as the one in JointObject.py
enum class JointType
{
Fixed,
Revolute,
Cylindrical,
Slider,
Ball,
Distance,
Parallel,
Perpendicular,
Angle,
RackPinion,
Screw,
Gears,
Belt,
};
enum class DistanceType
{
PointPoint,
LineLine,
LineCircle,
CircleCircle,
PlanePlane,
PlaneCylinder,
PlaneSphere,
PlaneCone,
PlaneTorus,
CylinderCylinder,
CylinderSphere,
CylinderCone,
CylinderTorus,
ConeCone,
ConeTorus,
ConeSphere,
TorusTorus,
TorusSphere,
SphereSphere,
PointPlane,
PointCylinder,
PointSphere,
PointCone,
PointTorus,
LinePlane,
LineCylinder,
LineSphere,
LineCone,
LineTorus,
CurvePlane,
CurveCylinder,
CurveSphere,
CurveCone,
CurveTorus,
PointLine,
PointCurve,
Other,
};
class AssemblyExport AssemblyObject: public App::Part
{
PROPERTY_HEADER_WITH_OVERRIDE(Assembly::AssemblyObject);
@@ -257,42 +190,6 @@ private:
bool bundleFixed;
// void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property
// *prop) override;
public:
// ---------------- Utils -------------------
// Can't put the functions by themselves in AssemblyUtils.cpp :
// see https://forum.freecad.org/viewtopic.php?p=729577#p729577
static void swapJCS(App::DocumentObject* joint);
static bool isEdgeType(App::DocumentObject* obj, std::string& elName, GeomAbs_CurveType type);
static bool isFaceType(App::DocumentObject* obj, std::string& elName, GeomAbs_SurfaceType type);
static double getFaceRadius(App::DocumentObject* obj, std::string& elName);
static double getEdgeRadius(App::DocumentObject* obj, std::string& elName);
static DistanceType getDistanceType(App::DocumentObject* joint);
static JointGroup* getJointGroup(const App::Part* part);
// getters to get from properties
static void setJointActivated(App::DocumentObject* joint, bool val);
static bool getJointActivated(App::DocumentObject* joint);
static double getJointDistance(App::DocumentObject* joint);
static double getJointDistance2(App::DocumentObject* joint);
static JointType getJointType(App::DocumentObject* joint);
static std::string getElementFromProp(App::DocumentObject* obj, const char* propName);
static std::string getElementTypeFromProp(App::DocumentObject* obj, const char* propName);
static App::DocumentObject* getObjFromProp(App::DocumentObject* joint, const char* propName);
static App::DocumentObject* getObjFromRef(App::DocumentObject* obj, std::string& sub);
static App::DocumentObject* getObjFromRef(App::PropertyXLinkSub* prop);
static App::DocumentObject* getObjFromRef(App::DocumentObject* joint, const char* propName);
App::DocumentObject* getMovingPartFromRef(App::DocumentObject* obj, std::string& sub);
App::DocumentObject* getMovingPartFromRef(App::PropertyXLinkSub* prop);
App::DocumentObject* getMovingPartFromRef(App::DocumentObject* joint, const char* propName);
static App::DocumentObject* getLinkedObjFromRef(App::DocumentObject* joint,
const char* propName);
static std::vector<std::string> getSubAsList(App::PropertyXLinkSub* prop);
static std::vector<std::string> getSubAsList(App::DocumentObject* joint, const char* propName);
};
// using AssemblyObjectPython = App::FeaturePythonT<AssemblyObject>;