Search in sources :

Example 6 with DistanceGrid

use of maspack.geometry.DistanceGrid in project artisynth_core by artisynth.

the class RigidBody method getDistanceGrid.

/**
 * Returns a signed distance grid that can be used with a
 * SignedDistanceCollider, or <code>null</code> if a grid is not available
 * (i.e., if {@link #hasDistanceGrid} returns <code>false</code>).
 * The number of divisons in the grid is controlled explicitly by the
 * property <code>distanceGridRes</code>, or, that is 0, by the property
 * <code>distanceGridMaxRes</code>. If both properties are 0, no grid is
 * available and <code>null</code> will be returned.
 *
 * @return signed distance grid, or <code>null</code> if a grid is
 * not available this RigidBody
 * @see #getDistanceGridMaxRes
 * @see #getDistanceGridRes
 */
public DistanceGrid getDistanceGrid() {
    if (mySDGrid == null || !mySDGridValid) {
        int maxRes = myDistanceGridMaxRes;
        if (!myDistanceGridRes.equals(Vector3i.ZERO) || maxRes > 0) {
            if (!myDistanceGridRes.equals(Vector3i.ZERO)) {
                mySDGrid = new DistanceGrid(myDistanceGridRes);
                maxRes = 0;
            } else {
                // resolution will be recomputed in computeFromFeatures
                mySDGrid = new DistanceGrid(new Vector3i(1, 1, 1));
            }
            mySDGrid.setDrawEdges(true);
            List<Face> faces = getMesh().getFaces();
            if (myDistanceGridOBB) {
                mySDGrid.computeFromFeaturesOBB(faces, myGridMargin, maxRes, /*signed=*/
                true);
            } else {
                mySDGrid.computeFromFeatures(faces, myGridMargin, /*TGL=*/
                null, maxRes, /*signed=*/
                true);
            }
            mySDGrid.setLocalToWorld(getPose());
        } else {
            mySDGrid = null;
        }
        // mySDGrid.smooth (0.33, -0.34, 2);
        mySDSurface = null;
        mySDGridValid = true;
    }
    return mySDGrid;
}
Also used : DistanceGrid(maspack.geometry.DistanceGrid) Vector3i(maspack.matrix.Vector3i) Face(maspack.geometry.Face)

Example 7 with DistanceGrid

use of maspack.geometry.DistanceGrid in project artisynth_core by artisynth.

the class MeshThicken method applyRemesh.

public void applyRemesh(PolygonalMesh mesh, Vector3i res) {
    DistanceGrid grid = new DistanceGrid(res);
    grid.computeFromFeatures(mesh.getFaces(), 0.1, null, 0, /*signed=*/
    true);
    grid.smooth(0.33, -0.2, 30);
    mesh = grid.createQuadDistanceSurface(0, 5);
    setMesh(mesh);
}
Also used : DistanceGrid(maspack.geometry.DistanceGrid)

Example 8 with DistanceGrid

use of maspack.geometry.DistanceGrid in project artisynth_core by artisynth.

the class RigidBody method render.

public void render(Renderer renderer, int flags) {
    if (myAxisLength > 0) {
        int lineWidth = myRenderProps.getLineWidth();
        renderer.drawAxes(myRenderFrame, myAxisLength, lineWidth, isSelected());
    }
    if (isSelected()) {
        flags |= Renderer.HIGHLIGHT;
    }
    PolygonalMesh surf = null;
    if (myRenderDistanceSurface != DistanceSurfaceRendering.NONE && (surf = mySDRenderSurface) != null) {
        surf.render(renderer, myRenderProps, flags);
    } else {
        myMeshInfo.render(renderer, myRenderProps, flags);
    }
    DistanceGrid grid = null;
    if (myRenderDistanceGrid && (grid = mySDRenderGrid) != null) {
        grid.render(renderer, myRenderProps, flags);
    }
}
Also used : DistanceGrid(maspack.geometry.DistanceGrid) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 9 with DistanceGrid

use of maspack.geometry.DistanceGrid in project artisynth_core by artisynth.

the class RigidBody method setDistanceGridRenderRanges.

/**
 * {@inheritDoc}
 */
public void setDistanceGridRenderRanges(String ranges) {
    if (ranges.matches("\\s*\\*\\s*") || ranges.matches("\\s*\\*\\s+\\*\\s+\\*\\s*")) {
        myDistanceGridRenderRanges = "* * *";
        if (mySDGrid != null) {
            mySDGrid.setRenderRanges(ranges);
        }
    } else {
        DistanceGrid grid = getDistanceGrid();
        StringHolder errMsg = new StringHolder();
        if (grid.parseRenderRanges(ranges, errMsg) == null) {
            throw new IllegalArgumentException("Illegal range spec: " + errMsg.value);
        } else {
            grid.setRenderRanges(ranges);
            myDistanceGridRenderRanges = grid.getRenderRanges();
        }
    }
}
Also used : StringHolder(maspack.util.StringHolder) DistanceGrid(maspack.geometry.DistanceGrid)

Example 10 with DistanceGrid

use of maspack.geometry.DistanceGrid in project artisynth_core by artisynth.

the class RigidBody method prerender.

public void prerender(RenderList list) {
    myRenderFrame.set(myState.XFrameToWorld);
    // list.addIfVisible (myMarkers);
    PolygonalMesh surf = null;
    if (myRenderDistanceSurface != DistanceSurfaceRendering.NONE && (surf = getDistanceSurface()) != null) {
        surf.prerender(myRenderProps);
    } else {
        if (myRenderProps == null) {
            throw new InternalErrorException("RigidBody has null RenderProps");
        }
        myMeshInfo.prerender(myRenderProps);
    }
    mySDRenderSurface = surf;
    DistanceGrid grid = null;
    if (myRenderDistanceGrid && (grid = getDistanceGrid()) != null) {
        grid.prerender(myRenderProps);
    }
    mySDRenderGrid = grid;
}
Also used : DistanceGrid(maspack.geometry.DistanceGrid) InternalErrorException(maspack.util.InternalErrorException) PolygonalMesh(maspack.geometry.PolygonalMesh)

Aggregations

DistanceGrid (maspack.geometry.DistanceGrid)13 PolygonalMesh (maspack.geometry.PolygonalMesh)6 Face (maspack.geometry.Face)4 Point3d (maspack.matrix.Point3d)2 Vector3d (maspack.matrix.Vector3d)2 Vector3i (maspack.matrix.Vector3i)2 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)1 FixedMeshBody (artisynth.core.mechmodels.FixedMeshBody)1 OBB (maspack.geometry.OBB)1 Vertex3d (maspack.geometry.Vertex3d)1 RigidTransform3d (maspack.matrix.RigidTransform3d)1 FastRadialMarcher (maspack.util.FastRadialMarcher)1 IndexedBinaryHeap (maspack.util.IndexedBinaryHeap)1 InternalErrorException (maspack.util.InternalErrorException)1 Point3dGridUtility (maspack.util.Point3dGridUtility)1 StringHolder (maspack.util.StringHolder)1