/*************************************************************************** * Copyright (C) 2005 by Torben Nielsen * * torben@t-hoerup.dk * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "containerminimalvector.h" #include #include "solution.h" ContainerMinimalVector::ContainerMinimalVector(GUIUpdate* update): SolutionContainer(update) { m_total = 0; } ContainerMinimalVector::~ContainerMinimalVector() { } int ContainerMinimalVector::getUniqueRemoved() { return m_total - m_solutions.size(); } int ContainerMinimalVector::numSolutions() { return m_solutions.size(); } int ContainerMinimalVector::totalSolutions() { return m_total; } Solution* ContainerMinimalVector::solution(int index) { return m_solutions[index].get(); } void ContainerMinimalVector::addSolution(Solution* sol) { std::auto_ptr norm1( sol->copy() ); std::auto_ptr norm2( sol->copy() ); std::auto_ptr norm3( sol->copy() ); std::auto_ptr mirror1( sol->copy() ); std::auto_ptr mirror2( sol->copy() ); std::auto_ptr mirror3( sol->copy() ); std::auto_ptr mirror4( sol->copy() ); bool found = false; norm1->rotate90(); norm2->rotate90(); norm2->rotate90(); norm3->rotate90(); norm3->rotate90(); norm3->rotate90(); mirror1->mirror(); mirror2->mirror(); mirror2->rotate90(); mirror3->mirror(); mirror3->rotate90(); mirror3->rotate90(); mirror4->mirror(); mirror4->rotate90(); mirror4->rotate90(); mirror4->rotate90(); for (VIt it = m_solutions.begin(); it != m_solutions.end() && found == false; it++) { if ( *norm1 == *(*it) || *norm2 == *(*it) || *norm3 == *(*it) || *mirror1 == *(*it) || *mirror2 == *(*it) || *mirror3 == *(*it) || *mirror4 == *(*it)) { found = true; break; } } if (found == false) { m_solutions.push_back( boost::shared_ptr(sol) ); } m_total++; } void ContainerMinimalVector::uniqueSolutions() { // Do nothing }