Skip to content

Commit 4d7636f

Browse files
authored
Merge pull request #7 from VolumeGraphics/mixed_project_support
Add mixed project support, unify different project types
2 parents 3dca07c + 7670462 commit 4d7636f

13 files changed

Lines changed: 85 additions & 85 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ that point into a [vg-data] folder using the same name as the .xvgi file will be
4545
the [vg-data] folder next to the .xvgi file when it is loaded. Organizing and referencing data this way ensures that
4646
.xvgi files and their associated [vg-data] folder can be moved and copied around easily.
4747

48+
![Image](docs/images/folder_and_file.png)
49+
4850
# Using .xvgi files
4951
VG software products starting from 2025.1 version are able to load these files, and support their use in
5052
* Open
@@ -63,9 +65,6 @@ data.
6365
> myVGL can not open .xvgi files. A licensed application needs to be used to turn the .xvgi file into a .vgl file, which
6466
> can then be viewed in myVGL in the usual way.
6567
66-
67-
![Image](docs/images/folder_and_file.png)
68-
6968
# Requirements
7069

7170
Requires Python 3.9 or newer.

examples/manual_setup/manual_setup.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
import shutil
55
from pathlib import Path
66

7-
from vg_nde_sdk.projects import VolumeProjectDescription
7+
from vg_nde_sdk.projects import ProjectDescription
88
from vg_nde_sdk.sections import (
99
ComponentInfoSection,
1010
ManufacturerInfoSection,
11+
MeshFormat,
12+
MeshSection,
13+
MeshSectionHolder,
14+
MeshUnit,
1115
ScanInfoSection,
1216
Vector3f,
1317
Vector3i,
@@ -19,6 +23,7 @@
1923
VolumeSection,
2024
VolumeSectionHolder,
2125
)
26+
from vg_nde_sdk.sections.mesh import MeshMetaInfoContainer
2227
from vg_nde_sdk.serializers import xvgi
2328

2429
THIS_DIR = Path(__file__).parent
@@ -37,6 +42,12 @@ def main():
3742
volumeFilePath,
3843
)
3944

45+
meshFilePath = targetVGDataFolderPath / "engine.stl"
46+
shutil.copy(
47+
os.path.dirname(os.path.abspath(__file__)) + "\\..\\meshes\\data\\engine.stl",
48+
meshFilePath,
49+
)
50+
4051
block_section = VolumeFileSection(
4152
FileName=volumeFilePath,
4253
FileFileFormat=VolumeFileFormat.Gzip,
@@ -67,7 +78,7 @@ def main():
6778
),
6879
)
6980

