Search in sources :

Example 1 with SurfaceRender

use of artisynth.core.femmodels.FemModel.SurfaceRender 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)

Example 2 with SurfaceRender

use of artisynth.core.femmodels.FemModel.SurfaceRender in project artisynth_core by artisynth.

the class MFreeMeshComp method setSurfaceRendering.

@Override
public void setSurfaceRendering(SurfaceRender mode) {
    SurfaceRender oldMode = getSurfaceRendering();
    super.setSurfaceRendering(mode);
    if (oldMode != mode) {
        if (myModel != null) {
            // paranoid: myFem should always be non-null here
            switch(mode) {
                case Strain:
                    myModel.setComputeNodalStrain(true);
                    myModel.updateStressAndStiffness();
                    break;
                case Stress:
                    myModel.setComputeNodalStress(true);
                    myModel.updateStressAndStiffness();
                    break;
                default:
                    {
                        myModel.setComputeNodalStrain(false);
                        myModel.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) FemMeshBase(artisynth.core.femmodels.FemMeshBase) SurfaceRender(artisynth.core.femmodels.FemModel.SurfaceRender)

Aggregations

SurfaceRender (artisynth.core.femmodels.FemModel.SurfaceRender)2 MeshBase (maspack.geometry.MeshBase)2 FemMeshBase (artisynth.core.femmodels.FemMeshBase)1