Search in sources :

Example 11 with MeshBase

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

the class FemMeshBase method setMeshFromInfo.

public void setMeshFromInfo() {
    // Overridden from super class. Is called by super.setMesh() and by scan
    // (whenever a mesh is scanned) to set mesh properties and auxiliary
    // data structures specific to the class.
    MeshBase mesh = getMesh();
    if (mesh != null) {
        mesh.setFixed(false);
        mesh.setColorsFixed(false);
        mesh.setColorInterpolation(getColorInterpolation());
    }
}
Also used : MeshBase(maspack.geometry.MeshBase) SkinMeshBase(artisynth.core.mechmodels.SkinMeshBase)

Example 12 with MeshBase

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

the class FemMeshBase method doSetMesh.

protected void doSetMesh(MeshBase mesh, String fileName, AffineTransform3dBase X) {
    MeshBase oldMesh = getMesh();
    if (oldMesh != null && isStressOrStrainRendering(mySurfaceRendering)) {
        restoreMeshColoring(oldMesh);
    }
    super.doSetMesh(mesh, fileName, X);
    if (isStressOrStrainRendering(mySurfaceRendering)) {
        saveMeshColoring(mesh);
        mesh.setVertexColoringEnabled();
        // not sure we need this here
        updateVertexColors();
    }
}
Also used : MeshBase(maspack.geometry.MeshBase) SkinMeshBase(artisynth.core.mechmodels.SkinMeshBase)

Example 13 with MeshBase

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

the class MeshBodyEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsMultipleSelection(selection, MeshComponent.class)) {
        if (containsSingleSelection(selection, MeshComponent.class)) {
            if (actionCommand == "Save local mesh as ...") {
                MeshComponent body = (MeshComponent) selection.get(0);
                MeshBase mesh = body.getMesh();
                EditorUtils.saveMesh(mesh, null);
            } else if (actionCommand == "Save world mesh as ...") {
                MeshComponent body = (MeshComponent) selection.get(0);
                MeshBase mesh = body.getMesh();
                EditorUtils.saveMesh(mesh, mesh != null ? mesh.getMeshToWorld() : null);
            } else if (actionCommand == "Add mesh inspector") {
                MeshComponent body = (MeshComponent) selection.get(0);
                MechModel mech = (MechModel) body.getGrandParent();
                EditablePolygonalMeshComp editMesh = new EditablePolygonalMeshComp((PolygonalMesh) body.getMesh());
                double size = RenderableUtils.getRadius(editMesh);
                RenderProps.setVisible(editMesh, true);
                RenderProps.setPointStyle(editMesh, Renderer.PointStyle.SPHERE);
                RenderProps.setPointRadius(editMesh, 0.05 * size);
                mech.addRenderable(editMesh);
            }
        }
    }
}
Also used : MeshComponent(artisynth.core.mechmodels.MeshComponent) MechModel(artisynth.core.mechmodels.MechModel) EditablePolygonalMeshComp(artisynth.core.renderables.EditablePolygonalMeshComp) MeshBase(maspack.geometry.MeshBase)

Example 14 with MeshBase

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

the class MeshComponent method setMeshFromInfo.

protected void setMeshFromInfo() {
    MeshBase mesh = getMesh();
    if (mesh != null) {
        mesh.setFixed(true);
        mesh.setColorInterpolation(getColorInterpolation());
        mesh.setVertexColorMixing(getVertexColorMixing());
    }
}
Also used : MeshBase(maspack.geometry.MeshBase)

Example 15 with MeshBase

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

the class MFreeMeshComp method updateVertexColors.

protected void updateVertexColors() {
    if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
        return;
    }
    if (myStressPlotRanging == Ranging.Auto) {
        myStressPlotRange.merge(myModel.getNodalPlotRange(mySurfaceRendering));
    }
    RenderProps rprops = getRenderProps();
    float alpha = (float) rprops.getAlpha();
    MeshBase mesh = getMesh();
    double sval = 0;
    for (int i = 0; i < myVertexAttachments.size(); i++) {
        PointAttachment attacher = myVertexAttachments.get(i);
        sval = 0;
        if (attacher instanceof PointFem3dAttachment) {
            PointFem3dAttachment pfa = (PointFem3dAttachment) attacher;
            FemNode[] nodes = pfa.getNodes();
            VectorNd weights = pfa.getCoordinates();
            for (int j = 0; j < nodes.length; j++) {
                if (nodes[j] instanceof MFreeNode3d) {
                    // paranoid!
                    MFreeNode3d node = (MFreeNode3d) nodes[j];
                    double w = weights.get(j);
                    if (mySurfaceRendering == SurfaceRender.Strain) {
                        sval += w * node.getVonMisesStrain();
                    } else if (mySurfaceRendering == SurfaceRender.Stress) {
                        sval += w * node.getVonMisesStress();
                    }
                }
            }
        } else if (attacher instanceof PointParticleAttachment) {
            PointParticleAttachment ppa = (PointParticleAttachment) attacher;
            MFreeNode3d node = (MFreeNode3d) ppa.getParticle();
            if (mySurfaceRendering == SurfaceRender.Strain) {
                sval = node.getVonMisesStrain();
            } else if (mySurfaceRendering == SurfaceRender.Stress) {
                sval = node.getVonMisesStress();
            }
        }
        double smin = myStressPlotRange.getLowerBound();
        double srng = myStressPlotRange.getRange();
        double c = (sval - smin) / srng;
        c = Math.max(0, Math.min(c, 1.0));
        myColorMap.getRGB(c, colorArray);
        mesh.setColor(i, colorArray[0], colorArray[1], colorArray[2], alpha);
    }
}
Also used : FemNode(artisynth.core.femmodels.FemNode) RenderProps(maspack.render.RenderProps) MeshBase(maspack.geometry.MeshBase) FemMeshBase(artisynth.core.femmodels.FemMeshBase) VectorNd(maspack.matrix.VectorNd) PointFem3dAttachment(artisynth.core.femmodels.PointFem3dAttachment) PointAttachment(artisynth.core.mechmodels.PointAttachment) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

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