Part/Toponaming: Transfer PartFeature Feature::create()

* Imported Feature::create() method in Part::Feature class
This commit is contained in:
Zheng, Lei
2024-03-02 09:41:36 +01:00
committed by CalligaroV
parent d4762cd828
commit d82fe1564f
2 changed files with 20 additions and 0 deletions

View File

@@ -536,6 +536,23 @@ TopLoc_Location Feature::getLocation() const
return TopLoc_Location(trf);
}
Feature* Feature::create(const TopoShape& shape, const char* name, App::Document* document)
{
if (!name || !name[0]) {
name = "Shape";
}
if (!document) {
document = App::GetApplication().getActiveDocument();
if (!document) {
document = App::GetApplication().newDocument();
}
}
auto res = static_cast<Part::Feature*>(document->addObject("Part::Feature", name));
res->Shape.setValue(shape);
res->purgeTouched();
return res;
}
ShapeHistory Feature::buildHistory(BRepBuilderAPI_MakeShape& mkShape, TopAbs_ShapeEnum type,
const TopoDS_Shape& newS, const TopoDS_Shape& oldS)
{

View File

@@ -110,6 +110,9 @@ public:
return owner && owner->isDerivedFrom(getClassTypeId());
}
static Feature*
create(const TopoShape& shape, const char* name = nullptr, App::Document* document = nullptr);
protected:
/// recompute only this object
App::DocumentObjectExecReturn *recompute() override;