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 06ecf757765..4e3696aa74f 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 @@ -470,12 +470,10 @@ namespace Heat_method_3 { */ CGAL_precondition(is_triangle_mesh(tm)); - //vertex_id_map = get(Vertex_property_tag(),const_cast(tm)); Index i = 0; BOOST_FOREACH(vertex_descriptor vd, vertices(tm)){ put(vertex_id_map, vd, i++); } - //face_id_map = get(Face_property_tag(), const_cast(tm)); Index face_i = 0; BOOST_FOREACH(face_descriptor fd, faces(tm)){ put(face_id_map, fd, face_i++); diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Intrinsic_Delaunay_Triangulation_3.h b/Heat_method_3/include/CGAL/Heat_method_3/Intrinsic_Delaunay_Triangulation_3.h index 54228a27f82..fad53eb8f91 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/Intrinsic_Delaunay_Triangulation_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/Intrinsic_Delaunay_Triangulation_3.h @@ -73,6 +73,9 @@ namespace Intrinsic_Delaunay_Triangulation_3 { struct IDT_vertex_point_property_map; + template + struct IDT_vertex_distance_property_map; + /** * Class `Intrinsic_Delaunay_Triangulation_3` is a ... * \tparam TriangleMesh a triangulated surface mesh, model of `FaceGraph` and `HalfedgeListGraph` @@ -86,14 +89,14 @@ namespace Intrinsic_Delaunay_Triangulation_3 { template ::const_type, typename FaceIndexMap = typename boost::property_map< TriangleMesh, face_index_t>::const_type, typename EdgeIndexMap = typename boost::property_map< TriangleMesh, boost::edge_index_t>::const_type, typename LA = Intrinsic_Delaunay_Triangulation_Eigen_traits_3> struct Intrinsic_Delaunay_Triangulation_3 // AF was class fix later { - typedef Intrinsic_Delaunay_Triangulation_3 Self; + typedef Intrinsic_Delaunay_Triangulation_3 Self; typedef typename boost::graph_traits graph_traits; typedef typename graph_traits::vertex_descriptor vertex_descriptor; @@ -113,9 +116,12 @@ namespace Intrinsic_Delaunay_Triangulation_3 { typedef typename LA::Index Index; typedef typename boost::property_traits::reference VertexPointMap_reference; - + + typedef CGAL::dynamic_halfedge_property_t Halfedge_coordinate_tag; + typedef typename boost::property_map::type HalfedgeCoordinateMap; + typedef typename boost::graph_traits::vertices_size_type vertices_size_type; - typedef typename boost::graph_traits::edges_size_type edges_size_type; + typedef typename boost::graph_traits::edges_size_type edges_size_type; typedef typename boost::graph_traits::faces_size_type faces_size_type; typedef CGAL::dynamic_vertex_property_t Vertex_property_tag; @@ -132,8 +138,12 @@ namespace Intrinsic_Delaunay_Triangulation_3 { typedef typename std::stack > edge_stack; friend struct IDT_vertex_point_property_map; + friend struct IDT_vertex_distance_property_map; public: // for the BGL functions below. They should maybe become friend? + + typedef IDT_vertex_distance_property_map Vertex_distance_map; + struct Vertex_descriptor { halfedge_descriptor hd; @@ -145,6 +155,11 @@ namespace Intrinsic_Delaunay_Triangulation_3 { Vertex_descriptor(const halfedge_descriptor& hd) : hd(hd) {} + + explicit Vertex_descriptor(const vertex_descriptor vd, const TriangleMesh& tm) + : hd(halfedge(vd,tm)) + {} + }; struct Vertex_iterator_functor @@ -165,16 +180,16 @@ namespace Intrinsic_Delaunay_Triangulation_3 { }; public: - Intrinsic_Delaunay_Triangulation_3(TriangleMesh& tm, HalfedgeCoordinateMap hcm) - : tm(tm), hcm(hcm) + Intrinsic_Delaunay_Triangulation_3(TriangleMesh& tm, VertexDistanceMap vdm) + : tm(tm), vdm(*this,vdm), hcm(get(Halfedge_coordinate_tag(), tm)) { build(); } - Intrinsic_Delaunay_Triangulation_3(TriangleMesh& tm, HalfedgeCoordinateMap hcm, FaceIndexMap fpm, EdgeIndexMap epm) - : tm(tm), hcm(hcm), fpm(fpm), epm(epm) + Intrinsic_Delaunay_Triangulation_3(TriangleMesh& tm, VertexDistanceMap vdm, FaceIndexMap fpm, EdgeIndexMap epm) + : tm(tm), vdm(*this,vdm), fpm(fpm), epm(epm), hcm(get(Halfedge_coordinate_tag(), tm)) { build(); } @@ -192,10 +207,18 @@ namespace Intrinsic_Delaunay_Triangulation_3 { return tm; } + const HalfedgeCoordinateMap& hcmap() const { return hcm; } + + const Vertex_distance_map vertex_distance_map() const + { + return vdm; + } + + double get_cotan_weight(edge_descriptor ed) { @@ -402,6 +425,7 @@ namespace Intrinsic_Delaunay_Triangulation_3 { } //todo:: determine which can be const TriangleMesh& tm; + Vertex_distance_map vdm; VertexPointMap vpm; FaceIndexMap fpm; EdgeIndexMap epm; @@ -419,14 +443,14 @@ namespace boost { template -struct graph_traits > { +struct graph_traits > { - typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 Mesh; + typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 Mesh; typedef typename Mesh::Vertex_descriptor vertex_descriptor; typedef boost::transform_iterator< typename Mesh::Vertex_iterator_functor, @@ -450,59 +474,59 @@ namespace Intrinsic_Delaunay_Triangulation_3 { template typename boost::graph_traits::vertices_size_type -num_vertices(const Intrinsic_Delaunay_Triangulation_3& idt) +num_vertices(const Intrinsic_Delaunay_Triangulation_3& idt) { return num_vertices(idt.triangle_mesh()); } template typename boost::graph_traits::edges_size_type -num_edges(const Intrinsic_Delaunay_Triangulation_3& idt) +num_edges(const Intrinsic_Delaunay_Triangulation_3& idt) { return num_edges(idt.triangle_mesh()); } template typename boost::graph_traits::faces_size_type -num_faces(const Intrinsic_Delaunay_Triangulation_3& idt) +num_faces(const Intrinsic_Delaunay_Triangulation_3& idt) { return num_faces(idt.triangle_mesh()); } template -typename std::pair>::vertex_iterator, - typename boost::graph_traits>::vertex_iterator> -vertices(const Intrinsic_Delaunay_Triangulation_3& idt) +typename std::pair>::vertex_iterator, + typename boost::graph_traits>::vertex_iterator> +vertices(const Intrinsic_Delaunay_Triangulation_3& idt) { std::pair::vertex_iterator, typename boost::graph_traits::vertex_iterator> p = vertices(idt.triangle_mesh()); typedef typename boost::graph_traits::vertex_iterator vertex_iterator; - typedef Intrinsic_Delaunay_Triangulation_3::Vertex_iterator_functor Fct; + typedef typename Intrinsic_Delaunay_Triangulation_3::Vertex_iterator_functor Fct; Fct fct(idt.triangle_mesh()); return std::make_pair(boost::make_transform_iterator(p.first, fct), boost::make_transform_iterator(p.second,fct)); @@ -510,14 +534,14 @@ vertices(const Intrinsic_Delaunay_Triangulation_3& idt) template typename std::pair::halfedge_iterator, typename boost::graph_traits::halfedge_iterator> -halfedges(const Intrinsic_Delaunay_Triangulation_3& idt) +halfedges(const Intrinsic_Delaunay_Triangulation_3& idt) { return halfedges(idt.triangle_mesh()); } @@ -525,14 +549,14 @@ halfedges(const Intrinsic_Delaunay_Triangulation_3& idt template typename std::pair::edge_iterator, typename boost::graph_traits::edge_iterator> -edges(const Intrinsic_Delaunay_Triangulation_3& idt) +edges(const Intrinsic_Delaunay_Triangulation_3& idt) { return edges(idt.triangle_mesh()); } @@ -540,57 +564,57 @@ edges(const Intrinsic_Delaunay_Triangulation_3& idt) template typename std::pair::face_iterator, typename boost::graph_traits::face_iterator> -faces(const Intrinsic_Delaunay_Triangulation_3& idt) +faces(const Intrinsic_Delaunay_Triangulation_3& idt) { return faces(idt.triangle_mesh()); } template -typename boost::graph_traits >::vertex_descriptor -vertex(typename boost::graph_traits >::halfedge_descriptor hd, - const Intrinsic_Delaunay_Triangulation_3& ) +typename boost::graph_traits >::vertex_descriptor +vertex(typename boost::graph_traits >::halfedge_descriptor hd, + const Intrinsic_Delaunay_Triangulation_3& ) { - return boost::graph_traits >::vertex_descriptor(hd); + return boost::graph_traits >::vertex_descriptor(hd); } template -typename boost::graph_traits >::halfedge_descriptor -halfedge(typename boost::graph_traits >::face_descriptor fd, - const Intrinsic_Delaunay_Triangulation_3& idt) +typename boost::graph_traits >::halfedge_descriptor +halfedge(typename boost::graph_traits >::face_descriptor fd, + const Intrinsic_Delaunay_Triangulation_3& idt) { return halfedge(fd, idt.triangle_mesh()); } template -typename boost::graph_traits >::halfedge_descriptor -halfedge(typename boost::graph_traits >::edge_descriptor ed, - const Intrinsic_Delaunay_Triangulation_3& idt) +typename boost::graph_traits >::halfedge_descriptor +halfedge(typename boost::graph_traits >::edge_descriptor ed, + const Intrinsic_Delaunay_Triangulation_3& idt) { return halfedge(ed, idt.triangle_mesh()); } @@ -598,14 +622,14 @@ halfedge(typename boost::graph_traits -typename boost::graph_traits >::halfedge_descriptor -next(typename boost::graph_traits >::halfedge_descriptor hd, - const Intrinsic_Delaunay_Triangulation_3& idt) +typename boost::graph_traits >::halfedge_descriptor +next(typename boost::graph_traits >::halfedge_descriptor hd, + const Intrinsic_Delaunay_Triangulation_3& idt) { return next(hd, idt.triangle_mesh()); } @@ -613,32 +637,32 @@ next(typename boost::graph_traits -typename boost::graph_traits >::vertex_descriptor -source(typename boost::graph_traits >::halfedge_descriptor hd, - const Intrinsic_Delaunay_Triangulation_3& idt) +typename boost::graph_traits >::vertex_descriptor +source(typename boost::graph_traits >::halfedge_descriptor hd, + const Intrinsic_Delaunay_Triangulation_3& idt) { - typedef typename boost::graph_traits >::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits >::vertex_descriptor vertex_descriptor; return vertex_descriptor(opposite(hd, idt.triangle_mesh())); } template -typename boost::graph_traits >::vertex_descriptor -target(typename boost::graph_traits >::halfedge_descriptor hd, - const Intrinsic_Delaunay_Triangulation_3& idt) +typename boost::graph_traits >::vertex_descriptor +target(typename boost::graph_traits >::halfedge_descriptor hd, + const Intrinsic_Delaunay_Triangulation_3& idt) { - typedef typename boost::graph_traits >::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits >::vertex_descriptor vertex_descriptor; return vertex_descriptor(hd); } @@ -684,12 +708,48 @@ target(typename boost::graph_traits& pm, key_type vd) { - typename TM::vertex_descriptor tm_vd = target(vd.hd,pm.idt.triangle_mesh()); + typename boost::graph_traits::vertex_descriptor tm_vd = target(vd.hd,pm.idt.triangle_mesh()); return get(pm,tm_vd); } }; + + template + struct IDT_vertex_distance_property_map { + const IDT& idt; + PM pm; + + typedef typename IDT::Triangle_mesh TM; + typedef typename IDT::Vertex_descriptor key_type; + typedef double value_type; + typedef value_type reference; + + IDT_vertex_distance_property_map(const IDT& idt, + PM pm) + : idt(idt), pm(pm) + {} + + friend value_type get(const IDT_vertex_distance_property_map& idtpm, + key_type vd) + { + typename boost::graph_traits::vertex_descriptor tm_vd = target(vd.hd, idtpm.idt.triangle_mesh()); + + return get(idtpm.pm,tm_vd); + } + + friend void put(IDT_vertex_distance_property_map idtpm, + key_type vd, + value_type v) + { + typename boost::graph_traits::vertex_descriptor tm_vd = target(vd.hd, idtpm.idt.triangle_mesh()); + + // std::cout << "put " << typeid(pm).name() << std::endl; + + put(idtpm.pm, tm_vd, v); + } + }; + } // namespace Intrinsic_Delaunay_Triangulation_3 } // namespace CGAL @@ -697,58 +757,58 @@ namespace boost { template - struct property_map, + struct property_map, CGAL::vertex_point_t > { - typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; + typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; typedef CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_point_property_map type; typedef type const_type; }; template -CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_point_property_map > +CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_point_property_map > get(CGAL::vertex_point_t, - const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) + const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) { - return CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_point_property_map >(idt); + return CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_point_property_map >(idt); } ////// change to face_index template - struct property_map, + struct property_map, CGAL::face_index_t > { - typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; + typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; typedef typename property_map::type type; typedef typename property_map::const_type const_type; }; template typename property_map::type get(CGAL::face_index_t fi, - const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) + const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) { return get(fi, idt.triangle_mesh()); } @@ -758,16 +818,16 @@ get(CGAL::face_index_t fi, template typename property_map::type get(boost::vertex_index_t vi, - const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) + const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) { - return CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_index_property_map, VPM >(idt, get(vi, idt.triangle_mesh())); + return CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_vertex_index_property_map, VPM >(idt, get(vi, idt.triangle_mesh())); } } // boost @@ -820,15 +880,15 @@ namespace boost { template - struct property_map, + struct property_map, CGAL::dynamic_vertex_property_t
> { - typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; + typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; typedef CGAL::Intrinsic_Delaunay_Triangulation_3::IDT_dynamic_vertex_property_map >::type, typename boost::graph_traits::vertex_descriptor, @@ -846,17 +906,17 @@ namespace CGAL { namespace Intrinsic_Delaunay_Triangulation_3 { template -typename boost::property_map, CGAL::dynamic_vertex_property_t
>::const_type +typename boost::property_map, CGAL::dynamic_vertex_property_t
>::const_type get(CGAL::dynamic_vertex_property_t
dvp, - const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) + const CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) { - typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; + typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; typedef IDT_dynamic_vertex_property_map >::const_type, typename boost::graph_traits::vertex_descriptor, @@ -866,17 +926,17 @@ get(CGAL::dynamic_vertex_property_t
dvp, template -typename boost::property_map, CGAL::dynamic_vertex_property_t
>::type +typename boost::property_map, CGAL::dynamic_vertex_property_t
>::type get(CGAL::dynamic_vertex_property_t
dvp, - CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) + CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3& idt) { - typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; + typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 IDT; typedef IDT_dynamic_vertex_property_map >::type, typename boost::graph_traits::vertex_descriptor, diff --git a/Heat_method_3/test/Heat_method_3/heat_method_intrinsic_surface_mesh_test.cpp b/Heat_method_3/test/Heat_method_3/heat_method_intrinsic_surface_mesh_test.cpp index bbd0583d2d4..8416f954f5a 100644 --- a/Heat_method_3/test/Heat_method_3/heat_method_intrinsic_surface_mesh_test.cpp +++ b/Heat_method_3/test/Heat_method_3/heat_method_intrinsic_surface_mesh_test.cpp @@ -14,25 +14,22 @@ typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef Kernel::Point_2 Point_2; -typedef CGAL::Surface_mesh BaseMesh; -typedef CGAL::dynamic_halfedge_property_t Halfedge_coordinate_tag; -typedef boost::property_map::type Halfedge_coordinate_map; - -typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 Mesh; - +typedef CGAL::Surface_mesh Surface_mesh; typedef CGAL::dynamic_vertex_property_t Vertex_distance_tag; -typedef boost::property_map::type Vertex_distance_map; +typedef boost::property_map::type Vertex_distance_map; + +typedef CGAL::Intrinsic_Delaunay_Triangulation_3::Intrinsic_Delaunay_Triangulation_3 Idt; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef CGAL::Heat_method_3::Heat_method_3 Heat_method; +typedef CGAL::Heat_method_3::Heat_method_3 Heat_method; typedef CGAL::Heat_method_3::Heat_method_Eigen_traits_3::SparseMatrix SparseMatrix; #if 0 -void source_set_tests(Heat_method hm, const Mesh& sm) +void source_set_tests(Heat_method hm, const Idt& sm) { vertex_descriptor source = *(vertices(sm).first); hm.add_source(source); @@ -98,7 +95,7 @@ void check_for_unit(const Eigen::MatrixXd& X, int dimension) } } -void check_no_update(const Mesh& sm, const Vertex_distance_map& original, const Vertex_distance_map& updated) +void check_no_update(const Idt& sm, const Vertex_distance_map& original, const Vertex_distance_map& updated) { BOOST_FOREACH(vertex_descriptor vd, vertices(sm)) { @@ -111,30 +108,36 @@ void check_no_update(const Mesh& sm, const Vertex_distance_map& original, const int main() { - BaseMesh bm; - Halfedge_coordinate_map hcm; - Mesh sm(bm,hcm); + Surface_mesh sm; + Vertex_distance_map vdm = get(Vertex_distance_tag(),sm); + + Idt idt(sm, vdm); + - Vertex_distance_map vertex_distance_map = get(Vertex_distance_tag(),sm); bool idf = false; std::ifstream in("data/pyramid0.off"); - in >> bm; - if(!in || num_vertices(bm) == 0) { + in >> sm; + if(!in || num_vertices(sm) == 0) { std::cerr << "Problem loading the input data" << std::endl; return 1; } - put(vertex_distance_map, * vertices(sm).first, 1.0); - put(vertex_distance_map, * halfedges(sm).first, 1.0); - + //put(vdm, * vertices(sm).first, 1.0); + //put(vdm, * halfedges(sm).first, 1.0); + //source set tests - Heat_method hm(sm, vertex_distance_map); - hm.add_source(* vertices(sm).first); + Heat_method hm(idt, idt.vertex_distance_map()); + // hm.add_source(* vertices(idt).first); + + hm.add_source(boost::graph_traits::vertex_descriptor(boost::graph_traits::vertex_descriptor(0),sm)); hm.update(); -#if 0 - source_set_tests(hm,sm); +#if 0 + + + + source_set_tests(hm,idt); //cotan matrix tests const SparseMatrix& M = hm.mass_matrix(); //std::cout<<"and M is: "<< Eigen::MatrixXd(M) << "\n";