Search in sources :

Example 1 with Line

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

the class XmlReader method getControlPointCurve.

/**
 * This method returns a ControlPointcurve object from a XML element.
 * Creation date: (5/22/2001 5:20:39 PM)
 * @return cbit.vcell.geometry.ControlPointCurve
 * @param param org.jdom.Element
 */
private ControlPointCurve getControlPointCurve(Element param) {
    ControlPointCurve curve = null;
    // get Attributes
    String type = param.getAttributeValue(XMLTags.TypeAttrTag);
    boolean closed = Boolean.valueOf(param.getAttributeValue(XMLTags.ClosedAttrTag)).booleanValue();
    List<Element> coordList = param.getChildren();
    // Upon de type, decide which Curve type to create
    if (type.equalsIgnoreCase(XMLTags.PolyLineTypeTag)) {
        if (coordList.size() == 2) {
            // I have a Line
            Coordinate begin = getCoordinate(coordList.get(0));
            Coordinate end = getCoordinate(coordList.get(1));
            // ****create new Line ****
            curve = new Line(begin, end);
        } else {
            // If it it is not a Line, then it is a SampledCurve
            Coordinate[] coords = new Coordinate[coordList.size()];
            for (int i = 0; i < coordList.size(); i++) {
                coords[i] = getCoordinate(coordList.get(i));
            }
            // ****create new SampledCurve ****
            curve = new SampledCurve(coords);
        }
    } else if (type.equalsIgnoreCase(XMLTags.SplineTypeTag)) {
        Coordinate[] coords = new Coordinate[coordList.size()];
        for (int i = 0; i < coordList.size(); i++) {
            coords[i] = getCoordinate(coordList.get(i));
        }
        // ****create new Spline ****
        curve = new Spline(coords);
    }
    // set Atributes
    curve.setClosed(closed);
    return curve;
}
Also used : Line(cbit.vcell.geometry.Line) SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate) Element(org.jdom.Element) ControlPointCurve(cbit.vcell.geometry.ControlPointCurve) Spline(cbit.vcell.geometry.Spline)

Example 2 with Line

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

the class Xmlproducer method getXML.

/**
 * This method retruns a XML ELement from a ControlPointCurve object.
 * Creation date: (5/22/2001 4:11:37 PM)
 * @return Element
 * @param param cbit.vcell.geometry.ControlPointCurve
 */
private Element getXML(ControlPointCurve param) {
    Element curve = new Element(XMLTags.CurveTag);
    // Add attributes
    String type = null;
    if (param instanceof Spline) {
        type = XMLTags.SplineTypeTag;
    } else if (param instanceof Line || param instanceof SampledCurve) {
        type = XMLTags.PolyLineTypeTag;
    }
    curve.setAttribute(XMLTags.TypeAttrTag, type);
    curve.setAttribute(XMLTags.ClosedAttrTag, String.valueOf(param.isClosed()));
    // Add coordinates
    Vector<Coordinate> vector = param.getControlPointsVector();
    Iterator<Coordinate> iterator = vector.iterator();
    while (iterator.hasNext()) {
        curve.addContent(getXML(iterator.next()));
    }
    return curve;
}
Also used : Line(cbit.vcell.geometry.Line) SampledCurve(cbit.vcell.geometry.SampledCurve) Coordinate(org.vcell.util.Coordinate) Element(org.jdom.Element) Spline(cbit.vcell.geometry.Spline)

Example 3 with Line

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

the class MeshDisplayAdapter method addSegmentToCurve.

/**
 * Insert the method's description here.
 * Creation date: (8/31/00 12:07:40 PM)
 * @return boolean
 * @param from cbit.vcell.solvers.MembraneElement
 * @param to cbit.vcell.solvers.MembraneElement
 */
