Search in sources :

Example 81 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class SegmentedPlanarConnector method computeRenderVtxs.

protected void computeRenderVtxs(int planeIdx, RigidTransform3d TDW) {
    ArrayList<Point3d> segPnts = mySegPlaneCoupling.getSegmentPoints();
    if (planeIdx >= segPnts.size() - 1) {
        throw new InternalErrorException("index " + planeIdx + " exceeds number of planes");
    }
    Point3d p0 = segPnts.get(planeIdx);
    Point3d p1 = segPnts.get(planeIdx + 1);
    Vector3d yaxis = Vector3d.Y_UNIT;
    myRenderVtxs[0].set(p0);
    myRenderVtxs[0].scaledAdd(-myPlaneSize / 2, yaxis, myRenderVtxs[0]);
    myRenderVtxs[3].set(p0);
    myRenderVtxs[3].scaledAdd(myPlaneSize / 2, yaxis, myRenderVtxs[3]);
    myRenderVtxs[1].set(p1);
    myRenderVtxs[1].scaledAdd(-myPlaneSize / 2, yaxis, myRenderVtxs[1]);
    myRenderVtxs[2].set(p1);
    myRenderVtxs[2].scaledAdd(myPlaneSize / 2, yaxis, myRenderVtxs[2]);
    for (int i = 0; i < myRenderVtxs.length; i++) {
        myRenderVtxs[i].transform(TDW);
    }
}
Also used : Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) InternalErrorException(maspack.util.InternalErrorException)

Example 82 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class DistanceGridSurfCalc method computeBCoefs.

public PlaneType computeBCoefs(double[] b, Vector3d r, double[] c, Plane planeCell) {
    double rx, ry, rz;
    Vector3d nrmCell = planeCell.normal;
    double off = planeCell.offset;
    PlaneType planeType;
    switch(nrmCell.maxAbsIndex()) {
        case 0:
            {
                rx = nrmCell.y / nrmCell.x;
                ry = nrmCell.z / nrmCell.x;
                rz = off / nrmCell.x;
                b[0] = c[1] + c[0] * rx * rx - c[5] * rx;
                b[1] = c[2] + c[0] * ry * ry - c[4] * ry;
                b[2] = c[3] + 2 * c[0] * rx * ry - c[5] * ry - c[4] * rx;
                b[3] = c[7] - 2 * c[0] * rz * rx + c[5] * rz - c[6] * rx;
                b[4] = c[8] - 2 * c[0] * rz * ry + c[4] * rz - c[6] * ry;
                b[5] = c[9] + c[0] * rz * rz + c[6] * rz;
                planeType = PlaneType.YZ;
                break;
            }
        case 1:
            {
                rx = nrmCell.z / nrmCell.y;
                ry = nrmCell.x / nrmCell.y;
                rz = off / nrmCell.y;
                b[0] = c[2] + c[1] * rx * rx - c[3] * rx;
                b[1] = c[0] + c[1] * ry * ry - c[5] * ry;
                b[2] = c[4] + 2 * c[1] * rx * ry - c[3] * ry - c[5] * rx;
                b[3] = c[8] - 2 * c[1] * rz * rx + c[3] * rz - c[7] * rx;
                b[4] = c[6] - 2 * c[1] * rz * ry + c[5] * rz - c[7] * ry;
                b[5] = c[9] + c[1] * rz * rz + c[7] * rz;
                planeType = PlaneType.ZX;
                break;
            }
        case 2:
            {
                rx = nrmCell.x / nrmCell.z;
                ry = nrmCell.y / nrmCell.z;
                rz = off / nrmCell.z;
                b[0] = c[0] + c[2] * rx * rx - c[4] * rx;
                b[1] = c[1] + c[2] * ry * ry - c[3] * ry;
                b[2] = c[5] + 2 * c[2] * rx * ry - c[4] * ry - c[3] * rx;
                b[3] = c[6] - 2 * c[2] * rz * rx + c[4] * rz - c[8] * rx;
                b[4] = c[7] - 2 * c[2] * rz * ry + c[3] * rz - c[8] * ry;
                b[5] = c[9] + c[2] * rz * rz + c[8] * rz;
                planeType = PlaneType.XY;
                break;
            }
        default:
            {
                throw new InternalErrorException("Vector3d.maxAbsIndex() returned value " + nrmCell.maxAbsIndex());
            }
    }
    if (r != null) {
        r.x = rx;
        r.y = ry;
        r.z = rz;
    }
    return planeType;
}
Also used : Vector3d(maspack.matrix.Vector3d) InternalErrorException(maspack.util.InternalErrorException)

