Skip to content
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

Overflow issues in Vol/Longvol readers #1637

Merged
merged 13 commits into from
Mar 21, 2022
2 changes: 1 addition & 1 deletion .github/workflows/buildAndDocumentation-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
TESTBLACKLIST: "(testCompressedVolWriter|testLongvol|testLinearStructure)"
TESTBLACKLIST: "(testLongvol|testCompressedVolWriter|testLinearStructure)"
CONFIG_GLOBAL: -DBUILD_EXAMPLES=true -DBUILD_TESTING=true -DDGTAL_RANDOMIZED_TESTING_THRESHOLD=25
CONFIG_LINUX: -DWITH_MAGICK=true -DWITH_GMP=true -DWITH_FFTW3=true -DWARNING_AS_ERROR=ON -DWITH_HDF5=true -DWITH_QGLVIEWER=true -DWITH_CAIRO=true -DWITH_EIGEN=true -DWITH_ITK=true -DDGTAL_ENABLE_FLOATING_POINT_EXCEPTIONS=true
CONFIG_MAC: -DWITH_EIGEN=true -DWITH_GMP=true
Expand Down
7 changes: 4 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
## Changes
- *Image*
- Bugfix in the SpaceND and HyperRectDomain classes to allow very large extent (e.g. >1024^3)
(David Coeurjolly, [#16XX](https://github.com/DGtal-team/DGtal/pull/16XX))
(David Coeurjolly, [#1636](https://github.com/DGtal-team/DGtal/pull/1636))
- Improved ITK image selection in ImageSelector and add ITK xx.gz an other
format support. New option to keep set domain or to compute current bounding
box of elements of the set in ImageFromSet.
Expand All @@ -69,7 +69,6 @@
all co-cycling sites (Robin Lamy, David Coeurjolly, Isabelle
Sivignon [#1605](https://github.com/DGtal-team/DGtal/pull/1605))


- *Build*
- Continuous integration does not use Travis anymore but Github
Actions. (David Coeurjolly, [#1591](https://github.com/DGtal-team/DGtal/pull/1591))
Expand Down Expand Up @@ -122,6 +121,8 @@
(Bertrand Kerautret, [#1610](https://github.com/DGtal-team/DGtal/pull/1610)
- Fix compilation issue in MeshReader compilation.
(Bertrand Kerautret, [#1611](https://github.com/DGtal-team/DGtal/pull/1611)
- Minor fixes in VolReader and LongVolReader to be able to load large vol files.
(David Coeurjolly, [#1637](https://github.com/DGtal-team/DGtal/pull/1637))

- *Geometry package*
- the following changes have been made to fix a bug in `examplePlaneProbingSurfaceLocalEstimator`:
Expand All @@ -131,7 +132,7 @@
trivial normal vector if it has been set to 'False'.
- in `PlaneProbingParallelepipedEstimator`: `isValid` does not call the `isValid` method of the
delegate, but only checks the relevant parts (which have been pushed in to separate methods).
(Tristan Roussillon, [#1607](https://github.com/DGtal-team/DGtal/pull/1607))
(Tristan Roussillon, [#1607](https://github.com/DGtal-team/DGtal/pull/1607))
- Fixing issue with the automatic deploy of the "nightly" documentation.
(Davi Coeurjolly, [#1620](https://github.com/DGtal-team/DGtal/pull/1620)

Expand Down
12 changes: 6 additions & 6 deletions src/DGtal/io/readers/LongvolReader.ih
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ DGtal::LongvolReader<T, TFunctor>::importLongvol( const std::string & filename,
{
T image( domain);

long count = 0;
size_t count = 0;
DGtal::uint64_t val=0;

typename T::Domain::ConstIterator it = domain.begin();
long int total = sx * sy * sz ;
long int totalbytes = total * sizeof(val);
size_t total = sx * sy * sz ;
size_t totalbytes = total * sizeof(val);
std::stringstream main;

unsigned char c_temp;
Expand All @@ -194,7 +194,7 @@ DGtal::LongvolReader<T, TFunctor>::importLongvol( const std::string & filename,

if ( count != totalbytes )
{
trace.error() << "LongvolReader: can't read file (raw data) !\n";
trace.error() << "LongvolReader: can't read file (raw data). I read "<<count<<" bytes instead of "<<total<<".\n";
throw dgtalexception;
}

Expand All @@ -207,7 +207,7 @@ DGtal::LongvolReader<T, TFunctor>::importLongvol( const std::string & filename,
in.push(main);
boost::iostreams::copy(in, uncompressed);
//Apply to the image structure
for(auto i=0; i < total; ++i)
for(size_t i=0; i < total; ++i)
{
read_word(uncompressed , val);
image.setValue(( *it ), aFunctor(val) );
Expand All @@ -217,7 +217,7 @@ DGtal::LongvolReader<T, TFunctor>::importLongvol( const std::string & filename,
else
{
//Apply to the image structure
for(auto i=0; i < total; ++i)
for(size_t i=0; i < total; ++i)
{
read_word(main, val);
image.setValue(( *it ), aFunctor(val) );
Expand Down
10 changes: 5 additions & 5 deletions src/DGtal/io/readers/VolReader.ih
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ DGtal::VolReader<T, TFunctor>::importVol( const std::string & filename,
{
T image( domain );

long count = 0;
size_t count = 0;
unsigned char val;
typename T::Domain::ConstIterator it = domain.begin();
long int total = sx * sy * sz;
size_t total = sx * sy * sz;
std::stringstream main;

//main read loop
Expand All @@ -206,7 +206,7 @@ DGtal::VolReader<T, TFunctor>::importVol( const std::string & filename,

if ( count != total )
{
trace.error() << "VolReader: can't read file (raw data) !\n";
trace.error() << "VolReader: can't read file (raw data). I read "<<count<<" bytes instead of "<<total<<".\n";
throw dgtalexception;
}

Expand All @@ -219,7 +219,7 @@ DGtal::VolReader<T, TFunctor>::importVol( const std::string & filename,
in.push(main);
boost::iostreams::copy(in, uncompressed);
//Apply to the image structure
for(auto i=0; i < total; ++i)
for(size_t i=0; i < total; ++i)
{
val = uncompressed.get();
image.setValue(( *it ), aFunctor(val) );
Expand All @@ -229,7 +229,7 @@ DGtal::VolReader<T, TFunctor>::importVol( const std::string & filename,
else
{
//Apply to the image structure
for(auto i=0; i < total; ++i)
for(size_t i=0; i < total; ++i)
{
val = main.get();
image.setValue(( *it ), aFunctor(val) );
Expand Down
1 change: 0 additions & 1 deletion tests/io/testLongvol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "DGtal/io/readers/LongvolReader.h"

///////////////////////////////////////////////////////////////////////////////

using namespace std;
using namespace DGtal;

Expand Down
1 change: 0 additions & 1 deletion tests/io/writers/testCompressedVolWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
///////////////////////////////////////////////////////////////////////////////

using namespace std;
using namespace DGtal;
using namespace Z3i;
Expand Down
2 changes: 1 addition & 1 deletion wrap/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ stages:
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
python -m pip install cmake
python -m pip install ninja
python -m pip install -r requirements-deploy.txt
python -m pip install scikit-build
python setup.py bdist_wheel --build-type Release -G Ninja -- -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DBOOST_ROOT:PATH=$(DEPENDENCIES_BUILD_DIR)/boost-build -DZLIB_ROOT:PATH=$(DEPENDENCIES_BUILD_DIR)/zlib
workingDirectory: '$(Build.SourcesDirectory)\wrap\deploy'
displayName: 'Build project'
Expand Down
2 changes: 1 addition & 1 deletion wrap/deploy/deploy_macos_one_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "$(python --version)"
python -m pip install cmake
python -m pip install ninja
python -m pip install delocate
python -m pip install -r $script_dir/requirements-deploy.txt
python -m pip install scikit-build


pushd ${script_dir}
Expand Down
3 changes: 1 addition & 2 deletions wrap/deploy/manylinux-build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ for PYBIN in "${PYBINARIES[@]}"; do

# Remove when scikit-build includes cmake_target PR:
# https://github.com/scikit-build/scikit-build/pull/477
${PYBIN}/python -m pip uninstall scikit-build -y
${PYBIN}/python -m pip install -r requirements-deploy.txt
${PYBIN}/python -m pip install scikit-build -y

# TODO: Switch BOOST_ROOT to these two when CMake is at least 3.15 and remove Boost_ROOT
# -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \
Expand Down