Search in sources :

Example 41 with InternalErrorException

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

the class SimpleCollide method setBottomObject.

private void setBottomObject(Collidable comp, ObjectType type) {
    Renderable rcomp = (Renderable) comp;
    ((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myBottomScale));
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
            {
                RenderProps.setPointColor(rcomp, Color.green);
                // fix the lower nodes
                Point3d min = new Point3d();
                RenderableUtils.getBounds(rcomp, min, null);
                FemModel3d fem = (FemModel3d) comp;
                fem.getSurfaceMesh();
                for (FemNode3d n : fem.getNodes()) {
                    if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.5)) {
                        n.setDynamic(false);
                    }
                }
                fem.resetRestPosition();
                break;
            }
        case FemCube:
            {
                RenderProps.setPointColor(rcomp, Color.green);
                // fix the lower nodes
                Point3d min = new Point3d();
                RenderableUtils.getBounds(rcomp, min, null);
                FemModel3d fem = (FemModel3d) comp;
                fem.getSurfaceMesh();
                for (FemNode3d n : fem.getNodes()) {
                    if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.1)) {
                        n.setDynamic(false);
                    }
                }
                // RenderProps.setAlpha (rcomp, 0.3);
                fem.resetRestPosition();
                break;
            }
        case Box:
            {
                ((RigidBody) comp).setDynamic(false);
                ((RigidBody) comp).setDistanceGridRes(new Vector3i(10, 5, 5));
                break;
            }
        case Molar:
            {
                ((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, -1, 0, Math.toRadians(172.09)));
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        case Bin:
            {
                ((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, 0, 0, 0));
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        case Paw:
        case House:
            {
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
    myBottomObject = comp;
    myBottomType = type;
}
Also used : TransformableGeometry(artisynth.core.modelbase.TransformableGeometry) RigidTransform3d(maspack.matrix.RigidTransform3d) Renderable(maspack.render.Renderable) FemModel3d(artisynth.core.femmodels.FemModel3d) Point3d(maspack.matrix.Point3d) FemNode3d(artisynth.core.femmodels.FemNode3d) Vector3i(maspack.matrix.Vector3i) InternalErrorException(maspack.util.InternalErrorException)

Example 42 with InternalErrorException

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

the class SimpleCollide method removeObject.

private void removeObject(ModelComponent comp, ObjectType type) {
    MechModel mechMod = (MechModel) models().get(0);
    ComponentList<Probe> myProbes = getInputProbes();
    for (Probe p : myProbes) {
        System.out.println("type's name: " + type.name());
        System.out.println("probe's name: " + p.getName());
        if (type.name().equals(p.getName())) {
            removeInputProbe(p);
        }
    }
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
        case FemCube:
            {
                mechMod.removeModel((FemModel3d) comp);
                break;
            }
        case Box:
        case Molar:
        case Bin:
        case Paw:
        case House:
            {
                mechMod.removeRigidBody((RigidBody) comp);
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) RigidBody(artisynth.core.mechmodels.RigidBody) InternalErrorException(maspack.util.InternalErrorException) Probe(artisynth.core.probes.Probe) NumericInputProbe(artisynth.core.probes.NumericInputProbe)

Example 43 with InternalErrorException

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

the class RenderProps method clone.

public RenderProps clone() {
    RenderProps props = null;
    try {
        props = (RenderProps) super.clone();
    } catch (CloneNotSupportedException e) {
        throw new InternalErrorException("cannot clone super in RenderProps");
    }
    props.myPropInfo = null;
    props.myPropHost = null;
    // create new objects
    if (props.mySpecular != null) {
        props.mySpecular = new float[3];
    }
    if (props.myBackColor != null) {
        props.myBackColor = new float[3];
    }
    if (props.myEdgeColor != null) {
        props.myEdgeColor = new float[3];
    }
    props.myFaceColor = new float[3];
    props.myLineColor = new float[3];
    props.myPointColor = new float[3];
    props.set(this);
    return props;
}
Also used : InternalErrorException(maspack.util.InternalErrorException)

Example 44 with InternalErrorException

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

the class Jack3d method intersectRayAndFixture.

private void intersectRayAndFixture(Point3d p, Line ray) {
    Line draggerRay = new Line(ray);
    draggerRay.inverseTransform(myXDraggerToWorld);
    switch(mySelectedComponent) {
        case X_AXIS:
            {
                double l = xAxis.nearestPoint(p, draggerRay);
                p.y = p.z = 0;
                break;
            }
        case Y_AXIS:
            {
                yAxis.nearestPoint(p, draggerRay);
                p.x = p.z = 0;
                break;
            }
        case Z_AXIS:
            {
                zAxis.nearestPoint(p, draggerRay);
                p.x = p.y = 0;
                break;
            }
        case Z_ROTATE:
            {
                draggerRay.intersectPlane(p, xyPlane);
                p.z = 0;
                break;
            }
        case X_ROTATE:
            {
                draggerRay.intersectPlane(p, yzPlane);
                p.x = 0;
                break;
            }
        case Y_ROTATE:
            {
                draggerRay.intersectPlane(p, zxPlane);
                p.y = 0;
                break;
            }
        default:
            {
                throw new InternalErrorException("unexpected case");
            }
    }
}
Also used : Line(maspack.matrix.Line) InternalErrorException(maspack.util.InternalErrorException)

Example 45 with InternalErrorException

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

the class HostList method getCommonRange.

public Range getCommonRange(PropTreeCell cell) {
    int[] indexPath = cell.getIndexPath();
    if (indexPath.length == 0) {
        throw new InternalErrorException("getCommonRange cannot be called for top-level cell");
    }
    Range commonRange = null;
    for (int i = 0; i < myHosts.size(); i++) {
        PropTreeData data = myDataList[i];
        HasProperties host = null;
        for (int level = 0; level < indexPath.length; level++) {
            host = data.myHost;
            if (data.getSubData() == null) {
                throw new InternalErrorException("data tree not initialized for " + cell.pathString());
            }
            // XXSystem.out.println ("25");
            data = data.getSubData()[indexPath[level]];
        }
        Range range = PropertyUtils.getRange(data.myInfo, host);
        if (range != null) {
            if (commonRange == null) {
                try {
                    commonRange = (Range) range.clone();
                } catch (Exception e) {
                    throw new InternalErrorException("Can't clone " + range.getClass());
                }
            } else {
                commonRange.intersect(range);
            }
        }
    }
    return commonRange;
}
Also used : InternalErrorException(maspack.util.InternalErrorException) Range(maspack.util.Range) InternalErrorException(maspack.util.InternalErrorException)

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