// graph-tool -- a general graph modification and manipulation thingy // // Copyright (C) 2007-2010 Tiago de Paula Peixoto // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 3 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // As a special exception, you have permission to link this program // with the CGAL library and distribute executables, as long as you // follow the requirements of the GNU GPL in regard to all of the // software in the executable aside from CGAL. #if (GCC_VERSION < 40400) # define CGAL_CFG_NO_TR1_ARRAY # define CGAL_CFG_NO_TR1_TUPLE #endif #include #include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Triangulation_3 SimpleTriangulation; typedef CGAL::Delaunay_triangulation_3 DelaunayTriangulation; namespace std { bool operator==(const SimpleTriangulation::Vertex& a, const SimpleTriangulation::Vertex& b) { return a.point() == b.point(); } } // periodic triangulation is only available in more recent versions of CGAL #if (CGAL_VERSION_NR >= 1030500000) #include #include typedef CGAL::Periodic_3_triangulation_traits_3 GT; typedef CGAL::Periodic_3_Delaunay_triangulation_3 PeriodicDelaunayTriangulation; namespace std { bool operator==(const PeriodicDelaunayTriangulation::Vertex& a, const PeriodicDelaunayTriangulation::Vertex& b) { return a.point() == b.point(); } } #endif #include "graph.hh" #include "graph_triangulation.hh" #include "graph_util.hh" #include "graph_filtering.hh" #include "numpy_bind.hh" using namespace std; using namespace boost; using namespace graph_tool; void triangulation(GraphInterface& gi, python::object points, boost::any pos, string type, bool periodic) { UndirectedAdaptor g(gi.GetGraph()); multi_array_ref points_array = get_array(points); typedef property_map_type::apply , GraphInterface::vertex_index_map_t>::type pos_type_t; pos_type_t pos_map = any_cast(pos); if (type == "simple") { get_triangulation()(g, points_array, pos_map); } else if (type == "delaunay") { if (!periodic) { get_triangulation()(g, points_array, pos_map); } else { #if (CGAL_VERSION_NR >= 1030500000) get_triangulation()(g, points_array, pos_map); #else throw ValueException("Periodic Delaunay triangulation is only " "available with versions of CGAL newer than " "3.5.0."); #endif } } gi.ReIndexEdges(); }