private void addSegmentToCurve(SampledCurve curve, MembraneElement from, MembraneElement to, int normalAxis, boolean bPrepend, Vector<Integer> resolvedMembraneIndexes) {
    Line toProjection = getProjectedSegment(to, normalAxis);
    if (from == null) {
        addPointToCurve(curve, bPrepend, toProjection, ORDER_P0);
        addPointToCurve(curve, bPrepend, toProjection, ORDER_PREPEND);
    } else {
        int order = determineOrder(from, to, normalAxis);
        addPointToCurve(curve, bPrepend, toProjection, order);
    }
    // 
    if (bPrepend && resolvedMembraneIndexes.size() > 0) {
        resolvedMembraneIndexes.add(0, new Integer(to.getMembraneIndex()));
    } else {
        resolvedMembraneIndexes.add(new Integer(to.getMembraneIndex()));
    }
}
Also used : Line(cbit.vcell.geometry.Line)

Example 4 with Line

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

the class MeshDisplayAdapter method getProjectedSegment.

/**
 * Insert the method's description here.
 * Creation date: (8/30/00 6:25:14 PM)
 * @return cbit.vcell.geometry.Line
 */
private Line getProjectedSegment(MembraneElement membraneElement, int normalAxis) {
    // Find midpoint between the 2 volume elements for this MembraneElement
    Coordinate c0 = getMesh().getCoordinateFromMembraneIndex(membraneElement.getMembraneIndex());
    double x0 = c0.getX(), y0 = c0.getY(), z0 = c0.getZ();
    double x1 = c0.getX(), y1 = c0.getY(), z1 = c0.getZ();
    // Stretch endpoints for the line segment based on membranePlane and size of volumeElement
    int membranePlane = getParalellAxis(membraneElement, normalAxis);
    if (membranePlane == Coordinate.Z_AXIS) {
        double elementZSize = (1.0 / (double) (mesh.getSizeZ() - 1)) * mesh.getExtent().getZ();
        z0 -= (elementZSize / 2.0);
        z1 += (elementZSize / 2.0);
    } else if (membranePlane == Coordinate.Y_AXIS) {
        double elementYSize = (1.0 / (double) (mesh.getSizeY() - 1)) * mesh.getExtent().getY();
        y0 -= (elementYSize / 2.0);
        y1 += (elementYSize / 2.0);
    } else if (membranePlane == Coordinate.X_AXIS) {
        double elementXSize = (1.0 / (double) (mesh.getSizeX() - 1)) * mesh.getExtent().getX();
        x0 -= (elementXSize / 2.0);
        x1 += (elementXSize / 2.0);
    }
    // Clip to edge of world
    x0 = (x0 < mesh.getOrigin().getX() ? mesh.getOrigin().getX() : x0);
    y0 = (y0 < mesh.getOrigin().getY() ? mesh.getOrigin().getY() : y0);
    z0 = (z0 < mesh.getOrigin().getZ() ? mesh.getOrigin().getZ() : z0);
    x1 = (x1 > (mesh.getOrigin().getX() + mesh.getExtent().getX()) ? mesh.getOrigin().getX() + mesh.getExtent().getX() : x1);
    y1 = (y1 > (mesh.getOrigin().getY() + mesh.getExtent().getY()) ? mesh.getOrigin().getY() + mesh.getExtent().getY() : y1);
    z1 = (z1 > (mesh.getOrigin().getZ() + mesh.getExtent().getZ()) ? mesh.getOrigin().getZ() + mesh.getExtent().getZ() : z1);
    // 
    return new Line(new Coordinate(x0, y0, z0), new Coordinate(x1, y1, z1));
}
Also used : Line(cbit.vcell.geometry.Line) Coordinate(org.vcell.util.Coordinate)

Aggregations

Line (cbit.vcell.geometry.Line)4 Coordinate (org.vcell.util.Coordinate)3 SampledCurve (cbit.vcell.geometry.SampledCurve)2 Spline (cbit.vcell.geometry.Spline)2 Element (org.jdom.Element)2 ControlPointCurve (cbit.vcell.geometry.ControlPointCurve)1