use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class Scaler3d 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 XY_PLANE:
{
draggerRay.intersectPlane(p, xyPlane);
p.z = 0;
break;
}
case YZ_PLANE:
{
draggerRay.intersectPlane(p, yzPlane);
p.x = 0;
break;
}
case ZX_PLANE:
{
draggerRay.intersectPlane(p, zxPlane);
p.y = 0;
break;
}
default:
{
throw new InternalErrorException("unexpected case " + mySelectedComponent);
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class CustomSphericalCoupling method getConstraintInfo.
@Override
public void getConstraintInfo(ConstraintInfo[] info, RigidTransform3d TGD, RigidTransform3d TCD, RigidTransform3d XERR, boolean setEngaged) {
// projectToConstraint(TGD, TCD);
// info[0].bilateral = true;
// info[1].bilateral = true;
// info[2].bilateral = true;
// info[3].bilateral = false;
// info[4].bilateral = false;
// info[5].bilateral = false;
// myXFC.mulInverseLeft(TGD, TCD);
myErr.set(XERR);
setDistancesAndZeroDerivatives(info, 3, myErr);
if (myRangeType == TILT_LIMIT) {
Vector3d utilt = new Vector3d();
// Tilt axis is is z(C) x z(D).
// In C coordinates, z(C) = (0,0,1) and z(D) = last row of TGD.R.
// In D coordinates, z(D) = (0,0,1) and z(C) = last col of TGD.R.
// D coordinates
utilt.set(TGD.R.m12, -TGD.R.m02, 0);
// utilt.set (-TGD.R.m21, TGD.R.m20, 0); // in C coordinates
double ulen = utilt.norm();
double theta = 0;
if (ulen > 1e-8) {
theta = Math.atan2(ulen, TGD.R.m22);
utilt.scale(1 / ulen);
}
if (setEngaged) {
if (theta > myMaxTilt) {
info[3].engaged = 1;
}
}
if (info[3].engaged != 0) {
info[3].distance = myMaxTilt - theta;
utilt.inverseTransform(TGD.R);
info[3].wrenchC.set(0, 0, 0, utilt.x, utilt.y, utilt.z);
info[3].dotWrenchC.setZero();
}
} else if (myRangeType == ROTATION_LIMIT) {
Vector3d u = new Vector3d();
double ang = TGD.R.getAxisAngle(u);
// paranoid
u.normalize();
Vector3d a = new Vector3d(u.x * myMaxRotX, u.y * myMaxRotY, u.z * myMaxRotZ);
double maxAng = a.norm();
if (setEngaged) {
if (ang > 0 && ang > maxAng) {
info[3].engaged = 1;
}
}
if (info[3].engaged != 0) {
info[3].distance = maxAng - ang;
u.x /= myMaxRotX;
u.y /= myMaxRotY;
u.z /= myMaxRotZ;
u.normalize();
info[3].wrenchC.set(0, 0, 0, -u.x, -u.y, -u.z);
// TODO set this
info[3].dotWrenchC.setZero();
}
} else if (myRangeType == CUSTOM_LIMIT) {
// get relative z axis
double[] z = new double[3];
// z(C) in D coordinates
TGD.R.getColumn(2, z);
// check if X inside curve, and project to boundary if outside
boolean engage = false;
double[] zNew = { z[0], z[1], z[2] };
Vector3d vAxis = new Vector3d(1, 0, 0);
if (!myCurve.isWithin(z)) {
double theta2 = myCurve.findClosestPoint(z, zNew);
if (theta2 > 1e-5) {
engage = true;
}
}
Vector3d v1 = new Vector3d(z);
Vector3d v2 = new Vector3d(zNew);
double theta = Math.acos(v1.dot(v2));
if (Math.toDegrees(theta) > 20) {
System.out.printf("Z: (%f,%f,%f), Zn: (%f,%f,%f),theta=%f\n", z[0], z[1], z[2], zNew[0], zNew[1], zNew[2], Math.toDegrees(theta));
}
if (theta > 1e-7) {
vAxis.cross(v1, v2);
// transform to C coordinates?
vAxis.inverseTransform(TGD);
} else {
theta = 0;
engage = false;
}
// maybe set engaged
if (setEngaged) {
if (engage) {
info[3].engaged = 1;
} else {
info[3].engaged = 0;
}
}
if (info[3].engaged != 0) {
vAxis.normalize();
info[3].distance = -theta;
info[3].wrenchC.set(0, 0, 0, vAxis.x, vAxis.y, vAxis.z);
info[3].dotWrenchC.setZero();
}
} else if (myRangeType == RPY_LIMIT) {
double roll, pitch, yaw;
double[] rpy = new double[3];
double[] rpyOrig = new double[3];
for (int i = 0; i < 3; i++) {
rpyOrig[i] = info[i + 3].coordinate;
}
RotationMatrix3d RDC = new RotationMatrix3d();
Vector3d wBA = new Vector3d();
RDC.transpose(TGD.R);
doGetRpy(rpy, RDC);
roll = rpy[0];
pitch = rpy[1];
yaw = rpy[2];
double cr = Math.cos(roll);
double sr = Math.sin(roll);
double cp = Math.cos(pitch);
double sp = Math.sin(pitch);
double denom = cp;
// the singularity at cp = 0
if (Math.abs(denom) < 0.0001) {
denom = (denom >= 0 ? 0.0001 : -0.0001);
}
double tp = sp / denom;
// Don't need to transform because vel is now in Frame C
// get angular velocity of B with respect to A in frame C
// if (!myComputeVelInFrameC) {
// wBA.transform(RDC, myVelBA.w);
// }
info[3].distance = 0;
info[4].distance = 0;
info[5].distance = 0;
double dotp = -sr * wBA.x + cr * wBA.y;
double doty = (cr * wBA.x + sr * wBA.y) / denom;
double dotr = wBA.z + sp * doty;
if (setEngaged) {
maybeSetEngaged(info[3], roll, myMinRoll, myMaxRoll);
maybeSetEngaged(info[4], pitch, myMinPitch, myMaxPitch);
maybeSetEngaged(info[5], yaw, myMinYaw, myMaxYaw);
}
if (info[3].engaged != 0) {
info[3].distance = getDistance(roll, myMinRoll, myMaxRoll);
info[3].wrenchC.set(0, 0, 0, sp * cr / denom, sp * sr / denom, 1);
info[3].dotWrenchC.f.setZero();
double tt = (1 + tp * tp);
info[3].dotWrenchC.m.set(-sr * tp * dotr + tt * cr * dotp, cr * tp * dotr + tt * sr * dotp, 0);
// checkDeriv ("roll", info[3], conR);
if (info[3].engaged == -1) {
info[3].wrenchC.negate();
info[3].dotWrenchC.negate();
}
}
if (info[4].engaged != 0) {
info[4].distance = getDistance(pitch, myMinPitch, myMaxPitch);
info[4].wrenchC.set(0, 0, 0, -sr, cr, 0);
info[4].dotWrenchC.f.setZero();
info[4].dotWrenchC.m.set(-cr * dotr, -sr * dotr, 0);
// checkDeriv ("pitch", info[4], conP);
if (info[4].engaged == -1) {
info[4].wrenchC.negate();
info[4].dotWrenchC.negate();
}
}
if (info[5].engaged != 0) {
info[5].distance = getDistance(yaw, myMinYaw, myMaxYaw);
info[5].wrenchC.set(0, 0, 0, cr / denom, sr / denom, 0);
info[5].dotWrenchC.f.setZero();
info[5].dotWrenchC.m.set((-sr * dotr + cr * tp * dotp) / denom, (cr * dotr + sr * tp * dotp) / denom, 0);
// checkDeriv ("yaw", info[5], conY);
if (info[5].engaged == -1) {
info[5].wrenchC.negate();
info[5].dotWrenchC.negate();
}
}
boolean bigshot = false;
for (int i = 3; i < 6; i++) {
if (info[i].engaged != 0) {
if (info[i].distance < -MAX_DISTANCE) {
bigshot = true;
break;
}
}
}
if (bigshot) {
System.out.println("Large jumps..");
System.out.printf("Angles: %f, %f, %f\n", Math.toDegrees(rpy[0]), Math.toDegrees(rpy[1]), Math.toDegrees(rpy[2]));
System.out.printf("Min : %f, %f, %f\n", Math.toDegrees(myMinRoll), Math.toDegrees(myMinPitch), Math.toDegrees(myMinYaw));
System.out.printf("Max : %f, %f, %f\n", Math.toDegrees(myMaxRoll), Math.toDegrees(myMaxPitch), Math.toDegrees(myMaxYaw));
System.out.printf("On : %d, %d, %d\n", info[3].engaged, info[4].engaged, info[5].engaged);
System.out.printf("Dist : %f, %f, %f\n", Math.toDegrees(info[3].distance), Math.toDegrees(info[4].distance), Math.toDegrees(info[5].distance));
}
} else if (myRangeType != 0) {
throw new InternalErrorException("Unimplemented range limits " + NumberFormat.formatHex(myRangeType));
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class Main method main.
/**
* the main entry point
*
* @param args command line arguments
*/
public static void main(String[] args) {
// some interfaces (like Matlab) may pass args in as null
if (args == null) {
args = new String[0];
}
ArgParser parser = new ArgParser("java artisynth.core.driver.Main", false);
parser.addOption("-help %v #prints help message", printHelp);
parser.addOption("-width %d #width (pixels)", viewerWidth);
parser.addOption("-height %d #height (pixels)", viewerHeight);
parser.addOption("-bgColor %fX3 #background color (3 rgb values, 0 to 1)", bgColor);
parser.addOption("-maxStep %f #maximum time for a single step (sec)", maxStep);
parser.addOption("-drawAxes %v #draw coordinate axes", drawAxes);
parser.addOption("-drawGrid %v #draw grid", drawGrid);
parser.addOption("-axisLength %f #coordinate axis length", axisLength);
parser.addOption("-play %v #play model immediately", play);
parser.addOption("-playFor %f #play model immediately for x seconds", playFor);
parser.addOption("-exitOnBreak %v #exit artisynth when playing stops", exitOnBreak);
parser.addOption("-demosFile %s #demo file (e.g. .demoModels)", demosFilename);
parser.addOption("-demosMenu %s #demo menu file (e.g. .demoMenu.xml)", demosMenuFilename);
parser.addOption("-historyFile %s #model history file (e.g. .history)", historyFilename);
parser.addOption("-scriptsFile %s #script file (e.g. .artisynthModels)", scriptsFilename);
parser.addOption("-mousePrefs %s #kees for pure mouse controls", mousePrefs);
parser.addOption("-ortho %v #use orthographic viewing", orthographic);
parser.addOption("-axialView %s{xy,xz} #initial view of x-y or x-z axes", axialView);
parser.addOption("-noTimeline %v{false} #do not start with a timeline", startWithTimeline);
parser.addOption("-showJythonConsole %v{true} #create jython console on startup", startWithJython);
parser.addOption("-largeTimeline %v{true} #start with vertically expanded timeline", largeTimeline);
parser.addOption("-timelineRight %v{true} #start with a timeline alligned to the right", timelineRight);
parser.addOption("-fps %f#frames per second", framesPerSecond);
parser.addOption("-fullscreen %v #full screen renderer", fullScreen);
// parser.addOption("-yup %v #initialize viewer with Y-axis up", yup);
parser.addOption("-timelineZoom %d #zoom level for timeline", zoom);
parser.addOption("-options %v #print options only", printOptions);
parser.addOption("-abortOnInvertedElems %v #abort on nonlinear element inversion", abortOnInvertedElems);
parser.addOption("-disableHybridSolves %v #disable hybrid linear solves", disableHybridSolves);
parser.addOption("-numSolverThreads %d #number of threads to use for linear solver", numSolverThreads);
parser.addOption("-posCorrection %s{Default,GlobalMass,GlobalStiffness} " + "#position correction mode", posCorrection);
parser.addOption("-noIncompressDamping %v #ignore incompress stiffness for damping", noIncompressDamping);
// parser.addOption ("-useOldTimeline %v #use old timeline", useOldTimeline);
parser.addOption("-useSignedDistanceCollider %v " + "#use SignedDistanceCollider where possible", useSignedDistanceCollider);
parser.addOption("-useAjlCollision" + "%v #use AJL collision detection", useAjlCollision);
parser.addOption("-useBodyVelsInSolve" + "%v #use body velocities for dynamic solves", useBodyVelsInSolve);
parser.addOption("-useArticulatedTransforms %v #enforce articulation " + "constraints with transformers", useArticulatedTransforms);
parser.addOption("-updateLibs %v #update libraries from ArtiSynth server", updateLibs);
parser.addOption("-flags %x #flag bits passed to the application", flags);
parser.addOption("-noGui %v #run ArtiSynth without the GUI", noGui);
parser.addOption("-openMatlabConnection %v " + "#open a MATLAB connection if possible", openMatlab);
parser.addOption("-GLVersion %d{2,3} " + "#version of openGL for graphics", glVersion);
parser.addOption("-useGLJPanel %v " + "#use GLJPanel for creating the openGL viewer", useGLJPanel);
parser.addOption("-useGLCanvas %v{false} " + "#use GLJCanvas for creating the openGL viewer", useGLJPanel);
parser.addOption("-logLevel %s", logLevel);
parser.addOption("-testSaveRestoreState %v #test save/restore state when running models", testSaveRestoreState);
parser.addOption("-movieFrameRate %f #frame rate to use when making movies", movieFrameRate);
parser.addOption("-movieMethod %s #method to use when making movies", movieMethod);
Locale.setDefault(Locale.CANADA);
URL initUrl = ArtisynthPath.findResource(".artisynthInit");
if (initUrl == null) {
// Removed warning message for now
// System.out.println (".artisynthInit not found");
} else {
InputStream is = null;
try {
is = initUrl.openStream();
} catch (Exception e) {
// do nothing if we can't open
System.out.println(".artisynthInit not found");
}
if (is != null) {
try {
args = ArgParser.prependArgs(new InputStreamReader(is), args);
} catch (Exception e) {
System.err.println("Error reading init file " + initUrl);
System.err.println(e.getMessage());
}
}
}
if (System.getProperty("file.separator").equals("\\")) {
// then we are running windows, so set noerasebackground to
// try and remove flicker bug
System.setProperty("sun.awt.noerasebackground", "true");
} else {
System.setProperty("awt.useSystemAAFontSettings", "on");
}
// Separate program arguments from model arguments introduced by -M
ArrayList<String> progArgs = new ArrayList<String>();
ArrayList<String> modelArgs = null;
ArrayList<String> scriptArgs = null;
ArrayList<String> taskManagerArgs = null;
for (String arg : args) {
if (modelArgs != null) {
modelArgs.add(arg);
} else {
if (arg.equals("-M")) {
modelArgs = new ArrayList<String>();
} else {
progArgs.add(arg);
}
}
}
// Match arguments one at a time so we can avoid exitOnError if we are
// running inside matlab
String[] pargs = progArgs.toArray(new String[0]);
int lastSwitch = -1;
int idx = 0;
while (idx < pargs.length) {
try {
int pidx = idx;
// check for list of arguments:
if ("-model".equals(pargs[pidx])) {
modelName.value = pargs[++idx];
modelArgs = new ArrayList<String>();
int nidx = maybeCollectArgs(pargs, ++idx, modelArgs);
if (nidx == idx) {
modelArgs = null;
}
idx = nidx;
} else if ("-script".equals(pargs[pidx])) {
scriptFile.value = pargs[++idx];
scriptArgs = new ArrayList<String>();
int nidx = maybeCollectArgs(pargs, ++idx, scriptArgs);
if (nidx == idx) {
scriptArgs = null;
}
idx = nidx;
} else if ("-taskManager".equals(pargs[pidx])) {
taskManagerClassName.value = pargs[++idx];
taskManagerArgs = new ArrayList<String>();
int nidx = maybeCollectArgs(pargs, ++idx, taskManagerArgs);
if (nidx == idx) {
taskManagerArgs = null;
}
idx = nidx;
} else {
idx = parser.matchArg(pargs, idx);
}
String unmatched;
if ((unmatched = parser.getUnmatchedArgument()) != null) {
boolean valid = false;
if (!valid) {
System.err.println("Unrecognized argument: " + unmatched + "\nUse -help for help information");
return;
}
} else {
lastSwitch = pidx;
}
} catch (Exception e) {
System.err.println("Error parsing options: " + e.getMessage());
return;
}
}
// parser.matchAllArgs (progArgs.toArray(new String[0]));
if (printOptions.value || printHelp.value) {
System.out.println(parser.getOptionsMessage(2));
System.out.println(" -model <string> [ <string>... ]\n" + " name of model to start, with optional arguments\n" + " delimited by square brackets\n" + " -script <string> [ <string>... ]\n" + " script to run immediately, with optional arguments\n" + " delimited by square brackets\n" + " -taskManager <className> [ <string>... ]\n" + " name of task manager class to run immediately, with\n" + " optional arguments delimited by square brackets\n");
return;
}
// Set system logger level
Logger.getSystemLogger().setLogLevel(LogLevel.find(logLevel.value));
MechSystemSolver.myDefaultHybridSolveP = !disableHybridSolves.value;
if (numSolverThreads.value > 0) {
PardisoSolver.setDefaultNumThreads(numSolverThreads.value);
}
FemModel3d.abortOnInvertedElems = abortOnInvertedElems.value;
// }
if (posCorrection.value.equals("GlobalMass")) {
MechSystemBase.setDefaultStabilization(PosStabilization.GlobalMass);
} else if (posCorrection.value.equals("GlobalStiffness")) {
MechSystemBase.setDefaultStabilization(PosStabilization.GlobalStiffness);
}
FemModel3d.noIncompressStiffnessDamping = noIncompressDamping.value;
if (useAjlCollision.value) {
CollisionManager.setDefaultColliderType(ColliderType.AJL_CONTOUR);
}
if (testSaveRestoreState.value) {
RootModel.testSaveAndRestoreState = true;
}
if (useGLJPanel.value == true) {
maspack.render.GL.GLViewer.useGLJPanel = true;
}
if (noGui.value == true) {
viewerWidth.value = -1;
}
GLVersion glv = (glVersion.value == 3 ? GLVersion.GL3 : GLVersion.GL2);
Main m = new Main(PROJECT_NAME, viewerWidth.value, viewerHeight.value, glv);
m.setArticulatedTransformsEnabled(useArticulatedTransforms.value);
if (axialView.value.equals("xy")) {
m.setDefaultViewOrientation(AxisAngle.IDENTITY);
} else if (axialView.value.equals("xz")) {
m.setDefaultViewOrientation(AxisAngle.ROT_X_90);
} else {
throw new InternalErrorException("Unknown axial view: " + axialView.value);
}
if (m.myFrame != null) {
m.myViewer.setBackgroundColor(bgColor[0], bgColor[1], bgColor[2]);
// XXX this should be done in the Main constructor, but needs
// to be done here instead because of sizing effects
m.myMenuBarHandler.initToolbar();
if (movieMethod.value != null) {
MovieMaker movieMaker = m.getMovieMaker();
try {
movieMaker.setMethod(movieMethod.value);
} catch (Exception e) {
System.out.println("Warning: unknown movie making method " + movieMethod.value);
}
}
if (movieFrameRate.value != -1) {
MovieMaker movieMaker = m.getMovieMaker();
try {
movieMaker.setFrameRate(movieFrameRate.value);
} catch (Exception e) {
System.out.println("Warning: illegal movie frame rate " + movieFrameRate.value);
}
}
}
if (mousePrefs.value != null && m.myViewer != null) {
m.setMouseBindings(mousePrefs.value);
}
m.setFlags(flags.value);
if (useBodyVelsInSolve.value) {
Frame.dynamicVelInWorldCoords = false;
}
m.start(startWithTimeline.value, timelineRight.value, largeTimeline.value);
// because setting it earlier can cause incorrect results
if (m.myFrame != null) {
m.setViewerSize(viewerWidth.value, viewerHeight.value);
}
if (System.getProperty("os.name").contains("Windows")) {
// XXX see function docs
fixPardisoThreadCountHack();
}
m.verifyNativeLibraries(updateLibs.value);
// the whole frame to be visible
if (m.myFrame != null && orthographic.value) {
m.getViewer().setOrthographicView(true);
}
// XXX store model arguments for future use?
if (modelArgs != null) {
m.myModelArgs = modelArgs.toArray(new String[modelArgs.size()]);
}
if (modelName.value != null) {
// load the specified model. See first if the name corresponds to a file
File file = new File(modelName.value);
if (file.exists() && file.canRead()) {
try {
m.loadModelFile(file);
} catch (IOException e) {
System.out.println("Error reading or loading model file " + modelName.value);
e.printStackTrace();
m.setRootModel(new RootModel(), null, null);
}
} else // otherwise, try to determine the model from the class name or alias
{
String className = m.getDemoClassName(modelName.value);
if (className == null) {
System.out.println("No class associated with model name " + modelName.value);
m.setRootModel(new RootModel(), null, null);
} else {
String name = modelName.value;
if (name.indexOf('.') != -1) {
name = name.substring(name.lastIndexOf('.') + 1);
if (name.length() == 0) {
name = "Unknown";
}
}
// load the model
ModelInfo mi = new ModelInfo(className, name, createArgArray(modelArgs));
m.loadModel(mi);
}
}
} else {
m.setRootModel(new RootModel(), null, null);
}
if (exitOnBreak.value) {
m.myScheduler.addListener(new QuitOnBreakListener(m));
}
if (playFor.value > 0) {
m.play(playFor.value);
} else if (play.value) {
m.play();
}
if (scriptFile.value != null && taskManagerClassName.value != null) {
System.out.println("Cannot specify both a script (option '-script') and a task manager (option \n" + "'-taskManager' at the same time");
System.exit(1);
} else if (scriptFile.value != null) {
m.runScriptFile(scriptFile.value, scriptArgs);
} else if (taskManagerClassName.value != null) {
m.runTaskManager(taskManagerClassName.value, taskManagerArgs);
}
if (m.myJythonConsole != null && m.myJythonFrame == null) {
m.myJythonConsole.interact();
}
if (openMatlab.value) {
m.openMatlabConnection();
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class MenuBarHandler method actionPerformed.
/**
* action performed to process all the menu and button actions in this class
*/
public void actionPerformed(ActionEvent event) {
String cmd = event.getActionCommand();
// Scripts menu
if (isScriptMenuItem(event.getSource())) {
String scriptName = myMain.getScriptName(cmd);
runScript(scriptName);
} else if (cmd.equals("load script from file")) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setCurrentDirectory(ArtisynthPath.getWorkingDir());
FileFilter jythonFilter = new GenericFileFilter(new String[] { "py", "jy" }, "Jython files");
fileChooser.addChoosableFileFilter(jythonFilter);
fileChooser.setFileFilter(jythonFilter);
int result = fileChooser.showOpenDialog(myFrame);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooser.getSelectedFile();
runScript(selectedFile.getAbsolutePath());
}
} else //
if (myMain.isDemoClassName(cmd)) {
ModelInfo mi = new ModelInfo(myMain.getDemoClassName(cmd), cmd, null);
doLoadModelSafely(mi);
} else //
if (cmd.equals("Clear model")) {
doClearModel();
} else if (cmd.equals("New blank MechModel")) {
doBlankMechmodel();
} else if (cmd.equals("Save model")) {
doSaveModel();
} else if (cmd.equals("Save model as ...")) {
doSaveModelAs();
} else if (cmd.equals("Reload model")) {
doReloadModel();
} else if (cmd.equals("Load model ...")) {
doLoadModel();
} else if (cmd.equals("Load from class ...")) {
doLoadFromClass();
} else if (cmd.equals("Switch workspace ...")) {
doSwitchWorkspace();
} else if (cmd.equals("Open MATLAB connection")) {
doOpenMatlab();
} else if (cmd.equals("Close MATLAB connection")) {
doCloseMatlab();
} else if (cmd.equals("Load probes ...")) {
doLoadProbes();
} else if (cmd.equals("Save probes")) {
doSaveProbes();
} else if (cmd.equals("Save probes as ...")) {
doSaveProbesAs();
} else if (cmd.equals("Load probes from ...")) {
newLoadProbesFrom();
} else if (cmd.equals("Save probes new")) {
newSaveProbes();
} else if (cmd.equals("Save probes in ...")) {
newSaveProbesIn();
} else if (cmd.equals("Save viewer image ...")) {
saveViewerImage();
} else if (cmd.equals("Quit")) {
myMain.quit();
} else //
if (cmd.equals("Add input probe")) {
doAddInputProbe();
} else if (cmd.equals("Add output probe")) {
doAddOutputProbe();
} else if (cmd.equals("Add control panel")) {
doAddControlPanel();
} else if (cmd.equals("Load control panel")) {
doLoadControlPanel();
} else if (cmd.equals("Print selection")) {
SelectionManager sm = myMain.getSelectionManager();
for (ModelComponent c : sm.getCurrentSelection()) {
System.out.println(ComponentUtils.getPathName(c));
}
} else if (cmd.equals("Undo")) {
doUndoCommand();
} else //
if (cmd.equals("Background color")) {
setBackgroundColor();
} else if (cmd.equals("Selection color")) {
setSelectionColor();
} else if (cmd.equals("Enable selection highlighting")) {
setSelectionColorEnabled(true);
} else if (cmd.equals("Disable selection highlighting")) {
setSelectionColorEnabled(false);
} else if (cmd.equals("Visual display rate")) {
setVisualDisplayRate();
} else if (cmd.equals("Real-time scaling")) {
setRealTimeScaling();
} else if (cmd.equals("Mouse Preferences ...")) {
openMouseSettingsDialog();
} else if (cmd.equals("Init draggers in world coords")) {
myMain.setInitDraggersInWorldCoords(true);
} else if (cmd.equals("Init draggers in local coords")) {
myMain.setInitDraggersInWorldCoords(false);
} else if (cmd.equals("Enable articulated transforms")) {
myMain.setArticulatedTransformsEnabled(true);
} else if (cmd.equals("Disable articulated transforms")) {
myMain.setArticulatedTransformsEnabled(false);
} else // }
if (cmd.equals("PullController properties ...")) {
showPullControllerPropertyDialog();
} else if (cmd.equals("PullController render props ...")) {
showPullControllerRenderPropsDialog();
} else //
if (cmd.equals("Center view on selection")) {
myMain.centerViewOnSelection();
} else if (cmd.equals("Hide timeline")) {
myMain.setTimelineVisible(false);
isTimelineVisible = false;
} else if (cmd.equals("Show timeline")) {
myMain.setTimelineVisible(true);
isTimelineVisible = true;
} else if (cmd.equals("Reset view")) {
GLViewer v = myMain.getViewer();
v.setAxialView(v.getAxialView());
v.autoFit();
} else if (cmd.equals("Perspective view")) {
myMain.getViewer().setOrthographicView(false);
} else if (cmd.equals("Orthographic view")) {
myMain.getViewer().setOrthographicView(true);
} else if (cmd.equals("Hide Jython console")) {
setJythonConsoleVisible(false);
} else if (cmd.equals("Show Jython console")) {
setJythonConsoleVisible(true);
} else if (cmd.equals("Show Inverse panel")) {
myMain.getInverseManager().showInversePanel(myMain.getRootModel(), InverseManager.findInverseController());
} else if (cmd.equals("Hide Inverse panel")) {
myMain.getInverseManager().hideInversePanel();
} else if (cmd.equals("Show movie panel")) {
myFrame.getMain().getViewer().getCanvas().display();
myMain.getMovieMaker().showDialog(myFrame);
} else if (cmd.equals("Hide movie panel")) {
// TODO: this isn't implemented yet because we need to set
// this up as an action
myMain.getMovieMaker().closeDialog();
} else if (cmd.equals("Show empty components in navpanel")) {
myFrame.getNavPanel().setHideEmptyComponents(false);
} else if (cmd.equals("Hide empty components in navpanel")) {
myFrame.getNavPanel().setHideEmptyComponents(true);
} else if (cmd.equals("New viewer")) {
myMain.createViewerFrame();
} else if (cmd.equals("Clear traces")) {
myMain.getRootModel().clearTraces();
} else if (cmd.equals("Disable all tracing")) {
myMain.getRootModel().disableAllTracing();
} else if (cmd.equals("Remove traces")) {
RemoveComponentsCommand rmCmd = new RemoveComponentsCommand("remove traces", myMain.getRootModel().getTracingProbes());
myMain.getUndoManager().saveStateAndExecute(rmCmd);
myMain.rerender();
} else if (cmd.equals("Set traces visible")) {
myMain.getRootModel().setTracingProbesVisible(true);
myMain.rerender();
} else if (cmd.equals("Set traces invisible")) {
myMain.getRootModel().setTracingProbesVisible(false);
myMain.rerender();
} else if (cmd.equals("Hide viewer toolbar")) {
isToolbarVisible = false;
detachViewerToolbar(toolbarPanel);
} else if (cmd.equals("Show viewer toolbar")) {
isToolbarVisible = true;
attachViewerToolbar(toolbarPanel);
} else if (cmd.equals("Merge control panels")) {
myMain.getRootModel().mergeAllControlPanels(true);
} else if (cmd.equals("Separate control panels")) {
myMain.getRootModel().mergeAllControlPanels(false);
} else if (cmd.equals("Show progress")) {
spawnProgressBar();
} else //
if (cmd.equals("About ArtiSynth")) {
myFrame.displayAboutArtisynth();
} else if (cmd.equals("About the current model")) {
myFrame.displayAboutModel(myMain.getRootModel());
} else if (cmd.equals("Keybindings")) {
myFrame.displayKeybindings();
} else //
if (cmd.equals("Hide NavBar")) {
myFrame.getNavPanel().setStatus(!myFrame.getNavPanel().getStatus());
myFrame.refreshSplitPane();
navBarButton.setToolTipText("Show Navbar");
navBarButton.setActionCommand("Show Navbar");
} else if (cmd.equals("Show Navbar")) {
myFrame.getNavPanel().setStatus(!myFrame.getNavPanel().getStatus());
myFrame.refreshSplitPane();
navBarButton.setToolTipText("Hide NavBar");
navBarButton.setActionCommand("Hide NavBar");
} else if (cmd.equals("Re-render")) {
myMain.rerender();
} else if (cmd.equals("Reset")) {
myMain.getScheduler().reset();
} else if (cmd.equals("Rewind")) {
myMain.getScheduler().rewind();
} else if (cmd.equals("Play")) {
myMain.getScheduler().play();
} else if (cmd.equals("Pause")) {
myMain.getScheduler().pause();
} else if (cmd.equals("Single step")) {
myMain.getScheduler().step();
} else if (cmd.equals("Fast forward")) {
myMain.getScheduler().fastForward();
} else if (cmd.equals("cancel")) {
return;
} else {
throw new InternalErrorException("Unimplemented command: " + cmd);
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class FemElement3d method createIntegrationPoints.
protected IntegrationPoint3d[] createIntegrationPoints() {
int numi = numIntegrationPoints();
IntegrationPoint3d[] pnts = new IntegrationPoint3d[numi];
double[] cdata = getIntegrationCoords();
if (cdata.length != 4 * numi) {
throw new InternalErrorException("Coordinate data length is " + cdata.length + ", expecting " + 4 * numi);
}
for (int k = 0; k < numi; k++) {
pnts[k] = IntegrationPoint3d.create(this, cdata[k * 4], cdata[k * 4 + 1], cdata[k * 4 + 2], cdata[k * 4 + 3]);
pnts[k].setNumber(k);
}
return pnts;
// Vector3d coords = new Vector3d();
// Vector3d dNds = new Vector3d();
// VectorNd shapeVals = new VectorNd(numNodes());
// VectorNd pressureShapeVals = new VectorNd(numPressureVals());
// for (int k=0; k<numi; k++) {
// coords.set (coordData[k*4], coordData[k*4+1], coordData[k*4+2]);
// pnts[k] = new IntegrationPoint3d (
// numNodes(), numPressureVals(),
// coords.x, coords.y, coords.z, coordData[k*4+3]);
// for (int i=0; i<numNodes(); i++) {
// shapeVals.set (i, getN (i, coords));
// getdNds (dNds, i, coords);
// pnts[k].setShapeGrad (i, dNds);
// }
// for (int i=0; i<numPressureVals(); i++) {
// pressureShapeVals.set (i, getH (i, coords));
// }
// pnts[k].setShapeVals (shapeVals);
// pnts[k].setPressureShapeVals (pressureShapeVals);
// }
// return pnts;
}
Aggregations