70-
project = VolumeProjectDescription(
81+
project = ProjectDescription(
7182
volumes=VolumeSectionHolder(
7283
[
7384
VolumeSection(
@@ -78,6 +89,16 @@ def main():
7889
)
7990
]
8091
),
92+
meshes=MeshSectionHolder(
93+
[
94+
MeshSection(
95+
FileName=meshFilePath,
96+
MeshFormat=MeshFormat.STL,
97+
MeshUnit=MeshUnit.Millimeter,
98+
MetaInfo=MeshMetaInfoContainer(),
99+
)
100+
]
101+
),
81102
)
82103

83104
writer = xvgi.XVGIWriter()

tests/serializers/xvgi/test_vge_mesh.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from vg_nde_sdk.projects import MeshProjectDescription
7+
from vg_nde_sdk.projects import ProjectDescription
88
from vg_nde_sdk.sections import (
99
MeshFormat,
1010
MeshSection,
@@ -16,8 +16,8 @@
1616

1717

1818
@pytest.fixture()
19-
def mesh_project_description(tmpdir: Path) -> MeshProjectDescription:
20-
return MeshProjectDescription(
19+
def mesh_project_description(tmpdir: Path) -> ProjectDescription:
20+
return ProjectDescription(
2121
meshes=MeshSectionHolder(
2222
[
2323
MeshSection(FileName=Path("data/vgcube/cubeMesh.stl")),
@@ -41,7 +41,7 @@ def mesh_project_description(tmpdir: Path) -> MeshProjectDescription:
4141

4242

4343
def test_serialize_mesh_project(
44-
mesh_project_description: MeshProjectDescription, tmpdir: Path
44+
mesh_project_description: ProjectDescription, tmpdir: Path
4545
):
4646
# GIVEN a mesh and a serializer
4747
writer = XVGIWriter()
@@ -54,7 +54,7 @@ def test_serialize_mesh_project(
5454

5555

5656
def test_serialize_mesh_project_to_file(
57-
mesh_project_description: MeshProjectDescription, tmpdir: Path
57+
mesh_project_description: ProjectDescription, tmpdir: Path
5858
):
5959
# GIVEN a mesh and a serializer
6060
output_dir = Path(tmpdir, "output")

tests/serializers/xvgi/test_vge_reconstruction.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from vg_nde_sdk.projects import ReconstructionProjectDescription
7+
from vg_nde_sdk.projects import ProjectDescription
88
from vg_nde_sdk.sections import (
99
ComponentInfoSection,
1010
ManufacturerInfoSection,
@@ -57,8 +57,8 @@
5757
@pytest.fixture()
5858
def reconstruction_project_description(
5959
tmpdir: Path,
60-
) -> ReconstructionProjectDescription:
61-
project = ReconstructionProjectDescription(
60+
) -> ProjectDescription:
61+
project = ProjectDescription(
6262
reconstructions=ReconstructionSectionHolder(
6363
reconstructions=[
6464
ReconstructionSection(
@@ -240,7 +240,7 @@ def reconstruction_project_description(
240240

241241

242242
def test_serialize_reconstruction_project(
243-
reconstruction_project_description: ReconstructionProjectDescription, tmpdir: Path
243+
reconstruction_project_description: ProjectDescription, tmpdir: Path
244244
):
245245
# GIVEN a project and a serializer
246246
writer = XVGIWriter()
@@ -253,7 +253,7 @@ def test_serialize_reconstruction_project(
253253

254254

255255
def test_serialize_reconstruction_project_to_file(
256-
reconstruction_project_description: ReconstructionProjectDescription, tmpdir: Path
256+
reconstruction_project_description: ProjectDescription, tmpdir: Path
257257
):
258258
# GIVEN a project and a serializer
259259
output_dir = Path(tmpdir, "output")

tests/serializers/xvgi/test_vge_volume.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from vg_nde_sdk.projects import VolumeProjectDescription
7+
from vg_nde_sdk.projects import ProjectDescription
88
from vg_nde_sdk.sections import (
99
ComponentInfoSection,
1010
ManufacturerInfoSection,
@@ -19,8 +19,8 @@
1919

2020

2121
@pytest.fixture()
22-
def volume_project_description(tmpdir: Path) -> VolumeProjectDescription:
23-
project = VolumeProjectDescription(
22+
def volume_project_description(tmpdir: Path) -> ProjectDescription:
23+
project = ProjectDescription(
2424
volumes=VolumeSectionHolder(
2525
[
2626
VolumeSection(
@@ -81,7 +81,7 @@ def volume_project_description(tmpdir: Path) -> VolumeProjectDescription:
8181

8282

8383
def test_serialize_volume_project(
84-
volume_project_description: VolumeProjectDescription, tmpdir: Path
84+
volume_project_description: ProjectDescription, tmpdir: Path
8585
):
8686
# GIVEN a volume and a serializer
8787
writer = XVGIWriter()
@@ -94,7 +94,7 @@ def test_serialize_volume_project(
9494

9595

9696
def test_serialize_volume_project_to_file(
97-
volume_project_description: VolumeProjectDescription, tmpdir: Path
97+
volume_project_description: ProjectDescription, tmpdir: Path
9898
):
9999
# GIVEN a volume and a serializer
100100
output_dir = Path(tmpdir, "output")

vg_nde_sdk/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"""Project generation SDK."""
22

3-
from .projects import (
4-
ReconstructionProjectDescription,
5-
VolumeProjectDescription,
3+
from .projects import ProjectDescription
4+
from .projecttools import (
65
make_mesh_project,
76
make_reconstruction_project_from_projections,
87
make_volume_project_from_block,

vg_nde_sdk/projects/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
"""Project types."""
22

3-
from .mesh import * # noqa
4-
from .reconstruction import * # noqa
5-
from .volume import * # noqa
3+
from .project import ProjectDescription

vg_nde_sdk/projects/project.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Volume project description."""
2+
3+
from dataclasses import dataclass, field
4+
5+
from vg_nde_sdk.sections import (
6+
MeshSectionHolder,
7+
ReconstructionSectionHolder,
8+
VersionSection,
9+
VolumeSectionHolder,
10+
)
11+
12+
13+
@dataclass
14+
class ProjectDescription:
15+
"""Mixed project description."""
16+
17+
version: VersionSection = field(default_factory=VersionSection)
18+
volumes: VolumeSectionHolder = field(default_factory=VolumeSectionHolder)
19+
meshes: MeshSectionHolder = field(default_factory=MeshSectionHolder)
20+
reconstructions: ReconstructionSectionHolder = field(
21+
default_factory=ReconstructionSectionHolder
22+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Project tools."""
2+
3+
from .mesh import make_mesh_project
4+
from .reconstruction import make_reconstruction_project_from_projections
5+
from .volume import make_volume_project_from_block, make_volume_project_from_slices
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
"""Volume project description."""
22

3-
from dataclasses import dataclass, field
43
from pathlib import Path
54

5+
from vg_nde_sdk.projects import ProjectDescription
66
from vg_nde_sdk.sections import (
77
ComponentInfoSection,
88
MeshFormat,
99
MeshSection,
1010
MeshSectionHolder,
1111
MeshUnit,
1212
Vector3f,
13-
VersionSection,
1413
)
1514
from vg_nde_sdk.sections.mesh import MeshMetaInfoContainer
1615

1716

18-
@dataclass
19-
class MeshProjectDescription:
20-
"""Volume project description."""
21-
22-
version: VersionSection = field(default_factory=VersionSection)
23-
meshes: MeshSectionHolder = field(default_factory=MeshSectionHolder)
24-
25-
2617
def make_mesh_project(
2718
mesh: Path,
2819
mesh_format: MeshFormat,
2920
mesh_unit: MeshUnit,
3021
mesh_info: ComponentInfoSection,
3122
mesh_translation: Vector3f = Vector3f(0, 0, 0), # noqa: B008
3223
mesh_rotation: Vector3f = Vector3f(0, 0, 0), # noqa: B008
33-
) -> MeshProjectDescription:
24+
) -> ProjectDescription:
3425
"""Generate minimal volume project description for a slice stack."""
3526
meta_infos = MeshMetaInfoContainer(ComponentInfo=mesh_info)
3627

37-
project = MeshProjectDescription(
28+
project = ProjectDescription(
3829
meshes=MeshSectionHolder(
3930
[
4031
MeshSection(

0 commit comments

Comments
 (0)