/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2012 University of Bonn. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder 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.
*
* MoleCuilder 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 MoleCuilder. If not, see .
*/
/*
* LinkedCell.cpp
*
* Created on: Nov 15, 2011
* Author: heber
*/
// include config.h
#ifdef HAVE_CONFIG_H
#include
#endif
#include "LinkedCell/types.hpp"
//#include "CodePatterns/MemDebug.hpp"
#include
#include "CodePatterns/Assert.hpp"
#include "LinkedCell/LinkedCell.hpp"
#include "Atom/TesselPoint.hpp"
LinkedCell::LinkedCell::LinkedCell(const tripleIndex &_indices) :
indices(_indices)
{}
LinkedCell::LinkedCell::~LinkedCell()
{
// prevent us from deleting any contained points
clear();
}
const LinkedCell::tripleIndex& LinkedCell::LinkedCell::getIndices() const
{
return indices;
}
const LinkedCell::LinkedCellArray::index& LinkedCell::LinkedCell::getIndex(const size_t index) const
{
ASSERT((index >=0) && (index <=2),
"LinkedCell::getIndex() - given index "+toString(index)+" is out of bounds [0,2].");
return indices[index];
}
/** Add \a *point to this LinkedCell.
*
* @param point point to add
*/
void LinkedCell::LinkedCell::addPoint(const TesselPoint *point)
{
push_back(point);
}
/** Remove \a *point from this LinkedCell.
*
* We do nothing if point is not found.
*
* @param point point to remove
*/
void LinkedCell::LinkedCell::deletePoint(const TesselPoint *point)
{
LinkedList::iterator iter = std::find(begin(), end(), point);
ASSERT( iter != end(),
"LinkedCell::LinkedCell::deletePoint() - "+toString(*point)+" not present in this cell.");
if (iter != end())
erase(iter);
}