[sfcgal] 01/06: Imported Upstream version 1.3.0

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Tue Mar 1 23:01:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository sfcgal.

commit 0482d7a33ddb5c16d1ca6efce5ef8fb47996f3a4
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Mar 1 23:43:22 2016 +0100

    Imported Upstream version 1.3.0
---
 CMakeLists.txt                                     |   29 +-
 NEWS                                               |   10 +
 .../boost-1.60.0/boost/graph/adjacency_matrix.hpp  | 1238 ++++++++++++++++++++
 src/Geometry.cpp                                   |   14 +-
 src/Geometry.h                                     |   17 +-
 src/Grid.cpp                                       |  138 ---
 src/Grid.h                                         |  239 ----
 src/algorithm/extrude.cpp                          |    4 +-
 src/algorithm/isValid.cpp                          |   74 +-
 src/algorithm/isValid.h                            |   71 +-
 src/algorithm/minkowskiSum.cpp                     |    4 +-
 src/algorithm/straightSkeleton.cpp                 |  165 ++-
 src/algorithm/straightSkeleton.h                   |   11 +-
 src/algorithm/union.cpp                            |    2 -
 src/capi/sfcgal_c.cpp                              |   62 +-
 src/capi/sfcgal_c.h                                |   30 +
 src/detail/ForceValidityVisitor.cpp                |  171 +++
 src/{io/asc.h => detail/ForceValidityVisitor.h}    |   42 +-
 src/detail/io/WktReader.cpp                        |   12 +-
 src/detail/tools/Log.h                             |    4 -
 src/detail/transform/AffineTransform2.cpp          |    6 +-
 src/detail/transform/AffineTransform3.cpp          |    5 +-
 src/detail/transform/Force2D.cpp                   |    5 +-
 src/detail/transform/ForceZ.cpp                    |    5 +-
 src/io/asc.cpp                                     |  125 --
 src/io/wkt.cpp                                     |   18 +-
 src/triangulate/triangulate2DZ.cpp                 |    2 +-
 test/bench/BenchPredicate.cpp                      |   73 ++
 test/data/CoversTest.txt                           |    4 +-
 test/garden/main.cpp                               |    5 +-
 test/regress/standalone/SFCGAL/ASCTest.cpp         |  102 --
 test/unit/SFCGAL/GridTest.cpp                      |  180 ---
 .../SFCGAL/algorithm/ApproximateMedialAxis.cpp     |   18 +-
 test/unit/SFCGAL/algorithm/DistanceTest.cpp        |    2 +-
 .../unit/SFCGAL/algorithm/StraightSkeletonTest.cpp |   16 +
 test/unit/SFCGAL/capi/sfcgal_cTest.cpp             |   20 +
 test/unit/SFCGAL/io/WktReaderTest.cpp              |   38 +-
 .../unit/SFCGAL/triangulate/Triangulate2DZTest.cpp |    4 -
 viewer/CMakeLists.txt                              |   40 -
 viewer/cmake/Modules/FindosgQt.cmake               |   50 -
 viewer/include/SFCGAL/viewer/GISManipulator.h      |   44 -
 viewer/include/SFCGAL/viewer/ViewerPlugin.h        |   74 --
 viewer/include/SFCGAL/viewer/ViewerWidget.h        |  102 --
 viewer/include/SFCGAL/viewer/ViewerWindow.h        |  112 --
 viewer/include/SFCGAL/viewer/plugins/DataPlugin.h  |   70 --
 viewer/include/SFCGAL/viewer/plugins/DemoPlugin.h  |   76 --
 viewer/include/SFCGAL/viewer/plugins/GridPlugin.h  |   67 --
 viewer/include/SFCGAL/viewer/plugins/PSQLPlugin.h  |  160 ---
 viewer/include/db.h                                |  274 -----
 viewer/main.cpp                                    |  105 --
 viewer/src/SFCGAL/viewer/GISManipulator.cpp        |   82 --
 viewer/src/SFCGAL/viewer/ViewerPlugin.cpp          |   67 --
 viewer/src/SFCGAL/viewer/ViewerWidget.cpp          |  353 ------
 viewer/src/SFCGAL/viewer/ViewerWindow.cpp          |  259 ----
 viewer/src/SFCGAL/viewer/plugins/DataPlugin.cpp    |  103 --
 viewer/src/SFCGAL/viewer/plugins/DemoPlugin.cpp    |  231 ----
 viewer/src/SFCGAL/viewer/plugins/GridPlugin.cpp    |  122 --
 viewer/src/SFCGAL/viewer/plugins/PSQLPlugin.cpp    |  553 ---------
 viewer/src/db.cpp                                  |   66 --
 59 files changed, 2019 insertions(+), 3956 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ecaebd..bbf7f24 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,14 +17,13 @@ endif()
 option( SFCGAL_BUILD_EXAMPLES "build examples" OFF )
 option( SFCGAL_BUILD_TESTS "build unit, garden and regress tests" OFF )
 option( SFCGAL_BUILD_BENCH "Build benchmarks" OFF )
-option( SFCGAL_BUILD_VIEWER "build viewer and OpenSceneGraph support (outputs in 3D formats)" OFF )
 
 #-- include finders and co
 set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules;${CMAKE_MODULE_PATH}" )
 
 set( SFCGAL_VERSION_MAJOR 1 )
-set( SFCGAL_VERSION_MINOR 2 )
-set( SFCGAL_VERSION_PATCH 2 )
+set( SFCGAL_VERSION_MINOR 3 )
+set( SFCGAL_VERSION_PATCH 0 )
 
 set( SFCGAL_VERSION "${SFCGAL_VERSION_MAJOR}.${SFCGAL_VERSION_MINOR}.${SFCGAL_VERSION_PATCH}" )
 
@@ -68,7 +67,7 @@ if ( SFCGAL_BUILD_TESTS )
 	set( SFCGAL_Boost_COMPONENTS unit_test_framework program_options ${SFCGAL_Boost_COMPONENTS} )
 endif()
 #-- program_options
-if ( SFCGAL_BUILD_TESTS OR SFCGAL_BUILD_EXAMPLES OR SFCGAL_BUILD_OSG OR SFCGAL_BUILD_VIEWER )
+if ( SFCGAL_BUILD_TESTS OR SFCGAL_BUILD_EXAMPLES OR SFCGAL_BUILD_OSG )
 	set( SFCGAL_Boost_COMPONENTS program_options chrono filesystem timer ${SFCGAL_Boost_COMPONENTS} )
 endif()
 find_package( Boost COMPONENTS ${SFCGAL_Boost_COMPONENTS} REQUIRED )
@@ -76,6 +75,10 @@ if((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 58))
 	message( STATUS "Defining BOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT" )
 	add_definitions( "-DBOOST_VARIANT_USE_RELAXED_GET_BY_DEFAULT" )
 endif()
+# patch boost 1.60.0      
+if((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 60) AND (${Boost_SUBMINOR_VERSION} EQUAL 0))
+  include_directories( patches/boost-1.60.0 )
+endif()
 
 #-- GMP (facultative)  -------------------------------------
 find_package( GMP )
@@ -137,18 +140,6 @@ link_directories(
 	${GMP_LIBRARY_DIRS}	
 )
 
-#-- optional OpenSceneGraph support
-if ( SFCGAL_BUILD_VIEWER )
-	find_package( OpenSceneGraph COMPONENTS osgDB osgUtil REQUIRED )
-	include_directories( SYSTEM ${OPENSCENEGRAPH_INCLUDE_DIRS} ) 
-	
-	# config.h generation
-	set( SFCGAL_WITH_OSG "ON" )
-	add_subdirectory( viewer )
-endif()
-
-
-
 #-- Warnings, frounding-math and gprof  ------------------------------------------
 option( SFCGAL_WARNING_AS_ERROR "fail the build on warnings" OFF )
 option( SFCGAL_BUILD_WITH_GPROF "build with gprof" OFF )
@@ -211,12 +202,6 @@ enable_testing()
 #note : not available on windows without export/import
 OPTION( SFCGAL_USE_STATIC_LIBS "define if SFCGAL is build as a static library" OFF )
 
-# option : do we check geometry validity before each processing ?
-option( SFCGAL_CHECK_VALIDITY "Always checks geometry validity" ON )
-if ( NOT SFCGAL_CHECK_VALIDITY )
-  add_definitions( "-DSFCGAL_NEVER_CHECK_VALIDITY" )
-endif()
-
 #-- build the library
 add_subdirectory( src )
 
