#include #include "cutface.h" IMPL_CutFaceFromString IMPL_CutFaceToString TMPL_CutFaceToPoints void normalizeCutFacePoints(std::vector *points) { QVector2D center; if (nullptr == points || points->empty()) return; float xLow = std::numeric_limits::max(); float xHigh = std::numeric_limits::lowest(); float yLow = std::numeric_limits::max(); float yHigh = std::numeric_limits::lowest(); for (const auto &position: *points) { if (position.x() < xLow) xLow = position.x(); else if (position.x() > xHigh) xHigh = position.x(); if (position.y() < yLow) yLow = position.y(); else if (position.y() > yHigh) yHigh = position.y(); } float xMiddle = (xHigh + xLow) * 0.5; float yMiddle = (yHigh + yLow) * 0.5; float xSize = xHigh - xLow; float ySize = yHigh - yLow; float longSize = ySize; if (xSize > longSize) longSize = xSize; if (qFuzzyIsNull(longSize)) longSize = 0.000001; for (auto &position: *points) { position.setX((position.x() - xMiddle) * 2 / longSize); position.setY((position.y() - yMiddle) * 2 / longSize); } }