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;
}
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);
}
}
}
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();
}
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;
}
}
}
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;
}
}
Aggregations