mirror of https://github.com/CGAL/cgal
Merge pull request #4960 from maxGimeno/Demo-C3t3_can_read_mesh_with_domain_0-maxGimeno
Polyhedron Demo: .mesh reading enhancement
This commit is contained in:
commit
113048faef
|
|
@ -24,8 +24,12 @@ class Mesh_complex_3_in_triangulation_3;
|
|||
|
||||
template<class Tr, bool c3t3_loader_failed>
|
||||
bool build_triangulation_from_file(std::istream& is,
|
||||
Tr& tr);
|
||||
Tr& tr,
|
||||
bool replace_domain_0);
|
||||
|
||||
template<class Tr, bool c3t3_loader_failed>
|
||||
bool build_triangulation_from_file(std::istream& is,
|
||||
Tr& tr);
|
||||
} // CGAL
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ bool build_finite_cells(Tr& tr,
|
|||
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
|
||||
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
|
||||
const std::map<std::array<int,3>, typename Tr::Cell::Surface_patch_index>& border_facets,
|
||||
const bool verbose)
|
||||
const bool verbose,
|
||||
bool replace_domain_0 = false)
|
||||
{
|
||||
typedef std::array<int, 5> 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<finite_cells.size(); ++i)
|
||||
{
|
||||
const Tet_with_ref& tet = finite_cells[i];
|
||||
if(tet[4] > max_domain)
|
||||
max_domain=tet[4];
|
||||
}
|
||||
}
|
||||
// build the finite cells
|
||||
for(std::size_t i=0; i<finite_cells.size(); ++i)
|
||||
{
|
||||
|
|
@ -141,7 +151,10 @@ bool build_finite_cells(Tr& tr,
|
|||
|
||||
Cell_handle c = tr.tds().create_cell(vs[0], vs[1], vs[2], vs[3]);
|
||||
c->set_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<std::array<int,5> >& finite_cells,
|
||||
const std::map<std::array<int,3>, typename Tr::Cell::Surface_patch_index>& border_facets,
|
||||
std::vector<typename Tr::Vertex_handle>& 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>(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>(tr, incident_cells_map, verbose))
|
||||
return false;
|
||||
|
|
@ -384,7 +398,8 @@ bool build_triangulation(Tr& tr,
|
|||
|
||||
template<class Tr, bool c3t3_loader_failed>
|
||||
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<typename Tr::Vertex_handle> vertices(points.size() + 1);
|
||||
bool is_well_built = build_triangulation<Tr, c3t3_loader_failed>(tr,
|
||||
points, finite_cells, border_facets, vertices);
|
||||
points, finite_cells, border_facets, vertices, false, replace_domain_0);
|
||||
return is_well_built;
|
||||
}
|
||||
|
||||
template<class Tr, bool c3t3_loader_failed>
|
||||
bool build_triangulation_from_file(std::istream& is,
|
||||
Tr& tr)
|
||||
{
|
||||
return build_triangulation_from_file<Tr, c3t3_loader_failed>(is, tr, false);
|
||||
}
|
||||
} // namespace CGAL
|
||||
|
||||
#include <CGAL/enable_warnings.h>
|
||||
|
|
|
|||
|
|
@ -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<C3t3::Triangulation, true>(in, item->c3t3().triangulation()))
|
||||
if(CGAL::build_triangulation_from_file<C3t3::Triangulation, true>(in, item->c3t3().triangulation(), true))
|
||||
{
|
||||
item->c3t3().rescan_after_load_of_triangulation();
|
||||
for( C3t3::Triangulation::Finite_cells_iterator
|
||||
|
|
|
|||
Loading…
Reference in New Issue