From dd8bf1f4dfcc4dcdaa918fa58f8e9ebcce7f08b4 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 24 May 2018 14:35:35 +0100 Subject: [PATCH] Add a constructor and two functions to get started --- .../heat_method_surface_mesh.cpp | 14 ++++ .../CGAL/Heat_method_3/Heat_method_3.h | 51 ++++++++++++-- .../Mockup_Surface_geodesic_distance.h | 38 +++++++++++ .../include/CGAL/license/Heat_method_3.h | 67 +++++++++++++++++++ 4 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 Heat_method_3/include/CGAL/Heat_method_3/Mockup_Surface_geodesic_distance.h create mode 100644 Installation/include/CGAL/license/Heat_method_3.h diff --git a/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp b/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp index 08f3b2ef12b..611b02ed9c5 100644 --- a/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp +++ b/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp @@ -1,5 +1,7 @@ #include #include +#include + #include #include @@ -7,11 +9,23 @@ typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Heat_method_3::Heat_method_3 Heat_method; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { Mesh sm; + std::ifstream in(argv[1]); + in >> sm; + + Heat_method hm(sm); + + vertex_descriptor source = *(vertices(sm).first); + hm.add_source(source); + + BOOST_FOREACH(vertex_descriptor vd , vertices(sm)){ + std::cout << vd << " is at distance " << hm.distance(vd) << " from " << source << std::endl; + } return 0; } diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Heat_method_3.h b/Heat_method_3/include/CGAL/Heat_method_3/Heat_method_3.h index 3dd6edd705b..63bbe4f704c 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/Heat_method_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/Heat_method_3.h @@ -25,21 +25,64 @@ #include #include +#include + +#include namespace CGAL { namespace Heat_method_3 { /** * Class `Heat_method_3` is a ... - * - * \tparam HMTraits must - * \sa `AA` + * \tparam TriangleMesh a triangulated surface mesh, model of `FaceGraph` and `HalfedgeListGraph` + * \tparam Traits a model of HeatMethodTraits_3 + * \tparam VertexPointMap a model of `ReadablePropertyMap` with + * `boost::graph_traits::%vertex_descriptor` as key and + * `Traits::Point_3` as value type. + * The default is `typename boost::property_map< TriangleMesh, vertex_point_t>::%type`. * */ - template + template ::type> class Heat_method_3 { + /// Polygon_mesh typedefs + typedef typename boost::graph_traits graph_traits; + typedef typename graph_traits::vertex_descriptor vertex_descriptor; + typedef typename graph_traits::edge_descriptor edge_descriptor; + typedef typename graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename graph_traits::face_descriptor face_descriptor; + + /// Geometric typedefs + typedef typename Traits::Point_3 Point_3; + typedef typename Traits::FT FT; + public: + + Heat_method_3(const TriangleMesh& tm) + : tm(tm) + {} + + /** + * add `vd` to the source set, returning `false` if `vd` is already in the set. + */ + bool add_source(vertex_descriptor vd) + { + return sources.insert(vd).second; + } + + /** + * get distance from the current source set to a vertex ` vd`. + */ + double distance(vertex_descriptor vd) + { + return 0; + } + + private: + const TriangleMesh& tm; + std::set sources; }; } // namespace Heat_method_3 diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Mockup_Surface_geodesic_distance.h b/Heat_method_3/include/CGAL/Heat_method_3/Mockup_Surface_geodesic_distance.h new file mode 100644 index 00000000000..d9ebb61e079 --- /dev/null +++ b/Heat_method_3/include/CGAL/Heat_method_3/Mockup_Surface_geodesic_distance.h @@ -0,0 +1,38 @@ +class Surface_mesh_geodesic_distance +{ + public: + // METHODS FOR QUERYING DISTANCE ======================= + + // Distance to a single source + double getDistance( Vertex y ); // get distance from the current source set to a vertex y + void getDistance( VertexSet T, VertexValuePairs dist ); // get distance from the current source set to each vertex in T + void getDistance( VertexFunction& dist ); // get distance from the current source set to all vertices + + // All-pairs distance query + void allPairsDistance( VertexSet S, Matrix D ); // compute all distances between pairs of points in S + + // Furthest point queries + void furthestPoint( Vertex& p, double& furthestDistance ); // find the point furthest from the current source set, and its distance; if there is not a unique furthest point, pick an arbitrary point + + // Distance gradients + double getDistanceGradient( Vertex y ); // get distance gradient with respect to the current source set to a vertex y + void getDistanceGradient( VertexSet T, VertexValuePairs dist ); // get distance gradient with respect to the current source set to each vertex in T + void getDistanceGradient( VertexFunction& dist ); // get distance gradient with respect to the current source set to all vertices + + // METHODS FOR SPECIFYING SOURCE SET =================== + bool addSource( Vertex s ); // add s to the source set, returning false if s is already in the set + bool removeSource( Vertex s ); // remove s to the source set, returning false if s is not in the set + void getSources( VertexSet& S ); // get the list of current sources + void clearSources(); // empty the source set + SourcePointIterator sourcesBegin(); // iterator to beginning of source list + SourcePointIterator sourcesEnd(); // iterator end end of source list + + protected: + // precomputed data + CholeskyFactorization Lheat; // factorization for Step I of heat method + CholeskyFactorization Lpoisson; // factorization for Step II of heat method + SurfaceMesh remesh; // intrinsic Delaunay mesh + + VertexSet sources; +}; + diff --git a/Installation/include/CGAL/license/Heat_method_3.h b/Installation/include/CGAL/license/Heat_method_3.h new file mode 100644 index 00000000000..7f270ec9338 --- /dev/null +++ b/Installation/include/CGAL/license/Heat_method_3.h @@ -0,0 +1,67 @@ +// Copyright (c) 2016 GeometryFactory SARL (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0+ +// +// Author(s) : Andreas Fabri +// +// Warning: this file is generated, see include/CGAL/licence/README.md + + +#ifndef CGAL_LICENSE_HEAT_METHOD_3_H +#define CGAL_LICENSE_HEAT_METHOD_3_H + +#include +#include + + + + +#ifdef CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE + +# if CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +# if defined(CGAL_LICENSE_WARNING) + + CGAL_pragma_warning("Your commercial license for CGAL does not cover " + "this release of the 3D Heat Method package.") +# endif + +# ifdef CGAL_LICENSE_ERROR +# error "Your commercial license for CGAL does not cover this release \ +of the 3D Heat Method package. \ +You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +# endif // CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +#else // no CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE + +# if defined(CGAL_LICENSE_WARNING) + CGAL_pragma_warning("\nThe macro CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE is not defined." + "\nYou use the CGAL 3D Heat Method package under " + "the terms of the GPLv3+.") +# endif // CGAL_LICENSE_WARNING + +# ifdef CGAL_LICENSE_ERROR +# error "The macro CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE is not defined.\ + You use the CGAL 3D Heat Method package under the terms of \ +the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +#endif // no CGAL_HEAT_METHOD_3_COMMERCIAL_LICENSE + +#endif // CGAL_LICENSE_CHECK_HEAT_METHOD_3_H