Search in sources :

Example 11 with GeometrySpec

use of cbit.vcell.geometry.GeometrySpec in project vcell by virtualcell.

the class StructureMappingCartoon method refreshAll.

/**
 * This method was created by a SmartGuide.
 */
@Override
public void refreshAll() {
    clearAllShapes();
    if (getSimulationContext() == null) {
        fireGraphChanged(new GraphEvent(this));
        return;
    }
    GeometryContextGeometryShape geometryShape = new GeometryContextGeometryShape(this, getGeometryContext().getGeometry());
    // GeometryContextStructureShape structureShape = new GeometryContextStructureShape(this,getGeometryContext().getModel());
    // GeometryContextContainerShape containerShape = new GeometryContextContainerShape(this,getGeometryContext(),structureShape,geometryShape);
    // addShape(containerShape);
    addShape(geometryShape);
    // addShape(structureShape);
    getGeometryContext().removePropertyChangeListener(this);
    getGeometryContext().addPropertyChangeListener(this);
    // 
    // create all StructureShapes
    // 
    // Structure structures[] = getGeometryContext().getModel().getStructures();
    // for (int i=0;i<structures.length;i++){
    // if (structures[i] instanceof Feature){
    // //addShape(new FeatureShape((Feature)structures[i],getGeometryContext().getModel(),this));
    // StructureMappingFeatureShape smShape = new StructureMappingFeatureShape((Feature)structures[i],getGeometryContext().getModel(),this);
    // addShape(smShape);
    // containerShape.addChildShape(smShape);
    // structures[i].removePropertyChangeListener(this);
    // structures[i].addPropertyChangeListener(this);
    // }
    // }
    // create all SubvolumeLegendShapes (for legend)
    // 
    GeometrySpec geometrySpec = getGeometryContext().getGeometry().getGeometrySpec();
    SubVolume[] subVolumes = geometrySpec.getSubVolumes();
    for (int i = 0; i < subVolumes.length; i++) {
        cbit.vcell.geometry.SubVolume subvolume = subVolumes[i];
        GeometryClassLegendShape subvolumeLegendShape = new GeometryClassLegendShape(subvolume, getGeometryContext().getGeometry(), this, 10);
        addShape(subvolumeLegendShape);
        geometryShape.addChildShape(subvolumeLegendShape);
    }
    // --------------------------------------------------
    if ((subVolumeContainerShape == null) || (subVolumeContainerShape.getModelObject() != getGeometryContext().getGeometry())) {
        subVolumeContainerShape = new SubVolumeContainerShape(getGeometryContext().getGeometry(), this);
    }
    subVolumeContainerShape.removeAllChildren();
    addShape(subVolumeContainerShape);
    geometryShape.addChildShape(subVolumeContainerShape);
    // --------------------------------------------------
    // // create all SubvolumeShapes (for image)
    // //
    // for (int i=0;i<subVolumes.length;i++){
    // cbit.vcell.geometry.SubVolume subvolume = (cbit.vcell.geometry.SubVolume)subVolumes[i];
    // SubvolumeShape subvolumeShape = new SubvolumeShape(subvolume,getGeometryContext().getGeometry(),this);
    // addShape(subvolumeShape);
    // subVolumeContainerShape.addChildShape(subvolumeShape);
    // }
    // 
    // create all FeatureMappingShapes
    // 
    // StructureMapping structureMappings[] = getGeometryContext().getStructureMappings();
    // for (int i=0;i<structureMappings.length;i++){
    // StructureMapping structureMapping = structureMappings[i];
    // if (structureMapping instanceof FeatureMapping){
    // FeatureMapping featureMapping = (FeatureMapping)structureMapping;
    // if (featureMapping.getSubVolume()!=null){
    // FeatureShape featureShape = (FeatureShape)getShapeFromModelObject(featureMapping.getFeature());
    // SubvolumeLegendShape subvolumeLegendShape = (SubvolumeLegendShape)getShapeFromModelObject(featureMapping.getSubVolume());
    // FeatureMappingShape fmShape = new FeatureMappingShape(featureMapping,featureShape,subvolumeLegendShape,this);
    // //FeatureMappingShape fmShape = new FeatureMappingShape(featureMapping,featureShape,featureMapping.getSubVolume(),imageShape,this);
    // addShape(fmShape);
    // containerShape.addChildShape(fmShape);
    // }
    // }
    // }
    // 
    // assign children to shapes according to heirarchy in Model
    // 
    // int nullParentCount=0;
    // Enumeration enum_shape = getShapes();
    // while (enum_shape.hasMoreElements()){
    // Shape shape = (Shape)enum_shape.nextElement();
    // //
    // // for each featureShape, find corresponding featureShape
    // //
    // if (shape instanceof FeatureShape){
    // FeatureShape fs = (FeatureShape)shape;
    // Membrane membrane = fs.getFeature().getMembrane();
    // if (membrane!=null){
    // //
    // // add this feature as child to parent feature
    // //
    // Feature parentFeature = membrane.getOutsideFeature();
    // FeatureShape parentFeatureShape = (FeatureShape)getShapeFromModelObject(parentFeature);
    // if (!parentFeatureShape.contains(fs)){
    // parentFeatureShape.addChildShape(fs);
    // }
    // }else{
    // if (!structureShape.contains(fs)){
    // structureShape.addChildShape(fs);
    // }
    // nullParentCount++;
    // }
    // }
    // }
    fireGraphChanged(new GraphEvent(this));
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec) GeometryClassLegendShape(cbit.vcell.graph.GeometryClassLegendShape) SubVolume(cbit.vcell.geometry.SubVolume) GeometryContextGeometryShape(cbit.vcell.graph.GeometryContextGeometryShape) GraphEvent(cbit.gui.graph.GraphEvent) SubVolume(cbit.vcell.geometry.SubVolume) SubVolumeContainerShape(cbit.vcell.graph.SubVolumeContainerShape)

