From: Henri Verbeet Subject: Re: [PATCH] d2d: Suppress last empty segment also for D2D1_FIGURE_END_OPEN Message-Id: Date: Mon, 3 Jan 2022 16:40:50 +0100 In-Reply-To: <26473716.ikUS8UAcQo@bacchus> References: <20211230221854.18968-1-stefan.bruens@rwth-aachen.de> <26473716.ikUS8UAcQo@bacchus> On Mon, 3 Jan 2022 at 15:10, Stefan Brüns wrote: > On Montag, 3. Januar 2022 12:58:50 CET you wrote: > > On Fri, 31 Dec 2021 at 08:23, Stefan Brüns > wrote: > > > When the last vertex is coincident with the first vertex, the last > > > segment should be suppressed for both END_OPEN and END_CLOSED. > > > > > > When the last, zero length segment is not omitted > > > d2d_geometry_intersect_self will add invalid segments. > > > > Unfortunately, I don't think that's correct. For an END_OPEN figure, > > the first and last vertex coinciding doesn't imply that the last > > segment is a zero-length segment. > > Please supply an example where coinciding does not mean zero length. > > Last vertex refers to the second vertex of the last segment, not its start > vertex. > Consider for example a triangle like this: p0, p3 /\ / \ /____\ p1 p2 and the corresponding Direct2D calls: BeginFigure(p0, ...); AddLine(p1); AddLine(p2); AddLine(p3); EndFigure(END_OPEN/END_CLOSED); In the END_CLOSED case, we'd first create three segments: p0->p1 p1->p2 p2->p3 and then we'd have a fourth implicit zero-length segment p3->p0. By removing the p3 vertex, we replace the p2->p3 and p3->p0 segments with an implicit p2->p0 segment. In the END_OPEN case however, we just have the three explicit segments above, without the implicit p3->p0 segment. In that case, removing the p3 vertex simply removes the p2->p3 segment, and we'd be left with the following figure: p0 / / /____ p1 p2 Looking at d2d_geometry_intersect_self() though, it looks like it doesn't take D2D_FIGURE_FLAG_CLOSED into account, probably because it predates its introduction. Perhaps that explains the behaviour you're seeing. In any case, thanks for looking into this! Henri