Example 83 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class SparseBlockMatrix method clone.

/**
 * Creates a clone of this SparseBlockMatrix, along with clones of all the
 * associated MatrixBlocks.
 */
public SparseBlockMatrix clone() {
    SparseBlockMatrix M;
    try {
        M = (SparseBlockMatrix) super.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalErrorException("clone not supported for super class of SparseBlockMatrix");
    }
    M.set(this);
    return M;
}
Also used : InternalErrorException(maspack.util.InternalErrorException)

Example 84 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class ComponentPropertyField method valueToText.

protected String valueToText(Object value) {
    ModelComponent comp = getComponent(value);
    RootModel root = myMain.getRootModel();
    if (root == null || comp == null) {
        return "";
    }
    if (value instanceof ModelComponent) {
        return ComponentUtils.getPathName(root, comp);
    } else if (value instanceof Property) {
        Property prop = (Property) value;
        boolean excludeLeaf = (myPropertySelector != null && !(prop.get() instanceof CompositeProperty));
        String path = ComponentUtils.getPropertyPathName(prop, root, false);
        if (!path.contains(":")) {
            // root component + property
            path = "/:" + path;
        }
        return path;
    } else {
        throw new InternalErrorException("Unknown value type: " + value.getClass());
    }
// String text = ComponentUtils.getPathName(root, comp);
// if (value instanceof Property)
// { Property prop = (Property)value;
// String propPath = getPropertyPath (prop, myPropertySelector != null);
// if (propPath.length() > 0)
// { text += "/" + propPath;
// }
// }
// return text;
}
Also used : RootModel(artisynth.core.workspace.RootModel) ModelComponent(artisynth.core.modelbase.ModelComponent) InternalErrorException(maspack.util.InternalErrorException) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property) CompositeProperty(maspack.properties.CompositeProperty)

Example 85 with InternalErrorException

use of maspack.util.InternalErrorException in project artisynth_core by artisynth.

the class ComponentPropertyField method setValueFromPropertySelector.

private void setValueFromPropertySelector() {
    if (!myPropertyMask) {
        String propName = (String) myPropertySelector.getValue();
        HasProperties host = getHost();
        if (propName.equals(nullString)) {
            Object value = getValueForHost();
            System.out.println("new value");
            updateValueAndDisplay(value);
            return;
        }
        if (host == null) {
            throw new InternalErrorException("Current property host is null");
        }
        Property prop = host.getProperty(propName);
        if (prop == null) {
            throw new InternalErrorException("Current property host does not contain property " + propName);
        }
        updateValueAndDisplay(prop);
    }
}
Also used : HasProperties(maspack.properties.HasProperties) InternalErrorException(maspack.util.InternalErrorException) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property)

Aggregations

InternalErrorException (maspack.util.InternalErrorException)92 Vector3d (maspack.matrix.Vector3d)9 CompositeProperty (maspack.properties.CompositeProperty)8 Point3d (maspack.matrix.Point3d)7 Property (maspack.properties.Property)7 FemModel3d (artisynth.core.femmodels.FemModel3d)6 Point (artisynth.core.mechmodels.Point)6 ModelComponent (artisynth.core.modelbase.ModelComponent)5 PolygonalMesh (maspack.geometry.PolygonalMesh)5 Line (maspack.matrix.Line)5 RigidTransform3d (maspack.matrix.RigidTransform3d)5 EditingProperty (maspack.properties.EditingProperty)5 BadLocationException (javax.swing.text.BadLocationException)4 RotationMatrix3d (maspack.matrix.RotationMatrix3d)4 RigidBody (artisynth.core.mechmodels.RigidBody)3 RootModel (artisynth.core.workspace.RootModel)3 File (java.io.File)3 IOException (java.io.IOException)3 LinkedList (java.util.LinkedList)3 SelectionManager (artisynth.core.gui.selectionManager.SelectionManager)2