Index: src/Filling/Filler.cpp
===================================================================
--- src/Filling/Filler.cpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
+++ src/Filling/Filler.cpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
@@ -0,0 +1,104 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Filler.cpp
+ *
+ *  Created on: Jan 16, 2012
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <algorithm>
+#include <boost/bind.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <sstream>
+#include <vector>
+
+#include "Filler.hpp"
+
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+
+#include "Atom/atom.hpp"
+#include "ClusterInterface.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "NodeTypes.hpp"
+#include "Predicates/FillPredicate.hpp"
+#include "Predicates/Ops_FillPredicate.hpp"
+#include "World.hpp"
+
+
+/** Constructor for class Filler.
+ *
+ * \note We store inverted \a _predicate because we need it only for
+ * remove_copy_if which works in this inverted way as desired.
+ *
+ * @param mesh Mesh with a NodeSet that fills its Shape
+ * @param predicate predicate construct to check at each Node
+ */
+Filler::Filler(const Mesh &_mesh, const FillPredicate &_predicate) :
+  mesh(_mesh),
+  predicate(!_predicate)
+{}
+
+/** Destructor for class Filler.
+ *
+ */
+Filler::~Filler()
+{}
+
+/** Fill in the desired Cluster at each remaining node.
+ *
+ * \note The cluster is non-const because it is moved to the first vacant node.
+ *
+ * @param copyMethod functor that knows how to copy atoms.
+ * @param cluster set of atomic ids contained in a specific Shape to fill each Node with
+ */
+void Filler::operator()(
+    CopyAtomsInterface &copyMethod,
+    ClusterInterface::Cluster_impl cluster) const
+{
+  const NodeSet &nodes = mesh.getNodes();
+  std::stringstream output;
+  std::for_each( nodes.begin(), nodes.end(), output << boost::lambda::_1 << " ");
+  LOG(1, "INFO: Listing nodes to check: " << output.str());
+  if (nodes.size() == 0) {
+    ASSERT(false,
+      "Filler::operator() - Mesh contains no nodes.");
+    return;
+  }
+  NodeSet FillNodes(nodes.size(), zeroVec);
+
+  // evaluate predicate and gather into new set
+  NodeSet::iterator transform_end  =
+      std::remove_copy_if(nodes.begin(), nodes.end(), FillNodes.begin(), predicate );
+  FillNodes.erase(transform_end, FillNodes.end());
+
+  if (FillNodes.size() == 0) {
+    LOG(1, "INFO: For none of the nodes did the predicate return true.");
+    return;
+  }
+
+  // skip first node (as we must keep the original atoms)
+  NodeSet::iterator iter = ++FillNodes.begin();
+
+  // fill all other true nodes
+  std::for_each(iter , FillNodes.end(),
+      boost::bind(&ClusterInterface::clone, boost::cref(cluster), boost::ref(copyMethod), _1) );
+
+  // move cluster to first node
+  cluster->translate(*FillNodes.begin());
+}
Index: src/Filling/Filler.hpp
===================================================================
--- src/Filling/Filler.hpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
+++ src/Filling/Filler.hpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
@@ -0,0 +1,47 @@
+/*
+ * Filler.hpp
+ *
+ *  Created on: Jan 16, 2012
+ *      Author: heber
+ */
+
+#ifndef FILLER_HPP_
+#define FILLER_HPP_
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Cluster.hpp"
+#include "Predicates/FillPredicate.hpp"
+#include "Mesh/Mesh.hpp"
+#include "NodeTypes.hpp"
+
+class CopyAtomsInterface;
+class FillPredicate;
+class Mesh;
+
+/** This class operators on a set of nodes (Vector's), checks which fulfill some
+ * given predicate, and fills these position with a given molecule lateron.
+ *
+ */
+class Filler
+{
+public:
+  Filler(const Mesh &_mesh, const FillPredicate &_predicate);
+  ~Filler();
+
+  void operator()(CopyAtomsInterface &copyMethod, ClusterInterface::Cluster_impl cluster) const;
+
+private:
+  //!> mesh is the set of points filling a Shape
+  const Mesh mesh;
+  //!> the predicate is evaluted whether a Node in the NodeSet of mesh is filled or not
+  const FillPredicate predicate;
+
+};
+
+
+#endif /* FILLER_HPP_ */
Index: src/Filling/Makefile.am
===================================================================
--- src/Filling/Makefile.am	(revision 5d81e514140621e03b61d2bd770397f6d45321d3)
+++ src/Filling/Makefile.am	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
@@ -6,4 +6,5 @@
 	Filling/Mesh/CubeMesh.cpp \
 	Filling/Mesh/Mesh.cpp \
+	Filling/Filler.cpp \
 	Filling/Predicates/AnyFillPredicate.cpp \
 	Filling/Predicates/FillPredicate.cpp \
@@ -18,4 +19,5 @@
 	Filling/Mesh/CubeMesh.hpp \
 	Filling/Mesh/Mesh.hpp \
+	Filling/Filler.hpp \
 	Filling/NodeTypes.hpp \
 	Filling/Predicates/AnyFillPredicate.hpp \
