Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ else()
set(ZLIB_LIBRARY "")
endif()

find_package(bgeo)
if (bgeo_FOUND)
message("Building with modern Bgeo support")
else()
message("Building with NO modern Bgeo support")
endif()

# Make modules able to see partio library
set(PARTIO_LIBRARIES partio ${ZLIB_LIBRARY})

Expand Down
35 changes: 33 additions & 2 deletions src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,34 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

file(GLOB io_cpp "io/*.cpp")
file(GLOB core_cpp "core/*.cpp")
set(core_cpp
core/Particle.cpp
core/ParticleCaching.cpp
core/ParticleHeaders.cpp
core/ParticleSimple.cpp
core/ParticleSimpleInterleave.cpp)

set(io_cpp
io/BGEO.cpp
io/BHCLASSIC.cpp
io/BIN.cpp
io/GEO.cpp
io/HCLASSIC.cpp
io/MC.cpp
io/ParticleIO.cpp
io/PDA.cpp
io/PDB.cpp
io/PDC.cpp
io/PRT.cpp
io/PTC.cpp
io/PTS.cpp
io/RIB.cpp
io/ZIP.cpp
)

if (bgeo_FOUND)
list(APPEND io_cpp io/BJSON.cpp )
endif()

if(PARTIO_BUILD_SHARED_LIBS)
set(PARTIO_LIBRARY_TYPE SHARED)
Expand All @@ -55,6 +81,11 @@ if (ZLIB_FOUND)
target_link_libraries(partio PUBLIC ZLIB::ZLIB)
endif()

if (bgeo_FOUND)
target_link_libraries(partio PUBLIC bgeo::bgeo)
target_compile_definitions(partio PRIVATE MODERN_BGEO)
endif()

install(TARGETS partio DESTINATION ${CMAKE_INSTALL_LIBDIR})

file(GLOB public_includes "*.h")
Expand Down
8 changes: 8 additions & 0 deletions src/lib/core/KdTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,16 @@ void KdTree<k>::sortSubtree(int n, int size, int j)

// partition range [n, n+size) along axis j into two subranges:
// [n, n+leftSize+1) and [n+leftSize+1, n+size)
#ifdef NDEBUG
std::nth_element(&_ids[n], &_ids[n+left], &_ids[n+size],
ComparePointsById(&_points[0].p[j]));
#else
// In Debug mode element compiler asserting on _ids[n+size] with
// Expression: vector subscript out of range
// whereas it's not accessed by algorithm
std::nth_element(&_ids[n], &_ids[n+left], &_ids[std::min(n+size, this->size()-1)],
ComparePointsById(&_points[0].p[j]));
#endif
// move median value (nth element) to front as root node of subtree
std::swap(_ids[n], _ids[n+left]);

Expand Down
Loading