Search in sources :

Example 21 with GeometrySurfaceDescription

use of cbit.vcell.geometry.surface.GeometrySurfaceDescription in project vcell by virtualcell.

the class RunSims method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
    ClientSimManager clientSimManager = (ClientSimManager) hashTable.get("clientSimManager");
    // DocumentManager documentManager = (DocumentManager)hashTable.get(CommonTask.DOCUMENT_MANAGER.name);
    JobManager jobManager = (JobManager) hashTable.get("jobManager");
    Simulation[] simulations = (Simulation[]) hashTable.get("simulations");
    Hashtable<Simulation, Throwable> failures = new Hashtable<Simulation, Throwable>();
    if (simulations != null && simulations.length > 0) {
        // we need to get the new ones if a save occurred...
        if (hashTable.containsKey(SaveDocument.DOC_KEY)) {
            VCDocument savedDocument = (VCDocument) hashTable.get(SaveDocument.DOC_KEY);
            Simulation[] allSims = null;
            if (savedDocument instanceof BioModel) {
                allSims = ((BioModel) savedDocument).getSimulations();
            } else if (savedDocument instanceof MathModel) {
                allSims = ((MathModel) savedDocument).getSimulations();
            }
            Vector<Simulation> v = new Vector<Simulation>();
            for (int i = 0; i < simulations.length; i++) {
                for (int j = 0; j < allSims.length; j++) {
                    if (simulations[i].getName().equals(allSims[j].getName())) {
                        v.add(allSims[j]);
                        break;
                    }
                }
            }
            simulations = (Simulation[]) BeanUtils.getArray(v, Simulation.class);
        }
        for (Simulation sim : simulations) {
            try {
                int dimension = sim.getMathDescription().getGeometry().getDimension();
                if (clientSimManager.getSimulationStatus(sim).isCompleted()) {
                    // completed
                    String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_1, sim.getName());
                    String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
                    if (result == null || !result.equals(UserMessage.OPTION_OK)) {
                        continue;
                    }
                }
                DataProcessingInstructions dataProcessingInstructions = sim.getDataProcessingInstructions();
                try {
                    if (dataProcessingInstructions != null) {
                        dataProcessingInstructions.getSampleImageFieldData(sim.getVersion().getOwner());
                    }
                } catch (Exception ex) {
                    DialogUtils.showErrorDialog(documentWindowManager.getComponent(), "Problem found in simulation '" + sim.getName() + "':\n" + ex.getMessage());
                    continue;
                }
                if (dimension > 0) {
                    MeshSpecification meshSpecification = sim.getMeshSpecification();
                    boolean bCellCentered = sim.hasCellCenteredMesh();
                    if (meshSpecification != null && !meshSpecification.isAspectRatioOK(bCellCentered)) {
                        String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_2, sim.getName(), "\u0394x=" + meshSpecification.getDx(bCellCentered) + "\n" + "\u0394y=" + meshSpecification.getDy(bCellCentered) + (dimension < 3 ? "" : "\n\u0394z=" + meshSpecification.getDz(bCellCentered)));
                        String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
                        if (result == null || !result.equals(UserMessage.OPTION_OK)) {
                            continue;
                        }
                    }
                    if (sim.getSolverTaskDescription().getSolverDescription().equals(SolverDescription.Smoldyn)) {
                        if (!isSmoldynTimeStepOK(sim)) {
                            double s = smoldynTimestepVars.getSpatialResolution();
                            double dMax = smoldynTimestepVars.getMaxDiffusion();
                            double condn = (s * s) / (2.0 * dMax);
                            String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_3, Double.toString(s), Double.toString(dMax), Double.toString(condn));
                            DialogUtils.showErrorDialog(documentWindowManager.getComponent(), warningMessage);
                            continue;
                        }
                    }
                    // check the number of regions if the simulation mesh is coarser.
                    Geometry mathGeometry = sim.getMathDescription().getGeometry();
                    ISize newSize = meshSpecification.getSamplingSize();
                    ISize defaultSize = mathGeometry.getGeometrySpec().getDefaultSampledImageSize();
                    if (!sim.getSolverTaskDescription().getSolverDescription().isChomboSolver()) {
                        int defaultTotalVolumeElements = mathGeometry.getGeometrySurfaceDescription().getVolumeSampleSize().getXYZ();
                        int newTotalVolumeElements = meshSpecification.getSamplingSize().getXYZ();
                        if (defaultTotalVolumeElements > newTotalVolumeElements) {
                            // coarser
                            Geometry resampledGeometry = (Geometry) BeanUtils.cloneSerializable(mathGeometry);
                            GeometrySurfaceDescription geoSurfaceDesc = resampledGeometry.getGeometrySurfaceDescription();
                            geoSurfaceDesc.setVolumeSampleSize(newSize);
                            geoSurfaceDesc.updateAll();
                            if (mathGeometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
                                mathGeometry.getGeometrySurfaceDescription().updateAll();
                            }
                            int defaultNumGeometricRegions = mathGeometry.getGeometrySurfaceDescription().getGeometricRegions().length;
                            int numGeometricRegions = geoSurfaceDesc.getGeometricRegions().length;
                            if (numGeometricRegions != defaultNumGeometricRegions) {
                                String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_4, newSize.getX() + (dimension > 1 ? " x " + newSize.getY() : "") + (dimension > 2 ? " x " + newSize.getZ() : ""), sim.getName(), numGeometricRegions, defaultNumGeometricRegions);
                                String result = PopupGenerator.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
                                if (result == null || !result.equals(UserMessage.OPTION_OK)) {
                                    continue;
                                }
                            }
                        }
                        if (mathGeometry.getGeometrySpec().hasImage()) {
                            // if it's an image.
                            if (defaultSize.getX() + 1 < newSize.getX() || defaultSize.getY() + 1 < newSize.getY() || defaultSize.getZ() + 1 < newSize.getZ()) {
                                // finer
                                String defaultSizeString = (defaultSize.getX() + 1) + (dimension > 1 ? " x " + (defaultSize.getY() + 1) : "") + (dimension > 2 ? " x " + (defaultSize.getZ() + 1) : "");
                                String warningMessage = VCellErrorMessages.getErrorMessage(VCellErrorMessages.RunSims_5, newSize.getX() + (dimension > 1 ? " x " + newSize.getY() : "") + (dimension > 2 ? " x " + newSize.getZ() : ""), sim.getName(), defaultSizeString, defaultSizeString);
                                String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
                                if (result == null || !result.equals(UserMessage.OPTION_OK)) {
                                    continue;
                                }
                            }
                        }
                    }
                    boolean bGiveWarning = false;
                    for (int i = 0; i < sim.getScanCount(); i++) {
                        if (sim.getSolverTaskDescription().getSolverDescription().equals(SolverDescription.SundialsPDE)) {
                            SimulationJob simJob = new SimulationJob(sim, i, null);
                            if (simJob.getSimulationSymbolTable().hasTimeVaryingDiffusionOrAdvection()) {
                                bGiveWarning = true;
                                break;
                            }
                        }
                    }
                    if (bGiveWarning) {
                        String warningMessage = VCellErrorMessages.RunSims_6;
                        String result = DialogUtils.showWarningDialog(documentWindowManager.getComponent(), warningMessage, new String[] { UserMessage.OPTION_OK, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_OK);
                        if (result == null || !result.equals(UserMessage.OPTION_OK)) {
                            continue;
                        }
                    }
                }
                SimulationInfo simInfo = sim.getSimulationInfo();
                if (simInfo != null) {
                    // 
                    // translate to common ancestral simulation (oldest mathematically equivalent simulation)
                    // 
                    SimulationStatus simulationStatus = jobManager.startSimulation(simInfo.getAuthoritativeVCSimulationIdentifier(), sim.getScanCount());
                    // updateStatus
                    clientSimManager.updateStatusFromStartRequest(sim, simulationStatus);
                } else {
                    // this should really not happen...
                    throw new RuntimeException(">>>>>>>>>> trying to run an unsaved simulation...");
                }
            } catch (Throwable exc) {
                exc.printStackTrace(System.out);
                failures.put(sim, exc);
            }
        }
    }
    // we deal with individual request failures here, passing down only other things (that break the whole thing down) to dispatcher
    if (!failures.isEmpty()) {
        Enumeration<Simulation> en = failures.keys();
        while (en.hasMoreElements()) {
            Simulation sim = en.nextElement();
            Throwable exc = (Throwable) failures.get(sim);
            // // updateStatus
            // SimulationStatus simulationStatus = clientSimManager.updateStatusFromStartRequest(sim, true, exc.getMessage());
            // notify user
            PopupGenerator.showErrorDialog(documentWindowManager, "Failed to start simulation'" + sim.getName() + "'\n" + exc.getMessage());
        }
    }
}
Also used : ClientSimManager(cbit.vcell.client.ClientSimManager) MathModel(cbit.vcell.mathmodel.MathModel) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) ISize(org.vcell.util.ISize) JobManager(cbit.vcell.client.server.JobManager) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) DataProcessingInstructions(cbit.vcell.solver.DataProcessingInstructions) Vector(java.util.Vector) SimulationJob(cbit.vcell.solver.SimulationJob) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) MeshSpecification(cbit.vcell.solver.MeshSpecification) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) SimulationStatus(cbit.vcell.server.SimulationStatus) BioModel(cbit.vcell.biomodel.BioModel) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 22 with GeometrySurfaceDescription

use of cbit.vcell.geometry.surface.GeometrySurfaceDescription in project vcell by virtualcell.

the class SBMLExporter method addGeometry.

private void addGeometry() throws SbmlException {
    SpatialModelPlugin mplugin = (SpatialModelPlugin) sbmlModel.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
    // Creates a geometry object via SpatialModelPlugin object.
    org.sbml.jsbml.ext.spatial.Geometry sbmlGeometry = mplugin.createGeometry();
    sbmlGeometry.setCoordinateSystem(GeometryKind.cartesian);
    sbmlGeometry.setSpatialId("vcell");
    Geometry vcGeometry = getSelectedSimContext().getGeometry();
    Model vcModel = getSelectedSimContext().getModel();
    // 
    // list of CoordinateComponents : 1 if geometry is 1-d, 2 if geometry is 2-d, 3 if geometry is 3-d
    // 
    int dimension = vcGeometry.getDimension();
    Extent vcExtent = vcGeometry.getExtent();
    Origin vcOrigin = vcGeometry.getOrigin();
    // add x coordinate component
    CoordinateComponent xComp = sbmlGeometry.createCoordinateComponent();
    xComp.setSpatialId(vcModel.getX().getName());
    xComp.setType(CoordinateKind.cartesianX);
    final UnitDefinition sbmlUnitDef_length = getOrCreateSBMLUnit(vcModel.getUnitSystem().getLengthUnit());
    xComp.setUnits(sbmlUnitDef_length);
    Boundary minX = new Boundary();
    xComp.setBoundaryMinimum(minX);
    minX.setSpatialId("Xmin");
    minX.setValue(vcOrigin.getX());
    Boundary maxX = new Boundary();
    xComp.setBoundaryMaximum(maxX);
    maxX.setSpatialId("Xmax");
    maxX.setValue(vcOrigin.getX() + (vcExtent.getX()));
    org.sbml.jsbml.Parameter pX = sbmlModel.createParameter();
    pX.setId(vcModel.getX().getName());
    pX.setValue(0.0);
    pX.setConstant(false);
    pX.setUnits(sbmlUnitDef_length);
    SpatialParameterPlugin spPluginPx = (SpatialParameterPlugin) pX.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
    SpatialSymbolReference spSymRefPx = new SpatialSymbolReference();
    spPluginPx.setParamType(spSymRefPx);
    spSymRefPx.setSpatialRef(xComp.getSpatialId());
    // add y coordinate component
    if (dimension == 2 || dimension == 3) {
        CoordinateComponent yComp = sbmlGeometry.createCoordinateComponent();
        yComp.setSpatialId(vcModel.getY().getName());
        yComp.setType(CoordinateKind.cartesianY);
        yComp.setUnits(sbmlUnitDef_length);
        Boundary minY = new Boundary();
        yComp.setBoundaryMinimum(minY);
        minY.setSpatialId("Ymin");
        minY.setValue(vcOrigin.getY());
        Boundary maxY = new Boundary();
        yComp.setBoundaryMaximum(maxY);
        maxY.setSpatialId("Ymax");
        maxY.setValue(vcOrigin.getY() + (vcExtent.getY()));
        org.sbml.jsbml.Parameter pY = sbmlModel.createParameter();
        pY.setId(vcModel.getY().getName());
        pY.setValue(0.0);
        pY.setConstant(false);
        pY.setUnits(sbmlUnitDef_length);
        SpatialParameterPlugin spPluginPy = (SpatialParameterPlugin) pY.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
        SpatialSymbolReference spSymRefPy = new SpatialSymbolReference();
        spPluginPy.setParamType(spSymRefPy);
        spSymRefPy.setSpatialRef(yComp.getSpatialId());
    }
    // add z coordinate component
    if (dimension == 3) {
        CoordinateComponent zComp = sbmlGeometry.createCoordinateComponent();
        zComp.setSpatialId(vcModel.getZ().getName());
        zComp.setType(CoordinateKind.cartesianZ);
        zComp.setUnits(sbmlUnitDef_length);
        Boundary minZ = new Boundary();
        zComp.setBoundaryMinimum(minZ);
        minZ.setSpatialId("Zmin");
        minZ.setValue(vcOrigin.getZ());
        Boundary maxZ = new Boundary();
        zComp.setBoundaryMaximum(maxZ);
        maxZ.setSpatialId("Zmax");
        maxZ.setValue(vcOrigin.getZ() + (vcExtent.getZ()));
        org.sbml.jsbml.Parameter pZ = sbmlModel.createParameter();
        pZ.setId(vcModel.getZ().getName());
        pZ.setValue(0.0);
        pZ.setConstant(false);
        pZ.setUnits(sbmlUnitDef_length);
        SpatialParameterPlugin spPluginPz = (SpatialParameterPlugin) pZ.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
        SpatialSymbolReference spSymRefPz = new SpatialSymbolReference();
        spPluginPz.setParamType(spSymRefPz);
        spSymRefPz.setSpatialRef(zComp.getSpatialId());
    }
    // 
    // list of compartmentMappings : VC structureMappings
    // 
    GeometryContext vcGeoContext = getSelectedSimContext().getGeometryContext();
    StructureMapping[] vcStrucMappings = vcGeoContext.getStructureMappings();
    for (int i = 0; i < vcStrucMappings.length; i++) {
        StructureMapping vcStructMapping = vcStrucMappings[i];
        String structName = vcStructMapping.getStructure().getName();
        Compartment comp = sbmlModel.getCompartment(TokenMangler.mangleToSName(structName));
        SpatialCompartmentPlugin cplugin = (SpatialCompartmentPlugin) comp.getPlugin(SBMLUtils.SBML_SPATIAL_NS_PREFIX);
        GeometryClass gc = vcStructMapping.getGeometryClass();
        if (!goodPointer(gc, GeometryClass.class, structName)) {
            continue;
        }
        CompartmentMapping compMapping = new CompartmentMapping();
        cplugin.setCompartmentMapping(compMapping);
        String geomClassName = gc.getName();
        String id = TokenMangler.mangleToSName(geomClassName + structName);
        compMapping.setSpatialId(id);
        compMapping.setDomainType(TokenMangler.mangleToSName(DOMAIN_TYPE_PREFIX + geomClassName));
        try {
            StructureMappingParameter usp = vcStructMapping.getUnitSizeParameter();
            Expression e = usp.getExpression();
            if (goodPointer(e, Expression.class, id)) {
                compMapping.setUnitSize(e.evaluateConstant());
            }
        } catch (ExpressionException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Unable to create compartment mapping for structureMapping '" + compMapping.getId() + "' : " + e.getMessage());
        }
    }
    // 
    // list of domain types : subvolumes and surface classes from VC
    // 
    boolean bAnyAnalyticSubvolumes = false;
    boolean bAnyImageSubvolumes = false;
    boolean bAnyCSGSubvolumes = false;
    GeometryClass[] vcGeomClasses = vcGeometry.getGeometryClasses();
    int numSubVols = 0;
    for (int i = 0; i < vcGeomClasses.length; i++) {
        DomainType domainType = sbmlGeometry.createDomainType();
        domainType.setSpatialId(DOMAIN_TYPE_PREFIX + vcGeomClasses[i].getName());
        if (vcGeomClasses[i] instanceof SubVolume) {
            if (((SubVolume) vcGeomClasses[i]) instanceof AnalyticSubVolume) {
                bAnyAnalyticSubvolumes = true;
            } else if (((SubVolume) vcGeomClasses[i]) instanceof ImageSubVolume) {
                bAnyImageSubvolumes = true;
            } else if (((SubVolume) vcGeomClasses[i]) instanceof CSGObject) {
                bAnyCSGSubvolumes = true;
            }
            domainType.setSpatialDimensions(3);
            numSubVols++;
        } else if (vcGeomClasses[i] instanceof SurfaceClass) {
            domainType.setSpatialDimensions(2);
        }
    }
    // 
    // list of domains, adjacent domains : from VC geometricRegions
    // 
    GeometrySurfaceDescription vcGSD = vcGeometry.getGeometrySurfaceDescription();
    if (vcGSD.getRegionImage() == null) {
        try {
            vcGSD.updateAll();
        } catch (Exception e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Unable to generate region images for geometry");
        }
    }
    GeometricRegion[] vcGeometricRegions = vcGSD.getGeometricRegions();
    ISize sampleSize = vcGSD.getVolumeSampleSize();
    int numX = sampleSize.getX();
    int numY = sampleSize.getY();
    int numZ = sampleSize.getZ();
    double ox = vcOrigin.getX();
    double oy = vcOrigin.getY();
    double oz = vcOrigin.getZ();
    RegionInfo[] regionInfos = vcGSD.getRegionImage().getRegionInfos();
    for (int i = 0; i < vcGeometricRegions.length; i++) {
        // domains
        Domain domain = sbmlGeometry.createDomain();
        domain.setSpatialId(vcGeometricRegions[i].getName());
        if (vcGeometricRegions[i] instanceof VolumeGeometricRegion) {
            domain.setDomainType(DOMAIN_TYPE_PREFIX + ((VolumeGeometricRegion) vcGeometricRegions[i]).getSubVolume().getName());
            // 
            // get a list of interior points ... should probably use the distance map to find a point
            // furthest inside (or several points associated with the morphological skeleton).
            // 
            InteriorPoint interiorPt = domain.createInteriorPoint();
            int regionID = ((VolumeGeometricRegion) vcGeometricRegions[i]).getRegionID();
            boolean bFound = false;
            int regInfoIndx = 0;
            for (int j = 0; j < regionInfos.length; j++) {
                regInfoIndx = j;
                if (regionInfos[j].getRegionIndex() == regionID) {
                    int volIndx = 0;
                    for (int z = 0; z < numZ && !bFound; z++) {
                        for (int y = 0; y < numY && !bFound; y++) {
                            for (int x = 0; x < numX && !bFound; x++) {
                                if (regionInfos[j].isIndexInRegion(volIndx)) {
                                    bFound = true;
                                    double unit_z = (numZ > 1) ? ((double) z) / (numZ - 1) : 0.5;
                                    double coordZ = oz + vcExtent.getZ() * unit_z;
                                    double unit_y = (numY > 1) ? ((double) y) / (numY - 1) : 0.5;
                                    double coordY = oy + vcExtent.getY() * unit_y;
                                    double unit_x = (numX > 1) ? ((double) x) / (numX - 1) : 0.5;
                                    double coordX = ox + vcExtent.getX() * unit_x;
                                    interiorPt.setCoord1(coordX);
                                    interiorPt.setCoord2(coordY);
                                    interiorPt.setCoord3(coordZ);
                                }
                                volIndx++;
                            }
                        // end - for x
                        }
                    // end - for y
                    }
                // end - for z
                }
            // end if
            }
            // end for regionInfos
            if (!bFound) {
                throw new RuntimeException("Unable to find interior point for region '" + regionInfos[regInfoIndx].toString());
            }
        } else if (vcGeometricRegions[i] instanceof SurfaceGeometricRegion) {
            SurfaceGeometricRegion vcSurfaceGeomReg = (SurfaceGeometricRegion) vcGeometricRegions[i];
            GeometricRegion geomRegion0 = vcSurfaceGeomReg.getAdjacentGeometricRegions()[0];
            GeometricRegion geomRegion1 = vcSurfaceGeomReg.getAdjacentGeometricRegions()[1];
            SurfaceClass surfaceClass = vcGSD.getSurfaceClass(((VolumeGeometricRegion) geomRegion0).getSubVolume(), ((VolumeGeometricRegion) geomRegion1).getSubVolume());
            domain.setDomainType(DOMAIN_TYPE_PREFIX + surfaceClass.getName());
            // adjacent domains : 2 adjacent domain objects for each surfaceClass in VC.
            // adjacent domain 1
            GeometricRegion adjGeomRegion0 = vcSurfaceGeomReg.getAdjacentGeometricRegions()[0];
            GeometricRegion adjGeomRegion1 = vcSurfaceGeomReg.getAdjacentGeometricRegions()[1];
            AdjacentDomains adjDomain = new AdjacentDomains();
            adjDomain.setSpatialId(TokenMangler.mangleToSName(vcSurfaceGeomReg.getName() + "_" + adjGeomRegion0.getName()));
            adjDomain.setDomain1(vcSurfaceGeomReg.getName());
            adjDomain.setDomain2(adjGeomRegion0.getName());
            sbmlGeometry.addAdjacentDomain(adjDomain);
            // adj domain 2
            adjDomain = new AdjacentDomains();
            adjDomain.setSpatialId(TokenMangler.mangleToSName(vcSurfaceGeomReg.getName() + "_" + adjGeomRegion1.getName()));
            adjDomain.setDomain1(vcSurfaceGeomReg.getName());
            adjDomain.setDomain2(adjGeomRegion1.getName());
            sbmlGeometry.addAdjacentDomain(adjDomain);
        }
    }
    // 
    if (bAnyAnalyticSubvolumes && !bAnyImageSubvolumes && !bAnyCSGSubvolumes) {
        AnalyticGeometry sbmlAnalyticGeomDefinition = sbmlGeometry.createAnalyticGeometry();
        sbmlAnalyticGeomDefinition.setSpatialId(TokenMangler.mangleToSName("Analytic_" + vcGeometry.getName()));
        sbmlAnalyticGeomDefinition.setIsActive(true);
        for (int i = 0; i < vcGeomClasses.length; i++) {
            if (vcGeomClasses[i] instanceof AnalyticSubVolume) {
                AnalyticVolume analyticVol = sbmlAnalyticGeomDefinition.createAnalyticVolume();
                analyticVol.setSpatialId(vcGeomClasses[i].getName());
                analyticVol.setDomainType(DOMAIN_TYPE_PREFIX + vcGeomClasses[i].getName());
                analyticVol.setFunctionType(FunctionKind.layered);
                analyticVol.setOrdinal(numSubVols - (i + 1));
                Expression expr = ((AnalyticSubVolume) vcGeomClasses[i]).getExpression();
                try {
                    String mathMLStr = ExpressionMathMLPrinter.getMathML(expr, true, MathType.BOOLEAN);
                    ASTNode mathMLNode = ASTNode.readMathMLFromString(mathMLStr);
                    analyticVol.setMath(mathMLNode);
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                    throw new RuntimeException("Error converting VC subvolume expression to mathML" + e.getMessage());
                }
            }
        }
    }
    // 
    if (!bAnyAnalyticSubvolumes && !bAnyImageSubvolumes && bAnyCSGSubvolumes) {
        CSGeometry sbmlCSGeomDefinition = new CSGeometry();
        sbmlGeometry.addGeometryDefinition(sbmlCSGeomDefinition);
        sbmlCSGeomDefinition.setSpatialId(TokenMangler.mangleToSName("CSG_" + vcGeometry.getName()));
        for (int i = 0; i < vcGeomClasses.length; i++) {
            if (vcGeomClasses[i] instanceof CSGObject) {
                CSGObject vcellCSGObject = (CSGObject) vcGeomClasses[i];
                org.sbml.jsbml.ext.spatial.CSGObject sbmlCSGObject = new org.sbml.jsbml.ext.spatial.CSGObject();
                sbmlCSGeomDefinition.addCSGObject(sbmlCSGObject);
                sbmlCSGObject.setSpatialId(vcellCSGObject.getName());
                sbmlCSGObject.setDomainType(DOMAIN_TYPE_PREFIX + vcellCSGObject.getName());
                // the ordinal should the the least for the default/background subVolume
                sbmlCSGObject.setOrdinal(numSubVols - (i + 1));
                org.sbml.jsbml.ext.spatial.CSGNode sbmlcsgNode = getSBMLCSGNode(vcellCSGObject.getRoot());
                sbmlCSGObject.setCSGNode(sbmlcsgNode);
            }
        }
    }
    // 
    // add "Segmented" and "DistanceMap" SampledField Geometries
    // 
    final boolean bVCGeometryIsImage = bAnyImageSubvolumes && !bAnyAnalyticSubvolumes && !bAnyCSGSubvolumes;
    // 55if (bAnyAnalyticSubvolumes || bAnyImageSubvolumes || bAnyCSGSubvolumes){
    if (bVCGeometryIsImage) {
        // 
        // add "Segmented" SampledFieldGeometry
        // 
        SampledFieldGeometry segmentedImageSampledFieldGeometry = sbmlGeometry.createSampledFieldGeometry();
        segmentedImageSampledFieldGeometry.setSpatialId(TokenMangler.mangleToSName("SegmentedImage_" + vcGeometry.getName()));
        segmentedImageSampledFieldGeometry.setIsActive(true);
        // 55boolean bVCGeometryIsImage = bAnyImageSubvolumes && !bAnyAnalyticSubvolumes && !bAnyCSGSubvolumes;
        Geometry vcImageGeometry = null;
        {
            if (bVCGeometryIsImage) {
                // make a resampled image;
                if (dimension == 3) {
                    try {
                        ISize imageSize = vcGeometry.getGeometrySpec().getDefaultSampledImageSize();
                        vcGeometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
                        vcImageGeometry = RayCaster.resampleGeometry(new GeometryThumbnailImageFactoryAWT(), vcGeometry, imageSize);
                    } catch (Throwable e) {
                        e.printStackTrace(System.out);
                        throw new RuntimeException("Unable to convert the original analytic or constructed solid geometry to image-based geometry : " + e.getMessage());
                    }
                } else {
                    try {
                        vcGeometry.precomputeAll(new GeometryThumbnailImageFactoryAWT(), true, false);
                        GeometrySpec origGeometrySpec = vcGeometry.getGeometrySpec();
                        VCImage newVCImage = origGeometrySpec.getSampledImage().getCurrentValue();
                        // 
                        // construct the new geometry with the sampled VCImage.
                        // 
                        vcImageGeometry = new Geometry(vcGeometry.getName() + "_asImage", newVCImage);
                        vcImageGeometry.getGeometrySpec().setExtent(vcGeometry.getExtent());
                        vcImageGeometry.getGeometrySpec().setOrigin(vcGeometry.getOrigin());
                        vcImageGeometry.setDescription(vcGeometry.getDescription());
                        vcImageGeometry.getGeometrySurfaceDescription().setFilterCutoffFrequency(vcGeometry.getGeometrySurfaceDescription().getFilterCutoffFrequency());
                        vcImageGeometry.precomputeAll(new GeometryThumbnailImageFactoryAWT(), true, true);
                    } catch (Exception e) {
                        e.printStackTrace(System.out);
                        throw new RuntimeException("Unable to convert the original analytic or constructed solid geometry to image-based geometry : " + e.getMessage());
                    }
                }
                GeometryClass[] vcImageGeomClasses = vcImageGeometry.getGeometryClasses();
                for (int j = 0; j < vcImageGeomClasses.length; j++) {
                    if (vcImageGeomClasses[j] instanceof ImageSubVolume) {
                        SampledVolume sampledVol = segmentedImageSampledFieldGeometry.createSampledVolume();
                        sampledVol.setSpatialId(vcGeomClasses[j].getName());
                        sampledVol.setDomainType(DOMAIN_TYPE_PREFIX + vcGeomClasses[j].getName());
                        sampledVol.setSampledValue(((ImageSubVolume) vcImageGeomClasses[j]).getPixelValue());
                    }
                }
                // add sampledField to sampledFieldGeometry
                SampledField segmentedImageSampledField = sbmlGeometry.createSampledField();
                VCImage vcImage = vcImageGeometry.getGeometrySpec().getImage();
                segmentedImageSampledField.setSpatialId("SegmentedImageSampledField");
                segmentedImageSampledField.setNumSamples1(vcImage.getNumX());
                segmentedImageSampledField.setNumSamples2(vcImage.getNumY());
                segmentedImageSampledField.setNumSamples3(vcImage.getNumZ());
                segmentedImageSampledField.setInterpolationType(InterpolationKind.nearestneighbor);
                segmentedImageSampledField.setCompression(CompressionKind.uncompressed);
                segmentedImageSampledField.setDataType(DataKind.UINT8);
                segmentedImageSampledFieldGeometry.setSampledField(segmentedImageSampledField.getId());
                try {
                    byte[] vcImagePixelsBytes = vcImage.getPixels();
                    // imageData.setCompression("");
                    StringBuffer sb = new StringBuffer();
                    for (int i = 0; i < vcImagePixelsBytes.length; i++) {
                        int uint8_sample = ((int) vcImagePixelsBytes[i]) & 0xff;
                        sb.append(uint8_sample + " ");
                    }
                    segmentedImageSampledField.setSamplesLength(vcImage.getNumXYZ());
                    segmentedImageSampledField.setSamples(sb.toString().trim());
                } catch (ImageException e) {
                    e.printStackTrace(System.out);
                    throw new RuntimeException("Unable to export image from VCell to SBML : " + e.getMessage());
                }
            }
        }
    /*		
		//
		// add "DistanceMap" SampledFieldGeometry if there are exactly two subvolumes (else need more fields) and geometry is 3d.
		//
		if (numSubVols==2 && dimension == 3){
			SignedDistanceMap[] distanceMaps = null;
			try {
				distanceMaps = DistanceMapGenerator.computeDistanceMaps(vcImageGeometry, vcImageGeometry.getGeometrySpec().getImage(), false, false);
			} catch (ImageException e) {
				e.printStackTrace(System.out);
				System.err.println("Unable to export distance map sampled field from VCell to SBML : " + e.getMessage());
				// throw new RuntimeException("Unable to export distance map sampled field from VCell to SBML : " + e.getMessage());
				
				// don't want to throw an exception and stop export because distance map geometry couldn't be exported. 
				// just 'return' from method (since this is the last thing that is being done in this method).
				return;
			}
			//
			// the two distanceMaps should be redundant (one is negation of the other) ... so choose first one for field.
			//
			double[] signedDistances = distanceMaps[0].getSignedDistances();
			SampledFieldGeometry distanceMapSampledFieldGeometry = sbmlGeometry.createSampledFieldGeometry();
			distanceMapSampledFieldGeometry.setSpatialId(TokenMangler.mangleToSName("DistanceMap_"+vcGeometry.getName()));
			SampledField distanceMapSampledField = distanceMapSampledFieldGeometry.createSampledField();
			distanceMapSampledField.setSpatialId("DistanceMapSampledField");
			distanceMapSampledField.setNumSamples1(distanceMaps[0].getSamplesX().length);
			distanceMapSampledField.setNumSamples2(distanceMaps[0].getSamplesY().length);
			distanceMapSampledField.setNumSamples3(distanceMaps[0].getSamplesZ().length);
			distanceMapSampledField.setDataType("real");
System.err.println("do we need distanceMapSampleField.setDataType()?");
			distanceMapSampledField.setInterpolationType("linear");
			ImageData distanceMapImageData = distanceMapSampledField.createImageData();
			distanceMapImageData.setDataType("int16");
System.err.println("should be:\n  distanceMapImageData.setDataType(\"float32\")");
//					distanceMapImageData.setCompression("");

			double maxAbsValue = 0;
			for (int i = 0; i < signedDistances.length; i++) {
				maxAbsValue = Math.max(maxAbsValue,Math.abs(signedDistances[i]));
			}
			if (maxAbsValue==0.0){
				throw new RuntimeException("computed distance map all zeros");
			}
			double scale = (Short.MAX_VALUE-1)/maxAbsValue;
			int[] scaledIntegerDistanceMap = new int[signedDistances.length];
			for (int i = 0; i < signedDistances.length; i++) {
				scaledIntegerDistanceMap[i] = (int)(scale * signedDistances[i]);
			}
			distanceMapImageData.setSamples(scaledIntegerDistanceMap, signedDistances.length);
System.err.println("should be:\n  distanceMapImageData.setSamples((float[])signedDistances,signedDistances.length)");
			SampledVolume sampledVol = distanceMapSampledFieldGeometry.createSampledVolume();
			sampledVol.setSpatialId(distanceMaps[0].getInsideSubvolumeName());
			sampledVol.setDomainType(DOMAIN_TYPE_PREFIX+distanceMaps[0].getInsideSubvolumeName());
			sampledVol.setSampledValue(255);
			sampledVol = distanceMapSampledFieldGeometry.createSampledVolume();
			sampledVol.setSpatialId(distanceMaps[1].getInsideSubvolumeName());
			sampledVol.setDomainType(DOMAIN_TYPE_PREFIX+distanceMaps[1].getInsideSubvolumeName());
			sampledVol.setSampledValue(1);
		}
*/
    }
// 
// add "SurfaceMesh" ParametricGeometry
// 
// if (bAnyAnalyticSubvolumes || bAnyImageSubvolumes || bAnyCSGSubvolumes){
// ParametricGeometry sbmlParametricGeomDefinition = sbmlGeometry.createParametricGeometry();
// sbmlParametricGeomDefinition.setSpatialId(TokenMangler.mangleToSName("SurfaceMesh_"+vcGeometry.getName()));
// xxxx
// }
}
Also used : Origin(org.vcell.util.Origin) CompartmentMapping(org.sbml.jsbml.ext.spatial.CompartmentMapping) Compartment(org.sbml.jsbml.Compartment) SpatialParameterPlugin(org.sbml.jsbml.ext.spatial.SpatialParameterPlugin) StructureMappingParameter(cbit.vcell.mapping.StructureMapping.StructureMappingParameter) AnalyticGeometry(org.sbml.jsbml.ext.spatial.AnalyticGeometry) ExpressionException(cbit.vcell.parser.ExpressionException) Boundary(org.sbml.jsbml.ext.spatial.Boundary) GeometrySpec(cbit.vcell.geometry.GeometrySpec) DomainType(org.sbml.jsbml.ext.spatial.DomainType) SampledVolume(org.sbml.jsbml.ext.spatial.SampledVolume) SubVolume(cbit.vcell.geometry.SubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) GeometryContext(cbit.vcell.mapping.GeometryContext) SpatialCompartmentPlugin(org.sbml.jsbml.ext.spatial.SpatialCompartmentPlugin) CoordinateComponent(org.sbml.jsbml.ext.spatial.CoordinateComponent) SimulationContext(cbit.vcell.mapping.SimulationContext) SpeciesContext(cbit.vcell.model.SpeciesContext) GeometryContext(cbit.vcell.mapping.GeometryContext) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) SpatialSymbolReference(org.sbml.jsbml.ext.spatial.SpatialSymbolReference) AnalyticVolume(org.sbml.jsbml.ext.spatial.AnalyticVolume) InteriorPoint(org.sbml.jsbml.ext.spatial.InteriorPoint) SampledField(org.sbml.jsbml.ext.spatial.SampledField) Domain(org.sbml.jsbml.ext.spatial.Domain) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) GeometryClass(cbit.vcell.geometry.GeometryClass) ImageException(cbit.image.ImageException) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) Extent(org.vcell.util.Extent) SurfaceClass(cbit.vcell.geometry.SurfaceClass) ISize(org.vcell.util.ISize) CSGeometry(org.sbml.jsbml.ext.spatial.CSGeometry) RegionInfo(cbit.vcell.geometry.RegionImage.RegionInfo) VCImage(cbit.image.VCImage) StructureMapping(cbit.vcell.mapping.StructureMapping) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) ASTNode(org.sbml.jsbml.ASTNode) CSGObject(cbit.vcell.geometry.CSGObject) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) UnitDefinition(org.sbml.jsbml.UnitDefinition) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) SampledFieldGeometry(org.sbml.jsbml.ext.spatial.SampledFieldGeometry) SpatialModelPlugin(org.sbml.jsbml.ext.spatial.SpatialModelPlugin) InteriorPoint(org.sbml.jsbml.ext.spatial.InteriorPoint) XMLStreamException(javax.xml.stream.XMLStreamException) SbmlException(org.vcell.sbml.SbmlException) ImageException(cbit.image.ImageException) SBMLException(org.sbml.jsbml.SBMLException) ExpressionException(cbit.vcell.parser.ExpressionException) AdjacentDomains(org.sbml.jsbml.ext.spatial.AdjacentDomains) Geometry(cbit.vcell.geometry.Geometry) SampledFieldGeometry(org.sbml.jsbml.ext.spatial.SampledFieldGeometry) AnalyticGeometry(org.sbml.jsbml.ext.spatial.AnalyticGeometry) CSGeometry(org.sbml.jsbml.ext.spatial.CSGeometry) Expression(cbit.vcell.parser.Expression) Model(cbit.vcell.model.Model) BioModel(cbit.vcell.biomodel.BioModel)

Example 23 with GeometrySurfaceDescription

use of cbit.vcell.geometry.surface.GeometrySurfaceDescription in project vcell by virtualcell.

the class SmoldynFileWriter method writeWallSurfaces.

private void writeWallSurfaces() throws SolverException {
    GeometrySurfaceDescription geometrySurfaceDescription = resampledGeometry.getGeometrySurfaceDescription();
    GeometrySpec geometrySpec = resampledGeometry.getGeometrySpec();
    SubVolume[] subVolumes = geometrySpec.getSubVolumes();
    printWriter.println("# boundaries");
    Origin origin = geometrySpec.getOrigin();
    Extent extent = geometrySpec.getExtent();
    Coordinate lowWall = new Coordinate(origin.getX(), origin.getY(), origin.getZ());
    Coordinate highWall = new Coordinate(origin.getX() + extent.getX(), origin.getY() + extent.getY(), origin.getZ() + extent.getZ());
    // potential artifact.
    if (bHasNoSurface) {
        SubDomain subDomain0 = mathDesc.getSubDomains().nextElement();
        CompartmentSubDomain compartSubDomain0 = null;
        compartSubDomain0 = (CompartmentSubDomain) subDomain0;
        // x
        if (compartSubDomain0.getBoundaryConditionXm().isPERIODIC()) {
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.boundaries + " 0 " + lowWall.getX() + " " + highWall.getX() + " " + SmoldynVCellMapper.SmoldynKeyword.p);
        } else {
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.low_wall + " 0 " + lowWall.getX() + " " + (compartSubDomain0.getBoundaryConditionXm().isNEUMANN() ? SmoldynVCellMapper.SmoldynKeyword.r : SmoldynVCellMapper.SmoldynKeyword.a));
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.high_wall + " 0 " + highWall.getX() + " " + (compartSubDomain0.getBoundaryConditionXp().isNEUMANN() ? SmoldynVCellMapper.SmoldynKeyword.r : SmoldynVCellMapper.SmoldynKeyword.a));
        }
        if (dimension > 1) {
            // y
            if (compartSubDomain0.getBoundaryConditionYm().isPERIODIC()) {
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.boundaries + " 1 " + lowWall.getY() + " " + highWall.getY() + " " + SmoldynVCellMapper.SmoldynKeyword.p);
            } else {
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.low_wall + " 1 " + lowWall.getY() + " " + (compartSubDomain0.getBoundaryConditionYm().isNEUMANN() ? SmoldynVCellMapper.SmoldynKeyword.r : SmoldynVCellMapper.SmoldynKeyword.a));
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.high_wall + " 1 " + highWall.getY() + " " + (compartSubDomain0.getBoundaryConditionYp().isNEUMANN() ? SmoldynVCellMapper.SmoldynKeyword.r : SmoldynVCellMapper.SmoldynKeyword.a));
            }
            if (dimension > 2) {
                // z
                if (compartSubDomain0.getBoundaryConditionZm().isPERIODIC()) {
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.boundaries + " 2 " + lowWall.getZ() + " " + highWall.getZ() + " " + SmoldynVCellMapper.SmoldynKeyword.p);
                } else {
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.low_wall + " 2 " + lowWall.getZ() + " " + (compartSubDomain0.getBoundaryConditionZm().isNEUMANN() ? SmoldynVCellMapper.SmoldynKeyword.r : SmoldynVCellMapper.SmoldynKeyword.a));
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.high_wall + " 2 " + highWall.getZ() + " " + (compartSubDomain0.getBoundaryConditionZp().isNEUMANN() ? SmoldynVCellMapper.SmoldynKeyword.r : SmoldynVCellMapper.SmoldynKeyword.a));
                }
            }
        }
        printWriter.println();
    } else {
        // x
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.boundaries + " 0 " + lowWall.getX() + " " + highWall.getX());
        if (dimension > 1) {
            // y
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.boundaries + " 1 " + lowWall.getY() + " " + highWall.getY());
            if (dimension > 2) {
                // z
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.boundaries + " 2 " + lowWall.getZ() + " " + highWall.getZ());
            }
        }
        printWriter.println();
        // bounding walls as surfaces
        // have to find boundary condition type
        ISize sampleSize = simulation.getMeshSpecification().getSamplingSize();
        int numX = sampleSize.getX();
        int numY = dimension < 2 ? 1 : sampleSize.getY();
        int numZ = dimension < 3 ? 1 : sampleSize.getZ();
        if (dimension > 2) {
            int[] k_wall = new int[] { 0, numZ - 1 };
            for (int k = 0; k < k_wall.length; k++) {
                for (int j = 0; j < numY; j++) {
                    for (int i = 0; i < numX; i++) {
                        int volIndex = k_wall[k] * numX * numY + j * numX + i;
                        for (SubVolume sv : subVolumes) {
                            // gather all the points in all the regions
                            GeometricRegion[] geometricRegions = geometrySurfaceDescription.getGeometricRegions(sv);
                            RegionInfo[] regionInfos = geometrySurfaceDescription.getRegionImage().getRegionInfos();
                            for (GeometricRegion gr : geometricRegions) {
                                VolumeGeometricRegion vgr = (VolumeGeometricRegion) gr;
                                for (RegionInfo ri : regionInfos) {
                                    if (ri.getRegionIndex() == vgr.getRegionID() && ri.isIndexInRegion(volIndex)) {
                                        boundaryZSubVolumes.add(sv);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (dimension > 1) {
            int[] j_wall = new int[] { 0, numY - 1 };
            for (int k = 0; k < numZ; k++) {
                for (int j = 0; j < j_wall.length; j++) {
                    for (int i = 0; i < numX; i++) {
                        int volIndex = k * numX * numY + j_wall[j] * numX + i;
                        for (SubVolume sv : subVolumes) {
                            // gather all the points in all the regions
                            GeometricRegion[] geometricRegions = geometrySurfaceDescription.getGeometricRegions(sv);
                            RegionInfo[] regionInfos = geometrySurfaceDescription.getRegionImage().getRegionInfos();
                            for (GeometricRegion gr : geometricRegions) {
                                VolumeGeometricRegion vgr = (VolumeGeometricRegion) gr;
                                for (RegionInfo ri : regionInfos) {
                                    if (ri.getRegionIndex() == vgr.getRegionID() && ri.isIndexInRegion(volIndex)) {
                                        boundaryYSubVolumes.add(sv);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        int[] i_wall = new int[] { 0, numX - 1 };
        for (int k = 0; k < numZ; k++) {
            for (int j = 0; j < numY; j++) {
                for (int i = 0; i < i_wall.length; i++) {
                    int volIndex = k * numX * numY + j * numX + i_wall[i];
                    for (SubVolume sv : subVolumes) {
                        // gather all the points in all the regions
                        GeometricRegion[] geometricRegions = geometrySurfaceDescription.getGeometricRegions(sv);
                        RegionInfo[] regionInfos = geometrySurfaceDescription.getRegionImage().getRegionInfos();
                        for (GeometricRegion gr : geometricRegions) {
                            VolumeGeometricRegion vgr = (VolumeGeometricRegion) gr;
                            for (RegionInfo ri : regionInfos) {
                                if (ri.getRegionIndex() == vgr.getRegionID() && ri.isIndexInRegion(volIndex)) {
                                    boundaryXSubVolumes.add(sv);
                                }
                            }
                        }
                    }
                }
            }
        }
        Set<SubVolume> boundarySubVolumes = new HashSet<SubVolume>();
        boundarySubVolumes.addAll(boundaryXSubVolumes);
        boundarySubVolumes.addAll(boundaryYSubVolumes);
        boundarySubVolumes.addAll(boundaryZSubVolumes);
        BoundaryConditionType[] computedBct = new BoundaryConditionType[dimension * 2];
        String[] smoldynBct = new String[dimension * 2];
        String[] wallNames = new String[] { "Xm", "Xp", "Ym", "Yp", "Zm", "Zp" };
        if (boundarySubVolumes.size() >= 1) {
            for (SubVolume sv : boundarySubVolumes) {
                CompartmentSubDomain csd = (CompartmentSubDomain) mathDesc.getSubDomain(sv.getName());
                BoundaryConditionType[] bct = new BoundaryConditionType[] { csd.getBoundaryConditionXm(), csd.getBoundaryConditionXp(), csd.getBoundaryConditionYm(), csd.getBoundaryConditionYp(), csd.getBoundaryConditionZm(), csd.getBoundaryConditionZp() };
                if (computedBct[0] == null) {
                    System.arraycopy(bct, 0, computedBct, 0, dimension * 2);
                    for (int i = 0; i < dimension * 2; i++) {
                        if (computedBct[i].isPERIODIC()) {
                            throw new SolverException("Models with both surfaces and periodic boundary conditions are not supported yet.");
                        }
                        smoldynBct[i] = computedBct[i].isDIRICHLET() ? SmoldynVCellMapper.SmoldynKeyword.absorb.name() : SmoldynVCellMapper.SmoldynKeyword.reflect.name();
                    }
                } else {
                    for (int i = 0; i < dimension * 2; i++) {
                        if (!computedBct[i].compareEqual(bct[i])) {
                            throw new SolverException(wallNames[i] + " wall has different boundary conditions");
                        }
                    }
                }
            }
        }
        printWriter.println("# bounding wall surface");
        // X walls
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.start_surface + " " + VCellSmoldynKeyword.bounding_wall_surface_X);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + "(" + SmoldynVCellMapper.SmoldynKeyword.up + ") " + SmoldynVCellMapper.SmoldynKeyword.both + " " + SmoldynVCellMapper.SmoldynKeyword.reflect);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + " " + SmoldynVCellMapper.SmoldynKeyword.front + " " + smoldynBct[0]);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + " " + SmoldynVCellMapper.SmoldynKeyword.back + " " + smoldynBct[1]);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.color + " " + SmoldynVCellMapper.SmoldynKeyword.both + " 1 1 1");
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.polygon + " " + SmoldynVCellMapper.SmoldynKeyword.both + " " + SmoldynVCellMapper.SmoldynKeyword.edge);
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.max_panels + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " 2");
        // yz walls
        switch(dimension) {
            case 1:
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " +0 " + lowWall.getX());
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " -0 " + highWall.getX());
                break;
            case 2:
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " +0 " + lowWall.getX() + " " + lowWall.getY() + " " + extent.getY());
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " -0 " + highWall.getX() + " " + lowWall.getY() + " " + extent.getY());
                break;
            case 3:
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " +0 " + lowWall.getX() + " " + lowWall.getY() + " " + lowWall.getZ() + " " + extent.getY() + " " + extent.getZ());
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " -0 " + highWall.getX() + " " + lowWall.getY() + " " + lowWall.getZ() + " " + extent.getY() + " " + extent.getZ());
                break;
        }
        printWriter.println(SmoldynVCellMapper.SmoldynKeyword.end_surface);
        printWriter.println();
        if (dimension > 1) {
            // Y walls
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.start_surface + " " + VCellSmoldynKeyword.bounding_wall_surface_Y);
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + "(" + SmoldynVCellMapper.SmoldynKeyword.up + ") " + SmoldynVCellMapper.SmoldynKeyword.both + " " + SmoldynVCellMapper.SmoldynKeyword.reflect);
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + " " + SmoldynVCellMapper.SmoldynKeyword.front + " " + smoldynBct[2]);
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + " " + SmoldynVCellMapper.SmoldynKeyword.back + " " + smoldynBct[3]);
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.color + " " + SmoldynVCellMapper.SmoldynKeyword.both + " 1 1 1");
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.polygon + " " + SmoldynVCellMapper.SmoldynKeyword.both + " " + SmoldynVCellMapper.SmoldynKeyword.edge);
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.max_panels + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " 2");
            // xz walls
            switch(dimension) {
                case 2:
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " +1 " + lowWall.getX() + " " + lowWall.getY() + " " + extent.getX());
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " -1 " + lowWall.getX() + " " + highWall.getY() + " " + extent.getX());
                    break;
                case 3:
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " +1 " + lowWall.getX() + " " + lowWall.getY() + " " + lowWall.getZ() + " " + extent.getX() + " " + extent.getZ());
                    printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " -1 " + lowWall.getX() + " " + highWall.getY() + " " + lowWall.getZ() + " " + extent.getX() + " " + extent.getZ());
                    break;
            }
            printWriter.println(SmoldynVCellMapper.SmoldynKeyword.end_surface);
            printWriter.println();
            if (dimension > 2) {
                // Z walls
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.start_surface + " " + VCellSmoldynKeyword.bounding_wall_surface_Z);
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + "(" + SmoldynVCellMapper.SmoldynKeyword.up + ") " + SmoldynVCellMapper.SmoldynKeyword.both + " " + SmoldynVCellMapper.SmoldynKeyword.reflect);
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + " " + SmoldynVCellMapper.SmoldynKeyword.front + " " + smoldynBct[4]);
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.action + " " + SmoldynVCellMapper.SmoldynKeyword.all + " " + SmoldynVCellMapper.SmoldynKeyword.back + " " + smoldynBct[5]);
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.color + " " + SmoldynVCellMapper.SmoldynKeyword.both + " 1 1 1");
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.polygon + " " + SmoldynVCellMapper.SmoldynKeyword.both + " " + SmoldynVCellMapper.SmoldynKeyword.edge);
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.max_panels + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " 2");
                // xy walls
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " +2 " + lowWall.getX() + " " + lowWall.getY() + " " + lowWall.getZ() + " " + extent.getX() + " " + extent.getY());
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.panel + " " + SmoldynVCellMapper.SmoldynKeyword.rect + " -2 " + lowWall.getX() + " " + lowWall.getY() + " " + highWall.getZ() + " " + extent.getX() + " " + extent.getY());
                printWriter.println(SmoldynVCellMapper.SmoldynKeyword.end_surface);
                printWriter.println();
            }
        }
    }
}
Also used : Origin(org.vcell.util.Origin) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) RegionInfo(cbit.vcell.geometry.RegionImage.RegionInfo) BoundaryConditionType(cbit.vcell.math.BoundaryConditionType) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) SurfaceGeometricRegion(cbit.vcell.geometry.surface.SurfaceGeometricRegion) VolumeGeometricRegion(cbit.vcell.geometry.surface.VolumeGeometricRegion) GeometricRegion(cbit.vcell.geometry.surface.GeometricRegion) GeometrySpec(cbit.vcell.geometry.GeometrySpec) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SubDomain(cbit.vcell.math.SubDomain) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) Coordinate(org.vcell.util.Coordinate) SubVolume(cbit.vcell.geometry.SubVolume) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) SolverException(cbit.vcell.solver.SolverException) HashSet(java.util.HashSet)