Index: src/Filling/unittests/FillerUnitTest.cpp
===================================================================
--- src/Filling/unittests/FillerUnitTest.cpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
+++ src/Filling/unittests/FillerUnitTest.cpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
@@ -0,0 +1,117 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * FillerUnitTest.cpp
+ *
+ *  Created on: Jan 19, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "Atom/atom.hpp"
+#include "Atom/CopyAtoms/CopyAtoms_Simple.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Element/periodentafel.hpp"
+#include "Filling/Cluster.hpp"
+#include "Filling/Filler.hpp"
+#include "Filling/Mesh/Mesh.hpp"
+#include "Filling/Predicates/FillPredicate.hpp"
+#include "LinearAlgebra/Vector.hpp"
+#include "molecule.hpp"
+#include "Shapes/BaseShapes.hpp"
+#include "Shapes/Shape.hpp"
+#include "World.hpp"
+#include "WorldTime.hpp"
+
+#include "FillerUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( FillerTest );
+
+
+class MeshStub : public Mesh
+{
+  public:
+  MeshStub() {
+    nodes.reserve(5);
+    for (double i=1; i<6.; ++i)
+      nodes.push_back(Vector(i,0.,0.));
+  }
+  virtual ~MeshStub()
+  {}
+};
+
+void FillerTest::setUp()
+{
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+  predicate = new FillPredicate(AlwaysFillPredicate());
+  mesh = new MeshStub();
+  CPPUNIT_ASSERT_EQUAL( (size_t)5, mesh->getNodes().size() );
+  filler = new Filler(*mesh, *predicate);
+  s = new Shape(Sphere( Vector(0.,0.,0.05), 0.1));
+
+  Cluster::atomIdSet atoms;
+
+  // create an atom
+  hydrogen = World::getInstance().getPeriode()->FindElement(1);
+  CPPUNIT_ASSERT(hydrogen != NULL);
+  _atom = World::getInstance().createAtom();
+  _atom->setType(hydrogen);
+  _atom->setPosition( zeroVec );
+  atoms.insert(_atom->getId());
+  _atom = World::getInstance().createAtom();
+  _atom->setType(hydrogen);
+  _atom->setPosition( Vector(0.,0.,0.1) );
+  atoms.insert(_atom->getId());
+
+  CPPUNIT_ASSERT( s->isInside(_atom->getPosition()) );
+  cluster = new ClusterInterface::Cluster_impl(new Cluster(atoms, *s));
+}
+
+
+void FillerTest::tearDown()
+{
+  hydrogen = NULL;
+  delete cluster;
+  delete filler;
+  delete mesh;
+  delete predicate;
+
+  World::purgeInstance();
+  WorldTime::purgeInstance();
+}
+
+/** Test whether operator() works
+ *
+ */
+void FillerTest::operatorTest()
+{
+  CopyAtoms_Simple copyMethod;
+  (*filler)(copyMethod, *cluster);
+
+  // one atom at 5 nodes added
+  CPPUNIT_ASSERT_EQUAL( mesh->getNodes().size()*2, World::getInstance().getAllAtoms().size() );
+}
Index: src/Filling/unittests/FillerUnitTest.hpp
===================================================================
--- src/Filling/unittests/FillerUnitTest.hpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
+++ src/Filling/unittests/FillerUnitTest.hpp	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
@@ -0,0 +1,55 @@
+/*
+ * FillerUnitTest.hpp
+ *
+ *  Created on: Jan 19, 2012
+ *      Author: heber
+ */
+
+#ifndef FILLERUNITTEST_HPP_
+#define FILLERUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <boost/shared_ptr.hpp>
+
+#include "types.hpp"
+
+class atom;
+class Cluster;
+class Filler;
+class FillPredicate;
+class Mesh;
+class Shape;
+class ClusterInterface;
+typedef boost::shared_ptr<ClusterInterface> Cluster_impl;
+
+/********************************************** Test classes **************************************/
+
+class FillerTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( FillerTest) ;
+    CPPUNIT_TEST ( operatorTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void operatorTest();
+
+private:
+      FillPredicate *predicate;
+      Mesh *mesh;
+      Filler *filler;
+      atom * _atom;
+      Shape *s;
+      const element * hydrogen;
+      Cluster_impl *cluster;
+};
+
+#endif /* FILLERUNITTEST_HPP_ */
Index: src/Filling/unittests/Makefile.am
===================================================================
--- src/Filling/unittests/Makefile.am	(revision 5d81e514140621e03b61d2bd770397f6d45321d3)
+++ src/Filling/unittests/Makefile.am	(revision d505a3699ad22730219478f69fe1a8ad8b608c2f)
@@ -4,4 +4,5 @@
 FILLINGTESTSSOURCES = \
   ../Filling/unittests/ClusterUnitTest.cpp \
+  ../Filling/unittests/FillerUnitTest.cpp \
   ../Filling/unittests/IsInsideDomain_FillPredicateUnitTest.cpp \
   ../Filling/unittests/IsInsideSurface_FillPredicateUnitTest.cpp \
@@ -12,4 +13,5 @@
 FILLINGTESTSHEADERS = \
   ../Filling/unittests/ClusterUnitTest.hpp \
+  ../Filling/unittests/FillerUnitTest.hpp \
   ../Filling/unittests/IsInsideDomain_FillPredicateUnitTest.hpp \
   ../Filling/unittests/IsInsideSurface_FillPredicateUnitTest.hpp \
@@ -20,4 +22,5 @@
 FILLINGTESTS = \
   ClusterUnitTest \
+  FillerUnitTest \
   IsInsideDomain_FillPredicateUnitTest \
   IsInsideSurface_FillPredicateUnitTest \
@@ -36,4 +39,15 @@
 	../Filling/unittests/ClusterUnitTest.hpp
 ClusterUnitTest_LDADD = \
+	../libMolecuilderFilling.la \
+	../libMolecuilderUI.la \
+	../libMolecuilder.la \
+	$(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
+	${CodePatterns_LIBS} \
+	$(BOOST_LIBS)
+
+FillerUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	../Filling/unittests/FillerUnitTest.cpp \
+	../Filling/unittests/FillerUnitTest.hpp
+FillerUnitTest_LDADD = \
 	../libMolecuilderFilling.la \
 	../libMolecuilderUI.la \
