Skip to content

Commit 5659c44

Browse files
authored
Merge pull request #56 from jcupitt/main
Update to 1.0
2 parents 62d3580 + 34d8e96 commit 5659c44

25 files changed

+3622
-1976
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[*.{cpp,c,h}]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.py]
14+
indent_style = space
15+
indent_size = 4

.github/workflows/codespell.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
---
21
name: Codespell
32

4-
on:
5-
push:
6-
branches: [main]
7-
pull_request:
8-
branches: [main]
3+
on: [push, pull_request]
94

10-
permissions:
11-
contents: read
5+
permissions: {}
126

137
jobs:
148
codespell:

.github/workflows/run_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
- name: Install build and test dependencies (Windows)
4848
if: startsWith(matrix.os, 'windows')
49-
run: pip install meson
49+
run: pip install meson ninja
5050

5151
- name: Build and install library
5252
shell: bash

README.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
[![Build Status](https://github.com/ImagingDataCommons/libdicom/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/ImagingDataCommons/libdicom/actions)
1+
[![Build
2+
Status](https://github.com/ImagingDataCommons/libdicom/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/ImagingDataCommons/libdicom/actions)
23

34
# libdicom
45

@@ -8,19 +9,43 @@ C library and executable tools for reading DICOM files.
89

910
### Building from source
1011

11-
```none
12+
```shell
1213
meson setup --buildtype release builddir
1314
meson compile -C builddir
1415
meson install -C builddir
1516
```
16-
See [the installation documentation](https://libdicom.readthedocs.io/en/latest/installation.html) for build dependencies and installation options.
17+
See [the installation
18+
documentation](https://libdicom.readthedocs.io/en/latest/installation.html)
19+
for build dependencies and installation options.
1720

1821
### Printing the metadata of a DICOM file
1922

20-
```none
23+
```shell
2124
dcm-dump data/test_files/sm_image.dcm
2225
```
2326

27+
### Fetching a frame from a file
28+
29+
```shell
30+
dcm-getframe -o tile.raw data/test_files/sm_image.dcm 12
31+
```
32+
33+
### From Python
34+
35+
There's a sample Python binding here:
36+
37+
https://github.com/ImagingDataCommons/pylibdicom
38+
2439
## Documentation
2540

26-
User and developer guides as well as API documentation can be found at [libdicom.readthedocs.io](https://libdicom.readthedocs.io/en/latest/).
41+
User and developer guides as well as API documentation can be found at
42+
[libdicom.readthedocs.io](https://libdicom.readthedocs.io/en/latest/).
43+
44+
# Thanks
45+
46+
Development of this library was supported by [NCI Imaging Data
47+
Commons](https://imaging.datacommons.cancer.gov/), and has been funded in
48+
whole or in part with Federal funds from the National Cancer Institute,
49+
National Institutes of Health, under Task Order No. HHSN26110071 under
50+
Contract No. HHSN261201500003l.
51+

TODO

Lines changed: 0 additions & 65 deletions
This file was deleted.

doc/source/api.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
API documentation
22
-----------------
33

4-
.. c:autodoc:: dicom.h
4+
.. c:autodoc:: dicom/dicom.h

doc/source/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os
1515
import sys
1616
from hawkmoth.util import readthedocs
17+
from hawkmoth.util import compiler
1718
from clang.cindex import Config as clang_config
1819

1920
# -- Project information -----------------------------------------------------
@@ -22,7 +23,6 @@
2223
copyright = '2021, Markus D. Herrmann'
2324
author = 'Markus D. Herrmann'
2425

25-
2626
# -- General configuration ---------------------------------------------------
2727

2828
primary_domain = 'c'
@@ -57,8 +57,11 @@
5757

5858
# -- Hawkmoth extension ------------------------------------------------------
5959

60-
cautodoc_root = os.path.abspath('../../include')
60+
hawkmoth_root = os.path.abspath('../../include')
6161
readthedocs.clang_setup()
62+
hawkmoth_clang = compiler.get_include_args()
63+
# we need build to get version.h
64+
hawkmoth_clang.append(f"-I{os.path.abspath('../../build')}")
6265
if sys.platform == 'darwin':
6366
lib_search_dirs = [
6467
'/usr/lib',

doc/source/contributing.rst

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Contributing
44
Coding style
55
++++++++++++
66

7-
Source code should be written following the `K&R (Kernighan & Ritchie) style <https://en.wikipedia.org/wiki/Indentation_style#K&R_style>`_ with a few modifications.
7+
Source code should be written following the `K&R (Kernighan & Ritchie)
8+
style <https://en.wikipedia.org/wiki/Indentation_style#K&R_style>`_ with
9+
a few modifications.
810

911
* Line length: max 80 characters
1012

@@ -13,68 +15,107 @@ Source code should be written following the `K&R (Kernighan & Ritchie) style <ht
1315
* Braces:
1416

1517
- Functions: opening brace at next line
18+
1619
- Control statements (mandatory): opening brace at same line
1720

1821
* Spacing:
1922

2023
- 2 lines between function definitions
21-
- 1 line between logical blocks within functions (and between variable declarations and definitions)
24+
25+
- 1 line between logical blocks within functions (and between variable
26+
declarations and definitions)
2227

2328
* Comments:
2429

25-
- Documentation of functions and other symbols: balanced, multi-line ``/** ... */`` comments in `reStructuredText <https://docutils.sourceforge.io/rst.html>`_ format using `field lists <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#field-lists>`_ ``:param:`` and ``:return:`` to document function parameters and return values, respectively, and ``:c:member:``, ``:c:func:``, ``:c:macro:``, ``:c:struct:``, ``:c:union:``, ``:c:enum:``, ``:c:enumerator:``, ``:c:type:``, ``:c:expr:``, ``:c:var:`` from the `Sphinx C domain <https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#the-c-domain>`_ directive to `cross-reference other C language constructs <https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cross-referencing-c-constructs>`_ or to insert a C expression as inline code.
30+
- Documentation of functions and other symbols: balanced,
31+
multi-line ``/** ... */`` comments in `reStructuredText
32+
<https://docutils.sourceforge.io/rst.html>`_ format using `field lists
33+
<https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#field-lists>`_
34+
``:param:`` and ``:return:`` to document function parameters and return
35+
values, respectively, and ``:c:member:``, ``:c:func:``, ``:c:macro:``,
36+
``:c:struct:``, ``:c:union:``, ``:c:enum:``, ``:c:enumerator:``,
37+
``:c:type:``, ``:c:expr:``, ``:c:var:`` from the `Sphinx C domain
38+
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#the-c-domain>`_
39+
directive to `cross-reference other C language constructs
40+
<https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#cross-referencing-c-constructs>`_
41+
or to insert a C expression as inline code.
2642

2743
- Inline comments in function body: single-line ``//`` C++ style comments
2844

2945
* Naming conventions:
3046

31-
- Data structures (``struct`` or ``enum``) and types are named using upper camel case (e.g., ``DcmDataSet``), while functions are named using all lower case with underscores (e.g., ``dcm_dataset_create()``).
47+
- Data structures (``struct`` or ``enum``) and types are named using
48+
upper camel case (e.g., ``DcmDataSet``), while functions are named using
49+
all lower case with underscores (e.g., ``dcm_dataset_create()``).
3250

33-
- Names of ``external`` functions, data structures, and types that are declared in the ``dicom.h`` header file are prefixed with ``dcm_`` or ``Dcm``. Names of ``static`` functions, types, or data structures declared in ``*.c`` files are never prefixed.
51+
- Names of ``external`` functions, data structures, and types that are
52+
declared in the ``dicom.h`` header file are prefixed with ``dcm_`` or
53+
``Dcm``. Names of ``static`` functions, types, or data structures declared
54+
in ``*.c`` files are never prefixed.
3455

3556

3657
Interface
3758
+++++++++
3859

39-
The library exposes an "object-oriented" application programming interface (API), which provides data structures and functions to store, access, and manipulate the data.
60+
The library exposes an "object-oriented" application programming interface
61+
(API), which provides data structures and functions to store, access,
62+
and manipulate the data.
4063

4164
To facilitate portability, the ``dicom.h`` header file is restricted to
4265

43-
* C99 version of the standard (C89 + Boolean type from ``stdbool.h`` + fixed-width integer types from ``stdint.h``/``inttypes.h``)
66+
* C99 version of the standard (C89 + Boolean type from ``stdbool.h`` +
67+
fixed-width integer types from ``stdint.h``/``inttypes.h``)
68+
4469
* Opaque data types
45-
* Clear, exact-width integer types (``int16_t``, ``int32_t``, ``int64_t``, ``uint16_t``, ``uint32_t``, and ``uint64_t``)
70+
71+
* Clear, exact-width integer types (``int16_t``, ``int32_t``, ``int64_t``,
72+
``uint16_t``, ``uint32_t``, and ``uint64_t``)
73+
4674
* Minimal use of enums
4775

4876

4977
Implementation
5078
++++++++++++++
5179

52-
The ``dicom-data.c`` (Part 5), ``dicom-dict.c`` (Part 6), and ``dicom-file.c`` (Part 10) are implemented based on the C11 version of the standard.
80+
The ``dicom-data.c`` (Part 5), ``dicom-dict.c`` (Part 6), and ``dicom-file.c``
81+
and ``dicom-parse.c`` (Part 10) are implemented based on the C11 version
82+
of the standard.
5383

54-
The Data Set and Sequence data structures are implemented using the battletested `uthash <https://troydhanson.github.io/uthash>`_ headers.
84+
The Data Set and Sequence data structures are implemented using the
85+
battletested `uthash <https://troydhanson.github.io/uthash>`_ headers.
5586

5687

5788
Documentation
5889
+++++++++++++
5990

60-
Documentation is written in `reStructuredText <https://docutils.sourceforge.io/rst.html>`_ format and HTML documents are autogenerated using `Sphinx <https://www.sphinx-doc.org/en/master/>`_.
61-
API documentation is automatically extracted from the comments in the source code in the ``dicom.h`` header file via the `Hawkmoth Sphinx C Autodoc <https://hawkmoth.readthedocs.io/en/latest/index.html>`_ extension, which relies on `Clang <https://libclang.readthedocs.io/en/latest/index.html>`_ to parse C code.
91+
Documentation is written in `reStructuredText
92+
<https://docutils.sourceforge.io/rst.html>`_ format and HTML documents
93+
are autogenerated using `Sphinx <https://www.sphinx-doc.org/en/master/>`_.
94+
API documentation is automatically extracted from the comments in the source
95+
code in the ``dicom.h`` header file via the `Hawkmoth Sphinx C Autodoc
96+
<https://hawkmoth.readthedocs.io/en/latest/index.html>`_ extension, which
97+
relies on `Clang <https://libclang.readthedocs.io/en/latest/index.html>`_
98+
to parse C code.
6299

63-
Documentation files are located under the ``doc/source`` directory of the repository.
64-
To build the documentation, install ``libclang`` development headers and the Python ``venv`` module, then build with ``meson``:
100+
Documentation files are located under the ``doc/source`` directory of the
101+
repository. To build the documentation, install ``libclang`` development
102+
headers and the Python ``venv`` module, then build with ``meson``:
65103

66104
meson compile -C builddir html
67105

68-
The generated documentation files will then be located under the ``builddir/html`` directory.
69-
The ``builddir/html/index.html`` HTML document can be rendered in the web browser.
106+
The generated documentation files will then be located under the
107+
``builddir/html`` directory. The ``builddir/html/index.html`` HTML document
108+
can be rendered in the web browser.
70109

71110

72111
Testing
73112
+++++++
74113

75-
Unit test cases are defined and run using `check <https://github.com/libcheck/check>`_.
114+
Unit test cases are defined and run using `check
115+
<https://github.com/libcheck/check>`_.
76116

77-
Test files are located under ``/tests`` and can be built and run using ``meson``::
117+
Test files are located under ``/tests`` and can be built and run using
118+
``meson``::
78119

79120
meson test -C builddir
80121

@@ -87,8 +128,8 @@ For example::
87128

88129
valgrind --leak-check=full dcm-dump data/test_files/sm_image.dcm
89130

90-
91-
Unit testing and dynamic analysis can also be performed using the provided `Dockerfile` (located in the root of the repository)::
131+
Unit testing and dynamic analysis can also be performed using the provided
132+
`Dockerfile` (located in the root of the repository)::
92133

93134
docker build -t dcm-testing .
94135
docker run dcm-testing

doc/source/installation.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Installation
44
Building
55
++++++++
66

7-
The library and executables can be built using `Meson <https://mesonbuild.com/>`_:
7+
The library and executables can be built using `Meson
8+
<https://mesonbuild.com/>`_:
89

910
.. code:: bash
1011
@@ -45,15 +46,18 @@ Build for development and debugging:
4546

4647
.. code:: bash
4748
48-
CFLAGS="-DDEBUG" meson setup builddir
49+
meson setup builddir --buildtype debug
4950
meson compile -C builddir
5051
5152
5253
Optional dependencies
5354
+++++++++++++++++++++
5455

55-
This package uses `check <https://libcheck.github.io/check/>`_ for unit testing and `uthash <https://troydhanson.github.io/uthash/>`_ for data structures.
56-
It will automatically download and build both libraries, or can use system copies.
56+
This package uses `check <https://libcheck.github.io/check/>`_ for unit
57+
testing and `uthash <https://troydhanson.github.io/uthash/>`_ for data
58+
structures. It will automatically download and build both libraries,
59+
or can use system copies.
60+
5761
To install system copies:
5862

5963
On Debian-based Linux distributions:

0 commit comments

Comments
 (0)