use of org.vcell.util.CommentStringTokenizer in project vcell by virtualcell.
the class CartesianMesh method readFromFiles.
// private void writeContourElements(OutputStream out)
// {
// int i;
// //
// // write out contour elements (if present)
// //
// if (getNumContourElements()>0){
// out.println(" ContourElements {\n");
// out.println(" %d\n",(int)getNumContourElements());
// //
// // index volumeIndex begin.x begin.y begin.z end.x, end.y end.z neighbor(prev) neighbor(next)
// //
// for (i=0;i<getNumContourElements();i++){
// ContourElement *cEl = getContourElement(i);
// int neighborPrev = -1;
// int neighborNext = -1;
// if (cEl->getBorder() == CONTOUR_BEGIN){
// neighborPrev = -1;
// neighborNext = i+1;
// }else if (cEl->getBorder() == CONTOUR_END){
// neighborPrev = i-1;
// neighborNext = -1;
// }else if (cEl->getBorder() == CONTOUR_INTERIOR){
// neighborPrev = i-1;
// neighborNext = i+1;
// }else{
// throw new Exception("Error writing contour mesh, contour element(%ld) has an illegal ContourBorder type = %d\n",i,cEl->getBorder());
// }
// out.println(" %ld %ld %lg %lg %lg %lg %lg %lg %ld %ld\n",cEl->getElementIndex(),cEl->getVolumeIndex(),
// cEl->getBegin().x,cEl->getBegin().y,cEl->getBegin().z,
// cEl->getEnd().x, cEl->getEnd().y, cEl->getEnd().z,
// neighborPrev, neighborNext);
// }
// out.println(" }\n"); // end ContourElements
// }
// }
public static CartesianMesh readFromFiles(File meshFile, File meshmetricsFile, File subdomainFile) throws IOException, MathException {
//
// read meshFile and parse into 'mesh' object
//
BufferedReader meshReader = null;
BufferedReader meshMetricsReader = null;
try {
meshReader = new BufferedReader(new FileReader(meshFile));
CommentStringTokenizer meshST = new CommentStringTokenizer(meshReader);
CommentStringTokenizer membraneMeshMetricsST = null;
if (meshmetricsFile != null) {
meshMetricsReader = new BufferedReader(new FileReader(meshmetricsFile));
membraneMeshMetricsST = new CommentStringTokenizer(meshMetricsReader);
}
CartesianMesh mesh = new CartesianMesh();
MembraneMeshMetrics membraneMeshMetrics = null;
if (membraneMeshMetricsST != null) {
membraneMeshMetrics = mesh.readMembraneMeshMetrics(membraneMeshMetricsST);
}
if (subdomainFile != null) {
mesh.subdomainInfo = SubdomainInfo.read(subdomainFile);
}
mesh.read(meshST, membraneMeshMetrics);
return mesh;
} finally {
if (meshReader != null) {
try {
meshReader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (meshMetricsReader != null) {
try {
meshMetricsReader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
use of org.vcell.util.CommentStringTokenizer in project vcell by virtualcell.
the class ClientRequestManager method createNewDocument.
/**
* Insert the method's description here.
* Creation date: (5/10/2004 3:48:16 PM)
*/
public AsynchClientTask[] createNewDocument(final TopLevelWindowManager requester, final VCDocument.DocumentCreationInfo documentCreationInfo) {
// throws UserCancelException, Exception {
/* asynchronous and not blocking any window */
AsynchClientTask[] taskArray = null;
final int createOption = documentCreationInfo.getOption();
switch(documentCreationInfo.getDocumentType()) {
case BIOMODEL_DOC:
{
AsynchClientTask task1 = new AsynchClientTask("creating biomodel", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
BioModel bioModel = createDefaultBioModelDocument(null);
hashTable.put("doc", bioModel);
}
};
taskArray = new AsynchClientTask[] { task1 };
break;
}
case MATHMODEL_DOC:
{
if ((createOption == VCDocument.MATH_OPTION_NONSPATIAL) || (createOption == VCDocument.MATH_OPTION_SPATIAL_EXISTS)) {
AsynchClientTask task2 = new AsynchClientTask("creating mathmodel", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry geometry = null;
if (createOption == VCDocument.MATH_OPTION_NONSPATIAL) {
geometry = new Geometry("Untitled", 0);
} else {
geometry = (Geometry) hashTable.get(GEOMETRY_KEY);
}
MathModel mathModel = createMathModel("Untitled", geometry);
mathModel.setName("MathModel" + (getMdiManager().getNumCreatedDocumentWindows() + 1));
hashTable.put("doc", mathModel);
}
};
if (createOption == VCDocument.MATH_OPTION_SPATIAL_EXISTS) {
AsynchClientTask task1 = createSelectDocTask(requester);
AsynchClientTask task1b = createSelectLoadGeomTask(requester);
taskArray = new AsynchClientTask[] { task1, task1b, task2 };
} else {
taskArray = new AsynchClientTask[] { task2 };
}
break;
} else if (createOption == VCDocument.MATH_OPTION_FROMBIOMODELAPP) {
AsynchClientTask task1 = new AsynchClientTask("select biomodel application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// spatial or non-spatial
BioModelInfo bioModelInfo = (BioModelInfo) DialogUtils.getDBTreePanelSelection(requester.getComponent(), getMdiManager().getDatabaseWindowManager().getBioModelDbTreePanel(), "Open", "Select BioModel");
if (bioModelInfo != null) {
// may throw UserCancelException
hashTable.put("bioModelInfo", bioModelInfo);
}
}
};
AsynchClientTask task2 = new AsynchClientTask("find sim contexts in biomodel application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// spatial or non-spatial
// Get the simContexts in the corresponding BioModel
BioModelInfo bioModelInfo = (BioModelInfo) hashTable.get("bioModelInfo");
SimulationContext[] simContexts = getDocumentManager().getBioModel(bioModelInfo).getSimulationContexts();
if (simContexts != null) {
// may throw UserCancelException
hashTable.put("simContexts", simContexts);
}
}
};
AsynchClientTask task3 = new AsynchClientTask("create math model from biomodel application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
SimulationContext[] simContexts = (SimulationContext[]) hashTable.get("simContexts");
String[] simContextNames = new String[simContexts.length];
if (simContextNames.length == 0) {
throw new RuntimeException("no application is available");
} else {
for (int i = 0; i < simContexts.length; i++) {
simContextNames[i] = simContexts[i].getName();
}
Component component = requester.getComponent();
// Get the simContext names, so that user can choose which simContext math to import
String simContextChoice = (String) PopupGenerator.showListDialog(component, simContextNames, "Please select Application");
if (simContextChoice == null) {
throw UserCancelException.CANCEL_DB_SELECTION;
}
SimulationContext chosenSimContext = null;
for (int i = 0; i < simContexts.length; i++) {
if (simContexts[i].getName().equals(simContextChoice)) {
chosenSimContext = simContexts[i];
break;
}
}
Objects.requireNonNull(chosenSimContext);
BioModelInfo bioModelInfo = (BioModelInfo) hashTable.get("bioModelInfo");
// Get corresponding mathDesc to create new mathModel and return.
String newName = bioModelInfo.getVersion().getName() + "_" + chosenSimContext.getName();
MathDescription bioMathDesc = chosenSimContext.getMathDescription();
MathDescription newMathDesc = null;
newMathDesc = new MathDescription(newName + "_" + (new Random()).nextInt());
newMathDesc.setGeometry(bioMathDesc.getGeometry());
newMathDesc.read_database(new CommentStringTokenizer(bioMathDesc.getVCML_database()));
newMathDesc.isValid();
MathModel newMathModel = new MathModel(null);
newMathModel.setName(newName);
newMathModel.setMathDescription(newMathDesc);
hashTable.put("doc", newMathModel);
}
}
};
taskArray = new AsynchClientTask[] { task1, task2, task3 };
break;
} else {
throw new RuntimeException("Unknown MathModel Document creation option value=" + documentCreationInfo.getOption());
}
}
case GEOMETRY_DOC:
{
if (createOption == VCDocument.GEOM_OPTION_1D || createOption == VCDocument.GEOM_OPTION_2D || createOption == VCDocument.GEOM_OPTION_3D) {
// analytic
AsynchClientTask task1 = new AsynchClientTask("creating analytic geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry geometry = new Geometry("Geometry" + (getMdiManager().getNumCreatedDocumentWindows() + 1), documentCreationInfo.getOption());
geometry.getGeometrySpec().addSubVolume(new AnalyticSubVolume("subdomain0", new Expression(1.0)));
geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
hashTable.put("doc", geometry);
}
};
taskArray = new AsynchClientTask[] { task1 };
break;
}
if (createOption == VCDocument.GEOM_OPTION_CSGEOMETRY_3D) {
// constructed solid geometry
AsynchClientTask task1 = new AsynchClientTask("creating constructed solid geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry geometry = new Geometry("Geometry" + (getMdiManager().getNumCreatedDocumentWindows() + 1), 3);
Extent extent = geometry.getExtent();
if (extent != null) {
// create a CSGPrimitive of type cube and scale it to the 'extent' components. Use this as the default or background CSGObject (subdomain).
// This can be considered as the equivalent of subdomain (with expression) 1.0 for analyticSubvolume.
// basic cube
CSGPrimitive cube = new CSGPrimitive("cube", CSGPrimitive.PrimitiveType.CUBE);
// scaled cube
double x = extent.getX();
double y = extent.getY();
double z = extent.getZ();
CSGScale scaledCube = new CSGScale("scale", new Vect3d(x / 2.0, y / 2.0, z / 2.0));
scaledCube.setChild(cube);
// translated scaled cube
CSGTranslation translatedScaledCube = new CSGTranslation("translation", new Vect3d(x / 2, y / 2, z / 2));
translatedScaledCube.setChild(scaledCube);
CSGObject csgObject = new CSGObject(null, "subdomain0", 0);
csgObject.setRoot(translatedScaledCube);
geometry.getGeometrySpec().addSubVolume(csgObject, false);
geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
hashTable.put("doc", geometry);
}
}
};
taskArray = new AsynchClientTask[] { task1 };
break;
} else {
throw new RuntimeException("Unknown Geometry Document creation option value=" + documentCreationInfo.getOption());
}
}
default:
{
throw new RuntimeException("Unknown default document type: " + documentCreationInfo.getDocumentType());
}
}
return taskArray;
}
use of org.vcell.util.CommentStringTokenizer in project vcell by virtualcell.
the class ClientRequestManager method createMathModelFromApplication.
/**
* Insert the method's description here.
* Creation date: (5/24/2004 12:22:11 PM)
* @param windowID java.lang.String
*/
public void createMathModelFromApplication(final BioModelWindowManager requester, final String name, final SimulationContext simContext) {
if (simContext == null) {
PopupGenerator.showErrorDialog(requester, "Selected Application is null, cannot generate corresponding math model");
return;
}
switch(simContext.getApplicationType()) {
case NETWORK_STOCHASTIC:
break;
case RULE_BASED_STOCHASTIC:
case NETWORK_DETERMINISTIC:
}
AsynchClientTask task1 = new AsynchClientTask("Creating MathModel from BioModel Application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
MathModel newMathModel = new MathModel(null);
// Get corresponding mathDesc to create new mathModel.
MathDescription mathDesc = simContext.getMathDescription();
MathDescription newMathDesc = null;
newMathDesc = new MathDescription(name + "_" + (new java.util.Random()).nextInt());
try {
if (mathDesc.getGeometry().getDimension() > 0 && mathDesc.getGeometry().getGeometrySurfaceDescription().getGeometricRegions() == null) {
mathDesc.getGeometry().getGeometrySurfaceDescription().updateAll();
}
} catch (ImageException e) {
e.printStackTrace(System.out);
throw new RuntimeException("Geometric surface generation error:\n" + e.getMessage());
} catch (GeometryException e) {
e.printStackTrace(System.out);
throw new RuntimeException("Geometric surface generation error:\n" + e.getMessage());
}
newMathDesc.setGeometry(mathDesc.getGeometry());
newMathDesc.read_database(new CommentStringTokenizer(mathDesc.getVCML_database()));
newMathDesc.isValid();
newMathModel.setName(name);
newMathModel.setMathDescription(newMathDesc);
hashTable.put("newMathModel", newMathModel);
}
};
AsynchClientTask task2 = new AsynchClientTask("Creating MathModel from BioModel Application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
MathModel newMathModel = (MathModel) hashTable.get("newMathModel");
DocumentWindowManager windowManager = createDocumentWindowManager(newMathModel);
if (simContext.getBioModel().getVersion() != null) {
((MathModelWindowManager) windowManager).setCopyFromBioModelAppVersionableTypeVersion(new VersionableTypeVersion(VersionableType.BioModelMetaData, simContext.getBioModel().getVersion()));
}
DocumentWindow dw = getMdiManager().createNewDocumentWindow(windowManager);
setFinalWindow(hashTable, dw);
}
};
ClientTaskDispatcher.dispatch(requester.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
use of org.vcell.util.CommentStringTokenizer in project vcell by virtualcell.
the class Kinetics method getKineticsParametersFromTokens.
private ArrayList<KineticsParameter> getKineticsParametersFromTokens(String kinetics_vcmlStr) throws ExpressionException, PropertyVetoException {
//
// old format (version 1) (still supported for reading)
//
// Kinetics GeneralCurrentKinetics {
// Parameter a 10;
// Parameter b 3;
// Parameter c d/2;
// Parameter d 5;
// CurrentDensity a+b/c;
// }
//
//
// new format (version 2) (deprecated, incompatible with Version 1, still supported for reading)
//
// Kinetics GeneralCurrentKinetics {
// CurrentDensity 'currentDensity'
// Parameter currentDensity a+b/c;
// Parameter a 10;
// Parameter b 3;
// Parameter c d/2;
// Parameter d 5;
// }
//
// latest format (version 3), which is backward compatable with version 1
// ParameterVCMLTokens (such as "CurrentDensity") have simple expressions
// that always consist of only the requiredIdentifier (e.g. currentDensity; )
//
// Kinetics GeneralCurrentKinetics {
// Parameter currentDensity a+b/c;
// Parameter a 10;
// Parameter b 3;
// Parameter c d/2;
// Parameter d 5;
// CurrentDensity currentDensity;
// }
//
// Kinetics GeneralCurrentKinetics {
// Parameter currentDensity a+b/c; [uM]
// Parameter a 10; [s-1]
// Parameter b 3; [m-1]
// Parameter c d/2; [uM.s-1]
// Parameter d 5; [s]
// CurrentDensity currentDensity; [s]
// }
//
//
// first pass :
// protect predefined parameters
ArrayList<KineticsParameter> localParameters = new ArrayList<Kinetics.KineticsParameter>();
KineticsParameter[] predefinedKineticParameters = getKineticsParameters();
for (KineticsParameter kp : predefinedKineticParameters) {
if (kp.getRole() != ROLE_UserDefined) {
localParameters.add(kp);
}
}
CommentStringTokenizer tokens = new CommentStringTokenizer(kinetics_vcmlStr);
@SuppressWarnings("unused") String kineticsKeywordToken = tokens.nextToken();
@SuppressWarnings("unused") String kineticsNameToken = tokens.nextToken();
@SuppressWarnings("unused") String // read "{"
beginBraceToken = tokens.nextToken();
ModelUnitSystem unitSystem = reactionStep.getModel().getUnitSystem();
HashMap<String, String> symbolRenamings = new HashMap<String, String>();
while (tokens.hasMoreTokens()) {
String firstTokenOfLine = tokens.nextToken();
if (firstTokenOfLine.equalsIgnoreCase(VCMODL.EndBlock)) {
break;
}
if (firstTokenOfLine.equalsIgnoreCase(VCMODL.Fast)) {
// setFast(true);
continue;
}
if (firstTokenOfLine.equalsIgnoreCase(VCMODL.Parameter)) {
String name = tokens.nextToken();
Expression exp = new Expression(tokens.readToSemicolon());
String unitsString = tokens.nextToken();
VCUnitDefinition unitDef = unitSystem.getInstance_TBD();
if (unitsString.startsWith("[")) {
while (!unitsString.endsWith("]")) {
String tempToken = tokens.nextToken();
unitsString = unitsString + " " + tempToken;
}
//
// now string starts with '[' and ends with ']'
//
unitDef = unitSystem.getInstance(unitsString.substring(1, unitsString.length() - 1));
} else {
// read too far, put it back in the stream.
tokens.pushToken(unitsString);
}
// could have two parameters with same name (one reserved, one user defined)
localParameters.add(new KineticsParameter(name, exp, ROLE_UserDefined, unitDef));
continue;
}
//
if (this instanceof GeneralLumpedKinetics) {
if (firstTokenOfLine.equals(VCMODL.ReactionRate) || firstTokenOfLine.equals(VCMODL.CurrentDensity) || firstTokenOfLine.equals(VCMODL.AssumedCompartmentSize_oldname)) {
firstTokenOfLine = tokens.nextToken();
continue;
} else if (firstTokenOfLine.equals(VCMODL.TotalRate_oldname)) {
firstTokenOfLine = VCMODL.LumpedReactionRate;
}
}
//
// assume that this line is a reserved ROLE
//
KineticsParameter parameterForRole = null;
for (int i = 0; i < RoleTags.length; i++) {
if (firstTokenOfLine.equalsIgnoreCase(RoleTags[i])) {
//
for (KineticsParameter kp : localParameters) {
if (kp.getRole() == i) {
parameterForRole = kp;
break;
}
}
if (parameterForRole == null) {
for (KineticsParameter kp : localParameters) {
if (isEquivalentRoleFromKineticsVCMLTokens(i, kp.getRole())) {
parameterForRole = kp;
break;
}
}
}
// may need to generate on the fly during database reading.
if (parameterForRole == null && i == ROLE_ElectricalUnitFactor) {
KineticsParameter unitFactorParm = new KineticsParameter(getDefaultParameterName(ROLE_ElectricalUnitFactor), new Expression(1.0), ROLE_ElectricalUnitFactor, null);
addKineticsParameter(unitFactorParm);
parameterForRole = unitFactorParm;
}
// be forgiving while parsing charge parameter variants from the database - to support legacy models.
if (parameterForRole == null && (i == ROLE_ChargeValence || i == ROLE_NetChargeValence || i == ROLE_CarrierChargeValence)) {
parameterForRole = getChargeValenceParameter();
}
if (parameterForRole == null) {
throw new RuntimeException("parameter for role " + RoleTags[i] + " not found in kinetic law " + this.getKineticsDescription().getName());
}
}
}
String nextTokenAfterRole = tokens.nextToken();
if (nextTokenAfterRole.endsWith("'") && nextTokenAfterRole.startsWith("'")) {
//
// if requiredIdentifier name is present (delimited by single quotes)
// use it as the user-supplied name for that required parameter
//
// e.g. CurrentDensity 'currentDensity'
//
String parmName = nextTokenAfterRole.substring(1, nextTokenAfterRole.length() - 1);
if (!parameterForRole.getName().equals(parmName)) {
symbolRenamings.put(parameterForRole.getName(), parmName);
}
} else {
//
// else if a non-trivial expression, then use the default name for the requiredParameter.
// if a single identifier expression, then use that identifier as the requiredParameter name.
//
// first token (already popped) must be part of the expression (need to push it back).
//
// e.g. CurrentDensity a+b/c;
//
// put back expression token for subsequent parsing.
tokens.pushToken(nextTokenAfterRole);
Expression exp = new Expression(tokens.readToSemicolon());
//
// find out if expression refers to another parameter declaration (expression of type "paramName;").
//
String[] symbols = exp.getSymbols();
boolean bIsSingleId = false;
if (symbols != null && symbols.length == 1) {
if (exp.compareEqual(new Expression(symbols[0]))) {
bIsSingleId = true;
}
}
//
// get unit definition (optional)
//
String unitsString = tokens.nextToken();
VCUnitDefinition unitDef = unitSystem.getInstance_TBD();
if (unitsString.startsWith("[")) {
while (!unitsString.endsWith("]")) {
String tempToken = tokens.nextToken();
unitsString = unitsString + " " + tempToken;
}
//
// now string starts with '[' and ends with ']'
//
unitDef = unitSystem.getInstance(unitsString.substring(1, unitsString.length() - 1));
} else {
// from the next line put it back in the stream.
tokens.pushToken(unitsString);
}
if (!bIsSingleId) {
//
// expression is real, not just a reference to a parameter defined on another line
// set expression and unit
//
parameterForRole.setExpression(exp);
if (unitDef != null && !unitDef.isTBD()) {
parameterForRole.setUnitDefinition(unitDef);
}
} else {
//
// expression is just a reference to a parameter defined on another line (e.g. Kf_012;)
// rename the reserved parameter to that name
//
// NOTE: COULD CREATE A CONFLICT ... TWO PARAMETERS WITH THE SAME NAME (RESOLVE LATER)
//
String parmName = symbols[0];
if (!parameterForRole.getName().equals(parmName)) {
symbolRenamings.put(parameterForRole.getName(), parmName);
}
}
}
}
//
for (String origSymbol : symbolRenamings.keySet()) {
String newSymbol = symbolRenamings.get(origSymbol);
for (KineticsParameter kp : localParameters) {
if (kp.getName().equals(origSymbol)) {
kp.setName(newSymbol);
}
if (kp.getExpression().hasSymbol(origSymbol)) {
kp.getExpression().substituteInPlace(new Expression(origSymbol), new Expression(newSymbol));
}
}
}
//
// merge parameters with same name (one is UserDefined, the other is Reserved role)
//
boolean bDirty = true;
while (bDirty) {
bDirty = false;
for (KineticsParameter kp1 : localParameters) {
KineticsParameter kp_withSameName = null;
for (KineticsParameter kp2 : localParameters) {
if (kp1 != kp2 && kp1.getName().equals(kp2.getName())) {
kp_withSameName = kp2;
}
}
if (kp_withSameName != null) {
// copy expression and unit from UserDefined Parameter to the Reserved Parmaeter and remove the user defined parameter
KineticsParameter userParameter = null;
KineticsParameter reservedParameter = null;
if (kp1.getRole() == ROLE_UserDefined && kp_withSameName.getRole() != ROLE_UserDefined) {
userParameter = kp1;
reservedParameter = kp_withSameName;
} else if (kp_withSameName.getRole() == ROLE_UserDefined && kp1.getRole() != ROLE_UserDefined) {
reservedParameter = kp1;
userParameter = kp_withSameName;
} else {
throw new RuntimeException("found two parameters with same name '" + kp1.getName() + "' in reaction '" + reactionStep.getName() + "', not able to reconcile");
}
reservedParameter.setExpression(userParameter.getExpression());
if (userParameter.getUnitDefinition() == null || userParameter.getUnitDefinition().isTBD()) {
reservedParameter.setUnitDefinition(userParameter.getUnitDefinition());
}
localParameters.remove(userParameter);
bDirty = true;
break;
}
}
}
return localParameters;
}
use of org.vcell.util.CommentStringTokenizer in project vcell by virtualcell.
the class CartesianMeshFileReader method readFromFiles.
public CartesianMesh readFromFiles(VCellSimFiles vcellSimFiles) throws IOException, MathException {
//
// read meshFile and parse into 'mesh' object
//
BufferedReader meshReader = null;
BufferedReader meshMetricsReader = null;
try {
meshReader = new BufferedReader(new FileReader(vcellSimFiles.cartesianMeshFile));
CommentStringTokenizer meshST = new CommentStringTokenizer(meshReader);
CommentStringTokenizer membraneMeshMetricsST = null;
if (vcellSimFiles.meshMetricsFile != null) {
meshMetricsReader = new BufferedReader(new FileReader(vcellSimFiles.meshMetricsFile));
membraneMeshMetricsST = new CommentStringTokenizer(meshMetricsReader);
}
MembraneMeshMetrics membraneMeshMetrics = null;
SubdomainInfo subdomainInfo = null;
if (membraneMeshMetricsST != null) {
membraneMeshMetrics = readMembraneMeshMetrics(membraneMeshMetricsST);
}
if (vcellSimFiles.subdomainFile != null) {
subdomainInfo = SubdomainInfo.read(vcellSimFiles.subdomainFile);
}
CartesianMesh mesh = readCartesianMesh(meshST, membraneMeshMetrics, subdomainInfo);
return mesh;
} finally {
if (meshReader != null) {
try {
meshReader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (meshMetricsReader != null) {
try {
meshMetricsReader.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Aggregations