From f86c65644c8137badb9575aebc0125c594ed6232 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 9 Jul 2013 10:40:37 +0200 Subject: [PATCH] Try alternative sort method --- src/Mod/PartDesign/App/FeatureSketchBased.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 0e2027160..29012d4c6 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include # include # include @@ -70,7 +71,8 @@ using namespace PartDesign; // sort bounding boxes according to diagonal length -class SketchBased::Wire_Compare { +class SketchBased::Wire_Compare : public std::binary_function { public: bool operator() (const TopoDS_Wire& w1, const TopoDS_Wire& w2) { @@ -362,10 +364,28 @@ TopoDS_Shape SketchBased::makeFace(const std::vector& w) const //FIXME: Need a safe method to sort wire that the outermost one comes last // Currently it's done with the diagonal lengths of the bounding boxes +#if 1 std::vector wires = w; std::sort(wires.begin(), wires.end(), Wire_Compare()); std::list wire_list; wire_list.insert(wire_list.begin(), wires.rbegin(), wires.rend()); +#else + //bug #0001133: try alternative sort algorithm + std::list unsorted_wire_list; + unsorted_wire_list.insert(unsorted_wire_list.begin(), w.begin(), w.end()); + std::list wire_list; + Wire_Compare wc; + while (!unsorted_wire_list.empty()) { + std::list::iterator w_ref = unsorted_wire_list.begin(); + std::list::iterator w_it = unsorted_wire_list.begin(); + for (++w_it; w_it != unsorted_wire_list.end(); ++w_it) { + if (wc(*w_ref, *w_it)) + w_ref = w_it; + } + wire_list.push_back(*w_ref); + unsorted_wire_list.erase(w_ref); + } +#endif // separate the wires into several independent faces std::list< std::list > sep_wire_list;