Index: src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp
===================================================================
--- src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp	(revision 2199c270b5bb1c4a866b5b3db213f32babe7c222)
+++ src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp	(revision 450adf0e68db3480279d96bc40bfd5dc2ba3ec36)
@@ -245,4 +245,107 @@
 }
 
+/** UnitTest for joinPoints()
+ */
+void SphericalPointDistributionTest::joinPointsTest()
+{
+  // test with simple configuration of three points
+  {
+    SphericalPointDistribution::Polygon_t newpolygon;
+    newpolygon += Vector(1.,0.,0.);
+    newpolygon += Vector(0.,1.,0.);
+    newpolygon += Vector(0.,0.,1.);
+    SphericalPointDistribution::Polygon_t expectedpolygon = newpolygon;
+    SphericalPointDistribution::IndexTupleList_t matching;
+    matching += SphericalPointDistribution::IndexList_t(1,0);
+    matching += SphericalPointDistribution::IndexList_t(1,1);
+    matching += SphericalPointDistribution::IndexList_t(1,2);
+    SphericalPointDistribution::IndexList_t IndexList =
+        SphericalPointDistribution::joinPoints(
+            newpolygon,
+            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
+            matching);
+    SphericalPointDistribution::IndexList_t expected;
+    expected += 0,1,2;
+    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
+    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
+  }
+
+  // test with simple configuration of three points, only two are picked
+  {
+    SphericalPointDistribution::Polygon_t newpolygon;
+    newpolygon += Vector(1.,0.,0.);
+    newpolygon += Vector(0.,1.,0.);
+    newpolygon += Vector(0.,0.,1.);
+    SphericalPointDistribution::Polygon_t expectedpolygon = newpolygon;
+    SphericalPointDistribution::IndexTupleList_t matching;
+    matching += SphericalPointDistribution::IndexList_t(1,1);
+    matching += SphericalPointDistribution::IndexList_t(1,2);
+    SphericalPointDistribution::IndexList_t IndexList =
+        SphericalPointDistribution::joinPoints(
+            newpolygon,
+            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
+            matching);
+    SphericalPointDistribution::IndexList_t expected;
+    expected += 1,2;
+    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
+    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
+  }
+
+  // test with simple configuration of three points, two are joined
+  {
+    SphericalPointDistribution::Polygon_t newpolygon;
+    newpolygon += Vector(1.,0.,0.);
+    newpolygon += Vector(0.,1.,0.);
+    newpolygon += Vector(0.,0.,1.);
+    SphericalPointDistribution::Polygon_t expectedpolygon;
+    expectedpolygon += Vector(1.,0.,0.);
+    expectedpolygon += Vector(0.,M_SQRT1_2,M_SQRT1_2);
+    SphericalPointDistribution::IndexTupleList_t matching;
+    SphericalPointDistribution::IndexList_t joined;
+    joined += 1,2;
+    matching += SphericalPointDistribution::IndexList_t(1,0);
+    matching += joined;
+    SphericalPointDistribution::IndexList_t IndexList =
+        SphericalPointDistribution::joinPoints(
+            newpolygon,
+            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
+            matching);
+    SphericalPointDistribution::IndexList_t expected;
+    expected += 0,1;
+    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
+    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
+  }
+
+  // test with simple configuration of six points, two are joined, jumbled indices
+  {
+    SphericalPointDistribution::Polygon_t newpolygon;
+    newpolygon += Vector(1.,0.,1.);
+    newpolygon += Vector(1.,0.,0.);
+    newpolygon += Vector(1.,1.,0.);
+    newpolygon += Vector(0.,1.,0.);
+    newpolygon += Vector(0.,0.,1.);
+    newpolygon += Vector(1.,0.,1.);
+    SphericalPointDistribution::Polygon_t expectedpolygon;
+    expectedpolygon += Vector(1.,0.,1.);
+    expectedpolygon += Vector(1.,0.,0.);
+    expectedpolygon += Vector(1.,1.,0.);
+    expectedpolygon += Vector(1.,0.,1.);
+    expectedpolygon += Vector(0.,M_SQRT1_2,M_SQRT1_2); // new centers go last
+    SphericalPointDistribution::IndexTupleList_t matching;
+    SphericalPointDistribution::IndexList_t joined;
+    joined += 3,4;
+    matching += SphericalPointDistribution::IndexList_t(1,1);
+    matching += joined;
+    SphericalPointDistribution::IndexList_t IndexList =
+        SphericalPointDistribution::joinPoints(
+            newpolygon,
+            SphericalPointDistribution::VectorArray_t(newpolygon.begin(), newpolygon.end()),
+            matching);
+    SphericalPointDistribution::IndexList_t expected;
+    expected += 1,4;
+    CPPUNIT_ASSERT_EQUAL( expected, IndexList );
+    CPPUNIT_ASSERT_EQUAL( expectedpolygon, newpolygon );
+  }
+}
 
 /** UnitTest for matchSphericalPointDistributions() with three points
