Skip to content

Commit

Permalink
Merge pull request #480 from PaulHax/dicom-loading-error
Browse files Browse the repository at this point in the history
fix(dataset-dicom): throw error if passed file but no volume results
  • Loading branch information
floryst authored Nov 6, 2023
2 parents 171c494 + 3689890 commit bfd3896
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/io/import/processors/importSingleFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { useModelStore } from '@/src/store/datasets-models';
import { FILE_READERS } from '@/src/io';
import { ImportHandler } from '@/src/io/import/common';
import { DataSourceWithFile } from '@/src/io/import/dataSource';
import { useDatasetStore } from '@/src/store/datasets';
import { useMessageStore } from '@/src/store/messages';

/**
* Reads and imports a file DataSource.
Expand Down Expand Up @@ -42,6 +44,11 @@ const importSingleFile: ImportHandler = async (dataSource, { done }) => {
}

if (dataObject.isA('vtkPolyData')) {
if (!useDatasetStore().primarySelection) {
useMessageStore().addWarning(
'Load an image to see the mesh. Initializing viewports from mesh files is not implemented.'
);
}
const dataID = useModelStore().addVTKPolyData(
fileSrc.file.name,
dataObject as vtkPolyData
Expand Down
2 changes: 2 additions & 0 deletions src/store/datasets-dicom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export const useDICOMStore = defineStore('dicom', {
const allFiles = [...fileToDataSource.keys()];

const volumeToFiles = await dicomIO.categorizeFiles(allFiles);
if (Object.keys(volumeToFiles).length === 0)
throw new Error('No volumes categorized from DICOM file(s)');

const fileStore = useFileStore();

Expand Down

0 comments on commit bfd3896

Please sign in to comment.