Test for changed Sketches avoiding TNP

This commit is contained in:
bgbsww
2024-05-01 18:03:00 -04:00
parent 47635c0507
commit f9b65e563d
4 changed files with 93 additions and 95 deletions

View File

@@ -155,11 +155,6 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
return nullptr;
auto linked = sobj->getLinkedObject(true);
auto geo = Base::freecad_dynamic_cast<GeoFeature>(linked);
// if(!geo && linked) {
// auto ext = linked->getExtensionByType<LinkBaseExtension>(true);
// if(ext)
// geo = Base::freecad_dynamic_cast<GeoFeature>(ext->getTrueLinkedObject(true));
// }
#else
auto sobj = obj->getSubObject(subname);
if(!sobj)
@@ -223,13 +218,6 @@ void GeoFeature::updateElementReference() {
auto geo = prop->getComplexData();
if(!geo) return;
bool reset = false;
// auto version = getElementMapVersion(prop);
// if(_ElementMapVersion.getStrValue().empty())
// _ElementMapVersion.setValue(version);
// else if(_ElementMapVersion.getStrValue()!=version) {
// reset = true;
// _ElementMapVersion.setValue(version);
// }
PropertyLinkBase::updateElementReferences(this,reset);
}
@@ -244,35 +232,6 @@ void GeoFeature::onChanged(const Property *prop) {
DocumentObject::onChanged(prop);
}
//void GeoFeature::onDocumentRestored() {
// if(!getDocument()->testStatus(Document::Status::Importing))
// _ElementMapVersion.setValue(getElementMapVersion(getPropertyOfGeometry(),true));
// DocumentObject::onDocumentRestored();
//}
//const std::vector<std::string>&
//GeoFeature::searchElementCache(const std::string &element,
// Data::SearchOptions options,
// double tol,
// double atol) const
//{
// static std::vector<std::string> none;
// (void)element;
// (void)options;
// (void)tol;
// (void)atol;
// return none;
//}
//const std::vector<const char *>&
//GeoFeature::getElementTypes(bool /*all*/) const
//{
// static std::vector<const char *> nil;
// auto prop = getPropertyOfGeometry();
// if (!prop)
// return nil;
// return prop->getComplexData()->getElementTypes();
//}
std::vector<Data::IndexedName>
GeoFeature::getHigherElements(const char *element, bool silent) const

View File

@@ -143,33 +143,10 @@ public:
#ifdef FC_USE_TNP_FIX
static bool hasMissingElement(const char *subname);
/** Search sub element using internal cached geometry
*
* @param element: element name
* @param options: search options
* @param tol: coordinate tolerance
* @param atol: angle tolerance
*
* @return Returns a list of found element reference to the new goemetry.
* The returned value will be invalidated when the geometry is changed.
*
* Before changing the property of geometry, GeoFeature will internally
* make a snapshot of all referenced element geometry. After change, user
* code may call this function to search for the new element name that
* reference to the same geometry of the old element.
*/
// virtual const std::vector<std::string>& searchElementCache(const std::string &element,
// Data::SearchOptions options = Data::SearchOption::CheckGeometry,
// double tol = 1e-7,
// double atol = 1e-10) const;
/// Return the object that owns the shape that contains the give element name
virtual DocumentObject *getElementOwner(const Data::MappedName & /*name*/) const
{return nullptr;}
// virtual const std::vector<const char *>& getElementTypes(bool all=true) const;
/// Return the higher level element names of the given element
virtual std::vector<Data::IndexedName> getHigherElements(const char *name, bool silent=false) const;

View File

@@ -400,36 +400,6 @@ bool PropertyLinkBase::_updateElementReference(DocumentObject *feature,
<< oldName << " -> " << newName);
}
}
// Note: the following code proves to be too risky. There is no way
// (so far) to ensure the recompute do not change the geometry. If
// the geometry does remain the same, the above geometry search
// should be able to find the new reference any way!
#if 0
else if (missing && reverse && shadow.first.size()) {
// reverse means we are trying to either generate the element
// name for the first time, or upgrade to a new map version. In
// case of upgrading, we still consult the original mapped name
// in first try. Here means the first try failed, and the
// geometry search cannot find any match, so we try the
// non-mapped name as a last resort.
//
// WARNING! We are assuming the recomputation is done with no
// actual property change, and the resulting geometry remains
// the same. If this condition is not met, the result may be
// undesirable. TODO: find a way to ensure this condition.
GeoFeature::resolveElement(obj, shadow.second.c_str(), elementName, true,
GeoFeature::ElementNameType::Export,feature);
if(!elementName.second.empty()) {
missing = Data::ComplexGeoData::hasMissingElement(elementName.second.c_str());
if (!missing) {
FC_WARN(propertyName(this)
<< " element reference changed " << ret->getFullName() << " "
<< shadow.first << " -> " << elementName.first);
}
}
}
#endif
}
}