use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.
the class FemModel3dAgent method restoreDefaultValues.
private void restoreDefaultValues() {
maskAllValueChangeListeners(true);
lastScale = 1.0;
scaleField.setValue(lastScale);
positionField.setVoidValueEnabled(true);
positionField.setValue(Property.VoidValue);
positionField.setVoidValueEnabled(false);
orientationField.setValue(new AxisAngle());
GLViewer viewer = myMain.getMain().getViewer();
double width = viewer.distancePerPixel(viewer.getCenter()) * viewer.getScreenWidth() / 6;
// Grid fields
double gridWidth = DEFAULT_GRID_DIM.x;
if (width > gridWidth) {
for (int i = -1; width > gridWidth; i++) {
gridWidth *= (i % 3 == 0) ? 2.5 : 2.0;
}
} else {
for (int i = -1; width < gridWidth; i++) {
gridWidth /= (i % 3 == 0) ? 2.5 : 2.0;
}
}
gridDimField.setValue(new Vector3d(gridWidth, gridWidth, gridWidth));
gridDivField.setValue(DEFAULT_GRID_DIV);
// Tube fields
double tubeScale = 1;
if (width > tubeScale * DEFAULT_TUBE_DIM.z) {
for (int i = -1; width > tubeScale * DEFAULT_TUBE_DIM.z; i++) {
tubeScale *= (i % 3 == 0) ? 2.5 : 2.0;
}
} else {
for (int i = -1; width < tubeScale * DEFAULT_TUBE_DIM.z; i++) {
tubeScale /= (i % 3 == 0) ? 2.5 : 2.0;
}
}
tubeScale /= 2.0;
tubeDimField.setValue(new Vector3d(DEFAULT_TUBE_DIM.x * tubeScale, DEFAULT_TUBE_DIM.y * tubeScale, DEFAULT_TUBE_DIM.z * tubeScale));
tubeDivField.setValue(DEFAULT_TUBE_DIV);
// Torus fields
double torusScale = 1;
if (width > torusScale * (DEFAULT_TORUS_DIM.x + DEFAULT_TORUS_DIM.z)) {
for (int i = -1; width > torusScale * (DEFAULT_TORUS_DIM.x + DEFAULT_TORUS_DIM.z); i++) {
torusScale *= (i % 3 == 0) ? 2.5 : 2.0;
}
} else {
for (int i = -1; width < torusScale * (DEFAULT_TORUS_DIM.x + DEFAULT_TORUS_DIM.z); i++) {
torusScale /= (i % 3 == 0) ? 2.5 : 2.0;
}
}
torusScale /= 2.0;
torusDimField.setValue(new Vector3d(DEFAULT_TORUS_DIM.x * torusScale, DEFAULT_TORUS_DIM.y * torusScale, DEFAULT_TORUS_DIM.z * torusScale));
torusDivField.setValue(DEFAULT_TORUS_DIV);
// Sphere field
sphereNodesField.setValue(SPHERE_NODE_OPTIONS[0]);
// Extrusion fields
extrusDepthField.setValue(DEFAULT_EXTRUSION_DEPTH);
extrusLayersField.setValue(DEFAULT_EXTRUSION_LAYERS);
extrusFileField.setValue(null);
// Ansys fields
ansysNodeFileField.setValue(null);
ansysElemFileField.setValue(null);
// Tetgen fields
tetgenNodeFileField.setValue(null);
tetgenEleFileField.setValue(null);
// UCD field
ucdMeshFileField.setValue(null);
// Surface mesh field
surfaceMeshFileField.setValue(null);
maskAllValueChangeListeners(false);
}
use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.
the class FemModel3dAgent method updateScale.
private void updateScale() {
resetScaling();
Vector3d minBound = new Vector3d();
Vector3d maxBound = new Vector3d();
fem.getSurfaceMesh().getWorldBounds(minBound, maxBound);
double meshWidth = maxBound.x - minBound.x;
double meshHeight = maxBound.y - minBound.y;
GLViewer viewer = myMain.getMain().getViewer();
double distancePerPixel = viewer.distancePerPixel(viewer.getCenter());
double width = distancePerPixel * viewer.getScreenWidth() / 4;
double height = distancePerPixel * viewer.getScreenHeight() / 4;
double meshScale = 1;
if (meshScale * meshWidth > width || meshScale * meshHeight > height) {
for (int i = -1; width < meshScale * meshWidth && height < meshScale * meshHeight; i++) {
meshScale /= (i % 3 == 0) ? 2.5 : 2.0;
}
} else {
for (int i = -1; width > meshScale * meshWidth || height > meshScale * meshHeight; i++) {
double increment = (i % 3 == 0) ? 2.5 : 2.0;
if (width <= meshScale * meshWidth * increment || height <= meshScale * meshHeight * increment) {
break;
}
meshScale *= increment;
}
}
scaleField.setValue(meshScale);
}
use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.
the class FemModel3dEditor method addNewSurfaceMesh.
private void addNewSurfaceMesh(FemModel3d model) {
GLViewer v = myMain.getViewer();
ElementFilter efilter = new ClippedElementFilter(v.getClipPlanes());
FemMeshComp mcomp = FemMeshComp.createSurface(null, model, efilter);
mcomp.setSurfaceRendering(SurfaceRender.Shaded);
model.addMeshComp(mcomp);
}
use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.
the class AddComponentAgent method getDefaultLineRadius.
/**
* Returns a default value for the cylinder radius render property.
*/
protected double getDefaultLineRadius() {
GLViewer viewer = myViewerManager.getViewer(0);
double r = viewer.estimateRadiusAndCenter(null);
// return 2*viewer.distancePerPixel (viewer.getCenter());
return 0.01 * r;
}
use of maspack.render.GL.GLViewer in project artisynth_core by artisynth.
the class AddComponentAgent method getDefaultAxisLength.
/**
* Returns a default value for the length of an axis.
*/
protected double getDefaultAxisLength() {
GLViewer viewer = myViewerManager.getViewer(0);
double r = viewer.estimateRadiusAndCenter(null);
// viewer.getWidth()/5;
return 0.05 * r;
}
Aggregations