.gear/rules | 3 + .gear/tags/list | 1 + .gear/vxl.spec | 144 +++++++++++++++++++++++++++++ config/cmake/Modules/FindDCMTK.cmake | 2 +- core/vil/file_formats/vil_dicom.cxx | 55 ++++++----- core/vil/file_formats/vil_dicom_stream.cxx | 26 +++--- core/vil/file_formats/vil_dicom_stream.h | 16 ++-- v3p/netlib/CMakeLists.txt | 2 + 8 files changed, 205 insertions(+), 44 deletions(-) diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000000..9bd891db25 --- /dev/null +++ b/.gear/rules @@ -0,0 +1,3 @@ +tar: v@version@:. +spec: .gear/vxl.spec +diff: v@version@:. . name=@name@-@version@-alt.patch diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 0000000000..0af2bb58a3 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +ecacd8cb08773d1dc100605e6d634706d34c9fc5 v3.5.0 diff --git a/.gear/vxl.spec b/.gear/vxl.spec new file mode 100644 index 0000000000..f47aeaf4c5 --- /dev/null +++ b/.gear/vxl.spec @@ -0,0 +1,144 @@ +%define _unpackaged_files_terminate_build 1 + +# documentation build sometimes generates non-identical files +%def_without docs + +# TODO: remove later this fix for documentation +#%%define _cmake__builddir BUILD + +%define openjpeg2_sover 2 +%define ver_maj 3 +%define sover 3.5 +%define libvxl libvxl%ver_maj + +Name: libvxl +Version: 3.5.0 +Release: alt1 + +Group: System/Libraries +Summary: C++ Libraries for Computer Vision Research and Implementation +License: BSD +Url: https://vxl.github.io/ + +# https://github.com/vxl/vxl.git +Source: %name-%version.tar +Patch1: %name-%version-alt.patch + +BuildRequires: gcc-c++ cmake libdcmtk-devel dcmtk libtiff-devel libjpeg-devel libssl-devel rpm-build-ninja +BuildRequires: libpng-devel libxml2-devel libgeotiff-devel +%if_with docs +BuildRequires: doxygen /usr/bin/dot texi2html +%endif + +%define _description \ +VXL (the Vision-something-Libraries) is a collection of C++ libraries designed \ +for computer vision research and implementation. It was created from TargetJr \ +and the IUE with the aim of making a light, fast and consistent system. VXL is \ +written in ANSI/ISO C++ and is designed to be portable over many platforms. + +%description +%_description + +%package -n %libvxl +Summary: Shared libraries for VXL +Group: System/Libraries +# dcmtk required, because its contains DICOM tags list +Requires: dcmtk + +%description -n %libvxl +This package contains shared libraries for VXL. +%_description + +%package devel +Summary: Headers for VXL +Group: Development/C++ + +%description devel +This package contains development files for VXL. +%_description + +%if_with docs +%package doc +Summary: Documentation for VXL +Group: Documentation +BuildArch: noarch + +%description doc +This package contains documentation for VXL. +%_description +%endif + +%prep +%setup +%patch1 -p1 + +%build +%cmake -GNinja \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DVXL_INSTALL_LIBRARY_DIR=%_libdir \ + -DVXL_INSTALL_ARCHIVE_DIR=%_libdir \ + -DVXL_FORCE_B3P_EXPAT:BOOL=OFF \ + -DVXL_FORCE_V3P_DCMTK:BOOL=OFF \ + -DVXL_FORCE_V3P_GEOTIFF:BOOL=OFF \ + -DVXL_FORCE_V3P_JPEG:BOOL=OFF \ + -DVXL_FORCE_V3P_PNG:BOOL=OFF \ + -DVXL_FORCE_V3P_TIFF:BOOL=OFF \ + -DVXL_FORCE_V3P_ZLIB:BOOL=OFF \ + -DVXL_USING_NATIVE_ZLIB=ON \ + -DVXL_USING_NATIVE_JPEG=ON \ + -DVXL_USING_NATIVE_PNG=ON \ + -DVXL_USING_NATIVE_TIFF=ON \ + -DVXL_USING_NATIVE_GEOTIFF=ON \ + -DBUILD_TESTING:BOOL=OFF \ + -DVNL_CONFIG_LEGACY_METHODS=ON \ +%if_with docs + -DVXL_BUILD_DOCUMENTATION=ON \ +%endif + -DVXL_LEGACY_FUTURE_REMOVE:BOOL=OFF \ + %nil + +%ninja_build -C "%_cmake__builddir" + +%if_with docs +%ninja_build -C "%_cmake__builddir" build_doxygen_doc +%endif + +%install +%ninja_install -C "%_cmake__builddir" + +%files -n %libvxl +%_libdir/lib*.so.%sover +%_libdir/lib*.so.%sover.* +%_libdir/libopenjpeg2.so.%openjpeg2_sover.* +%dir %_datadir/vxl/ + +%files devel +%_libdir/lib*.so +%_includedir/vxl/ +%_datadir/vxl/cmake/ + +%if_with docs +%files doc +%doc %_cmake__builddir/doxy/html +%endif + +%changelog +* Mon Apr 17 2023 Elizaveta Morozova 3.5.0-alt1 +- New version +- Build using ninja-build +- Include DCMTK-3.6.4 API update + +* Wed Sep 22 2021 Slava Aseev 2.0.2-alt4 +- Include missing "limits" std header + +* Fri May 14 2021 Aleksei Nikiforov 2.0.2-alt3 +- Backported from upstream changes required by new ITK. +- Fixed build with new cmake macros. +- Disabled building documentation. + +* Tue Jul 16 2019 Aleksei Nikiforov 2.0.2-alt2 +- Fixed generated header installation. +- Enabled deprecated functions. + +* Mon Dec 24 2018 Slava Aseev 2.0.2-alt1 +- Initial build for ALT diff --git a/config/cmake/Modules/FindDCMTK.cmake b/config/cmake/Modules/FindDCMTK.cmake index b70fbfd8e9..1e4e43d861 100644 --- a/config/cmake/Modules/FindDCMTK.cmake +++ b/config/cmake/Modules/FindDCMTK.cmake @@ -36,7 +36,7 @@ else() ${dcmtk_SOURCE_DIR}/dcmdata/include ${dcmtk_SOURCE_DIR}/dcmimgle/include ) - set( DCMTK_LIBRARIES dcmtk ) + set( DCMTK_LIBRARIES dcmdata dcmimgle ofstd ) endif() diff --git a/core/vil/file_formats/vil_dicom.cxx b/core/vil/file_formats/vil_dicom.cxx index 5fcdd42287..0650edb080 100644 --- a/core/vil/file_formats/vil_dicom.cxx +++ b/core/vil/file_formats/vil_dicom.cxx @@ -27,13 +27,13 @@ # include "vil/vil_pixel_format.h" # include "vil/vil_exception.h" -# include -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include +# include # include "vil_dicom_stream.h" // @@ -108,8 +108,9 @@ static void read_header(DcmObject * dataset, vil_dicom_header_info & i); static void -read_pixels_into_buffer(DcmPixelData * pixels, +read_pixels_into_buffer(DiDocument* doc, unsigned num_samples, + unsigned nplanes, Uint16 alloc, Uint16 stored, Uint16 high, @@ -119,7 +120,6 @@ read_pixels_into_buffer(DcmPixelData * pixels, vil_memory_chunk_sptr & out_buf, vil_pixel_format & out_format); - vil_dicom_image::vil_dicom_image(vil_stream * vs) : pixels_(0) { @@ -209,12 +209,15 @@ vil_dicom_image::vil_dicom_image(vil_stream * vs) else { assert(stack.top()->ident() == EVR_PixelData); - pixels = static_cast(stack.top()); } } + + DiDocument doc(&dset, EXS_Unknown); + pixels = doc.getPixelData(); + unsigned num_samples = ni() * nj() * nplanes(); read_pixels_into_buffer( - pixels, num_samples, bits_alloc, bits_stored, high_bit, pixel_rep, slope, intercept, pixel_buf, pixel_format); + &doc, num_samples, nplanes(), bits_alloc, bits_stored, high_bit, pixel_rep, slope, intercept, pixel_buf, pixel_format); } // Create an image resource to manage the pixel buffer @@ -1035,34 +1038,36 @@ namespace template void convert_src_type(InT const *, - DcmPixelData * pixels, + DiDocument *document, unsigned num_samples, + unsigned nplanes, Uint16 alloc, Uint16 stored, Uint16 high, Uint16 rep, - DiInputPixel *& pixel_data, - vil_pixel_format & act_format) + DiInputPixel *&pixel_data, + vil_pixel_format &act_format) { + Uint32 firstFragment = 0; if (rep == 0 && stored <= 8) { act_format = VIL_PIXEL_FORMAT_BYTE; - pixel_data = new DiInputPixelTemplate(pixels, alloc, stored, high, 0, num_samples); + pixel_data = new DiInputPixelTemplate( document, alloc, stored, high, 0, num_samples, nplanes, nullptr, firstFragment ); } else if (rep == 0 && stored <= 16) { act_format = VIL_PIXEL_FORMAT_UINT_16; - pixel_data = new DiInputPixelTemplate(pixels, alloc, stored, high, 0, num_samples); + pixel_data = new DiInputPixelTemplate( document, alloc, stored, high, 0, num_samples, nplanes, nullptr, firstFragment ); } else if (rep == 1 && stored <= 8) { act_format = VIL_PIXEL_FORMAT_SBYTE; - pixel_data = new DiInputPixelTemplate(pixels, alloc, stored, high, 0, num_samples); + pixel_data = new DiInputPixelTemplate( document, alloc, stored, high, 0, num_samples, nplanes, nullptr, firstFragment ); } else if (rep == 1 && stored <= 16) { act_format = VIL_PIXEL_FORMAT_INT_16; - pixel_data = new DiInputPixelTemplate(pixels, alloc, stored, high, 0, num_samples); + pixel_data = new DiInputPixelTemplate( document, alloc, stored, high, 0, num_samples, nplanes, nullptr, firstFragment ); } } @@ -1095,8 +1100,9 @@ swap_shorts(unsigned short * ip, unsigned short * op, int count) } # endif // MIXED_ENDIAN static void -read_pixels_into_buffer(DcmPixelData * pixels, +read_pixels_into_buffer(DiDocument* doc, unsigned num_samples, + unsigned nplanes, Uint16 alloc, Uint16 stored, Uint16 high, @@ -1106,6 +1112,7 @@ read_pixels_into_buffer(DcmPixelData * pixels, vil_memory_chunk_sptr & out_buf, vil_pixel_format & out_format) { + // This will be the "true" pixel buffer type after the overlay // planes are removed and the pixel bits shifted to the lowest bits // of the bytes. @@ -1117,14 +1124,14 @@ read_pixels_into_buffer(DcmPixelData * pixels, // Make sure pixel_data is deleted before this function exits! // DiInputPixel * pixel_data = 0; - if (pixels->getVR() == EVR_OW) - { - convert_src_type((Uint16 *)0, pixels, num_samples, alloc, stored, high, rep, pixel_data, act_format); + if ( doc->getPixelData()->getVR() == EVR_OW ) { + convert_src_type((Uint16 *) 0, doc, num_samples, nplanes, alloc, stored, high, rep, pixel_data, act_format); } else { - convert_src_type((Uint8 *)0, pixels, num_samples, alloc, stored, high, rep, pixel_data, act_format); + convert_src_type((Uint8 *) 0, doc, num_samples, nplanes, alloc, stored, high, rep, pixel_data, act_format); } + # ifdef MIXED_ENDIAN # ifdef NO_OFFSET slope = 1; @@ -1147,7 +1154,7 @@ read_pixels_into_buffer(DcmPixelData * pixels, } // The data has been copied and converted. Release the source. - pixels->clear(); + doc->getPixelData()->clear(); // Now, the actual buffer is good, or else we need to rescale // diff --git a/core/vil/file_formats/vil_dicom_stream.cxx b/core/vil/file_formats/vil_dicom_stream.cxx index e1f72efc82..87a722aaf3 100644 --- a/core/vil/file_formats/vil_dicom_stream.cxx +++ b/core/vil/file_formats/vil_dicom_stream.cxx @@ -4,7 +4,7 @@ # include "vil_dicom_stream.h" # include "vil/vil_stream.h" -# include +# include # include # ifdef _MSC_VER @@ -42,14 +42,14 @@ vil_dicom_stream_producer::status() const OFBool -vil_dicom_stream_producer::eos() const +vil_dicom_stream_producer::eos() { return vs_->tell() >= vs_->file_size(); } -Uint32 -vil_dicom_stream_producer::avail() const +offile_off_t +vil_dicom_stream_producer::avail() { vil_streampos n = vs_->file_size() - vs_->tell(); assert(n >= 0); @@ -57,13 +57,13 @@ vil_dicom_stream_producer::avail() const // apparently dicom streams only support 32 bit positions // whereas vil_streams now support 64 bit positions (when // available) - assert(n <= (vil_streampos)std::numeric_limits::max()); - return (Uint32)n; + assert( n <= (vil_streampos)std::numeric_limits::max() ); + return (offile_off_t)n; } -Uint32 -vil_dicom_stream_producer::read(void * buf, Uint32 buflen) +offile_off_t +vil_dicom_stream_producer::read( void *buf, offile_off_t buflen ) { vil_streampos n = vs_->read(buf, buflen); assert(n >= 0); @@ -71,13 +71,13 @@ vil_dicom_stream_producer::read(void * buf, Uint32 buflen) // apparently dicom streams only support 32 bit positions // whereas vil_streams now support 64 bit positions (when // available) - assert(n <= (vil_streampos)std::numeric_limits::max()); - return (Uint32)n; + assert( n <= (vil_streampos)std::numeric_limits::max() ); + return (offile_off_t)n; } -Uint32 -vil_dicom_stream_producer::skip(Uint32 skiplen) +offile_off_t +vil_dicom_stream_producer::skip(offile_off_t skiplen) { vs_->seek(vs_->tell() + skiplen); return skiplen; @@ -85,7 +85,7 @@ vil_dicom_stream_producer::skip(Uint32 skiplen) void -vil_dicom_stream_producer::putback(Uint32 num) +vil_dicom_stream_producer::putback(offile_off_t num) { vs_->seek(vs_->tell() - (long int)num); } diff --git a/core/vil/file_formats/vil_dicom_stream.h b/core/vil/file_formats/vil_dicom_stream.h index 79a639639a..8115184289 100644 --- a/core/vil/file_formats/vil_dicom_stream.h +++ b/core/vil/file_formats/vil_dicom_stream.h @@ -4,7 +4,8 @@ // \file // \author Amitha Perera -#include +#include +#include class vil_stream; @@ -18,11 +19,11 @@ class vil_dicom_stream_producer virtual OFBool good() const; virtual OFCondition status() const; - virtual OFBool eos() const; - virtual Uint32 avail() const; - virtual Uint32 read(void *buf, Uint32 buflen); - virtual Uint32 skip(Uint32 skiplen); - virtual void putback(Uint32 num); + OFBool eos() override; + offile_off_t avail() override; + offile_off_t read(void *buf, offile_off_t buflen) override; + offile_off_t skip(offile_off_t skiplen) override; + void putback(offile_off_t num) override; private: vil_stream* vs_; @@ -43,6 +44,9 @@ class vil_dicom_stream_factory { return new vil_dicom_stream_factory(*this); } + DcmInputStreamFactoryType ident() const override { + return DFT_DcmInputFileStreamFactory; + } private: vil_stream* vs_; diff --git a/v3p/netlib/CMakeLists.txt b/v3p/netlib/CMakeLists.txt index 1c3df5db0c..23fc69850a 100644 --- a/v3p/netlib/CMakeLists.txt +++ b/v3p/netlib/CMakeLists.txt @@ -13,6 +13,8 @@ vxl_add_library( DISABLE_MSVC_MP ) +set_target_properties(${VXL_LIB_PREFIX}netlib PROPERTIES PREFIX "libv3px_") + if(UNIX) target_link_libraries( ${VXL_LIB_PREFIX}netlib m ) endif()