From d30b5c1a7f1df1e17997e2afe57961231d9d6d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 26 Oct 2022 10:58:38 +0200 Subject: [PATCH] Indentation fixes --- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 221 +++++++++--------- 1 file changed, 116 insertions(+), 105 deletions(-) diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index 17d9759018b..f582a74e979 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -29,11 +29,9 @@ #include #include +namespace CGAL { +namespace SMDS_3 { -namespace CGAL -{ -namespace SMDS_3 -{ template std::array make_ordered_vertex_array(const Vh vh0, const Vh vh1, const Vh vh2) { @@ -64,12 +62,12 @@ void build_vertices(Tr& tr, } } -template +template bool add_facet_to_incident_cells_map(const typename Tr::Cell_handle c, int i, - boost::unordered_map, - std::vector > >& incident_cells_map, - const bool verbose, - const bool allow_non_manifold) + boost::unordered_map, + std::vector > >& 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 +template bool build_finite_cells(Tr& tr, - const CellRange& finite_cells, - const SubdomainsRange& subdomains, - const std::vector& vertex_handle_vector, - boost::unordered_map, - std::vector > >& 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& vertex_handle_vector, + boost::unordered_map, + std::vector > >& 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; iset_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(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 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 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 bool add_infinite_facets_to_incident_cells_map(typename Tr::Cell_handle c, - int inf_vert_pos, - boost::unordered_map, - std::vector > >& incident_cells_map, - const bool verbose, - const bool allow_non_manifold) + int inf_vert_pos, + boost::unordered_map, + std::vector > >& 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(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(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(c, l, incident_cells_map, verbose, allow_non_manifold); + return b1 && b2 && b3; } template bool build_infinite_cells(Tr& tr, - boost::unordered_map, - std::vector > >& incident_cells_map, - const bool verbose, - const bool allow_non_manifold) + boost::unordered_map, + std::vector > >& 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 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(c, 0, incident_cells_map, verbose, allow_non_manifold)) success = false; + } return success; } @@ -350,9 +354,9 @@ bool has_infinite_vertex(const std::array& v, template bool assign_neighbors(Tr& tr, - const boost::unordered_map, - std::vector > >& incident_cells_map, - const bool allow_non_manifold) + const boost::unordered_map, + std::vector > >& incident_cells_map, + const bool allow_non_manifold) { typedef typename Tr::Cell_handle Cell_handle; typedef std::pair Incident_cell; @@ -389,17 +393,18 @@ template bool build_triangulation_impl(Tr& tr, - const PointRange& points, - const CellRange& finite_cells, - const std::vector& subdomains, - const FacetPatchMap& border_facets, - std::vector& 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& subdomains, + const FacetPatchMap& border_facets, + std::vector& 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 Facet_vvv; @@ -408,48 +413,49 @@ bool build_triangulation_impl(Tr& tr, typedef std::pair Incident_cell; typedef boost::unordered_map > 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."<(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, finite_cells, subdomains, vertex_handle_vector, incident_cells_map, - border_facets, verbose, replace_domain_0)) + if (!CGAL::SMDS_3::build_finite_cells(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, 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, 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 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& 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& vertex_handle_vector, + const bool verbose,// = false, + const bool replace_domain_0,// = false + const bool allow_non_manifold)// = false { std::vector subdomains(finite_cells.size(), subdomain); return build_triangulation_impl(tr, points, finite_cells, subdomains, @@ -493,13 +500,13 @@ template 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 subdomains(finite_cells.size(), subdomain); std::vector vertex_handle_vector; @@ -515,13 +522,13 @@ template 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 vertex_handle_vector; std::vector 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