From 2afbc74713f0c2070d02c69ac2595bb3f1c1748e Mon Sep 17 00:00:00 2001 From: Deepak Rangarajan Date: Wed, 17 Jun 2020 13:52:27 +0000 Subject: [PATCH 1/3] Update README.md --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5d5a3d5..adcee90 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,57 @@ # csg-eb -Repo for parsing and validating MFIX input(s) files for use by mfix-app. +Library for parsing Constructive Solid Geometry (CSG) files into an implicit function that can be used to define embedded boundaries (EB). Uses PEGTL for parsing and Catch2 for tests. ## Build -> python3 -m pip install meson ninja -> meson build -> ninja -C build +> :warning: **Requires C++17, such as GCC 7.x or later, or Clang 5.x or later**. -## Run Tests -> meson test -C build +### Meson + +#### Installing meson and ninja the first time + + python3 -m pip install meson ninja + +#### Building using meson + + meson build + ninja -C build + + +#### Running unit tests + + meson test -C build + + +### CMake + +#### Installing conan + + brew install conan + +#### Building using CMake + + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build --target unit_tests_csg + cd build + make -j + +#### Running unit tests + + ctest + + +## Using library in other CMake projects + +* Add repo as a git submodule +* Build by adding as subdirectory in appropriate CMake file + + add_subdirectory() + +* Link by setting the dependency in appropriate CMake file + + target_link_libraries( .. csg) -- GitLab From c8341ca686d4923d13c22d834cd8ddf49aa2fc6c Mon Sep 17 00:00:00 2001 From: Deepak Rangarajan Date: Wed, 17 Jun 2020 20:18:49 +0000 Subject: [PATCH 2/3] Update README.md --- README.md | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index adcee90..7b01c1d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # csg-eb -Library for parsing Constructive Solid Geometry (CSG) files into an implicit function that can be used to define embedded boundaries (EB). +Library for parsing [Constructive Solid Geometry (CSG) files](https://github.com/openscad/openscad/wiki/CSG-File-Format) into an implicit function that can be used to define [Embedded Boundaries (EB)](https://amrex-codes.github.io/amrex/docs_html/EB.html). Uses PEGTL for parsing and Catch2 for tests. @@ -9,6 +9,23 @@ Uses PEGTL for parsing and Catch2 for tests. > :warning: **Requires C++17, such as GCC 7.x or later, or Clang 5.x or later**. +### CMake + +#### Installing conan for the first time + + python3 -m pip install conan + +#### Building using CMake + + cmake -S . -B build -DCMAKE_BUILD_TYPE=Release + cmake --build build --target unit_tests_csg + cd build + make -j + +#### Running unit tests + + ctest + ### Meson @@ -27,31 +44,35 @@ Uses PEGTL for parsing and Catch2 for tests. meson test -C build -### CMake +## Using the library in other projects -#### Installing conan +### Include in the code +* Include the header file - brew install conan - -#### Building using CMake + #include "csg.hpp" - cmake -S . -B build -DCMAKE_BUILD_TYPE=Release - cmake --build build --target unit_tests_csg - cd build - make -j - -#### Running unit tests - - ctest +* Create a function object + + auto csg_if = csg::get_csgif(, is_internal_flow); +* Above returns an implicit function which can be operated on a 3D point coordinate (x, y, z) as + + csg_if(x, y, z) -## Using library in other CMake projects +### Note on the return value +* If `internal_flow` is set to `true` + - **csg_if(x, y, z)** returns a number `less than 0`, if (x, y, z) lies `inside` the CSG object (a hollow) + - **csg_if(x, y, z)** returns a number `greater than 0`, if (x, y, z) lies `outside` the CSG object (a hollow) +* If `internal_flow` is set to `false` + - **csg_if(x, y, z)** returns a number `greater than 0`, if (x, y, z) lies `inside` the CSG object (a solid) + - **csg_if(x, y, z)** returns a number `less than 0`, if (x, y, z) lies `outside` the CSG object (a solid) -* Add repo as a git submodule +### Add to the CMake build +* Add this repo as a git submodule * Build by adding as subdirectory in appropriate CMake file add_subdirectory() * Link by setting the dependency in appropriate CMake file - target_link_libraries( .. csg) + target_link_libraries( PRIVATE csg) -- GitLab From 920c9296a993222f2ecc9f1158792b9f53f97a6f Mon Sep 17 00:00:00 2001 From: Deepak Rangarajan Date: Wed, 17 Jun 2020 20:25:45 +0000 Subject: [PATCH 3/3] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 7b01c1d..007c723 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,11 @@ Uses PEGTL for parsing and Catch2 for tests. csg_if(x, y, z) +* Can be passed to amrex EB2::makeShop + + auto gshop = EB2::makeShop(*csg_if); + + ### Note on the return value * If `internal_flow` is set to `true` - **csg_if(x, y, z)** returns a number `less than 0`, if (x, y, z) lies `inside` the CSG object (a hollow) -- GitLab