Giter Club home page Giter Club logo

ebgeometry's Introduction

EBGeometry

EBGeometry is a code for

  1. Turning watertight and orientable surface grids into signed distance functions (SDFs).
  2. Fast evaluation of such grids using bounding volume hierarchies (BVHs).
  3. Providing fast constructive solid geometry (CSG) unions using BVHs.

This code is header-only and can be dropped into any C++ project that supports C++14. It was originally written to be used with embedded-boundary (EB) codes like Chombo or AMReX. However, EBGeometry provides quite general SDFs, implicit functions, and CSG unions, and is useful beyond those codes.

To clone EBGeometry:

git clone [email protected]:rmrsk/EBGeometry.git

Requirements

  • A C++ compiler which supports C++14.

EBGeometry is a header-only library in C++ and has no external dependencies. To use it, simply make EBGeometry.hpp visible to your code and include it.

Documentation

User documentation is available as HTML or as a PDF. A doxygen-generated API is also available.

Example quickstart

Several examples are given in the Examples folder. To run one of the examples, navigate to the example and compile and run it.

1. Analytic distance fields

Use one of the analytic signed distance fields in EBGeometry:

cd Examples/EBGeometry_Shapes
g++ -O3 -std=c++14 main.cpp
./a.out

2. Creating an SDF from a surface grid

Read in an STL file and turn it into a signed distance field.

cd Examples/EBGeometry_DCEL
g++ -O3 -std=c++14 main.cpp
./a.out

Signed distance field from Armadillo geometry

3. Fast CSG operations for analytic functions

Generate a spherical packed bed geometry using analytic representations of spheres. BVH-accelerated CSG unions lead to order-of-magnitude faster implicit function evaluation.

cd Examples/EBGeometry_PackedSpheres
g++ -O3 -std=c++14 main.cpp
./a.out

Packed bed geometry

4. Fast CSG on composite geometries

Create an F18 implicit function using CSG on each part (65 parts in total).

cd Examples/EBGeometry_F18
g++ -O3 -std=c++17 main.cpp -lstdc++fs
./a.out

F18 composite geomery

5. Advanced examples

Some complex examples that use Chombo3 or AMReX are also provided in the Examples folder. These include application-specific code and require installation of Chombo3 or AMReX.

Contributing

  1. Create a branch for the new feature.

    git checkout main
    git pull
    git checkout -b my_branch
    
  2. Develop the feature.

    git add .
    git commit -m "my commit message"
    

    If relevant, add Sphinx and doxygen documentation.

  3. Format the source and example codes using clang-format:

    find Source Examples \( -name "*.hpp" -o -name "*.cpp" \) -exec clang-format -i {} +
    
  4. Push the changes to GitHub

    git push --set-upstream origin my_branch
    
  5. Create a pull request and make sure the GitHub continuous integration tests pass.

License

See LICENSE and Copyright.txt for redistribution rights.

ebgeometry's People

Contributors

rmrsk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ebgeometry's Issues

Visualizer

Add a simple visualizer for implicit functions. This should probably be based on a marching cubes algorithm.

Primitive sorting

It might be beneficial to permit the BVHs (and in particular LinearBVH) to perform a deep sort of the primitives.
Currently, these are only pointer-accessed which means that the actual memory stride can be much bigger than we think.

Heterogeneous BVH inputs and CSG

It might be desirable to put different kind of objects in the BVH accelerator (which share a base class). The natural base class is ImplicitFunction, but one question is what happens when one wants to move implicit functions around in (arbitrarily) complex ways, yet maintain an AABB that encloses them. We can't rotate/shift the AABB in the same way, because there's no workable math for the resulting distance queries to the bounding boxes.

I'm leaving this comment here for me to think about. Currently, the BVH "always works" because it's the users responsibility to put the bounding volume in the correct place (through the BV constructor). But we might want to consider more "general" algorithms that automatically compute an AABB for an arbitrary implicit function, e.g. by spatial subdivision (oct-trees). That would open up the possibility of reading in surface grids, manipulating their SDFs in arbitrary ways, and then later put them in a BVH accelerated CSG union. This is not currently possible, which users will quickly figure out if they try to do it. It might be possible to use oct-tree partitioning to do this, where we compute a loose-fitting box around the implicit surface.

Edit: Should probably add octree decomposition of the implicit surface to do this. This should be a member function of ImplicitFunction. Because this process can be expensive, the BVH build should precompute these during topDownSortAndPartition so we avoid multiple constructions.

Usability upgrade

Various usability upgrades are required for making EBGeometry simpler to use.

Fix old-style casts

GNU and Intel compilers obviously throw warnings when using (unsigned int) cast rather than static_cast.

TODO

  • Add more partitioners (SAH, minimize BV overlap etc).

Rename DIM

DIM is a common macro for many codes but is used in Vec2 and Vec3. This should be renamed to something less likely to cause conflicts with application codes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.