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

@@ -1217,16 +1217,69 @@ FilletBase::FilletBase()
{
ADD_PROPERTY(Base,(nullptr));
ADD_PROPERTY(Edges,(0,0,0));
ADD_PROPERTY_TYPE(EdgeLinks,(0), 0,
(App::PropertyType)(App::Prop_ReadOnly|App::Prop_Hidden),0);
Edges.setSize(0);
}
short FilletBase::mustExecute() const
{
if (Base.isTouched() || Edges.isTouched())
if (Base.isTouched() || Edges.isTouched() || EdgeLinks.isTouched())
return 1;
return 0;
}
void FilletBase::onChanged(const App::Property *prop) {
if(getDocument() && !getDocument()->testStatus(App::Document::Restoring)) {
if(prop == &Edges || prop == &Base) {
if(!prop->testStatus(App::Property::User3))
syncEdgeLink();
}
}
Feature::onChanged(prop);
}
void FilletBase::onDocumentRestored() {
if(EdgeLinks.getSubValues().empty())
syncEdgeLink();
Feature::onDocumentRestored();
}
void FilletBase::syncEdgeLink() {
if(!Base.getValue() || !Edges.getSize()) {
EdgeLinks.setValue(0);
return;
}
std::vector<std::string> subs;
std::string sub("Edge");
for(auto &info : Edges.getValues())
subs.emplace_back(sub+std::to_string(info.edgeid));
EdgeLinks.setValue(Base.getValue(),subs);
}
void FilletBase::onUpdateElementReference(const App::Property *prop) {
if(prop!=&EdgeLinks || !getNameInDocument())
return;
auto values = Edges.getValues();
const auto &subs = EdgeLinks.getSubValues();
for(size_t i=0;i<values.size();++i) {
if(i>=subs.size()) {
FC_WARN("fillet edge count mismatch in object " << getFullName());
break;
}
int idx = 0;
sscanf(subs[i].c_str(),"Edge%d",&idx);
if(idx)
values[i].edgeid = idx;
else
FC_WARN("invalid fillet edge link '" << subs[i] << "' in object "
<< getFullName());
}
Edges.setStatus(App::Property::User3,true);
Edges.setValues(values);
Edges.setStatus(App::Property::User3,false);
}
// ---------------------------------------------------------
PROPERTY_SOURCE(Part::FeatureExt, Part::Feature)