Skip to content

Commit 8b560fd

Browse files
Merge pull request #1594 from virtualcell/failure-to-export-math-model
Fix Math Model Export Error
2 parents ffd7665 + 7b30e06 commit 8b560fd

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

vcell-client/src/main/java/cbit/vcell/client/data/PDEExportDataPanel.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import cbit.vcell.client.task.ClientTaskDispatcher;
2323
import cbit.vcell.export.server.*;
2424
import cbit.vcell.export.server.ExportSpecs.SimNameSimDataID;
25+
import cbit.vcell.geometry.GeometrySpec;
2526
import cbit.vcell.geometry.SubVolume;
2627
import cbit.vcell.mapping.SimulationContext;
2728
import cbit.vcell.math.VariableType;
@@ -647,7 +648,6 @@ private ExportSpecs getExportSpecs() {
647648
for (int i = 0; i < selections.length; i++) {
648649
selections[i] = (SpatialSelection)selectionsArr[i];
649650
}
650-
SimulationContext sc = (SimulationContext) getSimulation().getSimulationOwner();
651651
MathOverrides mathOverrides = getSimulation().getMathOverrides();
652652

653653
String[] filteredConstants = mathOverrides.getFilteredConstantNames();
@@ -667,14 +667,25 @@ private ExportSpecs getExportSpecs() {
667667

668668
String serverSavedFileName = getExportSettings1().getFormatSpecificSpecs() instanceof N5Specs ? ((N5Specs) getExportSettings1().getFormatSpecificSpecs()).dataSetName : "";
669669

670-
boolean nonSpatial = sc.getGeometry().getDimension() == 0;
670+
SimulationOwner simulationOwner = getSimulation().getSimulationOwner();
671+
boolean nonSpatial = simulationOwner.getGeometry().getDimension() == 0;
671672
HashMap<Integer, String> subVolumes = new HashMap<>();
672-
for(SubVolume subVolume: sc.getGeometry().getGeometrySpec().getSubVolumes()){
673+
for(SubVolume subVolume: simulationOwner.getGeometry().getGeometrySpec().getSubVolumes()){
673674
subVolumes.put(subVolume.getHandle(), subVolume.getName());
674675
}
675-
HumanReadableExportData humanReadableExportData = new HumanReadableExportData(getSimulation().getName(), sc.getName(), sc.getBioModel().getName(),
676-
differentParameterValues, serverSavedFileName, sc.getApplicationType().name(), nonSpatial, subVolumes);
677676
GeometrySpecs geometrySpecs = new GeometrySpecs(selections, getNormalAxis(), getSlice(), geoMode);
677+
678+
HumanReadableExportData humanReadableExportData;
679+
if (simulationOwner instanceof SimulationContext sc){
680+
humanReadableExportData = new HumanReadableExportData(getSimulation().getName(), sc.getName(), sc.getBioModel().getName(),
681+
differentParameterValues, serverSavedFileName, sc.getApplicationType().name(), nonSpatial, subVolumes);
682+
} else if (simulationOwner instanceof MathModel mathModel){
683+
humanReadableExportData = new HumanReadableExportData(getSimulation().getName(), mathModel.getName(), mathModel.getName(),
684+
differentParameterValues, serverSavedFileName, mathModel.getDocumentType().name(), nonSpatial, subVolumes);
685+
} else {
686+
throw new IllegalArgumentException("Expected " + SimulationContext.class.getName() + " or " + MathModel.class.getName());
687+
}
688+
678689
ExportSpecs exportSpecs = new ExportSpecs(
679690
vcDataIdentifier,
680691
getExportSettings1().getSelectedFormat(),

0 commit comments

Comments
 (0)