Search in sources :

Example 21 with PointParticleAttachment

use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.

the class FemMeshComp method setVertexAttachment.

public void setVertexAttachment(int vidx, double[] weights, FemNode3d[] nodes) {
    if (weights.length > 1) {
        PointFem3dAttachment pattacher = new PointFem3dAttachment();
        pattacher.setFromNodes(nodes, weights);
        setVertexAttachment(vidx, pattacher);
    } else if (weights.length == 1) {
        PointParticleAttachment attacher = new PointParticleAttachment(nodes[0], null);
        setVertexAttachment(vidx, attacher);
    }
}
Also used : PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment)

Example 22 with PointParticleAttachment

use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.

the class FemMeshComp method getVertexMasters.

public void getVertexMasters(List<ContactMaster> mlist, Vertex3d vtx) {
    PointAttachment pa = getAttachment(vtx.getIndex());
    if (pa instanceof PointFem3dAttachment) {
        PointFem3dAttachment pfa = (PointFem3dAttachment) pa;
        FemNode[] masters = pfa.getNodes();
        for (int j = 0; j < masters.length; j++) {
            mlist.add(new ContactMaster(masters[j], pfa.getCoordinate(j)));
        }
    } else {
        PointParticleAttachment ppa = (PointParticleAttachment) pa;
        mlist.add(new ContactMaster((FemNode3d) ppa.getParticle(), 1));
    }
}
Also used : ContactMaster(artisynth.core.mechmodels.ContactMaster) PointAttachment(artisynth.core.mechmodels.PointAttachment) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Example 23 with PointParticleAttachment

use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.

the class FemMeshComp method scanAttachment.

protected void scanAttachment(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
    ArrayList<Double> weights = new ArrayList<Double>();
    rtok.scanToken('[');
    tokens.offer(ScanToken.BEGIN);
    while (ScanWriteUtils.scanAndStoreReference(rtok, tokens)) {
        weights.add(rtok.scanNumber());
    }
    if (rtok.ttype != ']') {
        throw new IOException("Expected ']', got " + rtok);
    }
    // while (rtok.nextToken() != ']') {
    // rtok.pushBack();
    // ScanWriteUtils.scanReferenceToken (rtok, tokens);
    // weights.add (rtok.scanNumber());
    // }
    // add null terminator
    tokens.offer(ScanToken.END);
    if (weights.size() == 1) {
        PointParticleAttachment ppa = new PointParticleAttachment();
        myVertexAttachments.add(ppa);
    } else {
        PointFem3dAttachment pfa = new PointFem3dAttachment();
        tokens.offer(new ObjectToken(ArraySupport.toDoubleArray(weights)));
        myVertexAttachments.add(pfa);
    }
}
Also used : ObjectToken(artisynth.core.util.ObjectToken) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment)

Example 24 with PointParticleAttachment

use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.

the class FemMeshComp method updateVertexColors.

protected void updateVertexColors() {
    if (mySurfaceRendering != SurfaceRender.Stress && mySurfaceRendering != SurfaceRender.Strain) {
        return;
    }
    if (myStressPlotRanging == Ranging.Auto) {
        myStressPlotRange.merge(myFem.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 FemNode3d) {
                    // paranoid!
                    FemNode3d node = (FemNode3d) 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;
            FemNode3d node = (FemNode3d) 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 : RenderProps(maspack.render.RenderProps) MeshBase(maspack.geometry.MeshBase) VectorNd(maspack.matrix.VectorNd) PointAttachment(artisynth.core.mechmodels.PointAttachment) PointParticleAttachment(artisynth.core.mechmodels.PointParticleAttachment) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point)

Example 25 with PointParticleAttachment

use of artisynth.core.mechmodels.PointParticleAttachment in project artisynth_core by artisynth.

the class MFreeMeshComp method getVertexMasters.

public void getVertexMasters(List<ContactMaster> mlist, Vertex3d vtx) {
    PointAttachment pa = getAttachment(vtx.getIndex());
    if (pa instanceof PointFem3dAttachment) {
        PointFem3dAttachment pfa = (PointFem3dAttachment) pa;
        FemNode[] masters = pfa.getNodes();
        for (int j = 0; j < masters.length; j++) {
            mlist.add(new ContactMaster(masters[j], pfa.getCoordinate(j)));
        }
    } else {
        PointParticleAttachment ppa = (PointParticleAttachment) pa;
        mlist.add(new ContactMaster((MFreeNode3d) ppa.getParticle(), 1));
    }
}
Also used : FemNode(artisynth.core.femmodels.FemNode) ContactMaster(artisynth.core.mechmodels.ContactMaster) 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

PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)31 ContactPoint (artisynth.core.mechmodels.ContactPoint)21 Point (artisynth.core.mechmodels.Point)21 PointAttachment (artisynth.core.mechmodels.PointAttachment)16 Vertex3d (maspack.geometry.Vertex3d)15 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)13 ArrayList (java.util.ArrayList)12 VectorNd (maspack.matrix.VectorNd)11 FemNode (artisynth.core.femmodels.FemNode)10 PolygonalMesh (maspack.geometry.PolygonalMesh)10 Point3d (maspack.matrix.Point3d)9 Face (maspack.geometry.Face)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)3 FemNode3d (artisynth.core.femmodels.FemNode3d)2 ContactMaster (artisynth.core.mechmodels.ContactMaster)2 ObjectToken (artisynth.core.util.ObjectToken)2 BVFeatureQuery (maspack.geometry.BVFeatureQuery)2 HalfEdge (maspack.geometry.HalfEdge)2 MeshBase (maspack.geometry.MeshBase)2