Example 12 with GeometrySpec

use of cbit.vcell.geometry.GeometrySpec in project vcell by virtualcell.

the class GeometryContext method gatherIssues.

/**
 * Insert the method's description here.
 * Creation date: (11/1/2005 9:48:55 AM)
 * @param issueList java.util.Vector
 */
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
    issueContext = issueContext.newChildContext(ContextType.Geometry, getGeometry());
    GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
    if (geometrySpec != null) {
        geometrySpec.gatherIssues(issueContext, getGeometry(), issueList);
    }
    for (int i = 0; fieldStructureMappings != null && i < fieldStructureMappings.length; i++) {
        fieldStructureMappings[i].gatherIssues(issueContext, issueList);
    }
    for (GeometryClass gc : fieldGeometry.getGeometryClasses()) {
        Structure[] structuresFromGeometryClass = getStructuresFromGeometryClass(gc);
        if (structuresFromGeometryClass == null || structuresFromGeometryClass.length == 0) {
            UnmappedGeometryClass unmappedGeometryClass = new UnmappedGeometryClass(gc);
            Issue issue = new Issue(unmappedGeometryClass, issueContext, IssueCategory.GeometryClassNotMapped, "Subdomain '" + gc.getName() + "' is not mapped to any physiological structure.", Issue.SEVERITY_WARNING);
            issueList.add(issue);
        }
    }
    if (getSimulationContext().isStoch() && getGeometry().getDimension() != 0 && getGeometry().getDimension() != 3) {
        Issue issue = new Issue(this, issueContext, IssueCategory.Smoldyn_Geometry_3DWarning, "VCell spatial stochastic models only support 3D geometry.", Issue.SEVERITY_ERROR);
        issueList.add(issue);
    }
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec) GeometryClass(cbit.vcell.geometry.GeometryClass) Issue(org.vcell.util.Issue) Structure(cbit.vcell.model.Structure)

Example 13 with GeometrySpec

use of cbit.vcell.geometry.GeometrySpec in project vcell by virtualcell.

the class RayCaster method resampleGeometry.

public static Geometry resampleGeometry(GeometryThumbnailImageFactory geometryThumbnailImageFactory, Geometry origGeometry, ISize sampleSize) throws ImageException, PropertyVetoException, GeometryException, ExpressionException {
    if (origGeometry.getDimension() < 3) {
        throw new GeometryException("Presently, the Raycaster resampling works only for 3d geometries.");
    }
    GeometrySpec origGeometrySpec = origGeometry.getGeometrySpec();
    VCImage origSubvolumeImage = origGeometrySpec.getSampledImage().getCurrentValue();
    if (origSubvolumeImage == null) {
        throw new GeometryException("original geometry does not have a sampled image");
    }
    VCImage resampledSubvolumeImage = RayCaster.sampleGeometry(origGeometry, sampleSize, false);
    // 
    // Check if resampling failed:
    // if not the same number of pixelClasses (between original geometry and resampled)
    // if the subvolume handles are the same
    // 
    boolean bSameSubvolumes = true;
    if (origSubvolumeImage.getNumPixelClasses() != resampledSubvolumeImage.getNumPixelClasses()) {
        bSameSubvolumes = false;
    }
    // 
    for (VCPixelClass origPixelClass : origSubvolumeImage.getPixelClasses()) {
        VCPixelClass resampledPixelClass = resampledSubvolumeImage.getPixelClassFromPixelValue(origPixelClass.getPixel());
        if (resampledPixelClass == null) {
            bSameSubvolumes = false;
            break;
        }
    }
    // 
    if (!bSameSubvolumes) {
        StringBuffer message = new StringBuffer();
        message.append("\n\nexisting geometry:\n");
        for (SubVolume oldSubvolume : origGeometrySpec.getSubVolumes()) {
            long count = origSubvolumeImage.countPixelsByValue((byte) oldSubvolume.getHandle());
            message.append("subvolume('" + oldSubvolume.getName() + "',handle=" + oldSubvolume.getHandle() + ",numPixels=" + count + " of " + origSubvolumeImage.getNumXYZ() + "\n");
        }
        message.append("\n\nnew resampled handle VCImage:\n");
        for (VCPixelClass newPixelClass : resampledSubvolumeImage.getPixelClasses()) {
            long count = resampledSubvolumeImage.countPixelsByValue((byte) newPixelClass.getPixel());
            message.append("pixelClass('" + newPixelClass.getPixelClassName() + "',pixelValue=" + newPixelClass.getPixel() + ",numPixels=" + count + " of " + resampledSubvolumeImage.getNumXYZ() + ")\n");
        }
        throw new GeometryException("original Geometry had " + origSubvolumeImage.getNumPixelClasses() + " subvolumes, resampled Geometry found " + resampledSubvolumeImage.getNumPixelClasses() + " subvolumes " + message.toString());
    }
    // 
    // Create new VCImage that will form the basis for a new image-based geometry.
    // 
    VCImage newVCImage = null;
    if (origGeometrySpec.getImage() != null) {
        // 
        // was an image-based geometry - try to make new VCImage similar to the original (same pixelClass names and pixel values).
        // the goal is to make identical geometries if the sample size is same as the original image size.
        // 
        // create a new VCImage with same image pixel values (not subvolume handles) and pixel class names as original image.
        // 
        byte[] newVCImagePixels = new byte[sampleSize.getXYZ()];
        byte[] resampledSubvolumePixels = resampledSubvolumeImage.getPixels();
        for (int i = 0; i < sampleSize.getXYZ(); i++) {
            int subvolumeHandle = resampledSubvolumePixels[i];
            ImageSubVolume imageSubvolume = (ImageSubVolume) origGeometrySpec.getSubVolume(subvolumeHandle);
            newVCImagePixels[i] = (byte) imageSubvolume.getPixelValue();
        }
        newVCImage = new VCImageUncompressed(null, newVCImagePixels, origGeometry.getExtent(), sampleSize.getX(), sampleSize.getY(), sampleSize.getZ());
        newVCImage.setName(origGeometrySpec.getImage().getName());
        ArrayList<VCPixelClass> newPixelClasses = new ArrayList<VCPixelClass>();
        for (VCPixelClass origPixelClass : origGeometrySpec.getImage().getPixelClasses()) {
            SubVolume origSubvolume = origGeometrySpec.getImageSubVolumeFromPixelValue(origPixelClass.getPixel());
            newPixelClasses.add(new VCPixelClass(null, origSubvolume.getName(), origPixelClass.getPixel()));
        }
        newVCImage.setPixelClasses(newPixelClasses.toArray(new VCPixelClass[newPixelClasses.size()]));
    } else {
        // 
        // was an analytic geometry - create a new image-based geometry
        // 
        // create a new VCImage with image pixel values and pixelClass names equal to corresponding subvolumes from original geometry
        // make new subvolume names equal to old subvolume names.
        // 
        byte[] newVCImageSubvolumePixels = resampledSubvolumeImage.getPixels().clone();
        newVCImage = new VCImageUncompressed(null, newVCImageSubvolumePixels, origGeometry.getExtent(), sampleSize.getX(), sampleSize.getY(), sampleSize.getZ());
        ArrayList<VCPixelClass> newPixelClasses = new ArrayList<VCPixelClass>();
        for (SubVolume origSubvolume : origGeometrySpec.getSubVolumes()) {
            // note: newVCImage already has subvolume handle pixels.
            newPixelClasses.add(new VCPixelClass(null, origSubvolume.getName(), origSubvolume.getHandle()));
        }
        newVCImage.setPixelClasses(newPixelClasses.toArray(new VCPixelClass[newPixelClasses.size()]));
    }
    // 
    // construct the new geometry with the sampled VCImage.
    // 
    Geometry newGeometry = new Geometry(origGeometry.getName(), newVCImage);
    newGeometry.getGeometrySpec().setExtent(origGeometry.getExtent());
    newGeometry.getGeometrySpec().setOrigin(origGeometry.getOrigin());
    newGeometry.setDescription(origGeometry.getDescription());
    newGeometry.getGeometrySurfaceDescription().setFilterCutoffFrequency(origGeometry.getGeometrySurfaceDescription().getFilterCutoffFrequency());
    newGeometry.precomputeAll(geometryThumbnailImageFactory, true, true);
    return newGeometry;
}
Also used : VCPixelClass(cbit.image.VCPixelClass) GeometryException(cbit.vcell.geometry.GeometryException) ArrayList(java.util.ArrayList) VCImage(cbit.image.VCImage) VCImageUncompressed(cbit.image.VCImageUncompressed) GeometrySpec(cbit.vcell.geometry.GeometrySpec) Geometry(cbit.vcell.geometry.Geometry) SubVolume(cbit.vcell.geometry.SubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume)

