GithubHelp home page GithubHelp logo

ukaea / overlap_checker Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 205 KB

A growing collection of tools to process CAD geometries for use in modelling workflows.

License: GNU General Public License v2.0

C++ 95.40% CMake 2.92% Shell 1.09% Python 0.58%
cad geometry-processing

overlap_checker's Introduction

This project contains a variety of small tools to validate and preprocess CAD files (e.g. STEP files, as produced by FreeCad) for integration into modelling workflows, for example simulation in OpenMC.

Building

Building currently requires a recent version of OpenCascade's headers and libraries to be installed on your system, along with CMake and Python.

Under Debian/Ubuntu these can be installed by running:

apt-get install cmake libocct-foundation-dev libocct-data-exchange-dev

Note, using Ubuntu 21.04 is recommended to get OpenCascade 7.5, Ubuntu 20.04 LTS is known to fail due to the library being too old.

Under ArchLinux the above dependencies would be installed via:

pacman -S cmake opencascade

Cloning

When fetching the source code please ensure that sub-modules are also cloned, e.g. via:

git clone --recurse-submodules https://github.com/ukaea/overlap_checker.git

Git Large File Storage (LFS)

Testing this code involves a number of geometry files that aren't suitable for tracking directly in Git. We're using Git LFS instead to track these so this must be installed first, if you want to run regression tests. See https://git-lfs.github.com/ for details.

Under Ubuntu 22.04, git-lfs can be installed via:

apt-get install git-lfs
git lfs install

Then to get the test data:

git lfs pull

Building

Next we set up a build directory, compile the code, and run the unit tests via:

# set up and enter a build directory
mkdir build; cd build
cmake ..

# compile the code
make -j6

# run tests
ctest

# install executables
make install

Experimental Conda integration for Blueprint

This package is designed to function within the Blueprint ecosystem which predominantly uses Conda for package management. The following recipe should work locally as well as within a condaforge/miniforge3 Docker container:

# ensure system level tools are installed
apt-get update && apt-get install libgl1 cmake g++

# create a conda environment and activate it
conda create -n bluemira python
conda activate bluemira

# install dependencies
conda install ninja meson occt fmt spdlog cli11 doctest

# set up and enter build directly
CXX=/usr/bin/g++ meson setup build \
  -Dconda_prefix=$CONDA_PREFIX -Duse_conan=false

cd build

# compile the code
meson compile

# run tests
meson test -v

Using the GCC C++ compiler installed within Conda causes the OpenGL libraries (depended on by OpenCascade) to fail to link, hence using an externally installed version.

The use_conan parameter controls whether dependencies are fetched via Conan, or are assumed to exist within the system. Allowing advanced users to install them, and use the following during the setup step:

meson setup build -Duse_conan=false

Notes

  • Some editors use clangd to provide autocompletions and other helpful tools, using the Clang compiler can help with this.

I need to use the following to accomplish this:

export CC=clang CXX=clang++

Running

Three small tools are provided that can be used in different workflows, they are:

  • step_to_brep extracts the solid shapes out of a STEP file and write them to a BREP file, along with CSV output of labels, material, and colour information.
  • overlap_checker performs pairwise checks on all solids, writing out a CSV file listing when they touch or overlap.
  • overlap_collecter collect intersections between solids and write out to BREP file.
  • imprint_solids removes any overlaps from solids, modifying veticies, edges and faces as appropriate.

A demo workflow is available in tests/demo_workflow.sh, and can be executed on a simple demo geometry as:

bash tests/demo_workflow.sh ../data/test_geometry.step

All output will be written into the current directory, a prefixed by test_geometry. The workflow is similar to the following:

# linearise all the shapes in the STEP file so they can be indexed consistantly by subsequent tools
step_to_brep ../data/test_geometry.step test_geometry.brep > test_geometry-geometry.csv

# perform overlap checking
overlap_checker test_geometry.brep > test_geometry-overlaps.csv

# collect overlapping solids and write to common.brep
grep overlap test_geometry-overlaps.csv | overlap_collecter test_geometry.brep test_geometry-common.brep

# perform imprinting
imprint_solids test_geometry.brep test_geometry-imprinted.brep < test_geometry-overlaps.csv

# merging of imprinted solids
merge_solids test_geometry-imprinted.brep test_geometry-merged.brep

Terminology

There are a few terms that are used a lot and I'll try to describe them here:

Imprinting

This ensures shapes that touch or intersect in any way both have equivalent features at the same place. For example if a rectangular face encompasses another smaller rectangular face, then that smaller face will be inscribed/imprinted into the larger face by removing the overlapping area, then adding 4 vertices and edges, and a face to the larger face, and stitching up the result.

Merging

This ensures that "topologically identical" features (e.g. vertices in the same place) are recorded as being the same. This ensures that subsequent processing steps are able to easily identify these shared features. For example, when meshing, we'd want mesh vertices along a shared edge to be the same and meshers will ensure this if they know a single edge is used rather than two separate edges that happen to be at the same location.

Tool descriptions

Note that all programs support passing the standard Unix --help (and the terse -h variant) to get information about supported command line arguments. For example, running:

overlap_checker -h

will print out information about how to specify the amount of parallelisation to exploit, tolerances on bounding boxes, volumes and clearances.

step_to_brep

This tool is the starting point of this toolkit. It recursively collects all solid shapes out of a STEP file and writes them out to a BREP file. It also tries to collect color and material information from the input file and outputs them to standard out, under the expectation that this is directed to a file so it can be used by other tools.

Note that the brep_flatten tool might be useful if you already have a BREP file that you got from somewhere else.

overlap_checker

This tool performs pairwise comparisons between all nearby solids outputting a CSV file for all cases where they touch (i.e. share a vertex or edge) or overlap. The user can specify a tolerance that is used when comparing shapes allowing small modelling/floating point errors (i.e. <0.001mm, see command line) to be considered as specifying the "same" thing.

When two solids overlap more than trivially (more than 1%, see command line for control over this) then this is determined to be an error with the geometry. The resulting non-zero exit status is designed to help CI pipelines.

Note that this is a computationally expensive operation so is parallelised, you can specify the number of threads to use with the -j parameter.

overlap_collecter

This tool collects the overlapping area between the shapes specified by a CSV file. The overlapping volumes are written to a BREP file under the expectation that this is read into a GUI along side the original STEP file so highlight where the overlaps occurred.

imprint_solids

This tool tries to clean up any overlapping volumes from solids. This uses the same tolerance options as overlap_checker, and hence vertices/edges of "touching" shapes might move due nearby shapes being within this tolerance.

merge_solids

This tool glues shared parts of solids together. It works from vertices upto compound solid, merging any shared edges/faces as appropriate. This is an intermediate step in our neutronics workflow and aims to produce output compatible with occ_faceter.

File formats

The geometry data is stored in BREP format with some constraints designed to simplify subsequent processing tasks. Our workflow is centered around solids and their materials. Each solid has a defined material, and it's important to be able to maintain this link during the processing steps. During import, e.g. step_to_brep, the hierchial structure is flattened to a list of solids, represented in OCCT and the BREP file as a COMPOUND. A CSV file describing material information is also written that uses the same ordering.

Subsequent tools that modify the shapes, e.g. imprint_solids, maintain the top-level order. For example if there is an intersection between shapes 3 and 4, the overlapping volume will be added to the larger shape (e.g. shape 4). Hence, after imprinting shape 3 will be slightly smaller while shape 4 will now be a COMPSOLID containing two SOLIDS, one solid being this small intersecting volume and a copy of shape 4 that has been modified to remove this intersection.

As a visual representation, our BREP format has a COMPOUND as the top-level shape with either SOLIDS or COMPSOLIDs inside. For example, after the above imprinting we might have:

 * COMPOUND
   * SOLID
   * SOLID
   * SOLID
   * SOLID
   * COMPSOLID
     * SOLID
     * SOLID
   * SOLID

note that numbering is zero based.

Coverage

Currently a few commands I found useful to run:

# configure with coverage enabled
env CXX=clang++ cmake build . -B build \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON

cd build

# run program
./merge_solids ../data/paramak_reactor.brep out.brep

# convert data into a format usable by llvm-cov
llvm-profdata merge -o testcov.profdata default.profraw

# generate html coverage report
llvm-cov show -output-dir=report -format=html ./merge_solids -instr-profile=testcov.profdata

can use LLVM_PROFILE_FILE=paramak_reactor-merge.profraw to output raw profile to another file. see [cov1][1] and [cov2][2] for more details

overlap_checker's People

Contributors

johnnonweiler avatar smason avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

je-cook

overlap_checker's Issues

maybe support some sort of timeout while checking for overlaps between pairs of individual solids

OCCT can take a long time to check for overlaps between some solids, e.g. minutes.

the observed behavior is that the overlap_checker will run for a long time, with only a single thread active at the end. this is because all other pairs have been processed, and it's just waiting on a single errant pair for the program to stop. I can't decide if we should just wait, but there are so many times when I see this that it seems worth while looking into.

I think I might be able to use Message_ProgressIndicator::UserBreak() to do this cleanly (set via BOPAlgo_Options::SetProgressIndicator()) to report (for human checking in a CAD package). stopping pairwise checks that take "too long" (e.g. 5 minutes) would be useful for batch checking many files

e.g. my script for checking all of Colin's files aborts if the overlap checking program runs for more than 10 minutes, but for large files this might be wrong as it could still be making useful progress

Error in the output stream

I get a tremendous about of chaff following #11 it looks like the CSV stream is going to stdout

1,7e+03,#8FAF8FFF,unknown,0
1047,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Coil#Lower_ELM_Coil;Solid1,7e+03,#8FAF8FFF,unknown,0
1048,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Coil#Lower_ELM_Coil;Solid1,7e+03,#8FAF8FFF,unknown,0
1049,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Coil#Lower_ELM_Coil;Solid1,7e+03,#8FAF8FFF,unknown,0
1050,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Coil#Lower_ELM_Coil;Solid1,7e+03,#8FAF8FFF,unknown,0
1051,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Coil#Lower_ELM_Coil;Solid1,7e+03,#8FAF8FFF,unknown,0
1052,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid9,1e+03,#8FAF8FFF,unknown,0
1053,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid10,1e+03,#8FAF8FFF,unknown,0
1054,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid11,1e+03,#8FAF8FFF,unknown,0
1055,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid12,1e+03,#8FAF8FFF,unknown,0
1056,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid13,1e+03,#8FAF8FFF,unknown,0
1057,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid14,1e+03,#8FAF8FFF,unknown,0
1058,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid15,1e+03,#8FAF8FFF,unknown,0
1059,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid16,1e+03,#8FAF8FFF,unknown,0
1060,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid17,1e+03,#8FAF8FFF,unknown,0
1061,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid18,1e+03,#8FAF8FFF,unknown,0
1062,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid19,1e+03,#8FAF8FFF,unknown,0
1063,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid20,1e+03,#8FAF8FFF,unknown,0
1064,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid21,1e+03,#8FAF8FFF,unknown,0
1065,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid22,1e+03,#8FAF8FFF,unknown,0
1066,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid23,1e+03,#8FAF8FFF,unknown,0
1067,MAST-U_VII_BC_v4.1-meshing_1462-4|Lower_ELM_Brackets#Lower_ELM_Brackets;Solid24,1e+03,#8FAF8FFF,unknown,0
1068,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_upper#NBI_PORTS_upper;Solid2,5e+03,#8F8FAFFF,unknown,0
1069,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_upper#NBI_PORTS_upper;Solid4,2e+02,#8F8FAFFF,unknown,0
1070,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_upper#NBI_PORTS_upper;Solid5,2e+02,#8F8FAFFF,unknown,0
1071,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_upper#NBI_PORTS_upper;Solid6,2e+02,#8F8FAFFF,unknown,0
1072,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_upper#NBI_PORTS_upper;Solid,5e+03,#8F8FAFFF,unknown,0
1073,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_upper_inner#NBI_PORTS_upper_inner;Solid1,1e+04,#AFA48FFF,unknown,0
1074,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid2,4e+03,#8F8FAFFF,unknown,0
1075,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid3,3e+01,#8F8FAFFF,unknown,0
1076,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid4,2e+01,#8F8FAFFF,unknown,0
1077,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid5,2e+01,#8F8FAFFF,unknown,0
1078,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid,2e+02,#8F8FAFFF,unknown,0
1079,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid,4e+02,#8F8FAFFF,unknown,0
1080,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid,2e+02,#8F8FAFFF,unknown,0
1081,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid,5e+01,#8F8FAFFF,unknown,0
1082,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower#NBI_PORTS_lower;Solid,5e+03,#8F8FAFFF,unknown,0
1083,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_PORTS_lower_inner#NBI_PORTS_lower_inner;Solid1,1e+04,#AFA48FFF,unknown,0
1084,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_inner#NBI_upper_void_inner;NBI_upper_void_inner,2e+05,#FF80C0FF,unknown,0
1085,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_small_bit3#NBI_upper_void_small_bit3;NBI_upper_void_small_bit3,2e+02,#FF80C0FF,unknown,0
1086,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_small_bit4#NBI_upper_void_small_bit4;NBI_upper_void_small_bit4,2e+02,#FF80C0FF,unknown,0
1087,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_small_bit2#NBI_upper_void_small_bit2;NBI_upper_void_small_bit2,4e+02,#FF80C0FF,unknown,0
1088,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_other#NBI_upper_void_other;NBI_upper_void_other,6e+05,#FF80C0FF,unknown,0
1089,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_small_bit1#NBI_upper_void_small_bit1;NBI_upper_void_small_bit1,2e+02,#FF80C0FF,unknown,0
1090,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_upper_void_gap#NBI_upper_void_gap;NBI_upper_void_gap,6e+03,#FF80C0FF,unknown,0
1091,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_inner#NBI_lower_void_inner;NBI_lower_void_inner,2e+05,#0080FFFF,unknown,0
1092,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_other#NBI_lower_void_other;NBI_lower_void_other,9e+05,#0080FFFF,unknown,0
1093,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_small_bit2#NBI_lower_void_small_bit2;NBI_lower_void_small_bit2,2e+02,#0080FFFF,unknown,0
1094,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_small_bit3#NBI_lower_void_small_bit3;NBI_lower_void_small_bit3,5e+02,#0080FFFF,unknown,0
1095,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_small_bit4#NBI_lower_void_small_bit4;NBI_lower_void_small_bit4,2e+02,#0080FFFF,unknown,0
1096,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_gap#NBI_lower_void_gap;NBI_lower_void_gap,5e+03,#0080FFFF,unknown,0
1097,MAST-U_VII_BC_v4.1-meshing_1462-4|NBI_lower_void_small_bit1#NBI_lower_void_small_bit1;NBI_lower_void_small_bit1,5e+01,#0080FFFF,unknown,0
1098,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300723#HE08-1 TILE STP-M46300723;Solid1,2e+02,#8D8D8DFF,unknown,0
1099,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300708#HE08-1 TILE STP-M46300708;Solid1,8e+01,#8D8D8DFF,unknown,0
1100,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300702#HE08-1 TILE STP-M46300702;Solid1,2e+02,#8D8D8DFF,unknown,0
1101,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300702#HE08-1 TILE STP-M46300702;Solid2,1e+02,#8D8D8DFF,unknown,0
1102,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300667#HE08-1 TILE STP-M46300667;Solid1,3e+02,#8D8D8DFF,unknown,0
1103,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300667#HE08-1 TILE STP-M46300667;Solid2,3e+02,#8D8D8DFF,unknown,0
1104,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300631#HE08-1 TILE STP-M46300631;Solid1,3e+02,#8D8D8DFF,unknown,0
1105,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300631#HE08-1 TILE STP-M46300631;Solid2,3e+02,#8D8D8DFF,unknown,0
1106,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300706#HE08-1 TILE STP-M46300706;Solid1,2e+02,#8D8D8DFF,unknown,0
1107,MAST-U_VII_BC_v4.1-meshing_1462-4|HE08-1 TILE STP-M46300704#HE08-1 TILE STP-M46300704;Solid1,3e+02,#8D8D8DFF,unknown,0
1108,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-2#HM06 TILE STP-2;Solid,2e+02,#8D8D8DFF,unknown,0
1109,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-3#HM06 TILE STP-3;Solid,3e+02,#8D8D8DFF,unknown,0
1110,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-4#HM06 TILE STP-4;Solid,3e+02,#8D8D8DFF,unknown,0
1111,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-5#HM06 TILE STP-5;Solid,3e+02,#8D8D8DFF,unknown,0
1112,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-6#HM06 TILE STP-6;Solid,2e+02,#8D8D8DFF,unknown,0
1113,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-7#HM06 TILE STP-7;Solid,4e+02,#8D8D8DFF,unknown,0
1114,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-8#HM06 TILE STP-8;Solid,3e+02,#8D8D8DFF,unknown,0
1115,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-9#HM06 TILE STP-9;Solid,2e+02,#8D8D8DFF,unknown,0
1116,MAST-U_VII_BC_v4.1-meshing_1462-4|HM06 TILE STP-1#HM06 TILE STP-1;Solid,2e+02,#8D8D8DFF,unknown,0
1117,MAST-U_VII_BC_v4.1-meshing_1462-4|SAMI_window_port#SAMI_window_port;Solid222222222222,7e+03,#FF8040FF,unknown,0
1118,MAST-U_VII_BC_v4.1-meshing_1462-4|SAMI WINDOW-M46300807#SAMI WINDOW-M46300807;PartBody,1e+04,#AFAF8FFF,unknown,0
1119,MAST-U_VII_BC_v4.1-meshing_1462-4|PROTECTION PLATES-M46300806#PROTECTION PLATES-M46300806;PartBody,1e+03,#AFAF8FFF,unknown,0
1120,MAST-U_VII_BC_v4.1-meshing_1462-4|PROTECTION PLATES-M46300805#PROTECTION PLATES-M46300805;PartBody,1e+03,#AFAF8FFF,unknown,0
1121,MAST-U_VII_BC_v4.1-meshing_1462-4|SAMI_window-void_extension#SAMI_window-void_extension;Solid,2e+05,#8F8FAFFF,unknown,0
61.292 [Info] geometry checks passed
61.292 [Info] enumerated 1121 labels, resulting in 1026 solids
61.292 [Warn] 2 solids were excluded because they were too small
61.292 [Warn] 16 solids were excluded because they had negative volume

