| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2012 University of Bonn. All rights reserved.
|
|---|
| 5 | *
|
|---|
| 6 | *
|
|---|
| 7 | * This file is part of MoleCuilder.
|
|---|
| 8 | *
|
|---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
|---|
| 10 | * it under the terms of the GNU General Public License as published by
|
|---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
|---|
| 12 | * (at your option) any later version.
|
|---|
| 13 | *
|
|---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 17 | * GNU General Public License for more details.
|
|---|
| 18 | *
|
|---|
| 19 | * You should have received a copy of the GNU General Public License
|
|---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | * IsVoidNode_FillPredicate.cpp
|
|---|
| 25 | *
|
|---|
| 26 | * Created on: Jan 16, 2012
|
|---|
| 27 | * Author: heber
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | // include config.h
|
|---|
| 31 | #ifdef HAVE_CONFIG_H
|
|---|
| 32 | #include <config.h>
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | //#include "CodePatterns/MemDebug.hpp"
|
|---|
| 36 |
|
|---|
| 37 | #include <boost/bind.hpp>
|
|---|
| 38 |
|
|---|
| 39 | #include "IsVoidNode_FillPredicate.hpp"
|
|---|
| 40 |
|
|---|
| 41 | #include "CodePatterns/Log.hpp"
|
|---|
| 42 |
|
|---|
| 43 | #include "Atom/TesselPoint.hpp"
|
|---|
| 44 | #include "LinkedCell/LinkedCell_View.hpp"
|
|---|
| 45 | #include "Shapes/ShapeOps.hpp"
|
|---|
| 46 | #include "Tesselation/tesselation.hpp"
|
|---|
| 47 | #include "World.hpp"
|
|---|
| 48 |
|
|---|
| 49 | #include "AnyFillPredicate.hpp"
|
|---|
| 50 | #include "FillPredicate.hpp"
|
|---|
| 51 |
|
|---|
| 52 | /** Checks whether a given node \a n in the domain is empty with respect to the
|
|---|
| 53 | * given \a shape.
|
|---|
| 54 | *
|
|---|
| 55 | * @param LC View of a linked cell structure for finding neighbors quickly
|
|---|
| 56 | * @param shape shape as a sort of placeholder
|
|---|
| 57 | * @param n point where to center the placeholder
|
|---|
| 58 | * @return true - placeholder at node contains no points,
|
|---|
| 59 | * false - there is at least one point contained
|
|---|
| 60 | */
|
|---|
| 61 | bool IsVoidNode(const LinkedCell::LinkedCell_View &LC, const Shape &shape, const Node &n)
|
|---|
| 62 | {
|
|---|
| 63 | LOG(3, "DEBUG: Node is " << n << ".");
|
|---|
| 64 | LOG(3, "DEBUG: Original shape is at " << shape.getCenter() << " with radius of "
|
|---|
| 65 | << shape.getRadius() << ".");
|
|---|
| 66 | const Shape shapeAtn = translate(shape, n);
|
|---|
| 67 | LOG(3, "DEBUG: Translated shape is at " << shapeAtn.getCenter() << ".");
|
|---|
| 68 | LinkedCell::LinkedList neighborlist = LC.getAllNeighbors(
|
|---|
| 69 | shapeAtn.getRadius(), shapeAtn.getCenter());
|
|---|
| 70 | LOG(3, "DEBUG: we have " << neighborlist.size() << " possible neighbors.");
|
|---|
| 71 | LinkedCell::LinkedList::const_iterator neighboriter =
|
|---|
| 72 | std::find_if(neighborlist.begin(), neighborlist.end(),
|
|---|
| 73 | boost::bind(&Shape::isInside, shapeAtn,
|
|---|
| 74 | boost::bind(&TesselPoint::getPosition, _1) ));
|
|---|
| 75 | return neighboriter == neighborlist.end();
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | FillPredicate IsVoidNode_FillPredicate(const Shape &_shape)
|
|---|
| 79 | {
|
|---|
| 80 | // copy _shape !
|
|---|
| 81 | const LinkedCell::LinkedCell_View LC = World::getInstance().getLinkedCell(_shape.getRadius());
|
|---|
| 82 | AnyFillPredicate::FillPredicator function = boost::bind(&IsVoidNode, LC, _shape, _1);
|
|---|
| 83 | LOG(2, "DEBUG: Create IsVoidNode_FillPredicate from shape at "
|
|---|
| 84 | << _shape.getCenter() << " and radius " << _shape.getRadius() << ".");
|
|---|
| 85 | FillPredicate::impl_ptr impl(new AnyFillPredicate(function));
|
|---|
| 86 | return FillPredicate(impl);
|
|---|
| 87 | }
|
|---|