use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class BeamBody method getShape.
public void getShape(Vector3d shp, int i, Vector3d pos0) {
double xi = 2 * pos0.x / myLen;
shp.setZero();
switch(i) {
case 0:
shp.y = 0.25 * sqr(1 - xi) * (2 + xi) - 0.5;
return;
case 1:
shp.y = 0.125 * myLen * sqr(1 - xi) * (1 + xi);
return;
case 2:
shp.y = -0.125 * myLen * sqr(1 + xi) * (1 - xi);
return;
case 3:
shp.z = 0.25 * sqr(1 - xi) * (2 + xi) - 0.5;
return;
case 4:
shp.z = 0.125 * myLen * sqr(1 - xi) * (1 + xi);
return;
case 5:
shp.z = -0.125 * myLen * sqr(1 + xi) * (1 - xi);
return;
default:
{
throw new InternalErrorException("shape function index " + i + " exceeds " + (numElasticCoords() - 1));
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class BeamBody method getDShape.
public void getDShape(Matrix3d Dshp, int i, Vector3d pos0) {
double xi = 2 * pos0.x / myLen;
Dshp.setZero();
switch(i) {
case 0:
Dshp.m10 = 1.5 * (xi * xi - 1) / myLen;
return;
case 1:
Dshp.m10 = 0.25 * (3 * xi * xi - 2 * xi - 1);
return;
case 2:
Dshp.m10 = 0.25 * (3 * xi * xi + 2 * xi - 1);
return;
case 3:
Dshp.m20 = 1.5 * (xi * xi - 1) / myLen;
return;
case 4:
Dshp.m20 = 0.25 * (3 * xi * xi - 2 * xi - 1);
return;
case 5:
Dshp.m20 = 0.25 * (3 * xi * xi + 2 * xi - 1);
return;
default:
{
throw new InternalErrorException("shape function index " + i + " exceeds " + (numElasticCoords() - 1));
}
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class SimpleCollide method createAndAddControlPanel.
ControlPanel createAndAddControlPanel(String name, ModelComponent comp) {
ControlPanel panel = new ControlPanel(name);
if (comp instanceof FemModel3d) {
panel.addWidget(comp, "material");
panel.addWidget(comp, "density");
panel.addWidget(comp, "incompressible");
panel.addWidget(comp, "volume");
} else if (comp instanceof RigidBody) {
panel.addWidget(comp, "position");
panel.addWidget(comp, "orientation");
} else {
throw new InternalErrorException("No control panel code for components of type " + comp.getClass());
}
ControlPanel existingPanel = getControlPanels().get(name);
if (existingPanel != null) {
int idx = getControlPanels().indexOf(existingPanel);
removeControlPanel(existingPanel);
existingPanel.dispose();
addControlPanel(panel, idx);
Main.getMain().arrangeControlPanels(this);
} else {
addControlPanel(panel);
}
return panel;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class SimpleCollide method setTopObject.
private void setTopObject(Collidable comp, ObjectType type) {
Renderable rcomp = (Renderable) comp;
((TransformableGeometry) comp).transformGeometry(new RigidTransform3d(0, /*-0.3*/
0.0, mySeparation));
((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myTopScale));
RenderProps.setFaceColor(rcomp, Color.red);
switch(type) {
case FemEllipsoid:
case FemSphere:
case FemCube:
{
RenderProps.setPointColor(rcomp, Color.gray);
RenderProps.setAlpha(rcomp, 0.3);
RenderProps.setDrawEdges(rcomp, true);
RenderProps.setVisible(((FemModel3d) rcomp).getElements(), false);
break;
}
case House:
{
((TransformableGeometry) comp).transformGeometry(new RigidTransform3d(0, 0, 2 * mySeparation, 1, 1, 0, Math.toRadians(170)));
break;
}
case Box:
case Molar:
case Bin:
case Paw:
{
break;
}
default:
{
throw new InternalErrorException("Unimplemented type " + type);
}
}
myTopObject = comp;
myTopType = type;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class DicomElement method parseTime.
public static DicomDateTime parseTime(String in) {
// HHMMSS.FFFFFF or HH:MM:SS.FFFFFF
String dtStr = in;
// remove colons
dtStr = dtStr.replace(":", "");
// fraction
int micros = 0;
int idPeriod = dtStr.indexOf('.');
if (idPeriod >= 0) {
String strDecimal = dtStr.substring(idPeriod);
dtStr = dtStr.substring(0, idPeriod);
micros = Math.round(Float.parseFloat(strDecimal) * 1000000);
if (dtStr.length() < 6) {
if (!timeWarning) {
System.err.println("Dicom Time warning: non-stardard time format '" + in + "'");
timeWarning = true;
}
dtStr = "000000".substring(0, 6 - dtStr.length()) + dtStr;
}
}
// HHMMSS
int hour = 0;
int min = 0;
int sec = 0;
String substr;
switch(dtStr.length()) {
case 5:
case 6:
{
int start = dtStr.length() - 2;
substr = dtStr.substring(start);
sec = Integer.parseInt(substr);
dtStr = dtStr.substring(0, start);
}
case 3:
case 4:
{
int start = dtStr.length() - 2;
substr = dtStr.substring(start);
min = Integer.parseInt(substr);
dtStr = dtStr.substring(0, start);
}
case 1:
case 2:
{
hour = Integer.parseInt(dtStr);
}
case 0:
{
break;
}
default:
{
throw new InternalErrorException("Date/Time string in invalid format (" + dtStr + ")");
}
}
DicomDateTime dt = new DicomDateTime(1970, 1, 1, hour, min, sec, micros);
return dt;
}
Aggregations