Search in sources :

Example 36 with InternalErrorException

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

the class ComponentPropertyField method getPropertyForComposite.

private Property getPropertyForComposite(CompositeProperty cprop) {
    PropertyInfo info = cprop.getPropertyInfo();
    HasProperties host = cprop.getPropertyHost();
    Property prop = host.getProperty(info.getName());
    if (prop == null) {
        throw new InternalErrorException("Property not found in composite property host");
    }
    return prop;
}
Also used : HasProperties(maspack.properties.HasProperties) InternalErrorException(maspack.util.InternalErrorException) PropertyInfo(maspack.properties.PropertyInfo) CompositeProperty(maspack.properties.CompositeProperty) Property(maspack.properties.Property)

Example 37 with InternalErrorException

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

the class MechSystemSolver method projectFrictionConstraints.

protected void projectFrictionConstraints(VectorNd vel, double t0) {
    // BEGIN project friction constraints
    updateFrictionConstraints();
    // assumes that updateMassMatrix() has been called
    myRBSolver.updateStructure(myMass, myGT, myGTVersion);
    myRBSolver.projectFriction(myMass, myGT, myNT, myDT, myRg, myBg, myRn, myBn, myBd, myFrictionInfo, vel, myLam, myThe, myPhi);
    // do a Gauss-Siedel project on remaining friction constraints:
    int[] RBDTmap = myRBSolver.getDTMap();
    if (RBDTmap != null) {
        int[] DTmap = new int[myDT.numBlockCols() - RBDTmap.length];
        int i = 0;
        int k = 0;
        for (int bj = 0; bj < myDT.numBlockCols(); bj++) {
            if (k < RBDTmap.length && RBDTmap[k] == bj) {
                k++;
            } else {
                DTmap[i++] = bj;
            }
        }
        if (i != DTmap.length) {
            throw new InternalErrorException("inconsistent DTmap");
        }
        updateInverseMassMatrix(t0);
        for (i = 0; i < DTmap.length; i++) {
            FrictionInfo info = myFrictionInfo[DTmap[i]];
            double phiMax;
            if ((info.flags & FrictionInfo.BILATERAL) != 0) {
                phiMax = info.getMaxFriction(myLam);
            } else {
                phiMax = info.getMaxFriction(myThe);
            }
            int bj = DTmap[i];
            int j = myDT.getBlockColOffset(bj);
            double doff = myBd.get(j);
            double phi = projectSingleFrictionConstraint(vel, myDT, bj, phiMax, doff, /*ignore rigid bodies=*/
            true);
            myPhi.set(j, phi);
        }
    }
    if (myUpdateForcesAtStepEnd) {
        int velSize = myActiveVelSize;
        if (myDsize > 0) {
            myDT.mulAdd(myFcon, myPhi, velSize, myDsize);
        }
    }
}
Also used : FrictionInfo(artisynth.core.mechmodels.MechSystem.FrictionInfo) InternalErrorException(maspack.util.InternalErrorException)

Example 38 with InternalErrorException

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

the class MovieMakerDialog method valueChange.

/**
 * Listens for value change events from the methodSelector and
 * the formatSelector.
 */
public void valueChange(ValueChangeEvent event) {
    if (event.getSource() == methodSelector) {
        String methodName = (String) methodSelector.getValue();
        if (!methodName.equals(myMovieMaker.getMethod())) {
            MovieMaker.Method method = myMovieMaker.getMethodMap().get(methodName);
            myMovieMaker.setMethod(methodName);
            if (!method.frameFileFormat.equals(myMovieMaker.getFormat())) {
                myMovieMaker.setFormat(method.frameFileFormat);
                formatSelector.setValue(method.frameFileFormat);
            }
        }
    } else if (event.getSource() == formatSelector) {
        String format = (String) formatSelector.getValue();
        if (!format.equals(myMovieMaker.getFormat())) {
            myMovieMaker.setFormat(format);
            String methodName = (String) methodSelector.getValue();
            MovieMaker.Method method = myMovieMaker.getMethodMap().get(methodName);
            method.frameFileFormat = format;
        }
    } else if (event.getSource() == frameRateField) {
        myMovieMaker.setFrameRate(frameRateField.getDoubleValue());
    } else if (event.getSource() == speedField) {
        myMovieMaker.setSpeed(speedField.getDoubleValue());
    } else if (event.getSource() == resizeSamples) {
        myMovieMaker.setAntiAliasingSamples(resizeSamples.getIntValue());
    } else {
        throw new InternalErrorException("valueChange event from unknown source " + event.getSource());
    }
    updateMethodSelectors();
}
Also used : Method(artisynth.core.moviemaker.MovieMaker.Method) Method(artisynth.core.moviemaker.MovieMaker.Method) InternalErrorException(maspack.util.InternalErrorException)

