Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/fileformats/ocd_file_import.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 Kai Pastor
* Copyright 2013-2023 Kai Pastor
*
* Some parts taken from file_format_oc*d8{.h,_p.h,cpp} which are
* Copyright 2012 Pete Curtis
Expand Down Expand Up @@ -2153,6 +2153,17 @@ void OcdFileImport::fillPathCoords(OcdImportedPathObject *object, bool is_area,
size_t start = 0;
for (size_t i = 0; i < object->coords.size(); ++i)
{
// There are .ocd files that erroneously contain an empty area hole, i.e., there are two subsequent points
// with the Ocd::OcdPoint32::FlagHole property. To fix this, the first of these points needs to be ignored.
// Since setPointFlags() applies the HolePoint property to the last point instead of the first point of the next part,
// the consequence is that instead of removing the first point of these two .ocd points,
// the second point of the two Mapper points with the HolePoint property needs to be removed.
// Using a loop ensures that multiple subsequent empty area holes are removed.
while (is_area && i < object->coords.size() - 1 && object->coords[i].isHolePoint() && object->coords[i+1].isHolePoint())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to use a separate loop (or STL algorithm) then to nest loops.

{
object->coords.erase(begin(object->coords) + i + 1);
}

if (!object->coords[i].isHolePoint() && i < object->coords.size() - 1)
continue;

Expand Down