I presume this is a bug?

Documentation

In the end i figured out how this is meant to work

  1. ./step_to_brep <step_file> <brep_file>
  2. ./overlap_check -j N <brep_file> > overlaps.csv
  3. ./imprint_solids <brep_file> < overlaps.csv

Does that seem correct?

what are degenerated edges and where do they come from?

SALOME's shape gluer code has various branches that are never tested because they are behind if(BRep_Tool::Degenerated(edge)) tests that never come up true. The docs aren't particularly here, currently documenting this function as:

Returns True if the edge is degenerated.

Would be good to figure out how to generate a geometry that has solids containing degenerated edges and know what the "right thing" to do when gluing shapes in the presence of them.

simplify imprinting code

not sure what I was thinking when I wrote it, it's far more complicated than it needs to be!

while writing the ARCHITECTURE document realized it only needs to do a single CUT operation with the shape being the smaller solid and the tool being the larger one

hopefully this will result in simpler geometry being written out at the end, which will make the mesher's job easier as well

report issues found while running overlap_collector back to user

if the operation failed, we should be reporting warnings and errors back as these probably indicate an issue with the input geometry that could turn out to be useful to the user

Helen's step file using broken sectioning code causes some internal errors to get set, which might be nice for testing!

support for running on a distributed memory system

