Part:Improve support for Links

This commit is contained in:
mwganson
2022-02-28 00:46:10 -06:00
committed by Uwe
parent db2236fe22
commit 929c89f700
10 changed files with 379 additions and 241 deletions

View File

@@ -46,6 +46,7 @@
#include "PartFeatures.h"
#include <App/Link.h>
using namespace Part;
@@ -82,20 +83,21 @@ App::DocumentObjectExecReturn* RuledSurface::getShape(const App::PropertyLinkSub
TopoDS_Shape& shape) const
{
App::DocumentObject* obj = link.getValue();
if (!(obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
const Part::TopoShape part = Part::Feature::getShape(obj, "", false, 0, 0, true, false);
if (part.isNull()) {
return new App::DocumentObjectExecReturn("No shape linked.");
}
// if no explicit sub-shape is selected use the whole part
const std::vector<std::string>& element = link.getSubValues();
if (element.empty()) {
shape = static_cast<Part::Feature*>(obj)->Shape.getValue();
shape = part.getShape();
return nullptr;
}
else if (element.size() != 1) {
return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked.");
}
const Part::TopoShape& part = static_cast<Part::Feature*>(obj)->Shape.getValue();
if (!part.getShape().IsNull()) {
if (!element[0].empty()) {
shape = part.getSubShape(element[0].c_str());