Skip to content

GetPlanViewPolygon3d silently reports success on empty polygon #194

Description

@gagelarsen

Problem

xmsgrid/ugrid/XmUGrid.cpp:2946-2969GetPlanViewPolygon3d always returns true for prismatic cells, even when iMergeSegmentsToPoly hit its failure path and cleared a_polygon:

if (GetCellXySegments(a_cellIdx, segments))
{
  // Prismatic cell
  iMergeSegmentsToPoly(segments, a_polygon);
  return true;            // ← always true, even when a_polygon was just cleared
}

When iMergeSegmentsToPoly fails (now expanded by PR #193's iBuildPolygon hardening) it fires a debug-only XM_ASSERT(0) and clears a_polygon. The public XmUGrid::GetCellPlanViewPolygon (line 2127-2139) then returns true with an empty VecPt3d, and callers cannot distinguish "valid prismatic cell" from "polygon construction failed."

Why this matters

The bool plumbing added inside iBuildPolygon in #193 dies one stack frame above where it would actually surface to a user. Issue #188 hardened the lower layer; this is the matching fix at the public-API boundary.

Suggested fix

Either:

  1. Change iMergeSegmentsToPoly to return bool and propagate:
    return iMergeSegmentsToPoly(segments, a_polygon);
  2. At minimum, return !a_polygon.empty(); after the call.

Context

Surfaced during review of #193 (follow-up to #186). Reviewer flagged as out-of-scope for #193 and recommended filing separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions