App/Toponaming: import SubObjectT dependencies for SubShapeBinder

* Fixed a mistake made in getSubObjectListFlatten()
 * Applied modifications according to review comments

Signed-off-by: CalligaroV <vincenzo.calligaro@gmail.com>
This commit is contained in:
CalligaroV
2024-04-23 10:22:12 +02:00
committed by Chris Hennes
parent 3109301e52
commit 767b2bd5e4
6 changed files with 179 additions and 53 deletions

View File

@@ -899,10 +899,10 @@ getSubObjectListFlatten(const std::vector<App::DocumentObject*>& resNotFlatten,
{
auto res {resNotFlatten};
auto linked = sobj->getLinkedObject();
if (container) {
if (*container) {
auto grp = App::GeoFeatureGroupExtension::getGroupOfObject(linked);
if (grp != *container) {
container = nullptr;
*container = nullptr;
}
else {
if (lastChild && !res.empty()) {
@@ -920,12 +920,12 @@ getSubObjectListFlatten(const std::vector<App::DocumentObject*>& resNotFlatten,
}
else if (linked != sobj || sobj->hasChildElement()) {
// Check for Link or LinkGroup
container = nullptr;
*container = nullptr;
}
else if (auto ext = sobj->getExtensionByType<LinkBaseExtension>(true)) {
// check for Link array
if (ext->getElementCountValue() != 0) {
container = nullptr;
*container = nullptr;
}
}
return res;
@@ -941,7 +941,7 @@ std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char* subnam
if (subsizes) {
subsizes->push_back(0);
}
if (!subname || (subname[0] == 0)) {
if (!subname || (subname[0] == '\0')) {
return res;
}
auto element = Data::findElementName(subname);
@@ -961,7 +961,7 @@ std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char* subnam
}
for (auto pos = sub.find('.'); pos != std::string::npos; pos = sub.find('.', pos + 1)) {
char subTail = sub[pos + 1];
sub[pos + 1] = 0;
sub[pos + 1] = '\0';
auto sobj = getSubObject(sub.c_str());
if (!sobj || !sobj->isAttachedToDocument()) {
continue;

View File

@@ -384,7 +384,7 @@ public:
* @param flatten: whether to flatten the object hierarchies that belong to
* the same geo feature group, e.g. (Part.Fusion.Box -> Part.Box)
*
* @return Return a list of object along the path.
* @return Return a list of objects along the path.
*/
std::vector<DocumentObject*> getSubObjectList(const char* subname,
std::vector<int>* subsizes = nullptr,

View File

@@ -348,7 +348,7 @@ bool normalizeConvertIndex(const std::vector<App::DocumentObject*>& objs, const
{
if (auto ext = objs[idx - 1]->getExtensionByType<App::LinkBaseExtension>(true)) {
if ((ext->getElementCountValue() != 0) && !ext->getShowElementValue()) {
// if the parent is a collapsed link array element, then we
// If the parent is a collapsed link array element, then we
// have to keep the index no matter what, because there is
// no sub-object corresponding to an array element.
return true;
@@ -376,7 +376,7 @@ bool SubObjectT::normalize(NormalizeOptions options)
return false;
}
for (unsigned i = 1; i < objs.size(); ++i) {
// Keep digit only subname, as it maybe an index to an array, which does
// Keep digit-only subname, as it maybe an index to an array, which does
// not expand its elements as objects.
const char* end = subname.c_str() + subs[i];
const char* sub = end - 2;
@@ -391,7 +391,7 @@ bool SubObjectT::normalize(NormalizeOptions options)
}
}
bool _keepSub {};
if (std::isdigit(sub[0]) == 0) {
if (!std::isdigit(sub[0])) {
_keepSub = keepSub;
}
else if (!convertIndex) {
@@ -454,7 +454,7 @@ bool SubObjectT::hasSubObject() const
bool SubObjectT::hasSubElement() const
{
auto element = getElementName();
return (element != nullptr) && (element[0] != 0);
return element && (element[0] != '\0');
}
std::string SubObjectT::getNewElementName() const {

View File

@@ -256,12 +256,14 @@ public:
{
/// Do not include sub-element reference in the output path
NoElement = 0x01,
/** Do not flatten the output path. If not specified, the output path
* will be flatten to exclude intermediate objects that belong to the
* same geo feature group before resolving. For example,
* Part.Fusion.Box. -> Part.Box.
*/
NoFlatten = 0x02,
/** Do not change the sub-object component inside the path. Each
* component of the subname object path can be either the object
* internal name, the label of the object if starts with '$', or an
@@ -269,6 +271,7 @@ public:
* be converted to object internal name, except for integer index.
*/
KeepSubName = 0x04,
/** Convert integer index in the path to sub-object internal name */
ConvertIndex = 0x08,
};