Sketcher: External Face: decide between defining and construction (#25390)
This commit is contained in:
@@ -8826,6 +8826,22 @@ void SketchObject::rebuildExternalGeometry(std::optional<ExternalToAdd> extToAdd
|
||||
{
|
||||
Base::StateLocker lock(managedoperation, true); // no need to check input data validity as this is an sketchobject managed operation.
|
||||
|
||||
// Analyze the state of existing external geometries to infer the desired state for new ones.
|
||||
// If any geometry from a source link is "defining", we'll treat the whole link as "defining".
|
||||
std::map<std::string, bool> linkIsDefiningMap;
|
||||
for (const auto& geo : ExternalGeo.getValues()) {
|
||||
auto egf = ExternalGeometryFacade::getFacade(geo);
|
||||
if (!egf->getRef().empty()) {
|
||||
bool isDefining = egf->testFlag(ExternalGeometryExtension::Defining);
|
||||
if (linkIsDefiningMap.find(egf->getRef()) == linkIsDefiningMap.end()) {
|
||||
linkIsDefiningMap[egf->getRef()] = isDefining;
|
||||
}
|
||||
else {
|
||||
linkIsDefiningMap[egf->getRef()] = linkIsDefiningMap[egf->getRef()] && isDefining;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get the actual lists of the externals
|
||||
auto Types = ExternalTypes.getValues();
|
||||
auto Objects = ExternalGeometry.getValues();
|
||||
@@ -9135,10 +9151,20 @@ void SketchObject::rebuildExternalGeometry(std::optional<ExternalToAdd> extToAdd
|
||||
|
||||
// now update the geometries
|
||||
for(auto &geos : newGeos) {
|
||||
if (geos.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the reference key for this group of geometries. All geos in this vector share the same ref.
|
||||
const std::string& key = ExternalGeometryFacade::getFacade(geos.front().get())->getRef();
|
||||
bool isLinkDefining = linkIsDefiningMap.count(key) ? linkIsDefiningMap[key] : false;
|
||||
|
||||
for(auto &geo : geos) {
|
||||
auto it = externalGeoMap.find(GeometryFacade::getId(geo.get()));
|
||||
if(it == externalGeoMap.end()) {
|
||||
// This is a new geometries.
|
||||
// Set its defining state based on the inferred state of its parent link.
|
||||
ExternalGeometryFacade::getFacade(geo.get())->setFlag(ExternalGeometryExtension::Defining, isLinkDefining);
|
||||
geoms.push_back(geo.release());
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user