Skip to content

Commit 932ede8

Browse files
authored
Attach meta-data to DCEL meshes (#60)
1 parent 2666a66 commit 932ede8

40 files changed

+1275
-581
lines changed

.github/workflows/CI.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
name: Continuous integration
23

34
on:
@@ -21,7 +22,7 @@ jobs:
2122
directory: [Source, Examples]
2223

2324
steps:
24-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2526
- name: Run clang-format
2627
uses: jidicula/clang-format-action@v4.10.1
2728
with:
@@ -39,7 +40,7 @@ jobs:
3940
directory: [Examples/EBGeometry_DCEL, Examples/EBGeometry_F18, Examples/EBGeometry_OctreeBoundingVolume, Examples/EBGeometry_PackedSpheres, Examples/EBGeometry_RandomCity, Examples/EBGeometry_Shapes]
4041

4142
steps:
42-
- uses: actions/checkout@v3
43+
- uses: actions/checkout@v4
4344
- name: Install dependencies
4445
run: |
4546
sudo apt-get update
@@ -71,7 +72,7 @@ jobs:
7172
directory: [Examples/EBGeometry_DCEL, Examples/EBGeometry_PackedSpheres, Examples/EBGeometry_RandomCity, Examples/EBGeometry_Shapes]
7273

7374
steps:
74-
- uses: actions/checkout@v3
75+
- uses: actions/checkout@v4
7576
- name: Install Intel oneAPI
7677
working-directory: /tmp
7778
run: |
@@ -100,7 +101,7 @@ jobs:
100101
needs: Formatting
101102
runs-on: ubuntu-latest
102103
steps:
103-
- uses: actions/checkout@v3
104+
- uses: actions/checkout@v4
104105
- name: Install dependencies
105106
run: |
106107
sudo apt-get update

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Examples/AMReX_Shapes/plt*
2727
Examples/AMReX_Shapes/tmp_build_dir
2828
Examples/AMReX_Shapes/Backtrace.*
2929

30+
Examples/AMReX_PaintEB/plt*
31+
Examples/AMReX_PaintEB/tmp_build_dir
32+
Examples/AMReX_PaintEB/Backtrace.*
33+
3034
Examples/Chombo3_DCEL/d/**
3135
Examples/Chombo3_DCEL/o/**
3236
Examples/Chombo3_DCEL/f/**

Docs/Sphinx/source/Concepts.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ It has the additional property
1414
1515
\left|\nabla S(\mathbf{x})\right| = 1 \quad\textrm{everywhere}.
1616
17-
Note that the normal vector is always
17+
The normal vector is always
1818

1919
.. math::
2020
2121
\mathbf{n} = \nabla S\left(\mathbf{x}\right).
2222
23-
EBGeometry uses the following convention for the sign:
23+
``EBGeometry`` uses the following convention for the sign:
2424

2525
.. math::
2626
@@ -60,7 +60,7 @@ DCEL
6060
Principle
6161
---------
6262

63-
EBGeometry uses a doubly-connected edge list (DCEL) structure for storing surface meshes.
63+
``EBGeometry`` uses a doubly-connected edge list (DCEL) structure for storing surface meshes.
6464
The DCEL structures consist of the following objects:
6565

6666
* Planar polygons (facets).
@@ -79,7 +79,7 @@ From the DCEL structure we can easily obtain all edges or vertices belonging to
7979
DCEL mesh structure. Each half-edge stores references to next half-edge, the pair edge, and the starting vertex.
8080
Vertices store a coordinate as well as a reference to one of the outgoing half-edges.
8181

82-
In EBGeometry the half-edge data structure is implemented in its own namespace.
82+
In ``EBGeometry`` the half-edge data structure is implemented in its own namespace.
8383
This is a comparatively standard implementation of the DCEL structure, supplemented by functions that permit signed distance computations to various features on such a mesh.
8484

8585
.. important::
@@ -111,7 +111,7 @@ Three cases can be distinguished:
111111

112112
.. tip::
113113

114-
EBGeometry uses the crossing number algorithm by default.
114+
``EBGeometry`` uses the crossing number algorithm by default.
115115

116116
If the point projects to the inside of the face, the signed distance is just :math:`\mathbf{n}_f\cdot\left(\mathbf{x} - \mathbf{x}_f\right)` where :math:`\mathbf{n}_f` is the face normal and :math:`\mathbf{x}_f` is a point on the face plane (e.g., a vertex).
117117
If the point projects to *outside* the polygon face, the closest feature is either an edge or a vertex.
@@ -188,7 +188,7 @@ For example, analytic signed distance functions can also be embedded in BVHs, pr
188188

189189
.. note::
190190

191-
EBGeometry is not limited to binary trees, but supports :math:`k` -ary trees where each regular node has :math:`k` child nodes.
191+
``EBGeometry`` is not limited to binary trees, but supports :math:`k` -ary trees where each regular node has :math:`k` child nodes.
192192

193193
Construction
194194
------------
@@ -203,7 +203,7 @@ Although the rules for BVH construction are highly flexible, performant BVHs are
203203
* **Balanced**, in the sense that the tree depth does not vary greatly through the tree, and there is approximately the same number of primitives in each leaf node.
204204

205205
Construction of a BVH is usually done recursively, from top to bottom (so-called top-down construction).
206-
Alternative construction methods also exist, but are not used in EBGeometry.
206+
Alternative construction methods also exist, but are not used in ``EBGeometry``.
207207
In this case one can represent the BVH construction of a :math:`k` -ary tree is done through a single function:
208208

209209
.. math::
@@ -255,7 +255,7 @@ For the traversal algorithm we consider the following steps:
255255
For example, it is necessary to traverse almost the entire tree when one tries to compute the signed distance at the origin of a tessellated sphere.
256256

257257
Note that types of tree traversal (that do not compute the signed distance) are also possible, e.g. we may want to compute the union :math:`I\left(\mathbf{x}\right) = \min\left(I_1\left(\mathbf{x}\right), I_2\left(\mathbf{x}\right), .\ldots\right)`.
258-
EBGeometry supports a fairly flexible approach to the tree traversal and update algorithms.
258+
``EBGeometry`` supports a fairly flexible approach to the tree traversal and update algorithms.
259259

260260
Octree
261261
======
@@ -268,7 +268,7 @@ Octree construction can be done in (at least) two ways:
268268
#. In depth-first order where entire sub-trees are built first.
269269
#. In breadth-first order where tree levels are added one at a time.
270270

271-
EBGeometry supports both of these methods.
271+
``EBGeometry`` supports both of these methods.
272272
Octree traversal is generally speaking quite similar to the traversal algorithms used for BVH trees.
273273

274274
Constructive solid geometry
@@ -278,7 +278,7 @@ Basic transformations
278278
---------------------
279279

280280
Implicit functions, and by extension also signed distance fields, can be manipulated using basic transformations (like rotations).
281-
EBGeometry supports many of these:
281+
``EBGeometry`` supports many of these:
282282

283283
* Rotations.
284284
* Translations.
@@ -294,11 +294,11 @@ EBGeometry supports many of these:
294294
Combining objects
295295
-----------------
296296

297-
EBGeometry supports standard operations in which implicit functions can be combined:
297+
``EBGeometry`` supports standard operations in which implicit functions can be combined:
298298

299299
* Union.
300300
* Intersection.
301301
* Difference.
302302

303303
Some of these CSG operations also have smooth equivalents, i.e. for smoothing the transition between combined objects.
304-
Fast CSG operations are also supported by EBGeometry, e.g. the BVH-accelerated CSG union where one uses the BVH when searching for the relevant geometric primitive(s).
304+
Fast CSG operations are also supported by ``EBGeometry``, e.g. the BVH-accelerated CSG union where one uses the BVH when searching for the relevant geometric primitive(s).

Docs/Sphinx/source/Examples.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
.. _Chap:Examples:
22

3-
Below, we consider a few examples that show how to use EBGeometry.
3+
Below, we consider a few examples that show how to use ``EBGeometry``.
44
All the examples are located in the :file:`Examples` folder.
55
For instructions on how to compile and run the examples, refer to the README file in the example folder.
66

77
EBGeometry
88
==========
99

10-
EBGeometry-specified examples are given in :file:`Examples/EBGeometry_<something>`.
11-
These examples display most of the EBGeometry functionality:
10+
``EBGeometry``-specified examples are given in :file:`Examples/EBGeometry_<something>`.
11+
These examples display most of the ``EBGeometry`` functionality:
1212

1313
* Generating analytic implicit or signed distance functions.
1414
* Representation of surface grids as signed distance functions.
@@ -21,10 +21,10 @@ AMReX
2121
=====
2222

2323
The AMReX examples are given in :file:`Examples/AMReX_<something>`.
24-
These examples are intended to expose the same features as the EBGeometry-specific examples.
24+
These examples are intended to expose the same features as the ``EBGeometry``-specific examples.
2525

2626
Chombo3
2727
=======
2828

2929
The Chombo-3 examples are given in :file:`Examples/Chombo3_<something>`.
30-
These examples are intended to expose the same features as the EBGeometry-specific examples.
30+
These examples are intended to expose the same features as the ``EBGeometry``-specific examples.

Docs/Sphinx/source/ImplemBVH.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The compact BVH is discussed below in :ref:`Chap:LinearBVH`.
3232
Bounding volumes
3333
----------------
3434

35-
EBGeometry supports the following bounding volumes, which are defined in :file:`EBGeometry_BoundingVolumes.hpp``:
35+
``EBGeometry`` supports the following bounding volumes, which are defined in :file:`EBGeometry_BoundingVolumes.hpp`:
3636

3737
* **BoundingSphere**, templated as ``EBGeometry::BoundingVolumes::BoundingSphereT<T>`` and describes a bounding sphere.
3838
Various constructors are available.
@@ -56,7 +56,7 @@ The second step is to recursively build the BVH, which is done through the funct
5656

5757
.. literalinclude:: ../../../Source/EBGeometry_BVH.hpp
5858
:language: c++
59-
:lines: 28, 62-94, 217-227, 248-257, 263-268, 274-285, 404, 643
59+
:lines: 29, 62-94, 217-227, 248-257, 263-268, 274-285, 404, 643,644
6060
:caption: Header section of the BVH implementation.
6161

6262
The optional input arguments to ``topDownSortAndPartition`` are polymorphic functions of type indicated above, and have the following responsibilities:
@@ -73,7 +73,7 @@ Default arguments for these are provided, bubt users are free to partition their
7373
Compact form
7474
------------
7575

76-
In addition to the standard BVH node ``NodeT<T, P, BV, K>``, EBGeometry provides a more compact formulation of the BVH hierarchy where the nodes are stored in depth-first order.
76+
In addition to the standard BVH node ``NodeT<T, P, BV, K>``, ``EBGeometry`` provides a more compact formulation of the BVH hierarchy where the nodes are stored in depth-first order.
7777
The "linearized" BVH can be automatically constructed from the standard BVH but not vice versa.
7878

7979
.. figure:: /_static/CompactBVH.png

Docs/Sphinx/source/ImplemCSG.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Geometry representation
66
Implicit functions
77
------------------
88

9-
EBGeometry implements implement functions and signed distance functions through virtual classes
9+
``EBGeometry`` implements implement functions and signed distance functions through virtual classes
1010

1111
.. literalinclude:: ../../../Source/EBGeometry_ImplicitFunction.hpp
1212
:language: c++
1313
:lines: 25-74
1414

15-
and for the signed distance field,
15+
Signed distance fields inherit from implicit functions as follows:
1616

1717
.. literalinclude:: ../../../Source/EBGeometry_SignedDistanceFunction.hpp
1818
:language: c++

Docs/Sphinx/source/ImplemDCEL.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The DCEL functionality exists under the namespace ``EBGeometry::DCEL`` and conta
1010

1111
.. important::
1212

13-
The DCEL functionality is *not* restricted to triangles, but supports N-sided polygons.
13+
The DCEL functionality is *not* restricted to triangles, but supports N-sided polygons, including *meta-data* attached to the vertices, edges, and facets.
1414

1515
Main types
1616
----------
@@ -21,7 +21,7 @@ The main DCEL functionality (vertices, edges, faces) is provided by the followin
2121

2222
.. code-block:: c++
2323

24-
template <class T>
24+
template <class T, class Meta>
2525
class VertexT
2626

2727
The DCEL vertex class stores the vertex position, normal vector, and the outgoing half-edge from the vertex.
@@ -33,7 +33,7 @@ The main DCEL functionality (vertices, edges, faces) is provided by the followin
3333

3434
.. code-block:: c++
3535

36-
template <class T>
36+
template <class T, class Meta>
3737
class EdgeT
3838

3939
The half-edges store a reference to their face, as well as pointers to the next edge, pair edge, and starting vertex.
@@ -44,7 +44,7 @@ The main DCEL functionality (vertices, edges, faces) is provided by the followin
4444

4545
.. code-block:: c++
4646

47-
template <class T>
47+
template <class T, class Meta>
4848
class FaceT
4949

5050
Faces also store
@@ -62,7 +62,7 @@ The main DCEL functionality (vertices, edges, faces) is provided by the followin
6262

6363
.. code-block:: c++
6464

65-
template <class T>
65+
template <class T, class Meta>
6666
class MeshT : public SignedDistanceFunction<T>
6767

6868
The mesh stores all the vertices, half-edges, and faces, and if it is watertight and orientable it is also a signed distance function.
@@ -77,10 +77,13 @@ The above DCEL classes have member functions of the type:
7777

7878
which can be used to compute the distance to the various features on the mesh.
7979

80+
Meta-data can be attached to the DCEL primitives by selecting an appropriate type for ``Meta`` above (which defaults to ``short``).
81+
82+
8083
.. _Chap:BVHIntegration:
8184

8285
BVH integration
8386
---------------
8487

8588
DCEL grids can easily be embedded in BVHs by enclosing bounding volumes around the polygons (e.g., triangles).
86-
Partitioning and bounding volume constructors are provided in :file:`Source/EBGeometry_DCEL_BVH.hpp`.
89+
Partitioning and bounding volume constructors are provided in :file:`Source/EBGeometry_MeshDistanceFunctions.hpp`.

Docs/Sphinx/source/ImplemOctree.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Octrees are encapsulated by a class
1111

1212
.. literalinclude:: ../../../Source/EBGeometry_Octree.hpp
1313
:language: c++
14-
:lines: 71-72
14+
:lines: 74-75
1515

1616

1717
where the template parameters are:
@@ -30,15 +30,15 @@ where the template parameters are:
3030
Construction
3131
------------
3232

33-
Constructing the octree is done by first initializing the root node and then building it in either depth-first or breadth-first ordering:
33+
Constructing the octree is done by first initializing the root node and then building it in either depth-first or breadth-first ordering.
3434

3535
.. literalinclude:: ../../../Source/EBGeometry_Octree.hpp
3636
:language: c++
37-
:lines: 71-73,80-81,87-88,94-96,180-184,191-194,226
37+
:lines: 74-76, 83, 90, 97-98,104,111,117-118,183-187,194-198,229,230
3838

3939
The input functions to ``buildDepthFirst`` and ``buildBreadthFirst`` are as follows:
4040

41-
#. ``StopFunction`` determines if the node should be split or not. If it returns true, the node will *not* be split.
41+
#. ``StopFunction`` determines if the node should be split or not. If it returns true, the node will *not* be split.
4242
#. ``MetaConstructor`` constructs meta-data in the child nodes. This can/should include the physical corners of the node, but this is not a requirement.
4343
#. ``DataConstructor`` constructs data in the child node. This can e.g. be a partitioning of the parent data.
4444

@@ -47,7 +47,7 @@ Tree traversal
4747

4848
.. literalinclude:: ../../../Source/EBGeometry_Octree.hpp
4949
:language: c++
50-
:lines: 71-73,101-102,108-109,114-115,202-208,226
50+
:lines: 74-76,205-211,239
5151

5252
The input functions to ``traverse`` are as follows:
5353

Docs/Sphinx/source/ImplemVec.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Vector types
44
============
55

6-
EBGeometry implements its own 2D and 3D vector types ``Vec2T`` and ``Vec3T``.
6+
``EBGeometry`` implements its own 2D and 3D vector types ``Vec2T`` and ``Vec3T``.
77

88
``Vec2T`` is a two-dimensional Cartesian vector.
99
It is templated as
@@ -19,7 +19,7 @@ It is templated as
1919
};
2020
}
2121

22-
Most of EBGeometry is written as three-dimensional code, but ``Vec2T`` is needed for DCEL functionality when determining if a point projects onto the interior or exterior of a planar polygon, see :ref:`Chap:DCEL`.
22+
Most of ``EBGeometry`` is written as three-dimensional code, but ``Vec2T`` is needed for DCEL functionality when determining if a point projects onto the interior or exterior of a planar polygon, see :ref:`Chap:DCEL`.
2323
``Vec2T`` has "most" common arithmetic operators like the dot product, length, multiplication operators and so on.
2424

2525
``Vec3T`` is a three-dimensional Cartesian vector type with precision ``T``.

Docs/Sphinx/source/Implementation.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Overview
44
========
55

6-
Here, we consider the basic EBGeometry API.
7-
EBGeometry is a header-only library, implemented under its own namespace ``EBGeometry``.
6+
Here, we consider the basic ``EBGeometry`` API.
7+
``EBGeometry`` is a header-only library, implemented under its own namespace (``EBGeometry``).
88
Various major components, like BVHs and DCEL, are implemented under namespaces ``EBGeometry::BVH`` and ``EBGeometry::DCEL``.
9-
Below, we consider a brief introduction to the API and implementation details of EBGeometry.
9+
Below, we consider a brief introduction to the API and implementation details of ``EBGeometry``.

Docs/Sphinx/source/Introduction.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ Requirements
55

66
* A C++ compiler which supports C++14.
77

8-
EBGeometry is a header-only library and is comparatively simple to set up and use.
8+
``EBGeometry`` is a header-only library and is comparatively simple to set up and use.
99
To use it, make :file:`EBGeometry.hpp` (stored at the top level) visible to your code and include it.
1010

1111
Quickstart
1212
==========
1313

14-
To obtain EBGeometry, clone the code from `github <https://github.com/rmrsk/EBGeometry>`_:
14+
To obtain ``EBGeometry``, clone the code from `github <https://github.com/rmrsk/EBGeometry>`_:
1515

1616
.. code-block:: bash
1717
1818
git clone git@github.com:rmrsk/EBGeometry.git
1919
20-
To compile the EBGeometry example codes, navigate to the EBGeometry/Examples folder.
21-
Folders that are named ``EBGeometry_<something>`` are pure ``EBGeometry`` examples and can be compiled without any third-party dependencies.
20+
To compile the ``EBGeometry`` example codes, navigate to the :file:`EBGeometry/Examples` folder.
21+
Folders that are named :file:`EBGeometry_<something>` are pure ``EBGeometry`` examples and can be compiled without any third-party dependencies.
2222

23-
To run the EBGeometry examples, navigate to one of the folders and execute
23+
To run the ``EBGeometry`` examples, navigate to one of the folders and execute
2424

2525
.. code-block:: bash
2626
2727
g++ -O3 -std=c++17 main.cpp && ./a.out
2828
29-
All EBGeometry examples should run using this command.
29+
All ``EBGeometry`` examples should run using this command.
3030
README files present in each folder provide more information regarding the functionality and usage of each example code.
3131

3232
Third-party examples

0 commit comments

Comments
 (0)