Add a constructor and two functions to get started

This commit is contained in:
Andreas Fabri 2018-05-24 14:35:35 +01:00
parent 4accc67abb
commit dd8bf1f4df
4 changed files with 166 additions and 4 deletions

View File

@ -1,5 +1,7 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Heat_method_3/Heat_method_3.h>
#include <iostream>
#include <fstream>
@ -7,11 +9,23 @@
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef CGAL::Heat_method_3::Heat_method_3<Mesh,Kernel> Heat_method;
typedef boost::graph_traits<Mesh>::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;
}

View File

@ -25,21 +25,64 @@
#include <CGAL/license/Heat_method_3.h>
#include <CGAL/disable_warnings.h>
#include <set>
#include <Eigen/Cholesky>
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<TriangleMesh>::%vertex_descriptor` as key and
* `Traits::Point_3` as value type.
* The default is `typename boost::property_map< TriangleMesh, vertex_point_t>::%type`.
*
*/
template <typename HMTraits>
template <typename TriangleMesh,
typename Traits,
typename VertexPointMap = typename boost::property_map< TriangleMesh, vertex_point_t>::type>
class Heat_method_3
{
/// Polygon_mesh typedefs
typedef typename boost::graph_traits<TriangleMesh> 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<vertex_descriptor> sources;
};
} // namespace Heat_method_3

View File

@ -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;
};

View File

@ -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 <CGAL/config.h>
#include <CGAL/license.h>
#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