Commit d074dc0f authored by David Thompson's avatar David Thompson
Browse files

Fix a bug in polygon's CreateEdge.

The test for whether a segment has been flipped must use
extended-precision coordinates to avoid integer overflow.
parent 74036c1b
......@@ -40,6 +40,7 @@ namespace smtk {
typedef typename boost::polygon::high_precision_type<Coord>::type HighPrecisionCoord;
typedef smtk::common::UUID Id;
typedef boost::polygon::point_data<Coord> Point;
typedef boost::polygon::point_data<HighPrecisionCoord> HighPrecisionPoint;
typedef boost::polygon::segment_data<Coord> Segment;
typedef boost::polygon::interval_data<Coord> Interval;
typedef boost::polygon::rectangle_data<Coord> Rect;
......@@ -251,12 +251,12 @@ smtk::model::OperatorResult CreateEdge::operateInternal()
std::size_t numSegsPerSrc = 0; // Number of result segs per input edge in edgeSegs
// Determine whether segments are reversed from the input edge:
//printSegment(storage, "Seg ", sit->second);
internal::Point deltaSrc =
internal::HighPrecisionPoint deltaSrc =
edgeIt->high().x() - edgeIt->low().x(),
edgeIt->high().y() - edgeIt->low().y());
internal::Point deltaDst =
internal::HighPrecisionPoint deltaDst =
sit->second.high().x() - sit->second.low().x(),
sit->second.high().y() - sit->second.low().y());
// Whether the segments are reversed or not, determine which
......@@ -285,7 +285,7 @@ smtk::model::OperatorResult CreateEdge::operateInternal()
sit = segStart;
// If the first point in the first ouput segment for any input-segment is
// a model vertex, make a note of it for periodic edges:
if (edgeIsPeriodic && storage->pointId(sit->second.low()))
if (edgeIsPeriodic && storage->pointId(sit->second.low()) && !haveFirstModelVertex)
haveFirstModelVertex = true;
firstModelVertex = sit;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment