Toposhape/Part: Transfer in FeatureFillet, FeatureChamfer and dependencies

This commit is contained in:
Zheng, Lei
2024-02-26 15:52:22 -05:00
committed by bgbsww
parent 9209331e59
commit 5da174f46e
6 changed files with 313 additions and 3 deletions

View File

@@ -592,6 +592,16 @@ void DlgFilletEdges::setupFillet(const std::vector<App::DocumentObject*>& objs)
{
App::DocumentObject* base = d->fillet->Base.getValue();
const std::vector<Part::FilletElement>& e = d->fillet->Edges.getValues();
const auto &subs = d->fillet->EdgeLinks.getShadowSubs();
if(subs.size()!=e.size()) {
FC_ERR("edge link size mismatch");
return;
}
std::set<std::string> subSet;
for(auto &sub : subs)
subSet.insert(sub.first.empty()?sub.second:sub.first);
std::string tmp;
std::vector<App::DocumentObject*>::const_iterator it = std::find(objs.begin(), objs.end(), base);
if (it != objs.end()) {
// toggle visibility
@@ -613,6 +623,40 @@ void DlgFilletEdges::setupFillet(const std::vector<App::DocumentObject*>& objs)
std::vector<std::string> subElements;
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
bool block = model->blockSignals(true); // do not call toggleCheckState
auto baseShape = Part::Feature::getTopoShape(base);
std::set<Part::FilletElement> elements;
for(size_t i=0;i<e.size();++i) {
auto &sub = subs[i];
if(sub.first.empty()) {
int idx = 0;
sscanf(sub.second.c_str(),"Edge%d",&idx);
if(idx==0)
FC_WARN("missing element reference: " << sub.second);
else
elements.insert(e[i]);
continue;
}
auto &ref = sub.first;
Part::TopoShape edge;
try {
edge = baseShape.getSubShape(ref.c_str());
}catch(...) {}
if(!edge.isNull()) {
elements.insert(e[i]);
continue;
}
FC_WARN("missing element reference: " << base->getFullName() << "." << ref);
for(auto &mapped : Part::Feature::getRelatedElements(base,ref.c_str())) {
tmp.clear();
if(!subSet.insert(mapped.index.toString(tmp)).second
|| !subSet.insert(mapped.name.toString(0)).second)
continue;
FC_WARN("guess element reference: " << ref << " -> " << mapped.index);
elements.emplace(mapped.index.getIndex(),e[i].radius1,e[i].radius2);
}
}
for (const auto & et : e) {
std::vector<int>::iterator it = std::find(d->edge_ids.begin(), d->edge_ids.end(), et.edgeid);
if (it != d->edge_ids.end()) {