Search in sources :

Example 6 with MeshBase

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

the class FemModel3d method getSurfaceMeshComp.

// Returns the FemMeshComp component for the surface mesh. If appropriate, the
// surface is generated on demand
public FemMeshComp getSurfaceMeshComp() {
    if (myMeshList.size() < 1) {
        throw new IllegalArgumentException("Default surface mesh component has been removed");
    }
    // if auto, take first.  If not, take first one marked as a surface mesh;
    if (!mySurfaceMeshValid) {
        if (myAutoGenerateSurface) {
            FemMeshComp meshc = doGetSurfaceMeshComp();
            createDefaultSurfaceMesh(meshc);
            mySurfaceMeshValid = true;
            myInternalSurfaceMeshComp = null;
            // grab newly created mesh
            MeshBase mesh = meshc.getMesh();
            // paranoid: call in case mesh is rendered directly before
            // prerender()
            PolygonalMesh smesh = (PolygonalMesh) mesh;
            smesh.saveRenderInfo(myRenderProps);
            return meshc;
        } else {
            return null;
        }
    } else {
        return myMeshList.get(0);
    }
}
Also used : MeshBase(maspack.geometry.MeshBase) PolygonalMesh(maspack.geometry.PolygonalMesh)

Example 7 with MeshBase

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

the class SkinMeshBody method resetBasePositions.

/**
 * Resets the base positions for all attachments in this SkinMeshBody
 * to the current vertex position.
 */
protected void resetBasePositions() {
    MeshBase mesh = getMesh();
    for (int i = 0; i < myVertexAttachments.size(); i++) {
        PointSkinAttachment a = myVertexAttachments.get(i);
        Vertex3d vtx = mesh.getVertices().get(a.getNumber());
        a.setBasePosition(vtx.getPosition());
    }
}
Also used : Vertex3d(maspack.geometry.Vertex3d) MeshBase(maspack.geometry.MeshBase) SkinMeshBase(artisynth.core.mechmodels.SkinMeshBase) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Example 8 with MeshBase

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

the class SkinMeshBody method initializeAttachments.

private void initializeAttachments() {
    MeshBase mesh = getMesh();
    int numVtxs = mesh.numVertices();
    myVertexAttachments.removeAll();
    myVertexAttachments.ensureCapacity(numVtxs);
}
Also used : MeshBase(maspack.geometry.MeshBase) SkinMeshBase(artisynth.core.mechmodels.SkinMeshBase) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Example 9 with MeshBase

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

the class SkinMeshBody method computeDisplacementAttachments.

/**
 * Computes displacement-based attachments for each vertex attachment in
 * this skin mesh.  For each vertex, the weights are determined using the
 * relative distances from the vertex to the surface meshes of each of the
 * controlling bodies (Frame, FemModel, etc.). Controlling bodies which
 * don't have a surface mesh are ignored.
 *
 * <p>
 * Bodies further away have a lower weighting. If <code>sigma</code>
 * is non-positive, the weighting is determined using an inverse-square
 * attenuation. Otherwise, the weighting is determined using a
 * Gaussian attention controlled by <code>sigma</code>.
 *
 * @param sigma if greater than 0, specifies a Gaussian weighting
 * attenuation.
 */
public void computeDisplacementAttachments(double sigma) {
    MeshBase mesh = getMesh();
    MeshDistCalc dcalc = new MeshDistCalc();
    clearAttachments();
    for (int i = 0; i < mesh.numVertices(); i++) {
        Vertex3d vtx = mesh.getVertices().get(i);
        dcalc.computeDistancesAndWeights(vtx.getPosition(), sigma);
        PointSkinAttachment a = dcalc.computeDisplacementAttachment();
        addAttachment(a);
    }
    myLastSigma = sigma;
}
Also used : Vertex3d(maspack.geometry.Vertex3d) MeshBase(maspack.geometry.MeshBase) SkinMeshBase(artisynth.core.mechmodels.SkinMeshBase) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Example 10 with MeshBase

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

the class FemMeshComp method setSurfaceRendering.

@Override
public void setSurfaceRendering(SurfaceRender mode) {
    SurfaceRender oldMode = getSurfaceRendering();
    super.setSurfaceRendering(mode);
    if (oldMode != mode) {
        if (myFem != null) {
            // paranoid: myFem should always be non-null here
            switch(mode) {
                case Strain:
                    myFem.setComputeNodalStrain(true);
                    myFem.updateStressAndStiffness();
                    break;
                case Stress:
                    myFem.setComputeNodalStress(true);
                    myFem.updateStressAndStiffness();
                    break;
                default:
                    {
                        myFem.setComputeNodalStrain(false);
                        myFem.setComputeNodalStress(false);
                        break;
                    }
            }
        }
        // save/restore original vertex colors
        MeshBase mesh = getMesh();
        if (mesh != null) {
            boolean oldStressOrStrain = isStressOrStrainRendering(oldMode);
            boolean newStressOrStrain = isStressOrStrainRendering(mode);
            if (newStressOrStrain != oldStressOrStrain) {
                if (newStressOrStrain) {
                    saveShading();
                    saveMeshColoring(mesh);
                    mesh.setVertexColoringEnabled();
                    mesh.setVertexColorMixing(ColorMixing.REPLACE);
                    myRenderProps.setShading(Shading.NONE);
                    // enable stress/strain rendering *after* vertex coloring set
                    // not sure we need this here
                    updateVertexColors();
                } else {
                    // disable stress/strain rendering *before* restoring colors
                    restoreMeshColoring(mesh);
                    restoreShading();
                }
            }
        }
    }
}
Also used : MeshBase(maspack.geometry.MeshBase) SurfaceRender(artisynth.core.femmodels.FemModel.SurfaceRender)

Aggregations

MeshBase (maspack.geometry.MeshBase)39 PolygonalMesh (maspack.geometry.PolygonalMesh)10 ContactPoint (artisynth.core.mechmodels.ContactPoint)5 Point (artisynth.core.mechmodels.Point)5 SkinMeshBase (artisynth.core.mechmodels.SkinMeshBase)5 FemMeshBase (artisynth.core.femmodels.FemMeshBase)3 Point (java.awt.Point)3 SurfaceRender (artisynth.core.femmodels.FemModel.SurfaceRender)2 PointAttachment (artisynth.core.mechmodels.PointAttachment)2 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)2 Color (java.awt.Color)2 File (java.io.File)2 PointMesh (maspack.geometry.PointMesh)2 Vertex3d (maspack.geometry.Vertex3d)2 XyzbReader (maspack.geometry.io.XyzbReader)2 VectorNd (maspack.matrix.VectorNd)2 RenderProps (maspack.render.RenderProps)2 ArgParser (argparser.ArgParser)1 FemNode (artisynth.core.femmodels.FemNode)1 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)1