Toponaming: Remove remaining FC_USE_TNP_FIX defines

This commit is contained in:
bgbsww
2024-08-28 08:07:43 -04:00
committed by Chris Hennes
parent 4068341873
commit 2a541c9536
19 changed files with 2 additions and 491 deletions

View File

@@ -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)

View File

@@ -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,'.');

View File

@@ -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<PickedInfo> &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<PickedInfo> &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());

View File

@@ -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) {

View File

@@ -830,7 +830,6 @@ void AttachEngine::readLinks(const std::vector<App::DocumentObject*> &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<App::DocumentObject*> &objs,
}
}
#else
for (std::size_t i = 0; i < objs.size(); i++) {
if (!objs[i]->isDerivedFrom<App::GeoFeature>()) {
throw AttachEngineException("AttachEngine3D: link points to something that is not App::GeoFeature");
}
App::GeoFeature* geof = static_cast<App::GeoFeature*>(objs[i]);
geofs[i] = geof;
Part::TopoShape shape;
if (geof->isDerivedFrom(Part::Feature::getClassTypeId())){
shape = (static_cast<Part::Feature*>(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)

View File

@@ -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() << "<Part file=\""
<< writer.addFile("PartShape.bin", this)
<< "\"/>" << std::endl;
}
else {
writer.Stream() << writer.ind() << "<Part file=\""
<< writer.addFile("PartShape.brp", this)
<< "\"/>" << 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

View File

@@ -154,8 +154,6 @@ void PropertyTopoShapeList::setPyObject(PyObject *value)
}
}
#ifdef FC_USE_TNP_FIX
void PropertyTopoShapeList::Save(Writer& writer) const
{
writer.Stream() << writer.ind() << "<ShapeList count=\"" << getSize() << "\">" << endl;
@@ -251,32 +249,6 @@ void PropertyTopoShapeList::RestoreDocFile(Base::Reader& reader)
}
}
#else
void PropertyTopoShapeList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<ShapeList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
_lValueList[i].Save(writer);
}
writer.decInd();
writer.Stream() << writer.ind() << "</ShapeList>" << 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<TopoShape>();
newShape->Restore(reader);
m_restorePointers.push_back(newShape);
}
reader.readEndElement("ShapeList");
}
#endif
App::Property *PropertyTopoShapeList::Copy() const
{
PropertyTopoShapeList *p = new PropertyTopoShapeList();

View File

@@ -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() << "<TopoShape file=\""
<< writer.addFile("TopoShape.bin", this)
<< "\"/>" << std::endl;
}
else {
writer.Stream() << writer.ind() << "<TopoShape file=\""
<< writer.addFile("TopoShape.brp", this)
<< "\"/>" << 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

View File

@@ -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 : ""));

View File

@@ -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()) {

View File

@@ -99,10 +99,6 @@ protected:
/**
* 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);

View File

@@ -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
{

View File

@@ -54,10 +54,6 @@ public:
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;
};

View File

@@ -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);

View File

@@ -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<Part::TopoShape> 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.

View File

@@ -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 {

View File

@@ -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<PartDesign::DressUp*>(DressUpView->getObject());
Gui::WaitCursor wait;
int count = pcDressUp->getBaseTopoShape().countSubElements("Edge");
std::vector<std::string> 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)

View File

@@ -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<Part::Geometry*>& 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<Part::Geometry> 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<Part::Geometry> 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<int>{ExtGeoId});
@@ -7780,73 +7764,7 @@ int SketchObject::delExternal(const std::vector<int>& 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<DocumentObject*> Objects = ExternalGeometry.getValues();
std::vector<std::string> SubElements = ExternalGeometry.getSubValues();
if (ExtGeoId < 0 || ExtGeoId >= int(SubElements.size()))
return -1;
const std::vector<DocumentObject*> originalObjects = Objects;
const std::vector<std::string> originalSubElements = SubElements;
Objects.erase(Objects.begin() + ExtGeoId);
SubElements.erase(SubElements.begin() + ExtGeoId);
const std::vector<Constraint*>& constraints = Constraints.getValues();
std::vector<Constraint*> newConstraints;
std::vector<Constraint*> 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<long> &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<std::vector<std::unique_ptr<Part::Geometry> > > 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<Part::Geometry*>::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

View File

@@ -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)