Toponaming: Missing suppress property and code
This commit is contained in:
@@ -1438,6 +1438,8 @@ public:
|
||||
const char* marker = nullptr,
|
||||
std::string* postfix = nullptr) const;
|
||||
|
||||
long isElementGenerated(const Data::MappedName &name, int depth=1) const;
|
||||
|
||||
/** @name sub shape cached functions
|
||||
*
|
||||
* Mapped element names introduces some overhead when getting sub shapes
|
||||
|
||||
@@ -5756,6 +5756,32 @@ bool TopoShape::isSame(const Data::ComplexGeoData& _other) const
|
||||
const auto& other = static_cast<const TopoShape&>(_other);
|
||||
return Tag == other.Tag && Hasher == other.Hasher && _Shape.IsEqual(other._Shape);
|
||||
}
|
||||
|
||||
long TopoShape::isElementGenerated(const Data::MappedName& _name, int depth) const
|
||||
{
|
||||
long res = 0;
|
||||
long tag = 0;
|
||||
traceElement(_name, [&](const Data::MappedName& name, int offset, long tag2, long) {
|
||||
(void)offset;
|
||||
if (tag2 < 0) {
|
||||
tag2 = -tag2;
|
||||
}
|
||||
if (tag && tag2 != tag) {
|
||||
if (--depth < 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
tag = tag2;
|
||||
if (depth == 1 && name.startsWith(genPostfix(), offset)) {
|
||||
res = tag;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void TopoShape::cacheRelatedElements(const Data::MappedName& name,
|
||||
HistoryTraceType sameType,
|
||||
const QVector<Data::MappedElement>& names) const
|
||||
|
||||
@@ -57,6 +57,7 @@ Feature::Feature()
|
||||
ADD_PROPERTY(BaseFeature,(nullptr));
|
||||
ADD_PROPERTY_TYPE(_Body,(nullptr),"Base",(App::PropertyType)(
|
||||
App::Prop_ReadOnly|App::Prop_Hidden|App::Prop_Output|App::Prop_Transient),0);
|
||||
ADD_PROPERTY(SuppressedShape,(TopoShape()));
|
||||
Placement.setStatus(App::Property::Hidden, true);
|
||||
BaseFeature.setStatus(App::Property::Hidden, true);
|
||||
|
||||
@@ -68,6 +69,37 @@ Feature::Feature()
|
||||
|
||||
App::DocumentObjectExecReturn* Feature::recompute()
|
||||
{
|
||||
#ifdef FC_USE_TNP_FIX
|
||||
SuppressedShape.setValue(TopoShape());
|
||||
|
||||
if (!Suppressed.getValue()) {
|
||||
return Part::Feature::recompute();
|
||||
}
|
||||
|
||||
bool failed = false;
|
||||
try {
|
||||
std::unique_ptr<App::DocumentObjectExecReturn> ret(Part::Feature::recompute());
|
||||
if (ret) {
|
||||
throw Base::RuntimeError(ret->Why);
|
||||
}
|
||||
}
|
||||
catch (Base::AbortException&) {
|
||||
throw;
|
||||
}
|
||||
catch (Base::Exception& e) {
|
||||
failed = true;
|
||||
e.ReportException();
|
||||
FC_ERR("Failed to recompute suppressed feature " << getFullName());
|
||||
}
|
||||
|
||||
if (!failed) {
|
||||
updateSuppressedShape();
|
||||
}
|
||||
else {
|
||||
Shape.setValue(getBaseTopoShape(true));
|
||||
}
|
||||
return App::DocumentObject::StdReturn;
|
||||
#else
|
||||
try {
|
||||
auto baseShape = getBaseTopoShape();
|
||||
if (Suppressed.getValue()) {
|
||||
@@ -81,6 +113,31 @@ App::DocumentObjectExecReturn* Feature::recompute()
|
||||
}
|
||||
|
||||
return DocumentObject::recompute();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Feature::updateSuppressedShape()
|
||||
{
|
||||
auto baseShape = getBaseTopoShape(true);
|
||||
TopoShape res(getID());
|
||||
TopoShape shape = Shape.getShape();
|
||||
shape.setPlacement(Base::Placement());
|
||||
std::vector<TopoShape> generated;
|
||||
if(!shape.isNull()) {
|
||||
unsigned count = shape.countSubShapes(TopAbs_FACE);
|
||||
for(unsigned i=1; i<=count; ++i) {
|
||||
Data::MappedName mapped = shape.getMappedName(
|
||||
Data::IndexedName::fromConst("Face", i));
|
||||
if(mapped && shape.isElementGenerated(mapped))
|
||||
generated.push_back(shape.getSubTopoShape(TopAbs_FACE, i));
|
||||
}
|
||||
}
|
||||
if(!generated.empty()) {
|
||||
res.makeElementCompound(generated);
|
||||
res.setPlacement(Placement.getValue());
|
||||
}
|
||||
Shape.setValue(baseShape);
|
||||
SuppressedShape.setValue(res);
|
||||
}
|
||||
|
||||
short Feature::mustExecute() const
|
||||
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
App::PropertyLink BaseFeature;
|
||||
App::PropertyLinkHidden _Body;
|
||||
|
||||
/// Keep a copy of suppressed shapes so that we can restore them (and maybe display them)
|
||||
Part::PropertyPartShape SuppressedShape;
|
||||
App::DocumentObjectExecReturn* recompute() override;
|
||||
|
||||
short mustExecute() const override;
|
||||
@@ -108,6 +110,8 @@ protected:
|
||||
bool isSingleSolidRuleSatisfied(const TopoDS_Shape&, TopAbs_ShapeEnum type = TopAbs_SOLID);
|
||||
SingleSolidRuleMode singleSolidRuleMode();
|
||||
|
||||
void updateSuppressedShape();
|
||||
|
||||
/// Grab any point from the given face
|
||||
static const gp_Pnt getPointFromFace(const TopoDS_Face& f);
|
||||
/// Make a shape from a base plane (convenience method)
|
||||
|
||||
Reference in New Issue
Block a user