diff --git a/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h index 2f4705e66d0..d0202553abc 100644 --- a/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -24,8 +24,12 @@ class Mesh_complex_3_in_triangulation_3; template bool build_triangulation_from_file(std::istream& is, - Tr& tr); + Tr& tr, + bool replace_domain_0); +template +bool build_triangulation_from_file(std::istream& is, + Tr& tr); } // CGAL #endif diff --git a/Mesh_3/include/CGAL/Mesh_3/tet_soup_to_c3t3.h b/Mesh_3/include/CGAL/Mesh_3/tet_soup_to_c3t3.h index e7e8c6d87f3..677d37124fa 100644 --- a/Mesh_3/include/CGAL/Mesh_3/tet_soup_to_c3t3.h +++ b/Mesh_3/include/CGAL/Mesh_3/tet_soup_to_c3t3.h @@ -106,7 +106,8 @@ bool build_finite_cells(Tr& tr, boost::unordered_map, std::vector > >& incident_cells_map, const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, - const bool verbose) + const bool verbose, + bool replace_domain_0 = false) { typedef std::array Tet_with_ref; // 4 ids + 1 reference @@ -118,7 +119,16 @@ bool build_finite_cells(Tr& tr, typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); ) - + int max_domain = 0; + if(replace_domain_0) + { + for(std::size_t i=0; i max_domain) + max_domain=tet[4]; + } + } // build the finite cells for(std::size_t i=0; iset_subdomain_index(tet[4]); // the cell's info keeps the reference of the tetrahedron - + if(replace_domain_0 && tet[4] == 0) + { + c->set_subdomain_index(max_domain+1); // the cell's info keeps the reference of the tetrahedron + } // assign cells to vertices for(int j=0; j<4; ++j) { @@ -328,7 +341,8 @@ bool build_triangulation(Tr& tr, const std::vector >& finite_cells, const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, std::vector& vertex_handle_vector, - const bool verbose = false) + const bool verbose = false, + bool replace_domain_0 = false) { typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -360,7 +374,7 @@ bool build_triangulation(Tr& tr, if (!finite_cells.empty()) { if(!build_finite_cells(tr, finite_cells, vertex_handle_vector, incident_cells_map, - border_facets, verbose)) + border_facets, verbose, replace_domain_0)) return false; if(!build_infinite_cells(tr, incident_cells_map, verbose)) return false; @@ -384,7 +398,8 @@ bool build_triangulation(Tr& tr, template bool build_triangulation_from_file(std::istream& is, - Tr& tr) + Tr& tr, + bool replace_domain_0) { typedef typename Tr::Point Point_3; @@ -473,10 +488,16 @@ bool build_triangulation_from_file(std::istream& is, std::vector vertices(points.size() + 1); bool is_well_built = build_triangulation(tr, - points, finite_cells, border_facets, vertices); + points, finite_cells, border_facets, vertices, false, replace_domain_0); return is_well_built; } +template +bool build_triangulation_from_file(std::istream& is, + Tr& tr) +{ + return build_triangulation_from_file(is, tr, false); +} } // namespace CGAL #include diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 95bf0246fe6..4dfab1afc69 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -127,7 +127,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( item->setName(fileinfo.baseName()); item->set_valid(false); - if(CGAL::build_triangulation_from_file(in, item->c3t3().triangulation())) + if(CGAL::build_triangulation_from_file(in, item->c3t3().triangulation(), true)) { item->c3t3().rescan_after_load_of_triangulation(); for( C3t3::Triangulation::Finite_cells_iterator