Example 39 with InternalErrorException

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

the class RootModel method advanceModel.

protected void advanceModel(ModelInfo info, double t0, double t1, int flags) {
    double ta = t0;
    if (t0 == 0) {
        applyOutputProbes(info.outputProbes, t0, info);
    }
    while (ta < t1) {
        double s;
        synchronized (this) {
            info.getModelAndControllersState(info.state);
        }
        if (testSaveAndRestoreState) {
            // test save-and-restore of model state
            CompositeState fullState = info.createFullState();
            CompositeState testState = info.createFullState();
            info.getFullState(fullState);
            info.setFullState(fullState);
            info.getFullState(testState);
            if (!testState.equals(fullState)) {
                throw new InternalErrorException("Error: save/restore state test failed");
            }
        }
        double tb = info.getNextAdvanceTime(ta, t1);
        do {
            synchronized (this) {
                StepAdjustment adj;
                // info.model.setDefaultInputs (ta, tb);
                adj = info.model.preadvance(ta, tb, flags);
                s = getRecommendedScaling(adj);
                if (s >= 1) {
                    applyInputProbes(info.inputProbes, tb);
                    applyControllers(info.controllers, ta, tb);
                    adj = info.model.advance(ta, tb, flags);
                    s = getRecommendedScaling(adj);
                }
                if (myAdaptiveStepping && s < 1) {
                    tb = info.reduceAdvanceTime(s, ta, tb, adj.getMessage());
                    info.setModelAndControllersState(info.state);
                    info.model.initialize(ta);
                }
            }
        } while (myAdaptiveStepping && s < 1 && !myStopAdvance);
        if (!(myAdaptiveStepping && s < 1)) {
            // then we have advanced to tb:
            info.updateStepInfo(s);
            applyMonitors(info.monitors, ta, tb);
            applyOutputProbes(info.outputProbes, tb, info);
            ta = tb;
        }
    }
}
Also used : CompositeState(artisynth.core.modelbase.CompositeState) InternalErrorException(maspack.util.InternalErrorException) StepAdjustment(artisynth.core.modelbase.StepAdjustment)

Example 40 with InternalErrorException

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

the class IntersectionTester method getPointEdge.

/**
 * Return the edge of a face that contains an intersection point.
 */
private HalfEdge getPointEdge(IntersectionPoint pa, Face face) {
    PolygonalMesh mesh = (PolygonalMesh) face.getMesh();
    if (edgeOnMesh(pa.edge, mesh)) {
        if (pa.edge.getFace() == face) {
            return pa.edge;
        } else if (getOppositeFace(pa.edge) == face) {
            return pa.edge.opposite;
        } else {
            throw new InternalErrorException("Face edge not found for point " + pa);
        }
    } else {
        // convert pa to mesh local coordinates
        Point3d paLoc = new Point3d(pa);
        paLoc.inverseTransform(mesh.getMeshToWorld());
        HalfEdge he0 = face.firstHalfEdge();
        HalfEdge he = he0;
        HalfEdge heMin = null;
        double dmin = Double.POSITIVE_INFINITY;
        do {
            double d = LineSegment.distance(he.getHead().pnt, he.getTail().pnt, paLoc);
            if (d < dmin) {
                heMin = he;
                dmin = d;
            }
            he = he.getNext();
        } while (he != he0);
        return heMin;
    }
}
Also used : Point3d(maspack.matrix.Point3d) HalfEdge(maspack.geometry.HalfEdge) InternalErrorException(maspack.util.InternalErrorException) PolygonalMesh(maspack.geometry.PolygonalMesh)

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