Skip to content

PointSymbol: Fix check for symmetry#2498

Open
dl3sdo wants to merge 1 commit intoOpenOrienteering:masterfrom
dl3sdo:fix-pointsymbol
Open

PointSymbol: Fix check for symmetry#2498
dl3sdo wants to merge 1 commit intoOpenOrienteering:masterfrom
dl3sdo:fix-pointsymbol

Conversation

@dl3sdo
Copy link
Copy Markdown
Member

@dl3sdo dl3sdo commented Apr 17, 2026

The test for symmetry in function isSymmetrical() was broken since the check for the position being at (0,0) was not negated.
Use std::all_of to improve readability.

The test for symmetry in function isSymmetrical() was broken since
the check for the position being at (0,0) was not negated.
Use std::all_of to improve readability.
@dl3sdo
Copy link
Copy Markdown
Member Author

dl3sdo commented Apr 17, 2026

Basically, the minimum fix would be

return std::none_of(begin(elements), end(elements), [](auto& element) {
	return element.symbol->getType() != Symbol::Point
	       || !static_cast<const PointObject*>(element.object.get())->getCoord().isPositionEqualTo({0,0});
});

Instead of using none_of in combination with two negations that are ORed, I prefer std::all_of as this is closer to the description in the .h-file: "only point elements at (0,0) are allowed".

@dl3sdo
Copy link
Copy Markdown
Member Author

dl3sdo commented Apr 17, 2026

The effect of the missing negation would only show up when importing an .ocd file where an unsymmetrical point object was rotated (I'm not aware that point symbols like that are really used):
OCAD:
RotatedPointObjectOCAD

Mapper (without fix) after import:
RotatedPointObjectWithoutFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant