Mod: Use new addObject<T>(...) using regex
This commit is contained in:
@@ -269,8 +269,7 @@ ImportOCAF2::expandShape(App::Document* doc, TDF_Label label, const TopoDS_Shape
|
||||
if (objs.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto compound =
|
||||
static_cast<Part::Compound2*>(doc->addObject("Part::Compound2", "Compound"));
|
||||
auto compound = doc->addObject<Part::Compound2>("Compound");
|
||||
compound->Links.setValues(objs);
|
||||
setPlacement(&compound->Placement, shape);
|
||||
return compound;
|
||||
@@ -382,8 +381,7 @@ bool ImportOCAF2::createObject(App::Document* doc,
|
||||
assert(feature);
|
||||
}
|
||||
else {
|
||||
feature = static_cast<Part::Feature*>(
|
||||
doc->addObject("Part::Feature", tshape.shapeName().c_str()));
|
||||
feature = doc->addObject<Part::Feature>(tshape.shapeName().c_str());
|
||||
feature->Shape.setValue(shape);
|
||||
}
|
||||
applyFaceColors(feature, {info.faceColor});
|
||||
@@ -479,10 +477,10 @@ bool ImportOCAF2::createGroup(App::Document* doc,
|
||||
myCollapsedObjects.emplace(info.obj, info.propPlacement);
|
||||
return true;
|
||||
}
|
||||
auto group = static_cast<App::LinkGroup*>(doc->addObject("App::LinkGroup", "LinkGroup"));
|
||||
auto group = doc->addObject<App::LinkGroup>("LinkGroup");
|
||||
for (auto& child : children) {
|
||||
if (child->getDocument() != doc) {
|
||||
auto link = static_cast<App::Link*>(doc->addObject("App::Link", "Link"));
|
||||
auto link = doc->addObject<App::Link>("Link");
|
||||
link->Label.setValue(child->Label.getValue());
|
||||
link->setLink(-1, child);
|
||||
auto pla = Base::freecad_dynamic_cast<App::PropertyPlacement>(
|
||||
@@ -566,8 +564,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
|
||||
}
|
||||
if (options.merge && ret && !ret->isDerivedFrom<Part::Feature>()) {
|
||||
auto shape = Part::Feature::getTopoShape(ret);
|
||||
auto feature =
|
||||
static_cast<Part::Feature*>(pDocument->addObject("Part::Feature", "Feature"));
|
||||
auto feature = pDocument->addObject<Part::Feature>("Feature");
|
||||
auto name = Tools::labelName(pDoc->Main());
|
||||
feature->Label.setValue(name.empty() ? default_name.c_str() : name.c_str());
|
||||
feature->Shape.setValue(shape);
|
||||
@@ -701,8 +698,7 @@ App::DocumentObject* ImportOCAF2::loadShape(App::Document* doc,
|
||||
auto name = getLabelName(label);
|
||||
if (info.faceColor != it->second.faceColor || info.edgeColor != it->second.edgeColor
|
||||
|| (!name.empty() && !info.baseName.empty() && name != info.baseName)) {
|
||||
auto compound =
|
||||
static_cast<Part::Compound2*>(doc->addObject("Part::Compound2", "Compound"));
|
||||
auto compound = doc->addObject<Part::Compound2>("Compound");
|
||||
compound->Links.setValue(info.obj);
|
||||
info.propPlacement = &compound->Placement;
|
||||
if (info.faceColor != it->second.faceColor) {
|
||||
@@ -719,7 +715,7 @@ App::DocumentObject* ImportOCAF2::loadShape(App::Document* doc,
|
||||
return info.obj;
|
||||
}
|
||||
|
||||
auto link = static_cast<App::Link*>(doc->addObject("App::Link", "Link"));
|
||||
auto link = doc->addObject<App::Link>("Link");
|
||||
link->setLink(-1, info.obj);
|
||||
setPlacement(&link->Placement, shape);
|
||||
info.obj = link;
|
||||
@@ -826,7 +822,7 @@ bool ImportOCAF2::createAssembly(App::Document* _doc,
|
||||
visibilities[i] = true;
|
||||
|
||||
// Okay, we are creating a link array
|
||||
auto link = static_cast<App::Link*>(doc->addObject("App::Link", "Link"));
|
||||
auto link = doc->addObject<App::Link>("Link");
|
||||
link->setLink(-1, child);
|
||||
link->ShowElement.setValue(false);
|
||||
link->ElementCount.setValue(childInfo.plas.size());
|
||||
|
||||
Reference in New Issue
Block a user