Search in sources :

Example 21 with FemNode3d

use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.

the class LinearAuxiliaryTest method createCylinder.

FemModel3d createCylinder(double h, double r) {
    FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
    fem.setDensity(1000);
    fem.setSurfaceRendering(SurfaceRender.Shaded);
    RenderProps.setFaceColor(fem, Color.ORANGE);
    RenderProps.setVisible(fem.getElements(), false);
    double eps = 1e-10;
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().z < -h / 2 + eps) {
            node.setDynamic(false);
        }
    }
    return fem;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 22 with FemNode3d

use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.

the class LinearAuxiliaryTest method createHexGrid.

static FemModel3d createHexGrid(double wx, double wy, double wz, int nx, int ny, int nz) {
    FemModel3d fem = FemFactory.createHexGrid(null, wx, wy, wz, nx, ny, nz);
    fem.setDensity(1000);
    fem.setSurfaceRendering(SurfaceRender.Shaded);
    RenderProps.setFaceColor(fem, Color.ORANGE);
    RenderProps.setVisible(fem.getElements(), false);
    double eps = 1e-10;
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().x < -wx / 2 + eps) {
            node.setDynamic(false);
        }
    }
    return fem;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 23 with FemNode3d

use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.

the class SimpleCollide method setBottomObject.

private void setBottomObject(Collidable comp, ObjectType type) {
    Renderable rcomp = (Renderable) comp;
    ((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myBottomScale));
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
            {
                RenderProps.setPointColor(rcomp, Color.green);
                // fix the lower nodes
                Point3d min = new Point3d();
                RenderableUtils.getBounds(rcomp, min, null);
                FemModel3d fem = (FemModel3d) comp;
                fem.getSurfaceMesh();
                for (FemNode3d n : fem.getNodes()) {
                    if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.5)) {
                        n.setDynamic(false);
                    }
                }
                fem.resetRestPosition();
                break;
            }
        case FemCube:
            {
                RenderProps.setPointColor(rcomp, Color.green);
                // fix the lower nodes
                Point3d min = new Point3d();
                RenderableUtils.getBounds(rcomp, min, null);
                FemModel3d fem = (FemModel3d) comp;
                fem.getSurfaceMesh();
                for (FemNode3d n : fem.getNodes()) {
                    if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.1)) {
                        n.setDynamic(false);
                    }
                }
                // RenderProps.setAlpha (rcomp, 0.3);
                fem.resetRestPosition();
                break;
            }
        case Box:
            {
                ((RigidBody) comp).setDynamic(false);
                ((RigidBody) comp).setDistanceGridRes(new Vector3i(10, 5, 5));
                break;
            }
        case Molar:
            {
                ((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, -1, 0, Math.toRadians(172.09)));
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        case Bin:
            {
                ((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, 0, 0, 0));
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        case Paw:
        case House:
            {
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
    myBottomObject = comp;
    myBottomType = type;
}
Also used : TransformableGeometry(artisynth.core.modelbase.TransformableGeometry) RigidTransform3d(maspack.matrix.RigidTransform3d) Renderable(maspack.render.Renderable) FemModel3d(artisynth.core.femmodels.FemModel3d) Point3d(maspack.matrix.Point3d) FemNode3d(artisynth.core.femmodels.FemNode3d) Vector3i(maspack.matrix.Vector3i) InternalErrorException(maspack.util.InternalErrorException)

Example 24 with FemNode3d

use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.

the class FemBeamWithBlock method build.

public void build(String[] args) throws IOException {
    // Build simple FemBeam
    super.build(args);
    // Create a rigid block and move to the side of FEM
    RigidBody block = RigidBody.createBox("block", width / 2, 1.2 * width, 1.2 * width, 2 * density);
    mech.addRigidBody(block);
    block.setPose(new RigidTransform3d(length / 2 + width / 4, 0, 0));
    // Attach right-side nodes to rigid block
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().x >= length / 2 - EPS) {
            mech.addAttachment(new PointFrameAttachment(block, node));
        }
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) FemNode3d(artisynth.core.femmodels.FemNode3d) RigidBody(artisynth.core.mechmodels.RigidBody) PointFrameAttachment(artisynth.core.mechmodels.PointFrameAttachment)

Example 25 with FemNode3d

use of artisynth.core.femmodels.FemNode3d in project artisynth_core by artisynth.

the class FemBeamTest method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    mech = new MechModel("mech");
    addModel(mech);
    fems = new RenderableComponentList<>(FemModel3d.class);
    FemModel3d tet = FemFactory.createTetGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    tet.setName("tet");
    fems.add(tet);
    FemModel3d pyr = FemFactory.createPyramidGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    pyr.setName("pyr");
    fems.add(pyr);
    FemModel3d wed = FemFactory.createWedgeGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    wed.setName("wed");
    fems.add(wed);
    FemModel3d hex = FemFactory.createHexGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    hex.setName("hex");
    fems.add(hex);
    FemModel3d qtet = FemFactory.createQuadtetGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qtet.setName("qtet");
    fems.add(qtet);
    FemModel3d qpyr = FemFactory.createQuadpyramidGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qpyr.setName("qpyr");
    fems.add(qpyr);
    FemModel3d qwed = FemFactory.createQuadwedgeGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qwed.setName("qwed");
    fems.add(qwed);
    FemModel3d qhex = FemFactory.createQuadhexGrid(null, widthX, widthY, widthZ, numX, numY, numZ);
    qhex.setName("qhex");
    fems.add(qhex);
    // freeze lhs nodes
    double eps = 1e-10;
    for (FemModel3d fem : fems) {
        for (FemNode3d node : fem.getNodes()) {
            if (node.getRestPosition().x < -widthX / 2 + eps) {
                node.setDynamic(false);
            }
        }
    }
    // distribute
    double delta = widthY * 0.25;
    RigidTransform3d translate = new RigidTransform3d();
    for (FemModel3d fem : fems) {
        fem.transformGeometry(translate);
        translate.p.y += widthY + delta;
    }
    mech.add(fems);
    // render properties
    int nfems = fems.size();
    int ifem = 0;
    for (FemModel3d fem : fems) {
        fem.setSurfaceRendering(SurfaceRender.Shaded);
        float h = (float) ifem / nfems;
        RenderProps.setFaceColor(fem, Color.getHSBColor(h, 1.0f, 1.0f));
        ++ifem;
    }
    setMaterial(createDefaultMaterial());
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Aggregations

FemNode3d (artisynth.core.femmodels.FemNode3d)38 FemModel3d (artisynth.core.femmodels.FemModel3d)12 Point3d (maspack.matrix.Point3d)12 RigidTransform3d (maspack.matrix.RigidTransform3d)9 FemElement3d (artisynth.core.femmodels.FemElement3d)8 MechModel (artisynth.core.mechmodels.MechModel)8 Point (artisynth.core.mechmodels.Point)7 RigidBody (artisynth.core.mechmodels.RigidBody)7 Vector3d (maspack.matrix.Vector3d)6 ArrayList (java.util.ArrayList)5 FemMarker (artisynth.core.femmodels.FemMarker)4 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)4 VectorNd (maspack.matrix.VectorNd)4 TetElement (artisynth.core.femmodels.TetElement)3 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)3 LinkedList (java.util.LinkedList)3 FemNode (artisynth.core.femmodels.FemNode)2 HexElement (artisynth.core.femmodels.HexElement)2 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)2 PyramidElement (artisynth.core.femmodels.PyramidElement)2