TopoShape/Part: Bring in FeatureDressup

This commit is contained in:
Zheng, Lei
2024-04-11 10:21:32 -04:00
committed by bgbsww
parent 9991c430d2
commit 7bc2b3688a

View File

@@ -231,7 +231,11 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap
baseShape.move(base->getLocation().Inverted());
if (base->getAddSubType() == Additive) {
if(!baseShape.isNull() && baseShape.hasSubShape(TopAbs_SOLID))
#ifdef FC_USE_TNP_FIX
shapes.emplace_back(shape.makeElementCut(baseShape.getShape()));
#else
shapes.emplace_back(shape.cut(baseShape.getShape()));
#endif
else
shapes.push_back(shape);
} else {
@@ -241,22 +245,35 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap
// push an empty compound to indicate null additive shape
shapes.emplace_back(comp);
if(!baseShape.isNull() && baseShape.hasSubShape(TopAbs_SOLID))
#ifdef FC_USE_TNP_FIX
shapes.emplace_back(baseShape.makeElementCut(shape.getShape()));
#else
shapes.emplace_back(baseShape.cut(shape.getShape()));
#endif
else
shapes.push_back(shape);
}
} else {
baseShape = getBaseTopoShape();
baseShape.move(getLocation().Inverted());
#ifdef FC_USE_TNP_FIX
shapes.emplace_back(shape.makeElementCut(baseShape.getShape()));
shapes.emplace_back(baseShape.makeElementCut(shape.getShape()));
#else
shapes.emplace_back(shape.cut(baseShape.getShape()));
shapes.emplace_back(baseShape.cut(shape.getShape()));
#endif
}
// Make a compound to contain both additive and subtractive shape,
// bceause a dressing (e.g. a fillet) can either be additive or
// subtractive. And the dressup feature can contain mixture of both.
AddSubShape.setValue(Part::TopoShape().makeCompound(shapes));
#ifdef FC_USE_TNP_FIX
AddSubShape.setValue(Part::TopoShape().makeElementCompound(shapes));
#else
AddSubShape.setValue(Part::TopoShape().makeCompound(shapes));
#endif
} catch (Standard_Failure &e) {
FC_THROWM(Base::CADKernelError, "Failed to calculate AddSub shape: "
<< e.GetMessageString());
@@ -274,12 +291,12 @@ void DressUp::getAddSubShape(Part::TopoShape &addShape, Part::TopoShape &subShap
if(!count)
throw Part::NullShapeException("Null AddSub shape");
if(count) {
Part::TopoShape s = res.getSubShape(TopAbs_SHAPE, 1);
Part::TopoShape s = res.getSubTopoShape(TopAbs_SHAPE, 1);
if(!s.isNull() && s.hasSubShape(TopAbs_SOLID))
addShape = s;
}
if(count > 1) {
Part::TopoShape s = res.getSubShape(TopAbs_SHAPE, 2);
Part::TopoShape s = res.getSubTopoShape(TopAbs_SHAPE, 2);
if(!s.isNull() && s.hasSubShape(TopAbs_SOLID))
subShape = s;
}