Toposhape/Part:: Fix, relocate and test element methods in ComplexGeoData and TopoShape

This commit is contained in:
bgbsww
2024-02-28 15:56:45 -05:00
parent ae5c0a6d9c
commit 3df25821e5
9 changed files with 691 additions and 336 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -76,7 +76,10 @@ public:
const char *name, bool recursive=true, bool sameType=false);
static QVector<Data::MappedElement>
getRelatedElements(App::DocumentObject *obj, const char *name, bool sameType=true, bool withCache=true);
getRelatedElements(App::DocumentObject* obj,
const char* name,
HistoryTraceType sameType = HistoryTraceType::followTypeChange,
bool withCache = true);
/** Obtain the element name from a feature based of the element name of its source feature
*
@@ -143,6 +146,8 @@ public:
static Feature*
create(const TopoShape& shape, const char* name = nullptr, App::Document* document = nullptr);
static bool isElementMappingDisabled(App::PropertyContainer *container);
protected:
/// recompute only this object
App::DocumentObjectExecReturn *recompute() override;

View File

@@ -50,6 +50,7 @@
#include "PartPyCXX.h"
#include "PropertyTopoShape.h"
#include "TopoShapePy.h"
#include "PartFeature.h"
FC_LOG_LEVEL_INIT("App", true, true)
@@ -103,14 +104,15 @@ TopoShape PropertyPartShape::getShape() const
{
_Shape.initCache(-1);
auto res = _Shape;
// March, 2024 Toponaming project: There was originally an unused feature to disable elementMapping
// that has not been kept:
// March, 2024 Toponaming project: There was originally an unused feature to disable
// elementMapping that has not been kept:
// if (Feature::isElementMappingDisabled(getContainer()))
if ( false )
res.Tag = -1;
else if (!res.Tag) {
if (auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer()))
// res.Tag = -1;
// else if (!res.Tag) {
if (!res.Tag) {
if (auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer())) {
res.Tag = parent->getID();
}
}
return res;
}

View File

@@ -107,6 +107,7 @@ using namespace Part;
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
#ifdef FC_USE_TNP_FIX
static Py_hash_t _TopoShapeHash(PyObject *self) {
if (!self) {
PyErr_SetString(PyExc_TypeError, "descriptor 'hash' of 'Part.TopoShape' object needs an argument");
@@ -124,6 +125,7 @@ struct TopoShapePyInit {
TopoShapePy::Type.tp_hash = _TopoShapeHash;
}
} _TopoShapePyInit;
#endif
// returns a string which represents the object e.g. when printed in python
std::string TopoShapePy::representation() const