| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2022 - 2024 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
#ifndef dealii_cgal_intersections_h |
| 16 |
#define dealii_cgal_intersections_h |
| 17 |
|
| 18 |
#include <deal.II/base/config.h> |
| 19 |
|
| 20 |
#include <deal.II/base/array_view.h> |
| 21 |
#include <deal.II/base/point.h> |
| 22 |
|
| 23 |
#include <deal.II/fe/mapping.h> |
| 24 |
|
| 25 |
#include <deal.II/grid/tria.h> |
| 26 |
|
| 27 |
|
| 28 |
DEAL_II_NAMESPACE_OPEN |
| 29 |
namespace CGALWrappers |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Given two deal.II affine cells, compute their intersection and return a |
| 33 |
* vector of simplices, each one identified by an array of deal.II Points. All |
| 34 |
* the simplices together are a subdivision of the intersection. If cells are |
| 35 |
* non-affine, a geometrical error is introduced. If the |
| 36 |
* measure of one of the simplices is below a certain threshold which defaults |
| 37 |
* to 1e-9, then it is discarded. In case the two cells are disjoint, an empty |
| 38 |
* array is returned. |
| 39 |
* |
| 40 |
* @note If the two cells have different intrinsic dimensions, than the |
| 41 |
* first iterator is assumed to have with higher intrinsic dimension. |
| 42 |
* The same holds for the two Mapping objects. |
| 43 |
* |
| 44 |
* |
| 45 |
* @param cell0 Iterator to the first cell. |
| 46 |
* @param cell1 Iterator to the second cell. |
| 47 |
* @param mapping0 Mapping for the first cell. |
| 48 |
* @param mapping1 Mapping for the second cell. |
| 49 |
* @param tol Threshold to decide whether or not a simplex is included. |
| 50 |
* @return Vector of arrays, where each array identify a simplex by its vertices. |
| 51 |
*/ |
| 52 |
template <int structdim0, int structdim1, int spacedim> |
| 53 |
std::vector<std::array<Point<spacedim>, structdim1 + 1>> |
| 54 |
compute_intersection_of_cells( |
| 55 |
const typename Triangulation<structdim0, spacedim>::cell_iterator &cell0, |
| 56 |
const typename Triangulation<structdim1, spacedim>::cell_iterator &cell1, |
| 57 |
const Mapping<structdim0, spacedim> &mapping0, |
| 58 |
const Mapping<structdim1, spacedim> &mapping1, |
| 59 |
const double tol = 1e-9); |
| 60 |
|
| 61 |
|
| 62 |
/** |
| 63 |
* Same function as above, but working directly with vertices. It's assumed |
| 64 |
* that the first vertices are coming from a Triangulation<dim0,spacedim>, |
| 65 |
* while the other vertices are from a Triangulation<dim1,spacedim>, with |
| 66 |
* @p dim0 > @p dim1. |
| 67 |
* |
| 68 |
* @note The vertices have to be given in CGAL order. |
| 69 |
*/ |
| 70 |
template <int structdim0, int structdim1, int spacedim> |
| 71 |
std::vector<std::array<Point<spacedim>, structdim1 + 1>> |
| 72 |
compute_intersection_of_cells( |
| 73 |
const ArrayView<const Point<spacedim>> &vertices0, |
| 74 |
const ArrayView<const Point<spacedim>> &vertices1, |
| 75 |
const double tol = 1e-9); |
| 76 |
|
| 77 |
} // namespace CGALWrappers |
| 78 |
|
| 79 |
DEAL_II_NAMESPACE_CLOSE |
| 80 |
|
| 81 |
#endif |