<commit_before>#include "ImageOutlineFinder.h"
#include "FMath.h"

#include <poly2tri.h>
#include <iostream>

#include "../liquidfun_contrib/ConvexDecomposition/b2Polygon.h"


ImageOutlineFinder::ImageOutlineFinder()
= default;

ImageOutlineFinder::~ImageOutlineFinder()
= default;

void ImageOutlineFinder::findOutLines(const sf::Image& image, const int alpha_threshold)
{
	alpha_threshold_ = alpha_threshold;
	image_ = image;
	const sf::Vector2i starting_point = findStartingPoint();
	if (starting_point.x > -1)
	{
		traverseBoundary(starting_point);
	}
}

sf::Vector2i ImageOutlineFinder::findStartingPoint() const
{

	for (unsigned int cx = 1; cx < image_.getSize().x; cx++) {
		for (unsigned int cy = 1; cy < image_.getSize().y; cy++) {
			if (isBoundary({ static_cast<int>(cx), static_cast<int>(cy) })) {
				return { static_cast<int>(cx), static_cast<int>(cy) };
			}
		}
	}
	return {-1, -1};
}

void ImageOutlineFinder::traverseBoundary(const sf::Vector2i starting_point)
{
	const sf::Vector2i start = sf::Vector2i(starting_point.x, starting_point.y);
	sf::Vector2i next = start;
	sf::Vector2i old = sf::Vector2i(-1, -1);
<commit_msg>some fix image tracing of in some fringe cases<commit_after>#include "ImageOutlineFinder.h"
#include "FMath.h"

#include <poly2tri.h>
#include <iostream>

#include "../liquidfun_contrib/ConvexDecomposition/b2Polygon.h"


ImageOutlineFinder::ImageOutlineFinder()
= default;

ImageOutlineFinder::~ImageOutlineFinder()
= default;

void ImageOutlineFinder::findOutLines(const sf::Image& image, const int alpha_threshold)
{
	alpha_threshold_ = alpha_threshold;
	image_ = image;
	const sf::Vector2i starting_point = findStartingPoint();
	if (starting_point.x > -1)
	{
		traverseBoundary({ starting_point.x + 1, starting_point.y + 1 });
	}
}

sf::Vector2i ImageOutlineFinder::findStartingPoint() const
{
	for (unsigned int cx = 1; cx < image_.getSize().x; cx++) {
		for (unsigned int cy = 1; cy < image_.getSize().y; cy++) {
			if (isBoundary({ static_cast<int>(cx), static_cast<int>(cy) })) {
				return { static_cast<int>(cx), static_cast<int>(cy) };
			}
		}
	}
	return {-1, -1};
}

void ImageOutlineFinder::traverseBoundary(const sf::Vector2i starting_point)
{
	const sf::Vector2i start = sf::Vector2i(starting_point.x, starting_point.y);
	sf::Vector2i next = start;
	sf::Vector2i old = sf::Vector2i(-1, -1);

{'fraction_non_alphanumeric': 0.1511925042589438, 'fraction_numerical': 0.015332197614991482, 'mean_word_length': 5.769452449567724, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2196641', 'n_tokens_mistral': 886, 'n_tokens_neox': 854, 'n_words': 168}