Example 14 with GeometrySpec

use of cbit.vcell.geometry.GeometrySpec in project vcell by virtualcell.

the class MathModel method gatherIssues.

@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
    issueContext = issueContext.newChildContext(ContextType.MathModel, this);
    GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
    if (geometrySpec != null) {
        geometrySpec.gatherIssues(issueContext, getGeometry(), issueList);
    }
    fieldMathDescription.gatherIssues(issueContext, issueList);
    outputFunctionContext.gatherIssues(issueContext, issueList);
// for (Simulation simulation : fieldSimulations){
// simulation.gatherIssues(issueContext,issueList);
// }
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec)

Example 15 with GeometrySpec

use of cbit.vcell.geometry.GeometrySpec in project vcell by virtualcell.

the class GeometrySurfaceUtils method getUpdatedGeometricRegions.

/**
 * Insert the method's description here.
 * Creation date: (6/28/2004 3:09:13 PM)
 * @return cbit.vcell.geometry.surface.GeometricRegion[]
 * @param geoSurfaceDescription cbit.vcell.geometry.surface.GeometrySurfaceDescription
 * @param surfaceCollection cbit.vcell.geometry.surface.SurfaceCollection
 */
public static GeometricRegion[] getUpdatedGeometricRegions(GeometrySurfaceDescription geoSurfaceDescription, cbit.vcell.geometry.RegionImage regionImage, SurfaceCollection surfaceCollection) {
    // 
    // parse regionImage into ResolvedVolumeLocations
    // 
    VCellThreadChecker.checkCpuIntensiveInvocation();
    double sizeOfPixel = 0;
    VCUnitDefinition volumeUnit = null;
    VCUnitDefinition surfaceUnit = null;
    GeometrySpec geometrySpec = geoSurfaceDescription.getGeometry().getGeometrySpec();
    GeometryUnitSystem geometryUnitSystem = geoSurfaceDescription.getGeometry().getUnitSystem();
    switch(geometrySpec.getDimension()) {
        case 1:
            {
                sizeOfPixel = geometrySpec.getExtent().getX() / (regionImage.getNumX() - 1);
                // sizeOfPixel /= 9.0;  // to account for the padding from 1D to 3D
                volumeUnit = geometryUnitSystem.getLengthUnit();
                surfaceUnit = geometryUnitSystem.getInstance_DIMENSIONLESS();
                break;
            }
        case 2:
            {
                sizeOfPixel = geometrySpec.getExtent().getX() / (regionImage.getNumX() - 1) * geometrySpec.getExtent().getY() / (regionImage.getNumY() - 1);
                // sizeOfPixel /= 3.0;  // to account for the padding from 2D to 3D
                volumeUnit = geometryUnitSystem.getAreaUnit();
                surfaceUnit = geometryUnitSystem.getLengthUnit();
                break;
            }
        case 3:
            {
                sizeOfPixel = geometrySpec.getExtent().getX() / (regionImage.getNumX() - 1) * geometrySpec.getExtent().getY() / (regionImage.getNumY() - 1) * geometrySpec.getExtent().getZ() / (regionImage.getNumZ() - 1);
                volumeUnit = geometryUnitSystem.getVolumeUnit();
                surfaceUnit = geometryUnitSystem.getAreaUnit();
                break;
            }
    }
    int numX = regionImage.getNumX();
    int numY = regionImage.getNumY();
    int numZ = regionImage.getNumZ();
    int numXY = numX * numY;
    java.util.Vector<GeometricRegion> regionList = new java.util.Vector<GeometricRegion>();
    cbit.vcell.geometry.RegionImage.RegionInfo[] regionInfos = regionImage.getRegionInfos();
    for (int i = 0; i < regionInfos.length; i++) {
        cbit.vcell.geometry.RegionImage.RegionInfo regionInfo = regionInfos[i];
        lg.info(regionInfo);
        cbit.vcell.geometry.SubVolume subVolume = geometrySpec.getSubVolume(regionInfo.getPixelValue());
        String name = subVolume.getName() + regionInfo.getRegionIndex();
        int numPixels = regionInfo.getNumPixels();
        double size = numPixels * sizeOfPixel;
        // 
        switch(geometrySpec.getDimension()) {
            case 1:
                {
                    int numHalvesToRemove = 0;
                    // -x pixel
                    if (regionInfo.isIndexInRegion(0)) {
                        // (regionImage.getRegionIndex(0,0,0) == regionIndex)
                        numHalvesToRemove++;
                    }
                    // +x pixel
                    if (regionInfo.isIndexInRegion(numX - 1)) {
                        // (regionImage.getRegionIndex(regionImageNumX-1,0,0) == regionIndex){
                        numHalvesToRemove++;
                    }
                    // *9; // 1D is padded by 3 in y and 3 in z (hence factor of 9)
                    size -= sizeOfPixel * 0.5 * numHalvesToRemove;
                    break;
                }
            case 2:
                {
                    int numQuadrantsToRemove = 0;
                    int yOffset = 0;
                    for (int yIndex = 0; yIndex < numY; yIndex++) {
                        if (regionInfo.isIndexInRegion(yOffset)) {
                            // (regionImage.getRegionIndex(0,yIndex,0) == regionIndex){
                            if (yIndex == 0 || yIndex == numY - 1) {
                                // corner, remove 3 quadrants
                                numQuadrantsToRemove += 3;
                            } else {
                                // side, remove 2 quadrants
                                numQuadrantsToRemove += 2;
                            }
                        }
                        // +x side (including attached corners)
                        if (regionInfo.isIndexInRegion(numX - 1 + yOffset)) {
                            // (regionImage.getRegionIndex(numX-1,yIndex,0) == regionIndex){
                            if (yIndex == 0 || yIndex == numY - 1) {
                                // corner, remove 3 quadrants
                                numQuadrantsToRemove += 3;
                            } else {
                                // side, remove 2 quadrants
                                numQuadrantsToRemove += 2;
                            }
                        }
                        yOffset += numX;
                    }
                    int yOffsetLastLine = (numY - 1) * numX;
                    for (int xIndex = 1; xIndex < numX - 1; xIndex++) {
                        // -y side (excluding corners)
                        if (regionInfo.isIndexInRegion(xIndex)) {
                            // (regionImage.getRegionIndex(xIndex,0,0) == regionIndex){
                            // side, remove 2 quadrants
                            numQuadrantsToRemove += 2;
                        }
                        // +x side (excluding corners)
                        if (regionInfo.isIndexInRegion(xIndex + yOffsetLastLine)) {
                            // (regionImage.getRegionIndex(xIndex,numY-1,0) == regionIndex){
                            // side, remove 2 quadrants
                            numQuadrantsToRemove += 2;
                        }
                    }
                    // *3; // 2D is padded by 3 in z (hence the factor of 3).
                    size -= sizeOfPixel * 0.25 * numQuadrantsToRemove;
                    break;
                }
            case 3:
                {
                    int numOctantsToRemove = 0;
                    for (int zIndex = 0; zIndex < numZ; zIndex++) {
                        for (int yIndex = 0; yIndex < numY; yIndex++) {
                            // -x side (including attached edges and corners)
                            // already on face of boundary (removing half)
                            int totalOctants = 4;
                            // lg.info("-x side including edges and corners");
                            if (regionInfo.isIndexInRegion(yIndex * numX + zIndex * numXY)) {
                                // (regionImage.getRegionIndex(0,yIndex,zIndex) == regionIndex){
                                if (yIndex == 0 || yIndex == numY - 1) {
                                    totalOctants /= 2;
                                }
                                if (zIndex == 0 || zIndex == numZ - 1) {
                                    totalOctants /= 2;
                                }
                                numOctantsToRemove += (8 - totalOctants);
                            }
                            // lg.info("+x side including edges and corners");
                            // +x side (including attached edges and corners)
                            // already on face of boundary (removing half)
                            totalOctants = 4;
                            if (regionInfo.isIndexInRegion(numX - 1 + yIndex * numX + zIndex * numXY)) {
                                // (regionImage.getRegionIndex(numX-1,yIndex,zIndex) == regionIndex){
                                if (yIndex == 0 || yIndex == numY - 1) {
                                    totalOctants /= 2;
                                }
                                if (zIndex == 0 || zIndex == numZ - 1) {
                                    totalOctants /= 2;
                                }
                                numOctantsToRemove += (8 - totalOctants);
                            }
                        }
                        for (int xIndex = 1; xIndex < numX - 1; xIndex++) {
                            // -y side (including attached edges along x axis, excluding corners)
                            // lg.info("-y side including edges");
                            // already on face of boundary (removing half)
                            int totalOctants = 4;
                            if (regionInfo.isIndexInRegion(xIndex + zIndex * numXY)) {
                                // (regionImage.getRegionIndex(xIndex,0,zIndex) == regionIndex){
                                if (zIndex == 0 || zIndex == numZ - 1) {
                                    totalOctants /= 2;
                                }
                                numOctantsToRemove += (8 - totalOctants);
                            }
                            // lg.info("+y side including edges");
                            // +y side (including attached edges along x axis, excluding corners)
                            // already on face of boundary (removing half)
                            totalOctants = 4;
                            if (regionInfo.isIndexInRegion(xIndex + (numY - 1) * numX + zIndex * numXY)) {
                                // (regionImage.getRegionIndex(xIndex,numY-1,zIndex) == regionIndex){
                                if (zIndex == 0 || zIndex == numZ - 1) {
                                    totalOctants /= 2;
                                }
                                numOctantsToRemove += (8 - totalOctants);
                            }
                        }
                    }
                    for (int yIndex = 1; yIndex < numY - 1; yIndex++) {
                        for (int xIndex = 1; xIndex < numX - 1; xIndex++) {
                            // already on face of boundary (removing half)
                            int totalOctants = 4;
                            // lg.info("-z side including nothing");
                            if (regionInfo.isIndexInRegion(xIndex + yIndex * numX)) {
                                // (regionImage.getRegionIndex(xIndex,yIndex,0) == regionIndex){
                                numOctantsToRemove += (8 - totalOctants);
                            }
                            // lg.info("+z side including nothing");
                            if (regionInfo.isIndexInRegion(xIndex + yIndex * numX + (numZ - 1) * numXY)) {
                                // (regionImage.getRegionIndex(xIndex,yIndex,numZ-1) == regionIndex){
                                numOctantsToRemove += (8 - totalOctants);
                            }
                        }
                    }
                    size -= sizeOfPixel * 0.125 * numOctantsToRemove;
                    if (lg.isInfoEnabled()) {
                        lg.info("size=" + size);
                    }
                    break;
                }
        }
        VolumeGeometricRegion volumeRegion = new VolumeGeometricRegion(name, size, volumeUnit, subVolume, regionInfo.getRegionIndex());
        regionList.add(volumeRegion);
        if (lg.isInfoEnabled()) {
            lg.info("added volumeRegion(" + volumeRegion.getName() + ")");
        }
    }
    // 
    for (int i = 0; i < surfaceCollection.getSurfaceCount(); i++) {
        cbit.vcell.geometry.surface.Surface surface = surfaceCollection.getSurfaces(i);
        int exteriorRegionIndex = surface.getExteriorRegionIndex();
        int interiorRegionIndex = surface.getInteriorRegionIndex();
        cbit.vcell.geometry.SubVolume surfaceExteriorSubvolume = geometrySpec.getSubVolume(regionInfos[exteriorRegionIndex].getPixelValue());
        cbit.vcell.geometry.SubVolume surfaceInteriorSubvolume = geometrySpec.getSubVolume(regionInfos[interiorRegionIndex].getPixelValue());
        String name = "membrane_" + surfaceInteriorSubvolume.getName() + interiorRegionIndex + "_" + surfaceExteriorSubvolume.getName() + exteriorRegionIndex;
        double correctedArea = surface.getArea();
        if (geometrySpec.getDimension() == 2) {
            correctedArea /= geometrySpec.getExtent().getZ();
        } else if (geometrySpec.getDimension() == 1) {
            correctedArea /= (geometrySpec.getExtent().getY() * geometrySpec.getExtent().getZ());
        }
        SurfaceGeometricRegion surfaceRegion = new SurfaceGeometricRegion(name, correctedArea, surfaceUnit);
        regionList.add(surfaceRegion);
        // 
        // connect this surfaceLocation to its exterior and interior volumeLocations
        // 
        VolumeGeometricRegion exteriorVolumeRegion = null;
        for (int j = 0; j < regionList.size(); j++) {
            GeometricRegion region = regionList.elementAt(j);
            if (region instanceof VolumeGeometricRegion && region.getName().equals(surfaceExteriorSubvolume.getName() + exteriorRegionIndex)) {
                exteriorVolumeRegion = (VolumeGeometricRegion) region;
            }
        }
        surfaceRegion.addAdjacentGeometricRegion(exteriorVolumeRegion);
        exteriorVolumeRegion.addAdjacentGeometricRegion(surfaceRegion);
        VolumeGeometricRegion interiorVolumeRegion = null;
        for (int j = 0; j < regionList.size(); j++) {
            GeometricRegion region = regionList.elementAt(j);
            if (region instanceof VolumeGeometricRegion && region.getName().equals(surfaceInteriorSubvolume.getName() + interiorRegionIndex)) {
                interiorVolumeRegion = (VolumeGeometricRegion) region;
            }
        }
        surfaceRegion.addAdjacentGeometricRegion(interiorVolumeRegion);
        interiorVolumeRegion.addAdjacentGeometricRegion(surfaceRegion);
        if (lg.isInfoEnabled()) {
            lg.info("added surfaceRegion(" + surfaceRegion.getName() + ")");
        }
    }
    return org.vcell.util.BeanUtils.getArray(regionList, GeometricRegion.class);
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) GeometryUnitSystem(cbit.vcell.geometry.GeometryUnitSystem) RegionImage(cbit.vcell.geometry.RegionImage)

Aggregations

GeometrySpec (cbit.vcell.geometry.GeometrySpec)23 SubVolume (cbit.vcell.geometry.SubVolume)12 VCImage (cbit.image.VCImage)7 SurfaceClass (cbit.vcell.geometry.SurfaceClass)6 GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)6 Expression (cbit.vcell.parser.Expression)6 ArrayList (java.util.ArrayList)6 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)5 Geometry (cbit.vcell.geometry.Geometry)5 GeometryThumbnailImageFactoryAWT (cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT)5 GeometricRegion (cbit.vcell.geometry.surface.GeometricRegion)5 SurfaceGeometricRegion (cbit.vcell.geometry.surface.SurfaceGeometricRegion)5 VolumeGeometricRegion (cbit.vcell.geometry.surface.VolumeGeometricRegion)5 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)5 MembraneSubDomain (cbit.vcell.math.MembraneSubDomain)5 Extent (org.vcell.util.Extent)5 Origin (org.vcell.util.Origin)5 CSGObject (cbit.vcell.geometry.CSGObject)4 ISize (org.vcell.util.ISize)4 VCImageUncompressed (cbit.image.VCImageUncompressed)3