Example 24 with GeometrySurfaceDescription

use of cbit.vcell.geometry.surface.GeometrySurfaceDescription in project vcell by virtualcell.

the class SmoldynSurfaceTessellator method cloneAndResample.

protected void cloneAndResample(Geometry geometry) throws Exception {
    // clone and resample geometry
    resampledGeometry = (Geometry) BeanUtils.cloneSerializable(geometry);
    GeometrySurfaceDescription geoSurfaceDesc = resampledGeometry.getGeometrySurfaceDescription();
    ISize newSize = simulation.getMeshSpecification().getSamplingSize();
    geoSurfaceDesc.setVolumeSampleSize(newSize);
    geoSurfaceDesc.updateAll();
    bHasNoSurface = geoSurfaceDesc.getSurfaceClasses() == null || geoSurfaceDesc.getSurfaceClasses().length == 0;
}
Also used : GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) ISize(org.vcell.util.ISize)

Example 25 with GeometrySurfaceDescription

use of cbit.vcell.geometry.surface.GeometrySurfaceDescription in project vcell by virtualcell.

the class ServerDocumentManager method saveBioModel.

/**
 * Insert the method's description here.
 * Creation date: (10/28/00 12:08:30 AM)
 */
public String saveBioModel(QueryHashtable dbc, User user, String bioModelXML, String newName, String[] independentSims) throws DataAccessException, java.sql.SQLException, java.beans.PropertyVetoException, MappingException, cbit.vcell.xml.XmlParseException {
    long start = System.currentTimeMillis();
    // 
    // this invokes "update" on the database layer
    // 
    BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML));
    forceDeepDirtyIfForeign(user, bioModel);
    boolean isSaveAsNew = true;
    // 
    if (newName != null) {
        try {
            bioModel.setName(newName);
        } catch (java.beans.PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException("couldn't set new name for BioModel: " + e.getMessage());
        }
    } else {
        isSaveAsNew = false;
    }
    Version oldVersion = bioModel.getVersion();
    BioModel origBioModel = null;
    if (oldVersion != null) {
        try {
            String origBioModelXML = getBioModelXML(dbc, user, oldVersion.getVersionKey(), false);
            origBioModel = XmlHelper.XMLToBioModel(new XMLSource(origBioModelXML));
        } catch (ObjectNotFoundException nfe) {
            if (isSaveAsNew) {
                User foceClearVersionUser = new User("foceClearVersionUser", new KeyValue("0"));
                forceDeepDirtyIfForeign(foceClearVersionUser, bioModel);
            } else {
                throw new DataAccessException("Stored model has been changed or removed, please use 'Save As..'");
            }
        }
    }
    boolean bSomethingChanged = false;
    // 
    // verify that there are no orphaned Simulations (that belonged to Applications that have null mathDescriptions ... incomplete mappings)
    // 
    // the workspace is responsible for cleaning up Simulations
    // 
    {
        Simulation[] sims = bioModel.getSimulations();
        SimulationContext[] scs = bioModel.getSimulationContexts();
        for (int i = 0; sims != null && i < sims.length; i++) {
            boolean bFound = false;
            for (int j = 0; scs != null && j < scs.length; j++) {
                if (scs[j].getMathDescription() == sims[i].getMathDescription()) {
                    bFound = true;
                }
            }
            if (!bFound) {
                throw new RuntimeException("Error: Simulation " + sims[i].getName() + " cannot be saved, no Application exists with same MathDescription");
            }
        }
    }
    // 
    // UPDATE AND SUBSTITUTE FROM BOTTOM UP
    // 
    // Image->Geometry
    // Geometry->SimContext,MathDescription
    // MathDescription->Simulation,SimulationContext
    // Model->BioModel
    // Simulation->BioModel
    // SimContext->BioModel
    // VCMetaData->BioModel
    // 
    Simulation[] simArray = bioModel.getSimulations();
    SimulationContext[] scArray = bioModel.getSimulationContexts();
    // Hashtable mathEquivHash = new Hashtable();
    long roundtripTimer = 0;
    long l1 = 0;
    long l2 = 0;
    // 
    // for each image (anywhere in document):
    // save if necessary (only once) and store saved instance in hashTable
    // 
    Hashtable<Versionable, Versionable> memoryToDatabaseHash = new Hashtable<Versionable, Versionable>();
    for (int i = 0; scArray != null && i < scArray.length; i++) {
        VCImage memoryImage = scArray[i].getGeometry().getGeometrySpec().getImage();
        if (memoryImage != null) {
            if (!memoryToDatabaseHash.containsKey(memoryImage)) {
                // 
                // didn't evaluate this image yet.
                // 
                // defaults to unchanged
                memoryToDatabaseHash.put(memoryImage, memoryImage);
                if (memoryImage.getKey() != null && memoryImage.getVersion().getName().equals(memoryImage.getName())) {
                    // 
                    // if image had previously been saved, not been forced 'dirty', and name not changed
                    // compare with original image to see if "update" is required.
                    // 
                    VCImage databaseImage = null;
                    if (origBioModel != null) {
                        for (int j = 0; j < origBioModel.getNumSimulationContexts(); j++) {
                            VCImage origImage = origBioModel.getSimulationContext(j).getGeometry().getGeometrySpec().getImage();
                            if (origImage != null && origImage.getKey().equals(memoryImage.getKey())) {
                                databaseImage = origImage;
                            }
                        }
                    }
                    if (databaseImage == null) {
                        // 
                        // saved image not found in origBioModel (too bad), get from database.
                        // 
                        l1 = System.currentTimeMillis();
                        databaseImage = dbServer.getDBTopLevel().getVCImage(dbc, user, memoryImage.getKey(), false);
                        l2 = System.currentTimeMillis();
                        roundtripTimer += l2 - l1;
                    }
                    if (databaseImage != null && !databaseImage.compareEqual(memoryImage)) {
                        KeyValue updatedImageKey = dbServer.getDBTopLevel().updateVersionable(user, memoryImage, false, true);
                        l1 = System.currentTimeMillis();
                        VCImage updatedImage = dbServer.getDBTopLevel().getVCImage(dbc, user, updatedImageKey, false);
                        l2 = System.currentTimeMillis();
                        roundtripTimer += l2 - l1;
                        memoryToDatabaseHash.put(memoryImage, updatedImage);
                        bSomethingChanged = true;
                    }
                } else {
                    // 
                    // Image hasn't been saved, has been renamed, or has been forced 'dirty'
                    // insert it with a unique name
                    // 
                    int count = 0;
                    fixNullImageName(memoryImage);
                    while (dbServer.getDBTopLevel().isNameUsed(user, VersionableType.VCImage, memoryImage.getName(), true)) {
                        try {
                            memoryImage.setName(TokenMangler.getNextRandomToken(memoryImage.getName()));
                        } catch (java.beans.PropertyVetoException e) {
                            e.printStackTrace(System.out);
                        }
                        if (count++ > 5) {
                            throw new DataAccessException("failed to find unique image name '" + memoryImage.getName() + "' is last name tried");
                        }
                    }
                    KeyValue updatedImageKey = dbServer.getDBTopLevel().insertVersionable(user, memoryImage, memoryImage.getName(), false, true);
                    l1 = System.currentTimeMillis();
                    VCImage updatedImage = dbServer.getDBTopLevel().getVCImage(dbc, user, updatedImageKey, false);
                    l2 = System.currentTimeMillis();
                    roundtripTimer += l2 - l1;
                    memoryToDatabaseHash.put(memoryImage, updatedImage);
                    bSomethingChanged = true;
                }
            }
        }
    }
    // 
    for (int i = 0; scArray != null && i < scArray.length; i++) {
        Geometry memoryGeometry = scArray[i].getGeometry();
        if (!memoryToDatabaseHash.containsKey(memoryGeometry)) {
            // 
            // didn't evaluate this geometry yet.
            // 
            // defaults to unchanged
            memoryToDatabaseHash.put(memoryGeometry, memoryGeometry);
            boolean bMustSaveGeometry = false;
            VCImage geometryImage = memoryGeometry.getGeometrySpec().getImage();
            if (geometryImage != null && memoryToDatabaseHash.get(geometryImage) != geometryImage) {
                // 
                // image had changed and was saved, load saved image into geometry and force a save of this geometry.
                // 
                memoryGeometry.getGeometrySpec().setImage((VCImage) memoryToDatabaseHash.get(geometryImage));
                geometryImage = (VCImage) memoryToDatabaseHash.get(geometryImage);
                bMustSaveGeometry = true;
            }
            if (memoryGeometry.getKey() != null && memoryGeometry.getVersion().getName().equals(memoryGeometry.getName())) {
                if (!bMustSaveGeometry) {
                    // 
                    // if geometry had previously been saved, not been forced 'dirty', and name not changed
                    // compare with original geometry to see if "update" is required.
                    // 
                    Geometry databaseGeometry = null;
                    if (origBioModel != null) {
                        for (int j = 0; j < origBioModel.getNumSimulationContexts(); j++) {
                            Geometry origGeometry = origBioModel.getSimulationContext(j).getGeometry();
                            if (origGeometry != null && origGeometry.getKey().equals(memoryGeometry.getKey())) {
                                databaseGeometry = origGeometry;
                            }
                        }
                    }
                    if (databaseGeometry == null) {
                        // 
                        // saved geometry not found in origBioModel (too bad), get from database.
                        // 
                        l1 = System.currentTimeMillis();
                        databaseGeometry = dbServer.getDBTopLevel().getGeometry(dbc, user, memoryGeometry.getKey(), false);
                        l2 = System.currentTimeMillis();
                        roundtripTimer += l2 - l1;
                    }
                    if (databaseGeometry != null && !databaseGeometry.compareEqual(memoryGeometry)) {
                        bMustSaveGeometry = true;
                    }
                    if (!bMustSaveGeometry && memoryGeometry.getDimension() > 0) {
                        GeometrySurfaceDescription geomSurfDescr = memoryGeometry.getGeometrySurfaceDescription();
                        SurfaceClass[] surfClassArr = geomSurfDescr.getSurfaceClasses();
                        for (int j = 0; surfClassArr != null && j < surfClassArr.length; j++) {
                            if (surfClassArr[j].getKey() == null) {
                                bMustSaveGeometry = true;
                                break;
                            }
                        }
                    }
                }
                if (bMustSaveGeometry) {
                    KeyValue updatedImageKey = (geometryImage != null) ? (geometryImage.getKey()) : (null);
                    KeyValue updatedGeometryKey = dbServer.getDBTopLevel().updateVersionable(dbc, user, memoryGeometry, updatedImageKey, false, true);
                    l1 = System.currentTimeMillis();
                    Geometry updatedGeometry = dbServer.getDBTopLevel().getGeometry(dbc, user, updatedGeometryKey, false);
                    l2 = System.currentTimeMillis();
                    roundtripTimer += l2 - l1;
                    memoryToDatabaseHash.put(memoryGeometry, updatedGeometry);
                    bSomethingChanged = true;
                }
            } else {
                // 
                // Geometry hasn't been saved, has been renamed, or has been forced 'dirty'
                // insert it with a unique name
                // 
                int count = 0;
                while (dbServer.getDBTopLevel().isNameUsed(user, VersionableType.Geometry, memoryGeometry.getName(), true)) {
                    try {
                        memoryGeometry.setName(TokenMangler.getNextRandomToken(memoryGeometry.getName()));
                    } catch (java.beans.PropertyVetoException e) {
                        e.printStackTrace(System.out);
                    }
                    if (count++ > 5) {
                        throw new DataAccessException("failed to find unique geometry name '" + memoryGeometry.getName() + "' is last name tried");
                    }
                }
                KeyValue updatedImageKey = (geometryImage != null) ? (geometryImage.getKey()) : (null);
                KeyValue updatedGeometryKey = dbServer.getDBTopLevel().insertVersionable(dbc, user, memoryGeometry, updatedImageKey, memoryGeometry.getName(), false, true);
                l1 = System.currentTimeMillis();
                Geometry updatedGeometry = dbServer.getDBTopLevel().getGeometry(dbc, user, updatedGeometryKey, false);
                l2 = System.currentTimeMillis();
                roundtripTimer += l2 - l1;
                memoryToDatabaseHash.put(memoryGeometry, updatedGeometry);
                bSomethingChanged = true;
            }
        }
    }
    // 
    // for each MathDescription in document:
    // substitute saved geometry's into SimulationContext and
    // save SimulationContext if necessary (only once) and store saved instance in hashtable.
    // 
    Hashtable<MathDescription, MathCompareResults> mathEquivalencyHash = new Hashtable<MathDescription, MathCompareResults>();
    for (int i = 0; scArray != null && i < scArray.length; i++) {
        MathDescription memoryMathDescription = scArray[i].getMathDescription();
        if (!memoryToDatabaseHash.containsKey(memoryMathDescription)) {
            // 
            // didn't evaluate this SimulationContext yet.
            // 
            // defaults to unchanged
            memoryToDatabaseHash.put(memoryMathDescription, memoryMathDescription);
            boolean bMustSaveMathDescription = false;
            Geometry scGeometry = memoryMathDescription.getGeometry();
            if (scGeometry != null && memoryToDatabaseHash.get(scGeometry) != scGeometry) {
                // 
                // geometry had changed and was saved, load saved geometry into SimulationContext (and it's MathDescription) and force a save of this SimulationContext.
                // 
                memoryMathDescription.setGeometry((Geometry) memoryToDatabaseHash.get(scGeometry));
                bMustSaveMathDescription = true;
            }
            MathDescription databaseMathDescription = null;
            if (memoryMathDescription.getKey() != null) {
                // 
                if (origBioModel != null) {
                    for (int j = 0; j < origBioModel.getNumSimulationContexts(); j++) {
                        MathDescription math = origBioModel.getSimulationContext(j).getMathDescription();
                        if (math.getKey().equals(memoryMathDescription.getKey())) {
                            databaseMathDescription = math;
                        }
                    }
                }
                if (databaseMathDescription == null) {
                    // 
                    // saved mathDescription not found in origBioModel (too bad), get from database.
                    // 
                    l1 = System.currentTimeMillis();
                    databaseMathDescription = dbServer.getDBTopLevel().getMathDescription(dbc, user, memoryMathDescription.getKey());
                    l2 = System.currentTimeMillis();
                    roundtripTimer += l2 - l1;
                }
                if (databaseMathDescription != null && !databaseMathDescription.compareEqual(memoryMathDescription)) {
                    bMustSaveMathDescription = true;
                }
            } else {
                bMustSaveMathDescription = true;
            }
            if (bMustSaveMathDescription) {
                MathCompareResults mathCompareResults = null;
                if (databaseMathDescription != null) {
                    try {
                        mathCompareResults = MathDescription.testEquivalency(SimulationSymbolTable.createMathSymbolTableFactory(), memoryMathDescription, databaseMathDescription);
                        if (mathCompareResults != null && !mathCompareResults.isEquivalent() && (mathCompareResults.decision.equals(Decision.MathDifferent_DIFFERENT_NUMBER_OF_VARIABLES) || mathCompareResults.decision.equals(Decision.MathDifferent_VARIABLE_NOT_FOUND_AS_FUNCTION))) {
                            // 
                            // if there is a different number of variables or cannot find variables by name (even considering change of state variables)
                            // then try the VCell 4.8 generated math.
                            // 
                            MathDescription mathDesc_4_8 = new MathMapping_4_8(scArray[i]).getMathDescription();
                            mathCompareResults = MathDescription.testEquivalency(SimulationSymbolTable.createMathSymbolTableFactory(), mathDesc_4_8, databaseMathDescription);
                        }
                    } catch (Exception e) {
                        e.printStackTrace(System.out);
                        mathCompareResults = new MathCompareResults(Decision.MathDifferent_FAILURE_UNKNOWN, "Exception: '" + e.getMessage() + "'");
                        System.out.println("FAILED TO COMPARE THE FOLLOWING MATH DESCRIPTIONS");
                        try {
                            System.out.println("MemoryMathDescription:\n" + ((memoryMathDescription != null) ? (memoryMathDescription.getVCML_database()) : ("null")));
                            System.out.println("DatabaseMathDescription:\n" + ((databaseMathDescription != null) ? (databaseMathDescription.getVCML_database()) : ("null")));
                        } catch (Exception e2) {
                            System.out.println("couldn't print math descriptions");
                        }
                    }
                } else {
                    mathCompareResults = new MathCompareResults(Decision.MathDifferent_NOT_SAVED);
                }
                // 
                // MathDescription hasn't been saved, has been renamed, or has been forced 'dirty'
                // insert it with a any name (doens't have to be unique ... mathDescription is not a top-level versionable).
                // 
                KeyValue updatedGeometryKey = memoryMathDescription.getGeometry().getKey();
                KeyValue updatedMathDescriptionKey = null;
                if (memoryMathDescription.getVersion() != null && memoryMathDescription.getVersion().getName().equals(memoryMathDescription.getName())) {
                    updatedMathDescriptionKey = dbServer.getDBTopLevel().updateVersionable(user, memoryMathDescription, updatedGeometryKey, false, true);
                } else {
                    updatedMathDescriptionKey = dbServer.getDBTopLevel().insertVersionable(user, memoryMathDescription, updatedGeometryKey, memoryMathDescription.getName(), false, true);
                }
                l1 = System.currentTimeMillis();
                MathDescription updatedMathDescription = dbServer.getDBTopLevel().getMathDescription(dbc, user, updatedMathDescriptionKey);
                l2 = System.currentTimeMillis();
                roundtripTimer += l2 - l1;
                memoryToDatabaseHash.put(memoryMathDescription, updatedMathDescription);
                mathEquivalencyHash.put(updatedMathDescription, mathCompareResults);
                bSomethingChanged = true;
            } else {
                mathEquivalencyHash.put(memoryMathDescription, new MathCompareResults(Decision.MathEquivalent_SAME_MATHDESC_AS_IN_DB));
            }
        }
    }
    // 
    // update physiology
    // 
    {
        Model memoryModel = bioModel.getModel();
        // preload with unchanged.
        memoryToDatabaseHash.put(memoryModel, memoryModel);
        if (memoryModel.getKey() != null && memoryModel.getVersion().getName().equals(memoryModel.getName())) {
            // 
            // if Model had previously been saved, not been forced 'dirty', and name not changed
            // compare with original Model to see if "update" is required.
            // 
            Model databaseModel = null;
            if (origBioModel != null) {
                if (origBioModel.getModel().getKey().equals(memoryModel.getKey())) {
                    databaseModel = origBioModel.getModel();
                }
            }
            if (databaseModel == null) {
                // 
                // saved model not found in origBioModel (too bad), get from database.
                // 
                l1 = System.currentTimeMillis();
                databaseModel = dbServer.getDBTopLevel().getModel(dbc, user, memoryModel.getKey());
                l2 = System.currentTimeMillis();
                roundtripTimer += l2 - l1;
            }
            if (databaseModel != null && !databaseModel.compareEqual(memoryModel)) {
                KeyValue updatedModelKey = dbServer.getDBTopLevel().updateVersionable(user, memoryModel, false, true);
                l1 = System.currentTimeMillis();
                Model updatedModel = dbServer.getDBTopLevel().getModel(dbc, user, updatedModelKey);
                l2 = System.currentTimeMillis();
                roundtripTimer += l2 - l1;
                memoryToDatabaseHash.put(memoryModel, updatedModel);
                bSomethingChanged = true;
            }
        } else {
            // 
            // Model hasn't been saved, has been renamed, or has been forced 'dirty'
            // insert it with a any name (doens't have to be unique ... mathDescription is not a top-level versionable).
            // 
            KeyValue updatedModelKey = dbServer.getDBTopLevel().insertVersionable(user, memoryModel, memoryModel.getName(), false, true);
            l1 = System.currentTimeMillis();
            Model updatedModel = dbServer.getDBTopLevel().getModel(dbc, user, updatedModelKey);
            l2 = System.currentTimeMillis();
            roundtripTimer += l2 - l1;
            memoryToDatabaseHash.put(memoryModel, updatedModel);
            bSomethingChanged = true;
        }
    }
    // 
    for (int i = 0; scArray != null && i < scArray.length; i++) {
        SimulationContext memorySimContext = scArray[i];
        if (!memoryToDatabaseHash.containsKey(memorySimContext)) {
            // 
            // didn't evaluate this SimulationContext yet.
            // 
            // defaults to unchanged
            memoryToDatabaseHash.put(memorySimContext, memorySimContext);
            boolean bMustSaveSimContext = false;
            Geometry scGeometry = memorySimContext.getGeometry();
            if (scGeometry != null && memoryToDatabaseHash.get(scGeometry) != scGeometry) {
                // 
                // geometry had changed and was saved, load saved geometry into SimulationContext (and force a save)
                // 
                memorySimContext.setGeometry((Geometry) memoryToDatabaseHash.get(scGeometry));
                bMustSaveSimContext = true;
            }
            MathDescription scMathDescription = memorySimContext.getMathDescription();
            if (scMathDescription != null && memoryToDatabaseHash.get(scMathDescription) != scMathDescription) {
                // 
                // mathDescription had changed and was saved, load saved mathDescription into SimulationContext (and force a save)
                // 
                memorySimContext.setMathDescription((MathDescription) memoryToDatabaseHash.get(scMathDescription));
                bMustSaveSimContext = true;
            }
            Model scModel = memorySimContext.getModel();
            if (scModel != null && memoryToDatabaseHash.get(scModel) != scModel) {
                // 
                // model had changed and was saved, load saved model into SimulationContext (and force a save)
                // 
                memorySimContext.setModel((Model) memoryToDatabaseHash.get(scModel));
                bMustSaveSimContext = true;
            }
            if (memorySimContext.getKey() != null && memorySimContext.getVersion().getName().equals(memorySimContext.getName())) {
                if (!bMustSaveSimContext) {
                    // 
                    // if SimulationContext had previously been saved, not been forced 'dirty', and name not changed
                    // compare with original SimulationContext to see if "update" is required.
                    // 
                    SimulationContext databaseSimContext = null;
                    if (origBioModel != null) {
                        for (int j = 0; j < origBioModel.getNumSimulationContexts(); j++) {
                            if (origBioModel.getSimulationContext(j).getKey().equals(memorySimContext.getKey())) {
                                databaseSimContext = origBioModel.getSimulationContext(j);
                            }
                        }
                    }
                    if (databaseSimContext == null) {
                        // 
                        // saved geometry not found in origBioModel (too bad), get from database.
                        // 
                        l1 = System.currentTimeMillis();
                        databaseSimContext = dbServer.getDBTopLevel().getSimulationContext(dbc, user, memorySimContext.getKey());
                        l2 = System.currentTimeMillis();
                        roundtripTimer += l2 - l1;
                    }
                    if (databaseSimContext != null && !databaseSimContext.compareEqual(memorySimContext)) {
                        bMustSaveSimContext = true;
                    }
                }
                if (bMustSaveSimContext) {
                    KeyValue updatedGeometryKey = memorySimContext.getGeometry().getKey();
                    KeyValue updatedMathDescriptionKey = memorySimContext.getMathDescription().getKey();
                    Model updatedModel = memorySimContext.getModel();
                    KeyValue updatedSimContextKey = dbServer.getDBTopLevel().updateVersionable(user, memorySimContext, updatedMathDescriptionKey, updatedModel, updatedGeometryKey, false, true);
                    l1 = System.currentTimeMillis();
                    SimulationContext updatedSimContext = dbServer.getDBTopLevel().getSimulationContext(dbc, user, updatedSimContextKey);
                    l2 = System.currentTimeMillis();
                    roundtripTimer += l2 - l1;
                    // 
                    // make sure mathDescription is a single reference (for this app and all of it's Simulations).
                    // 
                    updatedSimContext.setMathDescription((MathDescription) memorySimContext.getMathDescription());
                    memoryToDatabaseHash.put(memorySimContext, updatedSimContext);
                    bSomethingChanged = true;
                }
            } else {
                // 
                // SimulationContext hasn't been saved, has been renamed, or has been forced 'dirty'
                // 
                KeyValue updatedGeometryKey = memorySimContext.getGeometry().getKey();
                KeyValue updatedMathDescriptionKey = memorySimContext.getMathDescription().getKey();
                Model updatedModel = memorySimContext.getModel();
                KeyValue updatedSimContextKey = dbServer.getDBTopLevel().insertVersionable(user, memorySimContext, updatedMathDescriptionKey, updatedModel, updatedGeometryKey, memorySimContext.getName(), false, true);
                l1 = System.currentTimeMillis();
                SimulationContext updatedSimContext = dbServer.getDBTopLevel().getSimulationContext(dbc, user, updatedSimContextKey);
                l2 = System.currentTimeMillis();
                roundtripTimer += l2 - l1;
                // 
                // make sure mathDescription is a single reference (for this app and all of it's Simulations).
                // 
                updatedSimContext.setMathDescription((MathDescription) memorySimContext.getMathDescription());
                memoryToDatabaseHash.put(memorySimContext, updatedSimContext);
                bSomethingChanged = true;
            }
        }
    }
    // 
    for (int i = 0; simArray != null && i < simArray.length; i++) {
        Simulation memorySimulation = simArray[i];
        if (!memoryToDatabaseHash.containsKey(memorySimulation)) {
            // 
            // didn't evaluate this Simulation yet.
            // 
            // defaults to unchanged
            memoryToDatabaseHash.put(memorySimulation, memorySimulation);
            boolean bMustSaveSimulation = false;
            MathDescription simMathDescription = memorySimulation.getMathDescription();
            if (simMathDescription != null && memoryToDatabaseHash.get(simMathDescription) != simMathDescription) {
                if (memoryToDatabaseHash.get(simMathDescription) != null) {
                    // make sure mathDescription hasn't already propagated (newer math won't be in hashtable)
                    // 
                    // mathDescription had changed and was saved, load saved mathDescription into Simulation (and force a save)
                    // 
                    memorySimulation.setMathDescription((MathDescription) memoryToDatabaseHash.get(simMathDescription));
                    bMustSaveSimulation = true;
                }
            }
            Simulation databaseSimulation = null;
            // 
            if (memorySimulation.getKey() != null) {
                if (origBioModel != null) {
                    for (int j = 0; j < origBioModel.getNumSimulations(); j++) {
                        if (origBioModel.getSimulation(j).getKey().equals(memorySimulation.getKey())) {
                            databaseSimulation = origBioModel.getSimulation(j);
                        }
                    }
                }
                if (databaseSimulation == null) {
                    // 
                    // saved simulation not found in origBioModel (too bad), get from database.
                    // 
                    l1 = System.currentTimeMillis();
                    databaseSimulation = dbServer.getDBTopLevel().getSimulation(dbc, user, memorySimulation.getKey());
                    l2 = System.currentTimeMillis();
                    roundtripTimer += l2 - l1;
                }
                if (databaseSimulation != null) {
                    if (!memorySimulation.compareEqual(databaseSimulation)) {
                        bMustSaveSimulation = true;
                    }
                }
                if (!memorySimulation.getVersion().getName().equals(memorySimulation.getName())) {
                    // name was changed.
                    bMustSaveSimulation = true;
                }
            } else {
                // never been saved.
                bMustSaveSimulation = true;
            }
            if (bMustSaveSimulation) {
                boolean bMathematicallyEquivalent = false;
                if (databaseSimulation != null) {
                    // 
                    // if to be forced "independent", then set equivalent to false
                    // 
                    boolean bForceIndependent = false;
                    for (int j = 0; independentSims != null && j < independentSims.length; j++) {
                        if (independentSims[j].equals(memorySimulation.getName())) {
                            bForceIndependent = true;
                        }
                    }
                    // 
                    // check for math equivalency first
                    // 
                    MathCompareResults mathCompareResults = mathEquivalencyHash.get(memorySimulation.getMathDescription());
                    bMathematicallyEquivalent = !bForceIndependent && Simulation.testEquivalency(memorySimulation, databaseSimulation, mathCompareResults);
                    // 
                    if (bMathematicallyEquivalent) {
                        VCSimulationIdentifier vcSimulationIdentifier = databaseSimulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
                        SimulationStatusPersistent simStatus = dbServer.getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
                        if (simStatus == null || !simStatus.getHasData()) {
                            bMathematicallyEquivalent = false;
                        }
                    }
                }
                KeyValue updatedMathDescriptionKey = memorySimulation.getMathDescription().getKey();
                KeyValue updatedSimulationKey = null;
                if (memorySimulation.getKey() != null && memorySimulation.getVersion().getName().equals(memorySimulation.getName())) {
                    // name not changed, update simulation (but pass in database Simulation to check for parent-equivalence)
                    updatedSimulationKey = dbServer.getDBTopLevel().updateVersionable(user, memorySimulation, updatedMathDescriptionKey, false, bMathematicallyEquivalent, true);
                } else {
                    // name changed, insert simulation (but pass in database Simulation to check for parent-equivalence)
                    updatedSimulationKey = dbServer.getDBTopLevel().insertVersionable(user, memorySimulation, updatedMathDescriptionKey, memorySimulation.getName(), false, bMathematicallyEquivalent, true);
                }
                l1 = System.currentTimeMillis();
                Simulation updatedSimulation = dbServer.getDBTopLevel().getSimulation(dbc, user, updatedSimulationKey);
                l2 = System.currentTimeMillis();
                roundtripTimer += l2 - l1;
                // 
                // make sure mathDescription is a single reference (for an app and all of it's Simulations).
                // 
                updatedSimulation.setMathDescription((MathDescription) memorySimulation.getMathDescription());
                memoryToDatabaseHash.put(memorySimulation, updatedSimulation);
                bSomethingChanged = true;
            }
        }
    }
    boolean bMustSaveVCMetaData = false;
    if (origBioModel != null) {
        // 
        // for the VCMetaData in the document:
        // save VCMetaData if necessary (only once) and store saved instance in hashtable.
        // 
        // The persisted VCMetaData doesn't have any foreign keys
        // (when annotating a simulation ... we don't point to the simulation,
        // we use the text-based VCID that is stored in URIBindingList in the XML serialization
        // 
        // Therefore, there are no additional dependencies that we have to update during the
        // incremental save and force propagation to save the VCMetaData.
        // 
        VCMetaData memoryVCMetaData = bioModel.getVCMetaData();
        VCMetaData databaseVCMetaData = origBioModel.getVCMetaData();
        // 
        if (databaseVCMetaData == null || !databaseVCMetaData.compareEquals(memoryVCMetaData)) {
            bMustSaveVCMetaData = true;
            bSomethingChanged = true;
        }
    }
    if (bSomethingChanged || origBioModel == null || !bioModel.compareEqual(origBioModel)) {
        // 
        // create new BioModelMetaData and save to server
        // 
        KeyValue modelKey = ((Model) memoryToDatabaseHash.get(bioModel.getModel())).getKey();
        KeyValue[] scKeys = new KeyValue[bioModel.getNumSimulationContexts()];
        for (int i = 0; i < bioModel.getNumSimulationContexts(); i++) {
            scKeys[i] = ((SimulationContext) memoryToDatabaseHash.get(bioModel.getSimulationContext(i))).getKey();
        }
        KeyValue[] simKeys = new KeyValue[bioModel.getNumSimulations()];
        for (int i = 0; i < bioModel.getNumSimulations(); i++) {
            simKeys[i] = ((Simulation) memoryToDatabaseHash.get(bioModel.getSimulation(i))).getKey();
        }
        // @TODO Add VC_METADATA table ... pointed to by VC_BIOMODEL (metadataref on delete cascade)
        // @TODO Write script to populate VC_METADATA from VC_MIRIAM
        // @TODO save VCMetaData from this BioModel into VC_METADATA .. stick in memoryToDatabaseHash
        // 
        BioModelMetaData bioModelMetaData = null;
        String vcMetaDataXML = XmlHelper.vcMetaDataToXML(bioModel.getVCMetaData(), bioModel);
        if (oldVersion == null) {
            bioModelMetaData = new BioModelMetaData(modelKey, scKeys, simKeys, vcMetaDataXML, bioModel.getName(), bioModel.getDescription());
        } else {
            bioModelMetaData = new BioModelMetaData(oldVersion, modelKey, scKeys, simKeys, vcMetaDataXML);
            if (!bioModel.getDescription().equals(oldVersion.getAnnot())) {
                try {
                    bioModelMetaData.setDescription(bioModel.getDescription());
                } catch (java.beans.PropertyVetoException e) {
                    e.printStackTrace(System.out);
                }
            }
        }
        // bioModelMetaData.setMIRIAMAnnotation(bioModel.getMIRIAMAnnotation());
        BioModelMetaData updatedBioModelMetaData = null;
        if (bioModel.getVersion() == null || !bioModel.getVersion().getName().equals(bioModel.getName())) {
            KeyValue updatedBioModelKey = dbServer.getDBTopLevel().insertVersionable(user, bioModelMetaData, null, /*hack*/
            bioModel.getName(), false, true);
            l1 = System.currentTimeMillis();
            updatedBioModelMetaData = dbServer.getDBTopLevel().getBioModelMetaData(dbc, user, updatedBioModelKey);
            l2 = System.currentTimeMillis();
            roundtripTimer += l2 - l1;
        } else {
            KeyValue updatedBioModelKey = dbServer.getDBTopLevel().updateVersionable(user, bioModelMetaData, null, /*hack*/
            false, true);
            l1 = System.currentTimeMillis();
            updatedBioModelMetaData = dbServer.getDBTopLevel().getBioModelMetaData(dbc, user, updatedBioModelKey);
            l2 = System.currentTimeMillis();
            roundtripTimer += l2 - l1;
        }
        // 
        // (THIS IS THE REALLY SCAREY PART...NOT GETTING A FRESH VIEW OF EVERYTING FROM THE DATABASE FOR CREATING THE XML)
        // 
        // bioModelXML = getBioModelXML(user,updatedBioModelMetaData.getVersion().getVersionKey());
        BioModel updatedBioModel = new BioModel(updatedBioModelMetaData.getVersion());
        // updatedBioModel.setMIRIAMAnnotation(updatedBioModelMetaData.getMIRIAMAnnotation());
        updatedBioModel.setModel((Model) memoryToDatabaseHash.get(bioModel.getModel()));
        for (int i = 0; i < bioModel.getNumSimulationContexts(); i++) {
            updatedBioModel.addSimulationContext((SimulationContext) memoryToDatabaseHash.get(bioModel.getSimulationContext(i)));
        }
        for (int i = 0; i < bioModel.getNumSimulations(); i++) {
            updatedBioModel.addSimulation((Simulation) memoryToDatabaseHash.get(bioModel.getSimulation(i)));
        }
        updatedBioModel.setVCMetaData(XmlHelper.xmlToVCMetaData(updatedBioModel.getVCMetaData(), updatedBioModel, vcMetaDataXML));
        // TODO must replace this with proper persistance.
        updatedBioModel.getPathwayModel().merge(bioModel.getPathwayModel());
        updatedBioModel.getRelationshipModel().merge(bioModel.getRelationshipModel());
        bioModelXML = cbit.vcell.xml.XmlHelper.bioModelToXML(updatedBioModel);
        dbServer.insertVersionableChildSummary(user, VersionableType.BioModelMetaData, updatedBioModel.getVersion().getVersionKey(), updatedBioModel.createBioModelChildSummary().toDatabaseSerialization());
        dbServer.insertVersionableXML(user, VersionableType.BioModelMetaData, updatedBioModel.getVersion().getVersionKey(), bioModelXML);
        System.out.println("------------------------------> Total time: " + ((double) (System.currentTimeMillis() - start)) / 1000);
        System.out.println("------------------------------> Time spent on roundtrip: " + ((double) roundtripTimer) / 1000);
        return bioModelXML;
    } else {
        System.out.println("------------------------------> Total time: " + ((double) (System.currentTimeMillis() - start)) / 1000);
        System.out.println("------------------------------> Time spent on roundtrip: " + ((double) roundtripTimer) / 1000);
        return bioModelXML;
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) SurfaceClass(cbit.vcell.geometry.SurfaceClass) MathDescription(cbit.vcell.math.MathDescription) VCImage(cbit.image.VCImage) BioModelMetaData(cbit.vcell.biomodel.BioModelMetaData) PropertyVetoException(java.beans.PropertyVetoException) Versionable(org.vcell.util.document.Versionable) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) Version(org.vcell.util.document.Version) MathCompareResults(cbit.vcell.math.MathCompareResults) DataAccessException(org.vcell.util.DataAccessException) Hashtable(java.util.Hashtable) QueryHashtable(cbit.sql.QueryHashtable) SimulationStatusPersistent(cbit.vcell.server.SimulationStatusPersistent) MathMapping_4_8(cbit.vcell.mapping.vcell_4_8.MathMapping_4_8) SimulationContext(cbit.vcell.mapping.SimulationContext) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) PropertyVetoException(java.beans.PropertyVetoException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) MappingException(cbit.vcell.mapping.MappingException) Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) MathModel(cbit.vcell.mathmodel.MathModel) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) XMLSource(cbit.vcell.xml.XMLSource)

Aggregations

GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)25 ISize (org.vcell.util.ISize)14 GeometricRegion (cbit.vcell.geometry.surface.GeometricRegion)11 SurfaceGeometricRegion (cbit.vcell.geometry.surface.SurfaceGeometricRegion)10 VolumeGeometricRegion (cbit.vcell.geometry.surface.VolumeGeometricRegion)10 Geometry (cbit.vcell.geometry.Geometry)9 SubVolume (cbit.vcell.geometry.SubVolume)9 ExpressionException (cbit.vcell.parser.ExpressionException)8 SolverException (cbit.vcell.solver.SolverException)8 SurfaceClass (cbit.vcell.geometry.SurfaceClass)7 VCImage (cbit.image.VCImage)6 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)6 GeometrySpec (cbit.vcell.geometry.GeometrySpec)6 Extent (org.vcell.util.Extent)6 ImageException (cbit.image.ImageException)5 BioModel (cbit.vcell.biomodel.BioModel)5 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)5 PropertyVetoException (java.beans.PropertyVetoException)5 ArrayList (java.util.ArrayList)5 Origin (org.vcell.util.Origin)5