-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CGAL::Surface_mesh support #13653
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
684ffe8
Added CGALWrappers::to_cgal_mesh()
fdrmrc 54d50ef
Address some comments
fdrmrc 0180620
Get ref_cells by reference
fdrmrc 222c472
Code review.
luca-heltai aafc7e0
Renamed function. Added boost header.
luca-heltai 6945366
Trying to fix FindCGAL.
luca-heltai 926318c
Make sure we use recent versions of CGAL.
luca-heltai File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
160 changes: 160 additions & 0 deletions
160
bundled/boost-1.70.0/include/boost/thread/detail/thread_safety.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#ifndef BOOST_THREAD_DETAIL_THREAD_SAFETY_HPP | ||
#define BOOST_THREAD_DETAIL_THREAD_SAFETY_HPP | ||
|
||
#if defined(__GNUC__) && !defined(__GXX_EXPERIMENTAL_CXX0X__) | ||
// | ||
// This is horrible, but it seems to be the only we can shut up the | ||
// "anonymous variadic macros were introduced in C99 [-Wvariadic-macros]" | ||
// warning that get spewed out otherwise in non-C++11 mode. | ||
// | ||
#pragma GCC system_header | ||
#endif | ||
|
||
// See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html | ||
|
||
// Un-comment to enable Thread Safety Analysis | ||
//#define BOOST_THREAD_ENABLE_THREAD_SAFETY_ANALYSIS | ||
|
||
// Enable thread safety attributes only with clang. | ||
// The attributes can be safely erased when compiling with other compilers. | ||
#if defined (BOOST_THREAD_ENABLE_THREAD_SAFETY_ANALYSIS) && defined(__clang__) && (!defined(SWIG)) | ||
#define BOOST_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) | ||
#else | ||
#define BOOST_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op | ||
#endif | ||
|
||
#define BOOST_THREAD_CAPABILITY(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) | ||
|
||
#define BOOST_THREAD_SCOPED_CAPABILITY \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) | ||
|
||
#define BOOST_THREAD_GUARDED_BY(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) | ||
|
||
#define BOOST_THREAD_PT_GUARDED_BY(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) | ||
|
||
#define BOOST_THREAD_ACQUIRED_BEFORE(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_ACQUIRED_AFTER(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_REQUIRES(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_REQUIRES_SHARED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_ACQUIRE(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_ACQUIRE_SHARED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_RELEASE(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_RELEASE_SHARED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_TRY_ACQUIRE(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_TRY_ACQUIRE_SHARED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_EXCLUDES(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) | ||
|
||
#define BOOST_THREAD_ASSERT_CAPABILITY(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) | ||
|
||
#define BOOST_THREAD_ASSERT_SHARED_CAPABILITY(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) | ||
|
||
#define BOOST_THREAD_RETURN_CAPABILITY(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) | ||
|
||
#define BOOST_THREAD_NO_THREAD_SAFETY_ANALYSIS \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) | ||
|
||
#if defined(__clang__) && (!defined(SWIG)) && defined(__FreeBSD__) | ||
#if __has_attribute(no_thread_safety_analysis) | ||
#define BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) | ||
#else | ||
#define BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS | ||
#endif | ||
#else | ||
#define BOOST_THREAD_DISABLE_THREAD_SAFETY_ANALYSIS | ||
#endif | ||
|
||
#ifdef USE_LOCK_STYLE_THREAD_SAFETY_ATTRIBUTES | ||
// The original version of thread safety analysis the following attribute | ||
// definitions. These use a lock-based terminology. They are still in use | ||
// by existing thread safety code, and will continue to be supported. | ||
|
||
// Deprecated. | ||
#define BOOST_THREAD_PT_GUARDED_VAR \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) | ||
|
||
// Deprecated. | ||
#define BOOST_THREAD_GUARDED_VAR \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) | ||
|
||
// Replaced by REQUIRES | ||
#define BOOST_THREAD_EXCLUSIVE_LOCKS_REQUIRED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) | ||
|
||
// Replaced by REQUIRES_SHARED | ||
#define BOOST_THREAD_SHARED_LOCKS_REQUIRED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) | ||
|
||
// Replaced by CAPABILITY | ||
#define BOOST_THREAD_LOCKABLE \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(lockable) | ||
|
||
// Replaced by SCOPED_CAPABILITY | ||
#define BOOST_THREAD_SCOPED_LOCKABLE \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) | ||
|
||
// Replaced by ACQUIRE | ||
#define BOOST_THREAD_EXCLUSIVE_LOCK_FUNCTION(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) | ||
|
||
// Replaced by ACQUIRE_SHARED | ||
#define BOOST_THREAD_SHARED_LOCK_FUNCTION(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) | ||
|
||
// Replaced by RELEASE and RELEASE_SHARED | ||
#define BOOST_THREAD_UNLOCK_FUNCTION(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) | ||
|
||
// Replaced by TRY_ACQUIRE | ||
#define BOOST_THREAD_EXCLUSIVE_TRYLOCK_FUNCTION(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) | ||
|
||
// Replaced by TRY_ACQUIRE_SHARED | ||
#define BOOST_THREAD_SHARED_TRYLOCK_FUNCTION(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) | ||
|
||
// Replaced by ASSERT_CAPABILITY | ||
#define BOOST_THREAD_ASSERT_EXCLUSIVE_LOCK(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(assert_exclusive_lock(__VA_ARGS__)) | ||
|
||
// Replaced by ASSERT_SHARED_CAPABILITY | ||
#define BOOST_THREAD_ASSERT_SHARED_LOCK(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_lock(__VA_ARGS__)) | ||
|
||
// Replaced by EXCLUDE_CAPABILITY. | ||
#define BOOST_THREAD_LOCKS_EXCLUDED(...) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) | ||
|
||
// Replaced by RETURN_CAPABILITY | ||
#define BOOST_THREAD_LOCK_RETURNED(x) \ | ||
BOOST_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) | ||
|
||
#endif // USE_LOCK_STYLE_THREAD_SAFETY_ATTRIBUTES | ||
|
||
#endif // BOOST_THREAD_DETAIL_THREAD_SAFETY_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2022 by the deal.II authors | ||
// | ||
// This file is part of the deal.II library. | ||
// | ||
// The deal.II library is free software; you can use it, redistribute | ||
// it, and/or modify it under the terms of the GNU Lesser General | ||
// Public License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// The full text of the license can be found in the file LICENSE.md at | ||
// the top level directory of deal.II. | ||
// | ||
// --------------------------------------------------------------------- | ||
|
||
#ifndef dealii_cgal_surface_mesh_h | ||
#define dealii_cgal_surface_mesh_h | ||
|
||
#include <deal.II/base/config.h> | ||
|
||
#include <deal.II/fe/mapping.h> | ||
|
||
#include <deal.II/grid/tria.h> | ||
|
||
#include <deal.II/cgal/utilities.h> | ||
|
||
#ifdef DEAL_II_WITH_CGAL | ||
# include <CGAL/Surface_mesh.h> | ||
|
||
DEAL_II_NAMESPACE_OPEN | ||
|
||
namespace CGALWrappers | ||
{ | ||
/** | ||
* Build a CGAL::Surface_mesh from a deal.II cell. | ||
* | ||
* The class Surface_mesh implements a halfedge data structure and can be used | ||
* to represent polyhedral surfaces. It is an edge-centered data structure | ||
* capable of maintaining incidence information of vertices, edges, and faces. | ||
* Each edge is represented by two halfedges with opposite orientation. The | ||
* orientation of a face is chosen so that the halfedges around a face are | ||
* oriented counterclockwise. | ||
* | ||
* More information on this class is available at | ||
* https://doc.cgal.org/latest/Surface_mesh/index.html | ||
* | ||
* The function will throw an exception in dimension one. In dimension two, it | ||
* generates a surface mesh of the quadrilateral cell or of the triangle cell, | ||
* while in dimension three it will generate the surface mesh of the cell, | ||
* i.e., a polyhedral mesh containing the faces of the input cell. | ||
* | ||
* The generated mesh is useful when performing geometric operations using | ||
* CGAL::Polygon_mesh_processing, i.e., to compute boolean operations on | ||
* cells, splitting, cutting, slicing, etc. | ||
* | ||
* For examples on how to use the resulting CGAL::Surface_mesh see | ||
* https://doc.cgal.org/latest/Polygon_mesh_processing/ | ||
* | ||
* @param[in] cell The input deal.II cell iterator | ||
* @param[in] mapping The mapping used to map the vertices of the cell | ||
* @param[out] mesh The output CGAL::Surface_mesh | ||
*/ | ||
template <typename CGALPointType, int dim, int spacedim> | ||
void | ||
dealii_cell_to_cgal_surface_mesh( | ||
const typename dealii::Triangulation<dim, spacedim>::cell_iterator &cell, | ||
const dealii::Mapping<dim, spacedim> & mapping, | ||
CGAL::Surface_mesh<CGALPointType> & mesh); | ||
} // namespace CGALWrappers | ||
|
||
|
||
|
||
DEAL_II_NAMESPACE_CLOSE | ||
|
||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## --------------------------------------------------------------------- | ||
## | ||
## Copyright (C) 2022 by the deal.II authors | ||
## | ||
## This file is part of the deal.II library. | ||
## | ||
## The deal.II library is free software; you can use it, redistribute | ||
## it, and/or modify it under the terms of the GNU Lesser General | ||
## Public License as published by the Free Software Foundation; either | ||
## version 2.1 of the License, or (at your option) any later version. | ||
## The full text of the license can be found in the file LICENSE.md at | ||
## the top level directory of deal.II. | ||
## | ||
## --------------------------------------------------------------------- | ||
|
||
|
||
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
|
||
SET(_src | ||
surface_mesh.cc | ||
) | ||
|
||
|
||
|
||
SET(_inst | ||
surface_mesh.inst.in | ||
) | ||
|
||
FILE(GLOB _header | ||
${CMAKE_SOURCE_DIR}/include/deal.II/cgal/*.h | ||
) | ||
|
||
DEAL_II_ADD_LIBRARY(obj_cgal OBJECT ${_src} ${_header} ${_inst}) | ||
EXPAND_INSTANTIATIONS(obj_cgal "${_inst}") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general comment (not just related to this library): I think we should consider to not make these folders a top level folder but rather move them into subdirs (here into
grid
). The same holds also forarborx
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But CGAL does other things in addition to "grid". It also handles point clouds, bounding boxes of trees, etc. Don't you think it makes sense to keep features related to an external library in their own directory when this is the case (e.g, sundials, opencascade)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It seems we have now too many options to do the same thing ;) Does CGAL work in the distributed setting?
Apart from that I would very much prefer if external libraries where we only provide wrappers (incl. sundials) would not be in the main deal.II
include
directory but in a 3rd party library. But I guess I am too late for such wishes...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. If it makes you feel better, there will be also functions like
that internally use CGAL. This is not a wrapper, strictly speaking... where would you prefer these functions to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(all the types there are native dealii types)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!