use of cbit.vcell.geometry.surface.GeometricRegion in project vcell by virtualcell.
the class SimulationContext method refreshSpatialObjects.
public void refreshSpatialObjects() {
Geometry geometry = getGeometry();
if (geometry != null && geometry.getGeometrySurfaceDescription() != null && geometry.getGeometrySurfaceDescription().getGeometricRegions() != null) {
ArrayList<SpatialObject> unmappedSpatialObjects = new ArrayList<SpatialObject>(Arrays.asList(spatialObjects));
ArrayList<GeometricRegion> mappedRegions = new ArrayList<GeometricRegion>();
//
for (SpatialObject spatialObject : spatialObjects) {
if (spatialObject instanceof VolumeRegionObject) {
VolumeRegionObject volRegionObj = (VolumeRegionObject) spatialObject;
SubVolume existingSubvolume = volRegionObj.getSubVolume();
Integer existingRegionID = volRegionObj.getRegionID();
SubVolume newSubvolume = geometry.getGeometrySpec().getSubVolume(existingSubvolume.getName());
if (newSubvolume != null && geometry.getGeometrySurfaceDescription().getGeometricRegions() != null) {
for (GeometricRegion newRegion : geometry.getGeometrySurfaceDescription().getGeometricRegions(newSubvolume)) {
VolumeGeometricRegion newVolRegion = (VolumeGeometricRegion) newRegion;
if (newVolRegion.getRegionID() == existingRegionID) {
((VolumeRegionObject) spatialObject).setSubVolume(newSubvolume);
mappedRegions.add(newVolRegion);
unmappedSpatialObjects.remove(spatialObject);
}
}
}
}
if (spatialObject instanceof SurfaceRegionObject) {
SurfaceRegionObject surfaceRegionObj = (SurfaceRegionObject) spatialObject;
SubVolume existingInsideSubvolume = surfaceRegionObj.getInsideSubVolume();
SubVolume existingOutsideSubvolume = surfaceRegionObj.getOutsideSubVolume();
Integer existingInsideRegionID = surfaceRegionObj.getInsideRegionID();
Integer existingOutsideRegionID = surfaceRegionObj.getOutsideRegionID();
SubVolume newInsideSubvolume = geometry.getGeometrySpec().getSubVolume(existingInsideSubvolume.getName());
SubVolume newOutsideSubvolume = geometry.getGeometrySpec().getSubVolume(existingOutsideSubvolume.getName());
if (newInsideSubvolume != null && newOutsideSubvolume != null) {
SurfaceClass surfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(newInsideSubvolume, newOutsideSubvolume);
for (GeometricRegion newRegion : geometry.getGeometrySurfaceDescription().getGeometricRegions(surfaceClass)) {
SurfaceGeometricRegion newSurfaceRegion = (SurfaceGeometricRegion) newRegion;
GeometricRegion[] adjacentRegions = newSurfaceRegion.getAdjacentGeometricRegions();
if (adjacentRegions.length == 2 && adjacentRegions[0] instanceof VolumeGeometricRegion && adjacentRegions[1] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion adjVolRegion0 = (VolumeGeometricRegion) adjacentRegions[0];
VolumeGeometricRegion adjVolRegion1 = (VolumeGeometricRegion) adjacentRegions[1];
if (adjVolRegion0.getSubVolume() == newInsideSubvolume && adjVolRegion0.getRegionID() == existingInsideRegionID && adjVolRegion1.getSubVolume() == newOutsideSubvolume && adjVolRegion1.getRegionID() == existingOutsideRegionID) {
surfaceRegionObj.setInsideSubVolume(newInsideSubvolume);
surfaceRegionObj.setOutsideSubVolume(newOutsideSubvolume);
mappedRegions.add(newSurfaceRegion);
unmappedSpatialObjects.remove(spatialObject);
}
if (adjVolRegion0.getSubVolume() == newOutsideSubvolume && adjVolRegion0.getRegionID() == existingOutsideRegionID && adjVolRegion1.getSubVolume() == newInsideSubvolume && adjVolRegion1.getRegionID() == existingInsideRegionID) {
surfaceRegionObj.setInsideSubVolume(newInsideSubvolume);
surfaceRegionObj.setOutsideSubVolume(newOutsideSubvolume);
mappedRegions.add(newSurfaceRegion);
unmappedSpatialObjects.remove(spatialObject);
}
}
}
}
}
}
//
// for geometric regions not represented as spatial objects, add them
//
ArrayList<GeometricRegion> unmappedRegions = new ArrayList<GeometricRegion>(Arrays.asList(geometry.getGeometrySurfaceDescription().getGeometricRegions()));
unmappedRegions.removeAll(mappedRegions);
for (GeometricRegion unmappedRegion : unmappedRegions) {
if (unmappedRegion instanceof VolumeGeometricRegion) {
VolumeGeometricRegion unmappedVolRegion = (VolumeGeometricRegion) unmappedRegion;
try {
VolumeRegionObject vro = new VolumeRegionObject(unmappedVolRegion.getSubVolume(), unmappedVolRegion.getRegionID(), this);
addSpatialObject(vro);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
} else if (unmappedRegion instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion unmappedSurfRegion = (SurfaceGeometricRegion) unmappedRegion;
GeometricRegion[] adjacentRegions = unmappedSurfRegion.getAdjacentGeometricRegions();
if (adjacentRegions.length == 2 && adjacentRegions[0] instanceof VolumeGeometricRegion && adjacentRegions[1] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion volRegion0 = (VolumeGeometricRegion) adjacentRegions[0];
VolumeGeometricRegion volRegion1 = (VolumeGeometricRegion) adjacentRegions[1];
SubVolume insideSubVolume = volRegion0.getSubVolume();
SubVolume outsideSubVolume = volRegion1.getSubVolume();
int insideRegionID = volRegion0.getRegionID();
int outsideRegionID = volRegion1.getRegionID();
SurfaceClass surfaceClass = geometry.getGeometrySurfaceDescription().getSurfaceClass(insideSubVolume, outsideSubVolume);
try {
addSpatialObject(new SurfaceRegionObject(insideSubVolume, insideRegionID, outsideSubVolume, outsideRegionID, this));
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
}
}
//
try {
for (SpatialObject unmappedSpatialObject : unmappedSpatialObjects) {
if (unmappedSpatialObject instanceof VolumeRegionObject) {
System.err.println("volume region spatial object '" + unmappedSpatialObject.getName() + "' not found in geometry, delete.");
removeSpatialObject(unmappedSpatialObject);
}
if (unmappedSpatialObject instanceof SurfaceRegionObject) {
System.err.println("surface region spatial object '" + unmappedSpatialObject.getName() + "' not found in geometry, delete.");
removeSpatialObject(unmappedSpatialObject);
}
if (unmappedSpatialObject instanceof PointObject) {
System.err.println("point spatial object '" + unmappedSpatialObject.getName() + "' not found in geometry, this is expected.");
// removeSpatialObject(unmappedSpatialObject);
}
}
} catch (PropertyVetoException e) {
e.printStackTrace();
}
}
}
use of cbit.vcell.geometry.surface.GeometricRegion in project vcell by virtualcell.
the class SurfaceRegionObject method getSurfaceRegion.
public SurfaceGeometricRegion getSurfaceRegion(Geometry geometry) {
GeometricRegion[] regions = geometry.getGeometrySurfaceDescription().getGeometricRegions();
for (GeometricRegion region : regions) {
if (region instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion surfaceRegion = (SurfaceGeometricRegion) region;
GeometricRegion[] adjacentRegions = surfaceRegion.getAdjacentGeometricRegions();
if (adjacentRegions.length == 2 && adjacentRegions[0] instanceof VolumeGeometricRegion && adjacentRegions[1] instanceof VolumeGeometricRegion) {
VolumeGeometricRegion adjVolumeRegion0 = (VolumeGeometricRegion) adjacentRegions[0];
VolumeGeometricRegion adjVolumeRegion1 = (VolumeGeometricRegion) adjacentRegions[1];
// match adjacent vol0 with inside and vol1 with outside
if (adjVolumeRegion0.getSubVolume() == insideSubVolume && adjVolumeRegion0.getRegionID() == insideRegionID && adjVolumeRegion1.getSubVolume() == outsideSubVolume && adjVolumeRegion1.getRegionID() == outsideRegionID) {
return surfaceRegion;
}
// match adjacent vol1 with inside and vol0 with outside
if (adjVolumeRegion1.getSubVolume() == insideSubVolume && adjVolumeRegion1.getRegionID() == insideRegionID && adjVolumeRegion0.getSubVolume() == outsideSubVolume && adjVolumeRegion0.getRegionID() == outsideRegionID) {
return surfaceRegion;
}
}
}
}
return null;
}
use of cbit.vcell.geometry.surface.GeometricRegion in project vcell by virtualcell.
the class SurfaceRegionObject method gatherIssues.
@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
if (simulationContext.getGeometry().getGeometrySurfaceDescription() != null) {
GeometricRegion[] regions = simulationContext.getGeometry().getGeometrySurfaceDescription().getGeometricRegions();
boolean bFound = false;
if (regions != null) {
for (GeometricRegion region : regions) {
if (region instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion sr = (SurfaceGeometricRegion) region;
if (sr.getAdjacentGeometricRegions() != null && sr.getAdjacentGeometricRegions().length == 2) {
VolumeGeometricRegion vr1 = (VolumeGeometricRegion) sr.getAdjacentGeometricRegions()[0];
VolumeGeometricRegion vr2 = (VolumeGeometricRegion) sr.getAdjacentGeometricRegions()[1];
if (vr1.getSubVolume() == insideSubVolume && vr1.getRegionID() == insideRegionID && vr2.getSubVolume() == outsideSubVolume && vr2.getRegionID() == outsideRegionID) {
bFound = true;
}
if (vr1.getSubVolume() == outsideSubVolume && vr1.getRegionID() == outsideRegionID && vr2.getSubVolume() == insideSubVolume && vr2.getRegionID() == insideRegionID) {
bFound = true;
}
}
}
}
}
if (!bFound) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "could not find corresponding surface region in geometry", Issue.Severity.ERROR));
}
}
}
use of cbit.vcell.geometry.surface.GeometricRegion in project vcell by virtualcell.
the class XmlReader method getGeometrySurfaceDescription.
private GeometrySurfaceDescription getGeometrySurfaceDescription(Element param, Geometry geom) throws XmlParseException {
GeometrySurfaceDescription gsd = geom.getGeometrySurfaceDescription();
String cutoffStr = param.getAttributeValue(XMLTags.CutoffFrequencyAttrTag);
String xDim = param.getAttributeValue(XMLTags.NumSamplesXAttrTag);
String yDim = param.getAttributeValue(XMLTags.NumSamplesYAttrTag);
String zDim = param.getAttributeValue(XMLTags.NumSamplesZAttrTag);
if (cutoffStr == null || xDim == null || yDim == null || zDim == null) {
throw new XmlParseException("Attributes for element Surface Description not properly set, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
try {
ISize isize = new ISize(Integer.parseInt(xDim), Integer.parseInt(yDim), Integer.parseInt(zDim));
gsd.setVolumeSampleSize(isize);
gsd.setFilterCutoffFrequency(new Double(cutoffStr));
// these lists are allowed to be empty.
ArrayList<Element> memRegions = new ArrayList<Element>(param.getChildren(XMLTags.MembraneRegionTag, vcNamespace));
ArrayList<Element> volRegions = new ArrayList<Element>(param.getChildren(XMLTags.VolumeRegionTag, vcNamespace));
ArrayList<GeometricRegion> regions = new ArrayList<GeometricRegion>();
GeometryUnitSystem geometryUnitSystem = geom.getUnitSystem();
for (Element temp : volRegions) {
String regionID = temp.getAttributeValue(XMLTags.RegionIDAttrTag);
String name = temp.getAttributeValue(XMLTags.NameAttrTag);
String subvolumeRef = temp.getAttributeValue(XMLTags.SubVolumeAttrTag);
if (regionID == null || name == null || subvolumeRef == null) {
throw new XmlParseException("Attributes for element Volume Region not properly set, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
SubVolume subvolume = geom.getGeometrySpec().getSubVolume(subvolumeRef);
if (subvolume == null) {
throw new XmlParseException("The subvolume " + subvolumeRef + " could not be resolved.");
}
double size = -1;
VCUnitDefinition unit = null;
String sizeStr = temp.getAttributeValue(XMLTags.SizeAttrTag);
if (sizeStr != null) {
size = Double.parseDouble(sizeStr);
String unitSymbol = temp.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
if (unitSymbol != null) {
unit = geometryUnitSystem.getInstance(unitSymbol);
}
}
VolumeGeometricRegion vgr = new VolumeGeometricRegion(name, size, unit, subvolume, Integer.parseInt(regionID));
regions.add(vgr);
}
for (Element temp : memRegions) {
String volRegion_1 = temp.getAttributeValue(XMLTags.VolumeRegion_1AttrTag);
String volRegion_2 = temp.getAttributeValue(XMLTags.VolumeRegion_2AttrTag);
String name = temp.getAttributeValue(XMLTags.NameAttrTag);
if (volRegion_1 == null || volRegion_2 == null || name == null) {
throw new XmlParseException("Attributes for element Membrane Region not properly set, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
VolumeGeometricRegion region1 = getAdjacentVolumeRegion(regions, volRegion_1);
VolumeGeometricRegion region2 = getAdjacentVolumeRegion(regions, volRegion_2);
if (region1 == null || region2 == null) {
throw new XmlParseException("Element Membrane Region refernces invalid volume regions, under geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
}
double size = -1;
VCUnitDefinition unit = null;
String sizeStr = temp.getAttributeValue(XMLTags.SizeAttrTag);
if (sizeStr != null) {
size = Double.parseDouble(sizeStr);
String unitSymbol = temp.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
if (unitSymbol != null) {
unit = geometryUnitSystem.getInstance(unitSymbol);
}
}
SurfaceGeometricRegion rsl = new SurfaceGeometricRegion(name, size, unit);
rsl.addAdjacentGeometricRegion(region1);
region1.addAdjacentGeometricRegion(rsl);
rsl.addAdjacentGeometricRegion(region2);
region2.addAdjacentGeometricRegion(rsl);
regions.add(rsl);
}
if (regions.size() > 0) {
gsd.setGeometricRegions((GeometricRegion[]) regions.toArray(new GeometricRegion[regions.size()]));
}
} catch (Exception e) {
System.err.println("Unable to read geometry surface description from XML, for geometry: " + ((Element) param.getParent()).getAttributeValue(XMLTags.NameAttrTag));
e.printStackTrace();
}
return gsd;
}
use of cbit.vcell.geometry.surface.GeometricRegion in project vcell by virtualcell.
the class GeometryFileWriter method write.
/**
* Insert the method's description here.
* Creation date: (7/19/2004 10:54:30 AM)
* @param geometrySurfaceDescription cbit.vcell.geometry.surface.GeometrySurfaceDescription
* @throws IOException
*/
public static void write(Writer writer, Geometry resampledGeometry) throws IOException {
//
// "name" name
// "dimension" dimension
// "extent" extentx extenty extentz
// "origin" originx originy originz
// "volumeRegions" num
// name totalVolume featureHandle
// "membraneRegions" num
// name totalArea volumeRegionIndex1 volumeRegionIndex2
// "volumeSamples" numX, numY, numZ
// uncompressed regionIndexs for each volume element
// compressed regionIndexs for each volume element
// "nodes" num
// nodeIndex x y z
// "cells" num
// cellIndex patchIndex node1 node2 node3 node4
// "celldata"
// insideVolumeIndex outsideVolumeIndex area normalx normaly normalz
//
//
// When we are writing volume regions, we sort regions so that ID is equal to index
//
writer.write("name " + resampledGeometry.getName() + "\n");
writer.write("dimension " + resampledGeometry.getDimension() + "\n");
org.vcell.util.Extent extent = resampledGeometry.getExtent();
org.vcell.util.Origin origin = resampledGeometry.getOrigin();
switch(resampledGeometry.getDimension()) {
case 1:
writer.write("size " + extent.getX() + "\n");
writer.write("origin " + origin.getX() + "\n");
break;
case 2:
writer.write("size " + extent.getX() + " " + extent.getY() + "\n");
writer.write("origin " + origin.getX() + " " + origin.getY() + "\n");
break;
case 3:
writer.write("size " + extent.getX() + " " + extent.getY() + " " + extent.getZ() + "\n");
writer.write("origin " + origin.getX() + " " + origin.getY() + " " + origin.getZ() + "\n");
break;
}
GeometrySurfaceDescription geoSurfaceDesc = resampledGeometry.getGeometrySurfaceDescription();
RegionImage regionImage = geoSurfaceDesc.getRegionImage();
SurfaceCollection surfaceCollection = geoSurfaceDesc.getSurfaceCollection();
GeometricRegion[] geometricRegions = geoSurfaceDesc.getGeometricRegions();
int numVolumeRegions = 0;
int numMembraneRegions = 0;
Vector<VolumeGeometricRegion> volRegionList = new Vector<VolumeGeometricRegion>();
if (geometricRegions != null) {
for (int i = 0; i < geometricRegions.length; i++) {
if (geometricRegions[i] instanceof VolumeGeometricRegion) {
numVolumeRegions++;
volRegionList.add((VolumeGeometricRegion) geometricRegions[i]);
} else if (geometricRegions[i] instanceof SurfaceGeometricRegion) {
numMembraneRegions++;
}
}
}
//
// get ordered array of volume regions (where "id" == index into array)... fail if impossible
//
java.util.Collections.sort(volRegionList, new Comparator<VolumeGeometricRegion>() {
public int compare(VolumeGeometricRegion reg1, VolumeGeometricRegion reg2) {
if (reg1.getRegionID() < reg2.getRegionID()) {
return -1;
} else if (reg1.getRegionID() > reg2.getRegionID()) {
return 1;
} else {
return 0;
}
}
public boolean equals(Object obj) {
return this == obj;
}
});
VolumeGeometricRegion[] volRegions = (VolumeGeometricRegion[]) org.vcell.util.BeanUtils.getArray(volRegionList, VolumeGeometricRegion.class);
writer.write("volumeRegions " + numVolumeRegions + "\n");
for (int i = 0; i < volRegions.length; i++) {
if (volRegions[i].getRegionID() != i) {
throw new RuntimeException("Region ID != Region Index, they must be the same!");
}
writer.write(volRegions[i].getName() + " " + volRegions[i].getSize() + " " + volRegions[i].getSubVolume().getHandle() + "\n");
}
writer.write("membraneRegions " + numMembraneRegions + "\n");
if (geometricRegions != null) {
for (int i = 0; i < geometricRegions.length; i++) {
if (geometricRegions[i] instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion surfaceRegion = (SurfaceGeometricRegion) geometricRegions[i];
GeometricRegion[] neighbors = surfaceRegion.getAdjacentGeometricRegions();
VolumeGeometricRegion insideRegion = (VolumeGeometricRegion) neighbors[0];
VolumeGeometricRegion outsideRegion = (VolumeGeometricRegion) neighbors[1];
writer.write(surfaceRegion.getName() + " " + surfaceRegion.getSize() + " " + insideRegion.getRegionID() + " " + outsideRegion.getRegionID() + "\n");
}
}
}
//
// write volume samples
//
ISize volumeSampleSize = geoSurfaceDesc.getVolumeSampleSize();
switch(resampledGeometry.getDimension()) {
case 1:
writer.write("volumeSamples " + volumeSampleSize.getX() + "\n");
break;
case 2:
writer.write("volumeSamples " + volumeSampleSize.getX() + " " + volumeSampleSize.getY() + "\n");
break;
case 3:
writer.write("volumeSamples " + volumeSampleSize.getX() + " " + volumeSampleSize.getY() + " " + volumeSampleSize.getZ() + "\n");
break;
}
// regionImage
if (regionImage != null) {
if (regionImage.getNumRegions() > 65536) {
throw new RuntimeException("cannot process a geometry with more than 65536 volume regions");
}
byte[] uncompressedRegionIDs = new byte[2 * regionImage.getNumX() * regionImage.getNumY() * regionImage.getNumZ()];
for (int i = 0, j = 0; i < uncompressedRegionIDs.length; i += 2, j++) {
int regindex = regionImage.getRegionInfoFromOffset(j).getRegionIndex();
uncompressedRegionIDs[i] = (byte) (regindex & 0x000000ff);
uncompressedRegionIDs[i + 1] = (byte) ((regindex & 0x0000ff00) >> 8);
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(bos);
dos.write(uncompressedRegionIDs, 0, uncompressedRegionIDs.length);
dos.close();
byte[] compressedRegionIDs = bos.toByteArray();
writer.write(org.vcell.util.Hex.toString(compressedRegionIDs) + "\n");
} else {
writer.write("\n");
}
//
if (surfaceCollection == null) {
throw new RuntimeException("geometry is not updated");
}
int numCells = surfaceCollection.getTotalPolygonCount();
writer.write("cells " + numCells + "\n");
// "celldata"
// insideVolumeIndex outsideVolumeIndex area normalx normaly normalz
//
int cellID = 0;
int dimension = resampledGeometry.getDimension();
double correctCoeff = 1;
if (dimension == 1) {
correctCoeff = extent.getY() * extent.getZ();
} else if (dimension == 2) {
correctCoeff = extent.getZ();
}
if (surfaceCollection != null) {
for (int i = 0; i < surfaceCollection.getSurfaceCount(); i++) {
Surface surface = surfaceCollection.getSurfaces(i);
int region1Outside = 0;
int region1Inside = 0;
for (int j = 0; j < surface.getPolygonCount(); j++) {
Quadrilateral polygon = (Quadrilateral) surface.getPolygons(j);
Node[] node = polygon.getNodes();
cbit.vcell.render.Vect3d elementCoord = new cbit.vcell.render.Vect3d();
int nodesOnBoundary = 0;
for (int k = 0; k < node.length; k++) {
if (!node[k].getMoveX() || (dimension > 1 && !node[k].getMoveY()) || (dimension == 3 && !node[k].getMoveZ())) {
nodesOnBoundary++;
}
}
if (nodesOnBoundary == 0) {
for (int k = 0; k < node.length; k++) {
elementCoord.add(new cbit.vcell.render.Vect3d(node[k].getX(), node[k].getY(), node[k].getZ()));
}
elementCoord.scale(0.25);
} else if (nodesOnBoundary == 2) {
for (int k = 0; k < node.length; k++) {
if (!node[k].getMoveX() || !node[k].getMoveY() || !node[k].getMoveZ()) {
elementCoord.add(new cbit.vcell.render.Vect3d(node[k].getX(), node[k].getY(), node[k].getZ()));
}
}
elementCoord.scale(0.5);
} else if (nodesOnBoundary == 3) {
for (int k = 0; k < node.length; k++) {
if (!node[k].getMoveX() && !node[k].getMoveY() || !node[k].getMoveY() && !node[k].getMoveZ() || !node[k].getMoveX() && !node[k].getMoveZ()) {
elementCoord.set(node[k].getX(), node[k].getY(), node[k].getZ());
}
}
} else {
throw new RuntimeException("Unexcepted number of nodes on boundary for a polygon: " + nodesOnBoundary);
}
cbit.vcell.render.Vect3d unitNormal = new cbit.vcell.render.Vect3d();
polygon.getUnitNormal(unitNormal);
int volNeighbor1Region = regionImage.getRegionInfoFromOffset(polygon.getVolIndexNeighbor1()).getRegionIndex();
int volNeighbor2Region = regionImage.getRegionInfoFromOffset(polygon.getVolIndexNeighbor2()).getRegionIndex();
if (surface.getExteriorRegionIndex() == volNeighbor1Region && surface.getInteriorRegionIndex() == volNeighbor2Region) {
region1Outside++;
}
if (surface.getExteriorRegionIndex() == volNeighbor2Region && surface.getInteriorRegionIndex() == volNeighbor1Region) {
region1Inside++;
}
writer.write(cellID + " " + polygon.getVolIndexNeighbor1() + " " + polygon.getVolIndexNeighbor2() + " " + polygon.getArea() / correctCoeff + " " + elementCoord.getX() + " " + elementCoord.getY() + " " + elementCoord.getZ() + " " + unitNormal.getX() + " " + unitNormal.getY() + " " + unitNormal.getZ() + "\n");
cellID++;
}
if (region1Inside != surface.getPolygonCount() && region1Outside != surface.getPolygonCount()) {
throw new RuntimeException("Volume neighbor regions not consistent: [total, inside, outside]=" + surface.getPolygonCount() + "," + region1Inside + "," + region1Outside + "]");
}
}
}
}
Aggregations