Search in sources :

Example 11 with GLViewer

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);
}
Also used : AxisAngle(maspack.matrix.AxisAngle) GLViewer(maspack.render.GL.GLViewer) Vector3d(maspack.matrix.Vector3d)

Example 12 with GLViewer

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);
}
Also used : GLViewer(maspack.render.GL.GLViewer) Vector3d(maspack.matrix.Vector3d)

Example 13 with GLViewer

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);
}
Also used : GLViewer(maspack.render.GL.GLViewer) FemMeshComp(artisynth.core.femmodels.FemMeshComp) ElementFilter(artisynth.core.femmodels.FemModel.ElementFilter)

Example 14 with GLViewer

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;
}
Also used : GLViewer(maspack.render.GL.GLViewer)

Example 15 with GLViewer

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;
}
Also used : GLViewer(maspack.render.GL.GLViewer)

Aggregations

GLViewer (maspack.render.GL.GLViewer)36 Vector3d (maspack.matrix.Vector3d)9 File (java.io.File)5 RigidTransform3d (maspack.matrix.RigidTransform3d)4 AxisAngle (maspack.matrix.AxisAngle)3 Point3d (maspack.matrix.Point3d)3 GLViewerFrame (maspack.render.GL.GLViewerFrame)3 RigidBody (artisynth.core.mechmodels.RigidBody)2 ExtensionFileFilter (artisynth.core.util.ExtensionFileFilter)2 JFileChooser (javax.swing.JFileChooser)2 FileFilter (javax.swing.filechooser.FileFilter)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 RotationMatrix3d (maspack.matrix.RotationMatrix3d)2 GLGridPlane (maspack.render.GL.GLGridPlane)2 RenderProps (maspack.render.RenderProps)2 Transrotator3d (maspack.render.Transrotator3d)2 GenericFileFilter (maspack.util.GenericFileFilter)2 InternalErrorException (maspack.util.InternalErrorException)2 ArgParser (argparser.ArgParser)1 IntHolder (argparser.IntHolder)1