/*
 * Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
 *
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 * claim that you wrote the original software. If you use this software
 * in a product, an acknowledgment in the product documentation would be
 * appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 * misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 *
 */

#include "OE_pattern.h"

OE_pattern::OE_pattern()
{
}

OE_pattern::OE_pattern(std::vector<vector_2d> _pts, float _defaultOffset, bool _endPoints, std::string _name)
{
	pts = _pts;
	endPoints = _endPoints;
	defaultOffset = _defaultOffset;
	name = _name;
}

void OE_pattern::persist(Pakal::Archive* archive)
{
	archive->value("pts", pts);
	archive->value("endPoints", endPoints);
	archive->value("defaultOffset", defaultOffset);
	archive->value("name", name);
}

std::list<OE_pattern*> OE_pattern::createStandardPatterns()
{
	std::list<OE_pattern*> standardPattern;
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0)},0, false, "straight"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
	                                          vector_2d(1, 0),
											  vector_2d(0, 0)},0, false, "triple straight"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 1),
											  vector_2d(0.5, 0)},0.5, false, "satin"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0, 1)},0.5, false, "stretch"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0.3, 1),
											  vector_2d(0.6, 0)},0.5, false, "overcast"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0, 1),
											  vector_2d(0, 0)},0.5, false, "applique"));
	standardPattern.push_back(new OE_pattern({vector_2d(1, 1),
											  vector_2d(0.5, 0.5),
											  vector_2d(0, 1),
											  vector_2d(1, 0)},0.5, false, "cross"));
	standardPattern.push_back(new OE_pattern({vector_2d(0, 0),
											  vector_2d(0.5, 0),
											  vector_2d(0.5, 0.6),
											  vector_2d(0.3, 0.8),
											  vector_2d(0.5, 1),
											  vector_2d(0.7, 0.8),
											  vector_2d(0.5, 0.6),
											  vector_2d(0.5, 0)},0.5, false, "applique circle"));
	standardPattern.push_back(new OE_pattern({vector_2d(0.5, 0.5),
											  vector_2d(0.8, 0.5),
											  vector_2d(0.2, 0.5),
											  vector_2d(0.5, 0.5),
											  vector_2d(0.5, 0.2),
											  vector_2d(0.5, 0.8),
											  vector_2d(0.5, 0.5),
											  vector_2d(0.3, 0.3),
											  vector_2d(0.7, 0.7),
											  vector_2d(0.5, 0.5),
											  vector_2d(0.7, 0.3),
											  vector_2d(0.3, 0.7),
											  vector_2d(0.5, 0.5)},0.5, false, "flower"));

	return standardPattern;
}