i.e. can this tool efficiently utilize a cluster of machines (communicating over a network via something like MPI) when checking a "large" geometry. @makeclean I heard you're thinking about this

I should note that a number of existing choices have been made assuming this was a direction to be taken, and it's worth describing what these are:

step_to_brep

loading a STEP file with OCCT, given the current implementation, is relatively slow and all-or-nothing, while BREP files are much faster. e.g. a 200MiB STEP file takes ~2 minutes to open, writing the same geometry (~5000 solids) out as BREP takes ~7 seconds, and loading that BREP file ~3 seconds.

this step already flattens the shapes into a linear list because this structure is easier to schedule operations on than the hierarchy used by STEP. additionally, it might be worth splitting up a large input file into multiple flattened BREP files, either a range (e.g. solids 1000 to 2000) of a large STEP file, which would hopefully allow larger files to be checked by smaller-memory nodes

overlap_checker

this is currently the most computationally intensive step and (conveniently) the most amenable to parallelism. there are two main operations performed here:

  1. computing an acceleration structure, indicating which shapes can possibly overlap (currently using orientated bounding boxes)
  2. checking every pair of shapes that can overlap to see whether they do, and quantifying any intersections

both of these steps are currently parallelized over threads, but it's possible to also split this across nodes. given the speed of loading BREP files, it might even be worth performing this separately multiple times in a NUMA system to ensure that each socket has fast/local access to the geometry

imprint_solids and merge_solids

currently not parallelized, mostly because this functionality isn't heavily used yet and partially due to API limitations in OCCT

parallelisation of the merge tool

As part of #10, I've pulled out the relevant parts of Salome. The aim is to be able to glue geometries consisting of 100k+ solids, but the algorithm is currently serial and would grind to a halt on problems of this size.

The Salome code lives in src/salome/geom_gluer.cpp and I've started to refactor the code into a more understandable form. The majority of time is spent within the shape_merger::RefineCoincidentShapes method, as shown by the timings in the logging output. I'm currently working on getting a reproducible set of tests with an easy way of getting "known good" output from the original Salome code for regression tests for validating changes.

Note that "lists" in opencascade (OCC) are linked lists, so locality is likely not great when traversing a lot of these structures. Might be worth using some data structures from outside OCC.

Update ProgressIndicator for compatibility with OCCT >=7.6

When compiling overlap_checker with new OCCT it fails with:
image

It seems in OCCT 7.5 there was a bit of a redesign of the progres indicators as described here: https://dev.opencascade.org/content/redesign-progress-indicator

If I comment out this line

algo.SetProgressIndicator(*scope_);
everything compiles and as far as I have got works. It looks like some functionality is probably lost by doing that but I havent been able to decipher the above article well enough to put in a PR

report volumes in output of overlap_checker

have written some code to pull these out of the logs, but having them nicely in the CSV file would make life easier

three columns, vol_hi, vol_lo and vol_shared would be a good trade off I think

might be worth having vol_shared blank for touching objects to indicate there isn't any shared volume. this also provides a natural way to distinguish between objects that have an overlap that rounds (for display) to zero and objects that only touch

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.