Skip to content

Hdf5 improvements #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 114 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
3b718ee
msvc 2019 and win build script fixes
aothms Mar 5, 2021
60f309d
Create test for HDF libs
johltn Mar 18, 2021
daf138f
Abstract writer class with Hdf writer subclass
johltn Apr 12, 2021
f559f0c
Start iteration through continuous chunk
johltn Apr 12, 2021
6b3baf5
Read bits stream and start with HDF5
johltn Apr 12, 2021
bac0607
Store bit values into HDF file
johltn Apr 26, 2021
dbe4e00
Hyperslab writing on fixed dataset dimensions and add test case
johltn Apr 28, 2021
60d8a6e
Write multidimensional dataset for continuous chunks
johltn Apr 28, 2021
a1ba1c1
Use extents to write multidimensional HDF
johltn May 1, 2021
4e8868a
Handle constant null storage chunks
johltn May 4, 2021
d27df88
Better control flow
johltn May 15, 2021
426cbee
Merge remote-tracking branch 'upstream/master' into HDF5
johltn May 15, 2021
9ff08b9
Count all chunks and make planar explicit
johltn May 16, 2021
e83e84a
Write bits incrementally
johltn Jun 1, 2021
35298b1
Incrementally write dataset regions in Region dataset
johltn Jun 1, 2021
85e9820
New test case
johltn Jun 2, 2021
5433a71
Install hdf5
johltn Jun 2, 2021
e8537f5
Add pathes to include and lib dirs
johltn Jun 2, 2021
290fc67
Add quotes
johltn Jun 2, 2021
162fd65
Add subdir for include path
johltn Jun 2, 2021
8ea1951
Move HDF installation variables
johltn Jun 2, 2021
e7a3c45
Libraries variable
johltn Jun 2, 2021
5db0d4e
Update Travis file
johltn Jun 2, 2021
413febf
Update Travis file
johltn Jun 2, 2021
273444d
serial
johltn Jun 2, 2021
d4c996b
Replace lib name
johltn Jun 2, 2021
39889c0
serial
johltn Jun 2, 2021
55e002a
Update Travis file
johltn Jun 2, 2021
99e967b
Add dl
johltn Jun 3, 2021
e5602bb
Fix iterations over chunks
johltn Jun 6, 2021
952c57e
Fix region slabs dimensions
johltn Jun 6, 2021
c4e64e0
Tentative to incrementally write planar chunks to compound typed dataset
johltn Jun 7, 2021
367f4ba
Planar dataset writing ok for simple example
johltn Jun 7, 2021
e018ef7
Start cleaning before cosntant chunks handling
johltn Jun 7, 2021
7a41f0f
Writing preparation to constant chunks dataset
johltn Jun 7, 2021
95d7c0d
Write constant chunks + region references
johltn Jun 7, 2021
b17dd73
Change dimensions types to comply with clang compilator
johltn Jun 7, 2021
237ddb7
Modify control flow
johltn Jun 8, 2021
1a6c326
Start handling voxels stored as integers
johltn Jun 17, 2021
7bb7411
Store operations as groups containing chunk datasets
johltn Jun 21, 2021
47ed3ad
option to specify padding
aothms Mar 14, 2021
a24873d
Delete appveyor.yml
aothms Mar 14, 2021
c7143b9
Create test for HDF libs
johltn Mar 18, 2021
475fa6c
boolean operation fixes
aothms Mar 21, 2021
d447d40
decribe_components() zero() plane()
aothms Mar 21, 2021
86bfbf4
Add missing include
aothms Mar 21, 2021
7e54760
intersection fixes
aothms Mar 25, 2021
5794a4d
describe_group_by()
aothms Mar 25, 2021
b8eeb33
Use {0,1} voxelset for traversal on PRODUCT_ID method
aothms Mar 26, 2021
562fa5a
Fix hardcoded chunk size
aothms Mar 26, 2021
98e1712
Add chunk size to log output
aothms Mar 26, 2021
9ad66d4
shift() on uint storage
aothms Apr 10, 2021
c0b773d
sweep until
aothms Apr 10, 2021
9d08e2c
constant_like(type=)
aothms Apr 10, 2021
758b9e5
mesh(groups=)
aothms Apr 10, 2021
20fdc74
Remove debugging
aothms Apr 10, 2021
7d0b1cf
don't traverse chunks on max_depth
aothms Apr 11, 2021
8269dd4
uint storage option for traversal
aothms Apr 11, 2021
c6fc6fa
export_csv()
aothms Apr 11, 2021
acba092
Abstract writer class with Hdf writer subclass
johltn Apr 12, 2021
abe3c74
Start iteration through continuous chunk
johltn Apr 12, 2021
a9d47d1
Read bits stream and start with HDF5
johltn Apr 12, 2021
a641a43
initialize num_threads
aothms Apr 25, 2021
d96acbf
don't assign to first when skipped over interval
aothms Apr 25, 2021
e5863c7
voxel storage copy_as() method
aothms Apr 25, 2021
7fc4a33
multi-threaded geometry creation
aothms Apr 25, 2021
8507748
multi threaded VOLUME_PRODUCT_ID
aothms Apr 25, 2021
9e5e7d3
multi-threaded group_by()
aothms Apr 25, 2021
cbfa656
respect with_components in mesh()
aothms Apr 25, 2021
292b870
copy(type=) command
aothms Apr 25, 2021
914aefc
dist: focal
aothms Apr 25, 2021
ba17a9d
Update .travis.yml
aothms Apr 25, 2021
3cda43d
Update .travis.yml
aothms Apr 25, 2021
69a4f1c
Store bit values into HDF file
johltn Apr 26, 2021
1343f77
Hyperslab writing on fixed dataset dimensions and add test case
johltn Apr 28, 2021
7a15675
Write multidimensional dataset for continuous chunks
johltn Apr 28, 2021
c76b91d
don't attempt full chunk union on non-bit types
aothms Apr 29, 2021
18957a4
print_values() debugging option
aothms Apr 29, 2021
e9df48a
more chunk union fixes
aothms Apr 29, 2021
f0cef42
Use extents to write multidimensional HDF
johltn May 1, 2021
12438d1
Handle constant null storage chunks
johltn May 4, 2021
c2dea44
more optimal meshing in case of many chunks
aothms May 11, 2021
cd33f5f
Support for functions and small grammar changes
aothms May 11, 2021
2640dc3
Better control flow
johltn May 15, 2021
8120ab4
Count all chunks and make planar explicit
johltn May 16, 2021
fae86ec
Write bits incrementally
johltn Jun 1, 2021
b34b14a
Incrementally write dataset regions in Region dataset
johltn Jun 1, 2021
d462316
New test case
johltn Jun 2, 2021
7ae6a5f
Install hdf5
johltn Jun 2, 2021
05793b7
Add pathes to include and lib dirs
johltn Jun 2, 2021
e8d4f67
Add quotes
johltn Jun 2, 2021
ac94ad1
Add subdir for include path
johltn Jun 2, 2021
d58742b
Move HDF installation variables
johltn Jun 2, 2021
05dd057
Libraries variable
johltn Jun 2, 2021
d761235
Update Travis file
johltn Jun 2, 2021
94d7c0a
Update Travis file
johltn Jun 2, 2021
80cc06c
serial
johltn Jun 2, 2021
866d716
Replace lib name
johltn Jun 2, 2021
c04b2e4
serial
johltn Jun 2, 2021
1f7a652
Update Travis file
johltn Jun 2, 2021
59281bd
Add dl
johltn Jun 3, 2021
92f1eec
Fix iterations over chunks
johltn Jun 6, 2021
835a060
Fix region slabs dimensions
johltn Jun 6, 2021
d4012d0
Tentative to incrementally write planar chunks to compound typed dataset
johltn Jun 7, 2021
d196c31
Planar dataset writing ok for simple example
johltn Jun 7, 2021
db46840
Start cleaning before cosntant chunks handling
johltn Jun 7, 2021
b387a4c
Writing preparation to constant chunks dataset
johltn Jun 7, 2021
075e55d
Write constant chunks + region references
johltn Jun 7, 2021
6e81854
Change dimensions types to comply with clang compilator
johltn Jun 7, 2021
3d62d8b
Modify control flow
johltn Jun 8, 2021
612ced3
Start handling voxels stored as integers
johltn Jun 17, 2021
b6da6f3
Store operations as groups containing chunk datasets
johltn Jun 21, 2021
43f2dd1
Merge branch 'opensourceBIM:HDF5' into HDF5
johltn Jan 25, 2022
163d991
Voxelization toolkit works with IfcOpenShell v0.7.0 including HDF sup…
johltn Feb 3, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
*.out
*.app
build/

test
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ install:
- |
sudo apt-get install -y \
libocct-* \
libhdf5-dev \
libboost-all-dev

script:
- mkdir build && cd build
- |
cmake .. \
cmake -DHDF5_INCLUDE_DIR=/usr/include/hdf5/serial -DHDF5_LIBRARIES="/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5_cpp.a;/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.a;/usr/lib/x86_64-linux-gnu/libz.a;/usr/lib/x86_64-linux-gnu/libsz.a;/usr/lib/x86_64-linux-gnu/libaec.a;dl" .. \
-DIFC_SUPPORT=Off \
-DOCC_INCLUDE_DIR=/usr/include/opencascade \
-DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu \
Expand Down
71 changes: 55 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ cmake_minimum_required (VERSION 2.8.11)
project (voxel)

OPTION(IFC_SUPPORT "Build Volization Toolkit with IFC support (requires IfcOpenShell/master)." ON)
OPTION(USE_STATIC_MSVC_RUNTIME "Link to the static runtime on MSVC." ON)
OPTION(USE_STATIC_MSVC_RUNTIME "Link to the static runtime on MSVC." OFF)
OPTION(ENABLE_TESTS "Enable tests." ON)

include(CTest)

set(CMAKE_BUILD_TYPE "RelWithDebInfo")
set(Boost_NO_BOOST_CMAKE On)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(WIN_ARCH x64)
set(BITS 64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(WIN_ARCH Win32)
set(BITS 32)
endif()

set(OCC_LIBRARY_NAMES TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKOffset
Expand Down Expand Up @@ -57,20 +60,36 @@ if(UNIX)
add_definitions(-Wno-deprecated-declarations)
else()
if(IFC_SUPPORT)
# 1900 = VS 14.0 (v140 toolset)
# 1910-1919 = VS 15.0 (v141 toolset)
# 1920-1929 = VS 16.0 (v142 toolset)
set(MSVC_YEAR 2017)
if ("${MSVC_VERSION}" STREQUAL "1900")
set(MSVC_YEAR 2015)
elseif(MSVC_VERSION GREATER 1919)
set(MSVC_YEAR 2019)
endif()


file(READ "${IFCOPENSHELL_ROOT}/src/ifcparse/IfcParse.h" header)
string(REGEX MATCH "#define IFCOPENSHELL_VERSION \"[0-9a-zA-Z\\.\\-]+\"" ifcopenshell_version "${header}")
string(REGEX MATCH "[0-9]\\.[0-9]" ifcopenshell_major_version "${ifcopenshell_version}")
file(TO_CMAKE_PATH "${IFCOPENSHELL_ROOT}" IFCOPENSHELL_ROOT)
if (EXISTS ${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/oce/${WIN_ARCH}/lib)
set(OCC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/oce/${WIN_ARCH}/lib)
if (EXISTS ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/oce/${WIN_ARCH}/lib)
set(OCC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/oce/${WIN_ARCH}/lib)
else()
set(OCC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/opencascade-7.3.0p3/win32/lib)
if (${ifcopenshell_major_version} STREQUAL "0.7")
set(OCC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/opencascade-7.5.3/win${BITS}/lib)
else()
set(OCC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/opencascade-7.3.0p3/win${BITS}/lib)
endif()
endif()

set(OCC_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/oce/include/oce
${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/opencascade-7.3.0p3/inc)
if (${ifcopenshell_major_version} STREQUAL "0.7")
set(OCC_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/opencascade-7.5.3/inc)
else()
set(OCC_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/oce/include/oce
${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/opencascade-7.3.0p3/inc)
endif()

else()
file(TO_CMAKE_PATH "${OCC_LIBRARY_DIR}" OCC_LIBRARY_DIR)
endif()
Expand Down Expand Up @@ -103,13 +122,19 @@ endif()

set(BOOST_COMPONENTS regex program_options iostreams system)


if (IFC_SUPPORT)
# Find IfcOpenShell version, v0.6.0 does not have the IfcSchema namespace anymore
file(READ "${IFCOPENSHELL_ROOT}/src/ifcparse/IfcParse.h" header)
string(REGEX MATCH "#define IFCOPENSHELL_VERSION \"[0-9a-zA-Z\\.\\-]+\"" ifcopenshell_version "${header}")
string(REGEX MATCH "[0-9]\\.[0-9]" ifcopenshell_major_version "${ifcopenshell_version}")
message(STATUS "IfcOpenShell version ${ifcopenshell_major_version}")

if (${ifcopenshell_major_version} STREQUAL "0.7")
add_definitions("-DIFCOPENSHELL_07")
endif()


if (${ifcopenshell_major_version} STREQUAL "0.5")
set(IFC_LIBRARY_NAMES IfcGeom IfcParse)
add_definitions("-DIFCOPENSHELL_05")
Expand Down Expand Up @@ -140,18 +165,30 @@ if(UNIX)
string(REGEX REPLACE "([^;]+)" "${ICU_LIBRARY_DIR}/lib\\1.a" ICU_LIBRARIES "${ICU_LIBRARY_NAMES}")
endif()
else()
set(BOOST_ROOT ${IFCOPENSHELL_ROOT}/deps/boost_1_67_0)
set(BOOST_LIBRARYDIR ${IFCOPENSHELL_ROOT}/deps/boost_1_67_0/stage/vs${MSVC_YEAR}-${WIN_ARCH}/lib)
if (${ifcopenshell_major_version} STREQUAL "0.7")
SET(HDF5_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/HDF5-1.8.22-win64/include)
SET(HDF5_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/HDF5-1.8.22-win64/lib)

SET(HDF5_LIBRARIES
"${HDF5_LIBRARY_DIR}/libhdf5_cpp.lib"
"${HDF5_LIBRARY_DIR}/libhdf5.lib"
"${HDF5_LIBRARY_DIR}/libzlib.lib"
"${HDF5_LIBRARY_DIR}/libsz.lib"
"${HDF5_LIBRARY_DIR}/libaec.lib")
endif()

set(BOOST_ROOT ${IFCOPENSHELL_ROOT}/_deps/boost_1_74_0)
set(BOOST_LIBRARYDIR ${IFCOPENSHELL_ROOT}/_deps/boost_1_74_0/stage/vs${MSVC_YEAR}-${WIN_ARCH}/lib)

set(IFC_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/src)
set(IFC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/build-vs${MSVC_YEAR}-x86/${CMAKE_BUILD_TYPE})
set(IFC_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/_build-vs${MSVC_YEAR}-${WIN_ARCH}/${CMAKE_BUILD_TYPE})

string(REGEX REPLACE "([^;]+)" "${IFC_LIBRARY_DIR}/\\1.lib" IFC_LIBRARIES "${IFC_LIBRARY_NAMES}")

if (${ifcopenshell_major_version} STREQUAL "0.5")
set(ICU_LIBRARY_NAMES icuuc icudt)
set(ICU_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/icu/lib)
set(ICU_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/deps-vs${MSVC_YEAR}-x86-installed/icu/include)
set(ICU_LIBRARY_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/icu/lib)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the time of the 0.5 build script the dir was still called deps not _deps can you change that back?

set(ICU_INCLUDE_DIR ${IFCOPENSHELL_ROOT}/_deps-vs${MSVC_YEAR}-${WIN_ARCH}-installed/icu/include)
string(REGEX REPLACE "([^;]+)" "${ICU_LIBRARY_DIR}/\\1.lib" ICU_LIBRARIES "${ICU_LIBRARY_NAMES}")
endif()
endif()
Expand All @@ -162,17 +199,19 @@ find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
message(STATUS "Boost include files found in ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost libraries found in ${Boost_LIBRARY_DIRS}")

include_directories(${IFC_INCLUDE_DIR} ${OCC_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/eigen)
include_directories(${IFC_INCLUDE_DIR} ${OCC_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/eigen)
link_directories(${Boost_LIBRARY_DIRS})

include_directories(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${IFC_INCLUDE_DIR})
include_directories(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR} ${IFC_INCLUDE_DIR})
if (NOT MSVC)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
add_definitions(-std=c++14)
else()
message(FATAL_ERROR "requires a compiler with C++11 support")
endif()
endif()

if (ENABLE_TESTS)

Expand Down Expand Up @@ -211,7 +250,7 @@ ENDIF()
set(LIBVOXELIZER_HEADER_FILES progress_writer.h dim3.h sweep.h shift.h collapse.h edge_detect.h fill_gaps.h offset.h polyfill.h resample.h storage.h writer.h factory.h processor.h volume.h voxelizer.h traversal.h util.h json_logger.h)
set(LIBVOXELIZER_SOURCE_FILES tribox3.cpp polyfill.cpp progress_writer.cpp storage.cpp factory.cpp json_logger.cpp)
add_library(libvoxel STATIC ${LIBVOXELIZER_HEADER_FILES} ${LIBVOXELIZER_SOURCE_FILES})
target_link_libraries(libvoxel ${IFC_LIBRARIES} ${ICU_LIBRARIES} ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${OCC_LIBRARIES} ${LIB_RT} ${dl} ${CMAKE_THREAD_LIBS_INIT} ${WS2_LIBRARIES})
target_link_libraries(libvoxel ${IFC_LIBRARIES} ${ICU_LIBRARIES} ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} ${OCC_LIBRARIES} ${LIB_RT} ${dl} ${CMAKE_THREAD_LIBS_INIT} ${WS2_LIBRARIES} ${HDF5_LIBRARIES})

set(LIBVOXEC_HEADER_FILES voxelfile.h voxec.h)
set(LIBVOXEC_SOURCE_FILES voxec.cpp)
Expand Down
1 change: 1 addition & 0 deletions json_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <ctime>
#include <sstream>
#include <chrono>
#include <array>

namespace {
struct ptree_writer {
Expand Down
5 changes: 5 additions & 0 deletions processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
#include <ifcparse/IfcLogger.h> // @todo < commit in IfcopenShell
#include <ifcgeom/IfcGeomElement.h>

#ifdef IFCOPENSHELL_07
typedef IfcGeom::BRepElement elem_t;
#else
typedef IfcGeom::BRepElement<double> elem_t;
#endif

#endif

typedef TopoDS_Shape geometry_t;
typedef std::vector<std::pair<int, TopoDS_Compound > > geometry_collection_t;

Expand Down
111 changes: 111 additions & 0 deletions tests/test_hdf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include "../voxelizer.h"
#include "../writer.h"
#include "../processor.h"

#include "H5Cpp.h"
#include <gtest/gtest.h>

#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <BRep_Builder.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepTools.hxx>

#ifdef WITH_IFC
#include <ifcparse/IfcFile.h>
#ifdef IFCOPENSHELL_05
#include <ifcgeom/IfcGeomIterator.h>
using namespace Ifc2x3;
#else
#include <ifcgeom_schema_agnostic/IfcGeomIterator.h>
#endif
#endif


#ifdef WIN32
#define DIRSEP "\\"
#else
#define DIRSEP "/"
#endif


TEST(HdfFileName, HDF) {


BRepPrimAPI_MakeBox mb(gp_Pnt(0, 0, 0), gp_Pnt(10, 10, 10));
BRepPrimAPI_MakeSphere s(gp_Pnt(10, 10, 10), 7);

auto x = s.Solid();

auto storage2 = new chunked_voxel_storage<bit_t>( 0, 0, 0, 1, 32, 32, 32, 32);
BRepTools breptools;

breptools.Write(x, "sphere.brep");

BRepMesh_IncrementalMesh(x, 0.001);
auto vox = voxelizer(x, storage2);
vox.Convert();

auto storage = new chunked_voxel_storage<bit_t>(0., 0., 0., 0.1, 200, 150, 10, 32);

{
BRepBuilderAPI_MakePolygon mp(gp_Pnt(1, 1, 2), gp_Pnt(16, 1, 2), gp_Pnt(16, 9.8, 2), gp_Pnt(1, 9.8, 2), true);
BRepBuilderAPI_MakeFace mf(mp.Wire());
TopoDS_Face face = mf.Face();

auto vox = voxelizer(face, storage);
vox.Convert();
}

const double dim = 0.1;
auto storage3 = new chunked_voxel_storage<bit_t>(-dim, -dim, -dim, dim, 100, 100, 100, 16);
BRepPrimAPI_MakeBox make_box(8., 8., 8.);
auto vox3 = voxelizer(make_box.Solid(), storage3);
vox3.Convert();

hdf_writer writer;
writer.SetVoxels(storage3);
writer.Write("multi_dim_vox.h5");

//std::ofstream fs("voxobj.obj");
//obj_export_helper oeh{ fs };
//storage2->obj_export(oeh, false, false);

// Write a 4D dataset

const H5std_string FILE_NAME("multidim.h5");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the remainder of this test do? Should we open multi_dim_vox.h5 with RDONLY and check whether the dimensions and ranks of the datasets make sense?

Or even better: let's say we compare storage3->count() with std::accumulate(dataset.read()) (oversimplified the last) that way we have an actual test with ASSERT_EQUAL.

const H5std_string DATASET_NAME("continuous_chunks");
const int NX = 32; // dataset dimensions
const int NY = 32;
const int NZ = 32;
const int NC = 3;

const int RANK = 4;
H5::H5File file(FILE_NAME, H5F_ACC_TRUNC);

hsize_t dimsf[4]; // dataset dimensions
dimsf[0] = NC;
dimsf[1] = NX;
dimsf[2] = NY;
dimsf[3] = NZ;

H5::DataSpace dataspace(RANK, dimsf);

H5::IntType datatype(H5::PredType::NATIVE_INT);
datatype.setOrder(H5T_ORDER_LE);

H5::DataSet dataset = file.createDataSet(DATASET_NAME, datatype, dataspace);

//std::vector<int> data;

//for (int i = 0; i < NX*NY*NZ*NC; i++) {
// data.push_back(0);
//}

//dataset.write(data.data(), H5::PredType::NATIVE_INT);

}
Loading