diff --git a/NEWS b/NEWS
index 11828f8..34dcdab 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,16 @@
+1.3.0 (2016-02-29):
+    * Add a validity flag to geometries
+    * Add an option to straight skeleton to return the distance to borders
+    * Add sfcgal_geometry_is_valid_detail to the C API
+    * Remove grid and ASC reader
+    * Remove the viewer
+    * Fix compilation issue with boost 1.60 (#119)
+    * Fix WKT parsing issues (#81 #117)
+    * Retain bisectors of narrow angles in MedialAxis output
 1.2.2 (2015-11-16):
     * Fix compilation issues with CGAL 4.7
     * Fix Travis CI support for CGAL 4.3 and CGAL 4.7
+    * Fix potential crash in StraightSkeleton (#111)
 1.2.1 - invalid release
 1.2.0 (2015-09-18):
     * Improve the computation speed of straight skeletons by using an inexact construction kernel
diff --git a/patches/boost-1.60.0/boost/graph/adjacency_matrix.hpp b/patches/boost-1.60.0/boost/graph/adjacency_matrix.hpp
new file mode 100644
index 0000000..e00970c
--- /dev/null
+++ b/patches/boost-1.60.0/boost/graph/adjacency_matrix.hpp
@@ -0,0 +1,1238 @@
+//=======================================================================
+// Copyright 2001 University of Notre Dame.
+// Copyright 2006 Trustees of Indiana University
+// Authors: Jeremy G. Siek and Douglas Gregor <dgregor at cs.indiana.edu>
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//=======================================================================
+
+#ifndef BOOST_ADJACENCY_MATRIX_HPP
+#define BOOST_ADJACENCY_MATRIX_HPP
+
+#include <boost/config.hpp>
+#include <vector>
+#include <memory>
+#include <boost/assert.hpp>
+#include <boost/limits.hpp>
+#include <boost/iterator.hpp>
+#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/graph_mutability_traits.hpp>
+#include <boost/graph/graph_selectors.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/graph/adjacency_iterator.hpp>
+#include <boost/graph/detail/edge.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/iterator/filter_iterator.hpp>
+#include <boost/range/irange.hpp>
+#include <boost/graph/properties.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/property_map/property_map.hpp>
+#include <boost/property_map/transform_value_property_map.hpp>
+#include <boost/property_map/function_property_map.hpp>
+
+namespace boost {
+
+  namespace detail {
+
+    template <class Directed, class Vertex>
+    class matrix_edge_desc_impl : public edge_desc_impl<Directed,Vertex>
+    {
+      typedef edge_desc_impl<Directed,Vertex> Base;
+    public:
+      matrix_edge_desc_impl() { }
+      matrix_edge_desc_impl(bool exists, Vertex s, Vertex d,
+                            const void* ep = 0)
+        : Base(s, d, ep), m_exists(exists) { }
+      bool exists() const { return m_exists; }
+    private:
+      bool m_exists;
+    };
+
+    struct does_edge_exist {
+      template <class Edge>
+      bool operator()(const Edge& e) const { return e.exists(); }
+    };
+
+    // Note to self... The int for get_edge_exists and set_edge exist helps
+    // make these calls unambiguous.
+    template <typename EdgeProperty>
+    bool get_edge_exists(const std::pair<bool, EdgeProperty>& stored_edge, int) {
+      return stored_edge.first;
+    }
+    template <typename EdgeProperty>
+    void set_edge_exists(
+        std::pair<bool, EdgeProperty>& stored_edge,
+        bool flag,
+        int
+        ) {
+      stored_edge.first = flag;
+    }
+
+    template <typename EdgeProxy>
+    bool get_edge_exists(const EdgeProxy& edge_proxy, ...) {
+      return edge_proxy;
+    }
+    template <typename EdgeProxy>
+    EdgeProxy& set_edge_exists(EdgeProxy& edge_proxy, bool flag, ...) {
+      edge_proxy = flag;
+      return edge_proxy; // just to avoid never used warning
+    }
+
+
+    // NOTE: These functions collide with the get_property function for
+    // accessing bundled graph properties. Be excplicit when using them.
+    template <typename EdgeProperty>
+    const EdgeProperty&
+    get_edge_property(const std::pair<bool, EdgeProperty>& stored_edge) {
+      return stored_edge.second;
+    }
+    template <typename EdgeProperty>
+    EdgeProperty&
+    get_edge_property(std::pair<bool, EdgeProperty>& stored_edge) {
+      return stored_edge.second;
+    }
+
+    template <typename StoredEdgeProperty, typename EdgeProperty>
+    inline void
+    set_edge_property(std::pair<bool, StoredEdgeProperty>& stored_edge,
+                      const EdgeProperty& ep, int) {
+      stored_edge.second = ep;
+    }
+
+    inline const no_property& get_edge_property(const char&) {
+      static no_property s_prop;
+      return s_prop;
+    }
+    inline no_property& get_edge_property(char&) {
+      static no_property s_prop;
+      return s_prop;
+    }
+    template <typename EdgeProxy, typename EdgeProperty>
+    inline void set_edge_property(EdgeProxy, const EdgeProperty&, ...) {}
+
+    //=======================================================================
+    // Directed Out Edge Iterator
+
+    template <
+        typename VertexDescriptor, typename MatrixIter
+      , typename VerticesSizeType, typename EdgeDescriptor
+    >
+    struct dir_adj_matrix_out_edge_iter
+      : iterator_adaptor<
+            dir_adj_matrix_out_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        >
+    {
+        typedef iterator_adaptor<
+            dir_adj_matrix_out_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        > super_t;
+
+        dir_adj_matrix_out_edge_iter() { }
+
+        dir_adj_matrix_out_edge_iter(
+            const MatrixIter& i
+          , const VertexDescriptor& src
+          , const VerticesSizeType& n
+           )
+            : super_t(i), m_src(src), m_targ(0), m_n(n)
+        { }
+
+        void increment() {
+            ++this->base_reference();
+            ++m_targ;
+        }
+
+        inline EdgeDescriptor
+        dereference() const
+        {
+            return EdgeDescriptor(get_edge_exists(*this->base(), 0),
+                                  m_src, m_targ,
+                                  &get_edge_property(*this->base()));
+        }
+        VertexDescriptor m_src, m_targ;
+        VerticesSizeType m_n;
+    };
+
+    //=======================================================================
+    // Directed In Edge Iterator
+
+    template <
+        typename VertexDescriptor, typename MatrixIter
+      , typename VerticesSizeType, typename EdgeDescriptor
+    >
+    struct dir_adj_matrix_in_edge_iter
+      : iterator_adaptor<
+            dir_adj_matrix_in_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        >
+    {
+        typedef iterator_adaptor<
+            dir_adj_matrix_in_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        > super_t;
+
+        dir_adj_matrix_in_edge_iter() { }
+
+        dir_adj_matrix_in_edge_iter(
+            const MatrixIter& i
+          , const MatrixIter& last
+          , const VertexDescriptor& tgt
+          , const VerticesSizeType& n
+           )
+          : super_t(i), m_last(last), m_src(0), m_targ(tgt), m_n(n)
+        { }
+
+        void increment() {
+          if (VerticesSizeType(m_last - this->base_reference()) >= m_n) {
+            this->base_reference() += m_n;
+            ++m_src;
+          } else {
+            this->base_reference() = m_last;
+          }
+        }
+
+        inline EdgeDescriptor
+        dereference() const
+        {
+            return EdgeDescriptor(get_edge_exists(*this->base(), 0),
+                                  m_src, m_targ,
+                                  &get_edge_property(*this->base()));
+        }
+        MatrixIter m_last;
+        VertexDescriptor m_src, m_targ;
+        VerticesSizeType m_n;
+    };
+
+    //=======================================================================
+    // Undirected Out Edge Iterator
+
+    template <
+        typename VertexDescriptor, typename MatrixIter
+      , typename VerticesSizeType, typename EdgeDescriptor
+    >
+    struct undir_adj_matrix_out_edge_iter
+      : iterator_adaptor<
+            undir_adj_matrix_out_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        >
+    {
+        typedef iterator_adaptor<
+            undir_adj_matrix_out_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        > super_t;
+
+        undir_adj_matrix_out_edge_iter() { }
+
+        undir_adj_matrix_out_edge_iter(
+            const MatrixIter& i
+          , const VertexDescriptor& src
+          , const VerticesSizeType& n
+        )
+          : super_t(i), m_src(src), m_inc(src), m_targ(0), m_n(n)
+        {}
+
+        void increment()
+        {
+            if (m_targ < m_src)     // first half
+            {
+                ++this->base_reference();
+            }
+            else if (m_targ < m_n - 1)
+            {                  // second half
+                ++m_inc;
+                this->base_reference() += m_inc;
+            }
+            else
+            {                  // past-the-end
+                this->base_reference() += m_n - m_src;
+            }
+            ++m_targ;
+        }
+
+        inline EdgeDescriptor
+        dereference() const
+        {
+            return EdgeDescriptor(get_edge_exists(*this->base(), 0),
+                                  m_src, m_targ,
+                                  &get_edge_property(*this->base()));
+        }
+
+        VertexDescriptor m_src, m_inc, m_targ;
+        VerticesSizeType m_n;
+    };
+
+    //=======================================================================
+    // Undirected In Edge Iterator
+
+    template <
+        typename VertexDescriptor, typename MatrixIter
+      , typename VerticesSizeType, typename EdgeDescriptor
+    >
+    struct undir_adj_matrix_in_edge_iter
+      : iterator_adaptor<
+            undir_adj_matrix_in_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        >
+    {
+        typedef iterator_adaptor<
+            undir_adj_matrix_in_edge_iter<VertexDescriptor, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        > super_t;
+
+        undir_adj_matrix_in_edge_iter() { }
+
+        undir_adj_matrix_in_edge_iter(
+            const MatrixIter& i
+          , const VertexDescriptor& src
+          , const VerticesSizeType& n
+        )
+          : super_t(i), m_src(src), m_inc(src), m_targ(0), m_n(n)
+        {}
+
+        void increment()
+        {
+            if (m_targ < m_src)     // first half
+            {
+                ++this->base_reference();
+            }
+            else if (m_targ < m_n - 1)
+            {                  // second half
+                ++m_inc;
+                this->base_reference() += m_inc;
+            }
+            else
+            {                  // past-the-end
+                this->base_reference() += m_n - m_src;
+            }
+            ++m_targ;
+        }
+
+        inline EdgeDescriptor
+        dereference() const
+        {
+            return EdgeDescriptor(get_edge_exists(*this->base(), 0),
+                                  m_targ, m_src,
+                                  &get_edge_property(*this->base()));
+        }
+
+        VertexDescriptor m_src, m_inc, m_targ;
+        VerticesSizeType m_n;
+    };
+
+    //=======================================================================
+    // Edge Iterator
+
+    template <typename Directed, typename MatrixIter,
+              typename VerticesSizeType, typename EdgeDescriptor>
+    struct adj_matrix_edge_iter
+      : iterator_adaptor<
+            adj_matrix_edge_iter<Directed, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        >
+    {
+        typedef iterator_adaptor<
+            adj_matrix_edge_iter<Directed, MatrixIter,  VerticesSizeType, EdgeDescriptor>
+          , MatrixIter
+          , EdgeDescriptor
+          , use_default
+          , EdgeDescriptor
+          , std::ptrdiff_t
+        > super_t;
+
+        adj_matrix_edge_iter() { }
+
+        adj_matrix_edge_iter(const MatrixIter& i, const MatrixIter& start, const VerticesSizeType& n)
+            : super_t(i), m_start(start), m_src(0), m_targ(0), m_n(n) { }
+
+        void increment()
+        {
+            increment_dispatch(this->base_reference(), Directed());
+        }
+
+        void increment_dispatch(MatrixIter& i, directedS)
+        {
+            ++i;
+            if (m_targ == m_n - 1)
+            {
+                m_targ = 0;
+                ++m_src;
+            }
+            else
+            {
+                ++m_targ;
+            }
+        }
+
+        void increment_dispatch(MatrixIter& i, undirectedS)
+        {
+            ++i;
+            if (m_targ == m_src)
+            {
+                m_targ = 0;
+                ++m_src;
+            }
+            else
+            {
+                ++m_targ;
+            }
+        }
+
+        inline EdgeDescriptor
+        dereference() const
+        {
+            return EdgeDescriptor(get_edge_exists(*this->base(), 0),
+                                  m_src, m_targ,
+                                  &get_edge_property(*this->base()));
+        }
+
+        MatrixIter m_start;
+        VerticesSizeType m_src, m_targ, m_n;
+    };
+
+  } // namespace detail
+
+  //=========================================================================
+  // Adjacency Matrix Traits
+  template <typename Directed = directedS>
+  class adjacency_matrix_traits {
+    typedef typename Directed::is_directed_t is_directed;
+  public:
+    // The bidirectionalS tag is not allowed with the adjacency_matrix
+    // graph type. Instead, use directedS, which also provides the
+    // functionality required for a Bidirectional Graph (in_edges,
+    // in_degree, etc.)
+
+    // SFCGAL quick fix issue #119
+    // BOOST_STATIC_ASSERT(type_traits::ice_not<(is_same<Directed, bidirectionalS>::value)>::value);
+    BOOST_STATIC_ASSERT( ! is_same<Directed, bidirectionalS>::value );
+
+    typedef typename mpl::if_<is_directed,
+                                    bidirectional_tag, undirected_tag>::type
+      directed_category;
+
+    typedef disallow_parallel_edge_tag edge_parallel_category;
+
+    typedef std::size_t vertex_descriptor;
+
+    typedef detail::matrix_edge_desc_impl<directed_category,
+      vertex_descriptor> edge_descriptor;
+  };
+
+  struct adjacency_matrix_class_tag { };
+
+  struct adj_matrix_traversal_tag :
+    public virtual adjacency_matrix_tag,
+    public virtual vertex_list_graph_tag,
+    public virtual incidence_graph_tag,
+    public virtual adjacency_graph_tag,
+    public virtual edge_list_graph_tag { };
+
+  //=========================================================================
+  // Adjacency Matrix Class
+  template <typename Directed = directedS,
+            typename VertexProperty = no_property,
+            typename EdgeProperty = no_property,
+            typename GraphProperty = no_property,
+            typename Allocator = std::allocator<bool> >
+  class adjacency_matrix {
+    typedef adjacency_matrix self;
+    typedef adjacency_matrix_traits<Directed> Traits;
+
+  public:
+    // The bidirectionalS tag is not allowed with the adjacency_matrix
+    // graph type. Instead, use directedS, which also provides the
+    // functionality required for a Bidirectional Graph (in_edges,
+    // in_degree, etc.).
+    BOOST_STATIC_ASSERT(!(is_same<Directed, bidirectionalS>::value));
+
+    typedef GraphProperty graph_property_type;
+    typedef typename lookup_one_property<GraphProperty, graph_bundle_t>::type graph_bundled;
+
+    typedef VertexProperty vertex_property_type;
+    typedef typename lookup_one_property<VertexProperty, vertex_bundle_t>::type vertex_bundled;
+
+    typedef EdgeProperty edge_property_type;
+    typedef typename lookup_one_property<EdgeProperty, edge_bundle_t>::type edge_bundled;
+
+  public: // should be private
+    typedef typename mpl::if_<typename has_property<edge_property_type>::type,
+      std::pair<bool, edge_property_type>, char>::type StoredEdge;
+#if defined(BOOST_NO_STD_ALLOCATOR)
+    typedef std::vector<StoredEdge> Matrix;
+#else
+    typedef typename Allocator::template rebind<StoredEdge>::other Alloc;
+    typedef std::vector<StoredEdge, Alloc> Matrix;
+#endif
+    typedef typename Matrix::iterator MatrixIter;
+    typedef typename Matrix::size_type size_type;
+  public:
+    // Graph concept required types
+    typedef typename Traits::vertex_descriptor vertex_descriptor;
+    typedef typename Traits::edge_descriptor edge_descriptor;
+    typedef typename Traits::directed_category directed_category;
+    typedef typename Traits::edge_parallel_category edge_parallel_category;
+    typedef adj_matrix_traversal_tag traversal_category;
+
+    static vertex_descriptor null_vertex()
+    {
+      return (std::numeric_limits<vertex_descriptor>::max)();
+    }
+
+    //private: if friends worked, these would be private
+
+    typedef detail::dir_adj_matrix_out_edge_iter<
+        vertex_descriptor, MatrixIter, size_type, edge_descriptor
+    > DirOutEdgeIter;
+
+    typedef detail::undir_adj_matrix_out_edge_iter<
+        vertex_descriptor, MatrixIter, size_type, edge_descriptor
+    > UnDirOutEdgeIter;
+
+    typedef typename mpl::if_<
+        typename Directed::is_directed_t, DirOutEdgeIter, UnDirOutEdgeIter
+    >::type unfiltered_out_edge_iter;
+
+    typedef detail::dir_adj_matrix_in_edge_iter<
+        vertex_descriptor, MatrixIter, size_type, edge_descriptor
+    > DirInEdgeIter;
+
+    typedef detail::undir_adj_matrix_in_edge_iter<
+        vertex_descriptor, MatrixIter, size_type, edge_descriptor
+    > UnDirInEdgeIter;
+
+    typedef typename mpl::if_<
+        typename Directed::is_directed_t, DirInEdgeIter, UnDirInEdgeIter
+    >::type unfiltered_in_edge_iter;
+
+    typedef detail::adj_matrix_edge_iter<
+        Directed, MatrixIter, size_type, edge_descriptor
+    > unfiltered_edge_iter;
+
+  public:
+
+    // IncidenceGraph concept required types
+    typedef filter_iterator<detail::does_edge_exist, unfiltered_out_edge_iter>
+      out_edge_iterator;
+
+    typedef size_type degree_size_type;
+
+    // BidirectionalGraph required types
+    typedef filter_iterator<detail::does_edge_exist, unfiltered_in_edge_iter>
+      in_edge_iterator;
+
+    // AdjacencyGraph required types
+     typedef typename adjacency_iterator_generator<self,
+       vertex_descriptor, out_edge_iterator>::type adjacency_iterator;
+
+    // VertexListGraph required types
+    typedef size_type vertices_size_type;
+    typedef integer_range<vertex_descriptor> VertexList;
+    typedef typename VertexList::iterator vertex_iterator;
+
+    // EdgeListGraph required types
+    typedef size_type edges_size_type;
+    typedef filter_iterator<
+        detail::does_edge_exist, unfiltered_edge_iter
+    > edge_iterator;
+
+    // PropertyGraph required types
+    typedef adjacency_matrix_class_tag graph_tag;
+
+    // Constructor required by MutableGraph
+    adjacency_matrix(vertices_size_type n_vertices,
+                     const GraphProperty& p = GraphProperty())
+      : m_matrix(Directed::is_directed ?
+                 (n_vertices * n_vertices)
+                 : (n_vertices * (n_vertices + 1) / 2)),
+      m_vertex_set(0, n_vertices),
+      m_vertex_properties(n_vertices),
+      m_num_edges(0),
+      m_property(p) { }
+
+    template <typename EdgeIterator>
+    adjacency_matrix(EdgeIterator first,
+                     EdgeIterator last,
+                     vertices_size_type n_vertices,
+                     const GraphProperty& p = GraphProperty())
+      : m_matrix(Directed::is_directed ?
+                 (n_vertices * n_vertices)
+                 : (n_vertices * (n_vertices + 1) / 2)),
+      m_vertex_set(0, n_vertices),
+      m_vertex_properties(n_vertices),
+      m_num_edges(0),
+      m_property(p)
+    {
+      for (; first != last; ++first) {
+        add_edge(first->first, first->second, *this);
+      }
+    }
+
+    template <typename EdgeIterator, typename EdgePropertyIterator>
+    adjacency_matrix(EdgeIterator first,
+                     EdgeIterator last,
+                     EdgePropertyIterator ep_iter,
+                     vertices_size_type n_vertices,
+                     const GraphProperty& p = GraphProperty())
+      : m_matrix(Directed::is_directed ?
+                 (n_vertices * n_vertices)
+                 : (n_vertices * (n_vertices + 1) / 2)),
+      m_vertex_set(0, n_vertices),
+      m_vertex_properties(n_vertices),
+      m_num_edges(0),
+      m_property(p)
+    {
+      for (; first != last; ++first, ++ep_iter) {
+        add_edge(first->first, first->second, *ep_iter, *this);
+      }
+    }
+
+#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
+    // Directly access a vertex or edge bundle
+    vertex_bundled& operator[](vertex_descriptor v)
+    { return get(vertex_bundle, *this, v); }
+
+    const vertex_bundled& operator[](vertex_descriptor v) const
+    { return get(vertex_bundle, *this, v); }
+
+    edge_bundled& operator[](edge_descriptor e)
+    { return get(edge_bundle, *this, e); }
+
+    const edge_bundled& operator[](edge_descriptor e) const
+    { return get(edge_bundle, *this, e); }
+
+    graph_bundled& operator[](graph_bundle_t)
+    { return get_property(*this); }
+
+    const graph_bundled& operator[](graph_bundle_t) const
+    { return get_property(*this); }
+#endif
+
+    //private: if friends worked, these would be private
+
+    typename Matrix::const_reference
+    get_edge(vertex_descriptor u, vertex_descriptor v) const {
+      if (Directed::is_directed)
+        return m_matrix[u * m_vertex_set.size() + v];
+      else {
+        if (v > u)
+          std::swap(u, v);
+        return m_matrix[u * (u + 1)/2 + v];
+      }
+    }
+    typename Matrix::reference
+    get_edge(vertex_descriptor u, vertex_descriptor v) {
+      if (Directed::is_directed)
+        return m_matrix[u * m_vertex_set.size() + v];
+      else {
+        if (v > u)
+          std::swap(u, v);
+        return m_matrix[u * (u + 1)/2 + v];
+      }
+    }
+
+    Matrix m_matrix;
+    VertexList m_vertex_set;
+    std::vector<vertex_property_type> m_vertex_properties;
+    size_type m_num_edges;
+    graph_property_type m_property;
+  };
+
+  //=========================================================================
+  // Functions required by the AdjacencyMatrix concept
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<D,VP,EP,GP,A>::edge_descriptor,
+            bool>
+  edge(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+       typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor v,
+       const adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    bool exists = detail::get_edge_exists(g.get_edge(u,v), 0);
+    typename adjacency_matrix<D,VP,EP,GP,A>::edge_descriptor
+      e(exists, u, v, &detail::get_edge_property(g.get_edge(u,v)));
+    return std::make_pair(e, exists);
+  }
+
+  //=========================================================================
+  // Functions required by the IncidenceGraph concept
+
+  // O(1)
+  template <typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<directedS,VP,EP,GP,A>::out_edge_iterator,
+            typename adjacency_matrix<directedS,VP,EP,GP,A>::out_edge_iterator>
+  out_edges
+    (typename adjacency_matrix<directedS,VP,EP,GP,A>::vertex_descriptor u,
+     const adjacency_matrix<directedS,VP,EP,GP,A>& g_)
+  {
+    typedef adjacency_matrix<directedS,VP,EP,GP,A> Graph;
+    Graph& g = const_cast<Graph&>(g_);
+    typename Graph::vertices_size_type offset = u * g.m_vertex_set.size();
+    typename Graph::MatrixIter f = g.m_matrix.begin() + offset;
+    typename Graph::MatrixIter l = f + g.m_vertex_set.size();
+    typename Graph::unfiltered_out_edge_iter
+          first(f, u, g.m_vertex_set.size())
+        , last(l, u, g.m_vertex_set.size());
+    detail::does_edge_exist pred;
+    typedef typename Graph::out_edge_iterator out_edge_iterator;
+    return std::make_pair(out_edge_iterator(pred, first, last),
+                          out_edge_iterator(pred, last, last));
+  }
+
+  // O(1)
+  template <typename VP, typename EP, typename GP, typename A>
+  std::pair<
+    typename adjacency_matrix<undirectedS,VP,EP,GP,A>::out_edge_iterator,
+    typename adjacency_matrix<undirectedS,VP,EP,GP,A>::out_edge_iterator>
+  out_edges
+    (typename adjacency_matrix<undirectedS,VP,EP,GP,A>::vertex_descriptor u,
+     const adjacency_matrix<undirectedS,VP,EP,GP,A>& g_)
+  {
+    typedef adjacency_matrix<undirectedS,VP,EP,GP,A> Graph;
+    Graph& g = const_cast<Graph&>(g_);
+    typename Graph::vertices_size_type offset = u * (u + 1) / 2;
+    typename Graph::MatrixIter f = g.m_matrix.begin() + offset;
+    typename Graph::MatrixIter l = g.m_matrix.end();
+
+    typename Graph::unfiltered_out_edge_iter
+        first(f, u, g.m_vertex_set.size())
+      , last(l, u, g.m_vertex_set.size());
+
+    detail::does_edge_exist pred;
+    typedef typename Graph::out_edge_iterator out_edge_iterator;
+    return std::make_pair(out_edge_iterator(pred, first, last),
+                          out_edge_iterator(pred, last, last));
+  }
+
+  // O(N)
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D,VP,EP,GP,A>::degree_size_type
+  out_degree(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+             const adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    typename adjacency_matrix<D,VP,EP,GP,A>::degree_size_type n = 0;
+    typename adjacency_matrix<D,VP,EP,GP,A>::out_edge_iterator f, l;
+    for (boost::tie(f, l) = out_edges(u, g); f != l; ++f)
+      ++n;
+    return n;
+  }
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+    typename Dir, typename Vertex>
+  typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
+  source(const detail::matrix_edge_desc_impl<Dir,Vertex>& e,
+         const adjacency_matrix<D,VP,EP,GP,A>&)
+  {
+    return e.m_source;
+  }
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+    typename Dir, typename Vertex>
+  typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
+  target(const detail::matrix_edge_desc_impl<Dir,Vertex>& e,
+         const adjacency_matrix<D,VP,EP,GP,A>&)
+  {
+    return e.m_target;
+  }
+
+  //=========================================================================
+  // Functions required by the BidirectionalGraph concept
+
+  // O(1)
+  template <typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<directedS,VP,EP,GP,A>::in_edge_iterator,
+            typename adjacency_matrix<directedS,VP,EP,GP,A>::in_edge_iterator>
+  in_edges
+    (typename adjacency_matrix<directedS,VP,EP,GP,A>::vertex_descriptor u,
+     const adjacency_matrix<directedS,VP,EP,GP,A>& g_)
+  {
+    typedef adjacency_matrix<directedS,VP,EP,GP,A> Graph;
+    Graph& g = const_cast<Graph&>(g_);
+    typename Graph::MatrixIter f = g.m_matrix.begin() + u;
+    typename Graph::MatrixIter l = g.m_matrix.end();
+    typename Graph::unfiltered_in_edge_iter
+        first(f, l, u, g.m_vertex_set.size())
+      , last(l, l, u, g.m_vertex_set.size());
+    detail::does_edge_exist pred;
+    typedef typename Graph::in_edge_iterator in_edge_iterator;
+    return std::make_pair(in_edge_iterator(pred, first, last),
+                          in_edge_iterator(pred, last, last));
+  }
+
+  // O(1)
+  template <typename VP, typename EP, typename GP, typename A>
+  std::pair<
+    typename adjacency_matrix<undirectedS,VP,EP,GP,A>::in_edge_iterator,
+    typename adjacency_matrix<undirectedS,VP,EP,GP,A>::in_edge_iterator>
+  in_edges
+    (typename adjacency_matrix<undirectedS,VP,EP,GP,A>::vertex_descriptor u,
+     const adjacency_matrix<undirectedS,VP,EP,GP,A>& g_)
+  {
+    typedef adjacency_matrix<undirectedS,VP,EP,GP,A> Graph;
+    Graph& g = const_cast<Graph&>(g_);
+    typename Graph::vertices_size_type offset = u * (u + 1) / 2;
+    typename Graph::MatrixIter f = g.m_matrix.begin() + offset;
+    typename Graph::MatrixIter l = g.m_matrix.end();
+
+    typename Graph::unfiltered_in_edge_iter
+        first(f, u, g.m_vertex_set.size())
+      , last(l, u, g.m_vertex_set.size());
+
+    detail::does_edge_exist pred;
+    typedef typename Graph::in_edge_iterator in_edge_iterator;
+    return std::make_pair(in_edge_iterator(pred, first, last),
+                          in_edge_iterator(pred, last, last));
+  }
+
+  // O(N)
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D,VP,EP,GP,A>::degree_size_type
+  in_degree(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+             const adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    typename adjacency_matrix<D,VP,EP,GP,A>::degree_size_type n = 0;
+    typename adjacency_matrix<D,VP,EP,GP,A>::in_edge_iterator f, l;
+    for (boost::tie(f, l) = in_edges(u, g); f != l; ++f)
+      ++n;
+    return n;
+  }
+
+  //=========================================================================
+  // Functions required by the AdjacencyGraph concept
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<D,VP,EP,GP,A>::adjacency_iterator,
+            typename adjacency_matrix<D,VP,EP,GP,A>::adjacency_iterator>
+  adjacent_vertices
+    (typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+     const adjacency_matrix<D,VP,EP,GP,A>& g_)
+  {
+      typedef adjacency_matrix<D,VP,EP,GP,A> Graph;
+      const Graph& cg = static_cast<const Graph&>(g_);
+      Graph& g = const_cast<Graph&>(cg);
+      typedef typename Graph::adjacency_iterator adjacency_iterator;
+      typename Graph::out_edge_iterator first, last;
+      boost::tie(first, last) = out_edges(u, g);
+      return std::make_pair(adjacency_iterator(first, &g),
+                            adjacency_iterator(last, &g));
+  }
+
+  //=========================================================================
+  // Functions required by the VertexListGraph concept
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<D,VP,EP,GP,A>::vertex_iterator,
+            typename adjacency_matrix<D,VP,EP,GP,A>::vertex_iterator>
+  vertices(const adjacency_matrix<D,VP,EP,GP,A>& g_) {
+    typedef adjacency_matrix<D,VP,EP,GP,A> Graph;
+    Graph& g = const_cast<Graph&>(g_);
+    return std::make_pair(g.m_vertex_set.begin(), g.m_vertex_set.end());
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D,VP,EP,GP,A>::vertices_size_type
+  num_vertices(const adjacency_matrix<D,VP,EP,GP,A>& g) {
+    return g.m_vertex_set.size();
+  }
+
+  //=========================================================================
+  // Functions required by the EdgeListGraph concept
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<D,VP,EP,GP,A>::edge_iterator,
+            typename adjacency_matrix<D,VP,EP,GP,A>::edge_iterator>
+  edges(const adjacency_matrix<D,VP,EP,GP,A>& g_)
+  {
+    typedef adjacency_matrix<D,VP,EP,GP,A> Graph;
+    Graph& g = const_cast<Graph&>(g_);
+
+    typename Graph::unfiltered_edge_iter
+      first(g.m_matrix.begin(), g.m_matrix.begin(),
+                                    g.m_vertex_set.size()),
+      last(g.m_matrix.end(), g.m_matrix.begin(),
+                                    g.m_vertex_set.size());
+    detail::does_edge_exist pred;
+    typedef typename Graph::edge_iterator edge_iterator;
+    return std::make_pair(edge_iterator(pred, first, last),
+                          edge_iterator(pred, last, last));
+  }
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D,VP,EP,GP,A>::edges_size_type
+  num_edges(const adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    return g.m_num_edges;
+  }
+
+  //=========================================================================
+  // Functions required by the MutableGraph concept
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename EP2>
+  std::pair<typename adjacency_matrix<D,VP,EP,GP,A>::edge_descriptor, bool>
+  add_edge(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+           typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor v,
+           const EP2& ep,
+           adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    typedef typename adjacency_matrix<D,VP,EP,GP,A>::edge_descriptor
+      edge_descriptor;
+    if (detail::get_edge_exists(g.get_edge(u,v), 0) == false) {
+      ++(g.m_num_edges);
+      detail::set_edge_property(g.get_edge(u,v), EP(ep), 0);
+      detail::set_edge_exists(g.get_edge(u,v), true, 0);
+      return std::make_pair
+        (edge_descriptor(true, u, v, &detail::get_edge_property(g.get_edge(u,v))),
+         true);
+    } else
+      return std::make_pair
+        (edge_descriptor(true, u, v, &detail::get_edge_property(g.get_edge(u,v))),
+         false);
+  }
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  std::pair<typename adjacency_matrix<D,VP,EP,GP,A>::edge_descriptor, bool>
+  add_edge(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+           typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor v,
+           adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    EP ep;
+    return add_edge(u, v, ep, g);
+  }
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  void
+  remove_edge(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor u,
+              typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor v,
+              adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    // Don'remove the edge unless it already exists.
+    if(detail::get_edge_exists(g.get_edge(u,v), 0)) {
+      --(g.m_num_edges);
+      detail::set_edge_exists(g.get_edge(u,v), false, 0);
+    }
+  }
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  void
+  remove_edge(typename adjacency_matrix<D,VP,EP,GP,A>::edge_descriptor e,
+              adjacency_matrix<D,VP,EP,GP,A>& g)
+  {
+    remove_edge(source(e, g), target(e, g), g);
+  }
+
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  inline typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
+  add_vertex(adjacency_matrix<D,VP,EP,GP,A>& g) {
+    // UNDER CONSTRUCTION
+    BOOST_ASSERT(false);
+    return *vertices(g).first;
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename VP2>
+  inline typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
+  add_vertex(const VP2& /*vp*/, adjacency_matrix<D,VP,EP,GP,A>& g) {
+    // UNDER CONSTRUCTION
+    BOOST_ASSERT(false);
+    return *vertices(g).first;
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  inline void
+  remove_vertex(typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor /*u*/,
+                adjacency_matrix<D,VP,EP,GP,A>& /*g*/)
+  {
+    // UNDER CONSTRUCTION
+    BOOST_ASSERT(false);
+  }
+
+  // O(V)
+  template <typename VP, typename EP, typename GP, typename A>
+  void
+  clear_vertex
+    (typename adjacency_matrix<directedS,VP,EP,GP,A>::vertex_descriptor u,
+     adjacency_matrix<directedS,VP,EP,GP,A>& g)
+  {
+    typename adjacency_matrix<directedS,VP,EP,GP,A>::vertex_iterator
+      vi, vi_end;
+    for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
+      remove_edge(u, *vi, g);
+    for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
+      remove_edge(*vi, u, g);
+  }
+
+  // O(V)
+  template <typename VP, typename EP, typename GP, typename A>
+  void
+  clear_vertex
+    (typename adjacency_matrix<undirectedS,VP,EP,GP,A>::vertex_descriptor u,
+     adjacency_matrix<undirectedS,VP,EP,GP,A>& g)
+  {
+    typename adjacency_matrix<undirectedS,VP,EP,GP,A>::vertex_iterator
+      vi, vi_end;
+    for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
+      remove_edge(u, *vi, g);
+  }
+
+  //=========================================================================
+  // Functions required by the PropertyGraph concept
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Prop, typename Kind>
+  struct adj_mat_pm_helper;
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Prop>
+  struct adj_mat_pm_helper<D, VP, EP, GP, A, Prop, vertex_property_tag> {
+    typedef typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::vertex_descriptor arg_type;
+    typedef typed_identity_property_map<arg_type> vi_map_type;
+    typedef iterator_property_map<typename std::vector<VP>::iterator, vi_map_type> all_map_type;
+    typedef iterator_property_map<typename std::vector<VP>::const_iterator, vi_map_type> all_map_const_type;
+    typedef transform_value_property_map<
+              detail::lookup_one_property_f<VP, Prop>,
+              all_map_type>
+      type;
+    typedef transform_value_property_map<
+              detail::lookup_one_property_f<const VP, Prop>,
+              all_map_const_type>
+      const_type;
+    typedef typename property_traits<type>::reference single_nonconst_type;
+    typedef typename property_traits<const_type>::reference single_const_type;
+
+    static type get_nonconst(adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop) {
+      return type(prop, all_map_type(g.m_vertex_properties.begin(), vi_map_type()));
+    }
+
+    static const_type get_const(const adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop) {
+      return const_type(prop, all_map_const_type(g.m_vertex_properties.begin(), vi_map_type()));
+    }
+
+    static single_nonconst_type get_nonconst_one(adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop, arg_type v) {
+      return lookup_one_property<VP, Prop>::lookup(g.m_vertex_properties[v], prop);
+    }
+
+    static single_const_type get_const_one(const adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop, arg_type v) {
+      return lookup_one_property<const VP, Prop>::lookup(g.m_vertex_properties[v], prop);
+    }
+  };
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  struct adj_mat_pm_helper<D, VP, EP, GP, A, Tag, edge_property_tag> {
+    typedef typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::edge_descriptor edge_descriptor;
+
+    template <typename IsConst>
+    struct lookup_property_from_edge {
+      Tag tag;
+      lookup_property_from_edge(Tag tag): tag(tag) {}
+      typedef typename boost::mpl::if_<IsConst, const EP, EP>::type ep_type_nonref;
+      typedef ep_type_nonref& ep_type;
+      typedef typename lookup_one_property<ep_type_nonref, Tag>::type& result_type;
+      result_type operator()(edge_descriptor e) const {
+        return lookup_one_property<ep_type_nonref, Tag>::lookup(*static_cast<ep_type_nonref*>(e.get_property()), tag);
+      }
+    };
+
+    typedef function_property_map<
+              lookup_property_from_edge<boost::mpl::false_>,
+              typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::edge_descriptor> type;
+    typedef function_property_map<
+              lookup_property_from_edge<boost::mpl::true_>,
+              typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::edge_descriptor> const_type;
+    typedef edge_descriptor arg_type;
+    typedef typename lookup_property_from_edge<boost::mpl::false_>::result_type single_nonconst_type;
+    typedef typename lookup_property_from_edge<boost::mpl::true_>::result_type single_const_type;
+
+    static type get_nonconst(adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag) {
+      return type(tag);
+    }
+
+    static const_type get_const(const adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag) {
+      return const_type(tag);
+    }
+
+    static single_nonconst_type get_nonconst_one(adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag, edge_descriptor e) {
+      return lookup_one_property<EP, Tag>::lookup(*static_cast<EP*>(e.get_property()), tag);
+    }
+
+    static single_const_type get_const_one(const adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag, edge_descriptor e) {
+      return lookup_one_property<const EP, Tag>::lookup(*static_cast<const EP*>(e.get_property()), tag);
+    }
+  };
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  struct property_map<adjacency_matrix<D,VP,EP,GP,A>, Tag>
+    : adj_mat_pm_helper<D, VP, EP, GP, A, Tag,
+                        typename detail::property_kind_from_graph<adjacency_matrix<D, VP, EP, GP, A>, Tag>::type> {};
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::type
+  get(Tag tag, adjacency_matrix<D, VP, EP, GP, A>& g) {
+    return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_nonconst(g, tag);
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::const_type
+  get(Tag tag, const adjacency_matrix<D, VP, EP, GP, A>& g) {
+    return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_const(g, tag);
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::single_nonconst_type
+  get(Tag tag, adjacency_matrix<D, VP, EP, GP, A>& g, typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::arg_type a) {
+    return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_nonconst_one(g, tag, a);
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::single_const_type
+  get(Tag tag, const adjacency_matrix<D, VP, EP, GP, A>& g, typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::arg_type a) {
+    return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_const_one(g, tag, a);
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  void
+  put(Tag tag,
+      adjacency_matrix<D, VP, EP, GP, A>& g,
+      typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::arg_type a,
+      typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::single_const_type val) {
+    property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_nonconst_one(g, tag, a) = val;
+  }
+
+  // O(1)
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag, typename Value>
+  inline void
+  set_property(adjacency_matrix<D,VP,EP,GP,A>& g, Tag tag, const Value& value)
+  {
+      get_property_value(g.m_property, tag) = value;
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  inline typename graph_property<adjacency_matrix<D,VP,EP,GP,A>, Tag>::type&
+  get_property(adjacency_matrix<D,VP,EP,GP,A>& g, Tag tag)
+  {
+      return get_property_value(g.m_property, tag);
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A,
+            typename Tag>
+  inline const typename graph_property<adjacency_matrix<D,VP,EP,GP,A>, Tag>::type&
+  get_property(const adjacency_matrix<D,VP,EP,GP,A>& g, Tag tag)
+  {
+      return get_property_value(g.m_property, tag);
+  }
+
+  //=========================================================================
+  // Vertex Property Map
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  struct property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t> {
+    typedef typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor Vertex;
+    typedef typed_identity_property_map<Vertex> type;
+    typedef type const_type;
+  };
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type
+  get(vertex_index_t, adjacency_matrix<D, VP, EP, GP, A>&) {
+    return typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type();
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor
+  get(vertex_index_t,
+      adjacency_matrix<D, VP, EP, GP, A>&,
+      typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor v) {
+    return v;
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type
+  get(vertex_index_t, const adjacency_matrix<D, VP, EP, GP, A>&) {
+    return typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type();
+  }
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor
+  get(vertex_index_t,
+      const adjacency_matrix<D, VP, EP, GP, A>&,
+      typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor v) {
+    return v;
+  }
+
+  //=========================================================================
+  // Other Functions
+
+  template <typename D, typename VP, typename EP, typename GP, typename A>
+  typename adjacency_matrix<D,VP,EP,GP,A>::vertex_descriptor
+  vertex(typename adjacency_matrix<D,VP,EP,GP,A>::vertices_size_type n,
+         const adjacency_matrix<D,VP,EP,GP,A>&)
+  {
+    return n;
+  }
+
+template <typename D, typename VP, typename EP, typename GP, typename A>
+struct graph_mutability_traits<adjacency_matrix<D, VP, EP, GP, A> > {
+  typedef mutable_edge_property_graph_tag category;
+};
+
+
+} // namespace boost
+
+#endif // BOOST_ADJACENCY_MATRIX_HPP
diff --git a/src/Geometry.cpp b/src/Geometry.cpp
index c635708..186c94e 100644
--- a/src/Geometry.cpp
+++ b/src/Geometry.cpp
@@ -148,7 +148,7 @@ Geometry&   Geometry::geometryN( size_t const& n )
 ///
 ///
 ///
-Geometry::Geometry()
+Geometry::Geometry() : validityFlag_( false )
 {
 
 }
@@ -156,11 +156,21 @@ Geometry::Geometry()
 ///
 ///
 ///
-Geometry::Geometry( Geometry const& )
+Geometry::Geometry( Geometry const& other ) : validityFlag_( other.validityFlag_ )
 {
 
 }
 
+bool Geometry::hasValidityFlag() const
+{
+        return validityFlag_;
+}
+
+void Geometry::forceValidityFlag( bool valid )
+{
+        validityFlag_ = valid;
+}
+
 ///
 /// Function used to compare geometries
 /// FIXME
diff --git a/src/Geometry.h b/src/Geometry.h
index 86c7846..5893530 100644
--- a/src/Geometry.h
+++ b/src/Geometry.h
@@ -53,8 +53,6 @@ class PolyhedralSurface ;
 class Solid ;
 //not SFA, appears in GML/CityGML
 class MultiSolid ;
-//not SFA, appears in GML/CityGML
-class Grid ;
 
 class Envelope ;
 
@@ -164,6 +162,19 @@ public:
 
     //virtual bool         isSimple() const = 0 ;
 
+    
+    /**
+     * Force the state of the validity flag. The validity flag allows to bypass validity checks
+     * If the flag is true, it means the geometry is considered valid
+     * If the flag is false, it means the validity state of the geometry is unknown
+     * The flag is only changed for this geometry and not the internal geometries.
+     * @see propagateValidityFlag
+     */
+    void forceValidityFlag( bool validity );
+
+    /** Returns the validity flag */
+    bool hasValidityFlag() const;
+
     /**
      * [OGC/SFA]returns the WKT string
      * @param numDecimals extension specify fix precision output
@@ -272,6 +283,8 @@ protected:
     Geometry();
     Geometry( const Geometry& );
     const Geometry& operator=( const Geometry& );
+
+    bool validityFlag_;
 };
 
 /**
diff --git a/src/Grid.cpp b/src/Grid.cpp
deleted file mode 100644
index ec98b20..0000000
--- a/src/Grid.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <SFCGAL/Grid.h>
-
-#include <SFCGAL/Triangle.h>
-#include <SFCGAL/TriangulatedSurface.h>
-
-using namespace SFCGAL::detail;
-
-namespace SFCGAL {
-
-///
-///
-///
-Grid::Grid():
-    _data(),
-    _limits( Envelope( 0.0,1.0,0.0,1.0 ) ),
-    _pixelConvention( PIXEL_IS_POINT )
-{
-
-}
-
-///
-///
-///
-Grid::Grid(
-    const size_t& nrows,
-    const size_t& ncols,
-    const double& fillValue,
-    const Envelope& limits,
-    const PixelConvention& pixelType
-):
-    _data( ublas::scalar_matrix< double >( nrows, ncols, fillValue ) ),
-    _limits( limits ),
-    _pixelConvention( pixelType )
-{
-
-}
-
-
-///
-///
-///
-Grid::Grid(
-    const ublas::matrix< double >& data,
-    const Envelope& limits,
-    const PixelConvention& pixelType
-):
-    _data( data ),
-    _limits( limits ),
-    _pixelConvention( pixelType )
-{
-
-}
-
-///
-///
-///
-Grid::Grid( const Grid& other )
-{
-    ( *this ) = other ;
-}
-
-///
-///
-///
-Grid& Grid::operator = ( const Grid& other )
-{
-    _data      = other._data ;
-    _limits    = other._limits ;
-    _pixelConvention = other._pixelConvention ;
-    return *this ;
-}
-
-///
-///
-///
-Grid::~Grid()
-{
-
-}
-
-
-///
-///
-///
-std::auto_ptr< TriangulatedSurface > Grid::toTrianguledSurface() const
-{
-    std::auto_ptr< TriangulatedSurface > result( new TriangulatedSurface() ) ;
-
-    if ( nrows() <= 1 || ncols() <= 1 ) {
-        return result ;
-    }
-
-    for ( size_t i = 0; i < nrows() - 1; i++ ) {
-        for ( size_t j = 0; j < ncols() - 1; j++ ) {
-            /*
-             * a    b
-             *
-             * d    c
-             */
-            Point a = point( i,j );
-            Point b = point( i,j+1 );
-            Point c = point( i+1,j+1 );
-            Point d = point( i+1,j );
-
-            if ( d.isMeasured() && c.isMeasured() && b.isMeasured() ) {
-                result->addTriangle( new Triangle( d, c, b ) );
-            }
-
-            if ( d.isMeasured() && b.isMeasured() && a.isMeasured() ) {
-                result->addTriangle( new Triangle( d, b, a ) );
-            }
-        }
-    }
-
-    return result ;
-}
-
-} // namespace SFCGAL
diff --git a/src/Grid.h b/src/Grid.h
deleted file mode 100644
index 299e2bb..0000000
--- a/src/Grid.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _SFCGAL_GRID_H_
-#define _SFCGAL_GRID_H_
-
-#include <SFCGAL/detail/ublas.h>
-
-#include <SFCGAL/Envelope.h>
-#include <SFCGAL/Point.h>
-#include <SFCGAL/TriangulatedSurface.h>
-
-namespace SFCGAL {
-
-/**
- * @brief represents a pixel convention for Grid data
- *
- * PIXEL_IS_POINT : Each value represents a point of the grid
- * PIXEL_IS_AREA : Each value corresponds to an area
- *
- */
-typedef enum {
-    PIXEL_IS_POINT,
-    PIXEL_IS_AREA
-} PixelConvention ;
-
-/**
- * @brief represents a Grid.
- *
- * left-right, top-down orientation :
- *                         i
- * +----------------------->
- * |
- * |
- * |
- * |
- * v j
- *
- *
- * NaN represents undefined values
- */
-class SFCGAL_API Grid {
-public:
-
-    /**
-     * @brief default constructor
-     */
-    Grid();
-    /**
-     * @brief default constructor
-     */
-    Grid(
-        const size_t& nrows,
-        const size_t& ncols,
-        const double& fillValue = NaN(),
-        const Envelope& limits = Envelope( 0.0,1.0,0.0,1.0 ),
-        const PixelConvention& pixelType = PIXEL_IS_POINT
-    );
-    /**
-     * @brief copy constructor
-     */
-    Grid(
-        const detail::ublas::matrix< double >& data,
-        const Envelope& limits = Envelope( 0.0,1.0,0.0,1.0 ),
-        const PixelConvention& pixelType = PIXEL_IS_POINT
-    );
-    /**
-     * @brief copy constructor
-     */
-    Grid( const Grid& other );
-    /**
-     * @brief copy constructor
-     */
-    Grid& operator = ( const Grid& other );
-    /**
-     * @brief destructor
-     */
-    ~Grid();
-
-
-    /**
-     * @brief test if the grid is empty
-     */
-    inline bool isEmpty() const {
-        return ( _data.size1() == 0U ) || ( _data.size2() == 0U ) ;
-    }
-
-    /**
-     * @brief get a point at a specific location
-     */
-    inline Point point( const size_t& row, const size_t& col ) const {
-        if ( _pixelConvention == PIXEL_IS_POINT ) {
-            Point p(
-                _limits.xMin() + col * dx(),
-                _limits.yMax() - row * dy() );
-            p.setM( _data( row,col ) );
-            return p;
-        }
-        else {
-            Point p(
-                _limits.xMin() + ( 0.5 + col ) * dx(),
-                _limits.yMax() - ( 0.5 + row ) * dy() );
-            p.setM( _data( row,col ) );
-            return p;
-        }
-    }
-
-    /**
-     * @brief get the width of a pixel
-     */
-    inline double dx() const {
-        if ( _pixelConvention == PIXEL_IS_POINT ) {
-            return _limits.boundsN( 0 ).width() / ( _data.size2() - 1 ) ;
-        }
-        else {
-            return _limits.boundsN( 0 ).width() / ( _data.size2() ) ;
-        }
-    }
-
-    /**
-     * @brief get the height of a pixel
-     */
-    inline double dy() const {
-        if ( _pixelConvention == PIXEL_IS_POINT ) {
-            return _limits.boundsN( 1 ).width() / ( _data.size1() - 1 ) ;
-        }
-        else {
-            return _limits.boundsN( 1 ).width() / ( _data.size1() ) ;
-        }
-    }
-
-    /**
-     * @brief get Z for a given location
-     */
-    inline const double& z( const size_t& row, const size_t& col ) const {
-        return _data( row,col ) ;
-    }
-    /**
-     * @brief get Z for a given location
-     */
-    inline double& z( const size_t& row, const size_t& col ) {
-        return _data( row,col ) ;
-    }
-
-
-    /**
-     * @brief gets the height of the grid
-     */
-    inline size_t nrows() const {
-        return _data.size1() ;
-    }
-    /**
-     * @brief gets the width of the grid
-     */
-    inline size_t ncols() const {
-        return _data.size2() ;
-    }
-
-    /**
-     * @brief access to grid limits
-     */
-    inline const Envelope& limits() const {
-        return _limits ;
-    }
-    /**
-     * @brief Sets the limits
-     */
-    inline void setLimits( const Envelope& limits ) {
-        _limits = limits ;
-    }
-
-    /**
-     * @brief get pixel type
-     */
-    inline const PixelConvention& pixelConvention() const {
-        return _pixelConvention ;
-    }
-    /**
-     * @brief set the pixel type
-     */
-    inline void setPixelConvention( const PixelConvention& pixelConvention ) {
-        _pixelConvention = pixelConvention ;
-    }
-
-    /**
-     * @brief [advanced]access to grid data
-     */
-    inline detail::ublas::matrix< double >& data() {
-        return _data ;
-    }
-    /**
-     * @brief [advanced]access to grid data
-     */
-    inline const detail::ublas::matrix< double >& data() const {
-        return _data ;
-    }
-
-
-    /**
-     * @brief converts the Grid to a TriangulatedSurface
-     */
-    std::auto_ptr< TriangulatedSurface > toTrianguledSurface() const ;
-
-
-private:
-    /**
-     * @brief grid data
-     */
-    detail::ublas::matrix< double > _data ;
-    /**
-     * @brief grid extent
-     */
-    Envelope _limits ;
-    /**
-     * @brief pixel type
-     */
-    PixelConvention _pixelConvention ;
-};
-
-} // namespace SFCGAL
-
-#endif
diff --git a/src/algorithm/extrude.cpp b/src/algorithm/extrude.cpp
index b35aea1..c5cb7a7 100644
--- a/src/algorithm/extrude.cpp
+++ b/src/algorithm/extrude.cpp
@@ -363,7 +363,9 @@ std::auto_ptr< Geometry > extrude( const Geometry& g, Kernel::FT dx, Kernel::FT
 std::auto_ptr< Geometry > extrude( const Geometry& g, Kernel::FT dx, Kernel::FT dy, Kernel::FT dz )
 {
     SFCGAL_ASSERT_GEOMETRY_VALIDITY( g );
-    return extrude( g, dx, dy, dz, NoValidityCheck() );
+    std::auto_ptr<Geometry> result( extrude( g, dx, dy, dz, NoValidityCheck() ) );
+    propagateValidityFlag( *result, true );
+    return result;
 }
 
 SFCGAL_API std::auto_ptr< Geometry > extrude( const Geometry& g, const double& dx, const double& dy, const double& dz )
diff --git a/src/algorithm/isValid.cpp b/src/algorithm/isValid.cpp
index 5c04130..8f35546 100644
--- a/src/algorithm/isValid.cpp
+++ b/src/algorithm/isValid.cpp
@@ -43,19 +43,81 @@
 #include <SFCGAL/algorithm/connection.h>
 #include <SFCGAL/detail/tools/Log.h>
 #include <SFCGAL/detail/GetPointsVisitor.h>
+#include <SFCGAL/detail/ForceValidityVisitor.h>
 #include <SFCGAL/Kernel.h>
+#include <SFCGAL/Exception.h>
 
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/graph/visitors.hpp>
 #include <boost/graph/undirected_dfs.hpp>
-
+#include <boost/format.hpp>
 
 using namespace SFCGAL::detail::algorithm;
 
 namespace SFCGAL {
-namespace algorithm {
 
-bool SKIP_GEOM_VALIDATION = false;
+void SFCGAL_ASSERT_GEOMETRY_VALIDITY_( const Geometry& g, const std::string& ctxt )
+{
+    if ( !(g).hasValidityFlag() )
+    {
+        const Validity sfcgalAssertGeometryValidity = algorithm::isValid( g );
+        if ( ! sfcgalAssertGeometryValidity ) {
+            throw GeometryInvalidityException(
+                                              ( boost::format(ctxt + "%s is invalid : %s : %s")
+                                                % (g).geometryType()
+                                                % sfcgalAssertGeometryValidity.reason()
+                                                % (g).asText()
+                                                ).str()
+                                              );
+        }
+    }
+}
+
+void SFCGAL_ASSERT_GEOMETRY_VALIDITY( const Geometry& g )
+{
+    SFCGAL_ASSERT_GEOMETRY_VALIDITY_(g,"");
+}
+
+void SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( const Geometry& g )
+{
+    if ( !(g).hasValidityFlag() )
+    {
+        using namespace SFCGAL;
+        if ( (g).is3D() ) {
+            std::auto_ptr<SFCGAL::Geometry> sfcgalAssertGeometryValidityClone( (g).clone() );
+            algorithm::force2D( *sfcgalAssertGeometryValidityClone );
+            SFCGAL_ASSERT_GEOMETRY_VALIDITY_( (*sfcgalAssertGeometryValidityClone), "When converting to 2D - " );
+        }
+        else {
+            SFCGAL_ASSERT_GEOMETRY_VALIDITY( g );
+        }
+    }
+}
+
+void SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( const Geometry& g )
+{
+    if ( !(g).hasValidityFlag() )
+    {
+        using namespace SFCGAL;
+        if ( !(g).is3D() ) {
+            std::auto_ptr<Geometry> sfcgalAssertGeometryValidityClone( (g).clone() );
+            algorithm::force3D( *sfcgalAssertGeometryValidityClone );
+            SFCGAL_ASSERT_GEOMETRY_VALIDITY_( (*sfcgalAssertGeometryValidityClone), "When converting to 3D - " );
+        }
+        else {
+            SFCGAL_ASSERT_GEOMETRY_VALIDITY( g );
+        }
+    }
+}
+
+void SFCGAL_ASSERT_GEOMETRY_VALIDITY_ON_PLANE( const Geometry& /*g*/ )
+{
+    throw NotImplementedException("validation on geometry projected on arbitrary plane is not implemented");
+}
+
+
+
+namespace algorithm {
 
 // to detect unconnected interior in polygon
 struct LoopDetector : public boost::dfs_visitor<> {
@@ -496,5 +558,11 @@ const Validity isValid( const Geometry& g, const double& toleranceAbs )
     return Validity::invalid( ( boost::format( "isValid( %s ) is not defined" ) % g.geometryType() ).str() ); // to avoid warning
 }
 
+void propagateValidityFlag( Geometry& g, bool valid )
+{
+    detail::ForceValidityVisitor v( valid );
+    g.accept( v );
+}
+
 } // namespace algorithm
 } // namespace SFCGAL
diff --git a/src/algorithm/isValid.h b/src/algorithm/isValid.h
index 8c7dc57..b7a8376 100644
--- a/src/algorithm/isValid.h
+++ b/src/algorithm/isValid.h
@@ -27,9 +27,17 @@
 #include <SFCGAL/algorithm/force3D.h>
 
 namespace SFCGAL {
-namespace algorithm {
 
-extern bool SKIP_GEOM_VALIDATION;
+/**
+ * Functions used to assert for geometry validity
+ * @note exception message is apparently limited in length, thus print the reason for invalidity before its text representation (that can be very long)
+ */
+void SFCGAL_API SFCGAL_ASSERT_GEOMETRY_VALIDITY( const Geometry& g );
+void SFCGAL_API SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( const Geometry& g );
+void SFCGAL_API SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( const Geometry& g );
+void SFCGAL_API SFCGAL_ASSERT_GEOMETRY_VALIDITY_ON_PLANE( const Geometry& g );
+
+namespace algorithm {
 
 /**
  * @brief Check validity of a geometry
@@ -38,63 +46,10 @@ extern bool SKIP_GEOM_VALIDATION;
 SFCGAL_API const Validity isValid( const Geometry& g, const double& toleranceAbs= 1e-9 );
 
 /**
- * Macro used to by-pass validity check
- * @note do not convert to function since BOOST_THROW_EXCEPTION locates the throwing point (function and line)
- * @note exception message is apparently limited in length, thus print the reason for invalidity before its text representation (that can be very long)
+ * Sets the geometry flag on a geometry and propagate to every internal geometries
+ * @ingroup public_api
  */
-#ifndef SFCGAL_NEVER_CHECK_VALIDITY
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_(g, ctxt)  \
-    if (!SFCGAL::algorithm::SKIP_GEOM_VALIDATION)\
-    {\
-        using namespace SFCGAL;\
-        const Validity sfcgalAssertGeometryValidity = algorithm::isValid( g );\
-        if ( ! sfcgalAssertGeometryValidity ) {\
-            BOOST_THROW_EXCEPTION(GeometryInvalidityException(\
-                ( boost::format(ctxt "%s is invalid : %s : %s")\
-                  % (g).geometryType()\
-                  % sfcgalAssertGeometryValidity.reason()\
-                  % (g).asText()\
-                ).str()\
-            ));\
-        }\
-    }
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY(g) \
-        SFCGAL_ASSERT_GEOMETRY_VALIDITY_(g,"")
-
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D(g) \
-    if (!SFCGAL::algorithm::SKIP_GEOM_VALIDATION)\
-    {\
-        using namespace SFCGAL;\
-        if ( (g).is3D() ) {\
-            std::auto_ptr<SFCGAL::Geometry> sfcgalAssertGeometryValidityClone( (g).clone() );\
-            algorithm::force2D( *sfcgalAssertGeometryValidityClone );\
-            SFCGAL_ASSERT_GEOMETRY_VALIDITY_( (*sfcgalAssertGeometryValidityClone), "When converting to 2D - " ); \
-        }\
-        else {\
-            SFCGAL_ASSERT_GEOMETRY_VALIDITY( g );\
-        }\
-    }
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D(g) \
-    if (!SFCGAL::algorithm::SKIP_GEOM_VALIDATION)\
-    {\
-        using namespace SFCGAL;\
-        if ( !(g).is3D() ) {\
-            std::auto_ptr<Geometry> sfcgalAssertGeometryValidityClone( (g).clone() );\
-            algorithm::force3D( *sfcgalAssertGeometryValidityClone );\
-            SFCGAL_ASSERT_GEOMETRY_VALIDITY_( (*sfcgalAssertGeometryValidityClone), "When converting to 3D - " ); \
-        }\
-        else {\
-            SFCGAL_ASSERT_GEOMETRY_VALIDITY( g );\
-        }\
-    }
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_ON_PLANE(g, plane) \
-   BOOST_THROW_EXCEPTION( NotImplementedException("validation on geometry projected on arbitrary plane is not implemented") );
-#else
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY(g)
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D(g)
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D(g)
-#  define SFCGAL_ASSERT_GEOMETRY_VALIDITY_ON_PLANE(g, plane)
-#endif
+SFCGAL_API void propagateValidityFlag( Geometry& g, bool valid );
 
 /**
  * Tag used for variants of algorithm that do not do validity check
diff --git a/src/algorithm/minkowskiSum.cpp b/src/algorithm/minkowskiSum.cpp
index c14ca5c..bf3fc7d 100644
--- a/src/algorithm/minkowskiSum.cpp
+++ b/src/algorithm/minkowskiSum.cpp
@@ -283,7 +283,9 @@ std::auto_ptr< Geometry > minkowskiSum( const Geometry& gA, const Polygon& gB )
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( gA );
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( gB );
 
-    return minkowskiSum( gA, gB, NoValidityCheck() );
+    std::auto_ptr<Geometry> result( minkowskiSum( gA, gB, NoValidityCheck() ) );
+    propagateValidityFlag( *result, true );
+    return result;
 }
 
 } // namespace algorithm
diff --git a/src/algorithm/straightSkeleton.cpp b/src/algorithm/straightSkeleton.cpp
index 45b4186..ac07c48 100644
--- a/src/algorithm/straightSkeleton.cpp
+++ b/src/algorithm/straightSkeleton.cpp
@@ -45,9 +45,9 @@ typedef CGAL::Polygon_2<Kernel>            Polygon_2 ;
 typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2 ;
 typedef CGAL::Straight_skeleton_2<Kernel>  Straight_skeleton_2 ;
 
+namespace { // anonymous
 
-
-template<class K>
+template<class K, bool outputDistanceInM>
 void straightSkeletonToMultiLineString(
     const CGAL::Straight_skeleton_2<K>& ss,
     MultiLineString& result,
@@ -80,6 +80,95 @@ void straightSkeletonToMultiLineString(
             continue ;
         }
 
+        LineString* ls = 0;
+        if ( outputDistanceInM ) {
+            Point pa( it->opposite()->vertex()->point() );
+            Point pb( it->vertex()->point() );
+            pa.setM( CGAL::to_double(it->opposite()->vertex()->time()) );
+            pb.setM( CGAL::to_double(it->vertex()->time()) );
+            ls = new LineString( pa, pb );
+        }
+        else {
+            ls = new LineString( it->opposite()->vertex()->point(), it->vertex()->point() );
+        }
+        algorithm::translate( *ls, translate );
+        result.addGeometry( ls );
+    }
+}
+
+/**
+ * Return abc angle in radians
+ */
+static double
+angle(const Point &a, const Point &b, const Point &c)
+{
+  Point ab( to_double(b.x() - a.x()), to_double(b.y() - a.y()) );
+  Point cb( to_double(b.x() - c.x()), to_double(b.y() - c.y()) );
+
+  double dot = ( to_double(ab.x() * cb.x() + ab.y() * cb.y()) ); /* dot product */
+  double cross = ( to_double(ab.x() * cb.y() - ab.y() * cb.x()) ); /* cross product */
+
+  double alpha = std::atan2(cross, dot);
+
+  return alpha;
+}
+
+template<class K>
+void straightSkeletonToMedialAxis(
+    const CGAL::Straight_skeleton_2<K>& ss,
+    MultiLineString& result,
+    Kernel::Vector_2& translate
+)
+{
+    typedef CGAL::Straight_skeleton_2<K> Ss ;
+
+    typedef typename Ss::Halfedge_const_handle   Halfedge_const_handle ;
+    typedef typename Ss::Halfedge_const_iterator Halfedge_const_iterator ;
+
+    // Maximum angle for touching bisectors to be
+    // retained in the ouptput. The value is in
+    // radians and represents the angle between the
+    // bisector and the defining edge.
+    //
+    // The angle between the incident edges will be double
+    // this value, so CGAL_PI / 8.0 means 45 degrees between
+    // defining edges
+    //
+    // TODO: take as parameter ?
+    //
+    // NOTE: I'm adding some tolerance here to include those angles
+    //       of exactly 45 degrees that are otherwise cut out due
+    //       to rounding precision
+    //
+    const double maxTouchingAngle = CGAL_PI / 8.0 + 1e-15;
+
+    for ( Halfedge_const_iterator it = ss.halfedges_begin(); it != ss.halfedges_end(); ++it ) {
+        // skip contour edge
+        if ( ! it->is_bisector() ) {
+            continue ;
+        }
+
+        // avoid duplicates
+        if ( it->opposite() < it ) {
+            continue ;
+        }
+
+        // Skip non-inner edges unless they bisect
+        // a low angle pair of segments
+        if ( ! it->is_inner_bisector() ) {
+
+            const Halfedge_const_handle& de1 = it->defining_contour_edge ();
+
+            // We need to check the angle formed by:
+            const Point& p1 = it->vertex()->point();
+            const Point& p2 = de1->vertex()->point();
+            const Point& p3 = de1->opposite()->vertex()->point();
+
+            double ang = angle(p1, p2, p3);
+
+            if ( ang > maxTouchingAngle ) continue ;
+        }
+
         std::auto_ptr<LineString> ls ( new LineString(
                                 Point( it->opposite()->vertex()->point() ),
                                 Point( it->vertex()->point() ) )
@@ -148,37 +237,63 @@ preparePolygon( const Polygon& poly, Kernel::Vector_2& trans )
   return ret;
 }
 
+void
+extractPolygons( const Geometry& g, std::vector< Polygon >& vect )
+{
+  switch ( g.geometryTypeId() ) {
+  case TYPE_TRIANGLE:
+      vect.push_back( g.as< Triangle >().toPolygon() );
+      break;
+  case TYPE_POLYGON:
+      vect.push_back( g.as< Polygon >() );
+      break;
+  case TYPE_MULTIPOLYGON:
+  {
+      const MultiPolygon& mp = g.as< MultiPolygon >();
+      for ( size_t i = 0; i < mp.numGeometries(); i++ ) {
+        vect.push_back( mp.polygonN( i ) );
+      }
+      break;
+  }
+  default:
+      break;
+  }
+}
+
+} // namespace anonymous
 
 ///
 ///
 ///
-std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation, NoValidityCheck, bool innerOnly )
+std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation, NoValidityCheck, bool innerOnly, bool outputDistanceInM )
 {
     switch ( g.geometryTypeId() ) {
     case TYPE_TRIANGLE:
-        return straightSkeleton( g.as< Triangle >().toPolygon(), autoOrientation, innerOnly ) ;
+        return straightSkeleton( g.as< Triangle >().toPolygon(), autoOrientation, innerOnly, outputDistanceInM ) ;
 
     case TYPE_POLYGON:
-        return straightSkeleton( g.as< Polygon >(), autoOrientation, innerOnly ) ;
+        return straightSkeleton( g.as< Polygon >(), autoOrientation, innerOnly, outputDistanceInM ) ;
 
     case TYPE_MULTIPOLYGON:
-        return straightSkeleton( g.as< MultiPolygon >(), autoOrientation, innerOnly ) ;
+        return straightSkeleton( g.as< MultiPolygon >(), autoOrientation, innerOnly, outputDistanceInM ) ;
 
     default:
         return std::auto_ptr< MultiLineString >( new MultiLineString );
     }
 }
 
-std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation, bool innerOnly )
+std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation, bool innerOnly, bool outputDistanceInM )
 {
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( g );
 
-    return straightSkeleton( g, autoOrientation, NoValidityCheck(), innerOnly );
+    std::auto_ptr<MultiLineString> result( straightSkeleton( g, autoOrientation, NoValidityCheck(), innerOnly, outputDistanceInM ) );
+    propagateValidityFlag( *result, true );
+    return result;
 }
 ///
 ///
 ///
-std::auto_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool /*autoOrientation*/, bool innerOnly )
+std::auto_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool /*autoOrientation*/, bool innerOnly, bool outputDistanceInM )
 {
     std::auto_ptr< MultiLineString > result( new MultiLineString );
 
@@ -195,7 +310,10 @@ std::auto_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool /*auto
         BOOST_THROW_EXCEPTION( Exception( "CGAL failed to create straightSkeleton" ) ) ;
     }
 
-    straightSkeletonToMultiLineString( *skeleton, *result, innerOnly, trans ) ;
+    if ( outputDistanceInM )
+        straightSkeletonToMultiLineString<Kernel, true> ( *skeleton, *result, innerOnly, trans ) ;
+    else
+        straightSkeletonToMultiLineString<Kernel, false> ( *skeleton, *result, innerOnly, trans ) ;
     return result ;
 }
 
@@ -203,7 +321,7 @@ std::auto_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool /*auto
 ///
 ///
 ///
-std::auto_ptr< MultiLineString > straightSkeleton( const MultiPolygon& g, bool /*autoOrientation*/, bool innerOnly )
+std::auto_ptr< MultiLineString > straightSkeleton( const MultiPolygon& g, bool /*autoOrientation*/, bool innerOnly, bool outputDistanceInM )
 {
     std::auto_ptr< MultiLineString > result( new MultiLineString );
 
@@ -216,7 +334,10 @@ std::auto_ptr< MultiLineString > straightSkeleton( const MultiPolygon& g, bool /
             BOOST_THROW_EXCEPTION( Exception( "CGAL failed to create straightSkeleton" ) ) ;
         }
 
-        straightSkeletonToMultiLineString( *skeleton, *result, innerOnly, trans ) ;
+        if ( outputDistanceInM )
+            straightSkeletonToMultiLineString<Kernel, true>( *skeleton, *result, innerOnly, trans ) ;
+        else
+            straightSkeletonToMultiLineString<Kernel, false>( *skeleton, *result, innerOnly, trans ) ;
     }
 
     return result ;
@@ -226,9 +347,25 @@ std::auto_ptr< MultiLineString > approximateMedialAxis( const Geometry& g )
 {
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( g );
 
-    std::auto_ptr< MultiLineString > mx =
-        straightSkeleton( g, false, NoValidityCheck(), true );
+    std::auto_ptr< MultiLineString > mx( new MultiLineString );
+
+    std::vector< Polygon > polys;
+    extractPolygons( g, polys );
+
+    for ( size_t i=0; i<polys.size(); ++i )
+    {
+        Kernel::Vector_2 trans;
+        Polygon_with_holes_2 polygon = preparePolygon( polys[i], trans );
+        boost::shared_ptr< Straight_skeleton_2 > skeleton = straightSkeleton( polygon ) ;
+
+        if ( !skeleton.get() ) {
+            BOOST_THROW_EXCEPTION( Exception( "CGAL failed to create straightSkeleton" ) ) ;
+        }
+
+        straightSkeletonToMedialAxis( *skeleton, *mx, trans ) ;
+    }
 
+    propagateValidityFlag( *mx, true );
     return mx;
 }
 
diff --git a/src/algorithm/straightSkeleton.h b/src/algorithm/straightSkeleton.h
index 8ac3b76..4bf1551 100644
--- a/src/algorithm/straightSkeleton.h
+++ b/src/algorithm/straightSkeleton.h
@@ -47,34 +47,35 @@ SFCGAL_API std::auto_ptr< MultiLineString > approximateMedialAxis( const Geometr
 /**
  * @brief build a 2D straight skeleton for a Polygon
  * @todo add supports for TriangulatedSurface and PolyhedralSurface
- * @todo output M as distance to border?
  * @param g input geometry
  * @param autoOrientation check and fix polygon orientation
+ * @param outputM whether to output the distance to border as M
  * @ingroup public_api
  * @pre g is a valid geometry
  */
-SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation = true, bool innerOnly = false ) ;
+SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation = true, bool innerOnly = false, bool outputDistanceInM = false ) ;
 
 /**
  * @brief build a 2D straight skeleton for a Polygon
  * @param g input geometry
  * @param autoOrientation check and fix polygon orientation
+ * @param outputM whether to output the distance to border as M
  * @ingroup public_api
  * @pre g is a valid geometry
  * @warning No actual validity check is done
  */
-SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation, NoValidityCheck, bool innerOnly = false ) ;
+SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const Geometry& g, bool autoOrientation, NoValidityCheck, bool innerOnly = false, bool outputDistanceInM = false ) ;
 
 /**
  * @brief build a 2D straight skeleton for a Polygon
  * @ingroup detail
  */
-SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool autoOrientation = true, bool innerOnly = false ) ;
+SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool autoOrientation = true, bool innerOnly = false, bool outputDistanceInM = false ) ;
 /**
  * @brief build a 2D straight skeleton for a Polygon
  * @ingroup detail
  */
-SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const MultiPolygon& g, bool autoOrientation = true, bool innerOnly = false ) ;
+SFCGAL_API std::auto_ptr< MultiLineString > straightSkeleton( const MultiPolygon& g, bool autoOrientation = true, bool innerOnly = false, bool outputDistanceInM = false ) ;
 
 }//namespace algorithm
 }//namespace SFCGAL
diff --git a/src/algorithm/union.cpp b/src/algorithm/union.cpp
index 257e874..47c8356 100644
--- a/src/algorithm/union.cpp
+++ b/src/algorithm/union.cpp
@@ -954,7 +954,6 @@ std::auto_ptr<Geometry> union_( const Geometry& ga, const Geometry& gb )
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( ga );
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( gb );
     std::auto_ptr<Geometry>  result( union_( ga, gb, NoValidityCheck() ) );
-    SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( *result );
     return result;
 }
 
@@ -980,7 +979,6 @@ std::auto_ptr<Geometry> union3D( const Geometry& ga, const Geometry& gb )
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( ga );
     SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( gb );
     std::auto_ptr<Geometry>  result( union3D( ga, gb, NoValidityCheck() ) );
-    SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( *result );
     return result;
 }
 
