Search in sources :

Example 46 with MechModel

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

the class FemModel3dEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsSingleSelection(selection, FemModel3d.class)) {
        FemModel3d model = (FemModel3d) selection.get(0);
        if (actionCommand == "Add FemMarkers ...") {
            if (myEditManager.acquireEditLock()) {
                Fem3dMarkerAgent agent = new Fem3dMarkerAgent(myMain, model);
                agent.show(popupBounds);
            }
        } else if (actionCommand == "Rebuild surface mesh") {
            rebuildSurfaceMesh(model);
        } else if (actionCommand == "Add new surface mesh") {
            addNewSurfaceMesh(model);
        } else if (actionCommand == "Save surface mesh ...") {
            EditorUtils.saveMesh(model.getSurfaceMesh(), /*Transform= */
            null);
        } else if (actionCommand == "Save mesh as Ansys file...") {
            EditorUtils.saveMeshAsAnsysFile(model);
        } else if (actionCommand == "Attach particles ...") {
            if (myEditManager.acquireEditLock()) {
                // XXX should be more general than this ... what if mechModel
                // is a sub model?
                MechModel mech = (MechModel) model.getGrandParent();
                myMain.getSelectionManager().clearSelections();
                AttachParticleFemAgent agent = new AttachParticleFemAgent(myMain, mech, model);
                agent.show(popupBounds);
            }
        }
    } else if (containsMultipleCommonParentSelection(selection, HexElement.class)) {
        if (actionCommand == "Subdivide elements") {
            FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
            for (ModelComponent c : selection) {
                mod.subdivideHex((HexElement) c);
            }
        }
    }
    if (actionCommand == "Rebuild surface mesh for selected elements") {
        FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
        rebuildSurfaceMeshForSelectedElements(mod);
    } else if (actionCommand == "Add new surface mesh for selected elements") {
        FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
        addNewSurfaceMeshForSelectedElements(mod);
    }
}
Also used : HexElement(artisynth.core.femmodels.HexElement) MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 47 with MechModel

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

the class FrameMarkerEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsSingleSelection(selection, FrameMarker.class)) {
        if (actionCommand == "Add PlanarConnector") {
            FrameMarker mkr = (FrameMarker) selection.get(0);
            RigidTransform3d XPW = new RigidTransform3d();
            XPW.p.set(mkr.getPosition());
            if (mkr.getFrame() instanceof RigidBody && mkr.getGrandParent() instanceof MechModel) {
                PlanarConnector pc = new PlanarConnector();
                pc.set((RigidBody) mkr.getFrame(), mkr.getLocation(), Vector3d.Z_UNIT);
                pc.setPlaneSize(getDefaultPlaneSize());
                ((MechModel) mkr.getGrandParent()).addBodyConnector(pc);
            } else {
                System.out.println("Unable to create PlanarConnector from selected FrameMarker");
            }
        }
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) MechModel(artisynth.core.mechmodels.MechModel) FrameMarker(artisynth.core.mechmodels.FrameMarker) PlanarConnector(artisynth.core.mechmodels.PlanarConnector) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 48 with MechModel

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

the class MechModelAgent method createAndAddMechModel.

private void createAndAddMechModel() {
    MechModel model = new MechModel();
    setProperties(model, getPrototypeComponent(myComponentType));
    // update properties in the prototype as well ...
    setProperties(myPrototype, myPrototype);
    addComponent(new AddComponentsCommand("add MechModel", model, (MutableCompositeComponent<?>) myRootModel.models()));
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) MutableCompositeComponent(artisynth.core.modelbase.MutableCompositeComponent)

Example 49 with MechModel

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

the class RigidBodyEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    if (containsMultipleSelection(selection, RigidBody.class)) {
        actions.add(this, "Select markers");
        if (containsSingleSelection(selection, RigidBody.class)) {
            RigidBody body = (RigidBody) selection.get(0);
            actions.add(this, "Edit geometry and inertia ...", EXCLUSIVE);
            actions.add(this, "Save mesh as ...");
            if (body.getGrandParent() instanceof MechModel) {
                actions.add(this, "Attach particles ...", EXCLUSIVE);
            }
            if (body.getSurfaceMesh() != null) {
                actions.add(this, "Add mesh inspector");
            }
        }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 50 with MechModel

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

the class TransverseIsotropy method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = new MechModel("mech");
    addModel(mech);
    double h = 0.1;
    double r = 0.005;
    RigidBody rb = RigidBody.createBox("box", 2 * r, 2 * r, 2 * r, 100, true);
    mech.addRigidBody(rb);
    rb.transformGeometry(new RigidTransform3d(new Vector3d(0, 0, -h / 2 - r), AxisAngle.IDENTITY));
    FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
    fem.setDensity(1000);
    mech.addModel(fem);
    TransverseLinearMaterial mat = new TransverseLinearMaterial();
    mat.setYoungsModulus(50000, 50000);
    mat.setPoissonsRatio(0.45, 0.45);
    double G = 50000 / (2 * (1 + 0.45));
    mat.setShearModulus(G);
    fem.setMaterial(mat);
    fem.setName("fem");
    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);
        } else if (node.getPosition().z < -h / 2 + eps) {
            PointAttachment pa = rb.createPointAttachment(node);
            mech.addAttachment(pa);
        }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) Vector3d(maspack.matrix.Vector3d) FemNode3d(artisynth.core.femmodels.FemNode3d) RigidBody(artisynth.core.mechmodels.RigidBody) PointAttachment(artisynth.core.mechmodels.PointAttachment) TransverseLinearMaterial(artisynth.core.materials.TransverseLinearMaterial)

Aggregations

MechModel (artisynth.core.mechmodels.MechModel)59 RigidBody (artisynth.core.mechmodels.RigidBody)25 RigidTransform3d (maspack.matrix.RigidTransform3d)19 FemModel3d (artisynth.core.femmodels.FemModel3d)14 FemNode3d (artisynth.core.femmodels.FemNode3d)8 Particle (artisynth.core.mechmodels.Particle)8 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Vector3d (maspack.matrix.Vector3d)8 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)7 LinearMaterial (artisynth.core.materials.LinearMaterial)6 FrameMarker (artisynth.core.mechmodels.FrameMarker)6 CollisionManager (artisynth.core.mechmodels.CollisionManager)5 Color (java.awt.Color)5 AxialSpring (artisynth.core.mechmodels.AxialSpring)4 BodyConnector (artisynth.core.mechmodels.BodyConnector)4 WayPoint (artisynth.core.probes.WayPoint)4 Point3d (maspack.matrix.Point3d)4 MultiPointSpring (artisynth.core.mechmodels.MultiPointSpring)3 PlanarConnector (artisynth.core.mechmodels.PlanarConnector)3 FemElement3d (artisynth.core.femmodels.FemElement3d)2