From 2a541c9536f8ec29f7525a41e89a354f28bc8e0a Mon Sep 17 00:00:00 2001 From: bgbsww Date: Wed, 28 Aug 2024 08:07:43 -0400 Subject: [PATCH] Toponaming: Remove remaining FC_USE_TNP_FIX defines --- .../SetGlobalCompilerAndLinkerSettings.cmake | 3 - src/App/ElementNamingUtils.cpp | 2 - src/Gui/SoFCUnifiedSelection.cpp | 4 - src/Gui/View3DInventorSelection.cpp | 2 - src/Mod/Part/App/Attacher.cpp | 73 ----------- src/Mod/Part/App/PropertyTopoShape.cpp | 34 ----- src/Mod/Part/App/PropertyTopoShapeList.cpp | 28 ----- src/Mod/Part/App/TopoShape.cpp | 56 +-------- src/Mod/Part/App/TopoShapeExpansion.cpp | 39 ------ src/Mod/PartDesign/App/Feature.cpp | 38 ------ src/Mod/PartDesign/App/Feature.h | 4 - src/Mod/PartDesign/App/FeatureAddSub.cpp | 21 ---- src/Mod/PartDesign/App/FeatureAddSub.h | 4 - src/Mod/PartDesign/App/FeatureBoolean.cpp | 25 ---- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 14 --- src/Mod/PartDesign/App/ShapeBinder.cpp | 2 - .../PartDesign/Gui/TaskDressUpParameters.cpp | 23 ---- src/Mod/Sketcher/App/SketchObject.cpp | 119 +----------------- tests/CMakeLists.txt | 2 - 19 files changed, 2 insertions(+), 491 deletions(-) diff --git a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake index 12b4a784c05d..44a9dd2b4e34 100644 --- a/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake +++ b/cMake/FreeCAD_Helpers/SetGlobalCompilerAndLinkerSettings.cmake @@ -91,7 +91,4 @@ macro(SetGlobalCompilerAndLinkerSettings) endif() endif(MINGW) - # Enable the Topological Naming Problem mitigation code - add_compile_options(-DFC_USE_TNP_FIX) - endmacro(SetGlobalCompilerAndLinkerSettings) diff --git a/src/App/ElementNamingUtils.cpp b/src/App/ElementNamingUtils.cpp index 5810cdc10244..2b6e59d4d897 100644 --- a/src/App/ElementNamingUtils.cpp +++ b/src/App/ElementNamingUtils.cpp @@ -56,11 +56,9 @@ std::string Data::noElementName(const char *name) { } const char *Data::findElementName(const char *subname) { -#ifdef FC_USE_TNP_FIX // skip leading dots while(subname && subname[0] == '.') ++subname; -#endif if(!subname || !subname[0] || isMappedElement(subname)) return subname; const char *dot = strrchr(subname,'.'); diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index a509012e0719..da5b44abcc2c 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -398,14 +398,12 @@ void SoFCUnifiedSelection::doAction(SoAction *action) SoDetail *detail = nullptr; detailPath->truncate(0); auto subName = selaction->SelChange.pSubName; -#ifdef FC_USE_TNP_FIX App::ElementNamePair elementName;; App::GeoFeature::resolveElement(obj, subName, elementName); if (Data::isMappedElement(subName) && !elementName.oldName.empty()) { // If we have a shortened element name subName = elementName.oldName.c_str(); // use it. } -#endif if(!selaction->SelChange.pSubName || !selaction->SelChange.pSubName[0] || vp->getDetailPath(subName,detailPath,true,detail)) { @@ -625,7 +623,6 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo std::string subName = info.element; std::string objectName = objname; -#ifdef FC_USE_TNP_FIX // We need to convert the short name in the selection to a full element path to look it up // Ex: Body.Pad.Face9 to Body.Pad.;g3;SKT;:H12dc,E;FAC;:H12dc:4,F;:G0;XTR;:H12dc:8,F.Face9 App::ElementNamePair elementName; @@ -635,7 +632,6 @@ bool SoFCUnifiedSelection::setSelection(const std::vector &infos, bo subName.erase(subName.find(elementNameSuffix)); // Everything except original suffix suffix subName = subName.append(elementName.newName); // Add the mapped name suffix, } -#endif const char *subSelected = Gui::Selection().getSelectedElement( vpd->getObject(),subName.c_str()); diff --git a/src/Gui/View3DInventorSelection.cpp b/src/Gui/View3DInventorSelection.cpp index 6a6c681dabea..ce8d144c112e 100644 --- a/src/Gui/View3DInventorSelection.cpp +++ b/src/Gui/View3DInventorSelection.cpp @@ -114,14 +114,12 @@ void View3DInventorSelection::checkGroupOnTop(const SelectionChanges &Reason) std::string key(obj->getNameInDocument()); key += '.'; auto subname = Reason.pSubName; -#ifdef FC_USE_TNP_FIX App::ElementNamePair element; App::GeoFeature::resolveElement(obj, Reason.pSubName, element); if (Data::isMappedElement(subname) && !element.oldName.empty()) { // If we have a shortened element name subname = element.oldName.c_str(); // use if } -#endif if(subname) key += subname; if(Reason.Type == SelectionChanges::RmvSelection) { diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index 43d2e81e5c33..1353f14dd881 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -830,7 +830,6 @@ void AttachEngine::readLinks(const std::vector &objs, storage.reserve(objs.size()); shapes.resize(objs.size()); types.resize(objs.size()); -#ifdef FC_USE_TNP_FIX for (std::size_t i = 0; i < objs.size(); i++) { if (!objs[i]->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { FC_THROWM(AttachEngineException, @@ -914,78 +913,6 @@ void AttachEngine::readLinks(const std::vector &objs, } } -#else - for (std::size_t i = 0; i < objs.size(); i++) { - if (!objs[i]->isDerivedFrom()) { - throw AttachEngineException("AttachEngine3D: link points to something that is not App::GeoFeature"); - } - App::GeoFeature* geof = static_cast(objs[i]); - geofs[i] = geof; - Part::TopoShape shape; - if (geof->isDerivedFrom(Part::Feature::getClassTypeId())){ - shape = (static_cast(geof)->Shape.getShape()); - if (shape.isNull()){ - throw AttachEngineException("AttachEngine3D: Part has null shape"); - } - if (sub[i].length()>0){ - try{ - shape = Part::Feature::getTopoShape(geof, sub[i].c_str(), true); - if (shape.isNull()) - throw AttachEngineException("AttachEngine3D: null subshape"); - storage.push_back(shape.getShape()); - } catch (Standard_Failure &e){ - FC_THROWM(AttachEngineException, "AttachEngine3D: subshape not found " - << objs[i]->getNameInDocument() << '.' << sub[i] - << std::endl << e.GetMessageString()); - } catch (Base::CADKernelError &e){ - FC_THROWM(AttachEngineException, "AttachEngine3D: subshape not found " - << objs[i]->getNameInDocument() << '.' << sub[i] - << std::endl << e.what()); - } - if(storage[storage.size()-1].IsNull()) - FC_THROWM(AttachEngineException, "AttachEngine3D: null subshape " - << objs[i]->getNameInDocument() << '.' << sub[i]); - } else { - storage.push_back(shape.getShape()); - } - shapes[i] = &(storage[storage.size()-1]); - } else if ( geof->isDerivedFrom(App::Plane::getClassTypeId()) ){ - //obtain Z axis and origin of placement - Base::Vector3d norm; - geof->Placement.getValue().getRotation().multVec(Base::Vector3d(0.0,0.0,1.0),norm); - Base::Vector3d org; - geof->Placement.getValue().multVec(Base::Vector3d(),org); - //make shape - an local-XY plane infinite face - gp_Pln pl = gp_Pln(gp_Pnt(org.x, org.y, org.z), gp_Dir(norm.x, norm.y, norm.z)); - TopoDS_Shape myShape = BRepBuilderAPI_MakeFace(pl).Shape(); - myShape.Infinite(true); - storage.push_back(myShape); - shapes[i] = &(storage[storage.size()-1]); - } else if ( geof->isDerivedFrom(App::Line::getClassTypeId()) ){ - //obtain X axis and origin of placement - //note an inconsistency: App::Line is along local X, PartDesign::DatumLine is along local Z. - Base::Vector3d dir; - geof->Placement.getValue().getRotation().multVec(Base::Vector3d(1.0,0.0,0.0),dir); - Base::Vector3d org; - geof->Placement.getValue().multVec(Base::Vector3d(),org); - //make shape - an infinite line along local X axis - gp_Lin l = gp_Lin(gp_Pnt(org.x, org.y, org.z), gp_Dir(dir.x, dir.y, dir.z)); - TopoDS_Shape myShape = BRepBuilderAPI_MakeEdge(l).Shape(); - myShape.Infinite(true); - storage.push_back(myShape); - shapes[i] = &(storage[storage.size()-1]); - } else { - Base::Console().Warning("Attacher: linked object %s is unexpected, assuming it has no shape.\n",geof->getNameInDocument()); - storage.emplace_back(); - shapes[i] = &(storage[storage.size()-1]); - } - - //FIXME: unpack single-child compounds here? Compounds are not used so far, so it should be considered later, when the need arises. - types[i] = getShapeType(*(shapes[i])); - if (sub[i].length() == 0) - types[i] = eRefType(types[i] | rtFlagHasPlacement); - } -#endif } void AttachEngine::throwWrongMode(eMapMode mmode) diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index 237974b1e812..b392c7557772 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -257,25 +257,6 @@ void PropertyPartShape::beforeSave() const _Shape.beforeSave(); } } -#ifndef FC_USE_TNP_FIX -void PropertyPartShape::Save (Base::Writer &writer) const -{ - if(!writer.isForceXML()) { - //See SaveDocFile(), RestoreDocFile() - if (writer.getMode("BinaryBrep")) { - writer.Stream() << writer.ind() << "" << std::endl; - } - else { - writer.Stream() << writer.ind() << "" << std::endl; - } - } -} - -#else void PropertyPartShape::Save (Base::Writer &writer) const { //See SaveDocFile(), RestoreDocFile() @@ -328,7 +309,6 @@ void PropertyPartShape::Save (Base::Writer &writer) const _Shape.Save(writer); } } -#endif std::string PropertyPartShape::getElementMapVersion(bool restored) const { if(restored) @@ -336,19 +316,6 @@ std::string PropertyPartShape::getElementMapVersion(bool restored) const { return PropertyComplexGeoData::getElementMapVersion(false); } -#ifndef FC_USE_TNP_FIX -void PropertyPartShape::Restore(Base::XMLReader &reader) -{ - reader.readElement("Part"); - std::string file (reader.getAttribute("file") ); - - if (!file.empty()) { - // initiate a file read - reader.addFile(file.c_str(),this); - } -} - -#else void PropertyPartShape::Restore(Base::XMLReader &reader) { reader.readElement("Part"); @@ -450,7 +417,6 @@ void PropertyPartShape::afterRestore() } PropertyComplexGeoData::afterRestore(); } -#endif // The following function is copied from OCCT BRepTools.cxx and modified // to disable saving of triangulation diff --git a/src/Mod/Part/App/PropertyTopoShapeList.cpp b/src/Mod/Part/App/PropertyTopoShapeList.cpp index 6b9f58630428..1b90c856b890 100644 --- a/src/Mod/Part/App/PropertyTopoShapeList.cpp +++ b/src/Mod/Part/App/PropertyTopoShapeList.cpp @@ -154,8 +154,6 @@ void PropertyTopoShapeList::setPyObject(PyObject *value) } } -#ifdef FC_USE_TNP_FIX - void PropertyTopoShapeList::Save(Writer& writer) const { writer.Stream() << writer.ind() << "" << endl; @@ -251,32 +249,6 @@ void PropertyTopoShapeList::RestoreDocFile(Base::Reader& reader) } } -#else -void PropertyTopoShapeList::Save(Writer &writer) const -{ - writer.Stream() << writer.ind() << "" << endl; - writer.incInd(); - for (int i = 0; i < getSize(); i++) { - _lValueList[i].Save(writer); - } - writer.decInd(); - writer.Stream() << writer.ind() << "" << endl ; -} - -void PropertyTopoShapeList::Restore(Base::XMLReader &reader) -{ - reader.readElement("ShapeList"); - int count = reader.getAttributeAsInteger("count"); - m_restorePointers.clear(); // just in case - m_restorePointers.reserve(count); - for (int i = 0; i < count; i++) { - auto newShape = std::make_shared(); - newShape->Restore(reader); - m_restorePointers.push_back(newShape); - } - reader.readEndElement("ShapeList"); -} -#endif App::Property *PropertyTopoShapeList::Copy() const { PropertyTopoShapeList *p = new PropertyTopoShapeList(); diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 3f4bf3e1daa9..92e8b17276bd 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -1199,7 +1199,7 @@ bool TopoShape::getCenterOfGravity(Base::Vector3d& center) const return false; } -#ifdef FC_USE_TNP_FIX + void TopoShape::Save (Base::Writer &writer ) const { Data::ComplexGeoData::Save(writer); @@ -1221,60 +1221,6 @@ void TopoShape::RestoreDocFile(Base::Reader &reader) } -#else -void TopoShape::Save (Base::Writer& writer) const -{ - if(!writer.isForceXML()) { - //See SaveDocFile(), RestoreDocFile() - // add a filename to the writer's list. Each file on the list is eventually - // processed by SaveDocFile(). - if (writer.getMode("BinaryBrep")) { - writer.Stream() << writer.ind() << "" << std::endl; - } - else { - writer.Stream() << writer.ind() << "" << std::endl; - } - }} - -void TopoShape::Restore(Base::XMLReader& reader) -{ - reader.readElement("TopoShape"); - std::string file (reader.getAttribute("file") ); - - if (!file.empty()) { - // add a filename to the writer's list. Each file on the list is eventually - // processed by RestoreDocFile(). - reader.addFile(file.c_str(),this); - } -} - -void TopoShape::SaveDocFile (Base::Writer& writer) const -{ - if (getShape().IsNull()) { - return; - } - //the writer has already opened a stream with the appropriate filename - if (writer.getMode("BinaryBrep")) { - exportBinary(writer.Stream()); - } else { - exportBrep(writer.Stream()); - } -} - -void TopoShape::RestoreDocFile(Base::Reader& reader) -{ - Base::FileInfo brep(reader.getFileName()); - if (brep.hasExtension("bin")) { - importBinary(reader); - } else { - importBrep(reader); - } -} -#endif unsigned int TopoShape_RefCountShapes(const TopoDS_Shape& aShape) { unsigned int size = 1; // this shape diff --git a/src/Mod/Part/App/TopoShapeExpansion.cpp b/src/Mod/Part/App/TopoShapeExpansion.cpp index ef7ad3a2a0fc..d54448e2f3ba 100644 --- a/src/Mod/Part/App/TopoShapeExpansion.cpp +++ b/src/Mod/Part/App/TopoShapeExpansion.cpp @@ -792,41 +792,6 @@ void TopoShape::copyElementMap(const TopoShape& topoShape, const char* op) setMappedChildElements(children); } -#ifndef FC_USE_TNP_FIX -namespace -{ -void warnIfLogging() -{ - if (FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) { - FC_WARN("hasher mismatch"); // NOLINT - } -} - -void hasherMismatchError() -{ - FC_ERR("hasher mismatch"); // NOLINT -} - - -void checkAndMatchHasher(TopoShape& topoShape1, const TopoShape& topoShape2) -{ - if (topoShape1.Hasher) { - if (topoShape2.Hasher != topoShape1.Hasher) { - if (topoShape1.getElementMapSize(false) == 0U) { - warnIfLogging(); - } - else { - hasherMismatchError(); - } - topoShape1.Hasher = topoShape2.Hasher; - } - } - else { - topoShape1.Hasher = topoShape2.Hasher; - } -} -} // namespace -#endif // TODO: Refactor mapSubElementTypeForShape to reduce complexity void TopoShape::mapSubElementTypeForShape(const TopoShape& other, @@ -2045,11 +2010,7 @@ TopoShape TopoShape::getSubTopoShape(const char* Type, bool silent) const } return TopoShape(); } -#ifdef FC_USE_TNP_FIX auto res = shapeTypeAndIndex(mapped.index); -#else - auto res = shapeTypeAndIndex(Type); -#endif if (res.second <= 0) { if (!silent) { FC_THROWM(Base::ValueError, "Invalid shape name " << (Type ? Type : "")); diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index f93e2ca09d23..9bec74bedb2b 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -66,7 +66,6 @@ Feature::Feature() App::DocumentObjectExecReturn* Feature::recompute() { -#ifdef FC_USE_TNP_FIX SuppressedShape.setValue(TopoShape()); if (!Suppressed.getValue()) { @@ -96,21 +95,6 @@ App::DocumentObjectExecReturn* Feature::recompute() Shape.setValue(getBaseTopoShape(true)); } return App::DocumentObject::StdReturn; -#else - try { - auto baseShape = getBaseTopoShape(); - if (Suppressed.getValue()) { - this->Shape.setValue(baseShape.getShape()); - return StdReturn; - } - } - catch (Base::Exception&) { - //invalid BaseShape - Suppressed.setValue(false); - } - - return DocumentObject::recompute(); -#endif } void Feature::updateSuppressedShape() @@ -144,28 +128,6 @@ short Feature::mustExecute() const return Part::Feature::mustExecute(); } -#ifndef FC_USE_TNP_FIX -// TODO: Toponaming April 2024 Deprecated in favor of TopoShape method. Remove when possible. -TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape) -{ - if (shape.IsNull()) { - Standard_Failure::Raise("Shape is null"); - } - - // If single solid rule is not enforced we simply return the shape as is - if (singleSolidRuleMode() != Feature::SingleSolidRuleMode::Enforced) { - return shape; - } - - TopExp_Explorer xp; - xp.Init(shape, TopAbs_SOLID); - if (xp.More()) { - return xp.Current(); - } - - return {}; -} -#endif TopoShape Feature::getSolid(const TopoShape& shape) { if (shape.isNull()) { diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index bddea63b993d..6d3efabbef7d 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -99,10 +99,6 @@ class PartDesignExport Feature : public Part::Feature, public App::SuppressibleE /** * Get a solid of the given shape. If no solid is found an exception is raised. */ -#ifndef FC_USE_TNP_FIX - // TODO: Toponaming April 2024 Deprecated in favor of TopoShape method. Remove when possible. - TopoDS_Shape getSolid(const TopoDS_Shape&); -#endif TopoShape getSolid(const TopoShape&); static int countSolids(const TopoDS_Shape&, TopAbs_ShapeEnum type = TopAbs_SOLID); diff --git a/src/Mod/PartDesign/App/FeatureAddSub.cpp b/src/Mod/PartDesign/App/FeatureAddSub.cpp index a1a8b14517e0..ec5034e228ea 100644 --- a/src/Mod/PartDesign/App/FeatureAddSub.cpp +++ b/src/Mod/PartDesign/App/FeatureAddSub.cpp @@ -64,27 +64,6 @@ short FeatureAddSub::mustExecute() const return PartDesign::Feature::mustExecute(); } -#ifndef FC_USE_TNP_FIX -// TODO: Toponaming April 2024 Deprecated in favor of TopoShape method. Remove when possible. -TopoDS_Shape FeatureAddSub::refineShapeIfActive(const TopoDS_Shape& oldShape) const -{ - if (this->Refine.getValue()) { - try { - Part::BRepBuilderAPI_RefineModel mkRefine(oldShape); - TopoDS_Shape resShape = mkRefine.Shape(); - if (!TopoShape(resShape).isClosed()) { - return oldShape; - } - return resShape; - } - catch (Standard_Failure&) { - return oldShape; - } - } - - return oldShape; -} -#endif TopoShape FeatureAddSub::refineShapeIfActive(const TopoShape& oldShape) const { diff --git a/src/Mod/PartDesign/App/FeatureAddSub.h b/src/Mod/PartDesign/App/FeatureAddSub.h index 0a6bd1896249..30864a5f4120 100644 --- a/src/Mod/PartDesign/App/FeatureAddSub.h +++ b/src/Mod/PartDesign/App/FeatureAddSub.h @@ -54,10 +54,6 @@ class PartDesignExport FeatureAddSub : public PartDesign::Feature protected: Type addSubType{Additive}; -#ifndef FC_USE_TNP_FIX - // TODO: Toponaming April 2024 Deprecated in favor of TopoShape method. Remove when possible. - TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const; -#endif TopoShape refineShapeIfActive(const TopoShape&) const; }; diff --git a/src/Mod/PartDesign/App/FeatureBoolean.cpp b/src/Mod/PartDesign/App/FeatureBoolean.cpp index a3e0ec520c6f..2a0de63fbf02 100644 --- a/src/Mod/PartDesign/App/FeatureBoolean.cpp +++ b/src/Mod/PartDesign/App/FeatureBoolean.cpp @@ -137,7 +137,6 @@ App::DocumentObjectExecReturn *Boolean::execute() if (shape.IsNull()) return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Tool shape is null")); -#ifdef FC_USE_TNP_FIX const char *op = nullptr; if (type == "Fuse") op = Part::OpCodes::Fuse; @@ -160,30 +159,6 @@ App::DocumentObjectExecReturn *Boolean::execute() FC_ERR("Boolean operation failed: " << e.GetMessageString()); return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Boolean operation failed")); } -#else - if (type == "Fuse") { - BRepAlgoAPI_Fuse mkFuse(result, shape); - if (!mkFuse.IsDone()) - return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Fusion of tools failed")); - // we have to get the solids (fuse sometimes creates compounds) - boolOp = this->getSolid(mkFuse.Shape()); - // lets check if the result is a solid - if (boolOp.IsNull()) - return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Resulting shape is not a solid")); - } else if (type == "Cut") { - BRepAlgoAPI_Cut mkCut(result, shape); - if (!mkCut.IsDone()) - return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Cut out failed")); - boolOp = mkCut.Shape(); - } else if (type == "Common") { - BRepAlgoAPI_Common mkCommon(result, shape); - if (!mkCommon.IsDone()) - return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Common operation failed")); - boolOp = mkCommon.Shape(); - } - - result = boolOp; // Use result of this operation for fuse/cut of next body -#endif } result = refineShapeIfActive(result); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 8900a4a7b6dc..a0a9ca719427 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -404,7 +404,6 @@ TopoDS_Shape ProfileBased::getVerifiedFace(bool silent) const { return TopoDS_Face(); } -#ifdef FC_USE_TNP_FIX TopoShape ProfileBased::getProfileShape() const { TopoShape shape; @@ -426,19 +425,6 @@ TopoShape ProfileBased::getProfileShape() const } return shape; } -#else -Part::TopoShape ProfileBased::getProfileShape() const -{ - auto shape = getTopoShape(Profile.getValue()); - if (!shape.isNull() && !Profile.getSubValues().empty()) { - std::vector shapes; - for (auto& sub : Profile.getSubValues(true)) - shapes.emplace_back(shape.getSubShape(sub.c_str())); - shape = Part::TopoShape().makeCompound(shapes); - } - return shape; -} -#endif // TODO: Toponaming April 2024 Deprecated in favor of TopoShape method. Remove when possible. diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 195101967cfe..8908df80ec52 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -704,7 +704,6 @@ void SubShapeBinder::update(SubShapeBinder::UpdateOption options) { if (hit) return; } -#ifdef FC_USE_TNP_FIX std::ostringstream ss; int idx = -1; for(auto &shape : shapes) { @@ -725,7 +724,6 @@ void SubShapeBinder::update(SubShapeBinder::UpdateOption options) { shape = shape.makeElementCopy(); } -#endif if (shapes.size() == 1 && !Relative.getValue()) shapes.back().setPlacement(Base::Placement()); else { diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 794a78bb5004..a4827254cd73 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -140,7 +140,6 @@ void TaskDressUpParameters::referenceSelected(const Gui::SelectionChanges& msg, void TaskDressUpParameters::addAllEdges(QListWidget* widget) { -#ifdef FC_USE_TNP_FIX Q_UNUSED(widget) if (DressUpView.expired()) { @@ -172,28 +171,6 @@ void TaskDressUpParameters::addAllEdges(QListWidget* widget) catch (Base::Exception& e) { e.ReportException(); } -#else - PartDesign::DressUp* pcDressUp = static_cast(DressUpView->getObject()); - - Gui::WaitCursor wait; - int count = pcDressUp->getBaseTopoShape().countSubElements("Edge"); - std::vector edgeNames; - for (int ii = 0; ii < count; ii++){ - std::ostringstream edgeName; - edgeName << "Edge" << ii+1; - edgeNames.push_back(edgeName.str()); - } - - //First we need to clear the widget in case the user had faces selected. Else the faces will still be in widget but not in the feature refs! - QSignalBlocker block(widget); - widget->clear(); - - for (const auto & it : edgeNames){ - widget->addItem(QLatin1String(it.c_str())); - } - - updateFeature(pcDressUp, edgeNames); -#endif } void TaskDressUpParameters::deleteRef(QListWidget* widget) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 7ba863993ef7..24e450d07b38 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1868,7 +1868,6 @@ int SketchObject::setConstruction(int GeoId, bool on) // no need to check input data validity as this is an sketchobject managed operation. Base::StateLocker lock(managedoperation, true); -#ifdef FC_USE_TNP_FIX Part::PropertyGeometryList *prop; int idx; if (GeoId >= 0) { @@ -1882,21 +1881,12 @@ int SketchObject::setConstruction(int GeoId, bool on) idx = -GeoId-1; }else return -1; -#else - const std::vector& vals = getInternalGeometry(); - if (GeoId < 0 || GeoId >= int(vals.size())) - return -1; - - if (getGeometryFacade(GeoId)->isInternalAligned()) - return -1; -#endif // While it may seem that there is not a need to trigger an update at this time, because the // solver has its own copy of the geometry, and updateColors of the viewprovider may be // triggered by the clearselection of the UI command, this won't update the elements widget, in // the accumulative of actions it is judged that it is worth to trigger an update here. -#ifdef FC_USE_TNP_FIX std::unique_ptr geo(prop->getValues()[idx]->clone()); if(prop == &Geometry) GeometryFacade::setConstruction(geo.get(), on); @@ -1906,12 +1896,6 @@ int SketchObject::setConstruction(int GeoId, bool on) } prop->set1Value(idx,std::move(geo)); - -#else - std::unique_ptr geo(vals[GeoId]->clone()); - GeometryFacade::setConstruction(geo.get(), on); - this->Geometry.set1Value(GeoId, std::move(geo)); -#endif solverNeedsUpdate = true; return 0; } @@ -7751,7 +7735,7 @@ int SketchObject::addExternal(App::DocumentObject *Obj, const char* SubName, boo solverNeedsUpdate = true; return ExternalGeometry.getValues().size() - 1; } -#ifdef FC_USE_TNP_FIX + int SketchObject::delExternal(int ExtGeoId) { return delExternal(std::vector{ExtGeoId}); @@ -7780,73 +7764,7 @@ int SketchObject::delExternal(const std::vector& ExtGeoIds) delExternalPrivate(geoIds, true); return 0; } -#else -int SketchObject::delExternal(int ExtGeoId) -{ - // no need to check input data validity as this is an sketchobject managed operation. - Base::StateLocker lock(managedoperation, true); - - // get the actual lists of the externals - std::vector Objects = ExternalGeometry.getValues(); - std::vector SubElements = ExternalGeometry.getSubValues(); - - if (ExtGeoId < 0 || ExtGeoId >= int(SubElements.size())) - return -1; - - const std::vector originalObjects = Objects; - const std::vector originalSubElements = SubElements; - - Objects.erase(Objects.begin() + ExtGeoId); - SubElements.erase(SubElements.begin() + ExtGeoId); - - const std::vector& constraints = Constraints.getValues(); - std::vector newConstraints; - std::vector copiedConstraints; - int GeoId = GeoEnum::RefExt - ExtGeoId; - for (auto cstr : constraints) { - if (cstr->First != GeoId && cstr->Second != GeoId && cstr->Third != GeoId) { - auto copiedConstr = cstr; - if (copiedConstr->First < GeoId && copiedConstr->First != GeoEnum::GeoUndef) { - if (cstr == copiedConstr) - copiedConstr = cstr->clone(); - copiedConstr->First += 1; - } - if (copiedConstr->Second < GeoId && copiedConstr->Second != GeoEnum::GeoUndef) { - if (cstr == copiedConstr) - copiedConstr = cstr->clone(); - copiedConstr->Second += 1; - } - if (copiedConstr->Third < GeoId && copiedConstr->Third != GeoEnum::GeoUndef) { - if (cstr == copiedConstr) - copiedConstr = cstr->clone(); - copiedConstr->Third += 1; - } - newConstraints.push_back(copiedConstr); - if (cstr != copiedConstr) - copiedConstraints.push_back(copiedConstr); - } - } - - ExternalGeometry.setValues(Objects, SubElements); - try { - rebuildExternalGeometry(); - } - catch (const Base::Exception& e) { - Base::Console().Error("%s\n", e.what()); - // revert to original values - ExternalGeometry.setValues(originalObjects, originalSubElements); - for (Constraint* it : copiedConstraints) - delete it; - return -1; - } - - solverNeedsUpdate = true; - Constraints.setValues(std::move(newConstraints)); - acceptGeometry();// This may need to be refactored into OnChanged for ExternalGeometry. - return 0; -} -#endif void SketchObject::delExternalPrivate(const std::set &ids, bool removeRef) { Base::StateLocker lock(managedoperation, true); // no need to check input data validity as this is an sketchobject managed operation. @@ -8503,7 +8421,6 @@ void SketchObject::rebuildExternalGeometry(bool defining, bool addIntersection) // We use a vector here to keep the order (roughly) the same as ExternalGeometry std::vector > > newGeos; newGeos.reserve(Objects.size()); -#ifdef FC_USE_TNP_FIX for (int i=0; i < int(Objects.size()); i++) { const App::DocumentObject *Obj=Objects[i]; const std::string &SubElement=SubElements[i]; @@ -8527,24 +8444,6 @@ void SketchObject::rebuildExternalGeometry(bool defining, bool addIntersection) refSet.insert(std::move(key)); continue; } -#else - for (std::vector::iterator it = ExternalGeo.begin(); it != ExternalGeo.end(); - ++it) - if (*it) - delete *it; - ExternalGeo.clear(); - Part::GeomLineSegment* HLine = new Part::GeomLineSegment(); - Part::GeomLineSegment* VLine = new Part::GeomLineSegment(); - HLine->setPoints(Base::Vector3d(0, 0, 0), Base::Vector3d(1, 0, 0)); - VLine->setPoints(Base::Vector3d(0, 0, 0), Base::Vector3d(0, 1, 0)); - GeometryFacade::setConstruction(HLine, true); - GeometryFacade::setConstruction(VLine, true); - ExternalGeo.push_back(HLine); - ExternalGeo.push_back(VLine); - for (int i = 0; i < int(Objects.size()); i++) { - const App::DocumentObject* Obj = Objects[i]; - const std::string SubElement = SubElements[i]; -#endif if(!Obj || !Obj->getNameInDocument()) continue; @@ -10314,7 +10213,6 @@ void SketchObject::onChanged(const App::Property* prop) } } else if (prop == &ExternalGeometry) { -#ifdef FC_USE_TNP_FIX if (doc && doc->isPerformingTransaction()) { setStatus(App::PendingTransactionUpdate, true); } @@ -10350,15 +10248,6 @@ void SketchObject::onChanged(const App::Property* prop) } solve(); } -#else - // make sure not to change anything while restoring this object - if (!isRestoring()) { - // external geometry was cleared - if (ExternalGeometry.getSize() == 0) { - delConstraintsToExternal(); - } - } -#endif } #if 0 // For now do not delete anything (#0001791). When changing the support @@ -10617,7 +10506,6 @@ void SketchObject::restoreFinished() try { migrateSketch(); -#ifdef FC_USE_TNP_FIX updateGeometryRefs(); if(ExternalGeo.getSize()<=2) { if (ExternalGeo.getSize() < 2) @@ -10634,11 +10522,6 @@ void SketchObject::restoreFinished() }else acceptGeometry(); -#else - validateExternalLinks(); - rebuildExternalGeometry(); - Constraints.acceptGeometry(getCompleteGeometry()); -#endif synchroniseGeometryState(); // this may happen when saving a sketch directly in edit mode // but never performed a recompute before diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f24d1c3b7069..be8ff26b71f1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,8 +40,6 @@ if(MSVC) endif() endif() -add_compile_options("-DFC_USE_TNP_FIX") - if(WIN32) add_definitions(-DCOIN_DLL -D_USE_MATH_DEFINES) endif(WIN32)