diff --git a/src/capi/sfcgal_c.cpp b/src/capi/sfcgal_c.cpp
index e8b32b6..e466b4c 100644
--- a/src/capi/sfcgal_c.cpp
+++ b/src/capi/sfcgal_c.cpp
@@ -137,9 +137,8 @@ extern "C" const char* sfcgal_version()
     return SFCGAL::Version();
 }
 
-extern "C" void sfcgal_set_geometry_validation( int enabled )
+extern "C" void sfcgal_set_geometry_validation( int /*enabled*/ )
 {
-    SFCGAL::algorithm::SKIP_GEOM_VALIDATION = !enabled;
 }
 
 extern "C" sfcgal_geometry_type_t sfcgal_geometry_type_id( const sfcgal_geometry_t* geom )
@@ -161,6 +160,36 @@ extern "C" int sfcgal_geometry_is_valid( const sfcgal_geometry_t* geom )
     )
 }
 
+extern "C" int sfcgal_geometry_is_valid_detail( const sfcgal_geometry_t* geom, char** invalidity_reason, sfcgal_geometry_t** invalidity_location )
+{
+    // invalidity location is not supported for now
+    if ( invalidity_location )
+        *invalidity_location = 0;
+    // set to null for now
+    if ( invalidity_reason )
+        *invalidity_reason = 0;
+
+    const SFCGAL::Geometry* g = reinterpret_cast<const SFCGAL::Geometry*>( geom );
+    if ( g->hasValidityFlag() )
+        return true;
+    bool is_valid = false;
+    try
+    {
+        SFCGAL::Validity validity = SFCGAL::algorithm::isValid( *g );
+        is_valid = validity;
+        if ( !is_valid && invalidity_reason ) {
+            *invalidity_reason = strdup( validity.reason().c_str() );
+        }
+    }
+    catch ( SFCGAL::Exception& e )
+    {
+        if ( invalidity_reason ) {
+            *invalidity_reason = strdup( e.what() );
+        }
+    }
+    return is_valid;
+}
+
 extern "C" int sfcgal_geometry_is_3d( const sfcgal_geometry_t* geom )
 {
     SFCGAL_GEOMETRY_CONVERT_CATCH_TO_ERROR(
@@ -984,3 +1013,32 @@ extern "C" sfcgal_geometry_t* sfcgal_geometry_offset_polygon( const sfcgal_geome
     return mp.release();
 }
 
+extern "C" void sfcgal_geometry_force_valid( sfcgal_geometry_t* geom, int valid )
+{
+    SFCGAL::Geometry* g1 = reinterpret_cast<SFCGAL::Geometry*>( geom );
+    SFCGAL::algorithm::propagateValidityFlag( *g1, valid != 0 );
+}
+
+extern "C" int sfcgal_geometry_has_validity_flag( const sfcgal_geometry_t* geom )
+{
+    const SFCGAL::Geometry* g1 = reinterpret_cast<const SFCGAL::Geometry*>( geom );
+    return g1->hasValidityFlag() ? 1 : 0;
+}
+
+extern "C" sfcgal_geometry_t* sfcgal_geometry_straight_skeleton_distance_in_m( const sfcgal_geometry_t* geom )
+{
+    const SFCGAL::Geometry* g1 = reinterpret_cast<const SFCGAL::Geometry*>( geom );
+    std::auto_ptr<SFCGAL::MultiLineString> mls;
+
+    try {
+        mls = SFCGAL::algorithm::straightSkeleton( *g1, /*autoOrientation*/ true, /*innerOnly*/ false, /*outputDistanceInM*/ true );
+    }
+    catch ( std::exception& e ) {
+        SFCGAL_WARNING( "During straight_skeleton_distance_in_m(A):" );
+        SFCGAL_WARNING( "  with A: %s", ( ( const SFCGAL::Geometry* )( geom ) )->asText().c_str() );
+        SFCGAL_ERROR( "%s", e.what() );
+        return 0;
+    }
+
+    return mls.release();
+}
diff --git a/src/capi/sfcgal_c.h b/src/capi/sfcgal_c.h
index 617e593..3e7e412 100644
--- a/src/capi/sfcgal_c.h
+++ b/src/capi/sfcgal_c.h
@@ -81,6 +81,7 @@ typedef enum {
 /**
  * Set the geometry validation mode
  * @ingroup capi
+ * @note obsolete
  */
 SFCGAL_API void                      sfcgal_set_geometry_validation( int enabled );
 
@@ -97,6 +98,16 @@ SFCGAL_API sfcgal_geometry_type_t    sfcgal_geometry_type_id( const sfcgal_geome
 SFCGAL_API int                       sfcgal_geometry_is_valid( const sfcgal_geometry_t* );
 
 /**
+ * Tests if the given geometry is valid or not
+ * And return details in case of invalidity
+ * @param geom the input geometry
+ * @param invalidity_reason input/output parameter. If non null, a null-terminated string could be allocated and contain reason of the invalidity
+ * @param invalidity_location input/output parameter. If non null, a geometry could be allocated and contain the location of the invalidity
+ * @ingroup capi
+ */
+SFCGAL_API int                       sfcgal_geometry_is_valid_detail( const sfcgal_geometry_t* geom, char** invalidity_reason, sfcgal_geometry_t** invalidity_location );
+
+/**
  * Tests if the given geometry is 3D or not
  * @ingroup capi
  */
@@ -463,6 +474,17 @@ SFCGAL_API const sfcgal_geometry_t*  sfcgal_solid_shell_n( const sfcgal_geometry
 SFCGAL_API void                      sfcgal_solid_add_shell( sfcgal_geometry_t* solid, sfcgal_geometry_t* shell );
 
 
+/**
+ * Gets the validity flag of the geometry.
+ */
+int sfcgal_geometry_has_validity_flag( const sfcgal_geometry_t* geom );
+
+/**
+ * Sets the validity flag of the geometry.
+ * FIXME We better have geometry constructors to directly build valid geometries
+ */
+void sfcgal_geometry_force_valid( sfcgal_geometry_t* geom, int valid );
+
 /*--------------------------------------------------------------------------------------*
  *
  * Support for SFCGAL::PreparedGeometry
@@ -783,6 +805,14 @@ SFCGAL_API sfcgal_geometry_t*          sfcgal_geometry_offset_polygon( const sfc
 SFCGAL_API sfcgal_geometry_t*          sfcgal_geometry_straight_skeleton( const sfcgal_geometry_t* geom );
 
 /**
+ * Returns the straight skeleton of the given Geometry with the distance to the border as M coordinate
+ * @pre isValid(geom) == true
+ * @post isValid(return) == true
+ * @ingroup capi
+ */
+SFCGAL_API sfcgal_geometry_t*          sfcgal_geometry_straight_skeleton_distance_in_m( const sfcgal_geometry_t* geom );
+
+/**
  * Returns the approximate medial axis for the given Polygon
  * Approximate medial axis is based on straight skeleton
  * @pre isValid(geom) == true
diff --git a/src/detail/ForceValidityVisitor.cpp b/src/detail/ForceValidityVisitor.cpp
new file mode 100644
index 0000000..ad64ec9
--- /dev/null
+++ b/src/detail/ForceValidityVisitor.cpp
@@ -0,0 +1,171 @@
+/**
+ *   SFCGAL
+ *
+ *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
+ *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU Library General Public
+ *   License as published by the Free Software Foundation; either
+ *   version 2 of the License, or (at your option) any later version.
+ *
+ *   This library 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
+ *   Library General Public License for more details.
+
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <SFCGAL/detail/ForceValidityVisitor.h>
+
+#include <SFCGAL/Point.h>
+#include <SFCGAL/LineString.h>
+#include <SFCGAL/Polygon.h>
+#include <SFCGAL/Triangle.h>
+#include <SFCGAL/PolyhedralSurface.h>
+#include <SFCGAL/TriangulatedSurface.h>
+#include <SFCGAL/Solid.h>
+#include <SFCGAL/GeometryCollection.h>
+#include <SFCGAL/MultiPoint.h>
+#include <SFCGAL/MultiLineString.h>
+#include <SFCGAL/MultiPolygon.h>
+#include <SFCGAL/MultiSolid.h>
+
+namespace SFCGAL {
+namespace detail {
+
+///
+///
+///
+void ForceValidityVisitor::visit( Point& g )
+{
+    g.forceValidityFlag( valid_ );
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( LineString& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numPoints(); i++ ) {
+        visit( g.pointN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( Polygon& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numRings(); i++ ) {
+        visit( g.ringN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( Triangle& g )
+{
+    g.forceValidityFlag( valid_ );
+    visit( g.vertex( 0 ) );
+    visit( g.vertex( 1 ) );
+    visit( g.vertex( 2 ) );
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( Solid& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numShells(); i++ ) {
+        visit( g.shellN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( MultiPoint& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
+        visit( g.pointN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( MultiLineString& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
+        visit( g.lineStringN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( MultiPolygon& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
+        visit( g.polygonN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( MultiSolid& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
+        visit( g.solidN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( GeometryCollection& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
+        g.geometryN( i ).accept( *this );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( PolyhedralSurface& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numPolygons(); i++ ) {
+        visit( g.polygonN( i ) );
+    }
+}
+
+///
+///
+///
+void ForceValidityVisitor::visit( TriangulatedSurface& g )
+{
+    g.forceValidityFlag( valid_ );
+    for ( size_t i = 0; i < g.numGeometries(); i++ ) {
+        visit( g.geometryN( i ) );
+    }
+}
+
+
+
+}//detail
+}//SFCGAL
diff --git a/src/io/asc.h b/src/detail/ForceValidityVisitor.h
similarity index 50%
rename from src/io/asc.h
rename to src/detail/ForceValidityVisitor.h
index 5153219..1862947 100644
--- a/src/io/asc.h
+++ b/src/detail/ForceValidityVisitor.h
@@ -18,26 +18,38 @@
  *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _SFCGAL_IO_ASC_H_
-#define _SFCGAL_IO_ASC_H_
+#ifndef _SFCGAL_DETAIL_FORCEVALIDITY_VISITOR_H_
+#define _SFCGAL_DETAIL_FORCEVALIDITY_VISITOR_H_
 
 #include <SFCGAL/config.h>
 
-#include <sstream>
-
-#include <SFCGAL/Grid.h>
+#include <SFCGAL/GeometryVisitor.h>
 
 namespace SFCGAL {
-namespace io {
-
-/**
- * @brief read ASC grid from input stream
- * @see http://en.wikipedia.org/wiki/Esri_grid
- */
-SFCGAL_API std::auto_ptr< Grid > readASC( std::istream& s ) ;
-
+namespace detail {
+
+class SFCGAL_API ForceValidityVisitor : public GeometryVisitor {
+public:
+    ForceValidityVisitor( bool valid ) : valid_( valid ) {}    
+    virtual void visit( Point& g ) ;
+    virtual void visit( LineString& g ) ;
+    virtual void visit( Polygon& g ) ;
+    virtual void visit( Triangle& g ) ;
+    virtual void visit( Solid& g ) ;
+    virtual void visit( MultiPoint& g ) ;
+    virtual void visit( MultiLineString& g ) ;
+    virtual void visit( MultiPolygon& g ) ;
+    virtual void visit( MultiSolid& g ) ;
+    virtual void visit( GeometryCollection& g ) ;
+    virtual void visit( PolyhedralSurface& g ) ;
+    virtual void visit( TriangulatedSurface& g ) ;
+ private:
+    bool valid_;
+};
+
+
+}//detail
+}//SFCGAL
 
-} // namespace io
-} // namespace SFCGAL
 
 #endif
diff --git a/src/detail/io/WktReader.cpp b/src/detail/io/WktReader.cpp
index 3b8c925..1c1c98a 100644
--- a/src/detail/io/WktReader.cpp
+++ b/src/detail/io/WktReader.cpp
@@ -381,7 +381,7 @@ void    WktReader::readInnerMultiPoint( MultiPoint& g )
             }
         }
 
