Indentation fixes

This commit is contained in:
Mael Rouxel-Labbé 2022-10-26 10:58:38 +02:00
parent bd52dc631a
commit d30b5c1a7f
1 changed files with 116 additions and 105 deletions

View File

@ -29,11 +29,9 @@
#include <map>
#include <boost/unordered_map.hpp>
namespace CGAL {
namespace SMDS_3 {
namespace CGAL
{
namespace SMDS_3
{
template<typename Vh>
std::array<Vh, 3> make_ordered_vertex_array(const Vh vh0, const Vh vh1, const Vh vh2)
{
@ -64,12 +62,12 @@ void build_vertices(Tr& tr,
}
}
template<class Tr>
template <class Tr>
bool add_facet_to_incident_cells_map(const typename Tr::Cell_handle c, int i,
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool verbose,
const bool allow_non_manifold)
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool verbose,
const bool allow_non_manifold)
{
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Cell_handle Cell_handle;
@ -81,8 +79,8 @@ bool add_facet_to_incident_cells_map(const typename Tr::Cell_handle c, int i,
// the opposite vertex of f in c is i
Facet_vvv f = CGAL::SMDS_3::make_ordered_vertex_array(c->vertex((i + 1) % 4),
c->vertex((i + 2) % 4),
c->vertex((i + 3) % 4));
c->vertex((i + 2) % 4),
c->vertex((i + 3) % 4));
CGAL_precondition(f[0] != f[1] && f[1] != f[2]);
Incident_cell e = std::make_pair(c, i);
@ -105,16 +103,16 @@ bool add_facet_to_incident_cells_map(const typename Tr::Cell_handle c, int i,
return success;
}
template<class Tr, typename CellRange, typename SubdomainsRange, typename FacetPatchMap>
template <class Tr, typename CellRange, typename SubdomainsRange, typename FacetPatchMap>
bool build_finite_cells(Tr& tr,
const CellRange& finite_cells,
const SubdomainsRange& subdomains,
const std::vector<typename Tr::Vertex_handle>& vertex_handle_vector,
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const FacetPatchMap& border_facets,
const bool verbose,
const bool replace_domain_0)
const CellRange& finite_cells,
const SubdomainsRange& subdomains,
const std::vector<typename Tr::Vertex_handle>& vertex_handle_vector,
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const FacetPatchMap& border_facets,
const bool verbose,
const bool replace_domain_0)
{
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Cell_handle Cell_handle;
@ -123,11 +121,10 @@ bool build_finite_cells(Tr& tr,
bool success = true;
CGAL_assertion_code(
typename Tr::Geom_traits::Construct_point_3 cp =
tr.geom_traits().construct_point_3_object();
typename Tr::Geom_traits::Orientation_3 orientation =
tr.geom_traits().orientation_3_object();
typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object();
typename Tr::Geom_traits::Orientation_3 orientation = tr.geom_traits().orientation_3_object();
)
typename SubdomainsRange::value_type max_domain = 0;
if(replace_domain_0)
{
@ -137,6 +134,7 @@ bool build_finite_cells(Tr& tr,
max_domain = subdomains[i];
}
}
// build the finite cells
for(std::size_t i=0; i<finite_cells.size(); ++i)
{
@ -154,15 +152,12 @@ bool build_finite_cells(Tr& tr,
// this assertion also tests for degeneracy
CGAL_assertion(orientation(cp(tr.point(vs[0])), cp(tr.point(vs[1])),
cp(tr.point(vs[2])), cp(tr.point(vs[3])))
== POSITIVE);
cp(tr.point(vs[2])), cp(tr.point(vs[3]))) == POSITIVE);
Cell_handle c = tr.tds().create_cell(vs[0], vs[1], vs[2], vs[3]);
c->set_subdomain_index(subdomains[i]); // the cell's info keeps the reference of the tetrahedron
if(replace_domain_0 && subdomains[i] == 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)
@ -174,18 +169,20 @@ bool build_finite_cells(Tr& tr,
// build the map used for adjacency later
for(int j=0; j<4; ++j)
{
// do not allow non-manifold in the finite cells case
if(!CGAL::SMDS_3::add_facet_to_incident_cells_map<Tr>(c, j, incident_cells_map, verbose, false))
//do not allow non-manifold in the finite cells case
success = false;
if(border_facets.size() != 0)
{
std::array<int,3> facet;
facet[0]=tet[(j+1) % 4];
facet[1]=tet[(j+2) % 4];
facet[2]=tet[(j+3) % 4];
//find the circular permutation that puts the smallest index in the first place.
facet[0] = tet[(j+1) % 4];
facet[1] = tet[(j+2) % 4];
facet[2] = tet[(j+3) % 4];
// find the circular permutation that puts the smallest index in the first place.
int n0 = (std::min)((std::min)(facet[0], facet[1]), facet[2]);
int k=0;
int k = 0;
std::array<int,3> f;
do
{
@ -193,7 +190,8 @@ bool build_finite_cells(Tr& tr,
f[1]=facet[(1+k)%3];
f[2]=facet[(2+k)%3];
++k;
} while(f[0] != n0);
}
while(f[0] != n0);
typename FacetPatchMap::const_iterator it = border_facets.find(f);
if(it != border_facets.end())
@ -215,16 +213,17 @@ bool build_finite_cells(Tr& tr,
}
}
}
return success;
}
template<class Tr>
bool add_infinite_facets_to_incident_cells_map(typename Tr::Cell_handle c,
int inf_vert_pos,
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool verbose,
const bool allow_non_manifold)
int inf_vert_pos,
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool verbose,
const bool allow_non_manifold)
{
int l = (inf_vert_pos + 1) % 4;
bool b1 = CGAL::SMDS_3::add_facet_to_incident_cells_map<Tr>(c, l, incident_cells_map, verbose, allow_non_manifold);
@ -232,15 +231,16 @@ bool add_infinite_facets_to_incident_cells_map(typename Tr::Cell_handle c,
bool b2 = CGAL::SMDS_3::add_facet_to_incident_cells_map<Tr>(c, l, incident_cells_map, verbose, allow_non_manifold);
l = (inf_vert_pos + 3) % 4;
bool b3 = CGAL::SMDS_3::add_facet_to_incident_cells_map<Tr>(c, l, incident_cells_map, verbose, allow_non_manifold);
return b1 && b2 && b3;
}
template<class Tr>
bool build_infinite_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 bool verbose,
const bool allow_non_manifold)
boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool verbose,
const bool allow_non_manifold)
{
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Cell_handle Cell_handle;
@ -260,13 +260,14 @@ bool build_infinite_cells(Tr& tr,
{
if(it->second.size() == 2) // facet already has both its incident cells
continue;
CGAL_assertion(it->second.size() == 1);
Cell_handle c = it->second[0].first;
int i = it->second[0].second;
Cell_handle opp_c;
// the infinite cell that we are creating needs to be well oriented...
Cell_handle opp_c;
if(i == 0 || i == 2)
opp_c = tr.tds().create_cell(tr.infinite_vertex(),
c->vertex((i + 2) % 4),
@ -301,14 +302,15 @@ bool build_infinite_cells(Tr& tr,
for (int i = 1; i < 4; ++i)
{
std::array<Vertex_handle, 3> vs = CGAL::SMDS_3::make_ordered_vertex_array(c->vertex((i + 1) % 4),
c->vertex((i + 2) % 4),
c->vertex((i + 3) % 4));
c->vertex((i + 2) % 4),
c->vertex((i + 3) % 4));
if (facets.find(vs) == facets.end())
facets.insert(std::make_pair(vs, 1));
else
facets[vs]++;
}
}
for (auto fp : facets)
{
if (fp.second != 2)
@ -326,12 +328,14 @@ bool build_infinite_cells(Tr& tr,
// add the facets to the incident cells map
for (const Cell_handle& c : infinite_cells)
{
if(!CGAL::SMDS_3::add_infinite_facets_to_incident_cells_map<Tr>(c,
0,
incident_cells_map,
verbose,
allow_non_manifold))
success = false;
}
return success;
}
@ -350,9 +354,9 @@ bool has_infinite_vertex(const std::array<typename Tr::Vertex_handle, 3>& v,
template<class Tr>
bool assign_neighbors(Tr& tr,
const boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool allow_non_manifold)
const boost::unordered_map<std::array<typename Tr::Vertex_handle, 3>,
std::vector<std::pair<typename Tr::Cell_handle, int> > >& incident_cells_map,
const bool allow_non_manifold)
{
typedef typename Tr::Cell_handle Cell_handle;
typedef std::pair<Cell_handle, int> Incident_cell;
@ -389,17 +393,18 @@ template<class Tr,
typename CellRange,
typename FacetPatchMap>
bool build_triangulation_impl(Tr& tr,
const PointRange& points,
const CellRange& finite_cells,
const std::vector<typename Tr::Cell::Subdomain_index>& subdomains,
const FacetPatchMap& border_facets,
std::vector<typename Tr::Vertex_handle>& vertex_handle_vector,
const bool verbose,// = false,
const bool replace_domain_0,// = false,
const bool allow_non_manifold) // = false
const PointRange& points,
const CellRange& finite_cells,
const std::vector<typename Tr::Cell::Subdomain_index>& subdomains,
const FacetPatchMap& border_facets,
std::vector<typename Tr::Vertex_handle>& vertex_handle_vector,
const bool verbose,// = false,
const bool replace_domain_0,// = false,
const bool allow_non_manifold) // = false
{
if (verbose)
std::cout << "build_triangulation_impl()..." << std::endl;
typedef typename Tr::Vertex_handle Vertex_handle;
typedef typename Tr::Cell_handle Cell_handle;
typedef std::array<Vertex_handle, 3> Facet_vvv;
@ -408,48 +413,49 @@ bool build_triangulation_impl(Tr& tr,
typedef std::pair<Cell_handle, int> Incident_cell;
typedef boost::unordered_map<Facet_vvv, std::vector<Incident_cell> > Incident_cells_map;
bool success = true;
Incident_cells_map incident_cells_map;
vertex_handle_vector.resize(points.size() + 1); // id to vertex_handle
//index 0 is for infinite vertex
// 1 to n for points in `points`
CGAL_precondition(!points.empty());
if(finite_cells.empty())
{
std::cout << "WARNING: No finite cells were provided. Only the points will be loaded."<<std::endl;
}
bool success = true;
Incident_cells_map incident_cells_map;
tr.tds().clear(); // not tr.clear() since it calls tr.init() which we don't want
// id to vertex_handle
// index 0 is for infinite vertex; 1 to n for points in `points`
vertex_handle_vector.resize(points.size() + 1);
if(finite_cells.empty())
std::cout << "WARNING: No finite cells were provided. Only the points will be loaded." << std::endl;
tr.tds().clear(); // not tr.clear() since it calls tr.init(), which we don't want
build_vertices<Tr>(tr, points, vertex_handle_vector);
for(Vertex_handle vh : vertex_handle_vector)
{
vh->set_dimension(-1);
}
if (!finite_cells.empty())
{
if (!CGAL::SMDS_3::build_finite_cells<Tr>(tr, finite_cells, subdomains, vertex_handle_vector, incident_cells_map,
border_facets, verbose, replace_domain_0))
if (!CGAL::SMDS_3::build_finite_cells<Tr>(tr, finite_cells, subdomains, vertex_handle_vector,
incident_cells_map, border_facets, verbose, replace_domain_0))
{
if (verbose) std::cout << "build_finite_cells went wrong" << std::endl;
if (verbose)
std::cout << "build_finite_cells went wrong" << std::endl;
success = false;
}
else
std::cout << "build finite cells done" << std::endl;
if (!CGAL::SMDS_3::build_infinite_cells<Tr>(tr, incident_cells_map, verbose, allow_non_manifold))
{
if(verbose) std::cout << "build_infinite_cells went wrong" << std::endl;
if(verbose)
std::cout << "build_infinite_cells went wrong" << std::endl;
success = false;
}
else
std::cout << "build infinite cells done" << std::endl;
tr.tds().set_dimension(3);
if (!CGAL::SMDS_3::assign_neighbors<Tr>(tr, incident_cells_map, allow_non_manifold))
{
if(verbose) std::cout << "assign_neighbors went wrong" << std::endl;
if(verbose)
std::cout << "assign_neighbors went wrong" << std::endl;
success = false;
}
else
@ -460,6 +466,7 @@ bool build_triangulation_impl(Tr& tr,
std::cout << tr.number_of_cells() << " cells" << std::endl;
}
}
if(verbose)
std::cout << tr.number_of_vertices() << " vertices" << std::endl;
@ -472,14 +479,14 @@ template<class Tr,
typename CellRange,
typename FacetPatchMap>
bool build_triangulation_one_subdomain(Tr& tr,
const PointRange& points,
const CellRange& finite_cells,
const typename Tr::Cell::Subdomain_index& subdomain,
const FacetPatchMap& border_facets,
std::vector<typename Tr::Vertex_handle>& vertex_handle_vector,
const bool verbose,// = false,
const bool replace_domain_0,// = false
const bool allow_non_manifold)// = false
const PointRange& points,
const CellRange& finite_cells,
const typename Tr::Cell::Subdomain_index& subdomain,
const FacetPatchMap& border_facets,
std::vector<typename Tr::Vertex_handle>& vertex_handle_vector,
const bool verbose,// = false,
const bool replace_domain_0,// = false
const bool allow_non_manifold)// = false
{
std::vector<typename Tr::Cell::Subdomain_index> subdomains(finite_cells.size(), subdomain);
return build_triangulation_impl(tr, points, finite_cells, subdomains,
@ -493,13 +500,13 @@ template<class Tr,
typename CellRange,
typename FacetPatchMap>
bool build_triangulation_one_subdomain(Tr& tr,
const PointRange& points,
const CellRange& finite_cells,
const typename Tr::Cell::Subdomain_index& subdomain,
const FacetPatchMap& border_facets,
const bool verbose,// = false,
const bool replace_domain_0,// = false
const bool allow_non_manifold)//= false
const PointRange& points,
const CellRange& finite_cells,
const typename Tr::Cell::Subdomain_index& subdomain,
const FacetPatchMap& border_facets,
const bool verbose,// = false,
const bool replace_domain_0,// = false
const bool allow_non_manifold)//= false
{
std::vector<typename Tr::Cell::Subdomain_index> subdomains(finite_cells.size(), subdomain);
std::vector<typename Tr::Vertex_handle> vertex_handle_vector;
@ -515,13 +522,13 @@ template<class Tr,
typename SubdomainsRange,
typename FacetPatchMap>
bool build_triangulation_with_subdomains_range(Tr& tr,
const PointRange& points,
const CellRange& finite_cells,
const SubdomainsRange& subdomains,
const FacetPatchMap& border_facets,
const bool verbose,// = false
const bool replace_domain_0,// = false,
const bool allow_non_manifold)
const PointRange& points,
const CellRange& finite_cells,
const SubdomainsRange& subdomains,
const FacetPatchMap& border_facets,
const bool verbose,// = false
const bool replace_domain_0,// = false,
const bool allow_non_manifold)
{
std::vector<typename Tr::Vertex_handle> vertex_handle_vector;
std::vector<typename Tr::Cell::Subdomain_index> subdomains_vector(
@ -571,7 +578,9 @@ bool build_triangulation_from_file(std::istream& is,
{
is >> word;
if (word == "End")
{
break;
}
else if (word == "CGAL::Mesh_complex_3_in_triangulation_3")
{
dont_replace_domain_0 = true;//with CGAL meshes, domain 0 should be kept
@ -579,6 +588,7 @@ bool build_triangulation_from_file(std::istream& is,
}
//else skip other comments
}
if(word == "Vertices")
{
is >> nv;
@ -644,17 +654,18 @@ bool build_triangulation_from_file(std::istream& is,
if(finite_cells.empty())
return false;
CGAL_assertion(finite_cells.size() == subdomains.size());
return build_triangulation_with_subdomains_range(tr,
points, finite_cells, subdomains, border_facets,
verbose,
replace_domain_0 && !dont_replace_domain_0,
allow_non_manifold);
points, finite_cells, subdomains, border_facets,
verbose,
replace_domain_0 && !is_CGAL_mesh,
allow_non_manifold);
}
} // namespace SMDS_3
} // namespace CGAL
} // namespace SMDS_3
} // namespace CGAL
#include <CGAL/enable_warnings.h>