-        g.addGeometry( p.release() );
+        if ( !p->isEmpty() ) g.addGeometry( p.release() );
 
         //break if not followed by another points
         if ( ! _reader.match( ',' ) ) {
@@ -412,7 +412,7 @@ void   WktReader::readInnerMultiLineString( MultiLineString& g )
 
         std::auto_ptr< LineString > lineString( new LineString() );
         readInnerLineString( *lineString );
-        g.addGeometry( lineString.release() );
+        if ( !lineString->isEmpty() ) g.addGeometry( lineString.release() );
 
         //break if not followed by another points
         if ( ! _reader.match( ',' ) ) {
@@ -442,7 +442,7 @@ void   WktReader::readInnerMultiPolygon( MultiPolygon& g )
 
         std::auto_ptr< Polygon > polygon( new Polygon() );
         readInnerPolygon( *polygon );
-        g.addGeometry( polygon.release() );
+        if ( !polygon->isEmpty() ) g.addGeometry( polygon.release() );
 
         //break if not followed by another points
         if ( ! _reader.match( ',' ) ) {
@@ -471,7 +471,9 @@ void   WktReader::readInnerGeometryCollection( GeometryCollection& g )
     while( ! _reader.eof() ) {
 
         //read a full wkt geometry ex : POINT(2.0 6.0)
-        g.addGeometry( readGeometry() );
+        Geometry* gg = readGeometry();
+        if ( !gg->isEmpty() )
+            g.addGeometry( gg );
 
         //break if not followed by another points
         if ( ! _reader.match( ',' ) ) {
@@ -597,7 +599,7 @@ void WktReader::readInnerMultiSolid( MultiSolid& g )
 
         std::auto_ptr< Solid > solid( new Solid() );
         readInnerSolid( *solid );
-        g.addGeometry( solid.release() );
+        if ( !solid->isEmpty() ) g.addGeometry( solid.release() );
 
         //break if not followed by another points
         if ( ! _reader.match( ',' ) ) {
diff --git a/src/detail/tools/Log.h b/src/detail/tools/Log.h
index a8add24..18b5a64 100644
--- a/src/detail/tools/Log.h
+++ b/src/detail/tools/Log.h
@@ -26,10 +26,6 @@
 #include <string>
 #include <boost/format.hpp>
 
-#include <boost/iostreams/concepts.hpp>
-#include <boost/iostreams/stream.hpp>
-
-
 /**
  *
  * Helper method to log debug message
diff --git a/src/detail/transform/AffineTransform2.cpp b/src/detail/transform/AffineTransform2.cpp
index 3cafe6a..f181232 100644
--- a/src/detail/transform/AffineTransform2.cpp
+++ b/src/detail/transform/AffineTransform2.cpp
@@ -40,7 +40,11 @@ AffineTransform2::AffineTransform2( CGAL::Aff_transformation_2< Kernel > transfo
 void AffineTransform2::transform( Point& p )
 {
     if ( ! p.isEmpty() ) {
-        p = Point( p.toPoint_2().transform( _transform ) );
+        // FIXME add a Point::Point( Kernel::Point_2&, double m );
+        Point pt( p.toPoint_2().transform( _transform ) );
+        if ( p.isMeasured() )
+            pt.setM( p.m() );
+        p = pt;
     }
 }
 
diff --git a/src/detail/transform/AffineTransform3.cpp b/src/detail/transform/AffineTransform3.cpp
index a25f8bb..3215a31 100644
--- a/src/detail/transform/AffineTransform3.cpp
+++ b/src/detail/transform/AffineTransform3.cpp
@@ -54,7 +54,10 @@ AffineTransform3::AffineTransform3( CGAL::Aff_transformation_3< Kernel > transfo
 void AffineTransform3::transform( Point& p )
 {
     if ( ! p.isEmpty() ) {
-        p = Point( p.toPoint_3().transform( _transform ) ) ;
+        Point pt ( p.toPoint_3().transform( _transform ) );
+        if ( p.isMeasured() )
+            pt.setM( p.m() );
+        p = pt;
     }
 }
 
diff --git a/src/detail/transform/Force2D.cpp b/src/detail/transform/Force2D.cpp
index 21c832c..26567e2 100644
--- a/src/detail/transform/Force2D.cpp
+++ b/src/detail/transform/Force2D.cpp
@@ -31,7 +31,10 @@ namespace transform {
 void Force2D::transform( Point& p )
 {
     if ( ! p.isEmpty() && p.is3D() ) {
-        p = Point( p.x(), p.y() );
+        Point pt( p.x(), p.y() );
+        if ( p.isMeasured() )
+            pt.setM( p.m() );
+        p = pt;
     }
 }
 
diff --git a/src/detail/transform/ForceZ.cpp b/src/detail/transform/ForceZ.cpp
index c00aa87..fa8f44c 100644
--- a/src/detail/transform/ForceZ.cpp
+++ b/src/detail/transform/ForceZ.cpp
@@ -40,7 +40,10 @@ ForceZ::ForceZ( const Kernel::FT& defaultZ ):
 void ForceZ::transform( Point& p )
 {
     if ( ! p.isEmpty() && ! p.is3D() ) {
-        p = Point( p.x(), p.y(), _defaultZ );
+        Point pt( p.x(), p.y(), _defaultZ );
+        if ( p.isMeasured() )
+            pt.setM( p.m() );
+        p = pt;
     }
 }
 
diff --git a/src/io/asc.cpp b/src/io/asc.cpp
deleted file mode 100644
index 991a250..0000000
--- a/src/io/asc.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <SFCGAL/io/asc.h>
-
-#include <boost/format.hpp>
-
-#include <SFCGAL/Exception.h>
-#include <SFCGAL/detail/tools/InputStreamReader.h>
-
-using namespace SFCGAL::detail;
-
-namespace SFCGAL {
-namespace io {
-
-///
-///
-///
-std::auto_ptr< Grid > readASC( std::istream& s )
-{
-    tools::InputStreamReader reader( s );
-
-    //ncols         4
-    size_t ncols ;
-
-    if ( ! reader.match( "ncols" ) || ! reader.read( ncols ) ) {
-        BOOST_THROW_EXCEPTION( Exception( "expecting ncols <ncols>" ) );
-    }
-
-    //nrows         6
-    size_t nrows ;
-
-    if ( ! reader.match( "nrows" ) || ! reader.read( nrows ) ) {
-        BOOST_THROW_EXCEPTION( Exception( "expecting nrows <nrows>" ) );
-    }
-
-    //xllcorner     0.0
-    double xllcorner ;
-
-    if ( ! reader.match( "xllcorner" ) || ! reader.read( xllcorner ) ) {
-        BOOST_THROW_EXCEPTION( Exception( "expecting xllcorner <xllcorner>" ) );
-    }
-
-    //yllcorner     0.0
-    double yllcorner ;
-
-    if ( ! reader.match( "yllcorner" ) || ! reader.read( yllcorner ) ) {
-        BOOST_THROW_EXCEPTION( Exception( "expecting yllcorner <yllcorner>" ) );
-    }
-
-    //cellsize      50.0
-    double cellsize ;
-
-    if ( ! reader.match( "cellsize" ) || ! reader.read( cellsize ) ) {
-        BOOST_THROW_EXCEPTION( Exception( "expecting cellsize <cellsize>" ) );
-    }
-
-    //NODATA_value  -9999
-    double NODATA_value ;
-
-    if ( ! reader.match( "NODATA_value" ) || ! reader.read( NODATA_value ) ) {
-        BOOST_THROW_EXCEPTION( Exception( "expecting NODATA_value <NODATA_value>" ) );
-    }
-
-    /*
-     * a matrix and read data
-     */
-    ublas::matrix< double > data( nrows, ncols );
-
-    //-9999 -9999 5 2
-    //-9999 20 100 36
-    //3 8 35 10
-    //32 42 50 6
-    //88 75 27 9
-    //13 5 1 -9999
-    for ( size_t i = 0; i < nrows; i++ ) {
-        for ( size_t j = 0; j < ncols; j++ ) {
-            double value ;
-
-            if ( ! reader.read( value ) ) {
-                BOOST_THROW_EXCEPTION( Exception(
-                                           ( boost::format( "fail to read data(%s,%s) value" ) % i % j ).str()
-                                       ) );
-            }
-
-            if ( value == NODATA_value ) {
-                data( i,j ) = NaN() ;
-            }
-            else {
-                data( i,j ) = value ;
-            }
-        }
-    }
-
-    /*
-     * produce the resulting grid
-     */
-    Envelope limits(
-        xllcorner, xllcorner + cellsize * ncols,
-        yllcorner, yllcorner + cellsize * nrows
-    );
-    return std::auto_ptr< Grid >( new Grid( data, limits, PIXEL_IS_AREA ) ) ;
-}
-
-
-} // namespace io
-} // namespace SFCGAL
-
diff --git a/src/io/wkt.cpp b/src/io/wkt.cpp
index a61305d..93c7f5b 100644
--- a/src/io/wkt.cpp
+++ b/src/io/wkt.cpp
@@ -23,6 +23,7 @@
 #include <SFCGAL/detail/io/WktReader.h>
 #include <SFCGAL/detail/io/WktWriter.h>
 #include <SFCGAL/detail/tools/CharArrayBuffer.h>
+#include <SFCGAL/Exception.h>
 
 using namespace SFCGAL::detail::io;
 
@@ -45,7 +46,14 @@ std::auto_ptr< Geometry > readWkt( const std::string& s )
 {
     std::istringstream iss( s );
     WktReader wktReader( iss );
-    return std::auto_ptr< Geometry >( wktReader.readGeometry() );
+    std::auto_ptr< Geometry > geom( wktReader.readGeometry() );
+
+    char extra;
+    if ( iss >> extra ) {
+        std::string remaining( s.substr( int(iss.tellg()) - 1 ) );
+        throw WktParseException( "Extra characters in WKT: " + remaining );
+    }
+    return geom;
 }
 
 ///
@@ -56,7 +64,13 @@ std::auto_ptr< Geometry > readWkt( const char* str, size_t len )
     CharArrayBuffer buf( str, str + len );
     std::istream istr( &buf );
     WktReader wktReader( istr );
-    return std::auto_ptr< Geometry >( wktReader.readGeometry() );
+    std::auto_ptr< Geometry > geom( wktReader.readGeometry() );
+    char extra;
+    if ( istr >> extra ) {
+        std::string remaining( str + int(istr.tellg()) - 1, str + len );
+        throw WktParseException( "Extra characters in WKT: " + remaining );
+    }
+    return geom;
 }
 
 }//io
diff --git a/src/triangulate/triangulate2DZ.cpp b/src/triangulate/triangulate2DZ.cpp
index a412997..ddeeffb 100644
--- a/src/triangulate/triangulate2DZ.cpp
+++ b/src/triangulate/triangulate2DZ.cpp
@@ -106,7 +106,7 @@ void triangulate2DZ( const Geometry& g, ConstraintDelaunayTriangulation& triangu
     }
 
     if ( triangulation.hasProjectionPlane() ) {
-        SFCGAL_ASSERT_GEOMETRY_VALIDITY_ON_PLANE( g, triangulation.projectionPlane() );
+        SFCGAL_ASSERT_GEOMETRY_VALIDITY_ON_PLANE( g );
     }
     else {
         SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( g );
diff --git a/test/bench/BenchPredicate.cpp b/test/bench/BenchPredicate.cpp
new file mode 100644
index 0000000..b9f4f85
--- /dev/null
+++ b/test/bench/BenchPredicate.cpp
@@ -0,0 +1,73 @@
+/**
+ *   SFCGAL
+ *
+ *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
+ *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
+ *
+ *   This library is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU Library General Public
+ *   License as published by the Free Software Foundation; either
+ *   version 2 of the License, or (at your option) any later version.
+ *
+ *   This library 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
+ *   Library General Public License for more details.
+
+ *   You should have received a copy of the GNU Library General Public
+ *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+#include "../test_config.h"
+#include "Bench.h"
+
+#include <boost/test/unit_test.hpp>
+
+#include <SFCGAL/MultiPolygon.h>
+#include <SFCGAL/detail/generator/sierpinski.h>
+#include <SFCGAL/detail/GetPointsVisitor.h>
+
+using namespace boost::unit_test ;
+using namespace SFCGAL ;
+
+BOOST_AUTO_TEST_SUITE( SFCGAL_BenchPredicate )
+
+
+double randf()
+{
+    return double(rand()) / RAND_MAX;
+}
+
+BOOST_AUTO_TEST_CASE( testPointCompare )
+{
+    std::vector<CGAL::Point_3<Kernel> > points;
+    for ( size_t i = 0; i < 10000; i++ ) {
+        points.push_back( CGAL::Point_3<Kernel>( randf(), randf(), randf() ) );
+    }
+
+    bench().start( "xyz" ) ;
+
+    for ( size_t i = 0; i < points.size(); i++ ) {
+        for ( size_t j = 0; j < points.size(); j++ ) {
+            points[i].x() < points[j].x();
+        }
+    }
+
+    bench().stop();
+
+
+    bench().start( "compare" ) ;
+
+    for ( size_t i = 0; i < points.size(); i++ ) {
+        for ( size_t j = 0; j < points.size(); j++ ) {
+            CGAL::compare_x<Kernel>( points[i], points[j] );
+        }
+    }
+
+    bench().stop();
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+
+
+
diff --git a/test/data/CoversTest.txt b/test/data/CoversTest.txt
index 90c4fb1..67aca3a 100644
--- a/test/data/CoversTest.txt
+++ b/test/data/CoversTest.txt
@@ -112,8 +112,8 @@
 3|POLYGON((0 0,1 0,1 1,0 1,0 0),(0.4 0.4,0.4 0.6,0.6 0.6,0.6 0.4,0.4 0.4))|POLYGON((0 0,1 0,1 1,0 1,0 0),(0.4 0.4,0.4 0.6,0.6 0.6,0.6 0.4,0.4 0.4))|true
 3|POLYGON((0 0,1 0,1 1,0 1,0 0))|POLYGON((0 0,1 0,1 1,0 1,0 0),(0.4 0.4,0.4 0.6,0.6 0.6,0.6 0.4,0.4 0.4))|true
 
-3|POLYGON((1/1 1/4 1/2,1/1 0/1 1/2,1/2 0/1 1/2,1/2 1/2 1/2,1/1 1/4 1/2))|POLYGON((1/1 1/2 1/2,1/1 1/4 1/2,1/2 1/2 1/2,1/1 1/2 1/2)))|false
-3|POLYGON((1/1 1/2 1/2,1/1 1/4 1/2,1/2 1/2 1/2,1/1 1/2 1/2)))|POLYGON((1/1 1/4 1/2,1/1 0/1 1/2,1/2 0/1 1/2,1/2 1/2 1/2,1/1 1/4 1/2))|false
+3|POLYGON((1/1 1/4 1/2,1/1 0/1 1/2,1/2 0/1 1/2,1/2 1/2 1/2,1/1 1/4 1/2))|POLYGON((1/1 1/2 1/2,1/1 1/4 1/2,1/2 1/2 1/2,1/1 1/2 1/2))|false
+3|POLYGON((1/1 1/2 1/2,1/1 1/4 1/2,1/2 1/2 1/2,1/1 1/2 1/2))|POLYGON((1/1 1/4 1/2,1/1 0/1 1/2,1/2 0/1 1/2,1/2 1/2 1/2,1/1 1/4 1/2))|false
 
 # TIN|Point
 2|TIN(((0.6 0.4,0.4 0.4,0 0,0.6 0.4)),((0.6 0.4,0 0,1 0,0.6 0.4)),((0 1,0 0,0.4 0.4,0 1)),((0 1,0.4 0.6,0.6 0.6,0 1)),((0 1,0.4 0.4,0.4 0.6,0 1)),((1 1,0.6 0.6,1 0,1 1)),((1 1,0 1,0.6 0.6,1 1)),((0.6 0.6,0.6 0.4,1 0,0.6 0.6)))|POINT(0 0)|true
diff --git a/test/garden/main.cpp b/test/garden/main.cpp
index f4c51f8..5424612 100644
--- a/test/garden/main.cpp
+++ b/test/garden/main.cpp
@@ -75,7 +75,6 @@ int main( int argc, char* argv[] )
     ( "help", "produce help message" )
     ( "progress", "display progress" )
     ( "verbose",  "verbose mode" )
-    ( "novalidate",  "remove validation of input geometries" )
     ( "vtk",  "output vtk geom on failure" )
     ;
 
@@ -92,9 +91,6 @@ int main( int argc, char* argv[] )
     bool progress = vm.count( "progress" ) != 0 ;
     bool vtk = vm.count( "vtk" ) != 0 ;
 
-    SFCGAL::algorithm::SKIP_GEOM_VALIDATION = vm.count( "novalidate" ) != 0 ;
-
-
     //boost::timer timer ;
     boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
 
@@ -428,6 +424,7 @@ int main( int argc, char* argv[] )
         }
 
         CATCH_INVALID_GEOM_AND_NOT_IMPLEMENTED( ( void )algorithm::straightSkeleton( *geom1 ) ; )
+        CATCH_INVALID_GEOM_AND_NOT_IMPLEMENTED( ( void )algorithm::straightSkeleton( *geom1, /*autoOrientation*/ false, /*innerOnly*/ true, /*outputDistanceInM*/ true ) ; )
         CATCH_INVALID_GEOM_AND_NOT_IMPLEMENTED( ( void )algorithm::tesselate( *geom1 ) ; )
 
         CATCH_INVALID_GEOM_AND_NOT_IMPLEMENTED(
diff --git a/test/regress/standalone/SFCGAL/ASCTest.cpp b/test/regress/standalone/SFCGAL/ASCTest.cpp
deleted file mode 100644
index 49cd02d..0000000
--- a/test/regress/standalone/SFCGAL/ASCTest.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <fstream>
-
-#include <SFCGAL/Point.h>
-#include <SFCGAL/LineString.h>
-#include <SFCGAL/Polygon.h>
-#include <SFCGAL/Triangle.h>
-#include <SFCGAL/PolyhedralSurface.h>
-#include <SFCGAL/TriangulatedSurface.h>
-#include <SFCGAL/Solid.h>
-#include <SFCGAL/GeometryCollection.h>
-#include <SFCGAL/MultiPoint.h>
-#include <SFCGAL/MultiLineString.h>
-#include <SFCGAL/MultiPolygon.h>
-#include <SFCGAL/MultiSolid.h>
-#include <SFCGAL/io/asc.h>
-
-#include "../../../test_config.h"
-
-#include <boost/test/unit_test.hpp>
-using namespace boost::unit_test ;
-
-using namespace SFCGAL ;
-
-BOOST_AUTO_TEST_SUITE( SFCGAL_ASCTest )
-
-BOOST_AUTO_TEST_CASE( testReadExample )
-{
-    std::string filename( SFCGAL_TEST_DIRECTORY );
-    filename += "/data/example.asc" ;
-
-    std::ifstream ifs( filename.c_str() );
-    BOOST_REQUIRE( ifs.good() ) ;
-    std::auto_ptr< Grid > grid( io::readASC( ifs ) ) ;
-    BOOST_CHECK_EQUAL( grid->ncols(), 4U );
-    BOOST_CHECK_EQUAL( grid->nrows(), 6U );
-
-    BOOST_CHECK_EQUAL( grid->dx(), 50.0 );
-    BOOST_CHECK_EQUAL( grid->dy(), 50.0 );
-
-    Envelope limits = grid->limits();
-    BOOST_CHECK_EQUAL( limits.xMin(), 0.0 );
-    BOOST_CHECK_EQUAL( limits.xMax(), 200.0 );
-    BOOST_CHECK_EQUAL( limits.yMin(), 0.0 );
-    BOOST_CHECK_EQUAL( limits.yMax(), 300.0 );
-
-    // first line
-    BOOST_CHECK( isNaN( grid->z( 0,0 ) ) );
-    BOOST_CHECK( isNaN( grid->z( 0,1 ) ) );
-    BOOST_CHECK_EQUAL( grid->z( 0,2 ), 5.0 );
-    BOOST_CHECK_EQUAL( grid->z( 0,3 ), 2.0 );
-
-    // last line
-    BOOST_CHECK_EQUAL( grid->z( 5,0 ), 13.0 );
-    BOOST_CHECK_EQUAL( grid->z( 5,1 ), 5.0 );
-    BOOST_CHECK_EQUAL( grid->z( 5,2 ), 1.0 );
-    BOOST_CHECK( isNaN( grid->z( 5,3 ) ) );
-
-    // pixel is area convention
-    BOOST_CHECK_EQUAL( grid->pixelConvention(), PIXEL_IS_AREA ) ;
-    Point a00 = grid->point( 0,0 );
-    BOOST_CHECK_EQUAL( a00.x(), 25.0 );
-    BOOST_CHECK_EQUAL( a00.y(), 275.0 );
-
-    {
-        grid->setPixelConvention( PIXEL_IS_AREA );
-        std::auto_ptr< TriangulatedSurface > triangulatedSurface( grid->toTrianguledSurface() ) ;
-        std::string expected( "TIN M(((75.00000 225.00000 20.00000,125.00000 225.00000 100.00000,125.00000 275.00000 5.00000,75.00000 225.00000 20.00000)),((125.00000 225.00000 100.00000,175.00000 225.00000 36.00000,175.00000 275.00000 2.00000,125.00000 225.00000 100.00000)),((125.00000 225.00000 100.00000,175.00000 275.00000 2.00000,125.00000 275.00000 5.00000,125.00000 225.00000 100.00000)),((25.00000 175.00000 3.00000,75.00000 175.00000 8.00000,75.00000 225.00000 20.00000,25.00000 175 [...]
-        BOOST_CHECK_EQUAL( triangulatedSurface->asText( 5 ), expected );
-    }
-    {
-        grid->setPixelConvention( PIXEL_IS_POINT );
-        std::auto_ptr< TriangulatedSurface > triangulatedSurface( grid->toTrianguledSurface() ) ;
-        std::string expected( "TIN M(((66.66667 240.00000 20.00000,133.33333 240.00000 100.00000,133.33333 300.00000 5.00000,66.66667 240.00000 20.00000)),((133.33333 240.00000 100.00000,200.00000 240.00000 36.00000,200.00000 300.00000 2.00000,133.33333 240.00000 100.00000)),((133.33333 240.00000 100.00000,200.00000 300.00000 2.00000,133.33333 300.00000 5.00000,133.33333 240.00000 100.00000)),((0.00000 180.00000 3.00000,66.66667 180.00000 8.00000,66.66667 240.00000 20.00000,0.00000 180.0 [...]
-        BOOST_CHECK_EQUAL( triangulatedSurface->asText( 5 ), expected );
-    }
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-
-
-
diff --git a/test/unit/SFCGAL/GridTest.cpp b/test/unit/SFCGAL/GridTest.cpp
deleted file mode 100644
index e4a581e..0000000
--- a/test/unit/SFCGAL/GridTest.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/Grid.h>
-#include <SFCGAL/TriangulatedSurface.h>
-
-#include <boost/test/unit_test.hpp>
-using namespace boost::unit_test ;
-
-using namespace SFCGAL ;
-
-BOOST_AUTO_TEST_SUITE( SFCGAL_GridTest )
-
-///Grid();
-
-BOOST_AUTO_TEST_CASE( defaultConstructor )
-{
-    Grid g;
-    BOOST_CHECK( g.isEmpty() ) ;
-    BOOST_CHECK_EQUAL( g.pixelConvention(), PIXEL_IS_POINT );
-    BOOST_CHECK_EQUAL( g.ncols(), 0U );
-    BOOST_CHECK_EQUAL( g.nrows(), 0U );
-}
-
-
-///Grid(
-//	const size_t & nrows,
-//	const size_t & ncols,
-//	const double& fillValue = NaN(),
-//	const Envelope & limits = Envelope(0.0,1.0,0.0,1.0),
-//	const PixelConvention & pixelType = PIXEL_IS_POINT
-//);
-
-BOOST_AUTO_TEST_CASE( constructorWithSize )
-{
-    Grid g( 4, 2, 5.0 );
-    BOOST_CHECK_EQUAL( g.pixelConvention(), PIXEL_IS_POINT );
-    BOOST_CHECK_EQUAL( g.nrows(), 4U );
-    BOOST_CHECK_EQUAL( g.ncols(), 2U );
-
-    for ( size_t i = 0; i < g.nrows(); i++ ) {
-        for ( size_t j = 0; j < g.ncols(); j++ ) {
-            BOOST_CHECK_EQUAL( g.z( i,j ), 5.0 );
-        }
-    }
-}
-
-//Grid(
-//	const ublas::matrix< double > & data,
-//	const Envelope & limits = Envelope(0.0,1.0,0.0,1.0),
-//	const PixelConvention & pixelType = PIXEL_IS_POINT
-//);
-
-BOOST_AUTO_TEST_CASE( constructorWithMatrix )
-{
-    detail::ublas::matrix< double > data = detail::ublas::identity_matrix< double >( 5 );
-    Grid g( data );
-    BOOST_CHECK_EQUAL( g.pixelConvention(), PIXEL_IS_POINT );
-    BOOST_CHECK_EQUAL( g.nrows(), 5U );
-    BOOST_CHECK_EQUAL( g.ncols(), 5U );
-
-    for ( size_t i = 0; i < g.nrows(); i++ ) {
-        for ( size_t j = 0; j < g.ncols(); j++ ) {
-            if ( i == j ) {
-                BOOST_CHECK_EQUAL( g.z( i,j ), 1.0 );
-            }
-            else {
-                BOOST_CHECK_EQUAL( g.z( i,j ), 0.0 );
-            }
-        }
-    }
-}
-
-
-
-//Grid( const Grid & other );
-//Grid& operator = ( const Grid & other );
-//~Grid();
-//
-//inline bool isEmpty() const
-//
-//inline Point point( const size_t & row, const size_t & col ) const ;
-
-BOOST_AUTO_TEST_CASE( testPoint_PixelIsPoint )
-{
-    Grid g( 5, 5, 0.0, Envelope( 0.0,4.0,0.0,4.0 ) );
-    g.setPixelConvention( PIXEL_IS_POINT );
-    BOOST_CHECK_EQUAL( g.point( 0,0 ).x(), 0.0 );
-    BOOST_CHECK_EQUAL( g.point( 0,0 ).y(), 4.0 );
-
-    BOOST_CHECK_EQUAL( g.point( 1,1 ).x(), 1.0 );
-    BOOST_CHECK_EQUAL( g.point( 1,1 ).y(), 3.0 );
-
-    BOOST_CHECK_EQUAL( g.point( 4,4 ).x(), 4.0 );
-    BOOST_CHECK_EQUAL( g.point( 4,4 ).y(), 0.0 );
-}
-
-BOOST_AUTO_TEST_CASE( testPoint_PixelIsArea )
-{
-    Grid g( 4, 4, 0.0, Envelope( 0.0,4.0,0.0,4.0 ) );
-    g.setPixelConvention( PIXEL_IS_AREA );
-    BOOST_CHECK_EQUAL( g.point( 0,0 ).x(), 0.5 );
-    BOOST_CHECK_EQUAL( g.point( 0,0 ).y(), 3.5 );
-
-    BOOST_CHECK_EQUAL( g.point( 1,1 ).x(), 1.5 );
-    BOOST_CHECK_EQUAL( g.point( 1,1 ).y(), 2.5 );
-
-    BOOST_CHECK_EQUAL( g.point( 3,3 ).x(), 3.5 );
-    BOOST_CHECK_EQUAL( g.point( 3,3 ).y(), 0.5 );
-}
-
-
-//inline double dx() const ;
-//inline double dy() const ;
-BOOST_AUTO_TEST_CASE( testDxDy_PixelIsPoint )
-{
-    Grid g( 4,2 );
-    g.setPixelConvention( PIXEL_IS_POINT );
-    BOOST_CHECK_EQUAL( g.dx(), 1.0 );
-    BOOST_CHECK_EQUAL( g.dy(), 1.0/3.0 );
-}
-BOOST_AUTO_TEST_CASE( testDxDy_PixelIsArea )
-{
-    Grid g( 4,2 );
-    g.setPixelConvention( PIXEL_IS_AREA );
-    BOOST_CHECK_EQUAL( g.dx(), 0.50 );
-    BOOST_CHECK_EQUAL( g.dy(), 0.25 );
-}
-
-//
-//inline const double & z( const size_t& row, const size_t& col ) const ;
-//inline double & z( const size_t& row, const size_t& col ) ;
-//
-//inline const size_t nrows() const
-//inline const size_t ncols() const
-//inline const Envelope & limits() const
-//inline void setLimits( const Envelope & limits )
-//inline const PixelConvention & pixelConvention() const
-//inline void setPixelConvention( const PixelConvention & pixelConvention )
-//inline ublas::matrix< double > & data()
-//inline const ublas::matrix< double > & data() const
-
-
-//std::auto_ptr< TriangulatedSurface > toTrianguledSurface() const ;
-BOOST_AUTO_TEST_CASE( testToTriangulatedSurface )
-{
-    Grid g( 2,2 );
-    g.z( 0,0 ) = 0.0 ;
-    g.z( 0,1 ) = 1.0 ;
-    g.z( 1,0 ) = 2.0 ;
-    g.z( 1,1 ) = 3.0 ;
-
-    g.setPixelConvention( PIXEL_IS_POINT );
-    BOOST_CHECK_EQUAL( g.toTrianguledSurface()->asText( 1 ), "TIN M(((0.0 0.0 2.0,1.0 0.0 3.0,1.0 1.0 1.0,0.0 0.0 2.0)),((0.0 0.0 2.0,1.0 1.0 1.0,0.0 1.0 0.0,0.0 0.0 2.0)))" );
-    g.setPixelConvention( PIXEL_IS_AREA );
-    BOOST_CHECK_EQUAL( g.toTrianguledSurface()->asText( 1 ), "TIN M(((0.2 0.2 2.0,0.8 0.2 3.0,0.8 0.8 1.0,0.2 0.2 2.0)),((0.2 0.2 2.0,0.8 0.8 1.0,0.2 0.8 0.0,0.2 0.2 2.0)))" );
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
-
-
-
diff --git a/test/unit/SFCGAL/algorithm/ApproximateMedialAxis.cpp b/test/unit/SFCGAL/algorithm/ApproximateMedialAxis.cpp
index ed7ae4f..5dead02 100644
--- a/test/unit/SFCGAL/algorithm/ApproximateMedialAxis.cpp
+++ b/test/unit/SFCGAL/algorithm/ApproximateMedialAxis.cpp
@@ -43,18 +43,28 @@ using namespace SFCGAL ;
 BOOST_AUTO_TEST_SUITE( SFCGAL_algorithm_ApproximateMedialAxisTest )
 
 
-BOOST_AUTO_TEST_CASE( testTriangle )
+BOOST_AUTO_TEST_CASE( testTriangle45 )
 {
-    std::auto_ptr< Geometry > g( io::readWkt( "TRIANGLE((0 0,1 0,1 1,0 0))" ) );
+    std::auto_ptr< Geometry > g( io::readWkt( "TRIANGLE((1 1,2 1,2 2,1 1))" ) );
 
-    std::string expectedWKT( "MULTILINESTRING EMPTY");
+    std::string expectedWKT( "MULTILINESTRING((1.0 1.0,1.7 1.3),(2.0 2.0,1.7 1.3))");
     {
         std::auto_ptr< MultiLineString > result( algorithm::approximateMedialAxis( *g ) ) ;
-        BOOST_CHECK_EQUAL( result->numGeometries(), 0U );
         BOOST_CHECK_EQUAL( result->asText( 1 ), expectedWKT );
     }
 }
 
+BOOST_AUTO_TEST_CASE( testTriangle60 )
+{
+    std::auto_ptr< Geometry > g( io::readWkt( "TRIANGLE((1 1,3 1,2 3,1 1))" ) );
+
+    std::string expectedWKT( "MULTILINESTRING EMPTY" );
+    {
+        std::auto_ptr< MultiLineString > result( algorithm::approximateMedialAxis( *g ) ) ;
+        BOOST_CHECK_EQUAL( result->numGeometries(), 0U );
+        BOOST_CHECK_EQUAL( result->asText( 1 ), expectedWKT );
+    }
+}
 
 BOOST_AUTO_TEST_CASE( testPolygon )
 {
diff --git a/test/unit/SFCGAL/algorithm/DistanceTest.cpp b/test/unit/SFCGAL/algorithm/DistanceTest.cpp
index 1b0acdd..ea26c40 100644
--- a/test/unit/SFCGAL/algorithm/DistanceTest.cpp
+++ b/test/unit/SFCGAL/algorithm/DistanceTest.cpp
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE( testDistancePolygonPolygon_disjoint )
 
 BOOST_AUTO_TEST_CASE( testDistanceMultiPointMultiPoint_disjoint )
 {
-    std::auto_ptr< Geometry > gA( io::readWkt( "MULTIPOINT((0.0 0.0),(1.0 0.0),(1.0 1.0),(0.0 1.0)))" ) );
+    std::auto_ptr< Geometry > gA( io::readWkt( "MULTIPOINT((0.0 0.0),(1.0 0.0),(1.0 1.0),(0.0 1.0))" ) );
     std::auto_ptr< Geometry > gB( io::readWkt( "MULTIPOINT((8.0 8.0),(4.0 5.0))" ) );
     BOOST_CHECK_EQUAL( gA->distance( *gB ), 5.0 );
 }
diff --git a/test/unit/SFCGAL/algorithm/StraightSkeletonTest.cpp b/test/unit/SFCGAL/algorithm/StraightSkeletonTest.cpp
index abb7798..66a4264 100644
--- a/test/unit/SFCGAL/algorithm/StraightSkeletonTest.cpp
+++ b/test/unit/SFCGAL/algorithm/StraightSkeletonTest.cpp
@@ -147,5 +147,21 @@ BOOST_AUTO_TEST_CASE( testMultiPolygonWithTouchingHoles )
     BOOST_CHECK_THROW( algorithm::straightSkeleton( *g ), NotImplementedException );
 }
 
+BOOST_AUTO_TEST_CASE( testDistanceInM )
+{
+    std::auto_ptr< Geometry > g( io::readWkt( "POLYGON((0 0,1 0,1 1,0 1,0 0))" ) );
+    std::auto_ptr<Geometry> out( algorithm::straightSkeleton( *g, /* autoOrientation */ true, /* innerOnly */ false, /* outputDistanceInM */ true ) );
+    std::string expectedWKT( "MULTILINESTRING M((-0.0 -0.0 0.0,0.5 0.5 0.5),(1.0 -0.0 0.0,0.5 0.5 0.5),(1.0 1.0 0.0,0.5 0.5 0.5),(-0.0 1.0 0.0,0.5 0.5 0.5))" );
+    BOOST_CHECK_EQUAL( out->asText( 1 ), expectedWKT );
+}
+
+BOOST_AUTO_TEST_CASE( testMultiEmptyEmpty )
+{
+    std::auto_ptr< Geometry > g( io::readWkt( "MULTIPOLYGON(EMPTY,EMPTY)" ) );
+    std::auto_ptr<Geometry> out( algorithm::straightSkeleton( *g ) );
+    std::string expectedWKT( "MULTILINESTRING EMPTY" );
+    BOOST_CHECK_EQUAL( out->asText( 1 ), expectedWKT );
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
diff --git a/test/unit/SFCGAL/capi/sfcgal_cTest.cpp b/test/unit/SFCGAL/capi/sfcgal_cTest.cpp
index 356ac49..594d2a0 100644
--- a/test/unit/SFCGAL/capi/sfcgal_cTest.cpp
+++ b/test/unit/SFCGAL/capi/sfcgal_cTest.cpp
@@ -102,6 +102,26 @@ BOOST_AUTO_TEST_CASE( testStraightSkeletonMultiPolygon )
     BOOST_CHECK_EQUAL( 8, sfcgal_geometry_collection_num_geometries( sk ) );
 }
 
+BOOST_AUTO_TEST_CASE( testApproximateMedialAxis )
+{
+    sfcgal_set_error_handlers( printf, on_error );
+
+    std::auto_ptr<Geometry> g( io::readWkt(
+"POLYGON((-42 9,-44 9,-42 8,-22 7,-22 21,1 22,-5 13,-5 12,-4 13,2 23,-23 22,-23 8,-42 9))"
+    ) );
+
+    hasError = false;
+    sfcgal_geometry_t* sk = sfcgal_geometry_approximate_medial_axis( g.get() );
+    BOOST_CHECK( hasError == false );
+    // TODO: check length = 71.5634135885843
+    // NOTE: length not available in C-API
+    // algorithm::length
+    //BOOST_CHECK_EQUAL( 71.56, round(algorithm::length(sk)*100)/100; );
+    BOOST_CHECK_EQUAL( 11, sfcgal_geometry_collection_num_geometries( sk ) );
+
+    sfcgal_geometry_delete(sk);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 
diff --git a/test/unit/SFCGAL/io/WktReaderTest.cpp b/test/unit/SFCGAL/io/WktReaderTest.cpp
index 8bf190e..dafa8c4 100644
--- a/test/unit/SFCGAL/io/WktReaderTest.cpp
+++ b/test/unit/SFCGAL/io/WktReaderTest.cpp
@@ -169,17 +169,17 @@ BOOST_AUTO_TEST_CASE( multiPointEmpty )
 BOOST_AUTO_TEST_CASE( multiPointEmpty2 )
 {
     std::auto_ptr< Geometry > g( readWkt( "MULTIPOINT(0 0,1 1,EMPTY)" ) );
-    BOOST_CHECK( g->asText() == "MULTIPOINT((0/1 0/1),(1/1 1/1),EMPTY)" );
+    BOOST_CHECK( g->asText() == "MULTIPOINT((0/1 0/1),(1/1 1/1))" );
     BOOST_CHECK( g->is< MultiPoint >() );
-    BOOST_CHECK( g->numGeometries() == 3 );
+    BOOST_CHECK( g->numGeometries() == 2 );
 }
 
 BOOST_AUTO_TEST_CASE( multiPointEmpty3 )
 {
     std::auto_ptr< Geometry > g( readWkt( "MULTIPOINT(EMPTY,EMPTY)" ) );
-    BOOST_CHECK( g->asText() == "MULTIPOINT(EMPTY,EMPTY)" );
+    BOOST_CHECK( g->asText() == "MULTIPOINT EMPTY" );
     BOOST_CHECK( g->is< MultiPoint >() );
-    BOOST_CHECK( g->numGeometries() == 2 );
+    BOOST_CHECK( g->isEmpty() );
 }
 
 //-- WKT MULTILINESTRING
@@ -261,6 +261,36 @@ BOOST_AUTO_TEST_CASE( charArrayRead )
     BOOST_CHECK_EQUAL( g->as< LineString >().numPoints(), 2U );
 }
 
+BOOST_AUTO_TEST_CASE( wktExtraCharacters )
+{
+    bool threw = false;
+    try
+    {
+        std::auto_ptr< Geometry > g( readWkt( "POINT(0 0)POINT(1 0)" ) );
+    }
+    catch ( WktParseException& e )
+    {
+        std::string err( e.what() );
+        BOOST_CHECK_EQUAL( err, "Extra characters in WKT: POINT(1 0)" );
+        threw = true;
+    }
+    BOOST_CHECK( threw );
+
+    threw = false;
+    try
+    {
+        char str[] = "POINT(0 0)POINT(1 0)";
+        std::auto_ptr< Geometry > g( readWkt( str, strlen( str ) ) );
+    }
+    catch ( WktParseException& e )
+    {
+        std::string err( e.what() );
+        BOOST_CHECK_EQUAL( err, "Extra characters in WKT: POINT(1 0)" );
+        threw = true;
+    }
+    BOOST_CHECK( threw );
+}
+
 
 BOOST_AUTO_TEST_SUITE_END()
 
diff --git a/test/unit/SFCGAL/triangulate/Triangulate2DZTest.cpp b/test/unit/SFCGAL/triangulate/Triangulate2DZTest.cpp
index a95d91a..6eb1fe0 100644
--- a/test/unit/SFCGAL/triangulate/Triangulate2DZTest.cpp
+++ b/test/unit/SFCGAL/triangulate/Triangulate2DZTest.cpp
@@ -86,11 +86,7 @@ BOOST_AUTO_TEST_CASE( testSolid )
                                                       ((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),\
                                                       ((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1))))" ) );
 
-#ifndef SFCGAL_NEVER_CHECK_VALIDITY
     BOOST_CHECK_THROW( triangulate2DZ( *g ), GeometryInvalidityException );
-#else
-    BOOST_CHECK_THROW( triangulate2DZ( *g ), InappropriateGeometryException );
-#endif
 }
 
 
diff --git a/viewer/CMakeLists.txt b/viewer/CMakeLists.txt
deleted file mode 100644
index 581831b..0000000
--- a/viewer/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-find_package( Qt4 COMPONENTS QtGui QtCore REQUIRED )
-find_package( OpenSceneGraph COMPONENTS osgQt osgViewer osgGA osgDB osgUtil REQUIRED )
-find_package( PostgreSQL REQUIRED )
-
-include_directories(
-        include
-        # postgresql
-        ${POSTGRESQL_INCLUDE_DIR}
-        ${QT_INCLUDES} 
-        ${OPENSCENEGRAPH_INCLUDE_DIRS} 
-)
-
-file( GLOB_RECURSE VIEWER_SFCGAL_HEADERS ./*.h )
-file( GLOB_RECURSE VIEWER_SFCGAL_HEADERS_MOC ./include/SFCGAL/*.h )
-file( GLOB_RECURSE VIEWER_SFCGAL_SOURCES ./*.cpp )
-
-QT4_WRAP_CPP(VIEWER_SFCGAL_MOC ${VIEWER_SFCGAL_HEADERS_MOC})
-
-add_executable( viewer-SFCGAL 
-        ${VIEWER_SFCGAL_HEADERS}
-        ${VIEWER_SFCGAL_SOURCES}
-        ${VIEWER_SFCGAL_MOC}
-)
-
-set(QT_LIBRARIES QtCore QtGui)
-set_target_properties( viewer-SFCGAL PROPERTIES DEBUG_POSTFIX "d" )
-target_link_libraries( viewer-SFCGAL
-        SFCGAL
-        ${OPENSCENEGRAPH_LIBRARIES}  
-        ${QT_LIBRARIES}
-        ${CGAL_LIBRARIES}
-        ${Boost_LIBRARIES}
-        ${MPFR_LIBRARIES}
-        ${GMP_LIBRARIES}
-        # Postgresql
-        pq
-)
-install( TARGETS viewer-SFCGAL DESTINATION bin )
-
-
diff --git a/viewer/cmake/Modules/FindosgQt.cmake b/viewer/cmake/Modules/FindosgQt.cmake
deleted file mode 100644
index 658a7bd..0000000
--- a/viewer/cmake/Modules/FindosgQt.cmake
+++ /dev/null
@@ -1,50 +0,0 @@
-# This is part of the Findosg* suite used to find OpenSceneGraph components.
-# Each component is separate and you must opt in to each module. You must
-# also opt into OpenGL and OpenThreads (and Producer if needed) as these
-# modules won't do it for you. This is to allow you control over your own
-# system piece by piece in case you need to opt out of certain components
-# or change the Find behavior for a particular module (perhaps because the
-# default FindOpenGL.cmake module doesn't work with your system as an
-# example).
-# If you want to use a more convenient module that includes everything,
-# use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgQt
-# This module defines
-#
-# OSGQT_FOUND - Was osgQt found?
-# OSGQT_INCLUDE_DIR - Where to find the headers
-# OSGQT_LIBRARIES - The libraries to link for osgQt (use this)
-#
-# OSGQT_LIBRARY - The osgQt library
-# OSGQT_LIBRARY_DEBUG - The osgQt debug library
-#
-# $OSGDIR is an environment variable that would
-# correspond to the ./configure --prefix=$OSGDIR
-# used in building osg.
-#
-# Created by Eric Wing.
-# Modified to work with osgQt by Robert Osfield, January 2012.
-
-#=============================================================================
-# Copyright 2007-2009 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-#  License text for the above reference.)
-
-# Header files are presumed to be included like
-# #include <osg/PositionAttitudeTransform>
-# #include <osgQt/GraphicsWindowQt>
-
-OSG_FIND_PATH   (OSGQT osgQt/GraphicsWindowQt)
-OSG_FIND_LIBRARY(OSGQT osgQt)
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgQt DEFAULT_MSG
-    OSGQT_LIBRARY OSGQT_INCLUDE_DIR)
diff --git a/viewer/include/SFCGAL/viewer/GISManipulator.h b/viewer/include/SFCGAL/viewer/GISManipulator.h
deleted file mode 100644
index 00da55f..0000000
--- a/viewer/include/SFCGAL/viewer/GISManipulator.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_GISMANIPULATOR_H_
-#define _SFCGAL_VIEWER_GISMANIPULATOR_H_
-
-#include <osgGA/FirstPersonManipulator>
-
-namespace SFCGAL {
-namespace viewer {
-
-class GISManipulator : public osgGA::FirstPersonManipulator {
-public:
-    GISManipulator();
-
-    void init ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
-
-protected:
-    bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
-
-    bool handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
-};
-
-}//viewer
-}//SFCGAL
-
-
-#endif
diff --git a/viewer/include/SFCGAL/viewer/ViewerPlugin.h b/viewer/include/SFCGAL/viewer/ViewerPlugin.h
deleted file mode 100644
index fe88cc4..0000000
--- a/viewer/include/SFCGAL/viewer/ViewerPlugin.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_VIEWERPLUGIN_H_
-#define _SFCGAL_VIEWER_VIEWERPLUGIN_H_
-
-#include <QtCore/QObject>
-
-namespace SFCGAL {
-namespace viewer {
-
-class ViewerWindow ;
-class ViewerWidget ;
-
-/**
- * osgViewer::Viewer wrapped in a QWidget
- */
-class ViewerPlugin : public QObject {
-    Q_OBJECT
-
-    friend class ViewerWindow ;
-public:
-    /**
-     * Default constructor
-     */
-    ViewerPlugin() ;
-
-    /**
-     * Returns the plugin name
-     */
-    virtual QString pluginName() const = 0 ;
-
-    /**
-     * returns the window
-     */
-    ViewerWindow* viewerWindow() ;
-    /**
-     * returns the window
-     */
-    ViewerWidget* viewer() ;
-protected:
-    /**
-     * Load plugin
-     */
-    virtual void load() = 0 ;
-    /**
-     * Unload plugin
-     */
-    virtual void unload() ;
-private:
-    ViewerWindow* _viewerWindow ;
-};
-
-}//viewer
-}//SFCGAL
-
-
-#endif
diff --git a/viewer/include/SFCGAL/viewer/ViewerWidget.h b/viewer/include/SFCGAL/viewer/ViewerWidget.h
deleted file mode 100644
index 4d76006..0000000
--- a/viewer/include/SFCGAL/viewer/ViewerWidget.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_VIEWERWIDGET_H_
-#define _SFCGAL_VIEWER_VIEWERWIDGET_H_
-
-#include <QtCore/QTimer>
-#include <QtGui/QWidget>
-
-#include <osgViewer/Viewer>
-#include <osgQt/GraphicsWindowQt>
-
-namespace SFCGAL {
-namespace viewer {
-
-/**
- * osgViewer::Viewer wrapped in a QWidget
- */
-class ViewerWidget : public QWidget, public osgViewer::Viewer {
-    Q_OBJECT
-public:
-    /**
-     * Constructor with a threadingModel
-     */
-    ViewerWidget() ;
-    /**
-     * Constructor with a threadingModel
-     */
-    ViewerWidget( osg::ArgumentParser& arguments ) ;
-
-    /**
-     * returns the scene node
-     */
-    osg::Group*   getScene() ;
-
-    /**
-     * Get GraphicsWindows
-     */
-    osgQt::GraphicsWindowQt* getGraphicsWindowQt() ;
-
-
-    //-- [QWidget]
-    virtual void paintEvent( QPaintEvent* event ) ;
-
-    /**
-     * [factory]create viewer from command line arguments
-     */
-    static ViewerWidget* createFromArguments( osg::ArgumentParser& arguments ) ;
-
-    /**
-     * Save image to file
-     */
-    void saveImageToFile() ;
-
-
-    void setCameraToExtent( const osg::BoundingBox& );
-public slots :
-    /**
-     * start animation
-     */
-    void startAnimation() ;
-    /**
-     * stop animation
-     */
-    void stopAnimation() ;
-
-protected:
-    QTimer       _timer;
-    osg::Camera* _camera ;
-    osg::Group*  _scene ;
-
-
-    /**
-     * [helper]create a camera with the given parameters
-     */
-    osg::Camera* createCamera( int x, int y, int w, int h, const std::string& name="", bool windowDecoration=false ) ;
-
-private:
-    void initViewer() ;
-};
-
-}//viewer
-}//SFCGAL
-
-
-#endif
diff --git a/viewer/include/SFCGAL/viewer/ViewerWindow.h b/viewer/include/SFCGAL/viewer/ViewerWindow.h
deleted file mode 100644
index 35195cb..0000000
--- a/viewer/include/SFCGAL/viewer/ViewerWindow.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_VIEWERWINDOW_H_
-#define _SFCGAL_VIEWER_VIEWERWINDOW_H_
-
-#include <QtGui/QMainWindow>
-
-
-namespace SFCGAL {
-namespace viewer {
-
-class ViewerPlugin ;
-class ViewerWidget ;
-
-/**
- * osgViewer::Viewer wrapped in a QWidget
- */
-class ViewerWindow : public QMainWindow {
-    Q_OBJECT
-public:
-    /**
-     * constructor with a viewer
-     */
-    ViewerWindow( ViewerWidget* viewer = 0 );
-
-    /**
-     * destructor
-     */
-    ~ViewerWindow() ;
-
-    /**
-     * get viewer
-     */
-    ViewerWidget* viewer() ;
-    /**
-     * get viewer
-     */
-    void           setViewer( ViewerWidget* viewer ) ;
-
-    /**
-     * add a plugin to the window
-     */
-    void           addPlugin( ViewerPlugin* plugin ) ;
-
-public slots:
-
-    /**
-     * load a file
-     */
-    void loadFile() ;
-    /**
-     * save to a file
-     */
-    void saveFile() ;
-
-    /**
-     * display about message
-     */
-    void about() ;
-
-    /**
-     * take a screen shot
-     */
-    void screenShot() ;
-
-    /**
-     * switch to a GIS-oriented manipulator
-     */
-    void toGISView();
-
-    /**
-     * switch to a free view manipulator
-     */
-    void toFreeView();
-protected:
-    /**
-     * create default menus
-     */
-    void createMenus() ;
-
-protected:
-    ViewerWidget* _viewer ;
-
-    QMenu* _menuFile ;
-    QMenu* _menuData ;
-    QMenu* _menuHelp ;
-
-    std::vector< ViewerPlugin* > _plugins ;
-};
-
-}//viewer
-}//SFCGAL
-
-
-#endif
diff --git a/viewer/include/SFCGAL/viewer/plugins/DataPlugin.h b/viewer/include/SFCGAL/viewer/plugins/DataPlugin.h
deleted file mode 100644
index 05f7975..0000000
--- a/viewer/include/SFCGAL/viewer/plugins/DataPlugin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_PLUGINS_DATAPLUGIN_H_
-#define _SFCGAL_VIEWER_PLUGINS_DATAPLUGIN_H_
-
-#include <SFCGAL/viewer/ViewerPlugin.h>
-
-namespace osg {
-class Node ;
-}
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-/**
- * data management plugin
- */
-class DataPlugin : public ViewerPlugin {
-    Q_OBJECT
-public:
-    /**
-     * Default constructor
-     */
-    DataPlugin() ;
-
-    /**
-     * Returns the plugin name
-     */
-    virtual QString pluginName() const ;
-
-
-    static void displayNodeInformation( osg::Node* node, std::ostream& s, const size_t& depth = 0 ) ;
-
-public slots :
-    /**
-     * display data information
-     */
-    void displayInformations();
-protected:
-    /**
-     * init plugin
-     */
-    virtual void load() ;
-};
-
-}//plugins
-}//viewer
-}//SFCGAL
-
-
-#endif
-
diff --git a/viewer/include/SFCGAL/viewer/plugins/DemoPlugin.h b/viewer/include/SFCGAL/viewer/plugins/DemoPlugin.h
deleted file mode 100644
index c23b6e0..0000000
--- a/viewer/include/SFCGAL/viewer/plugins/DemoPlugin.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_PLUGINS_DEMOPLUGIN_H_
-#define _SFCGAL_VIEWER_PLUGINS_DEMOPLUGIN_H_
-
-#include <SFCGAL/viewer/ViewerPlugin.h>
-
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-/**
- * demo plugin
- */
-class DemoPlugin : public ViewerPlugin {
-    Q_OBJECT
-public:
-    /**
-     * Default constructor
-     */
-    DemoPlugin() ;
-
-    /**
-     * Returns the plugin name
-     */
-    virtual QString pluginName() const ;
-
-public slots :
-    /**
-     * demo extrude
-    */
-    void demoSpiral();
-    /**
-     * demo extrude
-     */
-    void demoWkt();
-    /**
-     * demo extrude
-     */
-    void demoExtrude();
-    /**
-     * demo convexHull
-     */
-    void demoConvexhull();
-protected:
-    /**
-     * init plugin
-     */
-    virtual void load() ;
-};
-
-}//plugins
-}//viewer
-}//SFCGAL
-
-
-#endif
-
diff --git a/viewer/include/SFCGAL/viewer/plugins/GridPlugin.h b/viewer/include/SFCGAL/viewer/plugins/GridPlugin.h
deleted file mode 100644
index c3307eb..0000000
--- a/viewer/include/SFCGAL/viewer/plugins/GridPlugin.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_PLUGINS_GRIDPLUGIN_H_
-#define _SFCGAL_VIEWER_PLUGINS_GRIDPLUGIN_H_
-
-#include <SFCGAL/viewer/ViewerPlugin.h>
-
-namespace osg {
-class Node ;
-}
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-/**
- * data management plugin
- */
-class GridPlugin : public ViewerPlugin {
-    Q_OBJECT
-public:
-    /**
-     * Default constructor
-     */
-    GridPlugin() ;
-
-    /**
-     * Returns the plugin name
-     */
-    virtual QString pluginName() const ;
-
-public slots :
-    /**
-     * display data information
-     */
-    void loadGridXYZ();
-protected:
-    /**
-     * init plugin
-     */
-    virtual void load() ;
-};
-
-}//plugins
-}//viewer
-}//SFCGAL
-
-
-#endif
-
diff --git a/viewer/include/SFCGAL/viewer/plugins/PSQLPlugin.h b/viewer/include/SFCGAL/viewer/plugins/PSQLPlugin.h
deleted file mode 100644
index 521569d..0000000
--- a/viewer/include/SFCGAL/viewer/plugins/PSQLPlugin.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _SFCGAL_VIEWER_PLUGINS_PSQLPLUGIN_H_
-#define _SFCGAL_VIEWER_PLUGINS_PSQLPLUGIN_H_
-
-#ifndef Q_MOC_RUN
-#include <boost/scoped_ptr.hpp>
-#include <osg/Geode>
-#endif
-
-#include <QtGui/QDockWidget>
-#include <QtGui/QPlainTextEdit>
-#include <QtGui/QPushButton>
-#include <QtGui/QListWidget>
-#include <QtGui/QLineEdit>
-
-#include <SFCGAL/viewer/ViewerPlugin.h>
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-class PSQLPluginImpl;
-/**
- * data management plugin
- */
-class PSQLPlugin : public ViewerPlugin {
-    Q_OBJECT
-public:
-    /**
-     * Default constructor
-     */
-    PSQLPlugin() ;
-
-    ~PSQLPlugin();
-
-    /**
-     * Returns the plugin name
-     */
-    virtual QString pluginName() const ;
-
-    /**
-     * Connect to the database
-     */
-    void connect( const std::string& dbOptions );
-
-    void disconnect();
-
-    /**
-     * Do the PostGIS query and returns an osg::Geode
-     */
-    osg::Geode* doQuery( const std::string& );
-
-    /**
-     * Do the PostGIS queries for all layers
-     */
-    void computeGeometries();
-
-    /**
-     * Display all visible layers
-     */
-    void display();
-public slots :
-    /**
-     * display data information
-     */
-    void launchConsole();
-
-    void saveLayers();
-    void loadLayers();
-    void onRefresh();
-protected:
-    /**
-     * init plugin
-     */
-    virtual void load() ;
-
-private:
-    PSQLPluginImpl* impl_;
-};
-
-
-///
-/// SQL editor for a layer
-class SQLConsole : public QDockWidget {
-    Q_OBJECT
-public:
-    SQLConsole( PSQLPlugin* plugin );
-
-    //
-    // connect to a QListWidgetItem storing the sql query and the resulting geometry
-    void connectItem( QListWidgetItem* );
-
-    //
-    //
-    void disconnectItem();
-
-public slots:
-    void onQuery();
-    void onReconnect();
-private:
-    QPlainTextEdit* sqlEdit_;
-    QPushButton* okBtn_;
-    QPushButton* connectBtn_;
-    QLineEdit* dbOptions_;
-
-    QListWidgetItem* item_;
-
-    PSQLPlugin* plugin_;
-};
-
-class LayersWidget : public QDockWidget {
-    Q_OBJECT
-public:
-    LayersWidget( PSQLPlugin* plugin, SQLConsole* );
-
-    QListWidget* widget() {
-        return listWidget_;
-    }
-
-    void addLayer( const QString& name, bool visible, const QString& dbOptions, const QString& query );
-public slots:
-    void onAdd();
-    void onClick( const QModelIndex& idx );
-
-    void onEdit();
-    void onRemove();
-    void onZoomToLayer();
-private:
-    QListWidget* listWidget_;
-    QPushButton* addBtn_;
-    SQLConsole* console_;
-
-    PSQLPlugin* plugin_;
-};
-
-}//plugins
-}//viewer
-}//SFCGAL
-
-
-#endif
-
diff --git a/viewer/include/db.h b/viewer/include/db.h
deleted file mode 100644
index dcde09b..0000000
--- a/viewer/include/db.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-// Database access classes
-// (c) 2012 Oslandia
-// MIT License
-
-#ifndef POSTGRESQL_CONNECTION_HH
-#define POSTGRESQL_CONNECTION_HH
-
-/**
-   Database access is modeled by means of the following classes, inspired by pqxx:
-   * A Db::Connection objet represents a connection to a database. It is a lightweighted objet that is reference-counted and thus can be copied safely.
-   * A Db::Result objet represents result of a query. It is a lightweighted objet that is reference-counted and thus can be copied safely.
-   * A Db::RowValue object represents a row of a result and is obtained by Db::Result::operator[]
-   * A Db::Value object represent a basic value. It is obtained by Db::RowValue::operator[]. It has templated conversion operators for common data types.
-
-   These classes throw std::runtime_error on problem.
- */
-
-#include <libpq-fe.h>
-
-#include <string>
-#include <stdexcept>
-
-#include <boost/assert.hpp>
-#include <boost/lexical_cast.hpp>
-
-namespace Db {
-///
-/// Class representing an atomic value stored in a database.
-class Value {
-public:
-    Value( const char* value, size_t len, bool isnull ) : value_( value ), len_( len ), isnull_( isnull ) {
-    }
-
-    ///
-    /// This is the generic conversion operator.
-    /// It calls stringstream conversion operators (slow!).
-    /// Specialization can be introduced, or via a specialization of the stringstream::operator>>()
-    template <class T>
-    T as() {
-        T obj;
-        std::istringstream istr( value_ );
-        istr >> obj;
-        return obj;
-    }
-
-    ///
-    /// Conversion operator. Does nothing if the underlying object is null (which is a special value in a database)
-    template <class T>
-    void operator >> ( T& obj ) {
-        if ( !isnull_ ) {
-            obj = as<T>();
-        }
-    }
-
-    ///
-    /// Tests if the underlying object is null
-    bool is_null() {
-        return isnull_;
-    }
-protected:
-    const char* value_;
-    size_t len_;
-    bool isnull_;
-};
-
-//
-// List of conversion specializations
-template <>
-bool Value::as<bool>();
-template <>
-std::string Value::as<std::string>();
-template <>
-long long Value::as<long long>();
-template <>
-int Value::as<int>();
-template <>
-float Value::as<float>();
-template <>
-double Value::as<double>();
-
-///
-/// Class used to represent a row in a result.
-class RowValue {
-public:
-    RowValue( PGresult* res, size_t nrow ) : res_( res ), nrow_( nrow ) {
-    }
-
-    ///
-    /// Access to a value by column number
-    Value operator [] ( size_t fn ) {
-        BOOST_ASSERT( fn < ( size_t )PQnfields( res_ ) );
-        return Value( PQgetvalue( res_, nrow_, fn ),
-                      PQgetlength( res_, nrow_, fn ),
-                      PQgetisnull( res_, nrow_, fn ) != 0 ? true : false
-                    );
-    }
-protected:
-    PGresult* res_;
-    size_t nrow_;
-};
-
-///
-/// Class representing result of a query
-class Result {
-public:
-    Result() : res_( 0 ) {}
-
-    Result( PGresult* res ) : res_( res ) {
-        BOOST_ASSERT( res_ );
-        nrefs_ = 1;
-    }
-    ///
-    /// Copy constructor
-    Result( const Result& r ) {
-        r.inc_refs();
-        dec_refs();
-        nrefs_ = r.nrefs_;
-        res_ = r.res_;
-    }
-    ///
-    /// Assignment operator. Deals with reference counting
-    Result& operator = ( const Result& r ) {
-        r.inc_refs();
-        dec_refs();
-        nrefs_ = r.nrefs_;
-        res_ = r.res_;
-        return *this;
-    }
-
-    virtual ~Result() {
-        dec_refs();
-    }
-
-    ///
-    /// Number of rows
-    size_t size() {
-        return res_ == 0 ? 0 : PQntuples( res_ );
-    }
-
-    ///
-    /// Number of columns
-    size_t columns() {
-        return res_ == 0 ? 0 : PQnfields( res_ );
-    }
-
-    ///
-    /// Access to a row of a result, by row number
-    RowValue operator [] ( size_t idx ) {
-        BOOST_ASSERT( idx < size() );
-        return RowValue( res_, idx );
-    }
-
-    PGresult* result() const {
-        return res_;
-    }
-protected:
-    PGresult* res_;
-
-    void dec_refs() const {
-        if ( res_ == 0 ) {
-            return;
-        }
-
-        if ( --nrefs_ == 0 ) {
-            PQclear( res_ );
-        }
-    }
-    void inc_refs() const {
-        nrefs_++;
-    }
-    mutable int nrefs_;
-};
-
-///
-/// Class representing connection to a database.
-class Connection {
-public:
-    Connection() : conn_( 0 ) {
-        nrefs_ = 0;
-    }
-
-    Connection( const std::string& db_options ) : conn_( 0 ) {
-        nrefs_ = 0;
-        connect( db_options );
-    }
-
-    void connect( const std::string& db_options ) {
-        dec_refs();
-        conn_ = PQconnectdb( db_options.c_str() );
-
-        if ( conn_ == NULL || PQstatus( conn_ ) != CONNECTION_OK ) {
-            std::string msg = "Database connection problem: ";
-            msg += PQerrorMessage( conn_ );
-            throw std::runtime_error( msg.c_str() );
-        }
-
-        nrefs_ = 1;
-    }
-
-    virtual ~Connection() {
-        dec_refs();
-    }
-
-    Connection( const Connection& r ) {
-        r.inc_refs();
-        dec_refs();
-        nrefs_ = r.nrefs_;
-        conn_ = r.conn_;
-    }
-    Connection& operator = ( const Connection& r ) {
-        r.inc_refs();
-        dec_refs();
-        nrefs_ = r.nrefs_;
-        conn_ = r.conn_;
-        return *this;
-    }
-
-    ///
-    /// Query execution. Returns a Db::Result. Throws a std::runtime_error on problem
-    Result exec( const std::string& query ) const throw ( std::runtime_error ) {
-        PGresult* res = PQexec( conn_, query.c_str() );
-        ExecStatusType ret = PQresultStatus( res );
-
-        if ( ( ret != PGRES_COMMAND_OK ) && ( ret != PGRES_TUPLES_OK ) ) {
-            std::string msg = "Problem on database query: ";
-            msg += PQresultErrorMessage( res );
-            PQclear( res );
-            throw std::runtime_error( msg.c_str() );
-        }
-
-        return res;
-    }
-    PGconn* connection() const {
-        return conn_;
-    }
-protected:
-    PGconn* conn_;
-
-    void dec_refs() const {
-        if ( nrefs_ == 0 ) {
-            return;
-        }
-
-        if ( --nrefs_ == 0 ) {
-            PQfinish( conn_ );
-        }
-    }
-    void inc_refs() const {
-        nrefs_++;
-    }
-    mutable int nrefs_;
-};
-}
-
-#endif
diff --git a/viewer/main.cpp b/viewer/main.cpp
deleted file mode 100644
index 48b1bd7..0000000
--- a/viewer/main.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <iostream>
-
-#include <QtGui/QApplication>
-
-#include <osgDB/ReadFile>
-#include <osgUtil/SmoothingVisitor>
-
-#include <osg/Material>
-#include <osgDB/Registry>
-
-#include <SFCGAL/Point.h>
-#include <SFCGAL/LineString.h>
-#include <SFCGAL/Polygon.h>
-#include <SFCGAL/Triangle.h>
-#include <SFCGAL/PolyhedralSurface.h>
-#include <SFCGAL/TriangulatedSurface.h>
-#include <SFCGAL/Solid.h>
-#include <SFCGAL/GeometryCollection.h>
-#include <SFCGAL/MultiPoint.h>
-#include <SFCGAL/MultiLineString.h>
-#include <SFCGAL/MultiPolygon.h>
-#include <SFCGAL/MultiSolid.h>
-#include <SFCGAL/detail/tools/Log.h>
-
-#include <SFCGAL/viewer/ViewerWidget.h>
-#include <SFCGAL/viewer/ViewerWindow.h>
-#include <SFCGAL/viewer/plugins/DemoPlugin.h>
-#include <SFCGAL/viewer/plugins/DataPlugin.h>
-#include <SFCGAL/viewer/plugins/GridPlugin.h>
-#include <SFCGAL/viewer/plugins/PSQLPlugin.h>
-#include <QtGui/QFileDialog>
-
-
-
-using namespace SFCGAL ;
-using namespace SFCGAL::viewer ;
-
-
-int main( int argc, char** argv )
-{
-    Logger::get()->setLogLevel( Logger::Debug );
-
-    // use an ArgumentParser object to manage the program arguments.
-    osg::ArgumentParser arguments( &argc,argv );
-
-    QApplication app( argc, argv );
-
-    ViewerWidget* viewer = ViewerWidget::createFromArguments( arguments );
-//    osg::Geode* geode = new osg::Geode;
-//    //osg::StateSet* status = geode->getOrCreateStateSet();
-//    //status->setMode(GL_LIGHTING, osg::StateAttribute::ON);
-//
-//
-//	std::auto_ptr< Geometry > g( io::readWkt("POLYGON((0.0 0.0 0.0,1.0 0.0 0.0,1.0 1.0 0.0,0.0 1.0 0.0,0.0 0.0 0.0),(0.2 0.2 0.0,0.8 0.2 0.0,0.8 0.8 0.0,0.2 0.8 0.0,0.2 0.2 0.0))")  );
-//	g->as< Polygon >().ringN(1).reverse();
-//	std::auto_ptr< Geometry > ext( algorithm::extrude(*g,0.0,0.0,1.0) );
-//
-//	detail::io::OsgFactory factory ;
-//
-//	osg::Geometry * osgGeometry = factory.createGeometry( *ext ) ;
-//
-
-// */
-//
-//	/*
-//	 * provide a material
-//	 */
-//	osg::ref_ptr<osg::StateSet> stateSet( geode->getOrCreateStateSet() );
-//	osg::ref_ptr<osg::Material> material( new osg::Material );
-//	material->setDiffuse(osg::Material::FRONT,osg::Vec4(1.0f,0.0f,0.0f,1.0f));
-//	stateSet->setAttribute( material.release() );
-//
-//
-//	geode->addDrawable( osgGeometry );
-//	viewer->getScene()->addChild( geode ) ;
-
-
-    ViewerWindow window( viewer );
-    window.addPlugin( new plugins::DataPlugin ) ;
-    window.addPlugin( new plugins::DemoPlugin ) ;
-    window.addPlugin( new plugins::GridPlugin ) ;
-    window.addPlugin( new plugins::PSQLPlugin ) ;
-    window.show();
-
-    return app.exec();
-}
diff --git a/viewer/src/SFCGAL/viewer/GISManipulator.cpp b/viewer/src/SFCGAL/viewer/GISManipulator.cpp
deleted file mode 100644
index 804e139..0000000
--- a/viewer/src/SFCGAL/viewer/GISManipulator.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <iostream>
-
-#include <osg/io_utils>
-
-#include <SFCGAL/viewer/GISManipulator.h>
-
-namespace SFCGAL {
-namespace viewer {
-
-GISManipulator::GISManipulator() : osgGA::FirstPersonManipulator()
-{
-}
-
-void GISManipulator::init ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )
-{
-    std::cout << "init" << std::endl;
-    osgGA::FirstPersonManipulator::init( ea, us );
-    setTransformation( /*eye*/ osg::Vec3f( 0.0, 0.0, 100.0 ), /*center*/ osg::Vec3f( 0.0, 0.0, 0.0 ), /* up */ osg::Vec3f( 0.0, 0.0, 1.0 ) );
-}
-
-bool GISManipulator::performMovementLeftMouseButton( const double /*eventTimeDelta*/, const double dx, const double dy )
-{
-    // TODO: compute the right amount in order for one mouse's pixel movement to correspond to a movement of one object's pixel
-    osg::Vec3d eye, center, up;
-    getTransformation( eye, center, up );
-
-    double altitude = eye[2];
-
-    moveRight( -dx * altitude / 8.0 );
-    moveUp( -dy * altitude / 8.0 );
-
-    return true;
-}
-
-bool GISManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )
-{
-    osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();
-
-    osg::Vec3d eye, center, up;
-    getTransformation( eye, center, up );
-    double altitude = eye[2];
-
-    if ( sm == osgGA::GUIEventAdapter::SCROLL_UP ) {
-        altitude /= 1.41;
-    }
-    else if ( sm == osgGA::GUIEventAdapter::SCROLL_DOWN ) {
-        altitude *= 1.41;
-    }
-    else {
-        return false;
-    }
-
-    eye[2] = altitude;
-    center[2] = eye[2] - 1.0;
-    setTransformation( eye, center, up );
-
-    us.requestRedraw();
-    us.requestContinuousUpdate( isAnimating() );
-    return true;
-}
-
-} // namespace viewer
-} // namespace SFCGAL
diff --git a/viewer/src/SFCGAL/viewer/ViewerPlugin.cpp b/viewer/src/SFCGAL/viewer/ViewerPlugin.cpp
deleted file mode 100644
index 3734547..0000000
--- a/viewer/src/SFCGAL/viewer/ViewerPlugin.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/viewer/ViewerPlugin.h>
-#include <SFCGAL/viewer/ViewerWidget.h>
-#include <SFCGAL/viewer/ViewerWindow.h>
-
-#include <iostream>
-
-namespace SFCGAL {
-namespace viewer {
-
-///
-///
-///
-ViewerPlugin::ViewerPlugin():
-    _viewerWindow( 0 )
-{
-
-}
-
-
-///
-///
-///
-ViewerWindow* ViewerPlugin::viewerWindow()
-{
-    return _viewerWindow ;
-}
-
-///
-///
-///
-ViewerWidget* ViewerPlugin::viewer()
-{
-    return _viewerWindow->viewer() ;
-}
-
-///
-///
-///
-void ViewerPlugin::unload()
-{
-
-}
-
-
-}//viewer
-}//SFCGAL
-
-
diff --git a/viewer/src/SFCGAL/viewer/ViewerWidget.cpp b/viewer/src/SFCGAL/viewer/ViewerWidget.cpp
deleted file mode 100644
index 31883d7..0000000
--- a/viewer/src/SFCGAL/viewer/ViewerWidget.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/viewer/ViewerWidget.h>
-
-#include <iostream>
-#include <memory>
-
-#include <QtGui/QVBoxLayout>
-
-
-#include <osgViewer/ViewerEventHandlers>
-#include <osgGA/CameraManipulator>
-#include <osgGA/TrackballManipulator>
-
-
-#include <osgDB/Registry>
-#include <osgDB/ReadFile>
-#include <osgDB/WriteFile>
-
-#include <osgViewer/Viewer>
-#include <osgViewer/ViewerEventHandlers>
-
-#include <osgGA/TrackballManipulator>
-#include <osgGA/FlightManipulator>
-#include <osgGA/DriveManipulator>
-#include <osgGA/KeySwitchMatrixManipulator>
-#include <osgGA/StateSetManipulator>
-#include <osgGA/AnimationPathManipulator>
-#include <osgGA/TerrainManipulator>
-#include <osgGA/SphericalManipulator>
-#include <osgGA/FirstPersonManipulator>
-
-
-#include <osgUtil/Optimizer>
-#include <osg/CoordinateSystemNode>
-
-#include <osg/Switch>
-#include <osgText/Text>
-
-#include <osg/io_utils>
-
-#include <SFCGAL/viewer/GISManipulator.h>
-
-namespace SFCGAL {
-namespace viewer {
-
-///
-///
-///
-ViewerWidget::ViewerWidget():
-    QWidget(),
-    osgViewer::Viewer()
-{
-    initViewer();
-}
-
-///
-///
-///
-ViewerWidget::ViewerWidget( osg::ArgumentParser& arguments ) :
-    QWidget(),
-    osgViewer::Viewer( arguments )
-{
-    initViewer();
-}
-
-///
-///
-///
-void ViewerWidget::initViewer()
-{
-    _camera = createCamera( 0,0,100,100 ) ;
-    setCamera( _camera );
-
-    _scene = new osg::Group();
-    setSceneData( _scene );
-
-    osgQt::GraphicsWindowQt* gw = dynamic_cast<osgQt::GraphicsWindowQt*>( _camera->getGraphicsContext() );
-
-    QVBoxLayout* layout = new QVBoxLayout;
-    layout->addWidget( gw ? gw->getGLWidget() : NULL );
-    setLayout( layout );
-
-    setMinimumSize( 700,300 );
-
-    connect( &_timer, SIGNAL( timeout() ), this, SLOT( update() ) );
-    startAnimation();
-}
-
-
-///
-///
-///
-osg::Group* ViewerWidget::getScene()
-{
-    return _scene ;
-}
-
-///
-///
-///
-osgQt::GraphicsWindowQt* ViewerWidget::getGraphicsWindowQt()
-{
-    return dynamic_cast<osgQt::GraphicsWindowQt*>( _camera->getGraphicsContext() ) ;
-}
-
-
-
-///
-///
-///
-osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h, const std::string& name, bool windowDecoration )
-{
-    osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
-    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
-    traits->windowName = name;
-    traits->windowDecoration = windowDecoration;
-    traits->x = x;
-    traits->y = y;
-    traits->width = w;
-    traits->height = h;
-    traits->doubleBuffer = true;
-    traits->alpha = ds->getMinimumNumAlphaBits();
-    traits->stencil = ds->getMinimumNumStencilBits();
-    traits->sampleBuffers = ds->getMultiSamples();
-    traits->samples = ds->getNumMultiSamples();
-
-    osg::ref_ptr<osg::Camera> camera = new osg::Camera;
-    camera->setGraphicsContext( new osgQt::GraphicsWindowQt( traits.get() ) );
-
-    camera->setClearColor( osg::Vec4( 0.2, 0.2, 0.6, 1.0 ) );
-    camera->setViewport( new osg::Viewport( 0, 0, traits->width, traits->height ) );
-
-    osg::Matrixd persp;
-    persp.makePerspective( 30.0f,
-                           static_cast<double>( traits->width )/static_cast<double>( traits->height ),
-                           1.0f,
-                           1000000000.0f
-                         );
-    camera->setProjectionMatrix( persp );
-
-    camera->setComputeNearFarMode( osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR );
-    return camera.release();
-}
-
-void ViewerWidget::setCameraToExtent( const osg::BoundingBox& bbox )
-{
-    // translate to the center of the bbox
-    osgGA::CameraManipulator* manip = getCameraManipulator();
-    osg::Vec3d eye, center, up;
-    osg::Matrixd m = manip->getMatrix();
-    m.getLookAt( eye, center, up );
-    center[0] = bbox.center()[0];
-    center[1] = bbox.center()[1];
-    eye = center;
-    eye[2] = center[2] + 1.0;
-    m.makeLookAt( eye, center, up );
-    manip->setByMatrix( m );
-
-    // TODO: compute the right amount of zoom (use the inverse projection matrix ?)
-}
-///
-///
-///
-void ViewerWidget::paintEvent( QPaintEvent* /*event*/ )
-{
-    frame();
-}
-
-///
-///
-///
-ViewerWidget* ViewerWidget::createFromArguments( osg::ArgumentParser& arguments )
-{
-    arguments.getApplicationUsage()->setApplicationName( arguments.getApplicationName() );
-    arguments.getApplicationUsage()->setDescription( arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models." );
-    arguments.getApplicationUsage()->setCommandLineUsage( arguments.getApplicationName()+" [options] filename ..." );
-    arguments.getApplicationUsage()->addCommandLineOption( "--image <filename>","Load an image and render it on a quad" );
-    arguments.getApplicationUsage()->addCommandLineOption( "--dem <filename>","Load an image/DEM and render it on a HeightField" );
-    arguments.getApplicationUsage()->addCommandLineOption( "--login <url> <username> <password>","Provide authentication information for http file access." );
-
-    std::auto_ptr< ViewerWidget > viewer( new ViewerWidget( arguments ) );
-
-    unsigned int helpType = 0;
-
-    if ( ( helpType = arguments.readHelpType() ) ) {
-        arguments.getApplicationUsage()->write( std::cout, helpType );
-        return NULL ;
-    }
-
-    // report any errors if they have occurred when parsing the program arguments.
-    if ( arguments.errors() ) {
-        arguments.writeErrorMessages( std::cout );
-        return NULL ;
-    }
-
-
-    std::string url, username, password;
-
-    while( arguments.read( "--login",url, username, password ) ) {
-        if ( !osgDB::Registry::instance()->getAuthenticationMap() ) {
-            osgDB::Registry::instance()->setAuthenticationMap( new osgDB::AuthenticationMap );
-            osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
-                url,
-                new osgDB::AuthenticationDetails( username, password )
-            );
-        }
-    }
-
-    // set up the camera manipulators.
-    {
-        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
-
-        keyswitchManipulator->addMatrixManipulator( '0', "GIS", new GISManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '1', "Orbit", new osgGA::OrbitManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '2', "Trackball", new osgGA::TrackballManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '3', "Flight", new osgGA::FlightManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '4', "Drive", new osgGA::DriveManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '5', "Terrain", new osgGA::TerrainManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '6', "FirstPerson", new osgGA::FirstPersonManipulator() );
-        keyswitchManipulator->addMatrixManipulator( '7', "Spherical", new osgGA::SphericalManipulator() );
-
-        std::string pathfile;
-        double animationSpeed = 1.0;
-
-        while( arguments.read( "--speed",animationSpeed ) ) {}
-
-        char keyForAnimationPath = '9';
-
-        while ( arguments.read( "-p",pathfile ) ) {
-            osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator( pathfile );
-
-            if ( apm || !apm->valid() ) {
-                apm->setTimeScale( animationSpeed );
-
-                unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
-                keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
-                keyswitchManipulator->selectMatrixManipulator( num );
-                ++keyForAnimationPath;
-            }
-        }
-
-        viewer->setCameraManipulator( keyswitchManipulator.get() );
-    }
-
-    // add the state manipulator
-    viewer->addEventHandler( new osgGA::StateSetManipulator( viewer->getCamera()->getOrCreateStateSet() ) );
-
-    // add the thread model handler
-    viewer->addEventHandler( new osgViewer::ThreadingHandler );
-
-    // add the window size toggle handler
-    //viewer->addEventHandler(new osgViewer::WindowSizeHandler);
-
-    // add the stats handler
-    viewer->addEventHandler( new osgViewer::StatsHandler );
-
-    // add the help handler
-    viewer->addEventHandler( new osgViewer::HelpHandler( arguments.getApplicationUsage() ) );
-
-    // add the record camera path handler
-    viewer->addEventHandler( new osgViewer::RecordCameraPathHandler );
-
-    // add the LOD Scale handler
-    viewer->addEventHandler( new osgViewer::LODScaleHandler );
-
-    // add the screen capture handler
-    viewer->addEventHandler( new osgViewer::ScreenCaptureHandler );
-
-    // load the data
-    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles( arguments );
-
-    if ( !loadedModel ) {
-        std::cout << arguments.getApplicationName() << ": No data loaded" << std::endl;
-    }
-    else {
-        osgUtil::Optimizer optimizer;
-        optimizer.optimize( loadedModel.get() );
-        viewer->setSceneData( loadedModel.get() );
-    }
-
-    // any option left unread are converted into errors to write out later.
-    arguments.reportRemainingOptionsAsUnrecognized();
-
-    // report any errors if they have occurred when parsing the program arguments.
-    if ( arguments.errors() ) {
-        arguments.writeErrorMessages( std::cerr );
-    }
-
-
-    /// TODO remove
-    viewer->setThreadingModel( osgViewer::Viewer::SingleThreaded ) ;
-    viewer->realize();
-
-
-    //viewer->setThreadingModel( osgViewer::Viewer::ThreadPerCamera );
-    //viewer->setThreadingModel( osgViewer::Viewer::DrawThreadPerContext ) ;
-
-    //viewer->run();
-    return viewer.release() ;
-}
-
-
-///
-///
-///
-void ViewerWidget::saveImageToFile()
-{
-    osgViewer::ScreenCaptureHandler::WriteToFile* writeToFileOperation = new osgViewer::ScreenCaptureHandler::WriteToFile(
-        "screenshot",
-        "png",
-        osgViewer::ScreenCaptureHandler::WriteToFile::SEQUENTIAL_NUMBER
-    );
-
-    osgViewer::ScreenCaptureHandler* captureHandler = new osgViewer::ScreenCaptureHandler( writeToFileOperation );
-    captureHandler->captureNextFrame( *this );
-}
-
-///
-///
-///
-void ViewerWidget::startAnimation()
-{
-    _timer.start( 20 ) ;
-}
-
-///
-///
-///
-void ViewerWidget::stopAnimation()
-{
-    _timer.stop();
-}
-
-}//viewer
-}//SFCGAL
diff --git a/viewer/src/SFCGAL/viewer/ViewerWindow.cpp b/viewer/src/SFCGAL/viewer/ViewerWindow.cpp
deleted file mode 100644
index 01028dd..0000000
--- a/viewer/src/SFCGAL/viewer/ViewerWindow.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/viewer/ViewerWindow.h>
-#include <SFCGAL/viewer/ViewerWidget.h>
-#include <SFCGAL/viewer/ViewerPlugin.h>
-
-#include <SFCGAL/detail/tools/Log.h>
-
-#include <iostream>
-
-#include <QtGui/QApplication>
-#include <QtGui/QVBoxLayout>
-
-#include <QtGui/QFileDialog>
-
-
-#include <QtGui/QMenu>
-#include <QtGui/QMenuBar>
-#include <QtGui/QPixmap>
-#include <QtGui/QPainter>
-#include <QtGui/QImage>
-#include <QtGui/QMessageBox>
-
-
-#include <QtOpenGL/QGLFramebufferObject>
-#include <QtOpenGL/QGLWidget>
-
-#include <osgDB/ReadFile>
-#include <osgDB/WriteFile>
-
-#include <osgGA/OrbitManipulator>
-#include <SFCGAL/viewer/GISManipulator.h>
-
-namespace SFCGAL {
-namespace viewer {
-
-///
-///
-///
-ViewerWindow::ViewerWindow( ViewerWidget* viewer )
-{
-    setViewer( viewer );
-
-    createMenus();
-}
-
-///
-///
-///
-ViewerWindow::~ViewerWindow()
-{
-    for ( std::vector< ViewerPlugin* >::iterator it = _plugins.begin(); it != _plugins.end(); ++it ) {
-        ( *it )->unload();
-        delete *it ;
-    }
-
-    _plugins.clear();
-}
-
-///
-///
-///
-ViewerWidget* ViewerWindow::viewer()
-{
-    return _viewer ;
-}
-
-///
-///
-///
-void ViewerWindow::setViewer( ViewerWidget* viewer )
-{
-    _viewer = viewer ;
-
-    QWidget* centralWidget = new QWidget ;
-    QVBoxLayout* layout = new QVBoxLayout ;
-
-    if ( _viewer ) {
-        layout->addWidget( _viewer );
-    }
-
-    centralWidget->setLayout( layout );
-    setCentralWidget( centralWidget );
-}
-
-
-///
-///
-///
-void   ViewerWindow::addPlugin( ViewerPlugin* plugin )
-{
-    BOOST_ASSERT( plugin != NULL );
-
-    SFCGAL_INFO( boost::format( "loading ViewerPlugin %1%..." ) % plugin->pluginName().toStdString() );
-
-    _plugins.push_back( plugin );
-    plugin->_viewerWindow = this ;
-    plugin->load() ;
-}
-
-
-
-///
-///
-///
-//void ViewerWindow::screenShot()
-//{
-//	QImage image( viewer()->size(), QImage::Format_ARGB32 );
-//	QPainter painter( &image );
-//	centralWidget()->render( &painter ) ;
-//	image.save("test.png","PNG");
-//}
-
-
-///
-///
-///
-void ViewerWindow::screenShot()
-{
-    viewer()->stopAnimation();
-    viewer()->saveImageToFile();
-    viewer()->startAnimation();
-}
-
-
-
-///
-///
-///
-void ViewerWindow::about()
-{
-    QApplication::aboutQt();
-}
-
-///
-///
-///
-void ViewerWindow::loadFile()
-{
-    viewer()->stopAnimation();
-
-    QString filename = QFileDialog::getOpenFileName( NULL,"select a file to open", QDir::currentPath() ) ;
-
-    osg::Node* node = osgDB::readNodeFile( filename.toStdString() );
-
-    if ( ! node ) {
-        QMessageBox::warning( this, "load file error", QString( "can't read file..." ) );
-    }
-    else {
-        node->setName( filename.toStdString() );
-        viewer()->getScene()->addChild( node );
-    }
-
-    viewer()->startAnimation();
-}
-
-
-///
-///
-///
-void ViewerWindow::saveFile()
-{
-    viewer()->stopAnimation();
-
-    QString filename = QFileDialog::getOpenFileName( NULL,"select save file name", QDir::currentPath() ) ;
-
-    if ( ! filename.isEmpty() ) {
-        osgDB::writeNodeFile( *viewer()->getScene(), filename.toStdString() );
-    }
-
-    viewer()->startAnimation();
-}
-
-///
-///
-///
-void ViewerWindow::toGISView()
-{
-    viewer()->setCameraManipulator( new GISManipulator(), /* resetPosition = */ true );
-}
-
-///
-///
-///
-void ViewerWindow::toFreeView()
-{
-    viewer()->setCameraManipulator( new osgGA::OrbitManipulator(), /* resetPosition = */ true );
-}
-
-///
-///
-///
-void ViewerWindow::createMenus()
-{
-    /*
-     * File menu
-     */
-    _menuFile = menuBar()->addMenu( "&File" ) ;
-
-    //-- load a file
-    QAction* actionLoadFile = _menuFile->addAction( "&Load a file..." );
-    connect( actionLoadFile, SIGNAL( triggered() ), this, SLOT( loadFile() ) );
-
-    //-- save as file
-    QAction* actionSaveFile = _menuFile->addAction( "&save to file..." );
-    connect( actionSaveFile, SIGNAL( triggered() ), this, SLOT( saveFile() ) );
-
-
-    //-- screenshot
-    QAction* actionSaveAsImage = _menuFile->addAction( "&Save as image..." );
-    connect( actionSaveAsImage, SIGNAL( triggered() ), this, SLOT( screenShot() ) );
-
-    _menuFile->addSeparator();
-    //-- exit
-    QAction* actionExit = _menuFile->addAction( "&Exit" );
-    connect( actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
-
-    /*
-     * Display menu
-     */
-    QMenu* displayMenu = menuBar()->addMenu( "&Display" );
-    QAction* gisView = displayMenu->addAction( "GIS view\t0" );
-    connect( gisView, SIGNAL( triggered() ), this, SLOT( toGISView() ) );
-
-    QAction* freeView = displayMenu->addAction( "Free view\t1" );
-    connect( freeView, SIGNAL( triggered() ), this, SLOT( toFreeView() ) );
-
-    /*
-     * Help menu
-     */
-    _menuHelp = menuBar()->addMenu( "&Help" ) ;
-
-    //-- about
-    QAction* actionAbout = _menuHelp->addAction( "&About" );
-    connect( actionAbout, SIGNAL( triggered() ), this, SLOT( about() ) );
-}
-
-
-
-}//viewer
-}//SFCGAL
-
diff --git a/viewer/src/SFCGAL/viewer/plugins/DataPlugin.cpp b/viewer/src/SFCGAL/viewer/plugins/DataPlugin.cpp
deleted file mode 100644
index 71b125c..0000000
--- a/viewer/src/SFCGAL/viewer/plugins/DataPlugin.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/viewer/plugins/DataPlugin.h>
-#include <SFCGAL/viewer/ViewerWindow.h>
-#include <SFCGAL/viewer/ViewerWidget.h>
-
-#include <iostream>
-
-#include <QtGui/QMenu>
-#include <QtGui/QMenuBar>
-#include <QtGui/QInputDialog>
-
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-///
-///
-///
-DataPlugin::DataPlugin()
-{
-
-}
-
-///
-///
-///
-QString DataPlugin::pluginName() const
-{
-    return QString( "DataPlugin" );
-}
-
-///
-///
-///
-void DataPlugin::displayNodeInformation( osg::Node* node, std::ostream& s, const size_t& depth )
-{
-    std::string indent ;
-
-    for ( size_t i = 0; i < depth; i++ ) {
-        indent += ' ';
-    }
-
-    s << indent << "Node[" << node->getName() << "]" << std::endl;
-    osg::Group* group = node->asGroup() ;
-
-    if ( group ) {
-        for ( size_t i = 0; i < group->getNumChildren(); i++ ) {
-            s << indent << "child[" << i << "]" << std::endl;
-            displayNodeInformation( group->getChild( i ), s, depth + 1 ) ;
-        }
-    }
-    else {
-        osg::Geode* geode = dynamic_cast< osg::Geode* >( node ) ;
-        s << indent << "Geode[" << geode->getBoundingBox().xMin() << " " << geode->getBoundingBox().xMax() << " " ;
-        s << geode->getBoundingBox().yMin() << " " << geode->getBoundingBox().yMax() << " " ;
-        s << geode->getBoundingBox().zMin() << " " << geode->getBoundingBox().zMax() << "]" << std::endl;
-    }
-}
-
-///
-///
-///
-void DataPlugin::displayInformations()
-{
-    displayNodeInformation( viewerWindow()->viewer()->getScene(), std::cout );
-}
-
-///
-///
-///
-void DataPlugin::load()
-{
-    QMenu* pluginMenu = viewerWindow()->menuBar()->addMenu( "Data" ) ;
-
-    QAction* actionDisplayInformations = pluginMenu->addAction( QString( "&display information" ) );
-    connect( actionDisplayInformations, SIGNAL( triggered() ), this, SLOT( displayInformations() ) );
-}
-
-
-
-}//plugins
-}//viewer
-}//SFCGAL
-
diff --git a/viewer/src/SFCGAL/viewer/plugins/DemoPlugin.cpp b/viewer/src/SFCGAL/viewer/plugins/DemoPlugin.cpp
deleted file mode 100644
index 6775d57..0000000
--- a/viewer/src/SFCGAL/viewer/plugins/DemoPlugin.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/viewer/plugins/DemoPlugin.h>
-#include <SFCGAL/viewer/ViewerWindow.h>
-#include <SFCGAL/viewer/ViewerWidget.h>
-
-#include <iostream>
-
-#include <QtGui/QMenu>
-#include <QtGui/QMenuBar>
-#include <QtGui/QInputDialog>
-
-#include <osg/Geode>
-
-#include <SFCGAL/Point.h>
-#include <SFCGAL/LineString.h>
-#include <SFCGAL/Polygon.h>
-#include <SFCGAL/Triangle.h>
-#include <SFCGAL/PolyhedralSurface.h>
-#include <SFCGAL/TriangulatedSurface.h>
-#include <SFCGAL/Solid.h>
-#include <SFCGAL/GeometryCollection.h>
-#include <SFCGAL/MultiPoint.h>
-#include <SFCGAL/MultiLineString.h>
-#include <SFCGAL/MultiPolygon.h>
-#include <SFCGAL/MultiSolid.h>
-
-#include <SFCGAL/io/wkt.h>
-#include <SFCGAL/detail/io/OsgFactory.h>
-#include <SFCGAL/algorithm/extrude.h>
-#include <SFCGAL/algorithm/convexHull.h>
-
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-///
-///
-///
-DemoPlugin::DemoPlugin():
-    ViewerPlugin()
-{
-
-}
-
-///
-///
-///
-QString DemoPlugin::pluginName() const
-{
-    return QString( "DemoPlugin" );
-}
-
-///
-///
-///
-void DemoPlugin::demoExtrude()
-{
-    QString wkt = QInputDialog::getText( NULL, QString( "Read WKT" ), QString( "Type WKT" ) );
-
-    if ( wkt.isEmpty() ) {
-        return ;
-    }
-
-    //parse wkt
-    std::auto_ptr< Geometry > g( io::readWkt( wkt.toStdString() ) );
-
-    //extrude
-    double h = QInputDialog::getDouble( NULL,"Height","Type height" );
-    std::auto_ptr< Geometry > ext( algorithm::extrude( *g,0.,0.,h ) );
-
-    //create osg::Geode
-    detail::io::OsgFactory factory ;
-    osg::Geometry* osgGeometry = factory.createGeometry( *ext );
-    osg::Geode* geode = new osg::Geode;
-    geode->setName( wkt.toStdString() );
-    geode->addDrawable( osgGeometry );
-
-    viewerWindow()->viewer()->getScene()->addChild( geode );
-}
-
-
-///
-///
-///
-void DemoPlugin::demoConvexhull()
-{
-    QString wkt = QInputDialog::getText( NULL, QString( "Read WKT" ), QString( "Type WKT" ) );
-
-    if ( wkt.isEmpty() ) {
-        return ;
-    }
-
-    //parse wkt
-    std::auto_ptr< Geometry > g( io::readWkt( wkt.toStdString() ) );
-
-    //build convexhull
-    std::auto_ptr< Geometry > hull( algorithm::convexHull3D( *g ) );
-
-    //create osg::Geode
-    detail::io::OsgFactory factory ;
-    osg::Geometry* osgGeometry = factory.createGeometry( *hull );
-    osg::Geode* geode = new osg::Geode;
-    geode->setName( wkt.toStdString() );
-    geode->addDrawable( osgGeometry );
-
-    viewerWindow()->viewer()->getScene()->addChild( geode );
-}
-
-///
-///
-///
-void DemoPlugin::demoSpiral()
-{
-    std::vector< Point > points ;
-
-    double r     = 0.0 ;
-    double z     = 0.0 ;
-    double theta = 0.0 ;
-
-    for ( size_t i = 0; i < 1000; i++ ) {
-        Point p( r*cos( theta ), r*sin( theta ), z );
-        points.push_back( p );
-
-        if ( i < 500 ) {
-            r += 0.01 ;
-        }
-        else {
-            r -= 0.01 ;
-        }
-
-        z     += 0.01 ;
-        theta += 0.1 ;
-    }
-
-    LineString g( points );
-
-    /*
-     * Convert to osg::Geometry
-     */
-    detail::io::OsgFactory factory ;
-    osg::Geometry* osgGeometry = factory.createGeometry( g );
-
-
-    /*
-     * provide a color to osg::Geometry
-     */
-    osg::Vec3Array* colors = new osg::Vec3Array();
-    colors->push_back( osg::Vec3( 1.0f,0.0f,0.0f ) );
-    osgGeometry->setColorArray( colors );
-    osgGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
-
-    /*
-     * Create a named Geode (Geometric Node)
-     */
-    osg::Geode* geode = new osg::Geode;
-    geode->setName( "DemoPlugin::demoSpiral" );
-    geode->addDrawable( osgGeometry );
-
-    viewerWindow()->viewer()->getScene()->addChild( geode );
-}
-
-///
-///
-///
-void DemoPlugin::demoWkt()
-{
-    QString wkt = QInputDialog::getText( NULL, QString( "Read WKT" ), QString( "Type WKT" ) );
-
-    if ( wkt.isEmpty() ) {
-        return ;
-    }
-
-    //parse
-    std::auto_ptr< Geometry > g( io::readWkt( wkt.toStdString() ) );
-    detail::io::OsgFactory factory ;
-
-    osg::Geometry* osgGeometry = factory.createGeometry( *g );
-    osg::Geode* geode = new osg::Geode;
-    geode->setName( wkt.toStdString() );
-    geode->addDrawable( osgGeometry );
-
-    viewerWindow()->viewer()->getScene()->addChild( geode );
-}
-
-
-///
-///
-///
-void DemoPlugin::load()
-{
-    QMenu* pluginMenu = viewerWindow()->menuBar()->addMenu( "DemoPlugin" ) ;
-
-    QAction* actionExtrude = pluginMenu->addAction( QString( "&extrude" ) );
-    connect( actionExtrude, SIGNAL( triggered() ), this, SLOT( demoExtrude() ) );
-
-    QAction* actionConvexhull = pluginMenu->addAction( QString( "&convexhull" ) );
-    connect( actionConvexhull, SIGNAL( triggered() ), this, SLOT( demoConvexhull() ) );
-
-
-    QAction* actionReadWkt = pluginMenu->addAction( QString( "&read wkt" ) );
-    connect( actionReadWkt, SIGNAL( triggered() ), this, SLOT( demoWkt() ) );
-
-    QAction* actionDemoSpiral = pluginMenu->addAction( QString( "&create a spiral" ) );
-    connect( actionDemoSpiral, SIGNAL( triggered() ), this, SLOT( demoSpiral() ) );
-}
-
-
-
-}//plugins
-}//viewer
-}//SFCGAL
-
diff --git a/viewer/src/SFCGAL/viewer/plugins/GridPlugin.cpp b/viewer/src/SFCGAL/viewer/plugins/GridPlugin.cpp
deleted file mode 100644
index 0d64f39..0000000
--- a/viewer/src/SFCGAL/viewer/plugins/GridPlugin.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <SFCGAL/viewer/plugins/GridPlugin.h>
-
-#include <SFCGAL/Point.h>
-#include <SFCGAL/MultiPoint.h>
-
-#include <SFCGAL/viewer/ViewerWindow.h>
-#include <SFCGAL/viewer/ViewerWidget.h>
-
-#include <fstream>
-
-#include <SFCGAL/detail/io/OsgFactory.h>
-
-#include <QtGui/QMenu>
-#include <QtGui/QMenuBar>
-#include <QtGui/QInputDialog>
-#include <QtGui/QMessageBox>
-#include <QtGui/QFileDialog>
-
-#include <osgUtil/Optimizer>
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-///
-///
-///
-GridPlugin::GridPlugin()
-{
-
-}
-
-///
-///
-///
-QString GridPlugin::pluginName() const
-{
-    return "GridPlugin";
-}
-
-///
-///
-///
-void GridPlugin::loadGridXYZ()
-{
-    viewerWindow()->viewer()->stopAnimation();
-    QString filename = QFileDialog::getOpenFileName( NULL, QString( "Open XYZ grid file" ) );
-
-    std::ifstream ifs( filename.toStdString().c_str() );
-
-    if ( ! ifs.good() ) {
-        QMessageBox::warning( NULL, QString( "load grid XYZ" ), QString( "can't load file" ) ) ;
-    }
-
-    MultiPoint multiPoint ;
-    double x, y, z ;
-
-    while ( ! ifs.eof() && ( ifs >> x >> y >> z ) ) {
-        if ( z == 0.0 ) {
-            continue ;
-        }
-
-        multiPoint.addGeometry( Point( x,y,z ) );
-    }
-
-    ifs.close();
-
-    //create OSG geometry
-    detail::io::OsgFactory factory ;
-    osg::Geode* geode = new osg::Geode();
-    geode->setName( filename.toStdString() );
-
-    geode->addDrawable( factory.createGeometry( multiPoint ) );
-
-    osgUtil::Optimizer optimizer ;
-    optimizer.optimize( geode );
-
-    geode->setCullingActive( false );
-
-    viewerWindow()->viewer()->getScene()->addChild( geode );
-
-
-    viewerWindow()->viewer()->startAnimation();
-}
-
-///
-///
-///
-void GridPlugin::load()
-{
-    QMenu* pluginMenu = viewerWindow()->menuBar()->addMenu( "GridPlugin" ) ;
-
-    QAction* actionLoadXYZ = pluginMenu->addAction( QString( "&load xyz" ) );
-    connect( actionLoadXYZ, SIGNAL( triggered() ), this, SLOT( loadGridXYZ() ) );
-}
-
-
-}//plugins
-}//viewer
-}//SFCGAL
-
-
-
diff --git a/viewer/src/SFCGAL/viewer/plugins/PSQLPlugin.cpp b/viewer/src/SFCGAL/viewer/plugins/PSQLPlugin.cpp
deleted file mode 100644
index f335e47..0000000
--- a/viewer/src/SFCGAL/viewer/plugins/PSQLPlugin.cpp
+++ /dev/null
@@ -1,553 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <iostream>
-
-#include <SFCGAL/viewer/plugins/PSQLPlugin.h>
-#include <SFCGAL/viewer/ViewerWindow.h>
-#include <SFCGAL/viewer/ViewerWidget.h>
-#include <SFCGAL/detail/io/OsgFactory.h>
-#include <SFCGAL/io/wkt.h>
-
-#include <osg/Geode>
-
-#include <QtGui/QMenu>
-#include <QtGui/QLabel>
-#include <QtGui/QMenuBar>
-#include <QtGui/QInputDialog>
-#include <QtGui/QMessageBox>
-#include <QtGui/QFileDialog>
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QApplication>
-
-#include "db.h"
-
-namespace SFCGAL {
-namespace viewer {
-namespace plugins {
-
-struct LayerInfo {
-    LayerInfo() : query( "" ), geode( 0 ) {}
-    std::string dbOptions;
-    std::string query;
-    osg::ref_ptr<osg::Geode> geode;
-};
-
-SQLConsole::SQLConsole( PSQLPlugin* plugin ) : QDockWidget( NULL ), plugin_( plugin )
-{
-    setMinimumSize( QSize( 300, 50 ) );
-    setWindowTitle( "SQL Console" );
-
-    QWidget* dockWidgetContents = new QWidget();
-    dockWidgetContents->setObjectName( QString::fromUtf8( "dockWidgetContents" ) );
-    QVBoxLayout* verticalLayout_2 = new QVBoxLayout( dockWidgetContents );
-    verticalLayout_2->setObjectName( QString::fromUtf8( "verticalLayout_2" ) );
-
-    QLabel* lbl1 = new QLabel( "DB options" );
-    verticalLayout_2->addWidget( lbl1 );
-
-    QHBoxLayout* hbox2 = new QHBoxLayout();
-    dbOptions_ = new QLineEdit( dockWidgetContents );
-    hbox2->addWidget( dbOptions_ );
-
-    connectBtn_ = new QPushButton( dockWidgetContents );
-    connectBtn_->setText( "&Connect" );
-    hbox2->addWidget( connectBtn_ );
-    verticalLayout_2->addItem( hbox2 );
-
-    QLabel* lbl2 = new QLabel( "SQL" );
-    verticalLayout_2->addWidget( lbl2 );
-
-    sqlEdit_ = new QPlainTextEdit( dockWidgetContents );
-    sqlEdit_->setObjectName( QString::fromUtf8( "sqlEdit" ) );
-    sqlEdit_->setMinimumSize( QSize( 200, 0 ) );
-
-    verticalLayout_2->addWidget( sqlEdit_ );
-
-    QHBoxLayout* horizontalLayout = new QHBoxLayout();
-    horizontalLayout->setObjectName( QString::fromUtf8( "horizontalLayout" ) );
-    QSpacerItem* horizontalSpacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
-
-    horizontalLayout->addItem( horizontalSpacer );
-
-    okBtn_ = new QPushButton( dockWidgetContents );
-    okBtn_->setObjectName( QString::fromUtf8( "okBtn" ) );
-    okBtn_->setText( "&Edit" );
-
-    horizontalLayout->addWidget( okBtn_ );
-
-    verticalLayout_2->addLayout( horizontalLayout );
-
-    setWidget( dockWidgetContents );
-
-    dbOptions_->setEnabled( false );
-    sqlEdit_->setEnabled( false );
-    okBtn_->setEnabled( false );
-
-    // connect signal
-    connect( okBtn_, SIGNAL( clicked() ), this, SLOT( onQuery() ) );
-    connect( connectBtn_, SIGNAL( clicked() ), this, SLOT( onReconnect() ) );
-}
-
-void SQLConsole::connectItem( QListWidgetItem* item )
-{
-    item_ = item;
-    dbOptions_->setEnabled( true );
-    connectBtn_->setEnabled( true );
-    sqlEdit_->setEnabled( true );
-    okBtn_->setText( "&Ok" );
-    okBtn_->setEnabled( true );
-    // disconnect from the db
-    disconnect();
-
-    sqlEdit_->clear();
-    LayerInfo* linfo = ( LayerInfo* )item_->data( Qt::UserRole ).value<void*>();
-
-    dbOptions_->setText( QString::fromStdString( linfo->dbOptions ) );
-    sqlEdit_->appendPlainText( QString::fromStdString( linfo->query ) );
-}
-
-void SQLConsole::disconnectItem()
-{
-    item_ = 0;
-    dbOptions_->setEnabled( false );
-    sqlEdit_->setEnabled( false );
-    okBtn_->setText( "&Edit" );
-    okBtn_->setEnabled( false );
-    connectBtn_->setEnabled( false );
-}
-
-void SQLConsole::onReconnect()
-{
-    plugin_->disconnect();
-    plugin_->connect( dbOptions_->text().toStdString() );
-}
-
-void SQLConsole::onQuery()
-{
-    plugin_->connect( dbOptions_->text().toStdString() );
-    osg::Geode* geode = plugin_->doQuery( sqlEdit_->toPlainText().toStdString() );
-
-    // store the query and its result
-    LayerInfo* linfo = ( LayerInfo* )item_->data( Qt::UserRole ).value<void*>();
-    linfo->query = sqlEdit_->toPlainText().toStdString();
-    linfo->dbOptions = dbOptions_->text().toStdString();
-    linfo->geode = osg::ref_ptr<osg::Geode>( geode );
-
-    // refresh the display
-    plugin_->display();
-}
-
-LayersWidget::LayersWidget( PSQLPlugin* plugin, SQLConsole* console ) : console_( console ), plugin_( plugin )
-{
-    setMinimumSize( QSize( 100, 50 ) );
-
-    QWidget* dockWidgetContents = new QWidget();
-    dockWidgetContents->setObjectName( QString::fromUtf8( "dockWidgetContents" ) );
-    QVBoxLayout* verticalLayout = new QVBoxLayout( dockWidgetContents );
-    verticalLayout->setObjectName( QString::fromUtf8( "verticalLayout" ) );
-    listWidget_ = new QListWidget( dockWidgetContents );
-    listWidget_->setObjectName( QString::fromUtf8( "listWidget" ) );
-
-    addBtn_ = new QPushButton( dockWidgetContents );
-    addBtn_->setText( "&Add" );
-
-    verticalLayout->addWidget( addBtn_ );
-    verticalLayout->addWidget( listWidget_ );
-
-    setWidget( dockWidgetContents );
-    setWindowTitle( "Layers" );
-
-    // connect signal
-    connect( addBtn_, SIGNAL( clicked() ), this, SLOT( onAdd() ) );
-
-    //
-    connect( listWidget_, SIGNAL( pressed( const QModelIndex& ) ), this, SLOT( onClick( const QModelIndex& ) ) );
-}
-
-void LayersWidget::addLayer( const QString& name, bool visible, const QString& dbOptions, const QString& query )
-{
-    QListWidgetItem* item = new QListWidgetItem( name );
-    item->setFlags( item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsEditable );
-
-    if ( visible ) {
-        item->setCheckState( Qt::Checked );
-    }
-    else {
-        item->setCheckState( Qt::Unchecked );
-    }
-
-    LayerInfo* linfo = new LayerInfo;
-    linfo->dbOptions = dbOptions.toStdString();
-    linfo->query = query.toStdString();
-    item->setData( Qt::UserRole, qVariantFromValue( ( void* )linfo ) );
-    listWidget_->addItem( item );
-}
-
-void LayersWidget::onAdd()
-{
-    addLayer( "layer", true, "", "" );
-}
-
-void LayersWidget::onClick( const QModelIndex& /*idx*/ )
-{
-    if ( QApplication::mouseButtons() & Qt::RightButton ) {
-        QMenu* menu = new QMenu;
-        QAction* removeAction = menu->addAction( "&Remove" );
-        connect( removeAction, SIGNAL( triggered() ), this, SLOT( onRemove() ) );
-        QAction* zoomAction = menu->addAction( "&Zoom to layer extent" );
-        connect( zoomAction, SIGNAL( triggered() ), this, SLOT( onZoomToLayer() ) );
-
-        menu->popup( QCursor::pos() );
-    }
-    else {
-        // left button
-        onEdit();
-    }
-}
-
-void LayersWidget::onEdit()
-{
-    //		std::cout << "edit " << listWidget_->currentRow() << std::endl;
-    console_->connectItem( listWidget_->item( listWidget_->currentRow() ) );
-}
-
-void LayersWidget::onRemove()
-{
-    console_->disconnectItem();
-
-    int current = listWidget_->currentRow();
-    QListWidgetItem* widget = listWidget_->item( current );
-    listWidget_->removeItemWidget( widget );
-    delete widget;
-}
-
-void LayersWidget::onZoomToLayer()
-{
-    int current = listWidget_->currentRow();
-    QListWidgetItem* item = listWidget_->item( current );
-    LayerInfo* linfo = ( LayerInfo* )item->data( Qt::UserRole ).value<void*>();
-
-    if ( linfo->geode ) {
-        const osg::BoundingBox& bbox = linfo->geode->getBoundingBox();
-        std::cout << bbox.xMin() << " ; " << bbox.xMax() << " " << bbox.yMin() << " ; " << bbox.yMax() << " " << bbox.zMin() << " ; " << bbox.zMax() << std::endl;
-        std::cout << bbox.center()[0] << " " << bbox.center()[1] << " " << bbox.center()[2] << std::endl;
-        plugin_->viewerWindow()->viewer()->setCameraToExtent( bbox );
-    }
-}
-
-std::string wkbToWkt( const std::string& wkb, const Db::Connection& db )
-{
-    // wkb is a hex textual representation of a binary array
-    std::string q = "SELECT ST_AsText(ST_GeomFromEWKB('\\x" + wkb + "'))";
-    // temporary : use a PostGIS query to convert from wkb to wkt
-    Db::Result r = db.exec( q );
-
-    if ( r.size() == 1 ) {
-        return r[0][0].as<std::string>();
-    }
-
-    return "";
-}
-
-
-struct Color {
-    Color( float r, float g, float b ) : r( r ), g( g ), b( b ) {}
-    float r, g, b;
-};
-
-//
-// The Pimpl class for this plugin
-struct PSQLPluginImpl {
-    PSQLPluginImpl( PSQLPlugin* super ) : geometry_oid_( 0 ), console( 0 ), layers( 0 ), isConnected( false ), super_( super ) {
-        colors.push_back( Color( 1.0, 0.0, 0.0 ) );
-        colors.push_back( Color( 0.0, 1.0, 0.0 ) );
-        colors.push_back( Color( 0.0, 0.0, 1.0 ) );
-        colors.push_back( Color( 1.0, 1.0, 0.0 ) );
-        colors.push_back( Color( 0.0, 1.0, 1.0 ) );
-        colors.push_back( Color( 1.0, 0.0, 1.0 ) );
-    }
-    unsigned geometry_oid_;
-    std::vector<Color> colors;
-    Db::Connection db;
-    SQLConsole* console;
-    LayersWidget* layers;
-    bool isConnected;
-
-    PSQLPlugin* super_;
-};
-
-///
-///
-///
-PSQLPlugin::PSQLPlugin() : impl_( new PSQLPluginImpl( this ) )
-{
-
-}
-
-
-PSQLPlugin::~PSQLPlugin()
-{
-    delete impl_;
-}
-
-void PSQLPlugin::launchConsole()
-{
-    impl_->console = new SQLConsole( this );
-    viewerWindow()->addDockWidget( Qt::BottomDockWidgetArea, impl_->console );
-    impl_->layers = new LayersWidget( this, impl_->console );
-    viewerWindow()->addDockWidget( Qt::LeftDockWidgetArea, impl_->layers );
-}
-
-void PSQLPlugin::connect( const std::string& db_options )
-{
-    if ( impl_->isConnected ) {
-        return;
-    }
-
-    try {
-        impl_->db.connect( db_options );
-    }
-    catch ( std::exception& e ) {
-        std::cerr << e.what() << std::endl;
-        return;
-    }
-
-    //
-    // get geometry type oid
-    Db::Result r = impl_->db.exec( "SELECT oid FROM pg_type WHERE typname='geometry'" );
-
-    if ( r.size() == 0 ) {
-        std::cerr << "Not a PostGIS database" << std::endl;
-        return;
-    }
-
-    impl_->geometry_oid_ = r[0][0].as<unsigned>();
-    impl_->isConnected = true;
-}
-
-void PSQLPlugin::disconnect()
-{
-    impl_->isConnected = false;
-}
-
-osg::Geode* PSQLPlugin::doQuery( const std::string& query )
-{
-    Db::Result r;
-
-    try {
-        r = impl_->db.exec( query );
-    }
-    catch ( std::runtime_error& e ) {
-        std::cerr << e.what() << std::endl;
-        return 0;
-    }
-
-    detail::io::OsgFactory factory;
-    osg::ref_ptr<osg::Geode> geode( new osg::Geode );
-
-    try {
-
-        std::cout << "# of rows: " << r.size() << std::endl;
-
-        for ( size_t i = 0; i < r.size(); ++i ) {
-            for ( size_t j = 0; j < r.columns(); ++j ) {
-                std::string geomWkt;
-
-                if ( PQftype( r.result(), j ) == impl_->geometry_oid_ ) {
-                    geomWkt = wkbToWkt( r[i][j].as<std::string>(), impl_->db );
-                }
-                else {
-                    geomWkt = r[i][j].as<std::string>();
-                }
-
-                std::auto_ptr<Geometry> g  = ( io::readWkt( geomWkt ) );
-                osg::Geometry* osgGeo = factory.createGeometry( *g );
-
-                osg::Vec4Array* colors = new osg::Vec4Array;
-                // Each column has a color
-                const Color& c = impl_->colors[ j % impl_->colors.size() ];
-                colors->push_back( osg::Vec4( c.r, c.g, c.b, 1.0f ) );
-                osgGeo->setColorArray( colors );
-                osgGeo->setColorBinding( osg::Geometry::BIND_OVERALL );
-
-                geode->addDrawable( osgGeo );
-            }
-        }
-
-    }
-    catch ( std::exception& e ) {
-        std::cerr << e.what() << std::endl;
-        return 0;
-    }
-
-    return geode.release();
-}
-
-void PSQLPlugin::computeGeometries()
-{
-    // iterate through the layers
-    QListWidget* listWidget = impl_->layers->widget();
-
-    for ( int i = 0; i < listWidget->count(); ++i ) {
-        QListWidgetItem* item = listWidget->item( i );
-        LayerInfo* linfo = ( LayerInfo* )item->data( Qt::UserRole ).value<void*>();
-
-        disconnect();
-        connect( linfo->dbOptions );
-        linfo->geode = osg::ref_ptr<osg::Geode>( doQuery( linfo->query ) );
-    }
-}
-
-void PSQLPlugin::display()
-{
-    if ( impl_->layers == 0 ) {
-        return;
-    }
-
-    osg::Group* root = viewerWindow()->viewer()->getScene();
-    // remove all children
-    root->removeChildren( 0, root->getNumChildren() );
-
-    // iterate through the layers
-    QListWidget* listWidget = impl_->layers->widget();
-
-    for ( int i = 0; i < listWidget->count(); ++i ) {
-        QListWidgetItem* item = listWidget->item( i );
-        LayerInfo* linfo = ( LayerInfo* )item->data( Qt::UserRole ).value<void*>();
-        bool visible = item->data( Qt::CheckStateRole ).toBool();
-        std::cout << "visible = " << visible << std::endl;
-
-        if ( visible && linfo->geode != 0 ) {
-            root->addChild( linfo->geode );
-        }
-    }
-}
-
-void PSQLPlugin::onRefresh()
-{
-    display();
-}
-///
-///
-///
-QString PSQLPlugin::pluginName() const
-{
-    return "PSQLPlugin";
-}
-
-void PSQLPlugin::saveLayers()
-{
-    if ( impl_->layers == 0 ) {
-        launchConsole();
-    }
-
-    viewerWindow()->viewer()->stopAnimation();
-    QString filename = QFileDialog::getSaveFileName( NULL, QString( "Choose a layers file to save to" ) );
-
-    QFile file( filename );
-    file.open( QIODevice::ReadWrite );
-    QDataStream stream( &file );
-
-    // iterate through the layers
-    QListWidget* listWidget = impl_->layers->widget();
-
-    // write the number of layers
-    stream << listWidget->count();
-
-    for ( int i = 0; i < listWidget->count(); ++i ) {
-        QListWidgetItem* item = listWidget->item( i );
-        QString name = item->text();
-        LayerInfo* linfo = ( LayerInfo* )item->data( Qt::UserRole ).value<void*>();
-        bool visible = item->data( Qt::CheckStateRole ).toBool();
-
-        // write the layer's data
-        stream << name << visible << QString::fromStdString( linfo->dbOptions ) << QString::fromStdString( linfo->query );
-    }
-
-    file.flush();
-    viewerWindow()->viewer()->startAnimation();
-}
-
-void PSQLPlugin::loadLayers()
-{
-    if ( impl_->layers == 0 ) {
-        launchConsole();
-    }
-
-    viewerWindow()->viewer()->stopAnimation();
-    QString filename = QFileDialog::getOpenFileName( NULL, QString( "Choose file to load layers from" ) );
-    QFile file( filename );
-    file.open( QIODevice::ReadOnly );
-    QDataStream str( &file );
-
-    // iterate through the layers
-    QListWidget* listWidget = impl_->layers->widget();
-
-    // clear the list
-    listWidget->clear();
-
-    // number of layers
-    int count;
-    str >> count;
-
-    for ( int i = 0; i < count; ++i ) {
-        QString name, dbOptions, query;
-        bool visible;
-
-        // read the layer's data
-        str >> name >> visible >> dbOptions >> query;
-        impl_->layers->addLayer( name, visible, dbOptions, query );
-    }
-
-    file.flush();
-
-    //
-    computeGeometries();
-    display();
-
-    impl_->console->disconnectItem();
-    viewerWindow()->viewer()->startAnimation();
-}
-
-void PSQLPlugin::load()
-{
-    QMenu* pluginMenu = viewerWindow()->menuBar()->addMenu( "PostGIS" ) ;
-
-    QAction* action = pluginMenu->addAction( QString( "&SQL console" ) );
-    QObject::connect( action, SIGNAL( triggered() ), this, SLOT( launchConsole() ) );
-
-    QAction* saveAction = pluginMenu->addAction( QString( "&Save layers" ) );
-    QObject::connect( saveAction, SIGNAL( triggered() ), this, SLOT( saveLayers() ) );
-
-    QAction* loadAction = pluginMenu->addAction( QString( "&Load layers" ) );
-    QObject::connect( loadAction, SIGNAL( triggered() ), this, SLOT( loadLayers() ) );
-
-    QAction* refreshAction = pluginMenu->addAction( QString( "&Refresh display\tF5" ) );
-    refreshAction->setShortcut( QKeySequence( "F5" ) );
-    QObject::connect( refreshAction, SIGNAL( triggered() ), this, SLOT( onRefresh() ) );
-}
-
-
-}//plugins
-}//viewer
-}//SFCGAL
-
-
-
diff --git a/viewer/src/db.cpp b/viewer/src/db.cpp
deleted file mode 100644
index bdd0369..0000000
--- a/viewer/src/db.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *   SFCGAL
- *
- *   Copyright (C) 2012-2013 Oslandia <infos at oslandia.com>
- *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
- *
- *   This library is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU Library General Public
- *   License as published by the Free Software Foundation; either
- *   version 2 of the License, or (at your option) any later version.
- *
- *   This library 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
- *   Library General Public License for more details.
-
- *   You should have received a copy of the GNU Library General Public
- *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-#include <iostream>
-
-#include "db.h"
-
-namespace Db {
-template <>
-bool Value::as<bool>()
-{
-    return std::string( value_, len_ ) == "t" ? true : false;
-}
-
-template <>
-std::string Value::as<std::string>()
-{
-    return std::string( value_, len_ );
-}
-
-template <>
-long long Value::as<long long>()
-{
-    long long v;
-    sscanf( value_, "%Ld", &v );
-    return v;
-}
-template <>
-int Value::as<int>()
-{
-    int v;
-    sscanf( value_, "%d", &v );
-    return v;
-}
-template <>
-float Value::as<float>()
-{
-    float v;
-    sscanf( value_, "%f", &v );
-    return v;
-}
-template <>
-double Value::as<double>()
-{
-    double v;
-    sscanf( value_, "%lf", &v );
-    return v;
-}
-
-}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/sfcgal.git



More information about the Pkg-grass-devel mailing list